Files
eden/src/yuzu/game_list_worker.h
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

101 lines
2.7 KiB
C++
Raw Normal View History

2025-09-15 17:21:18 +02:00
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <atomic>
2023-10-23 22:09:29 -04:00
#include <deque>
#include <memory>
#include <string>
#include <QList>
#include <QObject>
#include <QRunnable>
#include <QString>
#include "common/thread.h"
2025-05-29 08:20:11 +00:00
#include "core/file_sys/registered_cache.h"
#include "qt_common/config/uisettings.h"
#include "yuzu/compatibility_list.h"
#include "frontend_common/play_time_manager.h"
namespace Core {
class System;
}
2023-10-23 22:09:29 -04:00
class GameList;
2025-05-29 08:20:11 +00:00
class GameListDir;
class QStandardItem;
namespace FileSys {
class NCA;
class VfsFilesystem;
} // namespace FileSys
/**
* Asynchronous worker object for populating the game list.
* Communicates with other threads through Qt's signal/slot system.
*/
class GameListWorker : public QObject, public QRunnable {
Q_OBJECT
public:
2022-06-13 16:52:19 -04:00
explicit GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs_,
FileSys::ManualContentProvider* provider_,
QVector<UISettings::GameDir>& game_dirs_,
2023-08-27 18:41:42 -04:00
const CompatibilityList& compatibility_list_,
const PlayTime::PlayTimeManager& play_time_manager_,
2025-09-15 17:21:18 +02:00
Core::System& system_);
~GameListWorker() override;
/// Starts the processing of directory tree information.
void run() override;
2023-10-23 22:09:29 -04:00
public:
/**
2023-10-23 22:09:29 -04:00
* Synchronously processes any events queued by the worker.
*
* AddDirEntry is called on the game list for every discovered directory.
* AddEntry is called on the game list for every discovered program.
* DonePopulating is called on the game list when processing completes.
*/
2023-10-23 22:09:29 -04:00
void ProcessEvents(GameList* game_list);
2023-10-23 22:09:29 -04:00
signals:
void DataAvailable();
private:
template <typename F>
void RecordEvent(F&& func);
private:
void AddTitlesToGameList(GameListDir* parent_dir);
enum class ScanTarget {
FillManualContentProvider,
PopulateGameList,
};
void ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
GameListDir* parent_dir);
std::shared_ptr<FileSys::VfsFilesystem> vfs;
FileSys::ManualContentProvider* provider;
2019-06-08 00:51:58 +02:00
QVector<UISettings::GameDir>& game_dirs;
2019-10-04 23:41:02 +00:00
const CompatibilityList& compatibility_list;
2023-08-27 18:41:42 -04:00
const PlayTime::PlayTimeManager& play_time_manager;
2019-10-04 23:41:02 +00:00
QStringList watch_list;
2023-10-23 22:09:29 -04:00
std::mutex lock;
std::condition_variable cv;
std::deque<std::function<void(GameList*)>> queued_events;
std::atomic_bool stop_requested = false;
2023-10-23 22:09:29 -04:00
Common::Event processing_completed;
Core::System& system;
};