summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar lat9nq2021-05-25 20:06:06 -0400
committerGravatar lat9nq2021-05-25 20:10:41 -0400
commitcfb9bcbe422e02a5274b5edbefdbfc6c026f185a (patch)
treed16b8f9414ebe503cd757b3fe2f1f37683ca6bab
parentcommon: fs: Rework the Common Filesystem interface to make use of std::filesy... (diff)
downloadyuzu-cfb9bcbe422e02a5274b5edbefdbfc6c026f185a.tar.gz
yuzu-cfb9bcbe422e02a5274b5edbefdbfc6c026f185a.tar.xz
yuzu-cfb9bcbe422e02a5274b5edbefdbfc6c026f185a.zip
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.
-rw-r--r--src/yuzu/configuration/config.cpp4
-rw-r--r--src/yuzu/configuration/config.h4
-rw-r--r--src/yuzu/configuration/configure_per_game.cpp13
-rw-r--r--src/yuzu/configuration/configure_per_game.h3
-rw-r--r--src/yuzu/game_list.cpp8
-rw-r--r--src/yuzu/game_list.h3
-rw-r--r--src/yuzu/main.cpp28
-rw-r--r--src/yuzu/main.h5
8 files changed, 46 insertions, 22 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index eb58bfa5b..552454acf 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -16,7 +16,7 @@
16 16
17namespace FS = Common::FS; 17namespace FS = Common::FS;
18 18
19Config::Config(const std::string& config_name, ConfigType config_type) : type(config_type) { 19Config::Config(std::string_view config_name, ConfigType config_type) : type(config_type) {
20 global = config_type == ConfigType::GlobalConfig; 20 global = config_type == ConfigType::GlobalConfig;
21 21
22 Initialize(config_name); 22 Initialize(config_name);
@@ -242,7 +242,7 @@ const std::array<UISettings::Shortcut, 17> Config::default_hotkeys{{
242}}; 242}};
243// clang-format on 243// clang-format on
244 244
245void Config::Initialize(const std::string& config_name) { 245void Config::Initialize(std::string_view config_name) {
246 const auto fs_config_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir); 246 const auto fs_config_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir);
247 const auto config_file = fmt::format("{}.ini", config_name); 247 const auto config_file = fmt::format("{}.ini", config_name);
248 248
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h
index ce3355588..114a2eaa7 100644
--- a/src/yuzu/configuration/config.h
+++ b/src/yuzu/configuration/config.h
@@ -22,7 +22,7 @@ public:
22 InputProfile, 22 InputProfile,
23 }; 23 };
24 24
25 explicit Config(const std::string& config_name = "qt-config", 25 explicit Config(std::string_view config_name = "qt-config",
26 ConfigType config_type = ConfigType::GlobalConfig); 26 ConfigType config_type = ConfigType::GlobalConfig);
27 ~Config(); 27 ~Config();
28 28
@@ -45,7 +45,7 @@ public:
45 static const std::array<UISettings::Shortcut, 17> default_hotkeys; 45 static const std::array<UISettings::Shortcut, 17> default_hotkeys;
46 46
47private: 47private:
48 void Initialize(const std::string& config_name); 48 void Initialize(std::string_view config_name);
49 49
50 void ReadValues(); 50 void ReadValues();
51 void ReadPlayerValue(std::size_t player_index); 51 void ReadPlayerValue(std::size_t player_index);
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp
index 3e13bd438..a7b7698f2 100644
--- a/src/yuzu/configuration/configure_per_game.cpp
+++ b/src/yuzu/configuration/configure_per_game.cpp
@@ -4,6 +4,7 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include <memory> 6#include <memory>
7#include <string>
7#include <utility> 8#include <utility>
8 9
9#include <QCheckBox> 10#include <QCheckBox>
@@ -14,6 +15,7 @@
14#include <QTimer> 15#include <QTimer>
15#include <QTreeView> 16#include <QTreeView>
16 17
18#include "common/fs/path_util.h"
17#include "core/core.h" 19#include "core/core.h"
18#include "core/file_sys/control_metadata.h" 20#include "core/file_sys/control_metadata.h"
19#include "core/file_sys/patch_manager.h" 21#include "core/file_sys/patch_manager.h"
@@ -26,10 +28,15 @@
26#include "yuzu/uisettings.h" 28#include "yuzu/uisettings.h"
27#include "yuzu/util/util.h" 29#include "yuzu/util/util.h"
28 30
29ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id) 31ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id, std::string_view file_name)
30 : QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()), title_id(title_id) { 32 : QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()), title_id(title_id) {
31 game_config = std::make_unique<Config>(fmt::format("{:016X}", title_id), 33 if (title_id == 0) {
32 Config::ConfigType::PerGameConfig); 34 game_config = std::make_unique<Config>(Common::FS::GetFilename(file_name),
35 Config::ConfigType::PerGameConfig);
36 } else {
37 game_config = std::make_unique<Config>(fmt::format("{:016X}", title_id),
38 Config::ConfigType::PerGameConfig);
39 }
33 40
34 Settings::SetConfiguringGlobal(false); 41 Settings::SetConfiguringGlobal(false);
35 42
diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h
index 5f9a08cef..d86749a0e 100644
--- a/src/yuzu/configuration/configure_per_game.h
+++ b/src/yuzu/configuration/configure_per_game.h
@@ -5,6 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <string>
8#include <vector> 9#include <vector>
9 10
10#include <QDialog> 11#include <QDialog>
@@ -27,7 +28,7 @@ class ConfigurePerGame : public QDialog {
27 Q_OBJECT 28 Q_OBJECT
28 29
29public: 30public:
30 explicit ConfigurePerGame(QWidget* parent, u64 title_id); 31 explicit ConfigurePerGame(QWidget* parent, u64 title_id, std::string_view file_name);
31 ~ConfigurePerGame() override; 32 ~ConfigurePerGame() override;
32 33
33 /// Save all button configurations to settings file 34 /// Save all button configurations to settings file
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 63cf82f7d..aa3bd5e34 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -561,11 +561,11 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri
561 connect(remove_dlc, &QAction::triggered, [this, program_id]() { 561 connect(remove_dlc, &QAction::triggered, [this, program_id]() {
562 emit RemoveInstalledEntryRequested(program_id, InstalledEntryType::AddOnContent); 562 emit RemoveInstalledEntryRequested(program_id, InstalledEntryType::AddOnContent);
563 }); 563 });
564 connect(remove_shader_cache, &QAction::triggered, [this, program_id]() { 564 connect(remove_shader_cache, &QAction::triggered, [this, program_id, path]() {
565 emit RemoveFileRequested(program_id, GameListRemoveTarget::ShaderCache); 565 emit RemoveFileRequested(program_id, GameListRemoveTarget::ShaderCache, path);
566 }); 566 });
567 connect(remove_custom_config, &QAction::triggered, [this, program_id]() { 567 connect(remove_custom_config, &QAction::triggered, [this, program_id, path]() {
568 emit RemoveFileRequested(program_id, GameListRemoveTarget::CustomConfiguration); 568 emit RemoveFileRequested(program_id, GameListRemoveTarget::CustomConfiguration, path);
569 }); 569 });
570 connect(dump_romfs, &QAction::triggered, 570 connect(dump_romfs, &QAction::triggered,
571 [this, program_id, path]() { emit DumpRomFSRequested(program_id, path); }); 571 [this, program_id, path]() { emit DumpRomFSRequested(program_id, path); });
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h
index 9c0a1a482..2867f6653 100644
--- a/src/yuzu/game_list.h
+++ b/src/yuzu/game_list.h
@@ -88,7 +88,8 @@ signals:
88 const std::string& game_path); 88 const std::string& game_path);
89 void OpenTransferableShaderCacheRequested(u64 program_id); 89 void OpenTransferableShaderCacheRequested(u64 program_id);
90 void RemoveInstalledEntryRequested(u64 program_id, InstalledEntryType type); 90 void RemoveInstalledEntryRequested(u64 program_id, InstalledEntryType type);
91 void RemoveFileRequested(u64 program_id, GameListRemoveTarget target); 91 void RemoveFileRequested(u64 program_id, GameListRemoveTarget target,
92 std::string_view game_path);
92 void DumpRomFSRequested(u64 program_id, const std::string& game_path); 93 void DumpRomFSRequested(u64 program_id, const std::string& game_path);
93 void CopyTIDRequested(u64 program_id); 94 void CopyTIDRequested(u64 program_id);
94 void NavigateToGamedbEntryRequested(u64 program_id, 95 void NavigateToGamedbEntryRequested(u64 program_id,
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) {
1334 1334
1335 if (!(loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success)) { 1335 if (!(loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success)) {
1336 // Load per game settings 1336 // Load per game settings
1337 Config per_game_config(fmt::format("{:016X}", title_id), Config::ConfigType::PerGameConfig); 1337 if (title_id == 0) {
1338 Config per_game_config(Common::FS::GetFilename(filename.toStdString()),
1339 Config::ConfigType::PerGameConfig);
1340 } else {
1341 Config per_game_config(fmt::format("{:016X}", title_id),
1342 Config::ConfigType::PerGameConfig);
1343 }
1338 } 1344 }
1339 1345
1340 ConfigureVibration::SetAllVibrationDevices(); 1346 ConfigureVibration::SetAllVibrationDevices();
@@ -1795,7 +1801,8 @@ void GMainWindow::RemoveAddOnContent(u64 program_id, const QString& entry_type)
1795 tr("Successfully removed %1 installed DLC.").arg(count)); 1801 tr("Successfully removed %1 installed DLC.").arg(count));
1796} 1802}
1797 1803
1798void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target) { 1804void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target,
1805 std::string_view game_path) {
1799 const QString question = [this, target] { 1806 const QString question = [this, target] {
1800 switch (target) { 1807 switch (target) {
1801 case GameListRemoveTarget::ShaderCache: 1808 case GameListRemoveTarget::ShaderCache:
@@ -1817,7 +1824,7 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
1817 RemoveTransferableShaderCache(program_id); 1824 RemoveTransferableShaderCache(program_id);
1818 break; 1825 break;
1819 case GameListRemoveTarget::CustomConfiguration: 1826 case GameListRemoveTarget::CustomConfiguration:
1820 RemoveCustomConfiguration(program_id); 1827 RemoveCustomConfiguration(program_id, game_path);
1821 break; 1828 break;
1822 } 1829 }
1823} 1830}
@@ -1842,9 +1849,16 @@ void GMainWindow::RemoveTransferableShaderCache(u64 program_id) {
1842 } 1849 }
1843} 1850}
1844 1851
1845void GMainWindow::RemoveCustomConfiguration(u64 program_id) { 1852void GMainWindow::RemoveCustomConfiguration(u64 program_id, std::string_view game_path) {
1846 const auto custom_config_file_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / 1853 std::string custom_config_file_path;
1847 "custom" / fmt::format("{:016X}.ini", program_id); 1854 if (program_id == 0) {
1855 custom_config_file_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) /
1856 "custom" /
1857 fmt::format("{:s}.ini", Common::FS::GetFilename(game_path));
1858 } else {
1859 custom_config_file_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) /
1860 "custom" / fmt::format("{:016X}.ini", program_id);
1861 }
1848 1862
1849 if (!Common::FS::Exists(custom_config_file_path)) { 1863 if (!Common::FS::Exists(custom_config_file_path)) {
1850 QMessageBox::warning(this, tr("Error Removing Custom Configuration"), 1864 QMessageBox::warning(this, tr("Error Removing Custom Configuration"),
@@ -2633,7 +2647,7 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file
2633 const auto v_file = Core::GetGameFileFromPath(vfs, file_name); 2647 const auto v_file = Core::GetGameFileFromPath(vfs, file_name);
2634 const auto& system = Core::System::GetInstance(); 2648 const auto& system = Core::System::GetInstance();
2635 2649
2636 ConfigurePerGame dialog(this, title_id); 2650 ConfigurePerGame dialog(this, title_id, file_name);
2637 dialog.LoadFromFile(v_file); 2651 dialog.LoadFromFile(v_file);
2638 const auto result = dialog.exec(); 2652 const auto result = dialog.exec();
2639 if (result == QDialog::Accepted) { 2653 if (result == QDialog::Accepted) {
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index b3a5033ce..135681d41 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -236,7 +236,8 @@ private slots:
236 const std::string& game_path); 236 const std::string& game_path);
237 void OnTransferableShaderCacheOpenFile(u64 program_id); 237 void OnTransferableShaderCacheOpenFile(u64 program_id);
238 void OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type); 238 void OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type);
239 void OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target); 239 void OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target,
240 std::string_view game_path);
240 void OnGameListDumpRomFS(u64 program_id, const std::string& game_path); 241 void OnGameListDumpRomFS(u64 program_id, const std::string& game_path);
241 void OnGameListCopyTID(u64 program_id); 242 void OnGameListCopyTID(u64 program_id);
242 void OnGameListNavigateToGamedbEntry(u64 program_id, 243 void OnGameListNavigateToGamedbEntry(u64 program_id,
@@ -275,7 +276,7 @@ private:
275 void RemoveUpdateContent(u64 program_id, const QString& entry_type); 276 void RemoveUpdateContent(u64 program_id, const QString& entry_type);
276 void RemoveAddOnContent(u64 program_id, const QString& entry_type); 277 void RemoveAddOnContent(u64 program_id, const QString& entry_type);
277 void RemoveTransferableShaderCache(u64 program_id); 278 void RemoveTransferableShaderCache(u64 program_id);
278 void RemoveCustomConfiguration(u64 program_id); 279 void RemoveCustomConfiguration(u64 program_id, std::string_view game_path);
279 std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); 280 std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
280 InstallResult InstallNSPXCI(const QString& filename); 281 InstallResult InstallNSPXCI(const QString& filename);
281 InstallResult InstallNCA(const QString& filename); 282 InstallResult InstallNCA(const QString& filename);