mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-27 20:14:17 +01:00
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
|
applets/swkbd.h
|
||||||
bootmanager.cpp
|
bootmanager.cpp
|
||||||
bootmanager.h
|
bootmanager.h
|
||||||
|
compatibility_list.cpp
|
||||||
|
compatibility_list.h
|
||||||
camera/camera_util.cpp
|
camera/camera_util.cpp
|
||||||
camera/camera_util.h
|
camera/camera_util.h
|
||||||
camera/still_image_camera.cpp
|
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 <QToolButton>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include "citra_qt/compatibility_list.h"
|
||||||
#include "citra_qt/game_list.h"
|
#include "citra_qt/game_list.h"
|
||||||
#include "citra_qt/game_list_p.h"
|
#include "citra_qt/game_list_p.h"
|
||||||
#include "citra_qt/game_list_worker.h"
|
#include "citra_qt/game_list_worker.h"
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include "citra_qt/compatibility_list.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "ui_settings.h"
|
#include "ui_settings.h"
|
||||||
|
|
||||||
@ -71,9 +71,8 @@ signals:
|
|||||||
void GameChosen(QString game_path);
|
void GameChosen(QString game_path);
|
||||||
void ShouldCancelWorker();
|
void ShouldCancelWorker();
|
||||||
void OpenFolderRequested(u64 program_id, GameListOpenTarget target);
|
void OpenFolderRequested(u64 program_id, GameListOpenTarget target);
|
||||||
void NavigateToGamedbEntryRequested(
|
void NavigateToGamedbEntryRequested(u64 program_id,
|
||||||
u64 program_id,
|
const CompatibilityList& compatibility_list);
|
||||||
std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list);
|
|
||||||
void OpenDirectory(QString directory);
|
void OpenDirectory(QString directory);
|
||||||
void AddDirectory();
|
void AddDirectory();
|
||||||
void ShowList(bool show);
|
void ShowList(bool show);
|
||||||
@ -104,7 +103,7 @@ private:
|
|||||||
QStandardItemModel* item_model = nullptr;
|
QStandardItemModel* item_model = nullptr;
|
||||||
GameListWorker* current_worker = nullptr;
|
GameListWorker* current_worker = nullptr;
|
||||||
QFileSystemWatcher* watcher = nullptr;
|
QFileSystemWatcher* watcher = nullptr;
|
||||||
std::unordered_map<std::string, std::pair<QString, QString>> compatibility_list;
|
CompatibilityList compatibility_list;
|
||||||
|
|
||||||
friend class GameListSearchField;
|
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 GameList;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#include "citra_qt/compatibility_list.h"
|
||||||
#include "citra_qt/game_list.h"
|
#include "citra_qt/game_list.h"
|
||||||
#include "citra_qt/game_list_p.h"
|
#include "citra_qt/game_list_p.h"
|
||||||
#include "citra_qt/game_list_worker.h"
|
#include "citra_qt/game_list_worker.h"
|
||||||
@ -27,9 +28,8 @@ bool HasSupportedFileExtension(const std::string& file_name) {
|
|||||||
}
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
GameListWorker::GameListWorker(
|
GameListWorker::GameListWorker(QList<UISettings::GameDir>& game_dirs,
|
||||||
QList<UISettings::GameDir>& game_dirs,
|
const CompatibilityList& compatibility_list)
|
||||||
const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list)
|
|
||||||
: game_dirs(game_dirs), compatibility_list(compatibility_list) {}
|
: game_dirs(game_dirs), compatibility_list(compatibility_list) {}
|
||||||
|
|
||||||
GameListWorker::~GameListWorker() = default;
|
GameListWorker::~GameListWorker() = default;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <QRunnable>
|
#include <QRunnable>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include "citra_qt/compatibility_list.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
class QStandardItem;
|
class QStandardItem;
|
||||||
@ -27,9 +28,8 @@ class GameListWorker : public QObject, public QRunnable {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameListWorker(
|
GameListWorker(QList<UISettings::GameDir>& game_dirs,
|
||||||
QList<UISettings::GameDir>& game_dirs,
|
const CompatibilityList& compatibility_list);
|
||||||
const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list);
|
|
||||||
~GameListWorker() override;
|
~GameListWorker() override;
|
||||||
|
|
||||||
/// Starts the processing of directory tree information.
|
/// Starts the processing of directory tree information.
|
||||||
@ -58,7 +58,7 @@ private:
|
|||||||
GameListDir* parent_dir);
|
GameListDir* parent_dir);
|
||||||
|
|
||||||
QStringList watch_list;
|
QStringList watch_list;
|
||||||
const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list;
|
const CompatibilityList& compatibility_list;
|
||||||
QList<UISettings::GameDir>& game_dirs;
|
QList<UISettings::GameDir>& game_dirs;
|
||||||
std::atomic_bool stop_processing;
|
std::atomic_bool stop_processing;
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "citra_qt/camera/qt_multimedia_camera.h"
|
#include "citra_qt/camera/qt_multimedia_camera.h"
|
||||||
#include "citra_qt/camera/still_image_camera.h"
|
#include "citra_qt/camera/still_image_camera.h"
|
||||||
#include "citra_qt/compatdb.h"
|
#include "citra_qt/compatdb.h"
|
||||||
|
#include "citra_qt/compatibility_list.h"
|
||||||
#include "citra_qt/configuration/config.h"
|
#include "citra_qt/configuration/config.h"
|
||||||
#include "citra_qt/configuration/configure_dialog.h"
|
#include "citra_qt/configuration/configure_dialog.h"
|
||||||
#include "citra_qt/debugger/console.h"
|
#include "citra_qt/debugger/console.h"
|
||||||
@ -960,14 +961,11 @@ void GMainWindow::OnGameListOpenFolder(u64 data_id, GameListOpenTarget target) {
|
|||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(qpath));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(qpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnGameListNavigateToGamedbEntry(
|
void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id,
|
||||||
u64 program_id,
|
const CompatibilityList& compatibility_list) {
|
||||||
std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list) {
|
|
||||||
|
|
||||||
auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id);
|
auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id);
|
||||||
|
|
||||||
QString directory;
|
QString directory;
|
||||||
|
|
||||||
if (it != compatibility_list.end())
|
if (it != compatibility_list.end())
|
||||||
directory = it->second.second;
|
directory = it->second.second;
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
#include "citra_qt/compatibility_list.h"
|
||||||
#include "citra_qt/hotkeys.h"
|
#include "citra_qt/hotkeys.h"
|
||||||
#include "common/announce_multiplayer_room.h"
|
#include "common/announce_multiplayer_room.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
@ -153,9 +154,8 @@ private slots:
|
|||||||
/// Called whenever a user selects a game in the game list widget.
|
/// Called whenever a user selects a game in the game list widget.
|
||||||
void OnGameListLoadFile(QString game_path);
|
void OnGameListLoadFile(QString game_path);
|
||||||
void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target);
|
void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target);
|
||||||
void OnGameListNavigateToGamedbEntry(
|
void OnGameListNavigateToGamedbEntry(u64 program_id,
|
||||||
u64 program_id,
|
const CompatibilityList& compatibility_list);
|
||||||
std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list);
|
|
||||||
void OnGameListOpenDirectory(QString path);
|
void OnGameListOpenDirectory(QString path);
|
||||||
void OnGameListAddDirectory();
|
void OnGameListAddDirectory();
|
||||||
void OnGameListShowList(bool show);
|
void OnGameListShowList(bool show);
|
||||||
|
Loading…
Reference in New Issue
Block a user