стрелка (imgui.button) в imgui.BeginPopupModal

goosik

Участник
Автор темы
108
6
Версия MoonLoader
.027.0-preview
Как мне по нажатию стрелки (imgui,Button) возвращаться с окна imgui.BeginPopupModal в обычное окно? Код ниже
1711462780311.png

КоDick:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local faicons = require('fAwesome6')
local WinState = imgui.new.bool()
local tab = 1
imgui.OnFrame(function() return WinState[0] end, function(player)
    imgui.SetNextWindowPos(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(750, 400), imgui.Cond.Always)
    imgui.Begin(u8'##name', WinState, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)

    imgui.SetCursorPos(imgui.ImVec2(6, 118))
    if imgui.BeginChild('Name#45#'..tab, imgui.ImVec2(137, 170), true) then
        for numberTab,nameTab in pairs({'Транспорт','Расходники','Настройки'}) do
            if imgui.Button(u8(nameTab), imgui.ImVec2(120,48)) then
             tab = numberTab
         end
      end
      imgui.EndChild()
    end
    imgui.SetCursorPos(imgui.ImVec2(6, 10))
    imgui.BeginChild('Name#4535345#', imgui.ImVec2(137, 100), true)
    if imgui.ImageButton(imhandle, imgui.ImVec2(110, 78)) then
        imgui.OpenPopup(u8'Информация о скрипте')
    end
    if imgui.IsItemHovered() then
        imgui.BeginTooltip()
        imgui.Text(u8'При нажатии на картинку, Вам откроется информация о скрипте')
        imgui.EndTooltip()
    end
    if imgui.BeginPopupModal(u8"Информация о скрипте", nil, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar) then
        imgui.SetWindowSizeVec2(imgui.ImVec2(400, 250))
        if imgui.Button(faicons('left'),imgui.ImVec2(24,24)) then
            
        end
        imgui.EndPopup()
    end
    imgui.EndChild()
    imgui.SetCursorPos(imgui.ImVec2(6, 295))
    imgui.BeginChild('Name#4535#', imgui.ImVec2(137, 92), true)
    _,id = sampGetPlayerIdByCharHandle(playerPed)
    imgui.CenterText(faicons('user')..u8(' '.. sampGetPlayerNickname(id)))
    imgui.CenterText(faicons('star')..u8(' LVL: ')..sampGetPlayerScore(id))
    imgui.CenterText(faicons('eye')..u8(' ID: ')..id)
    imgui.CenterText(faicons('wifi')..u8(' Ping: ')..sampGetPlayerPing(id))
    imgui.EndChild()
    imgui.SetCursorPos(imgui.ImVec2(150, 8))
    if imgui.BeginChild('Name##'..tab, imgui.ImVec2(590, 380), true) then
        if tab == 1 then
            


            elseif tab == 2 then
            



            elseif tab == 3 then
            




        end
        imgui.EndChild()
    end
    imgui.End()
end)
function main()
    sampRegisterChatCommand('sc', function() WinState[0] = not WinState[0] end)
    wait(-1)
end
imgui.OnInitialize(function()
    theme()
    imgui.GetIO().IniFilename = nil
    local config = imgui.ImFontConfig()
    config.MergeMode = true
    config.PixelSnapH = true
    iconRanges = imgui.new.ImWchar[3](faicons.min_range, faicons.max_range, 0)
    imgui.GetIO().Fonts:AddFontFromMemoryCompressedBase85TTF(faicons.get_font_data_base85('solid'), 14, config, iconRanges)
    if doesFileExist(getWorkingDirectory()..'\\resource\\smartcar\\smartcarlogo.png') then
        imhandle = imgui.CreateTextureFromFile(getWorkingDirectory() .. '\\resource\\smartcar\\smartcarlogo.png')
    end
end)
function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle();
    local colors = style.Colors;
    style.Alpha = 1;
    style.WindowPadding = imgui.ImVec2(8.00, 8.00);
    style.WindowRounding = 12;
    style.WindowBorderSize = 1;
    style.WindowMinSize = imgui.ImVec2(32.00, 32.00);
    style.WindowTitleAlign = imgui.ImVec2(0.00, 0.50);
    style.ChildRounding = 12;
    style.ChildBorderSize = 1;
    style.PopupRounding = 12;
    style.PopupBorderSize = 1;
    style.FramePadding = imgui.ImVec2(4.00, 3.00);
    style.FrameRounding = 12;
    style.FrameBorderSize = 1;
    style.ItemSpacing = imgui.ImVec2(8.00, 4.00);
    style.ItemInnerSpacing = imgui.ImVec2(4.00, 4.00);
    style.IndentSpacing = 21;
    style.ScrollbarSize = 14;
    style.ScrollbarRounding = 12;
    style.GrabMinSize = 10;
    style.GrabRounding = 12;
    style.TabRounding = 12;
    style.ButtonTextAlign = imgui.ImVec2(0.50, 0.50);
    style.SelectableTextAlign = imgui.ImVec2(0.00, 0.00);
    colors[imgui.Col.Text] = imgui.ImVec4(1.00, 1.00, 1.00, 1.00);
    colors[imgui.Col.TextDisabled] = imgui.ImVec4(0.50, 0.50, 0.50, 1.00);
    colors[imgui.Col.WindowBg] = imgui.ImVec4(0.09, 0.23, 0.29, 1.00);
    colors[imgui.Col.ChildBg] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00);
    colors[imgui.Col.PopupBg] = imgui.ImVec4(0.08, 0.08, 0.08, 0.94);
    colors[imgui.Col.Border] = imgui.ImVec4(0.43, 0.43, 0.50, 0.50);
    colors[imgui.Col.BorderShadow] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00);
    colors[imgui.Col.FrameBg] = imgui.ImVec4(0.16, 0.29, 0.48, 0.54);
    colors[imgui.Col.FrameBgHovered] = imgui.ImVec4(0.26, 0.59, 0.98, 0.40);
    colors[imgui.Col.FrameBgActive] = imgui.ImVec4(0.26, 0.59, 0.98, 0.67);
    colors[imgui.Col.TitleBg] = imgui.ImVec4(0.04, 0.04, 0.04, 1.00);
    colors[imgui.Col.TitleBgActive] = imgui.ImVec4(0.16, 0.29, 0.48, 1.00);
    colors[imgui.Col.TitleBgCollapsed] = imgui.ImVec4(0.00, 0.00, 0.00, 0.51);
    colors[imgui.Col.MenuBarBg] = imgui.ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[imgui.Col.ScrollbarBg] = imgui.ImVec4(0.02, 0.02, 0.02, 0.53);
    colors[imgui.Col.ScrollbarGrab] = imgui.ImVec4(0.31, 0.31, 0.31, 1.00);
    colors[imgui.Col.ScrollbarGrabHovered] = imgui.ImVec4(0.41, 0.41, 0.41, 1.00);
    colors[imgui.Col.ScrollbarGrabActive] = imgui.ImVec4(0.51, 0.51, 0.51, 1.00);
    colors[imgui.Col.CheckMark] = imgui.ImVec4(0.26, 0.59, 0.98, 1.00);
    colors[imgui.Col.SliderGrab] = imgui.ImVec4(0.24, 0.52, 0.88, 1.00);
    colors[imgui.Col.SliderGrabActive] = imgui.ImVec4(0.26, 0.59, 0.98, 1.00);
    colors[imgui.Col.Button] = imgui.ImVec4(0.26, 0.59, 0.98, 0.40);
    colors[imgui.Col.ButtonHovered] = imgui.ImVec4(0.26, 0.59, 0.98, 1.00);
    colors[imgui.Col.ButtonActive] = imgui.ImVec4(0.06, 0.53, 0.98, 1.00);
    colors[imgui.Col.Header] = imgui.ImVec4(0.26, 0.59, 0.98, 0.31);
    colors[imgui.Col.HeaderHovered] = imgui.ImVec4(0.26, 0.59, 0.98, 0.80);
    colors[imgui.Col.HeaderActive] = imgui.ImVec4(0.26, 0.59, 0.98, 1.00);
    colors[imgui.Col.Separator] = imgui.ImVec4(0.43, 0.43, 0.50, 0.50);
    colors[imgui.Col.SeparatorHovered] = imgui.ImVec4(0.10, 0.40, 0.75, 0.78);
    colors[imgui.Col.SeparatorActive] = imgui.ImVec4(0.10, 0.40, 0.75, 1.00);
    colors[imgui.Col.ResizeGrip] = imgui.ImVec4(0.26, 0.59, 0.98, 0.25);
    colors[imgui.Col.ResizeGripHovered] = imgui.ImVec4(0.26, 0.59, 0.98, 0.67);
    colors[imgui.Col.ResizeGripActive] = imgui.ImVec4(0.26, 0.59, 0.98, 0.95);
    colors[imgui.Col.Tab] = imgui.ImVec4(0.18, 0.35, 0.58, 0.86);
    colors[imgui.Col.TabHovered] = imgui.ImVec4(0.26, 0.59, 0.98, 0.80);
    colors[imgui.Col.TabActive] = imgui.ImVec4(0.20, 0.41, 0.68, 1.00);
    colors[imgui.Col.TabUnfocused] = imgui.ImVec4(0.07, 0.10, 0.15, 0.97);
    colors[imgui.Col.TabUnfocusedActive] = imgui.ImVec4(0.14, 0.26, 0.42, 1.00);
    colors[imgui.Col.PlotLines] = imgui.ImVec4(0.61, 0.61, 0.61, 1.00);
    colors[imgui.Col.PlotLinesHovered] = imgui.ImVec4(1.00, 0.43, 0.35, 1.00);
    colors[imgui.Col.PlotHistogram] = imgui.ImVec4(0.90, 0.70, 0.00, 1.00);
    colors[imgui.Col.PlotHistogramHovered] = imgui.ImVec4(1.00, 0.60, 0.00, 1.00);
    colors[imgui.Col.TextSelectedBg] = imgui.ImVec4(0.26, 0.59, 0.98, 0.35);
    colors[imgui.Col.DragDropTarget] = imgui.ImVec4(1.00, 1.00, 0.00, 0.90);
    colors[imgui.Col.NavHighlight] = imgui.ImVec4(0.26, 0.59, 0.98, 1.00);
    colors[imgui.Col.NavWindowingHighlight] = imgui.ImVec4(1.00, 1.00, 1.00, 0.70);
    colors[imgui.Col.NavWindowingDimBg] = imgui.ImVec4(0.80, 0.80, 0.80, 0.20);
    colors[imgui.Col.ModalWindowDimBg] = imgui.ImVec4(0.80, 0.80, 0.80, 0.35);
end
function imgui.CenterText(text)
    local width = imgui.GetWindowWidth()
    local height = imgui.GetWindowHeight()
    local calc = imgui.CalcTextSize(text)
    imgui.SetCursorPosX( width / 2 - calc.x / 2 )
    imgui.Text(text)
end