From c86395c7d0d3fef219354cccfca1ffef2833ab9d Mon Sep 17 00:00:00 2001 From: CLIDragon <84266961+CLIDragon@users.noreply.github.com> Date: Thu, 14 Nov 2024 22:06:57 +1000 Subject: [PATCH 1/2] Use the player's theme colors in ImGui Co-authored-by: vetal l Co-authored-by: Daniel Brooks --- src/cata_imgui.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/cata_imgui.h | 3 +++ src/main.cpp | 3 +++ 3 files changed, 52 insertions(+) diff --git a/src/cata_imgui.cpp b/src/cata_imgui.cpp index 4f6679a8ebab3..0ef3265036f14 100644 --- a/src/cata_imgui.cpp +++ b/src/cata_imgui.cpp @@ -1055,3 +1055,49 @@ void cataimgui::EndRightAlign() { ImGui::EndTable(); } + +void cataimgui::init_colors() +{ + ImGuiStyle &style = ImGui::GetStyle(); + + style.Colors[ImGuiCol_Text] = c_white; + style.Colors[ImGuiCol_TextDisabled] = c_dark_gray; + style.Colors[ImGuiCol_WindowBg] = c_black; + style.Colors[ImGuiCol_ChildBg] = c_black; + style.Colors[ImGuiCol_PopupBg] = c_black; + style.Colors[ImGuiCol_Border] = c_white; + style.Colors[ImGuiCol_BorderShadow] = c_blue; + style.Colors[ImGuiCol_FrameBg] = c_dark_gray; + style.Colors[ImGuiCol_FrameBgHovered] = c_black; + style.Colors[ImGuiCol_FrameBgActive] = c_dark_gray; + style.Colors[ImGuiCol_TitleBg] = c_blue; + style.Colors[ImGuiCol_TitleBgActive] = c_dark_gray; + style.Colors[ImGuiCol_TitleBgCollapsed] = c_blue; + style.Colors[ImGuiCol_MenuBarBg] = c_black; + style.Colors[ImGuiCol_ScrollbarBg] = c_black; + style.Colors[ImGuiCol_ScrollbarGrab] = c_dark_gray; + style.Colors[ImGuiCol_ScrollbarGrabHovered] = c_light_gray; + style.Colors[ImGuiCol_ScrollbarGrabActive] = c_white; + style.Colors[ImGuiCol_CheckMark] = c_white; + style.Colors[ImGuiCol_SliderGrab] = c_white; + style.Colors[ImGuiCol_SliderGrabActive] = c_white; + style.Colors[ImGuiCol_Button] = c_dark_gray; + style.Colors[ImGuiCol_ButtonHovered] = c_dark_gray; + style.Colors[ImGuiCol_ButtonActive] = c_blue; + style.Colors[ImGuiCol_Header] = c_blue; + style.Colors[ImGuiCol_HeaderHovered] = c_black; + style.Colors[ImGuiCol_HeaderActive] = c_dark_gray; + style.Colors[ImGuiCol_Separator] = c_blue; + style.Colors[ImGuiCol_SeparatorHovered] = c_white; + style.Colors[ImGuiCol_SeparatorActive] = c_white; + style.Colors[ImGuiCol_ResizeGrip] = c_light_gray; + style.Colors[ImGuiCol_ResizeGripHovered] = c_white; + style.Colors[ImGuiCol_ResizeGripActive] = c_white; + style.Colors[ImGuiCol_Tab] = c_black; + style.Colors[ImGuiCol_TabHovered] = c_blue; + style.Colors[ImGuiCol_TabActive] = c_blue; + style.Colors[ImGuiCol_TabUnfocused] = c_black; + style.Colors[ImGuiCol_TabUnfocusedActive] = c_black; + style.Colors[ImGuiCol_TextSelectedBg] = c_blue; + style.Colors[ImGuiCol_NavHighlight] = c_blue; +} \ No newline at end of file diff --git a/src/cata_imgui.h b/src/cata_imgui.h index c921a6b37eb9c..1691508f8d6fd 100644 --- a/src/cata_imgui.h +++ b/src/cata_imgui.h @@ -155,4 +155,7 @@ void PushMonoFont(); bool BeginRightAlign( const char *str_id ); void EndRightAlign(); + +// Set ImGui theme colors to match colors loaded by the player. +void init_colors(); } // namespace cataimgui diff --git a/src/main.cpp b/src/main.cpp index 30d2f532e9765..9695ae140e91c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -802,6 +802,9 @@ int main( int argc, const char *argv[] ) exit_handler( -999 ); } + // Load the colors of ImGui to match the colors set by the user. + cataimgui::init_colors(); + // Override existing settings from cli options if( cli.disable_ascii_art ) { get_options().get_option( "ENABLE_ASCII_ART" ).setValue( "false" ); From da6a21f5be6fb59dd83c7bc6381e3540e5350654 Mon Sep 17 00:00:00 2001 From: Zhilkin Serg Date: Thu, 14 Nov 2024 17:53:39 +0300 Subject: [PATCH 2/2] Update cata_imgui.cpp --- src/cata_imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cata_imgui.cpp b/src/cata_imgui.cpp index 0ef3265036f14..d43660120a03b 100644 --- a/src/cata_imgui.cpp +++ b/src/cata_imgui.cpp @@ -1100,4 +1100,4 @@ void cataimgui::init_colors() style.Colors[ImGuiCol_TabUnfocusedActive] = c_black; style.Colors[ImGuiCol_TextSelectedBg] = c_blue; style.Colors[ImGuiCol_NavHighlight] = c_blue; -} \ No newline at end of file +}