Несколько окон imgui

Thomasya

Известный
Автор темы
68
2
Версия MoonLoader
.026-beta
Здравствуйте, нужна помощь с несколькими окнами imgui в одном скрипте, пожалуйста помогите.
Мне нужен пример работы двух окон, активация по команде
Lua:
    local main_window_state = imgui.ImBool(false)
    
    function main()

                    sampAddChatMessage(string.format("[CNN by Sabiny]:{FFFFFF} Редактор обьявлений успешно загружен."), gc )
                    sampRegisterChatCommand("redak", function() main_window_state.v = not main_window_state.v end) -- Команда /cnn
                    while true do
                        wait(0)
                        local result, button, list, input = sampHasDialogRespond(557)
                            if result then
                                if button == 1 then
                                    if list == 0 then
                                     lua_thread.create(function(input)
                                      sampSendChat('')
                                      end, input)
                                end
                            end
                    end
                        imgui.Process = main_window_state.v
                      end
                    end

                    function imgui.OnDrawFrame()
                        if main_window_state.v then
                            local sw, sh = getScreenResolution()
                            imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5)) -- ImGui окно будет центрироваться всегда
                            imgui.SetNextWindowSize(imgui.ImVec2(500, 250), imgui.Cond.FirstUseEver) -- Тут сам размер окна. 550 на 350 (X и Y)
                            imgui.Begin(u8'Sabiny', main_window_state, imgui.WindowFlags.NoResize) -- Test script - заголовок окна, main_window_state - крестик, чтобы закрыть, imgui.WindowFlags.NoResize - запрещает менять размер окна
                            -- Тут весь код, который будет в окне

               if imgui.Button(u8'Бар 51', imgui.ImVec2(-0.1, 20) )then
                sampSendDialogResponse(557,1,1,"В баре 51 на пляже Санта-Мария отдыхает много людей.Ждем всех")
            end

                         imgui.End()
                     end
end
Мне нужна помощь, создать второй imgui в котором так-же будут кнопки но с другим смыслом.
 
Решение
Lua:
local main_window_state = imgui.ImBool(false)
local two_window_state = imgui.ImBool(false)

function main()
  sampAddChatMessage(string.format("[CNN by Sabiny]:{FFFFFF} Редактор обьявлений успешно загружен."), gc )
  sampRegisterChatCommand("redak", function() main_window_state.v = not main_window_state.v end) -- Команда /cnn
    sampRegisterChatCommand("test", function() two_window_state.v = not two_window_state.v end)
  while true do
    wait(0)
    local result, button, list, input = sampHasDialogRespond(557)
    if result then
      if button == 1 then
        if list == 0 then
          lua_thread.create(function(input)
            sampSendChat('')
          end, input)
        end
      end
    end
    imgui.Process =...

Albertio

Attention! Thanks for your attention.
877
702
Lua:
local main_window_state = imgui.ImBool(false)
local two_window_state = imgui.ImBool(false)

function main()
  sampAddChatMessage(string.format("[CNN by Sabiny]:{FFFFFF} Редактор обьявлений успешно загружен."), gc )
  sampRegisterChatCommand("redak", function() main_window_state.v = not main_window_state.v end) -- Команда /cnn
    sampRegisterChatCommand("test", function() two_window_state.v = not two_window_state.v end)
  while true do
    wait(0)
    local result, button, list, input = sampHasDialogRespond(557)
    if result then
      if button == 1 then
        if list == 0 then
          lua_thread.create(function(input)
            sampSendChat('')
          end, input)
        end
      end
    end
    imgui.Process = main_window_state.v or two_window_state.v
  end
end

function imgui.OnDrawFrame()
  if main_window_state.v then
    local sw, sh = getScreenResolution()
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(500, 250), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Sabiny', main_window_state, imgui.WindowFlags.NoResize)
    if imgui.Button(u8'Бар 51', imgui.ImVec2(-0.1, 20))then
      sampSendDialogResponse(557, 1, 1, "В баре 51 на пляже Санта-Мария отдыхает много людей.Ждем всех")
    end
    imgui.End()
  end
    if two_window_state.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(500, 250), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'test', two_window_state, imgui.WindowFlags.NoResize)
        if imgui.Button(u8'Бар 228', imgui.ImVec2(-0.1, 20))then
            -- что будет происходить если будет нажата кнопка
        end
        imgui.End()
    end
end