в чем ошибка ?

Kegwineye.

Участник
Автор темы
478
20
Версия MoonLoader
.026-beta
attempt to call field 'SwitchColorTheme' (a nil value)
 
Решение
код мой ? или themes ?


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 themes = import "resource/imgui_themes.lua"

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)
local SetWindowColor = imgui.ImBool(false)

function main()
    while not isSampAvailable() do wait(200) end
    whitetheme = imgui.CreateTextureFromFile("moonloader/images/windows11.png")
    blacktheme =...

Kegwineye.

Участник
Автор темы
478
20
Ну значит кидай код
код мой ? или themes ?


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 themes = import "resource/imgui_themes.lua"

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)
local SetWindowColor = imgui.ImBool(false)

function main()
    while not isSampAvailable() do wait(200) end
    whitetheme = imgui.CreateTextureFromFile("moonloader/images/windows11.png")
    blacktheme = imgui.CreateTextureFromFile('moonloader/images/windows11black.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
        imgui.SwitchContext()
        imgui.SwitchColorTheme(1)
    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
        if window.v == false then
            imgui.Process = false
        end
    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(whitetheme, 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.NewLine()
        imgui.SetCursorPosY(55)
        imgui.PushFont(fontsize)
        imgui.Text(u8"Использовать темную тему Windows")
        imgui.SameLine()
        imgui.TextQuestion(u8'По стандарту выключено')
        imgui.SetCursorPosX(490)
        imgui.SetCursorPosY(55)
        imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0.00, 1.00, 0.25, 0.65))
        if imgui.ToggleButton("Test2##3", SetWindowColor) then imgui.SwitchColorTheme(2) end
        imgui.PopStyleColor()
        imgui.PopFont()
        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.Button(fa.ICON_FA_POWER_OFF .. '', 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.Button(fa.ICON_FA_POWER_OFF .. '', imgui.ImVec2(20, 20)) then thisScript():unload() end
        imgui.SetCursorPosY(234)
        imgui.SetCursorPosX(45)
        imgui.Text(u8'Перезагрузка')
        imgui.SetCursorPosY(230)
        if imgui.Button(fa.ICON_FA_SYNC_ALT .. '', imgui.ImVec2(20, 20)) then thisScript():reload() end
        imgui.SetCursorPosY(264)
        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', 15.0, font_config, fa_glyph_ranges)
        if fontsize == nil then
        fontsize = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\trebucbd.ttf', 18.0, nil, imgui.GetIO().Fonts:GetGlyphRangesCyrillic()) -- вместо 30 любой нужный размеp
        end
    end
end
 
function imgui.ToggleButton(str_id, bool)

    local rBool = false
 
    if LastActiveTime == nil then
       LastActiveTime = {}
    end
    if LastActive == nil then
       LastActive = {}
    end
 
    local function ImSaturate(f)
       return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
    end
 
    local p = imgui.GetCursorScreenPos()
    local draw_list = imgui.GetWindowDrawList()
 
    local height = imgui.GetTextLineHeightWithSpacing() + (imgui.GetStyle().FramePadding.y / 2)
    local width = height * 1.55
    local radius = height * 0.50
    local ANIM_SPEED = 0.15
 
    if imgui.InvisibleButton(str_id, imgui.ImVec2(width, height)) then
       bool.v = not bool.v
       rBool = true
       LastActiveTime[tostring(str_id)] = os.clock()
       LastActive[str_id] = true
    end
 
    local t = bool.v and 1.0 or 0.0
 
    if LastActive[str_id] then
       local time = os.clock() - LastActiveTime[tostring(str_id)]
       if time <= ANIM_SPEED then
          local t_anim = ImSaturate(time / ANIM_SPEED)
          t = bool.v and t_anim or 1.0 - t_anim
       else
          LastActive[str_id] = false
       end
    end
 
    local col_bg
    if imgui.IsItemHovered() then
       col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgHovered])
    else
       col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBg])
    end
 
    draw_list:AddRectFilled(p, imgui.ImVec2(p.x + width, p.y + height), col_bg, height * 0.5)
    draw_list:AddCircleFilled(imgui.ImVec2(p.x + radius + t * (width - radius * 2.0), p.y + radius), radius - 1.5, imgui.GetColorU32(bool.v and imgui.GetStyle().Colors[imgui.Col.ButtonActive] or imgui.GetStyle().Colors[imgui.Col.Button]))
 
    return rBool
end
function imgui.TextQuestion(text)
    imgui.TextDisabled(u8'(?)')
    if imgui.IsItemHovered() then
    imgui.BeginTooltip()
    imgui.PushTextWrapPos(450)
    imgui.TextUnformatted(text)
    imgui.PopTextWrapPos()
    imgui.EndTooltip() end end
 

qdIbp

Автор темы
Проверенный
1,450
1,191
код мой ? или themes ?


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 themes = import "resource/imgui_themes.lua"

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)
local SetWindowColor = imgui.ImBool(false)

function main()
    while not isSampAvailable() do wait(200) end
    whitetheme = imgui.CreateTextureFromFile("moonloader/images/windows11.png")
    blacktheme = imgui.CreateTextureFromFile('moonloader/images/windows11black.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
        imgui.SwitchContext()
        imgui.SwitchColorTheme(1)
    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
        if window.v == false then
            imgui.Process = false
        end
    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(whitetheme, 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.NewLine()
        imgui.SetCursorPosY(55)
        imgui.PushFont(fontsize)
        imgui.Text(u8"Использовать темную тему Windows")
        imgui.SameLine()
        imgui.TextQuestion(u8'По стандарту выключено')
        imgui.SetCursorPosX(490)
        imgui.SetCursorPosY(55)
        imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0.00, 1.00, 0.25, 0.65))
        if imgui.ToggleButton("Test2##3", SetWindowColor) then imgui.SwitchColorTheme(2) end
        imgui.PopStyleColor()
        imgui.PopFont()
        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.Button(fa.ICON_FA_POWER_OFF .. '', 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.Button(fa.ICON_FA_POWER_OFF .. '', imgui.ImVec2(20, 20)) then thisScript():unload() end
        imgui.SetCursorPosY(234)
        imgui.SetCursorPosX(45)
        imgui.Text(u8'Перезагрузка')
        imgui.SetCursorPosY(230)
        if imgui.Button(fa.ICON_FA_SYNC_ALT .. '', imgui.ImVec2(20, 20)) then thisScript():reload() end
        imgui.SetCursorPosY(264)
        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', 15.0, font_config, fa_glyph_ranges)
        if fontsize == nil then
        fontsize = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\trebucbd.ttf', 18.0, nil, imgui.GetIO().Fonts:GetGlyphRangesCyrillic()) -- вместо 30 любой нужный размеp
        end
    end
end
 
function imgui.ToggleButton(str_id, bool)

    local rBool = false
 
    if LastActiveTime == nil then
       LastActiveTime = {}
    end
    if LastActive == nil then
       LastActive = {}
    end
 
    local function ImSaturate(f)
       return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
    end
 
    local p = imgui.GetCursorScreenPos()
    local draw_list = imgui.GetWindowDrawList()
 
    local height = imgui.GetTextLineHeightWithSpacing() + (imgui.GetStyle().FramePadding.y / 2)
    local width = height * 1.55
    local radius = height * 0.50
    local ANIM_SPEED = 0.15
 
    if imgui.InvisibleButton(str_id, imgui.ImVec2(width, height)) then
       bool.v = not bool.v
       rBool = true
       LastActiveTime[tostring(str_id)] = os.clock()
       LastActive[str_id] = true
    end
 
    local t = bool.v and 1.0 or 0.0
 
    if LastActive[str_id] then
       local time = os.clock() - LastActiveTime[tostring(str_id)]
       if time <= ANIM_SPEED then
          local t_anim = ImSaturate(time / ANIM_SPEED)
          t = bool.v and t_anim or 1.0 - t_anim
       else
          LastActive[str_id] = false
       end
    end
 
    local col_bg
    if imgui.IsItemHovered() then
       col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgHovered])
    else
       col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBg])
    end
 
    draw_list:AddRectFilled(p, imgui.ImVec2(p.x + width, p.y + height), col_bg, height * 0.5)
    draw_list:AddCircleFilled(imgui.ImVec2(p.x + radius + t * (width - radius * 2.0), p.y + radius), radius - 1.5, imgui.GetColorU32(bool.v and imgui.GetStyle().Colors[imgui.Col.ButtonActive] or imgui.GetStyle().Colors[imgui.Col.Button]))
 
    return rBool
end
function imgui.TextQuestion(text)
    imgui.TextDisabled(u8'(?)')
    if imgui.IsItemHovered() then
    imgui.BeginTooltip()
    imgui.PushTextWrapPos(450)
    imgui.TextUnformatted(text)
    imgui.PopTextWrapPos()
    imgui.EndTooltip() end end
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 themes = import "resource/imgui_themes.lua"

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)
local SetWindowColor = imgui.ImBool(false)

function main()
    while not isSampAvailable() do wait(200) end
    whitetheme = imgui.CreateTextureFromFile("moonloader/images/windows11.png")
    blacktheme = imgui.CreateTextureFromFile('moonloader/images/windows11black.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
        imgui.SwitchContext()
        themes.SwitchColorTheme(1)
    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
        if window.v == false then
            imgui.Process = false
        end
    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(whitetheme, 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.NewLine()
        imgui.SetCursorPosY(55)
        imgui.PushFont(fontsize)
        imgui.Text(u8"Использовать темную тему Windows")
        imgui.SameLine()
        imgui.TextQuestion(u8'По стандарту выключено')
        imgui.SetCursorPosX(490)
        imgui.SetCursorPosY(55)
        imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0.00, 1.00, 0.25, 0.65))
        if imgui.ToggleButton("Test2##3", SetWindowColor) then imgui.SwitchColorTheme(2) end
        imgui.PopStyleColor()
        imgui.PopFont()
        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.Button(fa.ICON_FA_POWER_OFF .. '', 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.Button(fa.ICON_FA_POWER_OFF .. '', imgui.ImVec2(20, 20)) then thisScript():unload() end
        imgui.SetCursorPosY(234)
        imgui.SetCursorPosX(45)
        imgui.Text(u8'Перезагрузка')
        imgui.SetCursorPosY(230)
        if imgui.Button(fa.ICON_FA_SYNC_ALT .. '', imgui.ImVec2(20, 20)) then thisScript():reload() end
        imgui.SetCursorPosY(264)
        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', 15.0, font_config, fa_glyph_ranges)
        if fontsize == nil then
        fontsize = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\trebucbd.ttf', 18.0, nil, imgui.GetIO().Fonts:GetGlyphRangesCyrillic()) -- вместо 30 любой нужный размеp
        end
    end
end
 
function imgui.ToggleButton(str_id, bool)

    local rBool = false
 
    if LastActiveTime == nil then
       LastActiveTime = {}
    end
    if LastActive == nil then
       LastActive = {}
    end
 
    local function ImSaturate(f)
       return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
    end
 
    local p = imgui.GetCursorScreenPos()
    local draw_list = imgui.GetWindowDrawList()
 
    local height = imgui.GetTextLineHeightWithSpacing() + (imgui.GetStyle().FramePadding.y / 2)
    local width = height * 1.55
    local radius = height * 0.50
    local ANIM_SPEED = 0.15
 
    if imgui.InvisibleButton(str_id, imgui.ImVec2(width, height)) then
       bool.v = not bool.v
       rBool = true
       LastActiveTime[tostring(str_id)] = os.clock()
       LastActive[str_id] = true
    end
 
    local t = bool.v and 1.0 or 0.0
 
    if LastActive[str_id] then
       local time = os.clock() - LastActiveTime[tostring(str_id)]
       if time <= ANIM_SPEED then
          local t_anim = ImSaturate(time / ANIM_SPEED)
          t = bool.v and t_anim or 1.0 - t_anim
       else
          LastActive[str_id] = false
       end
    end
 
    local col_bg
    if imgui.IsItemHovered() then
       col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgHovered])
    else
       col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBg])
    end
 
    draw_list:AddRectFilled(p, imgui.ImVec2(p.x + width, p.y + height), col_bg, height * 0.5)
    draw_list:AddCircleFilled(imgui.ImVec2(p.x + radius + t * (width - radius * 2.0), p.y + radius), radius - 1.5, imgui.GetColorU32(bool.v and imgui.GetStyle().Colors[imgui.Col.ButtonActive] or imgui.GetStyle().Colors[imgui.Col.Button]))
 
    return rBool
end
function imgui.TextQuestion(text)
    imgui.TextDisabled(u8'(?)')
    if imgui.IsItemHovered() then
        imgui.BeginTooltip()
            imgui.PushTextWrapPos(450)
            imgui.TextUnformatted(text)
            imgui.PopTextWrapPos()
        imgui.EndTooltip()
    end
end

Lua:
themes.SwitchColorTheme(1) -- 32 строка должна выглядеть так
 
  • Нравится
Реакции: Kegwineye.

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 themes = import "resource/imgui_themes.lua"

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)
local SetWindowColor = imgui.ImBool(false)

function main()
    while not isSampAvailable() do wait(200) end
    whitetheme = imgui.CreateTextureFromFile("moonloader/images/windows11.png")
    blacktheme = imgui.CreateTextureFromFile('moonloader/images/windows11black.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
        imgui.SwitchContext()
        themes.SwitchColorTheme(1)
    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
        if window.v == false then
            imgui.Process = false
        end
    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(whitetheme, 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.NewLine()
        imgui.SetCursorPosY(55)
        imgui.PushFont(fontsize)
        imgui.Text(u8"Использовать темную тему Windows")
        imgui.SameLine()
        imgui.TextQuestion(u8'По стандарту выключено')
        imgui.SetCursorPosX(490)
        imgui.SetCursorPosY(55)
        imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0.00, 1.00, 0.25, 0.65))
        if imgui.ToggleButton("Test2##3", SetWindowColor) then imgui.SwitchColorTheme(2) end
        imgui.PopStyleColor()
        imgui.PopFont()
        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.Button(fa.ICON_FA_POWER_OFF .. '', 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.Button(fa.ICON_FA_POWER_OFF .. '', imgui.ImVec2(20, 20)) then thisScript():unload() end
        imgui.SetCursorPosY(234)
        imgui.SetCursorPosX(45)
        imgui.Text(u8'Перезагрузка')
        imgui.SetCursorPosY(230)
        if imgui.Button(fa.ICON_FA_SYNC_ALT .. '', imgui.ImVec2(20, 20)) then thisScript():reload() end
        imgui.SetCursorPosY(264)
        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', 15.0, font_config, fa_glyph_ranges)
        if fontsize == nil then
        fontsize = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\trebucbd.ttf', 18.0, nil, imgui.GetIO().Fonts:GetGlyphRangesCyrillic()) -- вместо 30 любой нужный размеp
        end
    end
end
 
function imgui.ToggleButton(str_id, bool)

    local rBool = false
 
    if LastActiveTime == nil then
       LastActiveTime = {}
    end
    if LastActive == nil then
       LastActive = {}
    end
 
    local function ImSaturate(f)
       return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
    end
 
    local p = imgui.GetCursorScreenPos()
    local draw_list = imgui.GetWindowDrawList()
 
    local height = imgui.GetTextLineHeightWithSpacing() + (imgui.GetStyle().FramePadding.y / 2)
    local width = height * 1.55
    local radius = height * 0.50
    local ANIM_SPEED = 0.15
 
    if imgui.InvisibleButton(str_id, imgui.ImVec2(width, height)) then
       bool.v = not bool.v
       rBool = true
       LastActiveTime[tostring(str_id)] = os.clock()
       LastActive[str_id] = true
    end
 
    local t = bool.v and 1.0 or 0.0
 
    if LastActive[str_id] then
       local time = os.clock() - LastActiveTime[tostring(str_id)]
       if time <= ANIM_SPEED then
          local t_anim = ImSaturate(time / ANIM_SPEED)
          t = bool.v and t_anim or 1.0 - t_anim
       else
          LastActive[str_id] = false
       end
    end
 
    local col_bg
    if imgui.IsItemHovered() then
       col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgHovered])
    else
       col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBg])
    end
 
    draw_list:AddRectFilled(p, imgui.ImVec2(p.x + width, p.y + height), col_bg, height * 0.5)
    draw_list:AddCircleFilled(imgui.ImVec2(p.x + radius + t * (width - radius * 2.0), p.y + radius), radius - 1.5, imgui.GetColorU32(bool.v and imgui.GetStyle().Colors[imgui.Col.ButtonActive] or imgui.GetStyle().Colors[imgui.Col.Button]))
 
    return rBool
end
function imgui.TextQuestion(text)
    imgui.TextDisabled(u8'(?)')
    if imgui.IsItemHovered() then
        imgui.BeginTooltip()
            imgui.PushTextWrapPos(450)
            imgui.TextUnformatted(text)
            imgui.PopTextWrapPos()
        imgui.EndTooltip()
    end
end

Lua:
themes.SwitchColorTheme(1)
А блять, вот я тупой. Ещё и видео смотрел все равно накосячил. Сябки.

А не можешь сказать, как при переключении Toggel баттона менялась текстура whitetheme на blacktheme?
 

qdIbp

Автор темы
Проверенный
1,450
1,191
А блять, вот я тупой. Ещё и видео смотрел все равно накосячил. Сябки.

А не можешь сказать, как при переключении Toggel баттона менялась текстура whitetheme на blacktheme?
Неа, я с Toggel еще не работал
попробуй: https://www.blast.hk/threads/13380/post-570152
может поможет