Имгуи

Neil_

Известный
Автор темы
204
32
Версия MoonLoader
Другое
Что тут не так? Увидел тему там говорили как сделать меню на подобии UltraFuck, так вот чел скинул код, но чёт он особо не работает, при выборе Основное меню, или чёт другое, крашит и пишет (попытка проиндексировать upvalue 'menu' (числовое значение)

Lua:
function imgui.OnDrawFrame()
    if menu.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, 385), imgui.Cond.FirstUseEver)
                        imgui.Begin('PhoneHelper', menu, imgui.WindowFlags.NoResize)
            imgui.BeginChild("child", imgui.ImVec2(145, 325), true)
            if imgui.Button(u8'Основное Меню', imgui.ImVec2(125, 50)) then menu = 1 end
            if imgui.Button(u8'Контакты', imgui.ImVec2(125, 50)) then menu = 2 end
            if imgui.Button(u8'VkCoin', imgui.ImVec2(125, 50)) then menu = 3 end
            if imgui.Button(u8'Коммерция', imgui.ImVec2(125, 50)) then menu = 4 end
            if imgui.Button(u8'Недвижимость', imgui.ImVec2(125, 50)) then menu = 5 end
            if imgui.Button(u8'Информация', imgui.ImVec2(125, 50)) then menu = 6 end
            imgui.EndChild()
            imgui.SameLine()
            if menu == 1 then
                imgui.BeginChild("child1", imgui.ImVec2(200, 100), true)
                imgui.Text("1")
                imgui.EndChild()
            end
            imgui.SameLine()
            if menu == 2 then
                imgui.BeginChild("child2", imgui.ImVec2(200, 100), true)
                imgui.Text("2")
                imgui.EndChild()
            end
            imgui.SameLine()
            if menu == 3 then
                imgui.BeginChild("child3", imgui.ImVec2(200, 100), true)
                imgui.Text("3")
                imgui.EndChild()
            end
            imgui.SameLine()
            if menu == 4 then
                imgui.BeginChild("child4", imgui.ImVec2(200, 100), true)
                imgui.Text("4")
                imgui.EndChild()
            end
            imgui.SameLine()
            if menu == 5 then
                imgui.BeginChild("child5", imgui.ImVec2(200, 100), true)
                imgui.Text("5")
                imgui.EndChild()
            end
            imgui.SameLine()
            if menu == 6 then
                imgui.BeginChild("child6", imgui.ImVec2(200, 100), true)
                imgui.Text("6")
                imgui.EndChild()
            end
                    imgui.End()
                end
            end
 
Решение
Лучше используй imgui.BeginTabBar -> imgui.BeginTabItem (ИМХО)
А по вопросу твоему:
Lua:
local menu = imgui.ImBool(true)
local tab = 0

local sw, sh = getScreenResolution()
local windowW, windowH = 500, 385

function imgui.OnDrawFrame()
    if menu.v then
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(windowW, windowH), imgui.Cond.FirstUseEver)
        imgui.Begin('PhoneHelper', menu, imgui.WindowFlags.NoResize)
        imgui.BeginChild("child", imgui.ImVec2(145, windowH - 40), true)
        if imgui.Button(u8'Основное Меню', imgui.ImVec2(125, 50)) then tab = 0 end
        if imgui.Button(u8'Контакты', imgui.ImVec2(125...

PanSeek

t.me/dailypanseek
Всефорумный модератор
910
1,782
Лучше используй imgui.BeginTabBar -> imgui.BeginTabItem (ИМХО)
А по вопросу твоему:
Lua:
local menu = imgui.ImBool(true)
local tab = 0

local sw, sh = getScreenResolution()
local windowW, windowH = 500, 385

function imgui.OnDrawFrame()
    if menu.v then
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(windowW, windowH), imgui.Cond.FirstUseEver)
        imgui.Begin('PhoneHelper', menu, imgui.WindowFlags.NoResize)
        imgui.BeginChild("child", imgui.ImVec2(145, windowH - 40), true)
        if imgui.Button(u8'Основное Меню', imgui.ImVec2(125, 50)) then tab = 0 end
        if imgui.Button(u8'Контакты', imgui.ImVec2(125, 50)) then tab = 1 end
        if imgui.Button(u8'VkCoin', imgui.ImVec2(125, 50)) then tab = 2 end
        if imgui.Button(u8'Коммерция', imgui.ImVec2(125, 50)) then tab = 3 end
        if imgui.Button(u8'Недвижимость', imgui.ImVec2(125, 50)) then tab = 4 end
        if imgui.Button(u8'Информация', imgui.ImVec2(125, 50)) then tab = 5 end
        imgui.EndChild()
        imgui.SameLine()
        if tab == 0 then
            imgui.BeginChild("child1", imgui.ImVec2(windowW-170, windowH - 40), true)
            imgui.Text("1")
            imgui.EndChild()
        end
        imgui.SameLine()
        if tab == 1 then
            imgui.BeginChild("child2", imgui.ImVec2(windowW-170, windowH - 40), true)
            imgui.Text("2")
            imgui.EndChild()
        end
        imgui.SameLine()
        if tab == 2 then
            imgui.BeginChild("child3", imgui.ImVec2(windowW-170, windowH - 40), true)
            imgui.Text("3")
            imgui.EndChild()
        end
        imgui.SameLine()
        if tab == 3 then
            imgui.BeginChild("child4", imgui.ImVec2(windowW-170, windowH - 40), true)
            imgui.Text("4")
            imgui.EndChild()
        end
        imgui.SameLine()
        if tab == 4 then
            imgui.BeginChild("child5", imgui.ImVec2(windowW-170, windowH - 40), true)
            imgui.Text("5")
            imgui.EndChild()
        end
        imgui.SameLine()
        if tab == 5 then
            imgui.BeginChild("child6", imgui.ImVec2(windowW-170, windowH - 40), true)
            imgui.Text("6")
            imgui.EndChild()
        end
        imgui.End()
    end
end
У тебя переменная menu булева, а ты суешь туда целое число, вот и ошибка.
UPD: Получай разрешение экрана вне цикла, достаточно одного раза.
 
  • Нравится
Реакции: James Saula и Neil_