Skip to content

Commit

Permalink
FSUI: Add Themes
Browse files Browse the repository at this point in the history
  • Loading branch information
kamfretoz committed Mar 2, 2025
1 parent 05e1947 commit 6ece112
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 27 deletions.
58 changes: 44 additions & 14 deletions pcsx2/ImGui/FullscreenUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ bool FullscreenUI::Initialize()
if (s_tried_to_initialize)
return false;

ImGuiFullscreen::SetTheme(Host::GetBaseBoolSettingValue("UI", "UseLightFullscreenUITheme", false));
ImGuiFullscreen::SetTheme(Host::GetBaseStringSettingValue("UI", "FullscreenUITheme", "Dark"));
ImGuiFullscreen::UpdateLayoutScale();
ApplyConfirmSetting();

Expand Down Expand Up @@ -695,6 +695,8 @@ void FullscreenUI::CheckForConfigChanges(const Pcsx2Config& old_config)
if (!IsInitialized())
return;

ImGuiFullscreen::SetTheme(Host::GetBaseStringSettingValue("UI", "FullscreenUITheme", "Dark"));

// If achievements got disabled, we might have the menu open...
// That means we're going to be reaching achievement state.
if (old_config.Achievements.Enabled && !EmuConfig.Achievements.Enabled)
Expand Down Expand Up @@ -999,7 +1001,7 @@ bool FullscreenUI::LoadResources()
s_fallback_exe_texture = LoadTexture("fullscreenui/applications-system.png");

for (u32 i = static_cast<u32>(GameDatabaseSchema::Compatibility::Nothing);
i <= static_cast<u32>(GameDatabaseSchema::Compatibility::Perfect); i++)
i <= static_cast<u32>(GameDatabaseSchema::Compatibility::Perfect); i++)
{
s_game_compatibility_textures[i - 1] = LoadTexture(fmt::format("icons/star-{}.png", i - 1).c_str());
}
Expand Down Expand Up @@ -3209,17 +3211,50 @@ void FullscreenUI::DrawSummarySettingsPage()

void FullscreenUI::DrawInterfaceSettingsPage()
{
static constexpr const char* s_theme_name[] = {
FSUI_NSTR("Dark"),
FSUI_NSTR("Light"),
FSUI_NSTR("Grey Matter"),
FSUI_NSTR("Untouched Lagoon"),
FSUI_NSTR("Baby Pastel"),
FSUI_NSTR("Pizza Time!"),
FSUI_NSTR("PCSX2 Blue"),
FSUI_NSTR("Scarlet Devil"),
FSUI_NSTR("Violet Angel"),
FSUI_NSTR("Cobalt Sky"),
FSUI_NSTR("AMOLED"),
};

static constexpr const char* s_theme_value[] = {
"Dark",
"Light",
"GreyMatter",
"UntouchedLagoon",
"BabyPastel",
"PizzaBrown",
"PCSX2Blue",
"ScarletDevil",
"VioletAngel",
"CobaltSky",
"AMOLED",
};

SettingsInterface* bsi = GetEditingSettingsInterface();

BeginMenuButtons();

MenuHeading(FSUI_CSTR("Behaviour"));
MenuHeading(FSUI_CSTR("Appearance"));
DrawStringListSetting(bsi, FSUI_ICONSTR(ICON_FA_PAINT_BRUSH, "Theme"),
FSUI_CSTR("Selects the color style to be used for Big Picture Mode."),
"UI", "FullscreenUITheme", "Dark", s_theme_name, s_theme_value, std::size(s_theme_name), true);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_INFO_CIRCLE, "Use Save State Selector"),
FSUI_CSTR("Show a save state selector UI when switching slots instead of showing a notification bubble."),
"EmuCore", "UseSavestateSelector", true);

MenuHeading(FSUI_CSTR("Behaviour"));
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_PF_SNOOZE, "Inhibit Screensaver"),
FSUI_CSTR("Prevents the screen saver from activating and the host from sleeping while emulation is running."), "EmuCore",
"InhibitScreensaver", true);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_USER_CIRCLE, "Enable Discord Presence"),
FSUI_CSTR("Shows the game you are currently playing as part of your profile on Discord."), "UI", "DiscordPresence", false);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_PAUSE, "Pause On Start"), FSUI_CSTR("Pauses the emulator when a game is started."), "UI",
"StartPaused", false);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_EYE, "Pause On Focus Loss"),
Expand All @@ -3239,15 +3274,6 @@ void FullscreenUI::DrawInterfaceSettingsPage()
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_ARCHIVE, "Create Save State Backups"),
FSUI_CSTR("Creates a backup copy of a save state if it already exists when the save is created. The backup copy has a .backup suffix"),
"EmuCore", "BackupSavestate", true);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_INFO_CIRCLE, "Use Save State Selector"),
FSUI_CSTR("Show a save state selector UI when switching slots instead of showing a notification bubble."),
"EmuCore", "UseSavestateSelector", true);
if (DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_LIGHTBULB, "Use Light Theme"),
FSUI_CSTR("Uses a light coloured theme instead of the default dark theme."), "UI", "UseLightFullscreenUITheme", false))
{
ImGuiFullscreen::SetTheme(bsi->GetBoolValue("UI", "UseLightFullscreenUITheme", false));
}

// DrawStringListSetting dosn't have a callback for applying settings
const SmallString swap_mode = bsi->GetSmallStringValue("UI", "SwapOKFullscreenUI", "auto");
static constexpr const char* swap_names[] = {
Expand Down Expand Up @@ -3294,6 +3320,10 @@ void FullscreenUI::DrawInterfaceSettingsPage()
});
}

MenuHeading(FSUI_CSTR("Integration"));
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_USER_CIRCLE, "Enable Discord Presence"),
FSUI_CSTR("Shows the game you are currently playing as part of your profile on Discord."), "UI", "DiscordPresence", false);

MenuHeading(FSUI_CSTR("Game Display"));
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_TV, "Start Fullscreen"),
FSUI_CSTR("Automatically switches to fullscreen mode when a game is started."), "UI", "StartFullscreen", false);
Expand Down
190 changes: 178 additions & 12 deletions pcsx2/ImGui/ImGuiFullscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ namespace ImGuiFullscreen
static u32 s_menu_button_index = 0;
static u32 s_close_button_state = 0;
static FocusResetType s_focus_reset_queued = FocusResetType::None;
static bool s_light_theme = false;

static LRUCache<std::string, std::shared_ptr<GSTexture>> s_texture_cache(128, true);
static std::shared_ptr<GSTexture> s_placeholder_texture;
Expand Down Expand Up @@ -2668,10 +2667,10 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing)
ImFont* const title_font = ImGuiFullscreen::g_large_font;
ImFont* const text_font = ImGuiFullscreen::g_medium_font;

const u32 toast_background_color = s_light_theme ? IM_COL32(241, 241, 241, 255) : IM_COL32(0x21, 0x21, 0x21, 255);
const u32 toast_border_color = s_light_theme ? IM_COL32(0x88, 0x88, 0x88, 255) : IM_COL32(0x48, 0x48, 0x48, 255);
const u32 toast_title_color = s_light_theme ? IM_COL32(1, 1, 1, 255) : IM_COL32(0xff, 0xff, 0xff, 255);
const u32 toast_text_color = s_light_theme ? IM_COL32(0, 0, 0, 255) : IM_COL32(0xff, 0xff, 0xff, 255);
const u32 toast_background_color = IM_COL32(0x21, 0x21, 0x21, 255);
const u32 toast_border_color = IM_COL32(0x48, 0x48, 0x48, 255);
const u32 toast_title_color = IM_COL32(0xff, 0xff, 0xff, 255);
const u32 toast_text_color = IM_COL32(0xff, 0xff, 0xff, 255);

for (u32 index = 0; index < static_cast<u32>(s_notifications.size());)
{
Expand Down Expand Up @@ -2839,13 +2838,10 @@ void ImGuiFullscreen::DrawToast()
}
}

void ImGuiFullscreen::SetTheme(bool light)
void ImGuiFullscreen::SetTheme(std::string_view theme)
{
s_light_theme = light;

if (!light)
if (theme == "Dark")
{
// dark
UIBackgroundColor = HEX_TO_IMVEC4(0x212121, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0xf0f0f0, 0xff);
Expand All @@ -2863,9 +2859,8 @@ void ImGuiFullscreen::SetTheme(bool light)
UISecondaryWeakColor = HEX_TO_IMVEC4(0x002171, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
}
else
else if (theme == "Light")
{
// light
UIBackgroundColor = HEX_TO_IMVEC4(0xc8c8c8, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0xe1e2e1, 0xff);
Expand All @@ -2883,4 +2878,175 @@ void ImGuiFullscreen::SetTheme(bool light)
UISecondaryWeakColor = HEX_TO_IMVEC4(0xc0cfff, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
}
else if (theme == "AMOLED")
{
UIBackgroundColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0xf0f0f0, 0xff);
UIBackgroundHighlightColor = HEX_TO_IMVEC4(0x0c0c0c, 0xff);
UIPopupBackgroundColor = HEX_TO_IMVEC4(0x212121, 0xf2);
UIPrimaryColor = HEX_TO_IMVEC4(0x0a0a0a, 0xff);
UIPrimaryLightColor = HEX_TO_IMVEC4(0xb5b5b5, 0xff);
UIPrimaryDarkColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIPrimaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIDisabledColor = HEX_TO_IMVEC4(0x8d8d8d, 0xff);
UITextHighlightColor = HEX_TO_IMVEC4(0x676767, 0xff);
UIPrimaryLineColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UISecondaryColor = HEX_TO_IMVEC4(0x969696, 0xff);
UISecondaryStrongColor = HEX_TO_IMVEC4(0x191919, 0xff);
UISecondaryWeakColor = HEX_TO_IMVEC4(0x474747, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
}
else if (theme == "CobaltSky")
{
UIBackgroundColor = HEX_TO_IMVEC4(0x2b3760, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0xf0f0f0, 0xff);
UIBackgroundHighlightColor = HEX_TO_IMVEC4(0x3b54ac, 0xff);
UIPopupBackgroundColor = HEX_TO_IMVEC4(0x2b3760, 0xf2);
UIPrimaryColor = HEX_TO_IMVEC4(0x202e5a, 0xff);
UIPrimaryLightColor = HEX_TO_IMVEC4(0xb5b5b5, 0xff);
UIPrimaryDarkColor = HEX_TO_IMVEC4(0x222c4d, 0xff);
UIPrimaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIDisabledColor = HEX_TO_IMVEC4(0x8d8d8d, 0xff);
UITextHighlightColor = HEX_TO_IMVEC4(0x676767, 0xff);
UIPrimaryLineColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UISecondaryColor = HEX_TO_IMVEC4(0x969696, 0xff);
UISecondaryStrongColor = HEX_TO_IMVEC4(0x245dda, 0xff);
UISecondaryWeakColor = HEX_TO_IMVEC4(0x3a3d7b, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
}
else if (theme == "GreyMatter")
{
UIBackgroundColor = HEX_TO_IMVEC4(0x353944, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0xf0f0f0, 0xff);
UIBackgroundHighlightColor = HEX_TO_IMVEC4(0x484d57, 0xff);
UIPopupBackgroundColor = HEX_TO_IMVEC4(0x212121, 0xf2);
UIPrimaryColor = HEX_TO_IMVEC4(0x292d35, 0xff);
UIPrimaryLightColor = HEX_TO_IMVEC4(0xb5b5b5, 0xff);
UIPrimaryDarkColor = HEX_TO_IMVEC4(0x212121, 0xff);
UIPrimaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIDisabledColor = HEX_TO_IMVEC4(0x8d8d8d, 0xff);
UITextHighlightColor = HEX_TO_IMVEC4(0x676767, 0xff);
UIPrimaryLineColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UISecondaryColor = HEX_TO_IMVEC4(0x969696, 0xff);
UISecondaryStrongColor = HEX_TO_IMVEC4(0x191919, 0xff);
UISecondaryWeakColor = HEX_TO_IMVEC4(0x2a2e36, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
}
else if (theme == "UntouchedLagoon")
{
UIBackgroundColor = HEX_TO_IMVEC4(0x9db1bb, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0xf0f0f0, 0xff);
UIBackgroundHighlightColor = HEX_TO_IMVEC4(0x1b7f7f, 0xff);
UIPopupBackgroundColor = HEX_TO_IMVEC4(0x488c8c, 0xf2);
UIPrimaryColor = HEX_TO_IMVEC4(0xa2c2bc, 0xff);
UIPrimaryLightColor = HEX_TO_IMVEC4(0xadcfc8, 0xff);
UIPrimaryDarkColor = HEX_TO_IMVEC4(0x488c8c, 0xff);
UIPrimaryTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIDisabledColor = HEX_TO_IMVEC4(0x4b4b4b, 0xff);
UITextHighlightColor = HEX_TO_IMVEC4(0x676767, 0xff);
UIPrimaryLineColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UISecondaryColor = HEX_TO_IMVEC4(0x969696, 0xff);
UISecondaryStrongColor = HEX_TO_IMVEC4(0x2a5151, 0xff);
UISecondaryWeakColor = HEX_TO_IMVEC4(0x475055, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
}
else if (theme == "BabyPastel")
{
UIBackgroundColor = HEX_TO_IMVEC4(0xf1d9ee, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0xe05885, 0xff);
UIBackgroundHighlightColor = HEX_TO_IMVEC4(0xe05885, 0xff);
UIPopupBackgroundColor = HEX_TO_IMVEC4(0xeba0b9, 0xf2);
UIPrimaryColor = HEX_TO_IMVEC4(0xffaec9, 0xff);
UIPrimaryLightColor = HEX_TO_IMVEC4(0xe05885, 0xff);
UIPrimaryDarkColor = HEX_TO_IMVEC4(0xc3859a, 0xff);
UIPrimaryTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIDisabledColor = HEX_TO_IMVEC4(0x4b4b4b, 0xff);
UITextHighlightColor = HEX_TO_IMVEC4(0xeba0b9, 0xff);
UIPrimaryLineColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UISecondaryColor = HEX_TO_IMVEC4(0xe05885, 0xff);
UISecondaryStrongColor = HEX_TO_IMVEC4(0xdc6c68, 0xff);
UISecondaryWeakColor = HEX_TO_IMVEC4(0xab5451, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
}
else if (theme == "PizzaBrown")
{
UIBackgroundColor = HEX_TO_IMVEC4(0xd9c9ba, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0xf0f0f0, 0xff);
UIBackgroundHighlightColor = HEX_TO_IMVEC4(0xaa5a36, 0xff);
UIPopupBackgroundColor = HEX_TO_IMVEC4(0xefad42, 0xf2);
UIPrimaryColor = HEX_TO_IMVEC4(0xe9bb93, 0xff);
UIPrimaryLightColor = HEX_TO_IMVEC4(0xf9e7ac, 0xff);
UIPrimaryDarkColor = HEX_TO_IMVEC4(0xefad42, 0xff);
UIPrimaryTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIDisabledColor = HEX_TO_IMVEC4(0x4b4b4b, 0xff);
UITextHighlightColor = HEX_TO_IMVEC4(0x676767, 0xff);
UIPrimaryLineColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UISecondaryColor = HEX_TO_IMVEC4(0x969696, 0xff);
UISecondaryStrongColor = HEX_TO_IMVEC4(0xaf1c2f, 0xff);
UISecondaryWeakColor = HEX_TO_IMVEC4(0xab5451, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
}
else if (theme == "ScarletDevil")
{
UIBackgroundColor = HEX_TO_IMVEC4(0x782c44, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0xf0f0f0, 0xff);
UIBackgroundHighlightColor = HEX_TO_IMVEC4(0xa73e5f, 0xff);
UIPopupBackgroundColor = HEX_TO_IMVEC4(0x88475d, 0xf2);
UIPrimaryColor = HEX_TO_IMVEC4(0x4f2c44, 0xff);
UIPrimaryLightColor = HEX_TO_IMVEC4(0xb5b5b5, 0xff);
UIPrimaryDarkColor = HEX_TO_IMVEC4(0x632438, 0xff);
UIPrimaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIDisabledColor = HEX_TO_IMVEC4(0x969696, 0xff);
UITextHighlightColor = HEX_TO_IMVEC4(0x676767, 0xff);
UIPrimaryLineColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UISecondaryColor = HEX_TO_IMVEC4(0x969696, 0xff);
UISecondaryStrongColor = HEX_TO_IMVEC4(0xc80000, 0xff);
UISecondaryWeakColor = HEX_TO_IMVEC4(0x8a334e, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
}
else if (theme == "VioletAngel")
{
UIBackgroundColor = HEX_TO_IMVEC4(0x6e1e7d, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0x862c9c, 0xff);
UIBackgroundHighlightColor = HEX_TO_IMVEC4(0x862c9c, 0xff);
UIPopupBackgroundColor = HEX_TO_IMVEC4(0x502657, 0xf2);
UIPrimaryColor = HEX_TO_IMVEC4(0x321846, 0xff);
UIPrimaryLightColor = HEX_TO_IMVEC4(0x9833d6, 0xff);
UIPrimaryDarkColor = HEX_TO_IMVEC4(0x70269e, 0xff);
UIPrimaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UIDisabledColor = HEX_TO_IMVEC4(0x969696, 0xff);
UITextHighlightColor = HEX_TO_IMVEC4(0x676767, 0xff);
UIPrimaryLineColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UISecondaryColor = HEX_TO_IMVEC4(0xe200cb, 0xff);
UISecondaryStrongColor = HEX_TO_IMVEC4(0xff00e6, 0xff);
UISecondaryWeakColor = HEX_TO_IMVEC4(0x561d79, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0xffffff, 0xff);
}
else if (theme == "PCSX2Blue")
{
UIBackgroundColor = HEX_TO_IMVEC4(0x819af0, 0xff);
UIBackgroundTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIBackgroundLineColor = HEX_TO_IMVEC4(0x89a5ff, 0xff);
UIBackgroundHighlightColor = HEX_TO_IMVEC4(0xfefffe, 0xff);
UIPopupBackgroundColor = HEX_TO_IMVEC4(0xb4cffe, 0xf2);
UIPrimaryColor = HEX_TO_IMVEC4(0x92b6fe, 0xff);
UIPrimaryLightColor = HEX_TO_IMVEC4(0x89a5ff, 0xff);
UIPrimaryDarkColor = HEX_TO_IMVEC4(0x7c8ef3, 0xff);
UIPrimaryTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
UIDisabledColor = HEX_TO_IMVEC4(0x4b4b4b, 0xff);
UITextHighlightColor = HEX_TO_IMVEC4(0x676767, 0xff);
UIPrimaryLineColor = HEX_TO_IMVEC4(0xffffff, 0xff);
UISecondaryColor = HEX_TO_IMVEC4(0x92b6fe, 0xff);
UISecondaryStrongColor = HEX_TO_IMVEC4(0x0c53c5, 0xff);
UISecondaryWeakColor = HEX_TO_IMVEC4(0x819af0, 0xff);
UISecondaryTextColor = HEX_TO_IMVEC4(0x000000, 0xff);
}
}
2 changes: 1 addition & 1 deletion pcsx2/ImGui/ImGuiFullscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace ImGuiFullscreen
/// Initializes, setting up any state.
bool Initialize(const char* placeholder_image_path);

void SetTheme(bool light);
void SetTheme(std::string_view theme);
void SetFonts(ImFont* standard_font, ImFont* medium_font, ImFont* large_font);
bool UpdateLayoutScale();

Expand Down

0 comments on commit 6ece112

Please sign in to comment.