diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index a2b6e984ee2aec932ba5d1f4066640f542d8f92b..f48b69809b202e08612cd719e1332d406521a1eb 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -9,6 +9,8 @@ add_executable(yuzu about_dialog.h bootmanager.cpp bootmanager.h + compatibility_list.cpp + compatibility_list.h configuration/config.cpp configuration/config.h configuration/configure_audio.cpp diff --git a/src/yuzu/compatibility_list.cpp b/src/yuzu/compatibility_list.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2d2cfd03cd127b34aef9facafbb749760dc03f53 --- /dev/null +++ b/src/yuzu/compatibility_list.cpp @@ -0,0 +1,18 @@ +// Copyright 2018 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <algorithm> + +#include <fmt/format.h> + +#include "yuzu/compatibility_list.h" + +CompatibilityList::const_iterator FindMatchingCompatibilityEntry( + const CompatibilityList& compatibility_list, u64 program_id) { + return std::find_if(compatibility_list.begin(), compatibility_list.end(), + [program_id](const auto& element) { + std::string pid = fmt::format("{:016X}", program_id); + return element.first == pid; + }); +} diff --git a/src/yuzu/compatibility_list.h b/src/yuzu/compatibility_list.h new file mode 100644 index 0000000000000000000000000000000000000000..bc0175bd3cf6df05e4bdf1a6915068517e2cd924 --- /dev/null +++ b/src/yuzu/compatibility_list.h @@ -0,0 +1,17 @@ +// Copyright 2018 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <string> +#include <unordered_map> + +#include <QString> + +#include "common/common_types.h" + +using CompatibilityList = std::unordered_map<std::string, std::pair<QString, QString>>; + +CompatibilityList::const_iterator FindMatchingCompatibilityEntry( + const CompatibilityList& compatibility_list, u64 program_id); diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 86532e4a946bcb2940d6d544146e54864df1355f..8c6e16d47034f86e56d47f8b5fa4ae64fdf0a180 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -19,6 +19,7 @@ #include "common/file_util.h" #include "common/logging/log.h" #include "core/file_sys/patch_manager.h" +#include "yuzu/compatibility_list.h" #include "yuzu/game_list.h" #include "yuzu/game_list_p.h" #include "yuzu/game_list_worker.h" diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index 3fcb298ed15f2855740503ad9fad2ef06b2a0336..2713e7b5445247a14fc8003a6fb4466e0461825f 100644 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h @@ -4,8 +4,6 @@ #pragma once -#include <unordered_map> - #include <QFileSystemWatcher> #include <QHBoxLayout> #include <QLabel> @@ -21,6 +19,7 @@ #include <QWidget> #include "common/common_types.h" +#include "yuzu/compatibility_list.h" class GameListWorker; class GMainWindow; @@ -90,9 +89,8 @@ signals: void GameChosen(QString game_path); void ShouldCancelWorker(); void OpenFolderRequested(u64 program_id, GameListOpenTarget target); - void NavigateToGamedbEntryRequested( - u64 program_id, - std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list); + void NavigateToGamedbEntryRequested(u64 program_id, + const CompatibilityList& compatibility_list); private slots: void onTextChanged(const QString& newText); @@ -114,7 +112,7 @@ private: QStandardItemModel* item_model = nullptr; GameListWorker* current_worker = nullptr; QFileSystemWatcher* watcher = nullptr; - std::unordered_map<std::string, std::pair<QString, QString>> compatibility_list; + CompatibilityList compatibility_list; }; Q_DECLARE_METATYPE(GameListOpenTarget); diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 2720bf143e4052791cd22aac7e1d9013e788b76d..f22e422e586bd4bd87a421935100bca9127a5443 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h @@ -176,14 +176,3 @@ public: return data(SizeRole).toULongLong() < other.data(SizeRole).toULongLong(); } }; - -inline auto FindMatchingCompatibilityEntry( - const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list, - u64 program_id) { - return std::find_if( - compatibility_list.begin(), compatibility_list.end(), - [program_id](const std::pair<std::string, std::pair<QString, QString>>& element) { - std::string pid = fmt::format("{:016X}", program_id); - return element.first == pid; - }); -} diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 9f26935d689e526fd0ac313736ee19f29e8c67f7..e228d61bd74cc1d4f0e0924f555d36b6bc47a05a 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp @@ -20,6 +20,7 @@ #include "core/file_sys/registered_cache.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/loader/loader.h" +#include "yuzu/compatibility_list.h" #include "yuzu/game_list.h" #include "yuzu/game_list_p.h" #include "yuzu/game_list_worker.h" @@ -75,9 +76,8 @@ QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager, bool } } // Anonymous namespace -GameListWorker::GameListWorker( - FileSys::VirtualFilesystem vfs, QString dir_path, bool deep_scan, - const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list) +GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs, QString dir_path, bool deep_scan, + const CompatibilityList& compatibility_list) : vfs(std::move(vfs)), dir_path(std::move(dir_path)), deep_scan(deep_scan), compatibility_list(compatibility_list) {} diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.h index 42c93fc31e95051589fbd87c4b57867ee1305e66..09d20c42fc6ec0a9c27b4816c9d855da706ff41c 100644 --- a/src/yuzu/game_list_worker.h +++ b/src/yuzu/game_list_worker.h @@ -16,6 +16,7 @@ #include <QString> #include "common/common_types.h" +#include "yuzu/compatibility_list.h" class QStandardItem; @@ -32,9 +33,8 @@ class GameListWorker : public QObject, public QRunnable { Q_OBJECT public: - GameListWorker( - std::shared_ptr<FileSys::VfsFilesystem> vfs, QString dir_path, bool deep_scan, - const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list); + GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs, QString dir_path, bool deep_scan, + const CompatibilityList& compatibility_list); ~GameListWorker() override; /// Starts the processing of directory tree information. @@ -67,6 +67,6 @@ private: QStringList watch_list; QString dir_path; bool deep_scan; - const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list; + const CompatibilityList& compatibility_list; std::atomic_bool stop_processing; }; diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 811e7cd3fe63dcc92ceb9bf8380c18689394518d..e36914f14e466c37131cde624db44d87bc6ccd31 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -47,6 +47,7 @@ #include "video_core/debug_utils/debug_utils.h" #include "yuzu/about_dialog.h" #include "yuzu/bootmanager.h" +#include "yuzu/compatibility_list.h" #include "yuzu/configuration/config.h" #include "yuzu/configuration/configure_dialog.h" #include "yuzu/debugger/console.h" @@ -725,14 +726,11 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target QDesktopServices::openUrl(QUrl::fromLocalFile(qpath)); } -void GMainWindow::OnGameListNavigateToGamedbEntry( - u64 program_id, - std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list) { - - auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); +void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, + const CompatibilityList& compatibility_list) { + const auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); QString directory; - if (it != compatibility_list.end()) directory = it->second.second; diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 089ea2445111d85f96576116c4c4f17764975b28..552e3e61c39ec2d6f728b0ea07815a7185d35466 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -13,6 +13,7 @@ #include "common/common_types.h" #include "core/core.h" #include "ui_main.h" +#include "yuzu/compatibility_list.h" #include "yuzu/hotkeys.h" class Config; @@ -137,9 +138,8 @@ private slots: /// Called whenever a user selects a game in the game list widget. void OnGameListLoadFile(QString game_path); void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target); - void OnGameListNavigateToGamedbEntry( - u64 program_id, - std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list); + void OnGameListNavigateToGamedbEntry(u64 program_id, + const CompatibilityList& compatibility_list); void OnMenuLoadFile(); void OnMenuLoadFolder(); void OnMenuInstallToNAND();