diff --git a/scripts/modules/CETMM.lua b/scripts/modules/CETMM.lua index 6a69c12..98a2cd5 100644 --- a/scripts/modules/CETMM.lua +++ b/scripts/modules/CETMM.lua @@ -121,9 +121,7 @@ end function CETMM.Render() registerForEvent("onDraw", function() m_gui.Initialize() - m_gui.GetStyle().PushTheme() m_gui.Render() - m_gui.GetStyle().PopTheme() end) end diff --git a/scripts/modules/gui/init.lua b/scripts/modules/gui/init.lua index 5c19da7..7ada4c7 100644 --- a/scripts/modules/gui/init.lua +++ b/scripts/modules/gui/init.lua @@ -2,7 +2,7 @@ local CETMM = require ("modules/CETMM") ---@class gui local gui = {} local m_dpi = require ("modules/gui/dpi") -local m_style = require ("modules/gui/style") +local m_themeSys = require ("modules/gui/themeSys") local m_widgets = require ("modules/gui/widgets") local m_window = require ("modules/gui/window") local m_windows = require ("modules/gui/windows") @@ -13,8 +13,8 @@ function gui.GetDPI() return m_dpi end -function gui.GetStyle() - return m_style +function gui.GetThemeSys() + return m_themeSys end function gui.GetWindow() @@ -25,7 +25,10 @@ function gui.Initialize() if not m_initialized then m_showUninstall = CETMM.IsUninstalled() m_dpi.Initialize() - if not m_showUninstall then + if m_showUninstall then + m_themeSys.Load("default", true) + else + m_themeSys.Initialize() m_window.Initialize() end m_initialized = true @@ -33,11 +36,13 @@ function gui.Initialize() end function gui.Render() + m_themeSys.PushTheme() if m_showUninstall then m_windows.uninstall.Render() else m_window.Render() end + m_themeSys.PopTheme() end return gui \ No newline at end of file diff --git a/scripts/modules/gui/style.lua b/scripts/modules/gui/style.lua deleted file mode 100644 index 1404c46..0000000 --- a/scripts/modules/gui/style.lua +++ /dev/null @@ -1,47 +0,0 @@ ----@class style -local style = {} -local theme = require ("modules/gui/theme") - ----@param aStyle number ----@param aColor number[] -function style.PushColor(aStyle, aColor) - ImGui.PushStyleColor(aStyle, aColor[1], aColor[2], aColor[3], aColor[4]) -end - -function style.PushTheme() - style.PushColor(ImGuiCol.TitleBg, theme.TitleBg) - style.PushColor(ImGuiCol.TitleBgCollapsed, theme.TitleBgCollapsed) - style.PushColor(ImGuiCol.TitleBgActive, theme.TitleBgActive) - style.PushColor(ImGuiCol.Border, theme.Border) - style.PushColor(ImGuiCol.WindowBg, theme.WindowBg) - style.PushColor(ImGuiCol.ScrollbarBg, theme.ScrollbarBg) - style.PushColor(ImGuiCol.ScrollbarGrab, theme.ScrollbarGrab) - style.PushColor(ImGuiCol.ScrollbarGrabHovered, theme.ScrollbarGrabHovered) - style.PushColor(ImGuiCol.ScrollbarGrabActive, theme.ScrollbarGrabActive) - style.PushColor(ImGuiCol.ResizeGrip, theme.ResizeGrip) - style.PushColor(ImGuiCol.ResizeGripHovered, theme.ResizeGripHovered) - style.PushColor(ImGuiCol.ResizeGripActive, theme.ResizeGripActive) - style.PushColor(ImGuiCol.Text, theme.Text) - style.PushColor(ImGuiCol.Header, theme.Header) - style.PushColor(ImGuiCol.HeaderHovered, theme.HeaderHovered) - style.PushColor(ImGuiCol.HeaderActive, theme.HeaderActive) - style.PushColor(ImGuiCol.CheckMark, theme.CheckMark) - style.PushColor(ImGuiCol.FrameBg, theme.FrameBg) - style.PushColor(ImGuiCol.FrameBgHovered, theme.FrameBgHovered) - style.PushColor(ImGuiCol.FrameBgActive, theme.FrameBgActive) - style.PushColor(ImGuiCol.Button, theme.Button) - style.PushColor(ImGuiCol.ButtonHovered, theme.ButtonHovered) - style.PushColor(ImGuiCol.ButtonActive, theme.ButtonActive) - style.PushColor(ImGuiCol.Separator, theme.Separator) - style.PushColor(ImGuiCol.PopupBg, theme.PopupBg) - - ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, 8, 8) - ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0) -end - -function style.PopTheme() - ImGui.PopStyleColor(25) - ImGui.PopStyleVar(2) -end - -return style \ No newline at end of file diff --git a/scripts/modules/gui/theme.lua b/scripts/modules/gui/theme.lua deleted file mode 100644 index 5a714ff..0000000 --- a/scripts/modules/gui/theme.lua +++ /dev/null @@ -1,195 +0,0 @@ --- CyberEngineTWeaks Mod Manager is a mod manager for Cyber Engine Tweaks based mods - --- Copyright (C) 2021 Mingming Cui --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . -local CETMM = require("modules/CETMM") -local options = CETMM.GetOptions() - ----@class theme_default -local theme_default = { - Text = { 1 , 0.44, 0.4 , 1 }, - TextDisabled = { 0.48, 0.39, 0.40, 1 }, - WindowBg = { 0.06, 0.04, 0.06, 0.9 }, - ChildBg = { 0.06, 0.04, 0.06, 0.9 }, - PopupBg = { 0.06, 0.04, 0.06, 0.9 }, - Border = { 0.3 , 0.07, 0.08, 1 }, - BorderShadow = { 0 , 0 , 0 , 0 }, - FrameBg = { 0.57, 0.17, 0.16, 1 }, - FrameBgHovered = { 0.32, 0.09, 0.11, 1 }, - FrameBgActive = { 0.1 , 0.05, 0.05, 1 }, - FrameBgDisabled = { 0.48, 0.39, 0.40, 1 }, - FrameBgHoveredDisabled = { 0.48, 0.39, 0.40, 1 }, - FrameBgActiveDisabled = { 0.48, 0.39, 0.40, 1 }, - TitleBg = { 0.06, 0.04, 0.06, 0.9 }, - TitleBgActive = { 0.06, 0.04, 0.06, 0.9 }, - TitleBgCollapsed = { 0.06, 0.04, 0.06, 0.9 }, - MenuBarBg = { 0 , 0 , 0 , 0 }, - ScrollbarBg = { 0.06, 0.04, 0.06, 0 }, - ScrollbarGrab = { 0.57, 0.17, 0.16, 1 }, - ScrollbarGrabHovered = { 0.57, 0.17, 0.16, 1 }, - ScrollbarGrabActive = { 0.57, 0.17, 0.16, 1 }, - CheckMark = { 1 , 0.44, 0.4 , 1 }, - CheckMarkTrueDisabled = { 0.34, 0.22, 0.24, 1 }, - CheckMarkFalseDisabled = { 0.48, 0.39, 0.40, 1 }, - SliderGrab = { 0 , 0 , 0 , 0 }, - SliderGrabActive = { 0 , 0 , 0 , 0 }, - Button = { 0.57, 0.17, 0.16, 1 }, - ButtonHovered = { 0.45, 0.13, 0.14, 1 }, - ButtonActive = { 0.57, 0.17, 0.16, 1 }, - Header = { 0.22, 0.64, 0.69, 0.2 }, - HeaderHovered = { 0.22, 0.64, 0.69, 0.3 }, - HeaderActive = { 0.22, 0.64, 0.69, 0.5 }, - Separator = { 0.3 , 0.07, 0.08, 1 }, - SeparatorHovered = { 0.29, 0.77, 0.79, 1 }, - SeparatorActive = { 0.29, 0.77, 0.79, 1 }, - ResizeGrip = { 0.06, 0.04, 0.06, 1 }, - ResizeGripHovered = { 1 , 0.44, 0.4 , 1 }, - ResizeGripActive = { 1 , 0.44, 0.4 , 1 }, - Tab = { 0 , 0 , 0 , 0 }, - TabHovered = { 0 , 0 , 0 , 0 }, - TabActive = { 0 , 0 , 0 , 0 }, - TabUnfocused = { 0 , 0 , 0 , 0 }, - TabUnfocusedActive = { 0 , 0 , 0 , 0 }, - DockingPreview = { 0 , 0 , 0 , 0 }, - DockingEmptyBg = { 0 , 0 , 0 , 0 }, - PlotLines = { 0 , 0 , 0 , 0 }, - PlotLinesHovered = { 0 , 0 , 0 , 0 }, - PlotHistogram = { 0 , 0 , 0 , 0 }, - PlotHistogramHovered = { 0 , 0 , 0 , 0 }, - TextSelectedBg = { 0 , 0 , 0 , 0 }, - DragDropTarget = { 0 , 0 , 0 , 0 }, - NavHighlight = { 0 , 0 , 0 , 0 }, - NavWindowingHighlight = { 0 , 0 , 0 , 0 }, - NavWindowingDimBg = { 0 , 0 , 0 , 0 }, - ModalWindowDimBg = { 0 , 0 , 0 , 0 }, - ModalWindowDarkening = { 0 , 0 , 0 , 0 }, - COUNT = { 0 , 0 , 0 , 0 }, - CustomToggleOn = { 0.29, 0.77, 0.79, 1 }, - CustomToggleOnHovered = { 0.20, 0.56, 0.59, 1 }, - CustomToggleOnActive = { 0.29, 0.77, 0.79, 1 }, - CustomToggleOnText = { 0 , 0 , 0 , 1 }, - CustomToggleOnDisable = { 0.04, 0.11, 0.12, 1 }, - CustomToggleOnDisableHovered = { 0.05, 0.16, 0.16, 1 }, - CustomToggleOnDisableText = { 0.06, 0.18, 0.2 , 1 }, - CustomToggleOff = { 0.57, 0.18, 0.16, 1 }, - CustomToggleOffHovered = { 0.45, 0.13, 0.14, 1 }, - CustomToggleOffText = { 1 , 0.44, 0.4 , 1 }, - CustomToggleOffDisable = { 0.1 , 0.04, 0.07, 1 }, - CustomToggleOffDisableHovered = { 0.16, 0.06, 0.07, 1 }, - CustomToggleOffDisableText = { 0.22, 0.07, 0.07, 1 }, - AltText = { 0.29, 0.77, 0.79, 1 }, - Hidden = { 0 , 0 , 0 , 0 }, -} - ----@class theme_ua_special -local theme_ua_special = { - Text = { 0.96, 0.81, 0.00, 1 }, - TextDisabled = { 0.48, 0.39, 0.40, 1 }, - WindowBg = { 0.05, 0.11, 0.18, 0.9 }, - ChildBg = { 0.05, 0.11, 0.18, 0.9 }, - PopupBg = { 0.05, 0.11, 0.18, 0.9 }, - Border = { 0.60, 0.51, 0.00, 1 }, - BorderShadow = { 0 , 0 , 0 , 0 }, - FrameBg = { 0.00, 0.35, 0.71, 1 }, - FrameBgHovered = { 0.00, 0.44, 0.90, 1 }, - FrameBgActive = { 0.00, 0.35, 0.71, 1 }, - FrameBgDisabled = { 0.48, 0.39, 0.40, 1 }, - FrameBgHoveredDisabled = { 0.48, 0.39, 0.40, 1 }, - FrameBgActiveDisabled = { 0.48, 0.39, 0.40, 1 }, - TitleBg = { 0.05, 0.11, 0.18, 0.9 }, - TitleBgActive = { 0.05, 0.11, 0.18, 0.9 }, - TitleBgCollapsed = { 0.05, 0.11, 0.18, 0.9 }, - MenuBarBg = { 0.05, 0.11, 0.18, 0.9 }, - ScrollbarBg = { 0.06, 0.04, 0.06, 0 }, - ScrollbarGrab = { 0.00, 0.35, 0.71, 1 }, - ScrollbarGrabHovered = { 0.00, 0.44, 0.90, 1 }, - ScrollbarGrabActive = { 0.00, 0.35, 0.71, 1 }, - CheckMark = { 0.96, 0.81, 0.00, 1 }, - CheckMarkTrueDisabled = { 0.34, 0.22, 0.24, 1 }, - CheckMarkFalseDisabled = { 0.48, 0.39, 0.40, 1 }, - SliderGrab = { 0 , 0 , 0 , 0 }, - SliderGrabActive = { 0 , 0 , 0 , 0 }, - Button = { 0.00, 0.35, 0.71, 1 }, - ButtonHovered = { 0.00, 0.44, 0.90, 1 }, - ButtonActive = { 0.00, 0.35, 0.71, 1 }, - Header = { 0.00, 0.21, 0.43, 0.6 }, - HeaderHovered = { 0.00, 0.21, 0.43, 0.9 }, - HeaderActive = { 0.00, 0.21, 0.43, 0.9 }, - Separator = { 0.60, 0.51, 0.00, 0.5 }, - SeparatorHovered = { 0.29, 0.77, 0.79, 1 }, - SeparatorActive = { 0.29, 0.77, 0.79, 1 }, - ResizeGrip = { 0.05, 0.11, 0.18, 1 }, - ResizeGripHovered = { 0.96, 0.81, 0.00, 1 }, - ResizeGripActive = { 0.96, 0.81, 0.00, 1 }, - Tab = { 0 , 0 , 0 , 0 }, - TabHovered = { 0 , 0 , 0 , 0 }, - TabActive = { 0 , 0 , 0 , 0 }, - TabUnfocused = { 0 , 0 , 0 , 0 }, - TabUnfocusedActive = { 0 , 0 , 0 , 0 }, - DockingPreview = { 0 , 0 , 0 , 0 }, - DockingEmptyBg = { 0 , 0 , 0 , 0 }, - PlotLines = { 0 , 0 , 0 , 0 }, - PlotLinesHovered = { 0 , 0 , 0 , 0 }, - PlotHistogram = { 0 , 0 , 0 , 0 }, - PlotHistogramHovered = { 0 , 0 , 0 , 0 }, - TextSelectedBg = { 0 , 0 , 0 , 0 }, - DragDropTarget = { 0 , 0 , 0 , 0 }, - NavHighlight = { 0 , 0 , 0 , 0 }, - NavWindowingHighlight = { 0 , 0 , 0 , 0 }, - NavWindowingDimBg = { 0 , 0 , 0 , 0 }, - ModalWindowDimBg = { 0 , 0 , 0 , 0 }, - ModalWindowDarkening = { 0 , 0 , 0 , 0 }, - COUNT = { 0 , 0 , 0 , 0 }, - CustomToggleOn = { 0.96, 0.81, 0.00, 1 }, - CustomToggleOnHovered = { 0.81, 0.67, 0.00, 1 }, - CustomToggleOnActive = { 0.96, 0.81, 0.00, 1 }, - CustomToggleOnText = { 0.00, 0.44, 0.90, 1 }, - CustomToggleOnDisable = { 0.04, 0.11, 0.12, 1 }, - CustomToggleOnDisableHovered = { 0.05, 0.16, 0.16, 1 }, - CustomToggleOnDisableText = { 0.06, 0.18, 0.2 , 1 }, - CustomToggleOff = { 0.57, 0.18, 0.16, 1 }, - CustomToggleOffHovered = { 0.45, 0.13, 0.14, 1 }, - CustomToggleOffText = { 0.96, 0.81, 0.00, 1 }, - CustomToggleOffDisable = { 0.1 , 0.04, 0.07, 1 }, - CustomToggleOffDisableHovered = { 0.16, 0.06, 0.07, 1 }, - CustomToggleOffDisableText = { 0.22, 0.07, 0.07, 1 }, - AltText = { 0.00, 0.44, 0.90, 1 }, - Hidden = { 0 , 0 , 0 , 0 }, -} - - ----@class theme:theme_default -local theme = {} - -local function load_impl(aTheme) - for key, value in pairs(aTheme) do - theme[key] = value - end -end - - -function theme.Load() - if options.m_theme == "ua_special" then - load_impl(theme_ua_special) - else - load_impl(theme_default) - end -end - -theme.Load() - -print("theme loadded...") - -return theme diff --git a/scripts/modules/gui/themeSys.lua b/scripts/modules/gui/themeSys.lua new file mode 100644 index 0000000..4bcba33 --- /dev/null +++ b/scripts/modules/gui/themeSys.lua @@ -0,0 +1,79 @@ +local CETMM = require("modules/CETMM") +---@class themeSys +local themeSys = { + themes = { + default = require("modules/gui/themes/default"), + ua_special = require("modules/gui/themes/ua_special"), + white = require("modules/gui/themes/white"), + }, + currentTheme = {} ---@type baseTheme +} + +function themeSys.Initialize() + local theme = CETMM.GetOptions().m_theme + themeSys.Load(theme) +end + +---Load theme +---@param aTheme string +---@param aNoSave? bool +function themeSys.Load(aTheme, aNoSave) + if themeSys.themes[aTheme] then + themeSys.currentTheme = themeSys.themes[aTheme] + else + themeSys.currentTheme = themeSys.themes.default + spdlog.error(string.format("Failed to load theme %s, loaded default theme instead.", aTheme)) + end + if not aNoSave then + CETMM.GetOptions().m_theme = themeSys.currentTheme:GetName() + CETMM.GetOptions().Save() + end +end + +function themeSys.GetCurrentTheme() + return themeSys.currentTheme +end + +---@param aStyle ImGuiCol +---@param aColor number[] +function themeSys.PushColor(aStyle, aColor) + ImGui.PushStyleColor(aStyle, unpack(aColor)) +end + +function themeSys.PushTheme() + themeSys.PushColor(ImGuiCol.TitleBg, themeSys.currentTheme:GetStyleColor("TitleBg" )) + themeSys.PushColor(ImGuiCol.TitleBgCollapsed, themeSys.currentTheme:GetStyleColor("TitleBgCollapsed" )) + themeSys.PushColor(ImGuiCol.TitleBgActive, themeSys.currentTheme:GetStyleColor("TitleBgActive" )) + themeSys.PushColor(ImGuiCol.Border, themeSys.currentTheme:GetStyleColor("Border" )) + themeSys.PushColor(ImGuiCol.WindowBg, themeSys.currentTheme:GetStyleColor("WindowBg" )) + themeSys.PushColor(ImGuiCol.ScrollbarBg, themeSys.currentTheme:GetStyleColor("ScrollbarBg" )) + themeSys.PushColor(ImGuiCol.ScrollbarGrab, themeSys.currentTheme:GetStyleColor("ScrollbarGrab" )) + themeSys.PushColor(ImGuiCol.ScrollbarGrabHovered, themeSys.currentTheme:GetStyleColor("ScrollbarGrabHovered" )) + themeSys.PushColor(ImGuiCol.ScrollbarGrabActive, themeSys.currentTheme:GetStyleColor("ScrollbarGrabActive" )) + themeSys.PushColor(ImGuiCol.ResizeGrip, themeSys.currentTheme:GetStyleColor("ResizeGrip" )) + themeSys.PushColor(ImGuiCol.ResizeGripHovered, themeSys.currentTheme:GetStyleColor("ResizeGripHovered" )) + themeSys.PushColor(ImGuiCol.ResizeGripActive, themeSys.currentTheme:GetStyleColor("ResizeGripActive" )) + themeSys.PushColor(ImGuiCol.Text, themeSys.currentTheme:GetStyleColor("Text" )) + themeSys.PushColor(ImGuiCol.Header, themeSys.currentTheme:GetStyleColor("Header" )) + themeSys.PushColor(ImGuiCol.HeaderHovered, themeSys.currentTheme:GetStyleColor("HeaderHovered" )) + themeSys.PushColor(ImGuiCol.HeaderActive, themeSys.currentTheme:GetStyleColor("HeaderActive" )) + themeSys.PushColor(ImGuiCol.CheckMark, themeSys.currentTheme:GetStyleColor("CheckMark" )) + themeSys.PushColor(ImGuiCol.FrameBg, themeSys.currentTheme:GetStyleColor("FrameBg" )) + themeSys.PushColor(ImGuiCol.FrameBgHovered, themeSys.currentTheme:GetStyleColor("FrameBgHovered" )) + themeSys.PushColor(ImGuiCol.FrameBgActive, themeSys.currentTheme:GetStyleColor("FrameBgActive" )) + themeSys.PushColor(ImGuiCol.Button, themeSys.currentTheme:GetStyleColor("Button" )) + themeSys.PushColor(ImGuiCol.ButtonHovered, themeSys.currentTheme:GetStyleColor("ButtonHovered" )) + themeSys.PushColor(ImGuiCol.ButtonActive, themeSys.currentTheme:GetStyleColor("ButtonActive" )) + themeSys.PushColor(ImGuiCol.Separator, themeSys.currentTheme:GetStyleColor("Separator" )) + themeSys.PushColor(ImGuiCol.PopupBg, themeSys.currentTheme:GetStyleColor("PopupBg" )) + + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, 8, 8) + ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0) +end + +function themeSys.PopTheme() + ImGui.PopStyleColor(25) + ImGui.PopStyleVar(2) +end + +return themeSys \ No newline at end of file diff --git a/scripts/modules/gui/themes/baseTheme.lua b/scripts/modules/gui/themes/baseTheme.lua new file mode 100644 index 0000000..380dc7e --- /dev/null +++ b/scripts/modules/gui/themes/baseTheme.lua @@ -0,0 +1,61 @@ +---@class baseTheme +---@operator call(string):baseTheme +local baseTheme = { + name = "default", + colors = {}, +} +baseTheme.__index = baseTheme + +-- baseTheme constructor + +setmetatable(baseTheme, { + __call = function (cls, ...) + return cls.New(...) + end, +}) + + +---@param aName string +---@return baseTheme +function baseTheme.New(aName) -- path: aPath + local self = setmetatable({}, baseTheme) + self.name = aName or self.name + return self +end + +-- methods +function baseTheme.GetName(self) + return self.name +end + +---Safe call method +---@param self baseTheme +---@param aMethod string +---@param ... any +---@return any +function baseTheme.Call(self, aMethod, ...) + if self[aMethod] then + return self[aMethod](self, ...) + end +end + +---Only call method in specific theme +---@param self baseTheme +---@param aThemeName string +---@param aMethod string +---@param ... any +---@return any +function baseTheme.CallIf(self, aThemeName, aMethod, ...) + if self.name == aThemeName and self[aMethod] then + return self[aMethod](self, ...) + end +end + +---@param self baseTheme +---@param aGuiColor string +---@return float[] +function baseTheme.GetStyleColor(self, aGuiColor) + return self.colors[aGuiColor] +end + +return baseTheme \ No newline at end of file diff --git a/scripts/modules/gui/themes/default.lua b/scripts/modules/gui/themes/default.lua new file mode 100644 index 0000000..42716d3 --- /dev/null +++ b/scripts/modules/gui/themes/default.lua @@ -0,0 +1,80 @@ +local baseTheme = require("modules/gui/themes/baseTheme") + +---@class themeDefault : baseTheme +local themeDefault = baseTheme("default") + +themeDefault.colors = { + Text = { 1 , 0.44, 0.4 , 1 }, + TextDisabled = { 0.48, 0.39, 0.40, 1 }, + WindowBg = { 0.06, 0.04, 0.06, 0.9 }, + ChildBg = { 0.06, 0.04, 0.06, 0.9 }, + PopupBg = { 0.06, 0.04, 0.06, 0.9 }, + Border = { 0.3 , 0.07, 0.08, 1 }, + BorderShadow = { 0 , 0 , 0 , 0 }, + FrameBg = { 0.57, 0.17, 0.16, 1 }, + FrameBgHovered = { 0.32, 0.09, 0.11, 1 }, + FrameBgActive = { 0.1 , 0.05, 0.05, 1 }, + FrameBgDisabled = { 0.48, 0.39, 0.40, 1 }, + FrameBgHoveredDisabled = { 0.48, 0.39, 0.40, 1 }, + FrameBgActiveDisabled = { 0.48, 0.39, 0.40, 1 }, + TitleBg = { 0.06, 0.04, 0.06, 0.9 }, + TitleBgActive = { 0.06, 0.04, 0.06, 0.9 }, + TitleBgCollapsed = { 0.06, 0.04, 0.06, 0.9 }, + MenuBarBg = { 0 , 0 , 0 , 0 }, + ScrollbarBg = { 0.06, 0.04, 0.06, 0 }, + ScrollbarGrab = { 0.57, 0.17, 0.16, 1 }, + ScrollbarGrabHovered = { 0.57, 0.17, 0.16, 1 }, + ScrollbarGrabActive = { 0.57, 0.17, 0.16, 1 }, + CheckMark = { 1 , 0.44, 0.4 , 1 }, + CheckMarkTrueDisabled = { 0.34, 0.22, 0.24, 1 }, + CheckMarkFalseDisabled = { 0.48, 0.39, 0.40, 1 }, + SliderGrab = { 0 , 0 , 0 , 0 }, + SliderGrabActive = { 0 , 0 , 0 , 0 }, + Button = { 0.57, 0.17, 0.16, 1 }, + ButtonHovered = { 0.45, 0.13, 0.14, 1 }, + ButtonActive = { 0.57, 0.17, 0.16, 1 }, + Header = { 0.22, 0.64, 0.69, 0.2 }, + HeaderHovered = { 0.22, 0.64, 0.69, 0.3 }, + HeaderActive = { 0.22, 0.64, 0.69, 0.5 }, + Separator = { 0.3 , 0.07, 0.08, 1 }, + SeparatorHovered = { 0.29, 0.77, 0.79, 1 }, + SeparatorActive = { 0.29, 0.77, 0.79, 1 }, + ResizeGrip = { 0.06, 0.04, 0.06, 1 }, + ResizeGripHovered = { 1 , 0.44, 0.4 , 1 }, + ResizeGripActive = { 1 , 0.44, 0.4 , 1 }, + Tab = { 0 , 0 , 0 , 0 }, + TabHovered = { 0 , 0 , 0 , 0 }, + TabActive = { 0 , 0 , 0 , 0 }, + TabUnfocused = { 0 , 0 , 0 , 0 }, + TabUnfocusedActive = { 0 , 0 , 0 , 0 }, + DockingPreview = { 0 , 0 , 0 , 0 }, + DockingEmptyBg = { 0 , 0 , 0 , 0 }, + PlotLines = { 0 , 0 , 0 , 0 }, + PlotLinesHovered = { 0 , 0 , 0 , 0 }, + PlotHistogram = { 0 , 0 , 0 , 0 }, + PlotHistogramHovered = { 0 , 0 , 0 , 0 }, + TextSelectedBg = { 0 , 0 , 0 , 0 }, + DragDropTarget = { 0 , 0 , 0 , 0 }, + NavHighlight = { 0 , 0 , 0 , 0 }, + NavWindowingHighlight = { 0 , 0 , 0 , 0 }, + NavWindowingDimBg = { 0 , 0 , 0 , 0 }, + ModalWindowDimBg = { 0 , 0 , 0 , 0 }, + ModalWindowDarkening = { 0 , 0 , 0 , 0 }, + COUNT = { 0 , 0 , 0 , 0 }, + CustomToggleOn = { 0.29, 0.77, 0.79, 1 }, + CustomToggleOnHovered = { 0.20, 0.56, 0.59, 1 }, + CustomToggleOnActive = { 0.29, 0.77, 0.79, 1 }, + CustomToggleOnText = { 0 , 0 , 0 , 1 }, + CustomToggleOnDisable = { 0.04, 0.11, 0.12, 1 }, + CustomToggleOnDisableHovered = { 0.05, 0.16, 0.16, 1 }, + CustomToggleOnDisableText = { 0.06, 0.18, 0.2 , 1 }, + CustomToggleOff = { 0.57, 0.18, 0.16, 1 }, + CustomToggleOffHovered = { 0.45, 0.13, 0.14, 1 }, + CustomToggleOffDisable = { 0.1 , 0.04, 0.07, 1 }, + CustomToggleOffDisableHovered = { 0.16, 0.06, 0.07, 1 }, + CustomToggleOffDisableText = { 0.22, 0.07, 0.07, 1 }, + AltText = { 0.29, 0.77, 0.79, 1 }, + Hidden = { 0 , 0 , 0 , 0 }, +} + +return themeDefault \ No newline at end of file diff --git a/scripts/modules/gui/themes/ua_special.lua b/scripts/modules/gui/themes/ua_special.lua new file mode 100644 index 0000000..351d9be --- /dev/null +++ b/scripts/modules/gui/themes/ua_special.lua @@ -0,0 +1,87 @@ +local baseTheme = require("modules/gui/themes/baseTheme") + +---@class themeUA : baseTheme +local themeUA = baseTheme("ua_special") + +themeUA.colors = { + Text = { 0.96, 0.81, 0.00, 1 }, + TextDisabled = { 0.48, 0.39, 0.40, 1 }, + WindowBg = { 0.05, 0.11, 0.18, 0.9 }, + ChildBg = { 0.05, 0.11, 0.18, 0.9 }, + PopupBg = { 0.05, 0.11, 0.18, 0.9 }, + Border = { 0.60, 0.51, 0.00, 1 }, + BorderShadow = { 0 , 0 , 0 , 0 }, + FrameBg = { 0.00, 0.35, 0.71, 1 }, + FrameBgHovered = { 0.00, 0.44, 0.90, 1 }, + FrameBgActive = { 0.00, 0.35, 0.71, 1 }, + FrameBgDisabled = { 0.48, 0.39, 0.40, 1 }, + FrameBgHoveredDisabled = { 0.48, 0.39, 0.40, 1 }, + FrameBgActiveDisabled = { 0.48, 0.39, 0.40, 1 }, + TitleBg = { 0.05, 0.11, 0.18, 0.9 }, + TitleBgActive = { 0.05, 0.11, 0.18, 0.9 }, + TitleBgCollapsed = { 0.05, 0.11, 0.18, 0.9 }, + MenuBarBg = { 0.05, 0.11, 0.18, 0.9 }, + ScrollbarBg = { 0.06, 0.04, 0.06, 0 }, + ScrollbarGrab = { 0.00, 0.35, 0.71, 1 }, + ScrollbarGrabHovered = { 0.00, 0.44, 0.90, 1 }, + ScrollbarGrabActive = { 0.00, 0.35, 0.71, 1 }, + CheckMark = { 0.96, 0.81, 0.00, 1 }, + CheckMarkTrueDisabled = { 0.34, 0.22, 0.24, 1 }, + CheckMarkFalseDisabled = { 0.48, 0.39, 0.40, 1 }, + SliderGrab = { 0 , 0 , 0 , 0 }, + SliderGrabActive = { 0 , 0 , 0 , 0 }, + Button = { 0.00, 0.35, 0.71, 1 }, + ButtonHovered = { 0.00, 0.44, 0.90, 1 }, + ButtonActive = { 0.00, 0.35, 0.71, 1 }, + Header = { 0.00, 0.21, 0.43, 0.6 }, + HeaderHovered = { 0.00, 0.21, 0.43, 0.9 }, + HeaderActive = { 0.00, 0.21, 0.43, 0.9 }, + Separator = { 0.60, 0.51, 0.00, 0.5 }, + SeparatorHovered = { 0.29, 0.77, 0.79, 1 }, + SeparatorActive = { 0.29, 0.77, 0.79, 1 }, + ResizeGrip = { 0.05, 0.11, 0.18, 1 }, + ResizeGripHovered = { 0.96, 0.81, 0.00, 1 }, + ResizeGripActive = { 0.96, 0.81, 0.00, 1 }, + Tab = { 0 , 0 , 0 , 0 }, + TabHovered = { 0 , 0 , 0 , 0 }, + TabActive = { 0 , 0 , 0 , 0 }, + TabUnfocused = { 0 , 0 , 0 , 0 }, + TabUnfocusedActive = { 0 , 0 , 0 , 0 }, + DockingPreview = { 0 , 0 , 0 , 0 }, + DockingEmptyBg = { 0 , 0 , 0 , 0 }, + PlotLines = { 0 , 0 , 0 , 0 }, + PlotLinesHovered = { 0 , 0 , 0 , 0 }, + PlotHistogram = { 0 , 0 , 0 , 0 }, + PlotHistogramHovered = { 0 , 0 , 0 , 0 }, + TextSelectedBg = { 0 , 0 , 0 , 0 }, + DragDropTarget = { 0 , 0 , 0 , 0 }, + NavHighlight = { 0 , 0 , 0 , 0 }, + NavWindowingHighlight = { 0 , 0 , 0 , 0 }, + NavWindowingDimBg = { 0 , 0 , 0 , 0 }, + ModalWindowDimBg = { 0 , 0 , 0 , 0 }, + ModalWindowDarkening = { 0 , 0 , 0 , 0 }, + COUNT = { 0 , 0 , 0 , 0 }, + CustomToggleOn = { 0.96, 0.81, 0.00, 1 }, + CustomToggleOnHovered = { 0.81, 0.67, 0.00, 1 }, + CustomToggleOnActive = { 0.96, 0.81, 0.00, 1 }, + CustomToggleOnText = { 0.00, 0.44, 0.90, 1 }, + CustomToggleOnDisable = { 0.04, 0.11, 0.12, 1 }, + CustomToggleOnDisableHovered = { 0.05, 0.16, 0.16, 1 }, + CustomToggleOnDisableText = { 0.06, 0.18, 0.2 , 1 }, + CustomToggleOff = { 0.57, 0.18, 0.16, 1 }, + CustomToggleOffHovered = { 0.45, 0.13, 0.14, 1 }, + CustomToggleOffDisable = { 0.1 , 0.04, 0.07, 1 }, + CustomToggleOffDisableHovered = { 0.16, 0.06, 0.07, 1 }, + CustomToggleOffDisableText = { 0.22, 0.07, 0.07, 1 }, + AltText = { 0.00, 0.44, 0.90, 1 }, + Hidden = { 0 , 0 , 0 , 0 }, +} + +function themeUA.RenderFooter(self) + ImGui.TableSetColumnIndex(1) + ImGui.PushStyleColor(ImGuiCol.Text, unpack(self.colors.Border)) + ImGui.Text("We stand with Ukraine!") + ImGui.PopStyleColor(1) +end + +return themeUA \ No newline at end of file diff --git a/scripts/modules/gui/themes/white.lua b/scripts/modules/gui/themes/white.lua new file mode 100644 index 0000000..39a5de0 --- /dev/null +++ b/scripts/modules/gui/themes/white.lua @@ -0,0 +1,173 @@ +local baseTheme = require("modules/gui/themes/baseTheme") + +---@class themeWhite : baseTheme +local themeWhite = baseTheme("white") + +themeWhite.states = {} + +themeWhite.def_colors = { + Text = { 1 , 1 , 1 , 1 }, + TextDisabled = { 1 , 1 , 1 , 1 }, + WindowBg = { 1 , 1 , 1 , 1 }, + ChildBg = { 1 , 1 , 1 , 1 }, + PopupBg = { 1 , 1 , 1 , 1 }, + Border = { 1 , 1 , 1 , 1 }, + BorderShadow = { 1 , 1 , 1 , 1 }, + FrameBg = { 1 , 1 , 1 , 1 }, + FrameBgHovered = { 1 , 1 , 1 , 1 }, + FrameBgActive = { 1 , 1 , 1 , 1 }, + FrameBgDisabled = { 1 , 1 , 1 , 1 }, + FrameBgHoveredDisabled = { 1 , 1 , 1 , 1 }, + FrameBgActiveDisabled = { 1 , 1 , 1 , 1 }, + TitleBg = { 1 , 1 , 1 , 1 }, + TitleBgActive = { 1 , 1 , 1 , 1 }, + TitleBgCollapsed = { 1 , 1 , 1 , 1 }, + MenuBarBg = { 1 , 1 , 1 , 1 }, + ScrollbarBg = { 1 , 1 , 1 , 1 }, + ScrollbarGrab = { 1 , 1 , 1 , 1 }, + ScrollbarGrabHovered = { 1 , 1 , 1 , 1 }, + ScrollbarGrabActive = { 1 , 1 , 1 , 1 }, + CheckMark = { 1 , 1 , 1 , 1 }, + CheckMarkTrueDisabled = { 1 , 1 , 1 , 1 }, + CheckMarkFalseDisabled = { 1 , 1 , 1 , 1 }, + SliderGrab = { 1 , 1 , 1 , 1 }, + SliderGrabActive = { 1 , 1 , 1 , 1 }, + Button = { 1 , 1 , 1 , 1 }, + ButtonHovered = { 1 , 1 , 1 , 1 }, + ButtonActive = { 1 , 1 , 1 , 1 }, + Header = { 1 , 1 , 1 , 1 }, + HeaderHovered = { 1 , 1 , 1 , 1 }, + HeaderActive = { 1 , 1 , 1 , 1 }, + Separator = { 1 , 1 , 1 , 1 }, + SeparatorHovered = { 1 , 1 , 1 , 1 }, + SeparatorActive = { 1 , 1 , 1 , 1 }, + ResizeGrip = { 1 , 1 , 1 , 1 }, + ResizeGripHovered = { 1 , 1 , 1 , 1 }, + ResizeGripActive = { 1 , 1 , 1 , 1 }, + Tab = { 1 , 1 , 1 , 1 }, + TabHovered = { 1 , 1 , 1 , 1 }, + TabActive = { 1 , 1 , 1 , 1 }, + TabUnfocused = { 1 , 1 , 1 , 1 }, + TabUnfocusedActive = { 1 , 1 , 1 , 1 }, + DockingPreview = { 1 , 1 , 1 , 1 }, + DockingEmptyBg = { 1 , 1 , 1 , 1 }, + PlotLines = { 1 , 1 , 1 , 1 }, + PlotLinesHovered = { 1 , 1 , 1 , 1 }, + PlotHistogram = { 1 , 1 , 1 , 1 }, + PlotHistogramHovered = { 1 , 1 , 1 , 1 }, + TextSelectedBg = { 1 , 1 , 1 , 1 }, + DragDropTarget = { 1 , 1 , 1 , 1 }, + NavHighlight = { 1 , 1 , 1 , 1 }, + NavWindowingHighlight = { 1 , 1 , 1 , 1 }, + NavWindowingDimBg = { 1 , 1 , 1 , 1 }, + ModalWindowDimBg = { 1 , 1 , 1 , 1 }, + ModalWindowDarkening = { 1 , 1 , 1 , 1 }, + COUNT = { 1 , 1 , 1 , 1 }, + CustomToggleOn = { 1 , 1 , 1 , 1 }, + CustomToggleOnHovered = { 1 , 1 , 1 , 1 }, + CustomToggleOnActive = { 1 , 1 , 1 , 1 }, + CustomToggleOnText = { 1 , 1 , 1 , 1 }, + CustomToggleOnDisable = { 1 , 1 , 1 , 1 }, + CustomToggleOnDisableHovered = { 1 , 1 , 1 , 1 }, + CustomToggleOnDisableText = { 1 , 1 , 1 , 1 }, + CustomToggleOff = { 1 , 1 , 1 , 1 }, + CustomToggleOffHovered = { 1 , 1 , 1 , 1 }, + CustomToggleOffDisable = { 1 , 1 , 1 , 1 }, + CustomToggleOffDisableHovered = { 1 , 1 , 1 , 1 }, + CustomToggleOffDisableText = { 1 , 1 , 1 , 1 }, + AltText = { 1 , 1 , 1 , 1 }, + Hidden = { 1 , 1 , 1 , 1 }, +} + +themeWhite.hvr_colors = { + Text = { 0.20, 0.20, 0.20, 1 }, + TextDisabled = { 0.48, 0.39, 0.40, 1 }, + WindowBg = { 1 , 1 , 1 , 0.9 }, + ChildBg = { 1 , 1 , 1 , 0.9 }, + PopupBg = { 1 , 1 , 1 , 0.9 }, + Border = { 0.5 , 0.5 , 0.5 , 1 }, + BorderShadow = { 0 , 0 , 0 , 0 }, + FrameBg = { 1 , 1 , 1 , 1 }, + FrameBgHovered = { 0.80, 0.80, 0.80, 1 }, + FrameBgActive = { 1 , 1 , 1 , 1 }, + FrameBgDisabled = { 0.48, 0.39, 0.40, 1 }, + FrameBgHoveredDisabled = { 0.48, 0.39, 0.40, 1 }, + FrameBgActiveDisabled = { 0.48, 0.39, 0.40, 1 }, + TitleBg = { 1 , 1 , 1 , 0.9 }, + TitleBgActive = { 1 , 1 , 1 , 0.9 }, + TitleBgCollapsed = { 1 , 1 , 1 , 0.9 }, + MenuBarBg = { 1 , 1 , 1 , 0.9 }, + ScrollbarBg = { 0.06, 0.04, 0.06, 0 }, + ScrollbarGrab = { 1 , 1 , 1 , 1 }, + ScrollbarGrabHovered = { 0.80, 0.80, 0.80, 1 }, + ScrollbarGrabActive = { 1 , 1 , 1 , 1 }, + CheckMark = { 0.20, 0.20, 0.20, 1 }, + CheckMarkTrueDisabled = { 0.20, 0.20, 0.20, 1 }, + CheckMarkFalseDisabled = { 0.20, 0.20, 0.20, 1 }, + SliderGrab = { 0 , 0 , 0 , 0 }, + SliderGrabActive = { 0 , 0 , 0 , 0 }, + Button = { 1 , 1 , 1 , 1 }, + ButtonHovered = { 0.80, 0.80, 0.80, 1 }, + ButtonActive = { 1 , 1 , 1 , 1 }, + Header = { 0.80, 0.80, 0.80, 0.6 }, + HeaderHovered = { 0.80, 0.80, 0.80, 0.9 }, + HeaderActive = { 0.80, 0.80, 0.80, 0.9 }, + Separator = { 0.5 , 0.5 , 0.5 , 1 }, + SeparatorHovered = { 0.5 , 0.5 , 0.5 , 1 }, + SeparatorActive = { 0.5 , 0.5 , 0.5 , 1 }, + ResizeGrip = { 0.80, 0.80, 0.80, 1 }, + ResizeGripHovered = { 0.70, 0.70, 0.70, 1 }, + ResizeGripActive = { 0.70, 0.70, 0.70, 1 }, + Tab = { 0 , 0 , 0 , 0 }, + TabHovered = { 0 , 0 , 0 , 0 }, + TabActive = { 0 , 0 , 0 , 0 }, + TabUnfocused = { 0 , 0 , 0 , 0 }, + TabUnfocusedActive = { 0 , 0 , 0 , 0 }, + DockingPreview = { 0 , 0 , 0 , 0 }, + DockingEmptyBg = { 0 , 0 , 0 , 0 }, + PlotLines = { 0 , 0 , 0 , 0 }, + PlotLinesHovered = { 0 , 0 , 0 , 0 }, + PlotHistogram = { 0 , 0 , 0 , 0 }, + PlotHistogramHovered = { 0 , 0 , 0 , 0 }, + TextSelectedBg = { 0 , 0 , 0 , 0 }, + DragDropTarget = { 0 , 0 , 0 , 0 }, + NavHighlight = { 0 , 0 , 0 , 0 }, + NavWindowingHighlight = { 0 , 0 , 0 , 0 }, + NavWindowingDimBg = { 0 , 0 , 0 , 0 }, + ModalWindowDimBg = { 0 , 0 , 0 , 0 }, + ModalWindowDarkening = { 0 , 0 , 0 , 0 }, + COUNT = { 0 , 0 , 0 , 0 }, + CustomToggleOn = { 0.80, 0.80, 0.80, 1 }, + CustomToggleOnHovered = { 0.70, 0.70, 0.70, 1 }, + CustomToggleOnActive = { 0.80, 0.80, 0.80, 1 }, + CustomToggleOnText = { 0.20, 0.20, 0.20, 1 }, + CustomToggleOnDisable = { 0.04, 0.11, 0.12, 1 }, + CustomToggleOnDisableHovered = { 0.05, 0.16, 0.16, 1 }, + CustomToggleOnDisableText = { 0.06, 0.18, 0.2 , 1 }, + CustomToggleOff = { 0.57, 0.18, 0.16, 1 }, + CustomToggleOffHovered = { 0.45, 0.13, 0.14, 1 }, + CustomToggleOffDisable = { 0.1 , 0.04, 0.07, 1 }, + CustomToggleOffDisableHovered = { 0.16, 0.06, 0.07, 1 }, + CustomToggleOffDisableText = { 0.22, 0.07, 0.07, 1 }, + AltText = { 0.80, 0.80, 0.80, 1 }, + Hidden = { 0 , 0 , 0 , 0 }, +} + +---@param self themeWhite +---@param aGuiColor string +---@return float[] +function themeWhite.GetStyleColor(self, aGuiColor) + for window, hovering in pairs(self.states) do + if hovering then + return self.hvr_colors[aGuiColor] + end + end + return self.def_colors[aGuiColor] +end + +---@param aWindow string +function themeWhite.GetHoverState(self, aWindow) + self.states[aWindow] = ImGui.IsWindowHovered(bit32.bor(ImGuiHoveredFlags.RootAndChildWindows, ImGuiHoveredFlags.AllowWhenBlockedByActiveItem, ImGuiHoveredFlags.AllowWhenBlockedByPopup, ImGuiHoveredFlags.AllowWhenDisabled)) +end + +return themeWhite \ No newline at end of file diff --git a/scripts/modules/gui/widgets/btnToggle.lua b/scripts/modules/gui/widgets/btnToggle.lua index 96d081e..1d2c1d4 100644 --- a/scripts/modules/gui/widgets/btnToggle.lua +++ b/scripts/modules/gui/widgets/btnToggle.lua @@ -1,6 +1,5 @@ local dpi = require ("modules/gui/dpi") -local style = require ("modules/gui/style") -local theme = require ("modules/gui/theme") +local themeSys = require ("modules/gui/themeSys") -- config local padding_x = 5 @@ -25,15 +24,15 @@ local function btnToggle(aLabel, aValue, aSizeX, aSizeY, aAutoscale) local imgui_style = ImGui.GetStyle() ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, imgui_style.FramePadding.x + dpi.Scale(padding_x), imgui_style.FramePadding.y + dpi.Scale(padding_y)) if aValue then - style.PushColor(ImGuiCol.Button, theme.CustomToggleOn) - style.PushColor(ImGuiCol.ButtonHovered, theme.CustomToggleOnHovered) - style.PushColor(ImGuiCol.ButtonActive, theme.CustomToggleOnActive) - style.PushColor(ImGuiCol.Text, theme.CustomToggleOnText) + themeSys.PushColor(ImGuiCol.Button, themeSys.GetCurrentTheme():GetStyleColor("CustomToggleOn")) + themeSys.PushColor(ImGuiCol.ButtonHovered, themeSys.GetCurrentTheme():GetStyleColor("CustomToggleOnHovered")) + themeSys.PushColor(ImGuiCol.ButtonActive, themeSys.GetCurrentTheme():GetStyleColor("CustomToggleOnActive")) + themeSys.PushColor(ImGuiCol.Text, themeSys.GetCurrentTheme():GetStyleColor("CustomToggleOnText")) else - style.PushColor(ImGuiCol.Button, theme.Button) - style.PushColor(ImGuiCol.ButtonHovered, theme.ButtonHovered) - style.PushColor(ImGuiCol.ButtonActive, theme.ButtonActive) - style.PushColor(ImGuiCol.Text, theme.Text) + themeSys.PushColor(ImGuiCol.Button, themeSys.GetCurrentTheme():GetStyleColor("Button")) + themeSys.PushColor(ImGuiCol.ButtonHovered, themeSys.GetCurrentTheme():GetStyleColor("ButtonHovered")) + themeSys.PushColor(ImGuiCol.ButtonActive, themeSys.GetCurrentTheme():GetStyleColor("ButtonActive")) + themeSys.PushColor(ImGuiCol.Text, themeSys.GetCurrentTheme():GetStyleColor("Text")) end if ImGui.Button(aLabel, aSizeX, aSizeY) then aValue = not aValue diff --git a/scripts/modules/gui/window.lua b/scripts/modules/gui/window.lua index 6ccb7ca..83240f2 100644 --- a/scripts/modules/gui/window.lua +++ b/scripts/modules/gui/window.lua @@ -3,8 +3,7 @@ local dpi = require("modules/gui/dpi") local i18n = require("modules/i18n") local languages = require("lang/lang") local widgets = require("modules/gui/widgets") -local style = require("modules/gui/style") -local theme = require("modules/gui/theme") +local themeSys = require("modules/gui/themeSys") local options = CETMM.GetOptions() local mods = CETMM.GetBackEnd().GetMods() local dofiles = CETMM.GetDofiles() @@ -38,6 +37,7 @@ local layout = { local function renderAboutWindow() window.m_draw_about = ImGui.Begin(window.m_about_title, window.m_draw_about, bit32.bor(ImGuiWindowFlags.NoSavedSettings, ImGuiWindowFlags.NoResize)) if window.m_draw_about then + themeSys.GetCurrentTheme():CallIf("white", "GetHoverState", "about") ImGui.SetWindowPos(dpi.GetDisplayResolution().x / 2 - dpi.Scale(300), dpi.Scale(dpi.GetDisplayResolution().y * 0.1), ImGuiCond.FirstUseEver) @@ -139,13 +139,14 @@ local function settings_popup() -- Theme if ImGui.BeginMenu("Theme") then - if ImGui.MenuItem("Default", "", options.m_theme == "default") then - options.m_theme = "default" - theme.Load() + if select(2, ImGui.MenuItem("Default", "", options.m_theme == "default")) then + themeSys.Load("default") end - if ImGui.MenuItem("UA Special", "", options.m_theme == "ua_special") then - options.m_theme = "ua_special" - theme.Load() + if select(2, ImGui.MenuItem("UA Special", "", options.m_theme == "ua_special")) then + themeSys.Load("ua_special") + end + if select(2, ImGui.MenuItem("White", "", options.m_theme == "white")) then + themeSys.Load("white") end ImGui.EndMenu() end @@ -164,7 +165,7 @@ local function settings_popup() end for _, entry in ipairs(languages) do - if ImGui.MenuItem(entry.name, "", options.m_lang == entry.id) then + if select(2, ImGui.MenuItem(entry.name, "", options.m_lang == entry.id)) then options.m_lang = entry.id CETMM.GetLocale().SetLocale() end @@ -215,6 +216,8 @@ end function window.Render() window.m_draw = ImGui.Begin(i18n("window_title"), window.m_draw) if window.m_draw then + -- Hover check for white theme + themeSys.GetCurrentTheme():CallIf("white", "GetHoverState", "main") -- Set window size and position ImGui.SetWindowPos(dpi.GetDisplayResolution().x / 2 - 210 * dpi.GetScale(), dpi.GetDisplayResolution().y / 2 - 320 * dpi.GetScale(), @@ -284,7 +287,7 @@ function window.Render() ImGui.Spacing() ImGui.TextWrapped(i18n("text_help_manager_5")) else - style.PushColor(ImGuiCol.Text, theme.AltText) + themeSys.PushColor(ImGuiCol.Text, themeSys.GetCurrentTheme():GetStyleColor("AltText")) ImGui.TextWrapped(i18n("text_help_dofiles_1")) ImGui.Spacing() ImGui.TextWrapped(i18n("text_help_dofiles_2")) @@ -379,12 +382,7 @@ function window.Render() CETMM.GetBackEnd().OpenDofilesFolder() end - if options.m_theme == "ua_special" then - ImGui.TableSetColumnIndex(1) - style.PushColor(ImGuiCol.Text, theme.Border) - ImGui.Text("We stand with Ukraine!") - ImGui.PopStyleColor(1) - end + themeSys.GetCurrentTheme():CallIf("ua_special", "RenderFooter") ImGui.EndTable() end diff --git a/scripts/modules/options.lua b/scripts/modules/options.lua index 00d664d..d70296a 100644 --- a/scripts/modules/options.lua +++ b/scripts/modules/options.lua @@ -5,7 +5,7 @@ local options = { m_lang = "en_us", m_autoappear = true, - m_theme = "default" + m_theme = "white" --default } -- private functions diff --git a/src/Installer/Update.cpp b/src/Installer/Update.cpp index 2fe0bb5..24da5f5 100644 --- a/src/Installer/Update.cpp +++ b/src/Installer/Update.cpp @@ -74,7 +74,10 @@ void Update::extractModule() bin2cppLua::FileManager& mgr_lua = bin2cppLua::FileManager::getInstance(); bool saved_lua = mgr_lua.saveFiles(scriptDir.string().c_str()); if (saved_loose && saved_lua) + { spdlog::info("Extracted script files to \"{}\"", scriptDir.string()); + setConfig(); // white update + } else spdlog::error("Failed to extract script files to \"{}\"", scriptDir.string()); } @@ -104,4 +107,24 @@ void Update::removeOldModule() spdlog::info("Removed: {}", dir_entry.path().string()); } } +} + +void Update::setConfig() // white update +{ + spdlog::info("Updating theme config.."); + + std::filesystem::path configPath = Installer::GetPaths().CETMMRoot() / "config.json"; + + std::fstream file; + file.open(configPath, std::fstream::in | std::fstream::out); + if (!file.is_open()) return; + + nlohmann::json cetmm_config = nlohmann::json::parse(file); + std::filesystem::resize_file(configPath, 0); + file.seekg(0); + + cetmm_config["theme"] = "white"; + + file << cetmm_config.dump() << std::endl; + file.close(); } \ No newline at end of file diff --git a/src/Installer/Update.h b/src/Installer/Update.h index 4258885..8ec2ef2 100644 --- a/src/Installer/Update.h +++ b/src/Installer/Update.h @@ -16,4 +16,5 @@ class Update std::string getModuleVersion(); void extractModule(); void removeOldModule(); + void setConfig(); //white update }; \ No newline at end of file