Как сделать тему Imgui разноцветной?

m04

Новичок
Автор темы
1
0
Версия MoonLoader
.027.0-preview
Отдельные кнопки выбора цвета темы.
Буду признателен кто поможет.
 

qdIbp

Автор темы
Проверенный
1,438
1,180
Lua:
require "lib.moonloader"
require 'lib.vkeys'
local imgui = require 'imgui'
radio = imgui.ImInt(1)

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local main_window_state = imgui.ImBool(false)
function imgui.OnDrawFrame()
    style()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(150, 200), imgui.Cond.FirstUseEver)
        imgui.Begin('My window', main_window_state)
        imgui.RadioButton(u8'1 тема', radio, 1)
        imgui.RadioButton(u8'2 тема', radio, 2)
        imgui.RadioButton(u8'3 тема', radio, 3)
        imgui.End()
    end
end

function main()
    while true do wait(0)
        if wasKeyPressed(VK_X) then  main_window_state.v = not main_window_state.v end
        imgui.Process = main_window_state.v
    end
end

function style()
    if radio.v == 1 then
        imgui.SwitchContext()
        local style = imgui.GetStyle()
        local colors = style.Colors
        local clr = imgui.Col
        local ImVec4 = imgui.ImVec4

        colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
        colors[clr.TextDisabled] = ImVec4(0.60, 0.60, 0.60, 1.00)
        colors[clr.WindowBg] = ImVec4(0.11, 0.10, 0.11, 1.00)
        colors[clr.ChildWindowBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
        colors[clr.PopupBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
        colors[clr.Border] = ImVec4(0.86, 0.86, 0.86, 1.00)
        colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
        colors[clr.FrameBg] = ImVec4(0.21, 0.20, 0.21, 0.60)
        colors[clr.FrameBgHovered] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.FrameBgActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.TitleBg] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.TitleBgActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.MenuBarBg] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.ScrollbarBg] = ImVec4(0.00, 0.46, 0.65, 0.00)
        colors[clr.ScrollbarGrab] = ImVec4(0.00, 0.46, 0.65, 0.44)
        colors[clr.ScrollbarGrabHovered] = ImVec4(0.00, 0.46, 0.65, 0.74)
        colors[clr.ScrollbarGrabActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.ComboBg] = ImVec4(0.15, 0.14, 0.15, 1.00)
        colors[clr.CheckMark] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.SliderGrab] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.SliderGrabActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.Button] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.ButtonHovered] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.ButtonActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.Header] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.HeaderHovered] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.HeaderActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
        colors[clr.ResizeGrip] = ImVec4(1.00, 1.00, 1.00, 0.30)
        colors[clr.ResizeGripHovered] = ImVec4(1.00, 1.00, 1.00, 0.60)
        colors[clr.ResizeGripActive] = ImVec4(1.00, 1.00, 1.00, 0.90)
        colors[clr.CloseButton] = ImVec4(1.00, 0.10, 0.24, 0.00)
        colors[clr.CloseButtonHovered] = ImVec4(0.00, 0.10, 0.24, 0.00)
        colors[clr.CloseButtonActive] = ImVec4(1.00, 0.10, 0.24, 0.00)
        colors[clr.PlotLines] = ImVec4(0.00, 0.00, 0.00, 0.00)
        colors[clr.PlotLinesHovered] = ImVec4(0.00, 0.00, 0.00, 0.00)
        colors[clr.PlotHistogram] = ImVec4(0.00, 0.00, 0.00, 0.00)
        colors[clr.PlotHistogramHovered] = ImVec4(0.00, 0.00, 0.00, 0.00)
        colors[clr.TextSelectedBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
        colors[clr.ModalWindowDarkening] = ImVec4(0.00, 0.00, 0.00, 0.00)
    elseif radio.v == 2 then
        imgui.SwitchContext()
        local style = imgui.GetStyle()
        local colors = style.Colors
        local clr = imgui.Col
        local ImVec4 = imgui.ImVec4

        style.Alpha = 1.0
        style.ChildWindowRounding = 3
        style.WindowRounding = 3
        style.GrabRounding = 1
        style.GrabMinSize = 20
        style.FrameRounding = 3

        colors[clr.Text] = ImVec4(0.00, 1.00, 1.00, 1.00)
        colors[clr.TextDisabled] = ImVec4(0.00, 0.40, 0.41, 1.00)
        colors[clr.WindowBg] = ImVec4(0.00, 0.00, 0.00, 1.00)
        colors[clr.ChildWindowBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
        colors[clr.Border] = ImVec4(0.00, 1.00, 1.00, 0.65)
        colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
        colors[clr.FrameBg] = ImVec4(0.44, 0.80, 0.80, 0.18)
        colors[clr.FrameBgHovered] = ImVec4(0.44, 0.80, 0.80, 0.27)
        colors[clr.FrameBgActive] = ImVec4(0.44, 0.81, 0.86, 0.66)
        colors[clr.TitleBg] = ImVec4(0.14, 0.18, 0.21, 0.73)
        colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.54)
        colors[clr.TitleBgActive] = ImVec4(0.00, 1.00, 1.00, 0.27)
        colors[clr.MenuBarBg] = ImVec4(0.00, 0.00, 0.00, 0.20)
        colors[clr.ScrollbarBg] = ImVec4(0.22, 0.29, 0.30, 0.71)
        colors[clr.ScrollbarGrab] = ImVec4(0.00, 1.00, 1.00, 0.44)
        colors[clr.ScrollbarGrabHovered] = ImVec4(0.00, 1.00, 1.00, 0.74)
        colors[clr.ScrollbarGrabActive] = ImVec4(0.00, 1.00, 1.00, 1.00)
        colors[clr.ComboBg] = ImVec4(0.16, 0.24, 0.22, 0.60)
        colors[clr.CheckMark] = ImVec4(0.00, 1.00, 1.00, 0.68)
        colors[clr.SliderGrab] = ImVec4(0.00, 1.00, 1.00, 0.36)
        colors[clr.SliderGrabActive] = ImVec4(0.00, 1.00, 1.00, 0.76)
        colors[clr.Button] = ImVec4(0.00, 0.65, 0.65, 0.46)
        colors[clr.ButtonHovered] = ImVec4(0.01, 1.00, 1.00, 0.43)
        colors[clr.ButtonActive] = ImVec4(0.00, 1.00, 1.00, 0.62)
        colors[clr.Header] = ImVec4(0.00, 1.00, 1.00, 0.33)
        colors[clr.HeaderHovered] = ImVec4(0.00, 1.00, 1.00, 0.42)
        colors[clr.HeaderActive] = ImVec4(0.00, 1.00, 1.00, 0.54)
        colors[clr.ResizeGrip] = ImVec4(0.00, 1.00, 1.00, 0.54)
        colors[clr.ResizeGripHovered] = ImVec4(0.00, 1.00, 1.00, 0.74)
        colors[clr.ResizeGripActive] = ImVec4(0.00, 1.00, 1.00, 1.00)
        colors[clr.CloseButton] = ImVec4(0.00, 0.78, 0.78, 0.35)
        colors[clr.CloseButtonHovered] = ImVec4(0.00, 0.78, 0.78, 0.47)
        colors[clr.CloseButtonActive] = ImVec4(0.00, 0.78, 0.78, 1.00)
        colors[clr.PlotLines] = ImVec4(0.00, 1.00, 1.00, 1.00)
        colors[clr.PlotLinesHovered] = ImVec4(0.00, 1.00, 1.00, 1.00)
        colors[clr.PlotHistogram] = ImVec4(0.00, 1.00, 1.00, 1.00)
        colors[clr.PlotHistogramHovered] = ImVec4(0.00, 1.00, 1.00, 1.00)
        colors[clr.TextSelectedBg] = ImVec4(0.00, 1.00, 1.00, 0.22)
        colors[clr.ModalWindowDarkening] = ImVec4(0.04, 0.10, 0.09, 0.51)
    elseif radio.v == 3 then
        imgui.SwitchContext()
        local style = imgui.GetStyle()
        local colors = style.Colors
        local clr = imgui.Col
        local ImVec4 = imgui.ImVec4
        local ImVec2 = imgui.ImVec2
        -- StyleColorsDark
        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.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);
        colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51);
        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.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.10, 0.40, 0.75, 0.78);
        colors[clr.SeparatorActive]        = ImVec4(0.10, 0.40, 0.75, 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.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);

        imgui.SetColorEditOptions(imgui.ColorEditFlags.HEX)

        style.FrameRounding = 0.0
        style.WindowRounding = 0.0
        style.ChildWindowRounding = 0.0

        colors[clr.TitleBgActive] = ImVec4(0.000, 0.009, 0.120, 0.940);
        colors[clr.TitleBg] = ImVec4(0.20, 0.25, 0.30, 1.0);
        colors[clr.Button] = ImVec4(0.260, 0.590, 0.980, 0.670);
        colors[clr.Header] = ImVec4(0.260, 0.590, 0.980, 0.670);
        colors[clr.HeaderHovered] = ImVec4(0.260, 0.590, 0.980, 1.000);
        colors[clr.ButtonHovered] = ImVec4(0.000, 0.545, 1.000, 1.000);
        colors[clr.ButtonActive] = ImVec4(0.060, 0.416, 0.980, 1.000);
        colors[clr.FrameBg] = ImVec4(0.20, 0.25, 0.30, 1.0);
        colors[clr.WindowBg] = ImVec4(0.000, 0.009, 0.120, 0.940);
        colors[clr.PopupBg] = ImVec4(0.076, 0.143, 0.209, 1.000);
    end
end
 

Dmitriy Makarov

25.05.2021
Проверенный
2,505
1,134

Lance_Sterling

Известный
978
342

Lance_Sterling

Известный
978
342
Так через CheckBox тоже можно это реализовать просто немного не эстетично будет 👉👈
Да, но, лол, как бы в чекбокс можно много галочек установить, как бы да
Поэтому так и сказал
 

7 СМЕРТНЫХ ГРЕХОВ

Известный
524
164
Да, но, лол, как бы в чекбокс можно много галочек установить, как бы да
Поэтому так и сказал
Ну можно сделать же типо если нажать чекбокс 2 чекбокс 1,3,4 = false
И тому подобное 👉👈
 
  • Нравится
Реакции: kjor32