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
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;
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 std::optional<int> 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()) :
FSUI_STR("Use Global Setting"));
const SmallString value_text =
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))
ImGui::OpenPopup(title);
@ -1975,8 +1975,8 @@ void FullscreenUI::DrawFloatRangeSetting(SettingsInterface* bsi, const char* tit
const bool game_settings = IsEditingGameSettings(bsi);
const std::optional<float> 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) :
FSUI_STR("Use Global Setting"));
const SmallString value_text = value.has_value() ? SmallString::from_sprintf(format, value.value() * multiplier) :
SmallString(FSUI_VSTR("Use Global Setting"));
if (MenuButtonWithValue(title, summary, value_text.c_str(), enabled, height, font, summary_font))
ImGui::OpenPopup(title);
@ -2036,8 +2036,8 @@ void FullscreenUI::DrawFloatSpinBoxSetting(SettingsInterface* bsi, const char* t
const bool game_settings = IsEditingGameSettings(bsi);
const std::optional<float> 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) :
FSUI_STR("Use Global Setting"));
const SmallString value_text = value.has_value() ? SmallString::from_sprintf(format, value.value() * multiplier) :
SmallString(FSUI_VSTR("Use Global Setting"));
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));
const std::optional<int> bottom_value =
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"),
top_value.has_value() ? StringUtil::StdStringFromFormat(format, top_value.value()) : std::string("Default"),
right_value.has_value() ? StringUtil::StdStringFromFormat(format, right_value.value()) : std::string("Default"),
bottom_value.has_value() ? StringUtil::StdStringFromFormat(format, bottom_value.value()) : std::string("Default")));
left_value.has_value() ? TinyString::from_sprintf(format, left_value.value()) : TinyString(FSUI_VSTR("Default")),
top_value.has_value() ? TinyString::from_sprintf(format, top_value.value()) : TinyString(FSUI_VSTR("Default")),
right_value.has_value() ? TinyString::from_sprintf(format, right_value.value()) : TinyString(FSUI_VSTR("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))
ImGui::OpenPopup(title);
@ -3514,12 +3514,16 @@ void FullscreenUI::DoSaveInputProfile()
if (index < 0)
return;
CloseChoiceDialog();
if (index > 0)
{
DoSaveInputProfile(title);
CloseChoiceDialog();
}
else
{
CloseChoiceDialog();
DoSaveNewInputProfile();
}
});
}
@ -6136,6 +6140,9 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
return;
}
if (!AreAnyDialogsOpen() && WantsToCloseMenu())
ReturnToPreviousWindow();
auto game_list_lock = GameList::GetLock();
const GameList::Entry* selected_entry = nullptr;
PopulateGameListEntryList();
@ -6346,11 +6353,8 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
return;
}
if (WantsToCloseMenu())
{
if (ImGui::IsWindowFocused())
ReturnToPreviousWindow();
}
if (ImGui::IsWindowFocused() && WantsToCloseMenu())
ReturnToPreviousWindow();
ResetFocusHere();
BeginMenuButtons();
@ -6537,13 +6541,10 @@ void FullscreenUI::DrawGameListSettingsWindow()
return;
}
if (WantsToCloseMenu())
if (ImGui::IsWindowFocused() && WantsToCloseMenu())
{
if (ImGui::IsWindowFocused())
{
s_current_main_window = MainWindowType::GameList;
QueueResetFocus();
}
s_current_main_window = MainWindowType::GameList;
QueueResetFocus();
}
auto lock = Host::GetSettingsLock();
@ -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", "Encore Mode");
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 the name of the input profile you wish to create.");
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 between full screen and windowed when the window is double-clicked.");
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", "Test Unofficial Achievements");
TRANSLATE_NOOP("FullscreenUI", "Texture Dumping");

View File

@ -1488,7 +1488,7 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, s32* v
if (!visible)
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 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;
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::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f));
@ -1560,7 +1561,7 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, float*
if (!visible)
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 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;
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::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f));
@ -2127,8 +2129,9 @@ void ImGuiFullscreen::DrawFileSelector()
if (!s_file_selector_open)
return;
ImGui::SetNextWindowSize(LayoutScale(1000.0f, 680.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::SetNextWindowSize(LayoutScale(1000.0f, 650.0f));
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());
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)) *
static_cast<float>(s_choice_dialog_options.size()));
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());
bool is_open = !WantsToCloseMenu();
@ -2381,7 +2385,8 @@ void ImGuiFullscreen::DrawInputDialog()
return;
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::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();
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::PushFont(g_large_font);
@ -2557,7 +2563,7 @@ void ImGuiFullscreen::DrawMessageDialog()
if (ImGui::BeginPopupModal(win_id, &is_open, flags))
{
BeginMenuButtons();
QueueResetFocus();
ResetFocusHere();
ImGui::TextWrapped("%s", s_message_dialog_message.c_str());
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + LayoutScale(20.0f));