Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the player's theme colors in ImGui #77842

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/cata_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,3 +1055,49 @@ void cataimgui::EndRightAlign()
{
ImGui::EndTable();
}

void cataimgui::init_colors()
{
ImGuiStyle &style = ImGui::GetStyle();

style.Colors[ImGuiCol_Text] = c_white;
Night-Pryanik marked this conversation as resolved.
Show resolved Hide resolved
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;
}
3 changes: 3 additions & 0 deletions src/cata_imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down
Loading