local imgui = require 'imgui'
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
local state = false
local themes = import 'resource/imgui_themes.lua'
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand('imgui', cmd_test)
imgui.SwitchContext()
themes.SwitchColorTheme(4) -- изначальная тема
while true do
wait(0)
if main_window_state.v == false then
imgui.Process = false
end
end
end
function cmd_test()
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end
function imgui.OnDrawFrame()
local ex, ey = getScreenResolution()
imgui.SetNextWindowSize(imgui.ImVec2(400, 200), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2(ex / 2, ey / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.Begin('Imgui window ', main_window_state)
if imgui.Button('BLUE') then -- при нажатии на кнопку будет эта тема
imgui.SwitchContext()
themes.SwitchColorTheme(1)
end
imgui.SameLine()
if imgui.Button('RED') then
imgui.SwitchContext()
themes.SwitchColorTheme(2)
end
imgui.SameLine()
if imgui.Button('BROWN') then
imgui.SwitchContext()
themes.SwitchColorTheme(3)
end
imgui.SameLine()
if imgui.Button('AQUA') then
imgui.SwitchContext()
themes.SwitchColorTheme(4)
end
imgui.SameLine()
if imgui.Button('BLACK') then
imgui.SwitchContext()
themes.SwitchColorTheme(5)
end
imgui.SameLine()
if imgui.Button('PURPLE') then
imgui.SwitchContext()
themes.SwitchColorTheme(6)
end
imgui.SameLine()
if imgui.Button('ORANGE') then
imgui.SwitchContext()
themes.SwitchColorTheme(7)
end
imgui.End()
end