Как увеличить размер этих кнопок

boy next door

Участник
Автор темы
212
18
Версия MoonLoader
.026-beta
Lua:
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)
        for i, title in ipairs(navigation.list) do
            if HeaderButton(navigation.current == i, title) then
                navigation.current = i
            end
        end
        if navigation.current == 1 then -- Home
            if imgui.Button('Button 1') then
                print("Button 1 clicked")
            end
        elseif navigation.current == 2 then -- Settings
            if imgui.Button('Button 2') then
                print("Button 2 clicked")
            end
        end
        imgui.End()
    end
)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('cw', function()
        renderWindow[0] = not renderWindow[0]
    end)
    while true do
        wait(0)
        HeaderButton = function(bool, str_id)
            local DL = imgui.GetWindowDrawList()
            local ToU32 = imgui.ColorConvertFloat4ToU32
            local result = false
            local label = string.gsub(str_id, "##.*$", "")
            local duration = { 0.5, 0.3 }
            local cols = {
                idle = imgui.GetStyle().Colors[imgui.Col.TextDisabled],
                hovr = imgui.GetStyle().Colors[imgui.Col.Text],
                slct = imgui.GetStyle().Colors[imgui.Col.ButtonActive]
            }
        
            if not AI_HEADERBUT then AI_HEADERBUT = {} end
             if not AI_HEADERBUT[str_id] then
                AI_HEADERBUT[str_id] = {
                    color = bool and cols.slct or cols.idle,
                    clock = os.clock() + duration[1],
                    h = {
                        state = bool,
                        alpha = bool and 1.00 or 0.00,
                        clock = os.clock() + duration[2],
                    }
                }
            end
            local pool = AI_HEADERBUT[str_id]
        
            local degrade = function(before, after, start_time, duration)
                local result = before
                local timer = os.clock() - start_time
                if timer >= 0.00 then
                    local offs = {
                        x = after.x - before.x,
                        y = after.y - before.y,
                        z = after.z - before.z,
                        w = after.w - before.w
                    }
        
                    result.x = result.x + ( (offs.x / duration) * timer )
                    result.y = result.y + ( (offs.y / duration) * timer )
                    result.z = result.z + ( (offs.z / duration) * timer )
                    result.w = result.w + ( (offs.w / duration) * timer )
                end
                return result
            end
        
            local pushFloatTo = function(p1, p2, clock, duration)
                local result = p1
                local timer = os.clock() - clock
                if timer >= 0.00 then
                    local offs = p2 - p1
                    result = result + ((offs / duration) * timer)
                end
                return result
            end
        
            local set_alpha = function(color, alpha)
                return imgui.ImVec4(color.x, color.y, color.z, alpha or 1.00)
            end
        
            imgui.BeginGroup()
                local pos = imgui.GetCursorPos()
                local p = imgui.GetCursorScreenPos()
              
                imgui.TextColored(pool.color, label)
                local s = imgui.GetItemRectSize()
                local hovered = imgui.IsItemHovered()
                local clicked = imgui.IsItemClicked()
              
                if pool.h.state ~= hovered and not bool then
                    pool.h.state = hovered
                    pool.h.clock = os.clock()
                end
              
                if clicked then
                    pool.clock = os.clock()
                    result = true
                end
        
                if os.clock() - pool.clock <= duration[1] then
                    pool.color = degrade(
                        imgui.ImVec4(pool.color),
                        bool and cols.slct or (hovered and cols.hovr or cols.idle),
                        pool.clock,
                        duration[1]
                    )
                else
                    pool.color = bool and cols.slct or (hovered and cols.hovr or cols.idle)
                end
        
                if pool.h.clock ~= nil then
                    if os.clock() - pool.h.clock <= duration[2] then
                        pool.h.alpha = pushFloatTo(
                            pool.h.alpha,
                            pool.h.state and 1.00 or 0.00,
                            pool.h.clock,
                            duration[2]
                        )
                    else
                        pool.h.alpha = pool.h.state and 1.00 or 0.00
                        if not pool.h.state then
                            pool.h.clock = nil
                        end
                    end
        
                    local max = s.x / 2
                    local Y = p.y + s.y + 3
                    local mid = p.x + max
        
                    DL:AddLine(imgui.ImVec2(mid, Y), imgui.ImVec2(mid + (max * pool.h.alpha), Y), ToU32(set_alpha(pool.color, pool.h.alpha)), 3)
                    DL:AddLine(imgui.ImVec2(mid, Y), imgui.ImVec2(mid - (max * pool.h.alpha), Y), ToU32(set_alpha(pool.color, pool.h.alpha)), 3)
                end
        
            imgui.EndGroup()
            return result
        end
    end
end
1722072228365.png
 
  • Ха-ха
Реакции: Gorskin