Два меню ImGUI с разными позициями

ReoGenT

Участник
Автор темы
90
6
Версия MoonLoader
.026-beta
Здравствуйте, никак не могу создать два меню с разными позициями и РАЗМЕРОМ, ПРИЧЕМ с активацией на одну команду! Можете помочь?
 
Решение
Переходи на mimgui:

Lua:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new

local renderWindow = new.bool(false)
local renderWindow2 = new.bool(false)


imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 300, 300
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Main Window', renderWindow)...

Sidney31

Известный
1,116
383
Переходи на mimgui:

Lua:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new

local renderWindow = new.bool(false)
local renderWindow2 = new.bool(false)


imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 300, 300
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Main Window', renderWindow)
        -- WINDOW CODE  
        imgui.End()
    end
)
local newFrame2 = imgui.OnFrame(
    function() return renderWindow2[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 200, 200
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 3, resY / 3), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Main Window2', renderWindow)
        -- WINDOW CODE  
        imgui.End()
    end
)


function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('test', function()
        renderWindow[0] = not renderWindow[0]
        renderWindow2[0] = not renderWindow2[0]
    end)
    while true do
        wait(0)
     
    end
end


imgui:

Lua:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
       
local window = imgui.ImBool(false)
       
function main()
    while not isSampAvailable() do wait(200) end
    sampRegisterChatCommand('test',function()
        window.v = not window.v
    end)
    while true do
        wait(0)
        imgui.Process = window.v
    end
end
       
function imgui.OnDrawFrame()
    if window.v then
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 300, 300 -- WINDOW SIZE
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Window Title', window)
        --window code
        imgui.End()
    end
    if window.v then
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 200, 200 -- WINDOW SIZE
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 3 - sizeX / 3, resY / 3 - sizeY / 3), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Window Title2', window)
        --window code
        imgui.End()
    end
end
 
  • Нравится
Реакции: ReoGenT

ReoGenT

Участник
Автор темы
90
6
Переходи на mimgui:

Lua:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new

local renderWindow = new.bool(false)
local renderWindow2 = new.bool(false)


imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 300, 300
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Main Window', renderWindow)
        -- WINDOW CODE 
        imgui.End()
    end
)
local newFrame2 = imgui.OnFrame(
    function() return renderWindow2[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 200, 200
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 3, resY / 3), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Main Window2', renderWindow)
        -- WINDOW CODE 
        imgui.End()
    end
)


function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('test', function()
        renderWindow[0] = not renderWindow[0]
        renderWindow2[0] = not renderWindow2[0]
    end)
    while true do
        wait(0)
    
    end
end


imgui:

Lua:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
      
local window = imgui.ImBool(false)
      
function main()
    while not isSampAvailable() do wait(200) end
    sampRegisterChatCommand('test',function()
        window.v = not window.v
    end)
    while true do
        wait(0)
        imgui.Process = window.v
    end
end
      
function imgui.OnDrawFrame()
    if window.v then
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 300, 300 -- WINDOW SIZE
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Window Title', window)
        --window code
        imgui.End()
    end
    if window.v then
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 200, 200 -- WINDOW SIZE
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 3 - sizeX / 3, resY / 3 - sizeY / 3), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Window Title2', window)
        --window code
        imgui.End()
    end
end
Спасибо огромное!