Skip to content

Commit

Permalink
Refactoring of game features for better management.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jun 1, 2024
1 parent a11617f commit f913cac
Show file tree
Hide file tree
Showing 27 changed files with 841 additions and 262 deletions.
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>();
GamePlugins* 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

0 comments on commit f913cac

Please sign in to comment.