[App] Misc App fixes

- Display xex filenames in title selection.
- Fixed fullscreen controller hotkeys executing from a non-UI thread.
- Fixed recent_titles_entry_amount not disabling if set to <= 0.
- Use RunTitle instead of LaunchPath which does more error checking.
This commit is contained in:
Adrian 2023-07-10 20:41:44 +01:00 committed by Radosław Gliński
parent a620397b35
commit 7c5b9372e7
3 changed files with 31 additions and 13 deletions

View File

@ -59,8 +59,8 @@ DECLARE_bool(d3d12_clear_memory_page_state);
DEFINE_bool(fullscreen, false, "Whether to launch the emulator in fullscreen.",
"Display");
DEFINE_bool(controller_hotkeys, true,
"Hotkeys for Xbox and PS controllers.", "General");
DEFINE_bool(controller_hotkeys, true, "Hotkeys for Xbox and PS controllers.",
"General");
DEFINE_string(
postprocess_antialiasing, "",
@ -1148,7 +1148,9 @@ const std::map<int, EmulatorWindow::ControllerHotKey> controller_hotkey_map = {
{X_INPUT_GAMEPAD_B | X_INPUT_GAMEPAD_GUIDE,
EmulatorWindow::ControllerHotKey(
EmulatorWindow::ButtonFunctions::ToggleLogging,
"B + Guide = Toggle between loglevel set in config and the 'Disabled' loglevel.", true, true)},
"B + Guide = Toggle between loglevel set in config and the 'Disabled' "
"loglevel.",
true, true)},
{X_INPUT_GAMEPAD_Y | X_INPUT_GAMEPAD_GUIDE,
EmulatorWindow::ControllerHotKey(
EmulatorWindow::ButtonFunctions::ToggleFullscreen,
@ -1191,7 +1193,9 @@ const std::map<int, EmulatorWindow::ControllerHotKey> controller_hotkey_map = {
{X_INPUT_GAMEPAD_BACK | X_INPUT_GAMEPAD_START,
EmulatorWindow::ControllerHotKey(
EmulatorWindow::ButtonFunctions::ToggleLogging,
"Back + Start = Toggle between loglevel set in config and the 'Disabled' loglevel.", false, false)},
"Back + Start = Toggle between loglevel set in config and the "
"'Disabled' loglevel.",
false, false)},
{X_INPUT_GAMEPAD_DPAD_DOWN,
EmulatorWindow::ControllerHotKey(
EmulatorWindow::ButtonFunctions::IncTitleSelect,
@ -1239,7 +1243,7 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
switch (button_combination.function) {
case ButtonFunctions::ToggleFullscreen:
ToggleFullscreen();
app_context().CallInUIThread([this]() { ToggleFullscreen(); });
// Extra Sleep
xe::threading::Sleep(delay);
@ -1250,7 +1254,6 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
app_context().CallInUIThread([this]() {
RunTitle(recently_launched_titles_[selected_title_index].path_to_file);
});
} break;
case ButtonFunctions::ClearMemoryPageState:
ToggleGPUSetting(gpu_cvar::ClearMemoryPageState);
@ -1305,7 +1308,7 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
}
if ((button_combination.function == ButtonFunctions::IncTitleSelect ||
button_combination.function == ButtonFunctions::DecTitleSelect) &&
button_combination.function == ButtonFunctions::DecTitleSelect) &&
recently_launched_titles_.size() > 0) {
selected_title_index = std::clamp(
selected_title_index, 0, (int)recently_launched_titles_.size() - 1);
@ -1315,10 +1318,20 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
// Titles may contain Unicode characters such as At Worlds End
// Must use ImGUI font that can render these Unicode characters
std::string title =
std::to_string(selected_title_index + 1) + ": " +
recently_launched_titles_[selected_title_index].title_name + "\n\n" +
controller_hotkey_map.find(X_INPUT_GAMEPAD_START)->second.pretty;
std::string title_name;
// Use filename if title name is empty
if (recently_launched_titles_[selected_title_index].title_name.empty()) {
title_name = recently_launched_titles_[selected_title_index]
.path_to_file.filename()
.string();
} else {
title_name = recently_launched_titles_[selected_title_index].title_name;
}
std::string title = fmt::format(
"{}: {}\n\n{}", selected_title_index + 1, title_name,
controller_hotkey_map.find(X_INPUT_GAMEPAD_START)->second.pretty);
xe::ui::ImGuiDialog::ShowMessageBox(imgui_drawer_.get(), "Title Selection",
title);
@ -1583,6 +1596,10 @@ void EmulatorWindow::LoadRecentlyLaunchedTitles() {
void EmulatorWindow::AddRecentlyLaunchedTitle(
std::filesystem::path path_to_file, std::string title_name) {
if (cvars::recent_titles_entry_amount <= 0) {
return;
}
// Check if game is already on list and pop it to front
auto entry_index = std::find_if(recently_launched_titles_.cbegin(),
recently_launched_titles_.cend(),

View File

@ -69,6 +69,7 @@ class EmulatorWindow {
void OnEmulatorInitialized();
xe::X_STATUS RunTitle(std::filesystem::path path_to_file);
void UpdateTitle();
void SetFullscreen(bool fullscreen);
void ToggleFullscreen();
@ -210,7 +211,6 @@ class EmulatorWindow {
std::string BoolToString(bool value);
void DisplayHotKeysConfig();
xe::X_STATUS RunTitle(std::filesystem::path path_to_file);
void RunPreviouslyPlayedTitle();
void FillRecentlyLaunchedTitlesMenu(xe::ui::MenuItem* recent_menu);
void LoadRecentlyLaunchedTitles();

View File

@ -615,7 +615,8 @@ void EmulatorApp::EmulatorThread() {
// Normalize the path and make absolute.
auto abs_path = std::filesystem::absolute(path);
result = app_context().CallInUIThread([this, abs_path]() { return emulator_->LaunchPath(abs_path); });
result = app_context().CallInUIThread(
[this, abs_path]() { return emulator_window_->RunTitle(abs_path); });
if (XFAILED(result)) {
xe::FatalError(fmt::format("Failed to launch target: {:08X}", result));
app_context().RequestDeferredQuit();