перенос кнопок

bruskin

Участник
Автор темы
151
14
Версия MoonLoader
Другое
1695577309896.png

кароче, я переношу кнопки при помощи imgui.SameLine и столкнулся с проблемой: когда доходит до 4 кнопки, то переноса на следующую строчку нет, а если нужную кнопку переносить на следующую строчку, то перенесутся остальные. Вопрос: как сделать так, чтоб было 4 кнопки в каждой строчке?
 
Решение
4 кнопки в каждой строчке
1695664980323.png

Lua:
    imgui.Begin(u8 'Взаимодействие с игроком', vzaim_window_state)
    imgui.Text(u8 'Взаимодействие с игроком: ' .. nicktarg .. '[' .. idtarg .. ']')
    if imgui.Button(u8 'Повысить срок', imgui.ImVec2(130, 70)) then
        imgui.OpenPopup(u8 'Повышение срока')
    end
    if imgui.BeginPopupModal(u8 'Повышение срока') then
        imgui.SetWindowSize(imgui.ImVec2(400, 100))
        imgui.InputText(u8 'Уровень повышения', leveladdpunishpopup)
        imgui.InputText(u8 'Причина', reasonaddpunishpopup)
        if imgui.Button(u8 'Выдать') and leveladdpunishpopup.v ~= nil and reasonaddpunishpopup.v ~= nil then
            imgui.CloseCurrentPopup()
            vzaim_window_state.v =...

bruskin

Участник
Автор темы
151
14
Продемонстрируй код, пожалуйста, чтобы можно было сделать какие-то выводы и предложения
Lua:
if vzaim_window_state.v then
        local scrX, scrY = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(scrX / 2, scrY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5));
        imgui.SetNextWindowSize(imgui.ImVec2(550,400), imgui.Cond.FirstUseEver)
        imgui.ShowCursor = true
        imgui.Begin(u8'Взаимодействие с игроком', vzaim_window_state)
        imgui.Text(u8'Взаимодействие с игроком: '..nicktarg..'['..idtarg..']')
        if imgui.Button(u8'Повысить срок') then
            imgui.OpenPopup(u8'Повышение срока')
        end
        if imgui.BeginPopupModal(u8'Повышение срока') then
            imgui.SetWindowSize(imgui.ImVec2(400, 100))
            imgui.InputText(u8'Уровень повышения', leveladdpunishpopup)
            imgui.InputText(u8'Причина', reasonaddpunishpopup)
            if imgui.Button(u8'Выдать') and leveladdpunishpopup.v ~= nil and reasonaddpunishpopup.v ~= nil then
                imgui.CloseCurrentPopup()
                vzaim_window_state.v = false
                lua_thread.create(function()
                    sampSendChat('/do КПК лежит в правом кармане.')
                    wait(1000)
                    sampSendChat('/me взял в руки КПК, авторизовался в системе')
                    wait(1000)
                    sampSendChat('/me зашел в раздел "Заключенные", начал искать нужного')
                    wait(1000)
                    sampSendChat('/do Заключенный найден.')
                    wait(1000)
                    sampSendChat('/me открыл меню взаимодейтсвия, выбрал "Повысить срок"..')
                    wait(1000)
                    sampSendChat('/me ..ввел причину и подтвердил действие')
                    wait(1000)
                    sampSendChat('/do Данные о заключенном обнавлены.')
                    wait(1000)
                    sampSendChat('/punish '..idtarg..' '..leveladdpunishpopup.v..' 2 '..u8:decode(reasonaddpunishpopup.v))
                end)
            end
            imgui.SameLine()
            if imgui.Button(u8'Закрыть') then imgui.CloseCurrentPopup() end
            imgui.EndPopup()
        end
        imgui.SameLine()
        if imgui.Button(u8'Надеть наруничики\nВести за собой', imgui.ImVec2(130,70)) then
            vzaim_window_state.v = false
            lua_thread.create(function()
                sampSendChat('/do С пояса свисают наручники.')
                wait(1000)
                sampSendChat('/me снял с пояса наручники, начал одевать их на руки подозреваемого')
                wait(1000)
                sampSendChat('/cuff '..idtarg)
                wait(4550)
                sampSendChat('/me заломал руки человеку')
                wait(1000)
                sampSendChat('/do Руки человека заломаны.')
                wait(1000)
                sampSendChat('/gotome '..idtarg)
            end)
        end
        imgui.SameLine()
        if imgui.Button(u8'Обыскать', imgui.ImVec2(130,70)) then
            vzaim_window_state.v = false
            lua_thread.create(function()
                sampSendChat('/do В правом кармане лежат перчатки.')
                wait(1000)
                sampSendChat('/me взял в руки перчатки, начал прохлопывать верхний слой одежды')
                wait(1000)
                sampSendChat('/frisk '..idtarg)
            end)
        end
        imgui.SameLine()
        if imgui.Button(u8'Посадить в карцер', imgui.ImVec2(130,70)) then imgui.OpenPopup(u8'Посадить в карцер') end
        if imgui.BeginPopupModal(u8'Посадить в карцер') then
            imgui.SetWindowSize(imgui.ImVec2(400, 125))
            imgui.InputText(u8'Номер камеры', cameracarcer)
            imgui.InputText(u8'Время', timecarcer)
            imgui.InputText(u8'Причина', reasoncarcer)
            if imgui.Button(u8'Выдать') and reasoncarcer.v ~= nil and timecarcer.v ~= nil and cameracarcer.v ~= nil then
                imgui.CloseCurrentPopup()
                vzaim_window_state.v = false
                lua_thread.create(function()
                    sampSendChat('/do Ключ от карцера лежит в левом кармане.')
                    wait(1000)
                    sampSendChat('/me залез свободной рукой в карман, достал ключ')
                    wait(1000)
                    sampSendChat('/do Ключ в руках.')
                    wait(1000)
                    sampSendChat('/me вставил ключ в замок, провернул на 180 градусов')
                    wait(1000)
                    sampSendChat('/do Дверь открылась.')
                    wait(1000)
                    sampSendChat('/me затолкал подозреваемого в карцер, захлопнул дверь')
                    wait(1000)
                    sampSendChat('/carcer '..idtarg..' '..u8:decode(cameracarcer.v)..' '..u8:decode(timecarcer.v)..' '..u8:decode(reasoncarcer.v))
                end)
            end
            imgui.SameLine()
            if imgui.Button(u8'Закрыть') then imgui.CloseCurrentPopup() end
            imgui.EndPopup()
        end
        --imgui.SetCursorPos(imgui.ImVec2(1,100))
        if imgui.Button(u8'Понизить срок') then imgui.OpenPopup(u8'Понизить срок') end
        if imgui.BeginPopupModal(u8'Понизить срок') then
            imgui.InputText(u8'Уровень', levelrempunish)
            imgui.InputText(u8'Причина', reasonrempunishpopup)
            if imgui.Button(u8'Выдать') then
                vzaim_window_state.v = false
                imgui.CloseCurrentPopup()
                lua_thread.create(function()
                    sampSendChat('/do КПК лежит в правом кармане.')
                    wait(1000)
                    sampSendChat('/me взял в руки КПК, авторизовался в системе')
                    wait(1000)
                    sampSendChat('/me зашел в раздел "Заключенные", начал искать нужного')
                    wait(1000)
                    sampSendChat('/do Заключенный найден.')
                    wait(1000)
                    sampSendChat('/me открыл меню взаимодейтсвия, выбрал "Понизить срок"..')
                    wait(1000)
                    sampSendChat('/me ..ввел причину и подтвердил действие')
                    wait(1000)
                    sampSendChat('/do Данные о заключенном обнавлены.')
                    wait(1000)
                    sampSendChat('/punish '..idtarg..' '..u8:decode(levelrempunish.v)..' 1 '..u8:decode(reason_rempunish.v))
                end)
            end
            if imgui.Button(u8'Закрыть') then imgui.CloseCurrentPopup() end
            imgui.EndPopup()
        end
        imgui.End()
    end
Что отмечено комментариями - до написания темы, иногда кнопка "Понизить срок" в коде (не в игре, именно в коде) между "Повысить срок" и "Надеть наручники и повести за собой", после кнопки "Понизить срок" был imgui.SameLine
 

Hinаta

Известный
777
363
4 кнопки в каждой строчке
1695664980323.png

Lua:
    imgui.Begin(u8 'Взаимодействие с игроком', vzaim_window_state)
    imgui.Text(u8 'Взаимодействие с игроком: ' .. nicktarg .. '[' .. idtarg .. ']')
    if imgui.Button(u8 'Повысить срок', imgui.ImVec2(130, 70)) then
        imgui.OpenPopup(u8 'Повышение срока')
    end
    if imgui.BeginPopupModal(u8 'Повышение срока') then
        imgui.SetWindowSize(imgui.ImVec2(400, 100))
        imgui.InputText(u8 'Уровень повышения', leveladdpunishpopup)
        imgui.InputText(u8 'Причина', reasonaddpunishpopup)
        if imgui.Button(u8 'Выдать') and leveladdpunishpopup.v ~= nil and reasonaddpunishpopup.v ~= nil then
            imgui.CloseCurrentPopup()
            vzaim_window_state.v = false
            lua_thread.create(function()
                sampSendChat('/do КПК лежит в правом кармане.')
                wait(1000)
                sampSendChat('/me взял в руки КПК, авторизовался в системе')
                wait(1000)
                sampSendChat('/me зашел в раздел "Заключенные", начал искать нужного')
                wait(1000)
                sampSendChat('/do Заключенный найден.')
                wait(1000)
                sampSendChat('/me открыл меню взаимодейтсвия, выбрал "Повысить срок"..')
                wait(1000)
                sampSendChat('/me ..ввел причину и подтвердил действие')
                wait(1000)
                sampSendChat('/do Данные о заключенном обнавлены.')
                wait(1000)
                sampSendChat('/punish ' .. idtarg .. ' ' ..
                leveladdpunishpopup.v .. ' 2 ' .. u8:decode(reasonaddpunishpopup.v))
            end)
        end
        imgui.SameLine()
        if imgui.Button(u8 'Закрыть') then imgui.CloseCurrentPopup() end
        imgui.EndPopup()
    end
    imgui.SameLine()
    if imgui.Button(u8 'Надеть наруничики\nВести за собой', imgui.ImVec2(130, 70)) then
        vzaim_window_state.v = false
        lua_thread.create(function()
            sampSendChat('/do С пояса свисают наручники.')
            wait(1000)
            sampSendChat('/me снял с пояса наручники, начал одевать их на руки подозреваемого')
            wait(1000)
            sampSendChat('/cuff ' .. idtarg)
            wait(4550)
            sampSendChat('/me заломал руки человеку')
            wait(1000)
            sampSendChat('/do Руки человека заломаны.')
            wait(1000)
            sampSendChat('/gotome ' .. idtarg)
        end)
    end
    imgui.SameLine()
    if imgui.Button(u8 'Обыскать', imgui.ImVec2(130, 70)) then
        vzaim_window_state.v = false
        lua_thread.create(function()
            sampSendChat('/do В правом кармане лежат перчатки.')
            wait(1000)
            sampSendChat('/me взял в руки перчатки, начал прохлопывать верхний слой одежды')
            wait(1000)
            sampSendChat('/frisk ' .. idtarg)
        end)
    end
    imgui.SameLine()
    if imgui.Button(u8 'Посадить в карцер', imgui.ImVec2(130, 70)) then imgui.OpenPopup(u8 'Посадить в карцер') end
    if imgui.BeginPopupModal(u8 'Посадить в карцер') then
        imgui.SetWindowSize(imgui.ImVec2(400, 125))
        imgui.InputText(u8 'Номер камеры', cameracarcer)
        imgui.InputText(u8 'Время', timecarcer)
        imgui.InputText(u8 'Причина', reasoncarcer)
        if imgui.Button(u8 'Выдать') and reasoncarcer.v ~= nil and timecarcer.v ~= nil and cameracarcer.v ~= nil then
            imgui.CloseCurrentPopup()
            vzaim_window_state.v = false
            lua_thread.create(function()
                sampSendChat('/do Ключ от карцера лежит в левом кармане.')
                wait(1000)
                sampSendChat('/me залез свободной рукой в карман, достал ключ')
                wait(1000)
                sampSendChat('/do Ключ в руках.')
                wait(1000)
                sampSendChat('/me вставил ключ в замок, провернул на 180 градусов')
                wait(1000)
                sampSendChat('/do Дверь открылась.')
                wait(1000)
                sampSendChat('/me затолкал подозреваемого в карцер, захлопнул дверь')
                wait(1000)
                sampSendChat('/carcer ' ..
                    idtarg .. ' ' .. u8:decode(cameracarcer.v) ..
                    ' ' .. u8:decode(timecarcer.v) .. ' ' .. u8:decode(reasoncarcer.v))
            end)
        end
        imgui.SameLine()
        if imgui.Button(u8 'Закрыть') then imgui.CloseCurrentPopup() end
        imgui.EndPopup()
    end

    if imgui.Button(u8 'Понизить срок') then imgui.OpenPopup(u8 'Понизить срок') end
    if imgui.BeginPopupModal(u8 'Понизить срок') then
        imgui.InputText(u8 'Уровень', levelrempunish)
        imgui.InputText(u8 'Причина', reasonrempunishpopup)
        if imgui.Button(u8 'Выдать') then
            vzaim_window_state.v = false
            imgui.CloseCurrentPopup()
            lua_thread.create(function()
                sampSendChat('/do КПК лежит в правом кармане.')
                wait(1000)
                sampSendChat('/me взял в руки КПК, авторизовался в системе')
                wait(1000)
                sampSendChat('/me зашел в раздел "Заключенные", начал искать нужного')
                wait(1000)
                sampSendChat('/do Заключенный найден.')
                wait(1000)
                sampSendChat('/me открыл меню взаимодейтсвия, выбрал "Понизить срок"..')
                wait(1000)
                sampSendChat('/me ..ввел причину и подтвердил действие')
                wait(1000)
                sampSendChat('/do Данные о заключенном обнавлены.')
                wait(1000)
                sampSendChat('/punish ' .. idtarg ..
                    ' ' .. u8:decode(levelrempunish.v) .. ' 1 ' .. u8:decode(reason_rempunish.v))
            end)
        end
        if imgui.Button(u8 'Закрыть') then imgui.CloseCurrentPopup() end
        imgui.EndPopup()
    end
    imgui.End()
 
  • Нравится
Реакции: bruskin