[imgui] Как сделать переключатель стилей с помощью imgui.Combo

sat0ry

Известный
Автор темы
1,092
293
Версия MoonLoader
.026-beta
Мужики, хелп пж! Помогите сделать переключатель стилей imgui через комбо бокс!
 

Dmitriy Makarov

25.05.2021
Проверенный
2,500
1,131
Если я нигде не накосячил, то всё должно работать.
Lua:
-- Начало
local style_selected = imgui.ImInt(1) -- 1 - Стандартное значение. ID стиля.
local style_list = {u8"Серая", u8"Синяя", u8"Тёмная", u8"Вишнёвая", u8"Тёмно-зелёная"} -- Список стилей. Я надеюсь, у тебя подключена библиотека "encoding"

-- OnDrawFrame()
if imgui.Combo(u8"Выберите стиль темы", style_selected, style_list, style_selected) then
    style(style_selected.v) -- Применяем сразу же выбранный стиль
    
    -- Дополнительно. Ну, для красоты.)
    sampAddChatMessage("Выбрана тема: №"..(style_selected.v + 1).." - "..u8:decode(style_list[style_selected.v + 1]), -1)
end

-- Отдельно. Можешь в самый низ пихать
function style(id)
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    if id == 0 then -- gray
        colors[clr.Text]                   = ImVec4(0.95, 0.96, 0.98, 1.00)
        colors[clr.TextDisabled]           = ImVec4(0.36, 0.42, 0.47, 1.00)
        colors[clr.WindowBg]               = ImVec4(0.11, 0.15, 0.17, 1.00)
        colors[clr.ChildWindowBg]          = ImVec4(0.15, 0.18, 0.22, 1.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.20, 0.25, 0.29, 1.00)
        colors[clr.FrameBgHovered]         = ImVec4(0.12, 0.20, 0.28, 1.00)
        colors[clr.FrameBgActive]          = ImVec4(0.09, 0.12, 0.14, 1.00)
        colors[clr.TitleBg]                = ImVec4(0.09, 0.12, 0.14, 0.65)
        colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
        colors[clr.TitleBgActive]          = ImVec4(0.08, 0.10, 0.12, 1.00)
        colors[clr.MenuBarBg]              = ImVec4(0.15, 0.18, 0.22, 1.00)
        colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.39)
        colors[clr.ScrollbarGrab]          = ImVec4(0.20, 0.25, 0.29, 1.00)
        colors[clr.ScrollbarGrabHovered]   = ImVec4(0.18, 0.22, 0.25, 1.00)
        colors[clr.ScrollbarGrabActive]    = ImVec4(0.09, 0.21, 0.31, 1.00)
        colors[clr.ComboBg]                = ImVec4(0.20, 0.25, 0.29, 1.00)
        colors[clr.CheckMark]              = ImVec4(0.28, 0.56, 1.00, 1.00)
        colors[clr.SliderGrab]             = ImVec4(0.28, 0.56, 1.00, 1.00)
        colors[clr.SliderGrabActive]       = ImVec4(0.37, 0.61, 1.00, 1.00)
        colors[clr.Button]                 = ImVec4(0.20, 0.25, 0.29, 1.00)
        colors[clr.ButtonHovered]          = ImVec4(0.28, 0.56, 1.00, 1.00)
        colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
        colors[clr.Header]                 = ImVec4(0.20, 0.25, 0.29, 0.55)
        colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
        colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.ResizeGrip]             = ImVec4(0.26, 0.59, 0.98, 0.25)
        colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.59, 0.98, 0.67)
        colors[clr.ResizeGripActive]       = ImVec4(0.06, 0.05, 0.07, 1.00)
        colors[clr.CloseButton]            = ImVec4(1.00, 0.39, 0.38, 0.56)
        colors[clr.CloseButtonHovered]     = ImVec4(1.00, 0.39, 0.38, 0.69)
        colors[clr.CloseButtonActive]      = ImVec4(1.00, 0.39, 0.38, 1.00)
        colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
        colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
        colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
        colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 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)
    elseif id == 1 then -- blue
        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)
        colors[clr.TitleBg]                 = ImVec4(0.04, 0.04, 0.04, 1.00)
        colors[clr.TitleBgActive]           = ImVec4(0.16, 0.29, 0.48, 1.00)
        colors[clr.TitleBgCollapsed]        = ImVec4(0.00, 0.00, 0.00, 0.51)
        colors[clr.CheckMark]               = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.SliderGrab]              = ImVec4(0.24, 0.52, 0.88, 1.00)
        colors[clr.SliderGrabActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.Button]                  = ImVec4(0.26, 0.59, 0.98, 0.40)
        colors[clr.ButtonHovered]           = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.ButtonActive]            = ImVec4(0.06, 0.53, 0.98, 1.00)
        colors[clr.Header]                  = ImVec4(0.26, 0.59, 0.98, 0.31)
        colors[clr.HeaderHovered]           = ImVec4(0.26, 0.59, 0.98, 0.80)
        colors[clr.HeaderActive]            = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.Separator]               = colors[clr.Border]
        colors[clr.SeparatorHovered]        = ImVec4(0.26, 0.59, 0.98, 0.78)
        colors[clr.SeparatorActive]         = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.ResizeGrip]              = ImVec4(0.26, 0.59, 0.98, 0.25)
        colors[clr.ResizeGripHovered]       = ImVec4(0.26, 0.59, 0.98, 0.67)
        colors[clr.ResizeGripActive]        = ImVec4(0.26, 0.59, 0.98, 0.95)
        colors[clr.TextSelectedBg]          = ImVec4(0.26, 0.59, 0.98, 0.35)
        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.ChildWindowBg]           = ImVec4(1.00, 1.00, 1.00, 0.00)
        colors[clr.PopupBg]                 = ImVec4(0.08, 0.08, 0.08, 0.94)
        colors[clr.ComboBg]                 = colors[clr.PopupBg]
        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.MenuBarBg]               = ImVec4(0.14, 0.14, 0.14, 1.00)
        colors[clr.ScrollbarBg]             = ImVec4(0.02, 0.02, 0.02, 0.53)
        colors[clr.ScrollbarGrab]           = ImVec4(0.31, 0.31, 0.31, 1.00)
        colors[clr.ScrollbarGrabHovered]    = ImVec4(0.41, 0.41, 0.41, 1.00)
        colors[clr.ScrollbarGrabActive]     = ImVec4(0.51, 0.51, 0.51, 1.00)
        colors[clr.CloseButton]             = ImVec4(0.41, 0.41, 0.41, 0.50)
        colors[clr.CloseButtonHovered]      = ImVec4(0.98, 0.39, 0.36, 1.00)
        colors[clr.CloseButtonActive]       = ImVec4(0.98, 0.39, 0.36, 1.00)
        colors[clr.PlotLines]               = ImVec4(0.61, 0.61, 0.61, 1.00)
        colors[clr.PlotLinesHovered]        = ImVec4(1.00, 0.43, 0.35, 1.00)
        colors[clr.PlotHistogram]           = ImVec4(0.90, 0.70, 0.00, 1.00)
        colors[clr.PlotHistogramHovered]    = ImVec4(1.00, 0.60, 0.00, 1.00)
        colors[clr.ModalWindowDarkening]    = ImVec4(0.80, 0.80, 0.80, 0.35)
    elseif id == 2 then -- dark
        colors[clr.Text]                    = ImVec4(0.80, 0.80, 0.83, 1.00)
        colors[clr.TextDisabled]            = ImVec4(0.24, 0.23, 0.29, 1.00)
        colors[clr.WindowBg]                = ImVec4(0.06, 0.05, 0.07, 1.00)
        colors[clr.ChildWindowBg]           = ImVec4(0.07, 0.07, 0.09, 1.00)
        colors[clr.PopupBg]                 = ImVec4(0.07, 0.07, 0.09, 1.00)
        colors[clr.Border]                  = ImVec4(0.43, 0.43, 0.50, 0.50)
        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(0.10, 0.09, 0.12, 1.00)
        colors[clr.ButtonHovered]           = ImVec4(0.24, 0.23, 0.29, 1.00)
        colors[clr.ButtonActive]            = ImVec4(0.56, 0.56, 0.58, 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)
    elseif id == 3 then -- cherry
        colors[clr.Text]                    = ImVec4(0.860, 0.930, 0.890, 0.78)
        colors[clr.TextDisabled]            = ImVec4(0.860, 0.930, 0.890, 0.28)
        colors[clr.WindowBg]                = ImVec4(0.13, 0.14, 0.17, 1.00)
        colors[clr.ChildWindowBg]           = ImVec4(0.200, 0.220, 0.270, 0.58)
        colors[clr.PopupBg]                 = ImVec4(0.200, 0.220, 0.270, 0.9)
        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.200, 0.220, 0.270, 1.00)
        colors[clr.FrameBgHovered]          = ImVec4(0.455, 0.198, 0.301, 0.78)
        colors[clr.FrameBgActive]           = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.TitleBg]                 = ImVec4(0.232, 0.201, 0.271, 1.00)
        colors[clr.TitleBgActive]           = ImVec4(0.502, 0.075, 0.256, 1.00)
        colors[clr.TitleBgCollapsed]        = ImVec4(0.200, 0.220, 0.270, 0.75)
        colors[clr.MenuBarBg]               = ImVec4(0.200, 0.220, 0.270, 0.47)
        colors[clr.ScrollbarBg]             = ImVec4(0.200, 0.220, 0.270, 1.00)
        colors[clr.ScrollbarGrab]           = ImVec4(0.09, 0.15, 0.1, 1.00)
        colors[clr.ScrollbarGrabHovered]    = ImVec4(0.455, 0.198, 0.301, 0.78)
        colors[clr.ScrollbarGrabActive]     = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.CheckMark]               = ImVec4(0.71, 0.22, 0.27, 1.00)
        colors[clr.SliderGrab]              = ImVec4(0.47, 0.77, 0.83, 0.14)
        colors[clr.SliderGrabActive]        = ImVec4(0.71, 0.22, 0.27, 1.00)
        colors[clr.Button]                  = ImVec4(0.47, 0.77, 0.83, 0.14)
        colors[clr.ButtonHovered]           = ImVec4(0.455, 0.198, 0.301, 0.86)
        colors[clr.ButtonActive]            = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.Header]                  = ImVec4(0.455, 0.198, 0.301, 0.76)
        colors[clr.HeaderHovered]           = ImVec4(0.455, 0.198, 0.301, 0.86)
        colors[clr.HeaderActive]            = ImVec4(0.502, 0.075, 0.256, 1.00)
        colors[clr.ResizeGrip]              = ImVec4(0.47, 0.77, 0.83, 0.04)
        colors[clr.ResizeGripHovered]       = ImVec4(0.455, 0.198, 0.301, 0.78)
        colors[clr.ResizeGripActive]        = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.PlotLines]               = ImVec4(0.860, 0.930, 0.890, 0.63)
        colors[clr.PlotLinesHovered]        = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.PlotHistogram]           = ImVec4(0.860, 0.930, 0.890, 0.63)
        colors[clr.PlotHistogramHovered]    = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.TextSelectedBg]          = ImVec4(0.455, 0.198, 0.301, 0.43)
        colors[clr.ModalWindowDarkening]    = ImVec4(0.200, 0.220, 0.270, 0.73)
    elseif id == 4 then -- dark green
        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.ChildWindowBg]           = 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.44, 0.44, 0.44, 0.60)
        colors[clr.FrameBgHovered]          = ImVec4(0.57, 0.57, 0.57, 0.70)
        colors[clr.FrameBgActive]           = ImVec4(0.76, 0.76, 0.76, 0.80)
        colors[clr.TitleBg]                 = ImVec4(0.04, 0.04, 0.04, 1.00)
        colors[clr.TitleBgActive]           = ImVec4(0.16, 0.16, 0.16, 1.00)
        colors[clr.TitleBgCollapsed]        = ImVec4(0.00, 0.00, 0.00, 0.60)
        colors[clr.MenuBarBg]               = ImVec4(0.14, 0.14, 0.14, 1.00)
        colors[clr.ScrollbarBg]             = ImVec4(0.02, 0.02, 0.02, 0.53)
        colors[clr.ScrollbarGrab]           = ImVec4(0.31, 0.31, 0.31, 1.00)
        colors[clr.ScrollbarGrabHovered]    = ImVec4(0.41, 0.41, 0.41, 1.00)
        colors[clr.ScrollbarGrabActive]     = ImVec4(0.51, 0.51, 0.51, 1.00)
        colors[clr.CheckMark]               = ImVec4(0.13, 0.75, 0.55, 0.80)
        colors[clr.SliderGrab]              = ImVec4(0.13, 0.75, 0.75, 0.80)
        colors[clr.SliderGrabActive]        = ImVec4(0.13, 0.75, 1.00, 0.80)
        colors[clr.Button]                  = ImVec4(0.13, 0.75, 0.55, 0.40)
        colors[clr.ButtonHovered]           = ImVec4(0.13, 0.75, 0.75, 0.60)
        colors[clr.ButtonActive]            = ImVec4(0.13, 0.75, 1.00, 0.80)
        colors[clr.Header]                  = ImVec4(0.13, 0.75, 0.55, 0.40)
        colors[clr.HeaderHovered]           = ImVec4(0.13, 0.75, 0.75, 0.60)
        colors[clr.HeaderActive]            = ImVec4(0.13, 0.75, 1.00, 0.80)
        colors[clr.Separator]               = ImVec4(0.13, 0.75, 0.55, 0.40)
        colors[clr.SeparatorHovered]        = ImVec4(0.13, 0.75, 0.75, 0.60)
        colors[clr.SeparatorActive]         = ImVec4(0.13, 0.75, 1.00, 0.80)
        colors[clr.ResizeGrip]              = ImVec4(0.13, 0.75, 0.55, 0.40)
        colors[clr.ResizeGripHovered]       = ImVec4(0.13, 0.75, 0.75, 0.60)
        colors[clr.ResizeGripActive]        = ImVec4(0.13, 0.75, 1.00, 0.80)
        colors[clr.PlotLines]               = ImVec4(0.61, 0.61, 0.61, 1.00)
        colors[clr.PlotLinesHovered]        = ImVec4(1.00, 0.43, 0.35, 1.00)
        colors[clr.PlotHistogram]           = ImVec4(0.90, 0.70, 0.00, 1.00)
        colors[clr.PlotHistogramHovered]    = ImVec4(1.00, 0.60, 0.00, 1.00)
        colors[clr.TextSelectedBg]          = ImVec4(0.26, 0.59, 0.98, 0.35)
        colors[clr.ModalWindowDarkening]    = ImVec4(0.80, 0.80, 0.80, 0.35)
    end
end
style(style_selected.v) -- Тут сразу применяем стандартный стиль
Lua:
-- В начало
local inicfg = require 'inicfg'

local mainIni = inicfg.load({
    config =
    {
        style = 1 -- Тут тот же стиль стандартный.
    }
}, "style.ini")

-- Сразу создаём ini файл, чтобы оттуда брать значение стиля.
if not doesFileExist('moonloader/config/style.ini') then
    inicfg.save(mainIni, 'style.ini')
end

local style_selected = imgui.ImInt(mainIni.config.style) -- Берём стандартное значение стиля из конфига
local style_list = {u8"Серая", u8"Синяя", u8"Тёмная", u8"Вишнёвая", u8"Тёмно-зелёная"}

-- OnDrawFrame()
if imgui.Combo(u8"Выберите стиль темы", style_selected, style_list, style_selected) then
    style(style_selected.v) -- Применяем сразу же выбранный стиль
    mainIni.config.style = style_selected.v -- Перезаписываем значение стиля в конфиге. Ну ID'шник выбранного стиля
    inicfg.save(mainIni, 'style.ini') -- Сохраняем конфиг

    -- Дополнительно. Ну, для красоты.)
    sampAddChatMessage("Выбрана тема: №"..(style_selected.v + 1).." - "..u8:decode(style_list[style_selected.v + 1]), -1)
end

--
function style(id)
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    if id == 0 then -- gray
        colors[clr.Text]                   = ImVec4(0.95, 0.96, 0.98, 1.00)
        colors[clr.TextDisabled]           = ImVec4(0.36, 0.42, 0.47, 1.00)
        colors[clr.WindowBg]               = ImVec4(0.11, 0.15, 0.17, 1.00)
        colors[clr.ChildWindowBg]          = ImVec4(0.15, 0.18, 0.22, 1.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.20, 0.25, 0.29, 1.00)
        colors[clr.FrameBgHovered]         = ImVec4(0.12, 0.20, 0.28, 1.00)
        colors[clr.FrameBgActive]          = ImVec4(0.09, 0.12, 0.14, 1.00)
        colors[clr.TitleBg]                = ImVec4(0.09, 0.12, 0.14, 0.65)
        colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
        colors[clr.TitleBgActive]          = ImVec4(0.08, 0.10, 0.12, 1.00)
        colors[clr.MenuBarBg]              = ImVec4(0.15, 0.18, 0.22, 1.00)
        colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.39)
        colors[clr.ScrollbarGrab]          = ImVec4(0.20, 0.25, 0.29, 1.00)
        colors[clr.ScrollbarGrabHovered]   = ImVec4(0.18, 0.22, 0.25, 1.00)
        colors[clr.ScrollbarGrabActive]    = ImVec4(0.09, 0.21, 0.31, 1.00)
        colors[clr.ComboBg]                = ImVec4(0.20, 0.25, 0.29, 1.00)
        colors[clr.CheckMark]              = ImVec4(0.28, 0.56, 1.00, 1.00)
        colors[clr.SliderGrab]             = ImVec4(0.28, 0.56, 1.00, 1.00)
        colors[clr.SliderGrabActive]       = ImVec4(0.37, 0.61, 1.00, 1.00)
        colors[clr.Button]                 = ImVec4(0.20, 0.25, 0.29, 1.00)
        colors[clr.ButtonHovered]          = ImVec4(0.28, 0.56, 1.00, 1.00)
        colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
        colors[clr.Header]                 = ImVec4(0.20, 0.25, 0.29, 0.55)
        colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
        colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.ResizeGrip]             = ImVec4(0.26, 0.59, 0.98, 0.25)
        colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.59, 0.98, 0.67)
        colors[clr.ResizeGripActive]       = ImVec4(0.06, 0.05, 0.07, 1.00)
        colors[clr.CloseButton]            = ImVec4(1.00, 0.39, 0.38, 0.56)
        colors[clr.CloseButtonHovered]     = ImVec4(1.00, 0.39, 0.38, 0.69)
        colors[clr.CloseButtonActive]      = ImVec4(1.00, 0.39, 0.38, 1.00)
        colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
        colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
        colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
        colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 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)
    elseif id == 1 then -- blue
        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)
        colors[clr.TitleBg]                 = ImVec4(0.04, 0.04, 0.04, 1.00)
        colors[clr.TitleBgActive]           = ImVec4(0.16, 0.29, 0.48, 1.00)
        colors[clr.TitleBgCollapsed]        = ImVec4(0.00, 0.00, 0.00, 0.51)
        colors[clr.CheckMark]               = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.SliderGrab]              = ImVec4(0.24, 0.52, 0.88, 1.00)
        colors[clr.SliderGrabActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.Button]                  = ImVec4(0.26, 0.59, 0.98, 0.40)
        colors[clr.ButtonHovered]           = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.ButtonActive]            = ImVec4(0.06, 0.53, 0.98, 1.00)
        colors[clr.Header]                  = ImVec4(0.26, 0.59, 0.98, 0.31)
        colors[clr.HeaderHovered]           = ImVec4(0.26, 0.59, 0.98, 0.80)
        colors[clr.HeaderActive]            = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.Separator]               = colors[clr.Border]
        colors[clr.SeparatorHovered]        = ImVec4(0.26, 0.59, 0.98, 0.78)
        colors[clr.SeparatorActive]         = ImVec4(0.26, 0.59, 0.98, 1.00)
        colors[clr.ResizeGrip]              = ImVec4(0.26, 0.59, 0.98, 0.25)
        colors[clr.ResizeGripHovered]       = ImVec4(0.26, 0.59, 0.98, 0.67)
        colors[clr.ResizeGripActive]        = ImVec4(0.26, 0.59, 0.98, 0.95)
        colors[clr.TextSelectedBg]          = ImVec4(0.26, 0.59, 0.98, 0.35)
        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.ChildWindowBg]           = ImVec4(1.00, 1.00, 1.00, 0.00)
        colors[clr.PopupBg]                 = ImVec4(0.08, 0.08, 0.08, 0.94)
        colors[clr.ComboBg]                 = colors[clr.PopupBg]
        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.MenuBarBg]               = ImVec4(0.14, 0.14, 0.14, 1.00)
        colors[clr.ScrollbarBg]             = ImVec4(0.02, 0.02, 0.02, 0.53)
        colors[clr.ScrollbarGrab]           = ImVec4(0.31, 0.31, 0.31, 1.00)
        colors[clr.ScrollbarGrabHovered]    = ImVec4(0.41, 0.41, 0.41, 1.00)
        colors[clr.ScrollbarGrabActive]     = ImVec4(0.51, 0.51, 0.51, 1.00)
        colors[clr.CloseButton]             = ImVec4(0.41, 0.41, 0.41, 0.50)
        colors[clr.CloseButtonHovered]      = ImVec4(0.98, 0.39, 0.36, 1.00)
        colors[clr.CloseButtonActive]       = ImVec4(0.98, 0.39, 0.36, 1.00)
        colors[clr.PlotLines]               = ImVec4(0.61, 0.61, 0.61, 1.00)
        colors[clr.PlotLinesHovered]        = ImVec4(1.00, 0.43, 0.35, 1.00)
        colors[clr.PlotHistogram]           = ImVec4(0.90, 0.70, 0.00, 1.00)
        colors[clr.PlotHistogramHovered]    = ImVec4(1.00, 0.60, 0.00, 1.00)
        colors[clr.ModalWindowDarkening]    = ImVec4(0.80, 0.80, 0.80, 0.35)
    elseif id == 2 then -- dark
        colors[clr.Text]                    = ImVec4(0.80, 0.80, 0.83, 1.00)
        colors[clr.TextDisabled]            = ImVec4(0.24, 0.23, 0.29, 1.00)
        colors[clr.WindowBg]                = ImVec4(0.06, 0.05, 0.07, 1.00)
        colors[clr.ChildWindowBg]           = ImVec4(0.07, 0.07, 0.09, 1.00)
        colors[clr.PopupBg]                 = ImVec4(0.07, 0.07, 0.09, 1.00)
        colors[clr.Border]                  = ImVec4(0.43, 0.43, 0.50, 0.50)
        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(0.10, 0.09, 0.12, 1.00)
        colors[clr.ButtonHovered]           = ImVec4(0.24, 0.23, 0.29, 1.00)
        colors[clr.ButtonActive]            = ImVec4(0.56, 0.56, 0.58, 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)
    elseif id == 3 then -- cherry
        colors[clr.Text]                    = ImVec4(0.860, 0.930, 0.890, 0.78)
        colors[clr.TextDisabled]            = ImVec4(0.860, 0.930, 0.890, 0.28)
        colors[clr.WindowBg]                = ImVec4(0.13, 0.14, 0.17, 1.00)
        colors[clr.ChildWindowBg]           = ImVec4(0.200, 0.220, 0.270, 0.58)
        colors[clr.PopupBg]                 = ImVec4(0.200, 0.220, 0.270, 0.9)
        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.200, 0.220, 0.270, 1.00)
        colors[clr.FrameBgHovered]          = ImVec4(0.455, 0.198, 0.301, 0.78)
        colors[clr.FrameBgActive]           = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.TitleBg]                 = ImVec4(0.232, 0.201, 0.271, 1.00)
        colors[clr.TitleBgActive]           = ImVec4(0.502, 0.075, 0.256, 1.00)
        colors[clr.TitleBgCollapsed]        = ImVec4(0.200, 0.220, 0.270, 0.75)
        colors[clr.MenuBarBg]               = ImVec4(0.200, 0.220, 0.270, 0.47)
        colors[clr.ScrollbarBg]             = ImVec4(0.200, 0.220, 0.270, 1.00)
        colors[clr.ScrollbarGrab]           = ImVec4(0.09, 0.15, 0.1, 1.00)
        colors[clr.ScrollbarGrabHovered]    = ImVec4(0.455, 0.198, 0.301, 0.78)
        colors[clr.ScrollbarGrabActive]     = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.CheckMark]               = ImVec4(0.71, 0.22, 0.27, 1.00)
        colors[clr.SliderGrab]              = ImVec4(0.47, 0.77, 0.83, 0.14)
        colors[clr.SliderGrabActive]        = ImVec4(0.71, 0.22, 0.27, 1.00)
        colors[clr.Button]                  = ImVec4(0.47, 0.77, 0.83, 0.14)
        colors[clr.ButtonHovered]           = ImVec4(0.455, 0.198, 0.301, 0.86)
        colors[clr.ButtonActive]            = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.Header]                  = ImVec4(0.455, 0.198, 0.301, 0.76)
        colors[clr.HeaderHovered]           = ImVec4(0.455, 0.198, 0.301, 0.86)
        colors[clr.HeaderActive]            = ImVec4(0.502, 0.075, 0.256, 1.00)
        colors[clr.ResizeGrip]              = ImVec4(0.47, 0.77, 0.83, 0.04)
        colors[clr.ResizeGripHovered]       = ImVec4(0.455, 0.198, 0.301, 0.78)
        colors[clr.ResizeGripActive]        = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.PlotLines]               = ImVec4(0.860, 0.930, 0.890, 0.63)
        colors[clr.PlotLinesHovered]        = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.PlotHistogram]           = ImVec4(0.860, 0.930, 0.890, 0.63)
        colors[clr.PlotHistogramHovered]    = ImVec4(0.455, 0.198, 0.301, 1.00)
        colors[clr.TextSelectedBg]          = ImVec4(0.455, 0.198, 0.301, 0.43)
        colors[clr.ModalWindowDarkening]    = ImVec4(0.200, 0.220, 0.270, 0.73)
    elseif id == 4 then -- dark green
        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.ChildWindowBg]           = 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.44, 0.44, 0.44, 0.60)
        colors[clr.FrameBgHovered]          = ImVec4(0.57, 0.57, 0.57, 0.70)
        colors[clr.FrameBgActive]           = ImVec4(0.76, 0.76, 0.76, 0.80)
        colors[clr.TitleBg]                 = ImVec4(0.04, 0.04, 0.04, 1.00)
        colors[clr.TitleBgActive]           = ImVec4(0.16, 0.16, 0.16, 1.00)
        colors[clr.TitleBgCollapsed]        = ImVec4(0.00, 0.00, 0.00, 0.60)
        colors[clr.MenuBarBg]               = ImVec4(0.14, 0.14, 0.14, 1.00)
        colors[clr.ScrollbarBg]             = ImVec4(0.02, 0.02, 0.02, 0.53)
        colors[clr.ScrollbarGrab]           = ImVec4(0.31, 0.31, 0.31, 1.00)
        colors[clr.ScrollbarGrabHovered]    = ImVec4(0.41, 0.41, 0.41, 1.00)
        colors[clr.ScrollbarGrabActive]     = ImVec4(0.51, 0.51, 0.51, 1.00)
        colors[clr.CheckMark]               = ImVec4(0.13, 0.75, 0.55, 0.80)
        colors[clr.SliderGrab]              = ImVec4(0.13, 0.75, 0.75, 0.80)
        colors[clr.SliderGrabActive]        = ImVec4(0.13, 0.75, 1.00, 0.80)
        colors[clr.Button]                  = ImVec4(0.13, 0.75, 0.55, 0.40)
        colors[clr.ButtonHovered]           = ImVec4(0.13, 0.75, 0.75, 0.60)
        colors[clr.ButtonActive]            = ImVec4(0.13, 0.75, 1.00, 0.80)
        colors[clr.Header]                  = ImVec4(0.13, 0.75, 0.55, 0.40)
        colors[clr.HeaderHovered]           = ImVec4(0.13, 0.75, 0.75, 0.60)
        colors[clr.HeaderActive]            = ImVec4(0.13, 0.75, 1.00, 0.80)
        colors[clr.Separator]               = ImVec4(0.13, 0.75, 0.55, 0.40)
        colors[clr.SeparatorHovered]        = ImVec4(0.13, 0.75, 0.75, 0.60)
        colors[clr.SeparatorActive]         = ImVec4(0.13, 0.75, 1.00, 0.80)
        colors[clr.ResizeGrip]              = ImVec4(0.13, 0.75, 0.55, 0.40)
        colors[clr.ResizeGripHovered]       = ImVec4(0.13, 0.75, 0.75, 0.60)
        colors[clr.ResizeGripActive]        = ImVec4(0.13, 0.75, 1.00, 0.80)
        colors[clr.PlotLines]               = ImVec4(0.61, 0.61, 0.61, 1.00)
        colors[clr.PlotLinesHovered]        = ImVec4(1.00, 0.43, 0.35, 1.00)
        colors[clr.PlotHistogram]           = ImVec4(0.90, 0.70, 0.00, 1.00)
        colors[clr.PlotHistogramHovered]    = ImVec4(1.00, 0.60, 0.00, 1.00)
        colors[clr.TextSelectedBg]          = ImVec4(0.26, 0.59, 0.98, 0.35)
        colors[clr.ModalWindowDarkening]    = ImVec4(0.80, 0.80, 0.80, 0.35)
    end
end
style(style_selected.v) -- Тут также применяем стиль. Вроде как разницы нет, что "mainIni.config.style", что "style_selected.v", так как второе всё равно значение с конфига берёт.
Screenshot_3.png
 
  • Нравится
Реакции: qdIbp