diff options
| author | 2018-09-09 22:32:53 -0400 | |
|---|---|---|
| committer | 2018-09-09 22:32:53 -0400 | |
| commit | 7ddd5b765d0410cbeea1ca11f36852010a98b8b1 (patch) | |
| tree | 9190633802a21094ca7780ae8c0d0f0cd46a4095 | |
| parent | Merge pull request #1276 from FearlessTobi/fix-stupid-stub (diff) | |
| parent | game_list: Make CompatibilityList parameter of NavigateToGamedbEntryRequested... (diff) | |
| download | yuzu-7ddd5b765d0410cbeea1ca11f36852010a98b8b1.tar.gz yuzu-7ddd5b765d0410cbeea1ca11f36852010a98b8b1.tar.xz yuzu-7ddd5b765d0410cbeea1ca11f36852010a98b8b1.zip | |
Merge pull request #1282 from lioncash/compat
yuzu: Move compatibility list specifics to their own source files
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/yuzu/compatibility_list.cpp | 18 | ||||
| -rw-r--r-- | src/yuzu/compatibility_list.h | 17 | ||||
| -rw-r--r-- | src/yuzu/game_list.cpp | 1 | ||||
| -rw-r--r-- | src/yuzu/game_list.h | 10 | ||||
| -rw-r--r-- | src/yuzu/game_list_p.h | 11 | ||||
| -rw-r--r-- | src/yuzu/game_list_worker.cpp | 6 | ||||
| -rw-r--r-- | src/yuzu/game_list_worker.h | 8 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 10 | ||||
| -rw-r--r-- | src/yuzu/main.h | 6 |
10 files changed, 56 insertions, 33 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index a2b6e984e..f48b69809 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt | |||
| @@ -9,6 +9,8 @@ add_executable(yuzu | |||
| 9 | about_dialog.h | 9 | about_dialog.h |
| 10 | bootmanager.cpp | 10 | bootmanager.cpp |
| 11 | bootmanager.h | 11 | bootmanager.h |
| 12 | compatibility_list.cpp | ||
| 13 | compatibility_list.h | ||
| 12 | configuration/config.cpp | 14 | configuration/config.cpp |
| 13 | configuration/config.h | 15 | configuration/config.h |
| 14 | configuration/configure_audio.cpp | 16 | configuration/configure_audio.cpp |
diff --git a/src/yuzu/compatibility_list.cpp b/src/yuzu/compatibility_list.cpp new file mode 100644 index 000000000..2d2cfd03c --- /dev/null +++ b/src/yuzu/compatibility_list.cpp | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | // Copyright 2018 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | |||
| 7 | #include <fmt/format.h> | ||
| 8 | |||
| 9 | #include "yuzu/compatibility_list.h" | ||
| 10 | |||
| 11 | CompatibilityList::const_iterator FindMatchingCompatibilityEntry( | ||
| 12 | const CompatibilityList& compatibility_list, u64 program_id) { | ||
| 13 | return std::find_if(compatibility_list.begin(), compatibility_list.end(), | ||
| 14 | [program_id](const auto& element) { | ||
| 15 | std::string pid = fmt::format("{:016X}", program_id); | ||
| 16 | return element.first == pid; | ||
| 17 | }); | ||
| 18 | } | ||
diff --git a/src/yuzu/compatibility_list.h b/src/yuzu/compatibility_list.h new file mode 100644 index 000000000..bc0175bd3 --- /dev/null +++ b/src/yuzu/compatibility_list.h | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | // Copyright 2018 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <string> | ||
| 8 | #include <unordered_map> | ||
| 9 | |||
| 10 | #include <QString> | ||
| 11 | |||
| 12 | #include "common/common_types.h" | ||
| 13 | |||
| 14 | using CompatibilityList = std::unordered_map<std::string, std::pair<QString, QString>>; | ||
| 15 | |||
| 16 | CompatibilityList::const_iterator FindMatchingCompatibilityEntry( | ||
| 17 | const CompatibilityList& compatibility_list, u64 program_id); | ||
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 86532e4a9..8c6e16d47 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "common/file_util.h" | 19 | #include "common/file_util.h" |
| 20 | #include "common/logging/log.h" | 20 | #include "common/logging/log.h" |
| 21 | #include "core/file_sys/patch_manager.h" | 21 | #include "core/file_sys/patch_manager.h" |
| 22 | #include "yuzu/compatibility_list.h" | ||
| 22 | #include "yuzu/game_list.h" | 23 | #include "yuzu/game_list.h" |
| 23 | #include "yuzu/game_list_p.h" | 24 | #include "yuzu/game_list_p.h" |
| 24 | #include "yuzu/game_list_worker.h" | 25 | #include "yuzu/game_list_worker.h" |
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index 3fcb298ed..2713e7b54 100644 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <unordered_map> | ||
| 8 | |||
| 9 | #include <QFileSystemWatcher> | 7 | #include <QFileSystemWatcher> |
| 10 | #include <QHBoxLayout> | 8 | #include <QHBoxLayout> |
| 11 | #include <QLabel> | 9 | #include <QLabel> |
| @@ -21,6 +19,7 @@ | |||
| 21 | #include <QWidget> | 19 | #include <QWidget> |
| 22 | 20 | ||
| 23 | #include "common/common_types.h" | 21 | #include "common/common_types.h" |
| 22 | #include "yuzu/compatibility_list.h" | ||
| 24 | 23 | ||
| 25 | class GameListWorker; | 24 | class GameListWorker; |
| 26 | class GMainWindow; | 25 | class GMainWindow; |
| @@ -90,9 +89,8 @@ signals: | |||
| 90 | void GameChosen(QString game_path); | 89 | void GameChosen(QString game_path); |
| 91 | void ShouldCancelWorker(); | 90 | void ShouldCancelWorker(); |
| 92 | void OpenFolderRequested(u64 program_id, GameListOpenTarget target); | 91 | void OpenFolderRequested(u64 program_id, GameListOpenTarget target); |
| 93 | void NavigateToGamedbEntryRequested( | 92 | void NavigateToGamedbEntryRequested(u64 program_id, |
| 94 | u64 program_id, | 93 | const CompatibilityList& compatibility_list); |
| 95 | std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list); | ||
| 96 | 94 | ||
| 97 | private slots: | 95 | private slots: |
| 98 | void onTextChanged(const QString& newText); | 96 | void onTextChanged(const QString& newText); |
| @@ -114,7 +112,7 @@ private: | |||
| 114 | QStandardItemModel* item_model = nullptr; | 112 | QStandardItemModel* item_model = nullptr; |
| 115 | GameListWorker* current_worker = nullptr; | 113 | GameListWorker* current_worker = nullptr; |
| 116 | QFileSystemWatcher* watcher = nullptr; | 114 | QFileSystemWatcher* watcher = nullptr; |
| 117 | std::unordered_map<std::string, std::pair<QString, QString>> compatibility_list; | 115 | CompatibilityList compatibility_list; |
| 118 | }; | 116 | }; |
| 119 | 117 | ||
| 120 | Q_DECLARE_METATYPE(GameListOpenTarget); | 118 | Q_DECLARE_METATYPE(GameListOpenTarget); |
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 2720bf143..f22e422e5 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h | |||
| @@ -176,14 +176,3 @@ public: | |||
| 176 | return data(SizeRole).toULongLong() < other.data(SizeRole).toULongLong(); | 176 | return data(SizeRole).toULongLong() < other.data(SizeRole).toULongLong(); |
| 177 | } | 177 | } |
| 178 | }; | 178 | }; |
| 179 | |||
| 180 | inline auto FindMatchingCompatibilityEntry( | ||
| 181 | const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list, | ||
| 182 | u64 program_id) { | ||
| 183 | return std::find_if( | ||
| 184 | compatibility_list.begin(), compatibility_list.end(), | ||
| 185 | [program_id](const std::pair<std::string, std::pair<QString, QString>>& element) { | ||
| 186 | std::string pid = fmt::format("{:016X}", program_id); | ||
| 187 | return element.first == pid; | ||
| 188 | }); | ||
| 189 | } | ||
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 9f26935d6..e228d61bd 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include "core/file_sys/registered_cache.h" | 20 | #include "core/file_sys/registered_cache.h" |
| 21 | #include "core/hle/service/filesystem/filesystem.h" | 21 | #include "core/hle/service/filesystem/filesystem.h" |
| 22 | #include "core/loader/loader.h" | 22 | #include "core/loader/loader.h" |
| 23 | #include "yuzu/compatibility_list.h" | ||
| 23 | #include "yuzu/game_list.h" | 24 | #include "yuzu/game_list.h" |
| 24 | #include "yuzu/game_list_p.h" | 25 | #include "yuzu/game_list_p.h" |
| 25 | #include "yuzu/game_list_worker.h" | 26 | #include "yuzu/game_list_worker.h" |
| @@ -75,9 +76,8 @@ QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager, bool | |||
| 75 | } | 76 | } |
| 76 | } // Anonymous namespace | 77 | } // Anonymous namespace |
| 77 | 78 | ||
| 78 | GameListWorker::GameListWorker( | 79 | GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs, QString dir_path, bool deep_scan, |
| 79 | FileSys::VirtualFilesystem vfs, QString dir_path, bool deep_scan, | 80 | const CompatibilityList& compatibility_list) |
| 80 | const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list) | ||
| 81 | : vfs(std::move(vfs)), dir_path(std::move(dir_path)), deep_scan(deep_scan), | 81 | : vfs(std::move(vfs)), dir_path(std::move(dir_path)), deep_scan(deep_scan), |
| 82 | compatibility_list(compatibility_list) {} | 82 | compatibility_list(compatibility_list) {} |
| 83 | 83 | ||
diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.h index 42c93fc31..09d20c42f 100644 --- a/src/yuzu/game_list_worker.h +++ b/src/yuzu/game_list_worker.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <QString> | 16 | #include <QString> |
| 17 | 17 | ||
| 18 | #include "common/common_types.h" | 18 | #include "common/common_types.h" |
| 19 | #include "yuzu/compatibility_list.h" | ||
| 19 | 20 | ||
| 20 | class QStandardItem; | 21 | class QStandardItem; |
| 21 | 22 | ||
| @@ -32,9 +33,8 @@ class GameListWorker : public QObject, public QRunnable { | |||
| 32 | Q_OBJECT | 33 | Q_OBJECT |
| 33 | 34 | ||
| 34 | public: | 35 | public: |
| 35 | GameListWorker( | 36 | GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs, QString dir_path, bool deep_scan, |
| 36 | std::shared_ptr<FileSys::VfsFilesystem> vfs, QString dir_path, bool deep_scan, | 37 | const CompatibilityList& compatibility_list); |
| 37 | const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list); | ||
| 38 | ~GameListWorker() override; | 38 | ~GameListWorker() override; |
| 39 | 39 | ||
| 40 | /// Starts the processing of directory tree information. | 40 | /// Starts the processing of directory tree information. |
| @@ -67,6 +67,6 @@ private: | |||
| 67 | QStringList watch_list; | 67 | QStringList watch_list; |
| 68 | QString dir_path; | 68 | QString dir_path; |
| 69 | bool deep_scan; | 69 | bool deep_scan; |
| 70 | const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list; | 70 | const CompatibilityList& compatibility_list; |
| 71 | std::atomic_bool stop_processing; | 71 | std::atomic_bool stop_processing; |
| 72 | }; | 72 | }; |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 811e7cd3f..e36914f14 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -47,6 +47,7 @@ | |||
| 47 | #include "video_core/debug_utils/debug_utils.h" | 47 | #include "video_core/debug_utils/debug_utils.h" |
| 48 | #include "yuzu/about_dialog.h" | 48 | #include "yuzu/about_dialog.h" |
| 49 | #include "yuzu/bootmanager.h" | 49 | #include "yuzu/bootmanager.h" |
| 50 | #include "yuzu/compatibility_list.h" | ||
| 50 | #include "yuzu/configuration/config.h" | 51 | #include "yuzu/configuration/config.h" |
| 51 | #include "yuzu/configuration/configure_dialog.h" | 52 | #include "yuzu/configuration/configure_dialog.h" |
| 52 | #include "yuzu/debugger/console.h" | 53 | #include "yuzu/debugger/console.h" |
| @@ -725,14 +726,11 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 725 | QDesktopServices::openUrl(QUrl::fromLocalFile(qpath)); | 726 | QDesktopServices::openUrl(QUrl::fromLocalFile(qpath)); |
| 726 | } | 727 | } |
| 727 | 728 | ||
| 728 | void GMainWindow::OnGameListNavigateToGamedbEntry( | 729 | void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, |
| 729 | u64 program_id, | 730 | const CompatibilityList& compatibility_list) { |
| 730 | std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list) { | 731 | const auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); |
| 731 | |||
| 732 | auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); | ||
| 733 | 732 | ||
| 734 | QString directory; | 733 | QString directory; |
| 735 | |||
| 736 | if (it != compatibility_list.end()) | 734 | if (it != compatibility_list.end()) |
| 737 | directory = it->second.second; | 735 | directory = it->second.second; |
| 738 | 736 | ||
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 089ea2445..552e3e61c 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "core/core.h" | 14 | #include "core/core.h" |
| 15 | #include "ui_main.h" | 15 | #include "ui_main.h" |
| 16 | #include "yuzu/compatibility_list.h" | ||
| 16 | #include "yuzu/hotkeys.h" | 17 | #include "yuzu/hotkeys.h" |
| 17 | 18 | ||
| 18 | class Config; | 19 | class Config; |
| @@ -137,9 +138,8 @@ private slots: | |||
| 137 | /// Called whenever a user selects a game in the game list widget. | 138 | /// Called whenever a user selects a game in the game list widget. |
| 138 | void OnGameListLoadFile(QString game_path); | 139 | void OnGameListLoadFile(QString game_path); |
| 139 | void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target); | 140 | void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target); |
| 140 | void OnGameListNavigateToGamedbEntry( | 141 | void OnGameListNavigateToGamedbEntry(u64 program_id, |
| 141 | u64 program_id, | 142 | const CompatibilityList& compatibility_list); |
| 142 | std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list); | ||
| 143 | void OnMenuLoadFile(); | 143 | void OnMenuLoadFile(); |
| 144 | void OnMenuLoadFolder(); | 144 | void OnMenuLoadFolder(); |
| 145 | void OnMenuInstallToNAND(); | 145 | void OnMenuInstallToNAND(); |