yuzu-emu
/
yuzu
Archived
1
0
Fork 0

game_list: Remove global instances of Core::System

This commit is contained in:
lat9nq 2021-07-30 09:32:26 -04:00 committed by Morph
parent 493905665c
commit 4ce53ffe6a
5 changed files with 19 additions and 13 deletions

View File

@ -305,8 +305,8 @@ void GameList::OnFilterCloseClicked() {
}
GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvider* provider,
GMainWindow* parent)
: QWidget{parent}, vfs(std::move(vfs)), provider(provider) {
Core::System& system_, GMainWindow* parent)
: QWidget{parent}, vfs(std::move(vfs)), provider(provider), system{system_} {
watcher = new QFileSystemWatcher(this);
connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory);
@ -738,7 +738,8 @@ void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
emit ShouldCancelWorker();
GameListWorker* worker = new GameListWorker(vfs, provider, game_dirs, compatibility_list);
GameListWorker* worker =
new GameListWorker(vfs, provider, game_dirs, compatibility_list, system);
connect(worker, &GameListWorker::EntryReady, this, &GameList::AddEntry, Qt::QueuedConnection);
connect(worker, &GameListWorker::DirEntryReady, this, &GameList::AddDirEntry,

View File

@ -72,7 +72,8 @@ public:
};
explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs,
FileSys::ManualContentProvider* provider, GMainWindow* parent = nullptr);
FileSys::ManualContentProvider* provider, Core::System& system_,
GMainWindow* parent = nullptr);
~GameList() override;
QString GetLastFilterResultItem() const;
@ -145,6 +146,8 @@ private:
CompatibilityList compatibility_list;
friend class GameListSearchField;
Core::System& system;
};
class GameListPlaceholder : public QWidget {

View File

@ -228,16 +228,15 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri
GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs,
FileSys::ManualContentProvider* provider,
QVector<UISettings::GameDir>& game_dirs,
const CompatibilityList& compatibility_list)
const CompatibilityList& compatibility_list, Core::System& system_)
: vfs(std::move(vfs)), provider(provider), game_dirs(game_dirs),
compatibility_list(compatibility_list) {}
compatibility_list(compatibility_list), system{system_} {}
GameListWorker::~GameListWorker() = default;
void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {
using namespace FileSys;
auto& system = Core::System::GetInstance();
const auto& cache = dynamic_cast<ContentProviderUnion&>(system.GetContentProvider());
auto installed_games = cache.ListEntriesFilterOrigin(std::nullopt, TitleType::Application,
@ -285,10 +284,7 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {
void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
GameListDir* parent_dir) {
auto& system = Core::System::GetInstance();
const auto callback = [this, target, parent_dir,
&system](const std::filesystem::path& path) -> bool {
const auto callback = [this, target, parent_dir](const std::filesystem::path& path) -> bool {
if (stop_processing) {
// Breaks the callback loop.
return false;

View File

@ -19,6 +19,10 @@
#include "common/common_types.h"
#include "yuzu/compatibility_list.h"
namespace Core {
class System;
}
class QStandardItem;
namespace FileSys {
@ -37,7 +41,7 @@ public:
explicit GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs,
FileSys::ManualContentProvider* provider,
QVector<UISettings::GameDir>& game_dirs,
const CompatibilityList& compatibility_list);
const CompatibilityList& compatibility_list, Core::System& system_);
~GameListWorker() override;
/// Starts the processing of directory tree information.
@ -80,4 +84,6 @@ private:
QStringList watch_list;
std::atomic_bool stop_processing;
Core::System& system;
};

View File

@ -701,7 +701,7 @@ void GMainWindow::InitializeWidgets() {
render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, system);
render_window->hide();
game_list = new GameList(vfs, provider.get(), this);
game_list = new GameList(vfs, provider.get(), system, this);
ui.horizontalLayout->addWidget(game_list);
game_list_placeholder = new GameListPlaceholder(this);