SA:MP Помощь с mimgui

Yankay

Участник
Автор темы
65
8
Не могу понять почему не изменяется размер окна, как это фиксить в чём проблема?


lua:
local imgui = require 'mimgui'
local vkeys = require 'vkeys'
local fa = require('fAwesome6_solid')
local wm = require 'windows.message'
local new = imgui.new

local renderWindow = new.bool()
local sizeX, sizeY = getScreenResolution()

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    fa.Init(26)
end)

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(sizeX / 2, sizeY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(250, 150), imgui.Cond.FirstUseEver)


        imgui.BeginChild("Sidebar", imgui.ImVec2(50, 0), true)

        local available_height = imgui.GetContentRegionAvail().y
        
        local item_count = 3
        local item_height = 30
        local spacing = imgui.GetStyle().ItemSpacing.y
        
        local total_height = (item_height * item_count) + (spacing * (item_count - 1))
        
        imgui.SetCursorPosY((available_height - total_height) / 2)
        
        imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0, 0, 0, 0))
        imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(0, 0, 0, 0.2))
        imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(0, 0, 0, 0.3))

        if imgui.Button(fa.HOUSE, imgui.ImVec2(40, 30)) then activeTab = 1 end
        imgui.Dummy(imgui.ImVec2(0, 10))
        if imgui.Button(fa.USER_PLUS, imgui.ImVec2(40, 30)) then activeTab = 2 end
        imgui.Dummy(imgui.ImVec2(0, 10))
        if imgui.Button(fa.PHONE, imgui.ImVec2(40, 30)) then activeTab = 3 end
        imgui.PopStyleColor(3)
        imgui.EndChild()
        
        imgui.SameLine()

        imgui.BeginChild("Hell", imgui.ImVec2(0, 0), true)
        imgui.Text("Test")
        imgui.EndChild()

        imgui.End()
    end
)

function main()
    addEventHandler('onWindowMessage', function(msg, wparam, lparam)
        if msg == wm.WM_KEYDOWN or msg == wm.WM_SYSKEYDOWN then
            if wparam == vkeys.VK_X then
                renderWindow[0] = not renderWindow[0]
            end
        end
    end)
    wait(-1)
end
 

painw

Известный
120
66
Lua:
local imgui = require 'mimgui'
local vkeys = require 'vkeys'
local fa = require('fAwesome6_solid')
local wm = require 'windows.message'
local new = imgui.new

local renderWindow = new.bool()
local sizeX, sizeY = getScreenResolution()

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    fa.Init(26)
end)

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(sizeX / 2, sizeY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(250, 150), imgui.Cond.FirstUseEver)
        imgui.Begin('window', _)

        imgui.BeginChild("Sidebar", imgui.ImVec2(50, 0), true)

        local available_height = imgui.GetContentRegionAvail().y
      
        local item_count = 3
        local item_height = 30
        local spacing = imgui.GetStyle().ItemSpacing.y
      
        local total_height = (item_height * item_count) + (spacing * (item_count - 1))
      
        imgui.SetCursorPosY((available_height - total_height) / 2)
      
        imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0, 0, 0, 0))
        imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(0, 0, 0, 0.2))
        imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(0, 0, 0, 0.3))

        if imgui.Button(fa.HOUSE, imgui.ImVec2(40, 30)) then activeTab = 1 end
        imgui.Dummy(imgui.ImVec2(0, 10))
        if imgui.Button(fa.USER_PLUS, imgui.ImVec2(40, 30)) then activeTab = 2 end
        imgui.Dummy(imgui.ImVec2(0, 10))
        if imgui.Button(fa.PHONE, imgui.ImVec2(40, 30)) then activeTab = 3 end
        imgui.PopStyleColor(3)
        imgui.EndChild()
      
        imgui.SameLine()

        imgui.BeginChild("Hell", imgui.ImVec2(0, 0), true)
        imgui.Text("Test")
        imgui.EndChild()

        imgui.End()
    end
)

function main()
    addEventHandler('onWindowMessage', function(msg, wparam, lparam)
        if msg == wm.WM_KEYDOWN or msg == wm.WM_SYSKEYDOWN then
            if wparam == vkeys.VK_X then
                renderWindow[0] = not renderWindow[0]
            end
        end
    end)
    wait(-1)
end
imgui.Begin забыл