script_name("Сотрудники")
script_author("Sanchez.")
script_description("Сотрудники")
require "lib.moonloader"
local imgui = require 'imgui'
local inicfg = require 'inicfg'
local encoding = require 'encoding'
local ia = require 'imgui_addons'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local mainIni = inicfg.load({
config = {
rang1 = "0",
name1 = "",
vig1 = 0,
rang2 = "0",
name2 = "",
vig2 = 0,
rang3 = "0",
name3 = "",
vig3 = 0,
rang4 = "0",
name4 = "",
vig4 = 0,
rang5 = "0",
name5 = "",
vig5 = 0,
rang6 = "0",
name6 = "",
vig6 = 0,
rang7 = "0",
name7 = "",
vig7 = 0,
}
}, "Sotrudniki")
--[[local rang1 = imgui.ImBool(mainIni.config.rang1)
local name1 = imgui.ImBool(mainIni.config.name1)
local vig1 = imgui.ImBool(mainIni.config.vig1)--]]
local rang1 = imgui.ImInt(mainIni.config.rang1)
local name1 = imgui.ImBuffer(tostring(mainIni.config.name1), 300)
local vig1 = imgui.ImInt(mainIni.config.vig1)
local rang2 = imgui.ImInt(mainIni.config.rang2)
local name2 = imgui.ImBuffer(tostring(mainIni.config.name2), 300)
local vig2 = imgui.ImInt(mainIni.config.vig2)
local rang3 = imgui.ImInt(mainIni.config.rang3)
local name3 = imgui.ImBuffer(tostring(mainIni.config.name3), 300)
local vig3 = imgui.ImInt(mainIni.config.vig3)
local rang4 = imgui.ImInt(mainIni.config.rang4)
local name4 = imgui.ImBuffer(tostring(mainIni.config.name4), 300)
local vig4 = imgui.ImInt(mainIni.config.vig4)
local rang5 = imgui.ImInt(mainIni.config.rang5)
local name5 = imgui.ImBuffer(tostring(mainIni.config.name5), 300)
local vig5 = imgui.ImInt(mainIni.config.vig5)
local rang6 = imgui.ImInt(mainIni.config.rang6)
local name6 = imgui.ImBuffer(tostring(mainIni.config.name6), 300)
local vig6 = imgui.ImInt(mainIni.config.vig6)
local rang7 = imgui.ImInt(mainIni.config.rang7)
local name7 = imgui.ImBuffer(tostring(mainIni.config.name7), 300)
local vig7 = imgui.ImInt(mainIni.config.vig7)
--[[function apply_custom_style()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
style.WindowRounding = 9.0
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
style.ChildWindowRounding = 2.0
style.FrameRounding = 4.0
style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
style.ScrollbarSize = 13.0
style.ScrollbarRounding = 0
style.GrabMinSize = 8.0
style.GrabRounding = 4.0
colors[clr.FrameBg] = ImVec4(0.16, 0.29, 0.48, 0.54)
colors[clr.FrameBgHovered] = ImVec4(0.26, 0.59, 0.98, 0.40)
colors[clr.FrameBgActive] = ImVec4(0.26, 0.59, 0.98, 0.67)
colors[clr.TitleBg] = ImVec4(0.04, 0.04, 0.04, 1.00)
colors[clr.TitleBgActive] = ImVec4(0.16, 0.29, 0.48, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
colors[clr.CheckMark] = ImVec4(0.26, 0.59, 0.98, 1.00)
colors[clr.SliderGrab] = ImVec4(0.24, 0.52, 0.88, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.26, 0.59, 0.98, 1.00)
colors[clr.Button] = ImVec4(0.26, 0.59, 0.98, 0.40)
colors[clr.ButtonHovered] = ImVec4(0.26, 0.59, 0.98, 1.00)
colors[clr.ButtonActive] = ImVec4(0.06, 0.53, 0.98, 1.00)
colors[clr.Header] = ImVec4(0.26, 0.59, 0.98, 0.31)
colors[clr.HeaderHovered] = ImVec4(0.26, 0.59, 0.98, 0.80)
colors[clr.HeaderActive] = ImVec4(0.26, 0.59, 0.98, 1.00)
colors[clr.Separator] = colors[clr.Border]
colors[clr.SeparatorHovered] = ImVec4(0.26, 0.59, 0.98, 0.78)
colors[clr.SeparatorActive] = ImVec4(0.26, 0.59, 0.98, 1.00)
colors[clr.ResizeGrip] = ImVec4(0.26, 0.59, 0.98, 0.25)
colors[clr.ResizeGripHovered] = ImVec4(0.26, 0.59, 0.98, 0.67)
colors[clr.ResizeGripActive] = ImVec4(0.26, 0.59, 0.98, 0.95)
colors[clr.TextSelectedBg] = ImVec4(0.26, 0.59, 0.98, 0.35)
colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.TextDisabled] = ImVec4(0.50, 0.50, 0.50, 1.00)
colors[clr.WindowBg] = ImVec4(0.06, 0.06, 0.06, 0.94)
colors[clr.ChildWindowBg] = ImVec4(1.00, 1.00, 1.00, 0.00)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
colors[clr.ComboBg] = colors[clr.PopupBg]
colors[clr.Border] = ImVec4(0.43, 0.43, 0.50, 0.50)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.MenuBarBg] = ImVec4(0.14, 0.14, 0.14, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53)
colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.51, 0.51, 0.51, 1.00)
colors[clr.CloseButton] = ImVec4(0.41, 0.41, 0.41, 0.50)
colors[clr.CloseButtonHovered] = ImVec4(0.98, 0.39, 0.36, 1.00)
colors[clr.CloseButtonActive] = ImVec4(0.98, 0.39, 0.36, 1.00)
colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00)
colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 1.00)
colors[clr.PlotHistogram] = ImVec4(0.90, 0.70, 0.00, 1.00)
colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
colors[clr.ModalWindowDarkening] = ImVec4(0.80, 0.80, 0.80, 0.35)
end
apply_custom_style()--]]
function style() -- стиль имгуи
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = ImVec2(10, 10)
style.WindowRounding = 10
style.ChildWindowRounding = 2
style.FramePadding = ImVec2(5, 4)
style.FrameRounding = 11
style.ItemSpacing = ImVec2(4, 4)
style.TouchExtraPadding = ImVec2(0, 0)
style.IndentSpacing = 21
style.ScrollbarSize = 16
style.ScrollbarRounding = 16
style.GrabMinSize = 11
style.GrabRounding = 16
style.WindowTitleAlign = ImVec2(0.5, 0.5)
style.ButtonTextAlign = ImVec2(0.5, 0.5)
colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.TextDisabled] = ImVec4(0.73, 0.75, 0.74, 1.00)
colors[clr.WindowBg] = ImVec4(0.09, 0.09, 0.09, 0.94)
colors[clr.ChildWindowBg] = ImVec4(10.00, 10.00, 10.00, 0.01)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
colors[clr.Border] = ImVec4(0.20, 0.20, 0.20, 0.50)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.00, 0.39, 1.00, 0.65)
colors[clr.FrameBgHovered] = ImVec4(0.11, 0.40, 0.69, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.11, 0.40, 0.69, 1.00)
colors[clr.TitleBg] = ImVec4(0.00, 0.00, 0.00, 1.00)
colors[clr.TitleBgActive] = ImVec4(0.00, 0.24, 0.54, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.22, 1.00, 0.67)
colors[clr.MenuBarBg] = ImVec4(0.08, 0.44, 1.00, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53)
colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.51, 0.51, 0.51, 1.00)
colors[clr.ComboBg] = ImVec4(0.20, 0.20, 0.20, 0.99)
colors[clr.CheckMark] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.SliderGrab] = ImVec4(0.34, 0.67, 1.00, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.84, 0.66, 0.66, 1.00)
colors[clr.Button] = ImVec4(0.00, 0.39, 1.00, 0.65)
colors[clr.ButtonHovered] = ImVec4(0.00, 0.64, 1.00, 0.65)
colors[clr.ButtonActive] = ImVec4(0.00, 0.53, 1.00, 0.50)
colors[clr.Header] = ImVec4(0.00, 0.62, 1.00, 0.54)
colors[clr.HeaderHovered] = ImVec4(0.00, 0.36, 1.00, 0.65)
colors[clr.HeaderActive] = ImVec4(0.00, 0.53, 1.00, 0.00)
colors[clr.Separator] = ImVec4(0.43, 0.43, 0.50, 0.50)
colors[clr.SeparatorHovered] = ImVec4(0.71, 0.39, 0.39, 0.54)
colors[clr.SeparatorActive] = ImVec4(0.71, 0.39, 0.39, 0.54)
colors[clr.ResizeGrip] = ImVec4(0.71, 0.39, 0.39, 0.54)
colors[clr.ResizeGripHovered] = ImVec4(0.84, 0.66, 0.66, 0.66)
colors[clr.ResizeGripActive] = ImVec4(0.84, 0.66, 0.66, 0.66)
colors[clr.CloseButton] = ImVec4(0.41, 0.41, 0.41, 1.00)
colors[clr.CloseButtonHovered] = ImVec4(0.98, 0.39, 0.36, 1.00)
colors[clr.CloseButtonActive] = ImVec4(0.98, 0.39, 0.36, 1.00)
colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00)
colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 1.00)
colors[clr.PlotHistogram] = ImVec4(0.90, 0.70, 0.00, 1.00)
colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
colors[clr.TextSelectedBg] = ImVec4(0.26, 0.59, 0.98, 0.35)
colors[clr.ModalWindowDarkening] = ImVec4(0.80, 0.80, 0.80, 0.35)
end
style()
local fontsize = nil
function imgui.BeforeDrawFrame()
if fontsize == nil then
fontsize = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\trebucbd.ttf', 20.0, nil, imgui.GetIO().Fonts:GetGlyphRangesCyrillic()) -- вместо 30 любой нужный размер
end
end
function imgui.CenterButton(text) -- закрытие попупа
local width = imgui.GetWindowWidth()
local calc = imgui.CalcTextSize(text)
imgui.SetCursorPosX( width / 2 - calc.x / 2 )
if text == 'OK' then
if imgui.Button(text) then imgui.CloseCurrentPopup() end
elseif text == u8'Принять' then
if imgui.Button(text) then oldVersion = false imgui.CloseCurrentPopup() end
else
imgui.Button(text)
end
end
if not doesFileExist('moonloader/config/Sotrudniki.ini') then inicfg.save(mainIni, 'Sotrudniki.ini') end
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("sotrudniki", function()
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end)
while true do
wait(0)
if main_window_state.v == false then
imgui.Process = false
end
end
imgui.Process = false
end
function imgui.OnDrawFrame()
imgui.SetNextWindowSize(imgui.ImVec2(700, 300), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.Begin(u8'Приложение "Сотрудники"', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
imgui.Text("") imgui.Text("")
imgui.SameLine(70)
imgui.PushFont(fontsize)
imgui.Text(u8"Список сотрудников ст. состава")
imgui.PopFont()
imgui.BeginChild("aboba", imgui.ImVec2(400, 150), true)
imgui.Text(u8"Ранг Никнейм Выговоры")
imgui.Separator()
imgui.Columns(3, "blabla", true)
if imgui.Selectable(u8:decode(mainIni.config.rang1)) then
--[[if mainIni.config.rang1 == "-" then
mainIni.config.rang1 = "aboba"
inicfg.save(mainIni, "Sotrudniki.ini")--]]
--end
imgui.OpenPopup(u8"abobus")
end
if imgui.BeginPopup(u8"abobus", imgui.WindowFlags.NoResize) then
imgui.Text(u8"Введите ранг сотрудника")
--imgui.PushItemWidth(100)
imgui.InputInt('', rang1)
save()
--imgui.PopItemWidth()
imgui.CenterButton(u8"Принять")
--mainIni.config.rang1 = rang1.v
--inicfg.save(mainIni, "Sotrudniki.ini")
imgui.EndPopup()
end
imgui.NextColumn()
if imgui.Selectable(u8:decode(u8(mainIni.config.name1))) then
imgui.OpenPopup(u8"abobus2.0")
end
if imgui.BeginPopup(u8"abobus2.0", imgui.WindowFlags.NoResize) then
imgui.Text(u8"Введите имя сотрудника")
--imgui.PushItemWidth(100)
imgui.InputText(u8'', name1)
save()
--imgui.PopItemWidth()
imgui.CenterButton(u8"Принять")
--mainIni.config.rang1 = rang1.v
--inicfg.save(mainIni, "Sotrudniki.ini")
imgui.EndPopup()
end
imgui.NextColumn()
if imgui.Selectable(u8:decode(mainIni.config.vig1) .. "/3") then
imgui.OpenPopup(u8"abobus2.1")
end
if imgui.BeginPopup(u8"abobus2.1", imgui.WindowFlags.NoResize) then
imgui.Text(u8"Введите количество выговор у сотрудника")
--imgui.PushItemWidth(100)
imgui.InputInt(u8'', vig1)
save()
--imgui.PopItemWidth()
imgui.CenterButton(u8"Принять")
--mainIni.config.rang1 = rang1.v
--inicfg.save(mainIni, "Sotrudniki.ini")
imgui.EndPopup()
end
imgui.Separator()
----------------------------------------------------------------------
if imgui.Selectable(u8:decode(mainIni.config.rang2)) then
--[[if mainIni.config.rang1 == "-" then
mainIni.config.rang1 = "aboba"
inicfg.save(mainIni, "Sotrudniki.ini")--]]
--end
imgui.OpenPopup(u8"abobus13")
end
if imgui.BeginPopup(u8"abobus13", imgui.WindowFlags.NoResize) then
imgui.Text(u8"Введите ранг сотрудника")
--imgui.PushItemWidth(100)
imgui.InputInt(' ', rang2)
save()
--imgui.PopItemWidth()
imgui.CenterButton(u8"Принять")
--mainIni.config.rang1 = rang1.v
--inicfg.save(mainIni, "Sotrudniki.ini")
imgui.EndPopup()
end
imgui.NextColumn()
if imgui.Selectable(u8:decode(u8(mainIni.config.name2))) then
imgui.OpenPopup(u8"abobus2.01")
end
if imgui.BeginPopup(u8"abobus2.01", imgui.WindowFlags.NoResize) then
imgui.Text(u8"Введите имя сотрудника")
--imgui.PushItemWidth(100)
imgui.InputText(u8'', name2)
save()
--imgui.PopItemWidth()
imgui.CenterButton(u8"Принять")
--mainIni.config.rang1 = rang1.v
--inicfg.save(mainIni, "Sotrudniki.ini")
imgui.EndPopup()
end
imgui.NextColumn()
if imgui.Selectable(u8:decode(mainIni.config.vig2) .. "/3") then
imgui.OpenPopup(u8"abobus12.1")
end
if imgui.BeginPopup(u8"abobus12.1", imgui.WindowFlags.NoResize) then
imgui.Text(u8"Введите количество выговор у сотрудника")
--imgui.PushItemWidth(100)
imgui.InputInt(u8'', vig2)
save()
--imgui.PopItemWidth()
imgui.CenterButton(u8"Принять")
--mainIni.config.rang1 = rang1.v
--inicfg.save(mainIni, "Sotrudniki.ini")
imgui.EndPopup()
end
imgui.EndChild()
imgui.End()
end
function save()
mainIni.config.rang1 = rang1.v
mainIni.config.name1 = name1.v
mainIni.config.vig1 = vig1.v
mainIni.config.rang2 = rang2.v
mainIni.config.name2 = name2.v
mainIni.config.vig2 = vig2.v
mainIni.config.rang3 = rang3.v
mainIni.config.name3 = name3.v
mainIni.config.vig3 = vig3.v
mainIni.config.rang4 = rang4.v
mainIni.config.name4 = name4.v
mainIni.config.vig4 = vig4.v
mainIni.config.rang5 = rang5.v
mainIni.config.name5 = name5.v
mainIni.config.vig5 = vig5.v
mainIni.config.rang6 = rang6.v
mainIni.config.name6 = name6.v
mainIni.config.vig6 = vig6.v
mainIni.config.rang7 = rang7.v
mainIni.config.name7 = name7.v
mainIni.config.vig7 = vig7.v
--mainIni.config.name1 = name1.v
--mainIni.config.vig1 = vig1.v
inicfg.save(mainIni, "Sotrudniki.ini")
end