[App] Reset dialogs on refresh

This commit is contained in:
Adrian 2024-11-25 21:10:30 +00:00 committed by Radosław Gliński
parent c71649161e
commit cfd7da696f
2 changed files with 19 additions and 4 deletions

View File

@ -1768,7 +1768,7 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
selected_title_index, 0, (int)recently_launched_titles_.size() - 1);
// Must clear dialogs to prevent stacking
imgui_drawer_.get()->ClearDialogs();
ClearDialogs();
// Titles may contain Unicode characters such as At Worlds End
// Must use ImGUI font that can render these Unicode characters
@ -1941,7 +1941,7 @@ void EmulatorWindow::DisplayHotKeysConfig() {
msg += "Controller Hotkeys: " +
xe::string_util::BoolToString(cvars::controller_hotkeys);
imgui_drawer_.get()->ClearDialogs();
ClearDialogs();
xe::ui::ImGuiDialog::ShowMessageBox(imgui_drawer_.get(), "Controller Hotkeys",
msg);
}
@ -1973,7 +1973,7 @@ xe::X_STATUS EmulatorWindow::RunTitle(
XELOGE("{}", log_msg);
imgui_drawer_.get()->ClearDialogs();
ClearDialogs();
xe::ui::ImGuiDialog::ShowMessageBox(imgui_drawer_.get(),
"Title Launch Failed!", log_msg);
@ -2020,7 +2020,7 @@ xe::X_STATUS EmulatorWindow::RunTitle(
display_config_dialog_.reset();
}
imgui_drawer_.get()->ClearDialogs();
ClearDialogs();
if (result) {
XELOGE("Failed to launch target: {:08X}", result);
@ -2148,5 +2148,18 @@ void EmulatorWindow::AddRecentlyLaunchedTitle(
file.close();
}
void EmulatorWindow::ClearDialogs() {
if (profile_config_dialog_) {
profile_config_dialog_.reset();
}
if (display_config_dialog_) {
display_config_dialog_.reset();
}
imgui_drawer_.get()->ClearDialogs();
kernel::xam::xam_dialogs_shown_ = 0;
}
} // namespace app
} // namespace xe

View File

@ -249,6 +249,8 @@ class EmulatorWindow {
void AddRecentlyLaunchedTitle(std::filesystem::path path_to_file,
std::string title_name);
void ClearDialogs();
Emulator* emulator_;
ui::WindowedAppContext& app_context_;
EmulatorWindowListener window_listener_;