From cfb9bcbe422e02a5274b5edbefdbfc6c026f185a Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 25 May 2021 20:06:06 -0400 Subject: yuzu qt: Handle per-game configs for title id 0 Currently with programs that have a 0 title id, yuzu loads the custom configuration 0000000000000000.ini for per-game configs. This is not ideal since many homebrews share this id. Instead for these programs, we load a config that is simply the file name and `.ini` appended to it. --- src/yuzu/main.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 37ef62967..8f04575f1 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1334,7 +1334,13 @@ void GMainWindow::BootGame(const QString& filename, std::size_t program_index) { if (!(loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success)) { // Load per game settings - Config per_game_config(fmt::format("{:016X}", title_id), Config::ConfigType::PerGameConfig); + if (title_id == 0) { + Config per_game_config(Common::FS::GetFilename(filename.toStdString()), + Config::ConfigType::PerGameConfig); + } else { + Config per_game_config(fmt::format("{:016X}", title_id), + Config::ConfigType::PerGameConfig); + } } ConfigureVibration::SetAllVibrationDevices(); @@ -1795,7 +1801,8 @@ void GMainWindow::RemoveAddOnContent(u64 program_id, const QString& entry_type) tr("Successfully removed %1 installed DLC.").arg(count)); } -void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target) { +void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target, + std::string_view game_path) { const QString question = [this, target] { switch (target) { case GameListRemoveTarget::ShaderCache: @@ -1817,7 +1824,7 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ RemoveTransferableShaderCache(program_id); break; case GameListRemoveTarget::CustomConfiguration: - RemoveCustomConfiguration(program_id); + RemoveCustomConfiguration(program_id, game_path); break; } } @@ -1842,9 +1849,16 @@ void GMainWindow::RemoveTransferableShaderCache(u64 program_id) { } } -void GMainWindow::RemoveCustomConfiguration(u64 program_id) { - const auto custom_config_file_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / - "custom" / fmt::format("{:016X}.ini", program_id); +void GMainWindow::RemoveCustomConfiguration(u64 program_id, std::string_view game_path) { + std::string custom_config_file_path; + if (program_id == 0) { + custom_config_file_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / + "custom" / + fmt::format("{:s}.ini", Common::FS::GetFilename(game_path)); + } else { + custom_config_file_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / + "custom" / fmt::format("{:016X}.ini", program_id); + } if (!Common::FS::Exists(custom_config_file_path)) { QMessageBox::warning(this, tr("Error Removing Custom Configuration"), @@ -2633,7 +2647,7 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file const auto v_file = Core::GetGameFileFromPath(vfs, file_name); const auto& system = Core::System::GetInstance(); - ConfigurePerGame dialog(this, title_id); + ConfigurePerGame dialog(this, title_id, file_name); dialog.LoadFromFile(v_file); const auto result = dialog.exec(); if (result == QDialog::Accepted) { -- cgit v1.2.3 From bc38d4c81baba258ecef3a9ce9d76c4b6a4c5429 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 25 May 2021 21:39:57 -0400 Subject: yuzu qt: Restore const qualifiers This addresses review comments. Co-authored-by: LC --- src/yuzu/main.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 8f04575f1..1d63ababb 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1334,13 +1334,10 @@ void GMainWindow::BootGame(const QString& filename, std::size_t program_index) { if (!(loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success)) { // Load per game settings - if (title_id == 0) { - Config per_game_config(Common::FS::GetFilename(filename.toStdString()), - Config::ConfigType::PerGameConfig); - } else { - Config per_game_config(fmt::format("{:016X}", title_id), - Config::ConfigType::PerGameConfig); - } + const auto config_file_name = title_id == 0 + ? Common::FS::GetFilename(filename.toStdString()) + : fmt::format("{:016X}", title_id); + Config per_game_config(config_file_name, Config::ConfigType::PerGameConfig); } ConfigureVibration::SetAllVibrationDevices(); @@ -1850,15 +1847,11 @@ void GMainWindow::RemoveTransferableShaderCache(u64 program_id) { } void GMainWindow::RemoveCustomConfiguration(u64 program_id, std::string_view game_path) { - std::string custom_config_file_path; - if (program_id == 0) { - custom_config_file_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / - "custom" / - fmt::format("{:s}.ini", Common::FS::GetFilename(game_path)); - } else { - custom_config_file_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / - "custom" / fmt::format("{:016X}.ini", program_id); - } + const auto config_file_name = program_id == 0 + ? fmt::format("{:s}.ini", Common::FS::GetFilename(game_path)) + : fmt::format("{:016X}.ini", program_id); + const auto custom_config_file_path = + Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / "custom" / config_file_name; if (!Common::FS::Exists(custom_config_file_path)) { QMessageBox::warning(this, tr("Error Removing Custom Configuration"), -- cgit v1.2.3