Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of game features for better management. #2043

Merged
merged 4 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ mo2_add_filter(NAME src/core GROUPS
nexusinterface
nxmaccessmanager
organizercore
game_features
plugincontainer
apiuseraccount
processrunner
Expand Down Expand Up @@ -196,6 +197,7 @@ mo2_add_filter(NAME src/profiles GROUPS

mo2_add_filter(NAME src/proxies GROUPS
downloadmanagerproxy
gamefeaturesproxy
modlistproxy
organizerproxy
pluginlistproxy
Expand Down
2 changes: 2 additions & 0 deletions src/activatemodsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.

#include <QtGlobal>

using namespace MOBase;

ActivateModsDialog::ActivateModsDialog(SaveGameInfo::MissingAssets const& missingAssets,
QWidget* parent)
: TutorableDialog("ActivateMods", parent), ui(new Ui::ActivateModsDialog)
Expand Down
7 changes: 3 additions & 4 deletions src/activatemodsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "tutorabledialog.h"

#include <QObject>

class QString;
class QWidget;
#include <QString>
#include <QWidget>

#include <set>

Expand All @@ -49,7 +48,7 @@ class ActivateModsDialog : public MOBase::TutorableDialog
* @param missingPlugins a map containing missing plugins that need to be activated
* @param parent ... Defaults to 0.
**/
explicit ActivateModsDialog(SaveGameInfo::MissingAssets const& missingAssets,
explicit ActivateModsDialog(MOBase::SaveGameInfo::MissingAssets const& missingAssets,
QWidget* parent = 0);
~ActivateModsDialog();

Expand Down
26 changes: 13 additions & 13 deletions src/directoryrefresher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "shared/filesorigin.h"

#include "envfs.h"
#include "game_features.h"
#include "iplugingame.h"
#include "modinfo.h"
#include "modinfodialogfwd.h"
#include "organizercore.h"
#include "report.h"
#include "settings.h"
#include "shared/util.h"
Expand Down Expand Up @@ -159,8 +161,8 @@ void dumpStats(std::vector<DirectoryStats>& stats)
++run;
}

DirectoryRefresher::DirectoryRefresher(std::size_t threadCount)
: m_threadCount(threadCount), m_lastFileCount(0)
DirectoryRefresher::DirectoryRefresher(OrganizerCore* core, std::size_t threadCount)
: m_Core(*core), m_threadCount(threadCount), m_lastFileCount(0)
{}

DirectoryEntry* DirectoryRefresher::stealDirectoryStructure()
Expand Down Expand Up @@ -204,11 +206,9 @@ void DirectoryRefresher::addModBSAToStructure(DirectoryEntry* root,
const QString& directory,
const QStringList& archives)
{
const IPluginGame* game = qApp->property("managed_game").value<IPluginGame*>();

QStringList loadOrder;

GamePlugins* gamePlugins = game->feature<GamePlugins>();
auto gamePlugins = m_Core.gameFeatures().gameFeature<GamePlugins>();
if (gamePlugins) {
loadOrder = gamePlugins->getLoadOrder();
}
Expand Down Expand Up @@ -320,6 +320,7 @@ void DirectoryRefresher::addModToStructure(DirectoryEntry* directoryStructure,

struct ModThread
{
GameFeatures* gameFeatures;
DirectoryRefreshProgress* progress = nullptr;
DirectoryEntry* ds = nullptr;
std::wstring modName;
Expand Down Expand Up @@ -355,10 +356,8 @@ struct ModThread
ds->addFromOrigin(walker, modName, path, prio, *stats);

if (Settings::instance().archiveParsing()) {
const IPluginGame* game = qApp->property("managed_game").value<IPluginGame*>();

QStringList loadOrder;
GamePlugins* gamePlugins = game->feature<GamePlugins>();
auto gamePlugins = gameFeatures->gameFeature<GamePlugins>();
if (gamePlugins) {
loadOrder = gamePlugins->getLoadOrder();
}
Expand Down Expand Up @@ -420,11 +419,12 @@ void DirectoryRefresher::addMultipleModsFilesToStructure(
} else {
auto& mt = g_threads.request();

mt.progress = progress;
mt.ds = directoryStructure;
mt.modName = e.modName.toStdWString();
mt.path = QDir::toNativeSeparators(e.absolutePath).toStdWString();
mt.prio = prio;
mt.gameFeatures = &m_Core.gameFeatures();
mt.progress = progress;
mt.ds = directoryStructure;
mt.modName = e.modName.toStdWString();
mt.path = QDir::toNativeSeparators(e.absolutePath).toStdWString();
mt.prio = prio;

mt.archives.clear();
for (auto&& a : e.archives) {
Expand Down
6 changes: 5 additions & 1 deletion src/directoryrefresher.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <tuple>
#include <vector>

class OrganizerCore;

/**
* @brief used to asynchronously generate the virtual view of the combined data
*directory
Expand All @@ -54,7 +56,7 @@ class DirectoryRefresher : public QObject
int priority;
};

DirectoryRefresher(std::size_t threadCount);
DirectoryRefresher(OrganizerCore* core, std::size_t threadCount);

/**
* @brief retrieve the updated directory structure
Expand Down Expand Up @@ -146,6 +148,8 @@ public slots:
void refreshed();

private:
OrganizerCore& m_Core;

std::vector<EntryInfo> m_Mods;
std::set<QString> m_EnabledArchives;
std::unique_ptr<MOShared::DirectoryEntry> m_Root;
Expand Down
Loading
Loading