Плавное появление окна имгуи?

cort

Активный
Автор темы
275
79
Версия MoonLoader
.026-beta
Ищу код плавного появления окна имгуи
 

Letovo

Участник
95
12
 

Lenny Scripts

Активный
179
35
Ищу код плавного появления окна имгуи
Именно Имгуи

Код:
local vk = require "vkeys"
local imgui = require "imgui"

local ui_meta = {
    __index = function(self, v)
        if v == "switch" then
            local switch = function()
                if self.process and self.process:status() ~= "dead" then
                    return false
                end
                self.timer = os.clock()
                self.state = not self.state

                self.process = lua_thread.create(function()
                    local bringFloatTo = function(from, to, start_time, duration)
                        local timer = os.clock() - start_time
                        if timer >= 0.00 and timer <= duration then
                            local count = timer / (duration / 100)
                            return count * ((to - from) / 100)
                        end
                        return (timer > duration) and to or from
                    end

                    while true do wait(0)
                        local a = bringFloatTo(0.00, 1.00, self.timer, self.duration)
                        self.alpha = self.state and a or 1.00 - a
                        if a == 1.00 then break end
                    end
                end)
                return true
            end
            return switch
        end
 
        if v == "alpha" then
            return self.state and 1.00 or 0.00
        end
    end
}

local menu = { state = false, duration = 0.5 }
setmetatable(menu, ui_meta)

local info = { state = false, duration = 1.0 }
setmetatable(info, ui_meta)

function main()
    repeat wait(0) until isSampAvailable()
 
    sampRegisterChatCommand("menu", menu.switch)
    sampRegisterChatCommand("info", info.switch)

    while true do
    
        imgui.Process = (menu.alpha > 0.00) or (info.alpha > 0.00)
        imgui.ShowCursor = menu.state or info.state

        if isKeyJustPressed(vk.VK_F2) then
            menu.switch()
        end

        wait(0)
    end
end

function imgui.OnDrawFrame()
    if menu.alpha > 0.00 then
        imgui.PushStyleVar(imgui.StyleVar.Alpha, menu.alpha)
        imgui.Begin("##My window", _, imgui.WindowFlags.NoTitleBar)

            -- // Code..

        imgui.End()
        imgui.PopStyleVar()
    end

    if info.alpha > 0.00 then
        imgui.PushStyleVar(imgui.StyleVar.Alpha, info.alpha)
        imgui.Begin("##Information", _, imgui.WindowFlags.NoTitleBar)
 
            -- // Code..
 
        imgui.End()
        imgui.PopStyleVar()
    end
end