yuzu: Move compatibility list specifics to their own source files
Lets us keep the generic portions of the compatibility list code together, and allows us to introduce a type alias that makes it so we don't need to type out a very long type declaration anymore, making the immediate readability of some code better.
This commit is contained in:
parent
9238015dd4
commit
230edc8c7c
@ -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
|
||||
|
18
src/citra_qt/compatibility_list.cpp
Normal file
18
src/citra_qt/compatibility_list.cpp
Normal file
@ -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 "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;
|
||||
});
|
||||
}
|
17
src/citra_qt/compatibility_list.h
Normal file
17
src/citra_qt/compatibility_list.h
Normal file
@ -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);
|
@ -21,6 +21,7 @@
|
||||
#include <QToolButton>
|
||||
#include <QTreeView>
|
||||
#include <fmt/format.h>
|
||||
#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"
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include <QMenu>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#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<std::string, std::pair<QString, QString>>& 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<std::string, std::pair<QString, QString>> compatibility_list;
|
||||
CompatibilityList compatibility_list;
|
||||
|
||||
friend class GameListSearchField;
|
||||
};
|
||||
|
@ -361,17 +361,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
class GameList;
|
||||
class QHBoxLayout;
|
||||
class QTreeView;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
#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<UISettings::GameDir>& game_dirs,
|
||||
const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list)
|
||||
GameListWorker::GameListWorker(QList<UISettings::GameDir>& game_dirs,
|
||||
const CompatibilityList& compatibility_list)
|
||||
: game_dirs(game_dirs), compatibility_list(compatibility_list) {}
|
||||
|
||||
GameListWorker::~GameListWorker() = default;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <QRunnable>
|
||||
#include <QString>
|
||||
|
||||
#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<UISettings::GameDir>& game_dirs,
|
||||
const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list);
|
||||
GameListWorker(QList<UISettings::GameDir>& 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<std::string, std::pair<QString, QString>>& compatibility_list;
|
||||
const CompatibilityList& compatibility_list;
|
||||
QList<UISettings::GameDir>& game_dirs;
|
||||
std::atomic_bool stop_processing;
|
||||
};
|
||||
|
@ -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<std::string, std::pair<QString, QString>>& 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;
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
#include <QTranslator>
|
||||
#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<std::string, std::pair<QString, QString>>& compatibility_list);
|
||||
void OnGameListNavigateToGamedbEntry(u64 program_id,
|
||||
const CompatibilityList& compatibility_list);
|
||||
void OnGameListOpenDirectory(QString path);
|
||||
void OnGameListAddDirectory();
|
||||
void OnGameListShowList(bool show);
|
||||
|
Loading…
Reference in New Issue
Block a user