FullscreenUI: Make footer text background semitransparent

This commit is contained in:
Stenzek 2025-01-16 01:14:22 +10:00
parent 57f3fee28c
commit 79245b6cd6
No known key found for this signature in database
5 changed files with 61 additions and 36 deletions

View File

@ -2711,7 +2711,8 @@ void Achievements::DrawAchievementsWindow()
std::make_pair(ImGuiFullscreen::IsGamepadInputSource() ? ICON_PF_BUTTON_A : ICON_PF_ENTER,
TRANSLATE_SV("Achievements", "View Details")),
std::make_pair(ImGuiFullscreen::IsGamepadInputSource() ? ICON_PF_BUTTON_B : ICON_PF_ESC,
TRANSLATE_SV("Achievements", "Back"))});
TRANSLATE_SV("Achievements", "Back"))},
FullscreenUI::GetBackgroundAlpha());
if (close_window)
FullscreenUI::ReturnToPreviousWindow();
@ -3171,7 +3172,8 @@ void Achievements::DrawLeaderboardsWindow()
std::make_pair(ImGuiFullscreen::IsGamepadInputSource() ? ICON_PF_BUTTON_A : ICON_PF_ENTER,
TRANSLATE_SV("Achievements", "Open Leaderboard")),
std::make_pair(ImGuiFullscreen::IsGamepadInputSource() ? ICON_PF_BUTTON_B : ICON_PF_ESC,
TRANSLATE_SV("Achievements", "Back"))});
TRANSLATE_SV("Achievements", "Back"))},
FullscreenUI::GetBackgroundAlpha());
}
else
{
@ -3258,7 +3260,8 @@ void Achievements::DrawLeaderboardsWindow()
std::make_pair(ImGuiFullscreen::IsGamepadInputSource() ? ICON_PF_BUTTON_A : ICON_PF_ENTER,
TRANSLATE_SV("Achievements", "View Profile")),
std::make_pair(ImGuiFullscreen::IsGamepadInputSource() ? ICON_PF_BUTTON_B : ICON_PF_ESC,
TRANSLATE_SV("Achievements", "Back"))});
TRANSLATE_SV("Achievements", "Back"))},
FullscreenUI::GetBackgroundAlpha());
}
if (close_leaderboard_on_exit)

View File

@ -297,7 +297,6 @@ static void DrawAdvancedSettingsPage();
static void DrawPatchesOrCheatsSettingsPage(bool cheats);
static bool ShouldShowAdvancedSettings();
static float GetBackgroundAlpha();
static bool IsEditingGameSettings(SettingsInterface* bsi);
static SettingsInterface* GetEditingSettingsInterface();
static SettingsInterface* GetEditingSettingsInterface(bool game_settings);
@ -588,7 +587,7 @@ void FullscreenUI::SetStandardSelectionFooterText(bool back_instead_of_cancel)
{
SmallString text;
GetStandardSelectionFooterText(text, back_instead_of_cancel);
ImGuiFullscreen::SetFullscreenFooterText(text);
ImGuiFullscreen::SetFullscreenFooterText(text, GetBackgroundAlpha());
}
void ImGuiFullscreen::GetChoiceDialogHelpText(SmallStringBase& dest)
@ -1754,15 +1753,18 @@ void FullscreenUI::DrawLandingWindow()
std::make_pair(ICON_PF_BUTTON_X, FSUI_VSTR("Toggle Fullscreen")),
std::make_pair(ICON_PF_XBOX_DPAD_LEFT_RIGHT, FSUI_VSTR("Navigate")),
std::make_pair(ICON_PF_BUTTON_A, FSUI_VSTR("Select")),
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Exit"))});
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Exit"))},
GetBackgroundAlpha());
}
else
{
SetFullscreenFooterText(std::array{
std::make_pair(ICON_PF_F1, FSUI_VSTR("About")), std::make_pair(ICON_PF_F3, FSUI_VSTR("Resume Last Session")),
std::make_pair(ICON_PF_F11, FSUI_VSTR("Toggle Fullscreen")),
std::make_pair(ICON_PF_ARROW_LEFT ICON_PF_ARROW_RIGHT, FSUI_VSTR("Navigate")),
std::make_pair(ICON_PF_ENTER, FSUI_VSTR("Select")), std::make_pair(ICON_PF_ESC, FSUI_VSTR("Exit"))});
SetFullscreenFooterText(std::array{std::make_pair(ICON_PF_F1, FSUI_VSTR("About")),
std::make_pair(ICON_PF_F3, FSUI_VSTR("Resume Last Session")),
std::make_pair(ICON_PF_F11, FSUI_VSTR("Toggle Fullscreen")),
std::make_pair(ICON_PF_ARROW_LEFT ICON_PF_ARROW_RIGHT, FSUI_VSTR("Navigate")),
std::make_pair(ICON_PF_ENTER, FSUI_VSTR("Select")),
std::make_pair(ICON_PF_ESC, FSUI_VSTR("Exit"))},
GetBackgroundAlpha());
}
}
@ -1820,14 +1822,16 @@ void FullscreenUI::DrawStartGameWindow()
SetFullscreenFooterText(std::array{std::make_pair(ICON_PF_XBOX_DPAD_LEFT_RIGHT, FSUI_VSTR("Navigate")),
std::make_pair(ICON_PF_BUTTON_Y, FSUI_VSTR("Load Global State")),
std::make_pair(ICON_PF_BUTTON_A, FSUI_VSTR("Select")),
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Back"))});
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Back"))},
GetBackgroundAlpha());
}
else
{
SetFullscreenFooterText(std::array{std::make_pair(ICON_PF_ARROW_LEFT ICON_PF_ARROW_RIGHT, FSUI_VSTR("Navigate")),
std::make_pair(ICON_PF_F1, FSUI_VSTR("Load Global State")),
std::make_pair(ICON_PF_ENTER, FSUI_VSTR("Select")),
std::make_pair(ICON_PF_ESC, FSUI_VSTR("Back"))});
std::make_pair(ICON_PF_ESC, FSUI_VSTR("Back"))},
GetBackgroundAlpha());
}
}
@ -3527,14 +3531,16 @@ void FullscreenUI::DrawSettingsWindow()
SetFullscreenFooterText(std::array{std::make_pair(ICON_PF_XBOX_DPAD_LEFT_RIGHT, FSUI_VSTR("Change Page")),
std::make_pair(ICON_PF_XBOX_DPAD_UP_DOWN, FSUI_VSTR("Navigate")),
std::make_pair(ICON_PF_BUTTON_A, FSUI_VSTR("Select")),
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Back"))});
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Back"))},
GetBackgroundAlpha());
}
else
{
SetFullscreenFooterText(std::array{std::make_pair(ICON_PF_ARROW_LEFT ICON_PF_ARROW_RIGHT, FSUI_VSTR("Change Page")),
std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN, FSUI_VSTR("Navigate")),
std::make_pair(ICON_PF_ENTER, FSUI_VSTR("Select")),
std::make_pair(ICON_PF_ESC, FSUI_VSTR("Back"))});
std::make_pair(ICON_PF_ESC, FSUI_VSTR("Back"))},
GetBackgroundAlpha());
}
}
@ -6293,7 +6299,7 @@ void FullscreenUI::DrawPauseMenu()
ImDrawList* dl = ImGui::GetBackgroundDrawList();
const ImVec2 display_size(ImGui::GetIO().DisplaySize);
const ImU32 text_color = ImGui::GetColorU32(UIStyle.BackgroundTextColor) | IM_COL32_A_MASK;
dl->AddRectFilled(ImVec2(0.0f, 0.0f), display_size,
dl->AddRectFilled(ImVec2(0.0f, 0.0f), display_size - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT),
(ImGui::GetColorU32(UIStyle.BackgroundColor) & ~IM_COL32_A_MASK) | (200 << IM_COL32_A_SHIFT));
// title info
@ -6523,13 +6529,16 @@ void FullscreenUI::DrawPauseMenu()
{
SetFullscreenFooterText(std::array{std::make_pair(ICON_PF_XBOX_DPAD_UP_DOWN, FSUI_VSTR("Change Selection")),
std::make_pair(ICON_PF_BUTTON_A, FSUI_VSTR("Select")),
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Return To Game"))});
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Return To Game"))},
GetBackgroundAlpha());
}
else
{
SetFullscreenFooterText(std::array{
std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN, FSUI_VSTR("Change Selection")),
std::make_pair(ICON_PF_ENTER, FSUI_VSTR("Select")), std::make_pair(ICON_PF_ESC, FSUI_VSTR("Return To Game"))});
SetFullscreenFooterText(
std::array{std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN, FSUI_VSTR("Change Selection")),
std::make_pair(ICON_PF_ENTER, FSUI_VSTR("Select")),
std::make_pair(ICON_PF_ESC, FSUI_VSTR("Return To Game"))},
GetBackgroundAlpha());
}
}
@ -6986,7 +6995,8 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading)
std::array{std::make_pair(ICON_PF_XBOX_DPAD, FSUI_VSTR("Select State")),
std::make_pair(ICON_PF_BUTTON_Y, FSUI_VSTR("Delete State")),
std::make_pair(ICON_PF_BUTTON_A, is_loading ? FSUI_VSTR("Load State") : FSUI_VSTR("Save State")),
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Cancel"))});
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Cancel"))},
GetBackgroundAlpha());
}
else
{
@ -6995,7 +7005,8 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading)
FSUI_VSTR("Select State")),
std::make_pair(ICON_PF_F1, FSUI_VSTR("Delete State")),
std::make_pair(ICON_PF_ENTER, is_loading ? FSUI_VSTR("Load State") : FSUI_VSTR("Save State")),
std::make_pair(ICON_PF_ESC, FSUI_VSTR("Cancel"))});
std::make_pair(ICON_PF_ESC, FSUI_VSTR("Cancel"))},
GetBackgroundAlpha());
}
if ((!ignore_close_request && WantsToCloseMenu()) || closed)
@ -7343,16 +7354,19 @@ void FullscreenUI::DrawGameListWindow()
std::make_pair(ICON_PF_BURGER_MENU, FSUI_VSTR("Settings")),
std::make_pair(ICON_PF_BUTTON_Y, FSUI_VSTR("Launch Options")),
std::make_pair(ICON_PF_BUTTON_A, FSUI_VSTR("Start Game")),
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Back"))});
std::make_pair(ICON_PF_BUTTON_B, FSUI_VSTR("Back"))},
GetBackgroundAlpha());
}
else
{
SetFullscreenFooterText(std::array{
std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN ICON_PF_ARROW_LEFT ICON_PF_ARROW_RIGHT,
FSUI_VSTR("Select Game")),
std::make_pair(ICON_PF_F1, FSUI_VSTR("Change View")), std::make_pair(ICON_PF_F2, FSUI_VSTR("Settings")),
std::make_pair(ICON_PF_F3, FSUI_VSTR("Launch Options")), std::make_pair(ICON_PF_ENTER, FSUI_VSTR("Start Game")),
std::make_pair(ICON_PF_ESC, FSUI_VSTR("Back"))});
SetFullscreenFooterText(
std::array{
std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN ICON_PF_ARROW_LEFT ICON_PF_ARROW_RIGHT,
FSUI_VSTR("Select Game")),
std::make_pair(ICON_PF_F1, FSUI_VSTR("Change View")), std::make_pair(ICON_PF_F2, FSUI_VSTR("Settings")),
std::make_pair(ICON_PF_F3, FSUI_VSTR("Launch Options")), std::make_pair(ICON_PF_ENTER, FSUI_VSTR("Start Game")),
std::make_pair(ICON_PF_ESC, FSUI_VSTR("Back"))},
GetBackgroundAlpha());
}
}

View File

@ -40,6 +40,8 @@ void Render();
void InvalidateCoverCache();
void TimeToPrintableString(SmallStringBase* str, time_t t);
float GetBackgroundAlpha();
void OpenLoadingScreen(std::string_view image, std::string_view message, s32 progress_min = -1, s32 progress_max = -1,
s32 progress_value = -1);
void UpdateLoadingScreen(std::string_view image, std::string_view message, s32 progress_min = -1, s32 progress_max = -1,

View File

@ -124,15 +124,16 @@ struct ALIGN_TO_CACHE_LINE UIState
SmallString last_fullscreen_footer_text;
std::vector<std::pair<std::string_view, std::string_view>> fullscreen_footer_icon_mapping;
float fullscreen_text_change_time;
float fullscreen_text_alpha;
bool choice_dialog_open = false;
bool choice_dialog_checkable = false;
std::string choice_dialog_title;
ChoiceDialogOptions choice_dialog_options;
ChoiceDialogCallback choice_dialog_callback;
ImGuiID enum_choice_button_id = 0;
s32 enum_choice_button_value = 0;
bool enum_choice_button_set = false;
bool choice_dialog_open = false;
bool choice_dialog_checkable = false;
bool input_dialog_open = false;
std::string input_dialog_title;
@ -838,14 +839,16 @@ void ImGuiFullscreen::CreateFooterTextString(SmallStringBase& dest,
}
}
void ImGuiFullscreen::SetFullscreenFooterText(std::string_view text)
void ImGuiFullscreen::SetFullscreenFooterText(std::string_view text, float background_alpha)
{
s_state.fullscreen_footer_text.assign(text);
s_state.fullscreen_text_alpha = background_alpha;
}
void ImGuiFullscreen::SetFullscreenFooterText(std::span<const std::pair<const char*, std::string_view>> items)
void ImGuiFullscreen::SetFullscreenFooterText(std::span<const std::pair<const char*, std::string_view>> items, float background_alpha)
{
CreateFooterTextString(s_state.fullscreen_footer_text, items);
s_state.fullscreen_text_alpha = background_alpha;
}
void ImGuiFullscreen::SetFullscreenFooterTextIconMapping(std::span<const std::pair<const char*, const char*>> mapping)
@ -876,7 +879,7 @@ void ImGuiFullscreen::DrawFullscreenFooter()
const float height = LayoutScale(LAYOUT_FOOTER_HEIGHT);
ImDrawList* dl = ImGui::GetForegroundDrawList();
dl->AddRectFilled(ImVec2(0.0f, io.DisplaySize.y - height), io.DisplaySize, ImGui::GetColorU32(UIStyle.PrimaryColor),
dl->AddRectFilled(ImVec2(0.0f, io.DisplaySize.y - height), io.DisplaySize, ImGui::GetColorU32(ModAlpha(UIStyle.PrimaryColor, s_state.fullscreen_text_alpha)),
0.0f);
ImFont* const font = UIStyle.MediumFont;
@ -923,6 +926,9 @@ void ImGuiFullscreen::DrawFullscreenFooter()
UIStyle.PrimaryTextColor.z, 1.0f - prev_opacity)),
s_state.fullscreen_footer_text.c_str(), s_state.fullscreen_footer_text.end_ptr());
}
// for next frame
s_state.fullscreen_text_alpha = 1.0f;
}
void ImGuiFullscreen::PrerenderMenuButtonBorder()

View File

@ -194,8 +194,8 @@ void EndFullscreenWindow();
bool IsGamepadInputSource();
std::string_view GetControllerIconMapping(std::string_view icon);
void CreateFooterTextString(SmallStringBase& dest, std::span<const std::pair<const char*, std::string_view>> items);
void SetFullscreenFooterText(std::string_view text);
void SetFullscreenFooterText(std::span<const std::pair<const char*, std::string_view>> items);
void SetFullscreenFooterText(std::string_view text, float background_alpha);
void SetFullscreenFooterText(std::span<const std::pair<const char*, std::string_view>> items, float background_alpha);
void SetFullscreenFooterTextIconMapping(std::span<const std::pair<const char*, const char*>> mapping);
void DrawFullscreenFooter();