Перенос данных мимгуи тем с другого файоа в imgui.Combo

boy next door

Участник
Автор темы
219
18
Версия MoonLoader
.026-beta
здарова.
сделал такой кодик, который должен импортировать темы, но он нифига не работает.
помогите решить проблему.

MIMGUI WINDOW:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new

local renderWindow = new.bool(false)

local selectedTheme = new.int(0)

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local themes = import 'resource/themes.lua'

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 500, 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)
            if imgui.Combo('Select Theme', selectedTheme, themes.colorThemes, #themes.colorThemes) then
                themes.themes(selectedTheme[0] + 1)
            end
        imgui.End()
    end
)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('mim', function()
        renderWindow[0] = not renderWindow[0]
    end)
    while true do
        wait(0)
    end
end

Themes.lua:
local imgui = require 'mimgui'

EXPORTS = {
    colorThemes = {'Dark-grey','Purple'},

    themes = function(theme)
        local ImVec4 = imgui.ImVec4
        local style = imgui.GetStyle()
        local colors = style.Colors

        style.WindowPadding = imgui.ImVec2(15, 15)     
        style.WindowRounding = 10.0
        style.ChildRounding = 6.0
        style.FramePadding = imgui.ImVec2(8, 7)
        style.FrameRounding = 8.0
        style.ItemSpacing = imgui.ImVec2(8, 8)
        style.ItemInnerSpacing = imgui.ImVec2(10, 6)
        style.IndentSpacing = 25.0
        style.ScrollbarSize = 20
        style.ScrollbarRounding = 12.0
        style.GrabMinSize = 10.0
        style.GrabRounding = 6.0
        style.PopupRounding = 8
        style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
        style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
        
        if theme == 1 or theme == nil then
            style.Colors[imgui.Col.Text] = imgui.ImVec4(1.00, 1.00, 1.00, 1.00);
            style.Colors[imgui.Col.TextDisabled] = imgui.ImVec4(0.50, 0.50, 0.50, 1.00);
            style.Colors[imgui.Col.WindowBg] = imgui.ImVec4(0.09, 0.09, 0.09, 1.00);
            style.Colors[imgui.Col.ChildBg] = imgui.ImVec4(0.13, 0.13, 0.13, 1.00);
            style.Colors[imgui.Col.PopupBg] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00);
            style.Colors[imgui.Col.Border] = imgui.ImVec4(0.19, 0.19, 0.19, 1.00);
            style.Colors[imgui.Col.BorderShadow] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00);
            style.Colors[imgui.Col.FrameBg] = imgui.ImVec4(0.08, 0.08, 0.08, 0.54);
            style.Colors[imgui.Col.FrameBgHovered] = imgui.ImVec4(0.16, 0.16, 0.16, 0.54);
            style.Colors[imgui.Col.FrameBgActive] = imgui.ImVec4(0.17, 0.17, 0.17, 0.54);
            style.Colors[imgui.Col.TitleBg] = imgui.ImVec4(0.21, 0.21, 0.21, 1.00);
            style.Colors[imgui.Col.TitleBgActive] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.TitleBgCollapsed] = imgui.ImVec4(0.00, 0.00, 0.00, 0.51);
            style.Colors[imgui.Col.MenuBarBg] = imgui.ImVec4(0.14, 0.14, 0.14, 1.00);
            style.Colors[imgui.Col.ScrollbarBg] = imgui.ImVec4(0.24, 0.24, 0.24, 1.00);
            style.Colors[imgui.Col.ScrollbarGrab] = imgui.ImVec4(0.18, 0.18, 0.18, 1.00);
            style.Colors[imgui.Col.ScrollbarGrabHovered] = imgui.ImVec4(0.18, 0.18, 0.18, 1.00);
            style.Colors[imgui.Col.ScrollbarGrabActive] = imgui.ImVec4(0.36, 0.36, 0.36, 1.00);
            style.Colors[imgui.Col.CheckMark] = imgui.ImVec4(1.00, 1.00, 1.00, 1.00);
            style.Colors[imgui.Col.SliderGrab] = imgui.ImVec4(0.24, 0.24, 0.24, 1.00);
            style.Colors[imgui.Col.SliderGrabActive] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.Button] = imgui.ImVec4(0.24, 0.24, 0.24, 1.00);
            style.Colors[imgui.Col.ButtonHovered] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.ButtonActive] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.Header] = imgui.ImVec4(0.24, 0.24, 0.24, 1.00);
            style.Colors[imgui.Col.HeaderHovered] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.HeaderActive] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.Separator] = imgui.ImVec4(0.71, 0.71, 0.71, 1.00);
            style.Colors[imgui.Col.SeparatorHovered] = imgui.ImVec4(0.71, 0.71, 0.71, 1.00);
            style.Colors[imgui.Col.SeparatorActive] = imgui.ImVec4(0.71, 0.71, 0.71, 1.00);
            style.Colors[imgui.Col.ResizeGrip] = imgui.ImVec4(0.71, 0.71, 0.71, 1.00);
            style.Colors[imgui.Col.ResizeGripHovered] = imgui.ImVec4(0.48, 0.48, 0.48, 1.00);
            style.Colors[imgui.Col.ResizeGripActive] = imgui.ImVec4(0.48, 0.48, 0.48, 1.00);
            style.Colors[imgui.Col.Tab] = imgui.ImVec4(0.24, 0.24, 0.24, 1.00);
            style.Colors[imgui.Col.TabHovered] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.TabActive] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.TabUnfocused] = imgui.ImVec4(0.07, 0.10, 0.15, 0.97);
            style.Colors[imgui.Col.TabUnfocusedActive] = imgui.ImVec4(0.14, 0.26, 0.42, 1.00);
            style.Colors[imgui.Col.PlotLines] = imgui.ImVec4(0.61, 0.61, 0.61, 1.00);
            style.Colors[imgui.Col.PlotLinesHovered] = imgui.ImVec4(1.00, 0.43, 0.35, 1.00);
            style.Colors[imgui.Col.PlotHistogram] = imgui.ImVec4(0.90, 0.70, 0.00, 1.00);
            style.Colors[imgui.Col.PlotHistogramHovered] = imgui.ImVec4(1.00, 0.60, 0.00, 1.00);
            style.Colors[imgui.Col.TextSelectedBg] = imgui.ImVec4(0.26, 0.59, 0.98, 0.35);
            style.Colors[imgui.Col.DragDropTarget] = imgui.ImVec4(1.00, 1.00, 0.00, 0.90);
            style.Colors[imgui.Col.NavHighlight] = imgui.ImVec4(0.26, 0.59, 0.98, 1.00);
            style.Colors[imgui.Col.NavWindowingHighlight] = imgui.ImVec4(1.00, 1.00, 1.00, 0.70);
            style.Colors[imgui.Col.NavWindowingDimBg] = imgui.ImVec4(0.80, 0.80, 0.80, 0.20);
            style.Colors[imgui.Col.ModalWindowDimBg] = imgui.ImVec4(0.80, 0.80, 0.80, 0.35);
        elseif theme == 2 then
            style.Colors[imgui.Col.Text]                   = imgui.ImVec4(1.00, 0.90, 0.85, 1.00)
            style.Colors[imgui.Col.TextDisabled]           = imgui.ImVec4(0.75, 0.60, 0.55, 1.00)
            style.Colors[imgui.Col.WindowBg]               = imgui.ImVec4(0.25, 0.15, 0.10, 1.00)
            style.Colors[imgui.Col.ChildBg]                = imgui.ImVec4(0.30, 0.20, 0.15, 0.30)
            style.Colors[imgui.Col.PopupBg]                = imgui.ImVec4(0.30, 0.20, 0.15, 1.00)
            style.Colors[imgui.Col.Border]                 = imgui.ImVec4(0.80, 0.35, 0.20, 1.00)
            style.Colors[imgui.Col.BorderShadow]           = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
            style.Colors[imgui.Col.FrameBg]                = imgui.ImVec4(0.30, 0.20, 0.15, 1.00)
            style.Colors[imgui.Col.FrameBgHovered]         = imgui.ImVec4(0.45, 0.25, 0.20, 1.00)
            style.Colors[imgui.Col.FrameBgActive]          = imgui.ImVec4(0.55, 0.35, 0.25, 1.00)
            style.Colors[imgui.Col.TitleBg]                = imgui.ImVec4(0.25, 0.15, 0.10, 1.00)
            style.Colors[imgui.Col.TitleBgCollapsed]       = imgui.ImVec4(0.20, 0.10, 0.05, 1.00)
            style.Colors[imgui.Col.TitleBgActive]          = imgui.ImVec4(0.30, 0.20, 0.15, 1.00)
            style.Colors[imgui.Col.MenuBarBg]              = imgui.ImVec4(0.25, 0.15, 0.10, 1.00)
            style.Colors[imgui.Col.ScrollbarBg]            = imgui.ImVec4(0.25, 0.15, 0.10, 1.00)
            style.Colors[imgui.Col.ScrollbarGrab]          = imgui.ImVec4(0.80, 0.35, 0.20, 1.00)
            style.Colors[imgui.Col.ScrollbarGrabHovered]   = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.ScrollbarGrabActive]    = imgui.ImVec4(1.00, 0.65, 0.50, 1.00)
            style.Colors[imgui.Col.CheckMark]              = imgui.ImVec4(1.00, 0.65, 0.50, 1.00)
            style.Colors[imgui.Col.SliderGrab]             = imgui.ImVec4(1.00, 0.65, 0.50, 1.00)
            style.Colors[imgui.Col.SliderGrabActive]       = imgui.ImVec4(1.00, 0.70, 0.55, 1.00)
            style.Colors[imgui.Col.Button]                 = imgui.ImVec4(0.30, 0.20, 0.15, 1.00)
            style.Colors[imgui.Col.ButtonHovered]          = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.ButtonActive]           = imgui.ImVec4(1.00, 0.55, 0.40, 1.00)
            style.Colors[imgui.Col.Header]                 = imgui.ImVec4(0.45, 0.25, 0.20, 1.00)
            style.Colors[imgui.Col.HeaderHovered]          = imgui.ImVec4(0.55, 0.30, 0.25, 1.00)
            style.Colors[imgui.Col.HeaderActive]           = imgui.ImVec4(0.65, 0.40, 0.30, 1.00)
            style.Colors[imgui.Col.Separator]              = imgui.ImVec4(0.80, 0.35, 0.20, 1.00)
            style.Colors[imgui.Col.SeparatorHovered]       = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.SeparatorActive]        = imgui.ImVec4(1.00, 0.65, 0.50, 1.00)
            style.Colors[imgui.Col.ResizeGrip]             = imgui.ImVec4(0.45, 0.25, 0.20, 1.00)
            style.Colors[imgui.Col.ResizeGripHovered]      = imgui.ImVec4(0.55, 0.30, 0.25, 1.00)
            style.Colors[imgui.Col.ResizeGripActive]       = imgui.ImVec4(0.65, 0.40, 0.30, 1.00)
            style.Colors[imgui.Col.PlotLines]              = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.PlotLinesHovered]       = imgui.ImVec4(1.00, 0.55, 0.40, 1.00)
            style.Colors[imgui.Col.PlotHistogram]          = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.PlotHistogramHovered]   = imgui.ImVec4(1.00, 0.55, 0.40, 1.00)
            style.Colors[imgui.Col.TextSelectedBg]         = imgui.ImVec4(0.55, 0.30, 0.25, 1.00)
            style.Colors[imgui.Col.ModalWindowDimBg]       = imgui.ImVec4(0.25, 0.15, 0.10, 0.80)
            style.Colors[imgui.Col.Tab]                    = imgui.ImVec4(0.30, 0.20, 0.15, 1.00)
            style.Colors[imgui.Col.TabHovered]             = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.TabActive]              = imgui.ImVec4(1.00, 0.55, 0.40, 1.00)
        end
    end
}

Лог ошибки:
[00:15:24.110500] (error)    faw.lua: ...es\Arizona Games Launcher\bin\arizona\moonloader\faw.lua:26: bad argument #3 to 'Combo' (cannot convert 'table' to 'const char *const *')
stack traceback:
    [C]: in function 'Combo'
    ...es\Arizona Games Launcher\bin\arizona\moonloader\faw.lua:26: in function '_draw'
    ...ames Launcher\bin\arizona\moonloader\lib\mimgui\init.lua:107: in function <...ames Launcher\bin\arizona\moonloader\lib\mimgui\init.lua:91>
[00:15:24.115500] (error)    faw.lua: Script died due to an error. (185A03C4)
 

boy next door

Участник
Автор темы
219
18
[09:12:13.601000] (error) faw.lua: ...es\Arizona Games Launcher\bin\arizona\moonloader\faw.lua:27: 'const char *[2]' has no member named 'colorThemes'
stack traceback:
...es\Arizona Games Launcher\bin\arizona\moonloader\faw.lua:27: in function '_draw'
...ames Launcher\bin\arizona\moonloader\lib\mimgui\init.lua:107: in function <...ames Launcher\bin\arizona\moonloader\lib\mimgui\init.lua:91>
[09:12:13.604000] (error) faw.lua: Script died due to an error. (1C576A4C)
Lua:
local items = imgui.new['const char*'][#themes.colorThemes](themes.colorThemes)
items писать в комбо аргумент 2 после selectedTheme
 

Theopka

Участник
39
19
Попробуй это
Lua:
local themeItems = {}
for _, v in ipairs(themes.colorThemes) do
    table.insert(themeItems, u8(v))
end

if imgui.Combo('Select Theme', selectedTheme, themeItems, #themeItems) then
    themes.themes(selectedTheme[0] + 1)
end
Если не будет работать сорян, с переносами работаю плохо
 

UBP

Известный
350
204
здарова.
сделал такой кодик, который должен импортировать темы, но он нифига не работает.
помогите решить проблему.

MIMGUI WINDOW:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new

local renderWindow = new.bool(false)

local selectedTheme = new.int(0)

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local themes = import 'resource/themes.lua'

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 500, 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)
            if imgui.Combo('Select Theme', selectedTheme, themes.colorThemes, #themes.colorThemes) then
                themes.themes(selectedTheme[0] + 1)
            end
        imgui.End()
    end
)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('mim', function()
        renderWindow[0] = not renderWindow[0]
    end)
    while true do
        wait(0)
    end
end

Themes.lua:
local imgui = require 'mimgui'

EXPORTS = {
    colorThemes = {'Dark-grey','Purple'},

    themes = function(theme)
        local ImVec4 = imgui.ImVec4
        local style = imgui.GetStyle()
        local colors = style.Colors

        style.WindowPadding = imgui.ImVec2(15, 15)    
        style.WindowRounding = 10.0
        style.ChildRounding = 6.0
        style.FramePadding = imgui.ImVec2(8, 7)
        style.FrameRounding = 8.0
        style.ItemSpacing = imgui.ImVec2(8, 8)
        style.ItemInnerSpacing = imgui.ImVec2(10, 6)
        style.IndentSpacing = 25.0
        style.ScrollbarSize = 20
        style.ScrollbarRounding = 12.0
        style.GrabMinSize = 10.0
        style.GrabRounding = 6.0
        style.PopupRounding = 8
        style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
        style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
       
        if theme == 1 or theme == nil then
            style.Colors[imgui.Col.Text] = imgui.ImVec4(1.00, 1.00, 1.00, 1.00);
            style.Colors[imgui.Col.TextDisabled] = imgui.ImVec4(0.50, 0.50, 0.50, 1.00);
            style.Colors[imgui.Col.WindowBg] = imgui.ImVec4(0.09, 0.09, 0.09, 1.00);
            style.Colors[imgui.Col.ChildBg] = imgui.ImVec4(0.13, 0.13, 0.13, 1.00);
            style.Colors[imgui.Col.PopupBg] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00);
            style.Colors[imgui.Col.Border] = imgui.ImVec4(0.19, 0.19, 0.19, 1.00);
            style.Colors[imgui.Col.BorderShadow] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00);
            style.Colors[imgui.Col.FrameBg] = imgui.ImVec4(0.08, 0.08, 0.08, 0.54);
            style.Colors[imgui.Col.FrameBgHovered] = imgui.ImVec4(0.16, 0.16, 0.16, 0.54);
            style.Colors[imgui.Col.FrameBgActive] = imgui.ImVec4(0.17, 0.17, 0.17, 0.54);
            style.Colors[imgui.Col.TitleBg] = imgui.ImVec4(0.21, 0.21, 0.21, 1.00);
            style.Colors[imgui.Col.TitleBgActive] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.TitleBgCollapsed] = imgui.ImVec4(0.00, 0.00, 0.00, 0.51);
            style.Colors[imgui.Col.MenuBarBg] = imgui.ImVec4(0.14, 0.14, 0.14, 1.00);
            style.Colors[imgui.Col.ScrollbarBg] = imgui.ImVec4(0.24, 0.24, 0.24, 1.00);
            style.Colors[imgui.Col.ScrollbarGrab] = imgui.ImVec4(0.18, 0.18, 0.18, 1.00);
            style.Colors[imgui.Col.ScrollbarGrabHovered] = imgui.ImVec4(0.18, 0.18, 0.18, 1.00);
            style.Colors[imgui.Col.ScrollbarGrabActive] = imgui.ImVec4(0.36, 0.36, 0.36, 1.00);
            style.Colors[imgui.Col.CheckMark] = imgui.ImVec4(1.00, 1.00, 1.00, 1.00);
            style.Colors[imgui.Col.SliderGrab] = imgui.ImVec4(0.24, 0.24, 0.24, 1.00);
            style.Colors[imgui.Col.SliderGrabActive] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.Button] = imgui.ImVec4(0.24, 0.24, 0.24, 1.00);
            style.Colors[imgui.Col.ButtonHovered] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.ButtonActive] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.Header] = imgui.ImVec4(0.24, 0.24, 0.24, 1.00);
            style.Colors[imgui.Col.HeaderHovered] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.HeaderActive] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.Separator] = imgui.ImVec4(0.71, 0.71, 0.71, 1.00);
            style.Colors[imgui.Col.SeparatorHovered] = imgui.ImVec4(0.71, 0.71, 0.71, 1.00);
            style.Colors[imgui.Col.SeparatorActive] = imgui.ImVec4(0.71, 0.71, 0.71, 1.00);
            style.Colors[imgui.Col.ResizeGrip] = imgui.ImVec4(0.71, 0.71, 0.71, 1.00);
            style.Colors[imgui.Col.ResizeGripHovered] = imgui.ImVec4(0.48, 0.48, 0.48, 1.00);
            style.Colors[imgui.Col.ResizeGripActive] = imgui.ImVec4(0.48, 0.48, 0.48, 1.00);
            style.Colors[imgui.Col.Tab] = imgui.ImVec4(0.24, 0.24, 0.24, 1.00);
            style.Colors[imgui.Col.TabHovered] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.TabActive] = imgui.ImVec4(0.37, 0.37, 0.37, 1.00);
            style.Colors[imgui.Col.TabUnfocused] = imgui.ImVec4(0.07, 0.10, 0.15, 0.97);
            style.Colors[imgui.Col.TabUnfocusedActive] = imgui.ImVec4(0.14, 0.26, 0.42, 1.00);
            style.Colors[imgui.Col.PlotLines] = imgui.ImVec4(0.61, 0.61, 0.61, 1.00);
            style.Colors[imgui.Col.PlotLinesHovered] = imgui.ImVec4(1.00, 0.43, 0.35, 1.00);
            style.Colors[imgui.Col.PlotHistogram] = imgui.ImVec4(0.90, 0.70, 0.00, 1.00);
            style.Colors[imgui.Col.PlotHistogramHovered] = imgui.ImVec4(1.00, 0.60, 0.00, 1.00);
            style.Colors[imgui.Col.TextSelectedBg] = imgui.ImVec4(0.26, 0.59, 0.98, 0.35);
            style.Colors[imgui.Col.DragDropTarget] = imgui.ImVec4(1.00, 1.00, 0.00, 0.90);
            style.Colors[imgui.Col.NavHighlight] = imgui.ImVec4(0.26, 0.59, 0.98, 1.00);
            style.Colors[imgui.Col.NavWindowingHighlight] = imgui.ImVec4(1.00, 1.00, 1.00, 0.70);
            style.Colors[imgui.Col.NavWindowingDimBg] = imgui.ImVec4(0.80, 0.80, 0.80, 0.20);
            style.Colors[imgui.Col.ModalWindowDimBg] = imgui.ImVec4(0.80, 0.80, 0.80, 0.35);
        elseif theme == 2 then
            style.Colors[imgui.Col.Text]                   = imgui.ImVec4(1.00, 0.90, 0.85, 1.00)
            style.Colors[imgui.Col.TextDisabled]           = imgui.ImVec4(0.75, 0.60, 0.55, 1.00)
            style.Colors[imgui.Col.WindowBg]               = imgui.ImVec4(0.25, 0.15, 0.10, 1.00)
            style.Colors[imgui.Col.ChildBg]                = imgui.ImVec4(0.30, 0.20, 0.15, 0.30)
            style.Colors[imgui.Col.PopupBg]                = imgui.ImVec4(0.30, 0.20, 0.15, 1.00)
            style.Colors[imgui.Col.Border]                 = imgui.ImVec4(0.80, 0.35, 0.20, 1.00)
            style.Colors[imgui.Col.BorderShadow]           = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
            style.Colors[imgui.Col.FrameBg]                = imgui.ImVec4(0.30, 0.20, 0.15, 1.00)
            style.Colors[imgui.Col.FrameBgHovered]         = imgui.ImVec4(0.45, 0.25, 0.20, 1.00)
            style.Colors[imgui.Col.FrameBgActive]          = imgui.ImVec4(0.55, 0.35, 0.25, 1.00)
            style.Colors[imgui.Col.TitleBg]                = imgui.ImVec4(0.25, 0.15, 0.10, 1.00)
            style.Colors[imgui.Col.TitleBgCollapsed]       = imgui.ImVec4(0.20, 0.10, 0.05, 1.00)
            style.Colors[imgui.Col.TitleBgActive]          = imgui.ImVec4(0.30, 0.20, 0.15, 1.00)
            style.Colors[imgui.Col.MenuBarBg]              = imgui.ImVec4(0.25, 0.15, 0.10, 1.00)
            style.Colors[imgui.Col.ScrollbarBg]            = imgui.ImVec4(0.25, 0.15, 0.10, 1.00)
            style.Colors[imgui.Col.ScrollbarGrab]          = imgui.ImVec4(0.80, 0.35, 0.20, 1.00)
            style.Colors[imgui.Col.ScrollbarGrabHovered]   = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.ScrollbarGrabActive]    = imgui.ImVec4(1.00, 0.65, 0.50, 1.00)
            style.Colors[imgui.Col.CheckMark]              = imgui.ImVec4(1.00, 0.65, 0.50, 1.00)
            style.Colors[imgui.Col.SliderGrab]             = imgui.ImVec4(1.00, 0.65, 0.50, 1.00)
            style.Colors[imgui.Col.SliderGrabActive]       = imgui.ImVec4(1.00, 0.70, 0.55, 1.00)
            style.Colors[imgui.Col.Button]                 = imgui.ImVec4(0.30, 0.20, 0.15, 1.00)
            style.Colors[imgui.Col.ButtonHovered]          = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.ButtonActive]           = imgui.ImVec4(1.00, 0.55, 0.40, 1.00)
            style.Colors[imgui.Col.Header]                 = imgui.ImVec4(0.45, 0.25, 0.20, 1.00)
            style.Colors[imgui.Col.HeaderHovered]          = imgui.ImVec4(0.55, 0.30, 0.25, 1.00)
            style.Colors[imgui.Col.HeaderActive]           = imgui.ImVec4(0.65, 0.40, 0.30, 1.00)
            style.Colors[imgui.Col.Separator]              = imgui.ImVec4(0.80, 0.35, 0.20, 1.00)
            style.Colors[imgui.Col.SeparatorHovered]       = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.SeparatorActive]        = imgui.ImVec4(1.00, 0.65, 0.50, 1.00)
            style.Colors[imgui.Col.ResizeGrip]             = imgui.ImVec4(0.45, 0.25, 0.20, 1.00)
            style.Colors[imgui.Col.ResizeGripHovered]      = imgui.ImVec4(0.55, 0.30, 0.25, 1.00)
            style.Colors[imgui.Col.ResizeGripActive]       = imgui.ImVec4(0.65, 0.40, 0.30, 1.00)
            style.Colors[imgui.Col.PlotLines]              = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.PlotLinesHovered]       = imgui.ImVec4(1.00, 0.55, 0.40, 1.00)
            style.Colors[imgui.Col.PlotHistogram]          = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.PlotHistogramHovered]   = imgui.ImVec4(1.00, 0.55, 0.40, 1.00)
            style.Colors[imgui.Col.TextSelectedBg]         = imgui.ImVec4(0.55, 0.30, 0.25, 1.00)
            style.Colors[imgui.Col.ModalWindowDimBg]       = imgui.ImVec4(0.25, 0.15, 0.10, 0.80)
            style.Colors[imgui.Col.Tab]                    = imgui.ImVec4(0.30, 0.20, 0.15, 1.00)
            style.Colors[imgui.Col.TabHovered]             = imgui.ImVec4(0.90, 0.50, 0.35, 1.00)
            style.Colors[imgui.Col.TabActive]              = imgui.ImVec4(1.00, 0.55, 0.40, 1.00)
        end
    end
}

Лог ошибки:
[00:15:24.110500] (error)    faw.lua: ...es\Arizona Games Launcher\bin\arizona\moonloader\faw.lua:26: bad argument #3 to 'Combo' (cannot convert 'table' to 'const char *const *')
stack traceback:
    [C]: in function 'Combo'
    ...es\Arizona Games Launcher\bin\arizona\moonloader\faw.lua:26: in function '_draw'
    ...ames Launcher\bin\arizona\moonloader\lib\mimgui\init.lua:107: in function <...ames Launcher\bin\arizona\moonloader\lib\mimgui\init.lua:91>
[00:15:24.115500] (error)    faw.lua: Script died due to an error. (185A03C4)
Combo ожидает массив строк в качестве третьего аргумента, но ты передаешь таблицу (themes.colorThemes)


Lua:
-- Преобразуем таблицу цветовых тем в массив строк
local colorThemeNames = {}
for i, theme in ipairs(themes.colorThemes) do
    colorThemeNames[i-1] = theme
end

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 500, 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)
            if imgui.Combo('Select Theme', selectedTheme, colorThemeNames, #themes.colorThemes) then
                themes.themes(selectedTheme[0] + 1)
            end
        imgui.End()
    end
)


Lua:
local EXPORTS = {
    colorThemes = {'Dark-grey', 'Purple'},
    -- ...
}

return EXPORTS
 

boy next door

Участник
Автор темы
219
18
Combo ожидает массив строк в качестве третьего аргумента, но ты передаешь таблицу (themes.colorThemes)


Lua:
-- Преобразуем таблицу цветовых тем в массив строк
local colorThemeNames = {}
for i, theme in ipairs(themes.colorThemes) do
    colorThemeNames[i-1] = theme
end

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 500, 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)
            if imgui.Combo('Select Theme', selectedTheme, colorThemeNames, #themes.colorThemes) then
                themes.themes(selectedTheme[0] + 1)
            end
        imgui.End()
    end
)


Lua:
local EXPORTS = {
    colorThemes = {'Dark-grey', 'Purple'},
    -- ...
}

return EXPORTS
[ML] (error) faw.lua: F:\white gta ot subs x smoke\moonloader\faw.lua:32: bad argument #3 to 'Combo' (cannot convert 'table' to 'const char *const *')
stack traceback:
[C]: in function 'Combo'
F:\white gta ot subs x smoke\moonloader\faw.lua:32: in function '_draw'
F:\white gta ot subs x smoke\moonloader\lib\mimgui\init.lua:107: in function <F:\white gta ot subs x smoke\moonloader\lib\mimgui\init.lua:91>
[ML] (error) faw.lua: Script died due to an error. (01959D34)

Lua:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new

local renderWindow = new.bool(false)

local selectedTheme = new.int(0)

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local themes = import 'resource/themes.lua'
local items = imgui.new['const char*'][#themes.colorThemes](themes.colorThemes)

local colorThemeNames = {}
for i, theme in ipairs(themes.colorThemes) do
    colorThemeNames[i-1] = theme
end

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 500, 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)
            if imgui.Combo('Select Theme', selectedTheme, colorThemeNames, #themes.colorThemes) then
                themes.themes(selectedTheme[0] + 1)
            end
        imgui.End()
    end
)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('mim', function()
        renderWindow[0] = not renderWindow[0]
    end)
    while true do
        wait(0)
    end
end
 

UBP

Известный
350
204
[ML] (error) faw.lua: F:\white gta ot subs x smoke\moonloader\faw.lua:32: bad argument #3 to 'Combo' (cannot convert 'table' to 'const char *const *')
stack traceback:
[C]: in function 'Combo'
F:\white gta ot subs x smoke\moonloader\faw.lua:32: in function '_draw'
F:\white gta ot subs x smoke\moonloader\lib\mimgui\init.lua:107: in function <F:\white gta ot subs x smoke\moonloader\lib\mimgui\init.lua:91>
[ML] (error) faw.lua: Script died due to an error. (01959D34)

Lua:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new

local renderWindow = new.bool(false)

local selectedTheme = new.int(0)

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local themes = import 'resource/themes.lua'
local items = imgui.new['const char*'][#themes.colorThemes](themes.colorThemes)

local colorThemeNames = {}
for i, theme in ipairs(themes.colorThemes) do
    colorThemeNames[i-1] = theme
end

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 500, 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)
            if imgui.Combo('Select Theme', selectedTheme, colorThemeNames, #themes.colorThemes) then
                themes.themes(selectedTheme[0] + 1)
            end
        imgui.End()
    end
)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('mim', function()
        renderWindow[0] = not renderWindow[0]
    end)
    while true do
        wait(0)
    end
end
Lua:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local themes = require 'themes'

local window = imgui.new.bool(false)
local selectedTheme = imgui.new.int(0)

-- строка со всеми темами, разделенными нулевым символом
local themesString = table.concat(themes.colorThemes, '\0') .. '\0'

local main_window = imgui.OnFrame(
    function() return window[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(300, 300), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(200, 100), imgui.Cond.FirstUseEver)
        imgui.Begin('Theme Selector', window)

        if imgui.Combo('Theme', selectedTheme, themesString, #themes.colorThemes) then
            themes.applyTheme(selectedTheme[0] + 1)
        end

        imgui.End()
    end
)

function main()
    while not isSampAvailable() do wait(0) end
    
    sampRegisterChatCommand('themes', function()
        window[0] = not window[0]
    end)

    while true do
        wait(0)
    end
end


Lua:
local imgui = require 'mimgui'

local themes = {
    colorThemes = {'Dark', 'Light', 'Classic'},

    applyTheme = function(themeIndex)
        local style = imgui.GetStyle()
        local colors = style.Colors
        local clr = imgui.Col
        local ImVec4 = imgui.ImVec4

        style.WindowPadding = imgui.ImVec2(8, 8)
        style.WindowRounding = 6
        style.ChildRounding = 5
        style.FramePadding = imgui.ImVec2(5, 3)
        style.FrameRounding = 3.0
        style.ItemSpacing = imgui.ImVec2(5, 4)
        style.ItemInnerSpacing = imgui.ImVec2(4, 4)
        style.IndentSpacing = 21
        style.ScrollbarSize = 10.0
        style.ScrollbarRounding = 13
        style.GrabMinSize = 8
        style.GrabRounding = 1
        style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
        style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)

        if themeIndex == 1 then
            colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
            colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
            colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 0.94)
            colors[clr.ChildBg]                = ImVec4(0.00, 0.00, 0.00, 0.00)
            colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
            colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
            colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
            colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
            colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
            colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
        elseif themeIndex == 2 then
            colors[clr.Text]                   = ImVec4(0.00, 0.00, 0.00, 1.00)
            colors[clr.TextDisabled]           = ImVec4(0.60, 0.60, 0.60, 1.00)
            colors[clr.WindowBg]               = ImVec4(0.94, 0.94, 0.94, 1.00)
            colors[clr.ChildBg]                = ImVec4(0.00, 0.00, 0.00, 0.00)
            colors[clr.PopupBg]                = ImVec4(1.00, 1.00, 1.00, 0.98)
            colors[clr.Border]                 = ImVec4(0.00, 0.00, 0.00, 0.30)
            colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
            colors[clr.FrameBg]                = ImVec4(1.00, 1.00, 1.00, 1.00)
            colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
        end
    end
}

return themes
 

boy next door

Участник
Автор темы
219
18
Lua:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local themes = require 'themes'

local window = imgui.new.bool(false)
local selectedTheme = imgui.new.int(0)

-- строка со всеми темами, разделенными нулевым символом
local themesString = table.concat(themes.colorThemes, '\0') .. '\0'

local main_window = imgui.OnFrame(
    function() return window[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(300, 300), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(200, 100), imgui.Cond.FirstUseEver)
        imgui.Begin('Theme Selector', window)

        if imgui.Combo('Theme', selectedTheme, themesString, #themes.colorThemes) then
            themes.applyTheme(selectedTheme[0] + 1)
        end

        imgui.End()
    end
)

function main()
    while not isSampAvailable() do wait(0) end
   
    sampRegisterChatCommand('themes', function()
        window[0] = not window[0]
    end)

    while true do
        wait(0)
    end
end


Lua:
local imgui = require 'mimgui'

local themes = {
    colorThemes = {'Dark', 'Light', 'Classic'},

    applyTheme = function(themeIndex)
        local style = imgui.GetStyle()
        local colors = style.Colors
        local clr = imgui.Col
        local ImVec4 = imgui.ImVec4

        style.WindowPadding = imgui.ImVec2(8, 8)
        style.WindowRounding = 6
        style.ChildRounding = 5
        style.FramePadding = imgui.ImVec2(5, 3)
        style.FrameRounding = 3.0
        style.ItemSpacing = imgui.ImVec2(5, 4)
        style.ItemInnerSpacing = imgui.ImVec2(4, 4)
        style.IndentSpacing = 21
        style.ScrollbarSize = 10.0
        style.ScrollbarRounding = 13
        style.GrabMinSize = 8
        style.GrabRounding = 1
        style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
        style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)

        if themeIndex == 1 then
            colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
            colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
            colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 0.94)
            colors[clr.ChildBg]                = ImVec4(0.00, 0.00, 0.00, 0.00)
            colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
            colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
            colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
            colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
            colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
            colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
        elseif themeIndex == 2 then
            colors[clr.Text]                   = ImVec4(0.00, 0.00, 0.00, 1.00)
            colors[clr.TextDisabled]           = ImVec4(0.60, 0.60, 0.60, 1.00)
            colors[clr.WindowBg]               = ImVec4(0.94, 0.94, 0.94, 1.00)
            colors[clr.ChildBg]                = ImVec4(0.00, 0.00, 0.00, 0.00)
            colors[clr.PopupBg]                = ImVec4(1.00, 1.00, 1.00, 0.98)
            colors[clr.Border]                 = ImVec4(0.00, 0.00, 0.00, 0.30)
            colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
            colors[clr.FrameBg]                = ImVec4(1.00, 1.00, 1.00, 1.00)
            colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
        end
    end
}

return themes

[13:04:14.732000] (error) faw.lua: F:\white gta ot subs x smoke\moonloader\faw.lua:6: module 'themes' not found:
no field package.preload['themes']
no file 'F:\white gta ot subs x smoke\moonloader\lib\themes.lua'
no file 'F:\white gta ot subs x smoke\moonloader\lib\themes\init.lua'
no file 'F:\white gta ot subs x smoke\moonloader\themes.lua'
no file 'F:\white gta ot subs x smoke\moonloader\themes\init.lua'
no file '.\themes.lua'
no file 'F:\white gta ot subs x smoke\moonloader\lib\themes.luac'
no file 'F:\white gta ot subs x smoke\moonloader\lib\themes\init.luac'
no file 'F:\white gta ot subs x smoke\moonloader\themes.luac'
no file 'F:\white gta ot subs x smoke\moonloader\themes\init.luac'
no file '.\themes.luac'
no file 'F:\white gta ot subs x smoke\moonloader\lib\themes.dll'
stack traceback:
[C]: in function 'require'
F:\white gta ot subs x smoke\moonloader\faw.lua:6: in main chunk
[13:04:14.732000] (error) faw.lua: Script died due to an error. (171C2944)

я не могу понять, если поставить вместо local themes = require 'themes' это - local themes = import 'resource/themes.lua', то оно выдаёт другую ошибку -

[13:02:37.279000] (error) faw.lua: F:\white gta ot subs x smoke\moonloader\faw.lua:12: attempt to index local 'themes' (a nil value)
stack traceback:
F:\white gta ot subs x smoke\moonloader\faw.lua:12: in main chunk
[13:02:37.279000] (error) faw.lua: Script died due to an error. (171C10C4)