diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index aa96a2e0d..3fb9c8433 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -14,6 +14,8 @@ add_executable(citra-qt applets/swkbd.h bootmanager.cpp bootmanager.h + compatibility_list.cpp + compatibility_list.h camera/camera_util.cpp camera/camera_util.h camera/still_image_camera.cpp diff --git a/src/citra_qt/compatibility_list.cpp b/src/citra_qt/compatibility_list.cpp new file mode 100644 index 000000000..5bf6e5648 --- /dev/null +++ b/src/citra_qt/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 + +#include + +#include "citra_qt/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/citra_qt/compatibility_list.h b/src/citra_qt/compatibility_list.h new file mode 100644 index 000000000..bc0175bd3 --- /dev/null +++ b/src/citra_qt/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 +#include + +#include + +#include "common/common_types.h" + +using CompatibilityList = std::unordered_map>; + +CompatibilityList::const_iterator FindMatchingCompatibilityEntry( + const CompatibilityList& compatibility_list, u64 program_id); diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index c16b63b86..c28878b88 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -21,6 +21,7 @@ #include #include #include +#include "citra_qt/compatibility_list.h" #include "citra_qt/game_list.h" #include "citra_qt/game_list_p.h" #include "citra_qt/game_list_worker.h" diff --git a/src/citra_qt/game_list.h b/src/citra_qt/game_list.h index cfcf23615..a10d7fe15 100644 --- a/src/citra_qt/game_list.h +++ b/src/citra_qt/game_list.h @@ -4,10 +4,10 @@ #pragma once -#include #include #include #include +#include "citra_qt/compatibility_list.h" #include "common/common_types.h" #include "ui_settings.h" @@ -71,9 +71,8 @@ signals: void GameChosen(QString game_path); void ShouldCancelWorker(); void OpenFolderRequested(u64 program_id, GameListOpenTarget target); - void NavigateToGamedbEntryRequested( - u64 program_id, - std::unordered_map>& compatibility_list); + void NavigateToGamedbEntryRequested(u64 program_id, + const CompatibilityList& compatibility_list); void OpenDirectory(QString directory); void AddDirectory(); void ShowList(bool show); @@ -104,7 +103,7 @@ private: QStandardItemModel* item_model = nullptr; GameListWorker* current_worker = nullptr; QFileSystemWatcher* watcher = nullptr; - std::unordered_map> compatibility_list; + CompatibilityList compatibility_list; friend class GameListSearchField; }; diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 46f4714bc..2a1cb615c 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -361,17 +361,6 @@ public: } }; -inline auto FindMatchingCompatibilityEntry( - const std::unordered_map>& compatibility_list, - u64 program_id) { - return std::find_if( - compatibility_list.begin(), compatibility_list.end(), - [program_id](const std::pair>& element) { - std::string pid = fmt::format("{:016X}", program_id); - return element.first == pid; - }); -} - class GameList; class QHBoxLayout; class QTreeView; diff --git a/src/citra_qt/game_list_worker.cpp b/src/citra_qt/game_list_worker.cpp index b29f4246b..5e1e98466 100644 --- a/src/citra_qt/game_list_worker.cpp +++ b/src/citra_qt/game_list_worker.cpp @@ -10,6 +10,7 @@ #include #include +#include "citra_qt/compatibility_list.h" #include "citra_qt/game_list.h" #include "citra_qt/game_list_p.h" #include "citra_qt/game_list_worker.h" @@ -27,9 +28,8 @@ bool HasSupportedFileExtension(const std::string& file_name) { } } // Anonymous namespace -GameListWorker::GameListWorker( - QList& game_dirs, - const std::unordered_map>& compatibility_list) +GameListWorker::GameListWorker(QList& game_dirs, + const CompatibilityList& compatibility_list) : game_dirs(game_dirs), compatibility_list(compatibility_list) {} GameListWorker::~GameListWorker() = default; diff --git a/src/citra_qt/game_list_worker.h b/src/citra_qt/game_list_worker.h index b35e890ca..f87492cb1 100644 --- a/src/citra_qt/game_list_worker.h +++ b/src/citra_qt/game_list_worker.h @@ -15,6 +15,7 @@ #include #include +#include "citra_qt/compatibility_list.h" #include "common/common_types.h" class QStandardItem; @@ -27,9 +28,8 @@ class GameListWorker : public QObject, public QRunnable { Q_OBJECT public: - GameListWorker( - QList& game_dirs, - const std::unordered_map>& compatibility_list); + GameListWorker(QList& game_dirs, + const CompatibilityList& compatibility_list); ~GameListWorker() override; /// Starts the processing of directory tree information. @@ -58,7 +58,7 @@ private: GameListDir* parent_dir); QStringList watch_list; - const std::unordered_map>& compatibility_list; + const CompatibilityList& compatibility_list; QList& game_dirs; std::atomic_bool stop_processing; }; diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 8d0856af1..f09c228a7 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -21,6 +21,7 @@ #include "citra_qt/camera/qt_multimedia_camera.h" #include "citra_qt/camera/still_image_camera.h" #include "citra_qt/compatdb.h" +#include "citra_qt/compatibility_list.h" #include "citra_qt/configuration/config.h" #include "citra_qt/configuration/configure_dialog.h" #include "citra_qt/debugger/console.h" @@ -960,14 +961,11 @@ void GMainWindow::OnGameListOpenFolder(u64 data_id, GameListOpenTarget target) { QDesktopServices::openUrl(QUrl::fromLocalFile(qpath)); } -void GMainWindow::OnGameListNavigateToGamedbEntry( - u64 program_id, - std::unordered_map>& compatibility_list) { - +void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, + const CompatibilityList& compatibility_list) { auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); QString directory; - if (it != compatibility_list.end()) directory = it->second.second; diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index bbc0714c5..fc1382ddd 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -9,6 +9,7 @@ #include #include #include +#include "citra_qt/compatibility_list.h" #include "citra_qt/hotkeys.h" #include "common/announce_multiplayer_room.h" #include "core/core.h" @@ -153,9 +154,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>& compatibility_list); + void OnGameListNavigateToGamedbEntry(u64 program_id, + const CompatibilityList& compatibility_list); void OnGameListOpenDirectory(QString path); void OnGameListAddDirectory(); void OnGameListShowList(bool show);