aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_fomod_plus/installer/ui/FomodViewModel.h
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-14 02:45:12 -0600
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-14 02:45:25 -0600
commit817e8f5cd26739c69d930d21cd9dc4c0b6e4984e (patch)
tree52aed11d6751bb7d20b06acf197d56fac113203d /libs/installer_fomod_plus/installer/ui/FomodViewModel.h
parent51a9f8f197727f00896e5de44569b098923527dd (diff)
Add FUSE external mapping support, BG3/Oblivion Remastered fixes, fomod-plus and NaK integration
FUSE VFS now deploys non-data-dir mod mappings (Paks, OBSE, UE4SS, etc.) via real symlinks and injects file-level data-dir mappings (plugins.txt, loadorder.txt) into the VFS tree. Fixes game launches for Oblivion Remastered (Root Builder path resolution, script extender support) and BG3 (Wine prefix documents directory, file mapper symlinks on Linux). Vendors mo2-fomod-plus plugin and NaK crate for FOMOD installer and game finder/runtime support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/installer_fomod_plus/installer/ui/FomodViewModel.h')
-rw-r--r--libs/installer_fomod_plus/installer/ui/FomodViewModel.h154
1 files changed, 154 insertions, 0 deletions
diff --git a/libs/installer_fomod_plus/installer/ui/FomodViewModel.h b/libs/installer_fomod_plus/installer/ui/FomodViewModel.h
new file mode 100644
index 0000000..f0ce070
--- /dev/null
+++ b/libs/installer_fomod_plus/installer/ui/FomodViewModel.h
@@ -0,0 +1,154 @@
+#pragma once
+
+#include <imoinfo.h>
+#include <string>
+
+#include "lib/ConditionTester.h"
+#include "lib/FlagMap.h"
+#include "lib/FileInstaller.h"
+#include "lib/ViewModels.h"
+#include "xml/FomodInfoFile.h"
+
+/*
+--------------------------------------------------------------------------------
+ Info
+--------------------------------------------------------------------------------
+*/
+class InfoViewModel {
+public:
+ explicit InfoViewModel(const std::unique_ptr<FomodInfoFile>& infoFile)
+ {
+ if (infoFile) {
+ // Copy the necessary members from FomodInfoFile to InfoViewModel
+ mName = infoFile->getName();
+ mVersion = infoFile->getVersion();
+ mAuthor = infoFile->getAuthor();
+ mWebsite = infoFile->getWebsite();
+ }
+ }
+
+ // Accessor methods
+ [[nodiscard]] std::string getName() const { return mName; }
+ [[nodiscard]] std::string getVersion() const { return mVersion; }
+ [[nodiscard]] std::string getAuthor() const { return mAuthor; }
+ [[nodiscard]] std::string getWebsite() const { return mWebsite; }
+
+private:
+ std::string mName;
+ std::string mVersion;
+ std::string mAuthor;
+ std::string mWebsite;
+};
+
+/*
+--------------------------------------------------------------------------------
+ View Model
+--------------------------------------------------------------------------------
+*/
+class FomodViewModel {
+public:
+ FomodViewModel(
+ MOBase::IOrganizer* organizer,
+ std::unique_ptr<ModuleConfiguration> fomodFile,
+ std::unique_ptr<FomodInfoFile> infoFile);
+
+ static std::shared_ptr<FomodViewModel> create(
+ MOBase::IOrganizer* organizer,
+ std::unique_ptr<ModuleConfiguration> fomodFile,
+ std::unique_ptr<FomodInfoFile> infoFile);
+
+ void forEachGroup(const std::function<void(GroupRef)>& callback) const;
+
+ void forEachPlugin(const std::function<void(GroupRef, PluginRef)>& callback) const;
+
+ void forEachFuturePlugin(int fromStepIndex, const std::function<void(GroupRef, PluginRef)>& callback) const;
+
+ void selectFromJson(nlohmann::json json) const;
+
+ void resetToDefaults();
+
+ [[nodiscard]] std::shared_ptr<PluginViewModel> getFirstPluginForActiveStep() const;
+
+ // Steps
+ [[nodiscard]] shared_ptr_list<StepViewModel> getSteps() const { return mSteps; }
+ [[nodiscard]] StepRef getActiveStep() const { return mActiveStep; }
+ [[nodiscard]] int getCurrentStepIndex() const { return mCurrentStepIndex; }
+ [[deprecated]] void setCurrentStepIndex(const int index) { mCurrentStepIndex = index; }
+
+ void updateVisibleSteps() const;
+
+ void rebuildConditionFlagsForStep(int stepIndex) const;
+
+ void preinstall(const std::shared_ptr<MOBase::IFileTree>& tree, const QString& fomodPath);
+
+ std::shared_ptr<FileInstaller> getFileInstaller() { return mFileInstaller; }
+
+ std::string getDisplayImage() const;
+
+ // Plugins
+ [[nodiscard]] PluginRef getActivePlugin() const { return mActivePlugin; }
+
+ // Info
+ [[nodiscard]] std::shared_ptr<InfoViewModel> getInfoViewModel() const { return mInfoViewModel; }
+
+ // Interactions
+ void stepBack();
+
+ void stepForward();
+
+ bool isLastVisibleStep() const;
+
+ bool isFirstVisibleStep() const;
+
+ bool togglePlugin(const GroupRef, const PluginRef, bool selected) const;
+
+ bool ctrlTogglePlugin(const GroupRef, const PluginRef, bool selected) const;
+
+ void setActivePlugin(const PluginRef plugin) const { mActivePlugin = plugin; }
+
+ static void markManuallySet(PluginRef plugin);
+
+private:
+ Logger& log = Logger::getInstance();
+ MOBase::IOrganizer* mOrganizer = nullptr;
+ std::unique_ptr<ModuleConfiguration> mFomodFile;
+ std::unique_ptr<FomodInfoFile> mInfoFile;
+ std::shared_ptr<FlagMap> mFlags{ nullptr };
+ ConditionTester mConditionTester;
+ std::shared_ptr<InfoViewModel> mInfoViewModel;
+ std::vector<std::shared_ptr<StepViewModel> > mSteps;
+ mutable std::shared_ptr<PluginViewModel> mActivePlugin{ nullptr };
+ mutable std::shared_ptr<StepViewModel> mActiveStep{ nullptr };
+ mutable std::vector<int> mVisibleStepIndices;
+ std::shared_ptr<FileInstaller> mFileInstaller{ nullptr };
+ bool mInitialized{ false };
+
+ void createStepViewModels();
+
+ void setFlagForPluginState(const std::shared_ptr<PluginViewModel>& plugin) const;
+
+ static void createNonePluginForGroup(const std::shared_ptr<GroupViewModel>& group);
+
+ void processPlugin(const std::shared_ptr<GroupViewModel>& group,
+ const std::shared_ptr<PluginViewModel>& plugin) const;
+
+ void enforceRadioGroupConstraints(const std::shared_ptr<GroupViewModel>& group) const;
+
+ void enforceSelectAllConstraint(const std::shared_ptr<GroupViewModel>& groupViewModel) const;
+
+ void enforceSelectAtLeastOneConstraint(const std::shared_ptr<GroupViewModel>& group) const;
+
+ void enforceGroupConstraints() const;
+
+ void processPluginConditions(int fromStepIndex) const;
+
+ // Indices
+ int mCurrentStepIndex{ 0 };
+
+ void logMessage(const LogLevel level, const std::string& message) const
+ {
+ log.logMessage(level, "[VIEWMODEL] " + message);
+ }
+
+ std::string toString() const;
+};