From f25d6ebc45dc02904ef3ca6ad8efea9a0853d194 Mon Sep 17 00:00:00 2001 From: MonsterDruide1 <5958456@gmail.com> Date: Fri, 18 Jun 2021 16:20:10 +0200 Subject: [PATCH] settings: File selector & other settings First of all, TASing requires a script to play back. The user can select the parent directory at `System -> Filesystem`, next to an option to pause TAS during loads: This requires a "hacky" setup deeper in the code and will be added in the last commit. Also, Hotkeys are being introduced: CTRL+F5 for playback start/stop, CTRL+F6 for re-reading the script and CTRL+F7 for recording a new script. --- src/common/fs/path_util.cpp | 2 + src/common/fs/path_util.h | 2 + src/common/settings.h | 3 ++ src/yuzu/configuration/config.cpp | 24 ++++++++- src/yuzu/configuration/config.h | 2 +- .../configuration/configure_filesystem.cpp | 10 ++++ src/yuzu/configuration/configure_filesystem.h | 1 + .../configuration/configure_filesystem.ui | 49 +++++++++++++++++++ src/yuzu/main.cpp | 13 +++++ 9 files changed, 104 insertions(+), 2 deletions(-) diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index 6cdd14f13..5f76adedb 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp @@ -116,6 +116,8 @@ private: GenerateYuzuPath(YuzuPath::ScreenshotsDir, yuzu_path / SCREENSHOTS_DIR); GenerateYuzuPath(YuzuPath::SDMCDir, yuzu_path / SDMC_DIR); GenerateYuzuPath(YuzuPath::ShaderDir, yuzu_path / SHADER_DIR); + + GenerateYuzuPath(YuzuPath::TASFile, fs::path{""}); } ~PathManagerImpl() = default; diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h index f956ac9a2..6079de4c6 100644 --- a/src/common/fs/path_util.h +++ b/src/common/fs/path_util.h @@ -23,6 +23,8 @@ enum class YuzuPath { ScreenshotsDir, // Where yuzu screenshots are stored. SDMCDir, // Where the emulated SDMC is stored. ShaderDir, // Where shaders are stored. + + TASFile, // Where the current script file is stored. }; /** diff --git a/src/common/settings.h b/src/common/settings.h index 29b888f10..884ea55f8 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -550,6 +550,9 @@ struct Values { BasicSetting gamecard_current_game{false, "gamecard_current_game"}; BasicSetting gamecard_path{std::string(), "gamecard_path"}; + // TAS + bool pauseTasOnLoad; + // Debugging bool record_frame_times; BasicSetting use_gdbstub{false, "use_gdbstub"}; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 952e96769..99e318a8f 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -221,7 +221,7 @@ const std::array Config::default // This must be in alphabetical order according to action name as it must have the same order as // UISetting::values.shortcuts, which is alphabetically ordered. // clang-format off -const std::array Config::default_hotkeys{{ +const std::array Config::default_hotkeys{{ {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::WidgetWithChildrenShortcut}}, {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::ApplicationShortcut}}, {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}}, @@ -235,6 +235,9 @@ const std::array Config::default_hotkeys{{ {QStringLiteral("Mute Audio"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), Qt::WindowShortcut}}, {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}}, {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}}, + {QStringLiteral("TAS Start/Stop"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F5"), Qt::ApplicationShortcut}}, + {QStringLiteral("TAS Reset"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F6"), Qt::ApplicationShortcut}}, + {QStringLiteral("TAS Record"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F7"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}}, {QStringLiteral("Toggle Framerate Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+U"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F9"), Qt::ApplicationShortcut}}, @@ -564,6 +567,9 @@ void Config::ReadControlValues() { Settings::values.mouse_panning = false; ReadBasicSetting(Settings::values.mouse_panning_sensitivity); + ReadBasicSetting(Settings::values.tas_enable = false); + ReadBasicSetting(Settings::values.tas_reset = false); + ReadGlobalSetting(Settings::values.use_docked_mode); // Disable docked mode if handheld is selected @@ -661,9 +667,20 @@ void Config::ReadDataStorageValues() { QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))) .toString() .toStdString()); + FS::SetYuzuPath( + FS::YuzuPath::TASFile, + qt_config + ->value(QStringLiteral("tas_path"), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::TASFile))) + .toString() + .toStdString()); + + ReadBasicSetting(Settings::values.pauseTasOnLoad); + ReadBasicSetting(Settings::values.gamecard_inserted); ReadBasicSetting(Settings::values.gamecard_current_game); ReadBasicSetting(Settings::values.gamecard_path); + qt_config->endGroup(); } @@ -1215,6 +1232,11 @@ void Config::SaveDataStorageValues() { WriteSetting(QStringLiteral("dump_directory"), QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)), QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))); + WriteSetting(QStringLiteral("tas_path"), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::TASFile)), + QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::TASFile))); + WriteSetting(QStringLiteral("tas_pause_on_load"), Settings::values.pauseTasOnLoad, true); + WriteBasicSetting(Settings::values.gamecard_inserted); WriteBasicSetting(Settings::values.gamecard_current_game); WriteBasicSetting(Settings::values.gamecard_path); diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 4733227b6..3ee694e7c 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -42,7 +42,7 @@ public: default_mouse_buttons; static const std::array default_keyboard_keys; static const std::array default_keyboard_mods; - static const std::array default_hotkeys; + static const std::array default_hotkeys; private: void Initialize(const std::string& config_name); diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp index 9cb317822..cd9ba0a90 100644 --- a/src/yuzu/configuration/configure_filesystem.cpp +++ b/src/yuzu/configuration/configure_filesystem.cpp @@ -26,6 +26,8 @@ ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) [this] { SetDirectory(DirectoryTarget::Dump, ui->dump_path_edit); }); connect(ui->load_path_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::Load, ui->load_path_edit); }); + connect(ui->tas_path_button, &QToolButton::pressed, this, + [this] { SetDirectory(DirectoryTarget::TAS, ui->tas_path_edit); }); connect(ui->reset_game_list_cache, &QPushButton::pressed, this, &ConfigureFilesystem::ResetMetadata); @@ -49,9 +51,12 @@ void ConfigureFilesystem::setConfiguration() { QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::DumpDir))); ui->load_path_edit->setText( QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LoadDir))); + ui->tas_path_edit->setText( + QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::TASFile))); ui->gamecard_inserted->setChecked(Settings::values.gamecard_inserted.GetValue()); ui->gamecard_current_game->setChecked(Settings::values.gamecard_current_game.GetValue()); + ui->tas_pause_on_load->setChecked(Settings::values.pauseTasOnLoad); ui->dump_exefs->setChecked(Settings::values.dump_exefs.GetValue()); ui->dump_nso->setChecked(Settings::values.dump_nso.GetValue()); @@ -69,9 +74,11 @@ void ConfigureFilesystem::applyConfiguration() { ui->dump_path_edit->text().toStdString()); Common::FS::SetYuzuPath(Common::FS::YuzuPath::LoadDir, ui->load_path_edit->text().toStdString()); + Common::FS::SetYuzuPath(Common::FS::YuzuPath::TASFile, ui->tas_path_edit->text().toStdString()); Settings::values.gamecard_inserted = ui->gamecard_inserted->isChecked(); Settings::values.gamecard_current_game = ui->gamecard_current_game->isChecked(); + Settings::values.pauseTasOnLoad = ui->tas_pause_on_load->isChecked(); Settings::values.dump_exefs = ui->dump_exefs->isChecked(); Settings::values.dump_nso = ui->dump_nso->isChecked(); @@ -97,6 +104,9 @@ void ConfigureFilesystem::SetDirectory(DirectoryTarget target, QLineEdit* edit) case DirectoryTarget::Load: caption = tr("Select Mod Load Directory..."); break; + case DirectoryTarget::TAS: + caption = tr("Select TAS Directory..."); + break; } QString str; diff --git a/src/yuzu/configuration/configure_filesystem.h b/src/yuzu/configuration/configure_filesystem.h index 2147cd405..86dab8684 100644 --- a/src/yuzu/configuration/configure_filesystem.h +++ b/src/yuzu/configuration/configure_filesystem.h @@ -32,6 +32,7 @@ private: Gamecard, Dump, Load, + TAS, }; void SetDirectory(DirectoryTarget target, QLineEdit* edit); diff --git a/src/yuzu/configuration/configure_filesystem.ui b/src/yuzu/configuration/configure_filesystem.ui index 62b9abc7a..8ac7250fd 100644 --- a/src/yuzu/configuration/configure_filesystem.ui +++ b/src/yuzu/configuration/configure_filesystem.ui @@ -219,6 +219,55 @@ + + + + TAS Directories + + + + + + Path + + + + + + + ... + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 60 + 20 + + + + + + + + Pause TAS execution during loads (SMO - 1.3) + + + + + + diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 22489231b..f3529d151 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1015,6 +1015,19 @@ void GMainWindow::InitializeHotkeys() { render_window->setAttribute(Qt::WA_Hover, true); } }); + connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Start/Stop"), this), + &QShortcut::activated, this, [&] { + Settings::values.tas_enable = !Settings::values.tas_enable; + LOG_INFO(Frontend, "Tas enabled {}", Settings::values.tas_enable); + }); + + connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Reset"), this), + &QShortcut::activated, this, [&] { Settings::values.tas_reset = true; }); + connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Record"), this), + &QShortcut::activated, this, [&] { + Settings::values.tas_record = !Settings::values.tas_record; + LOG_INFO(Frontend, "Tas recording {}", Settings::values.tas_record); + }); } void GMainWindow::SetDefaultUIGeometry() {