как закрыть окно имгуи если оно не закрывается

Kegwineye.

Участник
Автор темы
478
20
столкнулся с проблемой, что при нажатии на крестик в imgui не закрывается само окно. код внизу.


require "lib.moonloader"
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'C1251'
u8 = encoding.UTF8

local tag = "[My First Script]:"
local label = 0
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local menu = 1

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

local enabel1 = imgui.ImBool(false)
local checkbox2 = imgui.ImBool(false)
local checkbox3 = imgui.ImBool(false)

-- for combo
local combo_select = imgui.ImInt(1)
local arr_str = {"test1", "test2", "test3"}

function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end

sampRegisterChatCommand("hel", cmdimgui)

handle, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
nick = sampGetPlayerNickname(id)

imgui.Process = false

while true do
wait(0)

if enabel1.v then
for handle, v in pairs(getAllObjects()) do
local asd
if sampGetObjectSampIdByHandle(v) ~= -1 then
asd = sampGetObjectSampIdByHandle(v)
end
if isObjectOnScreen(v) then
local result, oX, oY, oZ = getObjectCoordinates(v)
local x1, y1 = convert3DCoordsToScreen(oX,oY,oZ)
local objmodel = getObjectModel(v)
local x2,y2,z2 = getCharCoordinates(PLAYER_PED)
local x10, y10 = convert3DCoordsToScreen(x2,y2,z2)
distance = string.format("%.0f", getDistanceBetweenCoords3d(oX,oY,oZ, x2, y2, z2))
if objmodel == 3930 then renderDrawLine(x10, y10, x1, y1, 2, 0xFFFFFF) renderFontDrawText(font,"{FFFF00}Resource:FF0000}"..distance, x1, y1, -1) end
end
end
end
end -- function
end

if main_window_state.v == false then
imgui.Process = false
end
function cmdimgui()
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end

function imgui.OnDrawFrame()
imgui.Begin("Start imgui", main_window_state)
imgui.BeginChild("##left", imgui.ImVec2(200, 85), true)
if imgui.Button('Menu', imgui.ImVec2(180, 20)) then menu = 1 end
if imgui.Button('Settings', imgui.ImVec2(180, 20)) then menu = 2 end
if imgui.Button('Author', imgui.ImVec2(180, 20)) then menu = 3 end

imgui.EndChild()

imgui.SameLine()

imgui.BeginChild("##right", imgui.ImVec2(400, 150), true)
if menu == 1 then
imgui.Text('Wall Hack')
imgui.Checkbox('Resource', enabel1)
end
if menu == 2 then
imgui.Text('Settings')
imgui.Combo("", combo_select, arr_str, #arr_str)
end
if menu == 3 then
imgui.Text('Автором скрипта является - han')
end
imgui.EndChild()
imgui.End()
end
-- end тут не нужен