не пропадает курсор с экрана

Kegwineye.

Участник
Автор темы
478
20
Lua:
local imgui = require 'imgui'
local key = require "vkeys"
local image
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local fa = require 'fAwesome5'

local tag = '[{0000CD}Windows 11{FFFFFF}]: Виндовс загружена!'
local window = imgui.ImBool(false)
local window2 = imgui.ImBool(false)
local window3 = imgui.ImBool(false)
local window4 = imgui.ImBool(false)
local second_window = imgui.ImBool(false)

function main()
    while not isSampAvailable() do wait(200) end
    image = imgui.CreateTextureFromFile("moonloader/images/windows11.png")
    folder7 = imgui.CreateTextureFromFile("moonloader/images/folderforwin7.png")
    winbutt = imgui.CreateTextureFromFile("moonloader/images/winbutt.png")
    trashe = imgui.CreateTextureFromFile("moonloader/images/trasheicon.png")
    settings = imgui.CreateTextureFromFile("moonloader/images/settings_cog.png")
    colorwindow = imgui.CreateTextureFromFile("moonloader/images/white.png")
    offbutton = imgui.CreateTextureFromFile("moonloader/images/offbutton.png")
    offbutton2 = imgui.CreateTextureFromFile("moonloader/images/offbutton2.png")
    reloadbutton = imgui.CreateTextureFromFile("moonloader/images/reloadbutton.png")
    imgui.Process = false
    window.v = false
    sampAddChatMessage('[{0000CD}Windows 11{FFFFFF}]: Виндовс загружена!', 0xFFFFFF)
    while true do
        wait(0)
        if isKeyDown(key.VK_LMENU) and isKeyJustPressed(key.VK_B) then
            window.v = not window.v
            imgui.Process = window.v
        end
        imgui.Process = window.v
    end
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(350.0, 250.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(1375.0, 700.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Window Title', window, imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoMove)
        imgui.Image(image, imgui.ImVec2(1260, 660))
        imgui.SetCursorPosY(620)
        imgui.Image(colorwindow, imgui.ImVec2(1260, 60))
        imgui.SetCursorPosY(620)
        imgui.SetCursorPosX(450)
        if imgui.ImageButton(folder7, imgui.ImVec2(45, 45)) then window3.v = not window3.v end
        imgui.SetCursorPosY(620)
        imgui.SetCursorPosX(507)
        if imgui.ImageButton(settings, imgui.ImVec2(45, 45)) then window2.v = not window2.v end
        imgui.SetCursorPosY(641)
        imgui.SetCursorPosX(14)
        if imgui.ImageButton(winbutt, imgui.ImVec2(25, 25)) then window4.v = not window4.v end
        imgui.End()
    end
    if window2.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(550.0, 450.0), imgui.Cond.FirstUseEver)
        imgui.Begin('dasda', window2, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoMove)
        imgui.CenterText('Settings')
        imgui.SameLine()
    imgui.SetCursorPosX(510)
    if imgui.Button(fa.ICON_FA_TIMES .. '', imgui.ImVec2(25, 20)) then
        window2.v = not window2.v
    end
        imgui.Separator()
        imgui.End()
    end
    if window3.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(550.0, 450.0), imgui.Cond.FirstUseEver)
        imgui.Begin('dad', window3, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoMove)
        imgui.CenterText('Folder')
        imgui.SameLine()
    imgui.SetCursorPosX(510)
    if imgui.Button(fa.ICON_FA_TIMES .. '', imgui.ImVec2(25, 20)) then
        window3.v = not window3.v
    end
        imgui.Separator()
        imgui.End()
    end
    if window4.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(350.0, 550.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(350.0, 320.0), imgui.Cond.FirstUseEver)
        imgui.Begin('', window4, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoMove)
        imgui.SetCursorPosY(290)
        if imgui.ImageButton(offbutton, imgui.ImVec2(20, 20)) then second_window.v = not second_window.v end
    
        imgui.End()
    end

    if second_window.v then -- thisScript():reload()
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(350.0, 520.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(100.0, 60.0), imgui.Cond.FirstUseEver)
        imgui.Begin('', second_window, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoMove)
        imgui.SetCursorPosY(260)
        if imgui.ImageButton(offbutton2, imgui.ImVec2(20, 20)) then thisScript():unload() end
        imgui.SetCursorPosY(237)
        imgui.SetCursorPosX(45)
        imgui.Text(u8'Перезагрузка')
        imgui.SetCursorPosY(230)
        if imgui.ImageButton(reloadbutton, imgui.ImVec2(20, 20)) then thisScript():reload()  end
        imgui.SetCursorPosY(267)
        imgui.SetCursorPosX(45)
        imgui.Text(u8'Выключение')
        imgui.End()
    end
end

function onWindowMessage(msg, wparam, lparam)
    if msg == 0x100 or msg == 0x101 then
        if (wparam == key.VK_DELETE and (window.v)) and not isPauseMenuActive() and not isSampfuncsConsoleActive() and not window2.v and not window3.v and not window4.v then
            consumeWindowMessage(true, false)
            if msg == 0x101 then
                window.v = false
            end
        end
    end
end

function imgui.CenterText(text)
    local width = imgui.GetWindowWidth()
    local calc = imgui.CalcTextSize(text)
    imgui.SetCursorPosX( width / 2 - calc.x / 2 )
    imgui.Text(text)
end

local fa_font = nil
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
function imgui.BeforeDrawFrame()
    if fa_font == nil then
        local font_config = imgui.ImFontConfig()
        font_config.MergeMode = true

        fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fa-solid-900.ttf', 13.0, font_config, fa_glyph_ranges)
        if fontsize == nil then
        fontsize = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\trebucbd.ttf', 37.0, nil, imgui.GetIO().Fonts:GetGlyphRangesCyrillic()) -- вместо 30 любой нужный размеp
        end
    end
end

function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
 
    style.WindowPadding = imgui.ImVec2(15, 15)
    style.WindowRounding = 1.5
    style.FramePadding = imgui.ImVec2(5, 5)
    style.FrameRounding = 4.0
    style.ItemSpacing = imgui.ImVec2(12, 8)
    style.ItemInnerSpacing = imgui.ImVec2(8, 6)
    style.IndentSpacing = 25.0
    style.ScrollbarSize = 15.0
    style.ScrollbarRounding = 9.0
    style.GrabMinSize = 5.0
    style.GrabRounding = 3.0
 
    colors[clr.Text] = ImVec4(0.10, 0.10, 0.13, 1.00)
    colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.WindowBg] = ImVec4(1.06, 1.05, 1.07, 1.00)
    colors[clr.ChildWindowBg] = ImVec4(1.07, 1.07, 1.09, 1.00)
    colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
    colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
    colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
    colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
    colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.Button] = ImVec4(1.10, 1.09, 1.12, 1.00)
    colors[clr.ButtonHovered] = ImVec4(1.10, 1.09, 1.12, 1.00)
    colors[clr.ButtonActive] = ImVec4(1.10, 1.09, 1.12, 1.00)
    colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
    colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
    colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
    colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
    colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
    colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
    colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
    colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
    colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
  end
  apply_custom_style()