FullscreenUI: Various minor bug fixes

This commit is contained in:
Stenzek 2024-04-13 14:41:10 +10:00
parent 8ab1623276
commit 6258cb9e0e
No known key found for this signature in database
3 changed files with 44 additions and 37 deletions

View File

@ -342,7 +342,7 @@ private:
#endif #endif
template<u32 L> template<u32 L>
ALWAYS_INLINE SmallStackString<L> SmallStackString<L>::from_sprintf(const char* format, ...) SmallStackString<L> SmallStackString<L>::from_sprintf(const char* format, ...)
{ {
std::va_list ap; std::va_list ap;
va_start(ap, format); va_start(ap, format);

View File

@ -1917,8 +1917,8 @@ void FullscreenUI::DrawIntRangeSetting(SettingsInterface* bsi, const char* title
const bool game_settings = IsEditingGameSettings(bsi); const bool game_settings = IsEditingGameSettings(bsi);
const std::optional<int> value = const std::optional<int> value =
bsi->GetOptionalIntValue(section, key, game_settings ? std::nullopt : std::optional<int>(default_value)); bsi->GetOptionalIntValue(section, key, game_settings ? std::nullopt : std::optional<int>(default_value));
const std::string value_text(value.has_value() ? StringUtil::StdStringFromFormat(format, value.value()) : const SmallString value_text =
FSUI_STR("Use Global Setting")); value.has_value() ? SmallString::from_sprintf(format, value.value()) : SmallString(FSUI_VSTR("Use Global Setting"));
if (MenuButtonWithValue(title, summary, value_text.c_str(), enabled, height, font, summary_font)) if (MenuButtonWithValue(title, summary, value_text.c_str(), enabled, height, font, summary_font))
ImGui::OpenPopup(title); ImGui::OpenPopup(title);
@ -1975,8 +1975,8 @@ void FullscreenUI::DrawFloatRangeSetting(SettingsInterface* bsi, const char* tit
const bool game_settings = IsEditingGameSettings(bsi); const bool game_settings = IsEditingGameSettings(bsi);
const std::optional<float> value = const std::optional<float> value =
bsi->GetOptionalFloatValue(section, key, game_settings ? std::nullopt : std::optional<float>(default_value)); bsi->GetOptionalFloatValue(section, key, game_settings ? std::nullopt : std::optional<float>(default_value));
const std::string value_text(value.has_value() ? StringUtil::StdStringFromFormat(format, value.value() * multiplier) : const SmallString value_text = value.has_value() ? SmallString::from_sprintf(format, value.value() * multiplier) :
FSUI_STR("Use Global Setting")); SmallString(FSUI_VSTR("Use Global Setting"));
if (MenuButtonWithValue(title, summary, value_text.c_str(), enabled, height, font, summary_font)) if (MenuButtonWithValue(title, summary, value_text.c_str(), enabled, height, font, summary_font))
ImGui::OpenPopup(title); ImGui::OpenPopup(title);
@ -2036,8 +2036,8 @@ void FullscreenUI::DrawFloatSpinBoxSetting(SettingsInterface* bsi, const char* t
const bool game_settings = IsEditingGameSettings(bsi); const bool game_settings = IsEditingGameSettings(bsi);
const std::optional<float> value = const std::optional<float> value =
bsi->GetOptionalFloatValue(section, key, game_settings ? std::nullopt : std::optional<float>(default_value)); bsi->GetOptionalFloatValue(section, key, game_settings ? std::nullopt : std::optional<float>(default_value));
const std::string value_text(value.has_value() ? StringUtil::StdStringFromFormat(format, value.value() * multiplier) : const SmallString value_text = value.has_value() ? SmallString::from_sprintf(format, value.value() * multiplier) :
FSUI_STR("Use Global Setting")); SmallString(FSUI_VSTR("Use Global Setting"));
static bool manual_input = false; static bool manual_input = false;
@ -2174,12 +2174,12 @@ void FullscreenUI::DrawIntRectSetting(SettingsInterface* bsi, const char* title,
bsi->GetOptionalIntValue(section, right_key, game_settings ? std::nullopt : std::optional<int>(default_right)); bsi->GetOptionalIntValue(section, right_key, game_settings ? std::nullopt : std::optional<int>(default_right));
const std::optional<int> bottom_value = const std::optional<int> bottom_value =
bsi->GetOptionalIntValue(section, bottom_key, game_settings ? std::nullopt : std::optional<int>(default_bottom)); bsi->GetOptionalIntValue(section, bottom_key, game_settings ? std::nullopt : std::optional<int>(default_bottom));
const std::string value_text(fmt::format( const SmallString value_text = SmallString::from_format(
"{}/{}/{}/{}", "{}/{}/{}/{}",
left_value.has_value() ? StringUtil::StdStringFromFormat(format, left_value.value()) : std::string("Default"), left_value.has_value() ? TinyString::from_sprintf(format, left_value.value()) : TinyString(FSUI_VSTR("Default")),
top_value.has_value() ? StringUtil::StdStringFromFormat(format, top_value.value()) : std::string("Default"), top_value.has_value() ? TinyString::from_sprintf(format, top_value.value()) : TinyString(FSUI_VSTR("Default")),
right_value.has_value() ? StringUtil::StdStringFromFormat(format, right_value.value()) : std::string("Default"), right_value.has_value() ? TinyString::from_sprintf(format, right_value.value()) : TinyString(FSUI_VSTR("Default")),
bottom_value.has_value() ? StringUtil::StdStringFromFormat(format, bottom_value.value()) : std::string("Default"))); bottom_value.has_value() ? TinyString::from_sprintf(format, bottom_value.value()) : TinyString(FSUI_VSTR("Default")));
if (MenuButtonWithValue(title, summary, value_text.c_str(), enabled, height, font, summary_font)) if (MenuButtonWithValue(title, summary, value_text.c_str(), enabled, height, font, summary_font))
ImGui::OpenPopup(title); ImGui::OpenPopup(title);
@ -3514,12 +3514,16 @@ void FullscreenUI::DoSaveInputProfile()
if (index < 0) if (index < 0)
return; return;
CloseChoiceDialog();
if (index > 0) if (index > 0)
{
DoSaveInputProfile(title); DoSaveInputProfile(title);
CloseChoiceDialog();
}
else else
{
CloseChoiceDialog();
DoSaveNewInputProfile(); DoSaveNewInputProfile();
}
}); });
} }
@ -6136,6 +6140,9 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
return; return;
} }
if (!AreAnyDialogsOpen() && WantsToCloseMenu())
ReturnToPreviousWindow();
auto game_list_lock = GameList::GetLock(); auto game_list_lock = GameList::GetLock();
const GameList::Entry* selected_entry = nullptr; const GameList::Entry* selected_entry = nullptr;
PopulateGameListEntryList(); PopulateGameListEntryList();
@ -6346,11 +6353,8 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
return; return;
} }
if (WantsToCloseMenu()) if (ImGui::IsWindowFocused() && WantsToCloseMenu())
{
if (ImGui::IsWindowFocused())
ReturnToPreviousWindow(); ReturnToPreviousWindow();
}
ResetFocusHere(); ResetFocusHere();
BeginMenuButtons(); BeginMenuButtons();
@ -6537,14 +6541,11 @@ void FullscreenUI::DrawGameListSettingsWindow()
return; return;
} }
if (WantsToCloseMenu()) if (ImGui::IsWindowFocused() && WantsToCloseMenu())
{
if (ImGui::IsWindowFocused())
{ {
s_current_main_window = MainWindowType::GameList; s_current_main_window = MainWindowType::GameList;
QueueResetFocus(); QueueResetFocus();
} }
}
auto lock = Host::GetSettingsLock(); auto lock = Host::GetSettingsLock();
SettingsInterface* bsi = GetEditingSettingsInterface(false); SettingsInterface* bsi = GetEditingSettingsInterface(false);
@ -7151,7 +7152,7 @@ TRANSLATE_NOOP("FullscreenUI", "Enables more precise frame pacing at the cost of
TRANSLATE_NOOP("FullscreenUI", "Enables the replacement of background textures in supported games."); TRANSLATE_NOOP("FullscreenUI", "Enables the replacement of background textures in supported games.");
TRANSLATE_NOOP("FullscreenUI", "Encore Mode"); TRANSLATE_NOOP("FullscreenUI", "Encore Mode");
TRANSLATE_NOOP("FullscreenUI", "Enhancements"); TRANSLATE_NOOP("FullscreenUI", "Enhancements");
TRANSLATE_NOOP("FullscreenUI", "Ensures every frame generated is displayed for optimal pacing. Disable if you are having speed or sound issues."); TRANSLATE_NOOP("FullscreenUI", "Ensures every frame generated is displayed for optimal pacing. Enable for variable refresh displays, such as GSync/FreeSync. Disable if you are having speed or sound issues.");
TRANSLATE_NOOP("FullscreenUI", "Enter Value"); TRANSLATE_NOOP("FullscreenUI", "Enter Value");
TRANSLATE_NOOP("FullscreenUI", "Enter the name of the input profile you wish to create."); TRANSLATE_NOOP("FullscreenUI", "Enter the name of the input profile you wish to create.");
TRANSLATE_NOOP("FullscreenUI", "Execution Mode"); TRANSLATE_NOOP("FullscreenUI", "Execution Mode");
@ -7474,7 +7475,7 @@ TRANSLATE_NOOP("FullscreenUI", "Summary");
TRANSLATE_NOOP("FullscreenUI", "Switches back to 4:3 display aspect ratio when displaying 24-bit content, usually FMVs."); TRANSLATE_NOOP("FullscreenUI", "Switches back to 4:3 display aspect ratio when displaying 24-bit content, usually FMVs.");
TRANSLATE_NOOP("FullscreenUI", "Switches between full screen and windowed when the window is double-clicked."); TRANSLATE_NOOP("FullscreenUI", "Switches between full screen and windowed when the window is double-clicked.");
TRANSLATE_NOOP("FullscreenUI", "Sync To Host Refresh Rate"); TRANSLATE_NOOP("FullscreenUI", "Sync To Host Refresh Rate");
TRANSLATE_NOOP("FullscreenUI", "Synchronizes presentation of the console's frames to the host. Enable for smoother animations."); TRANSLATE_NOOP("FullscreenUI", "Synchronizes presentation of the console's frames to the host. GSync/FreeSync users should enable Optimal Frame Pacing instead.");
TRANSLATE_NOOP("FullscreenUI", "Temporarily disables all enhancements, useful when testing."); TRANSLATE_NOOP("FullscreenUI", "Temporarily disables all enhancements, useful when testing.");
TRANSLATE_NOOP("FullscreenUI", "Test Unofficial Achievements"); TRANSLATE_NOOP("FullscreenUI", "Test Unofficial Achievements");
TRANSLATE_NOOP("FullscreenUI", "Texture Dumping"); TRANSLATE_NOOP("FullscreenUI", "Texture Dumping");

View File

@ -1488,7 +1488,7 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, s32* v
if (!visible) if (!visible)
return false; return false;
const std::string value_text(StringUtil::StdStringFromFormat(format, *value)); const SmallString value_text = SmallString::from_sprintf(format, *value);
const ImVec2 value_size(ImGui::CalcTextSize(value_text.c_str())); const ImVec2 value_size(ImGui::CalcTextSize(value_text.c_str()));
const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f); const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f);
@ -1521,7 +1521,8 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, s32* v
bool changed = false; bool changed = false;
ImGui::SetNextWindowSize(LayoutScale(500.0f, 180.0f)); ImGui::SetNextWindowSize(LayoutScale(500.0f, 180.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowPos((ImGui::GetIO().DisplaySize - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT)) * 0.5f,
ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::PushFont(g_large_font); ImGui::PushFont(g_large_font);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f)); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f));
@ -1560,7 +1561,7 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, float*
if (!visible) if (!visible)
return false; return false;
const std::string value_text(StringUtil::StdStringFromFormat(format, *value)); const SmallString value_text = SmallString::from_sprintf(format, *value);
const ImVec2 value_size(ImGui::CalcTextSize(value_text.c_str())); const ImVec2 value_size(ImGui::CalcTextSize(value_text.c_str()));
const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f); const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f);
@ -1593,7 +1594,8 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, float*
bool changed = false; bool changed = false;
ImGui::SetNextWindowSize(LayoutScale(500.0f, 180.0f)); ImGui::SetNextWindowSize(LayoutScale(500.0f, 180.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowPos((ImGui::GetIO().DisplaySize - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT)) * 0.5f,
ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::PushFont(g_large_font); ImGui::PushFont(g_large_font);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f)); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f));
@ -2127,8 +2129,9 @@ void ImGuiFullscreen::DrawFileSelector()
if (!s_file_selector_open) if (!s_file_selector_open)
return; return;
ImGui::SetNextWindowSize(LayoutScale(1000.0f, 680.0f)); ImGui::SetNextWindowSize(LayoutScale(1000.0f, 650.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowPos((ImGui::GetIO().DisplaySize - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT)) * 0.5f,
ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::OpenPopup(s_file_selector_title.c_str()); ImGui::OpenPopup(s_file_selector_title.c_str());
FileSelectorItem* selected = nullptr; FileSelectorItem* selected = nullptr;
@ -2278,7 +2281,8 @@ void ImGuiFullscreen::DrawChoiceDialog()
title_height + LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY + (LAYOUT_MENU_BUTTON_Y_PADDING * 2.0f)) * title_height + LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY + (LAYOUT_MENU_BUTTON_Y_PADDING * 2.0f)) *
static_cast<float>(s_choice_dialog_options.size())); static_cast<float>(s_choice_dialog_options.size()));
ImGui::SetNextWindowSize(ImVec2(width, height)); ImGui::SetNextWindowSize(ImVec2(width, height));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowPos((ImGui::GetIO().DisplaySize - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT)) * 0.5f,
ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::OpenPopup(s_choice_dialog_title.c_str()); ImGui::OpenPopup(s_choice_dialog_title.c_str());
bool is_open = !WantsToCloseMenu(); bool is_open = !WantsToCloseMenu();
@ -2381,7 +2385,8 @@ void ImGuiFullscreen::DrawInputDialog()
return; return;
ImGui::SetNextWindowSize(LayoutScale(700.0f, 0.0f)); ImGui::SetNextWindowSize(LayoutScale(700.0f, 0.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowPos((ImGui::GetIO().DisplaySize - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT)) * 0.5f,
ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::OpenPopup(s_input_dialog_title.c_str()); ImGui::OpenPopup(s_input_dialog_title.c_str());
ImGui::PushFont(g_large_font); ImGui::PushFont(g_large_font);
@ -2536,7 +2541,8 @@ void ImGuiFullscreen::DrawMessageDialog()
const char* win_id = s_message_dialog_title.empty() ? "##messagedialog" : s_message_dialog_title.c_str(); const char* win_id = s_message_dialog_title.empty() ? "##messagedialog" : s_message_dialog_title.c_str();
ImGui::SetNextWindowSize(LayoutScale(700.0f, 0.0f)); ImGui::SetNextWindowSize(LayoutScale(700.0f, 0.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowPos((ImGui::GetIO().DisplaySize - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT)) * 0.5f,
ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::OpenPopup(win_id); ImGui::OpenPopup(win_id);
ImGui::PushFont(g_large_font); ImGui::PushFont(g_large_font);
@ -2557,7 +2563,7 @@ void ImGuiFullscreen::DrawMessageDialog()
if (ImGui::BeginPopupModal(win_id, &is_open, flags)) if (ImGui::BeginPopupModal(win_id, &is_open, flags))
{ {
BeginMenuButtons(); BeginMenuButtons();
QueueResetFocus(); ResetFocusHere();
ImGui::TextWrapped("%s", s_message_dialog_message.c_str()); ImGui::TextWrapped("%s", s_message_dialog_message.c_str());
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + LayoutScale(20.0f)); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + LayoutScale(20.0f));