Limo
A simple mod manager
Loading...
Searching...
No Matches
OpenMwPluginDeployer Class Reference

Autonomous deployer which handles plugin files for OpenMW using LOOT. More...

#include <openmwplugindeployer.h>

Inheritance diagram for OpenMwPluginDeployer:
Collaboration diagram for OpenMwPluginDeployer:

Public Member Functions

 OpenMwPluginDeployer (const std::filesystem::path &source_path, const std::filesystem::path &dest_path, const std::string &name)
 Loads plugins.
 
virtual void unDeploy (std::optional< ProgressNode * > progress_node={}) override
 If no backup exists: Backs up current plugin file, then reloads all plugins.
 
virtual std::vector< std::vector< int > > getConflictGroups () const override
 Groups plugins by whether or not they are scrips, groundcover plugins or neither.
 
virtual std::map< std::string, int > getAutoTagMap () override
 Returns all available auto tag names.
 
virtual void sortModsByConflicts (std::optional< ProgressNode * > progress_node={}) override
 Sort mods by into script, groundcover and normal groups.
 
virtual bool supportsModConflicts () const override
 Returns whether or not this deployer type supports showing mod conflicts.
 
virtual std::vector< std::pair< std::string, std::string > > getModActions () const override
 Returns names and icon names for additional actions which can be applied to a mod.
 
virtual std::vector< std::vector< int > > getValidModActions () const override
 Returns a vector containing valid mod actions.
 
virtual void applyModAction (int action, int mod_id) override
 Applies the given mod action to the given mod.
 
- Public Member Functions inherited from PluginDeployer
 PluginDeployer (const std::filesystem::path &source_path, const std::filesystem::path &dest_path, const std::string &name)
 Constructor.
 
virtual std::map< int, unsigned long > deploy (std::optional< ProgressNode * > progress_node={}) override
 Reloads all deployed plugins.
 
virtual std::map< int, unsigned long > deploy (const std::vector< int > &loadorder, std::optional< ProgressNode * > progress_node={}) override
 Reloads all deployed plugins.
 
virtual void changeLoadorder (int from_index, int to_index) override
 Moves a mod from one position in the load order to another. Saves changes to disk.
 
virtual void setModStatus (int mod_id, bool status) override
 Enables or disables the given mod in the load order. Saves changes to disk.
 
virtual std::vector< std::string > getModNames () const override
 Generates a vector of names for every plugin.
 
virtual void addProfile (int source=-1) override
 Adds a new profile and optionally copies it's load order from an existing profile. Profiles are stored in the target directory.
 
virtual void removeProfile (int profile) override
 Removes a profile.
 
virtual void setProfile (int profile) override
 Setter for the active profile. Changes the currently active plugin files to the ones saved in the new profile.
 
virtual void setConflictGroups (const std::vector< std::vector< int > > &newConflict_groups) override
 Not supported by this type.
 
virtual int getNumMods () const override
 Returns the number of plugins on the load order.
 
virtual std::vector< std::tuple< int, bool > > getLoadorder () const override
 Getter for the current plugin load order.
 
virtual bool addMod (int mod_id, bool enabled=true, bool update_conflicts=true) override
 Does nothing since this deployer manages its own mods.
 
virtual bool removeMod (int mod_id) override
 Not supported by this type.
 
virtual bool hasMod (int mod_id) const override
 Since this deployer uses its own internal mod ids, this function always returns false.
 
virtual bool swapMod (int old_id, int new_id) override
 Does nothing since this deployer manages its own mods.
 
virtual std::vector< ConflictInfogetFileConflicts (int mod_id, bool show_disabled=false, std::optional< ProgressNode * > progress_node={}) const override
 Not supported.
 
virtual std::unordered_set< int > getModConflicts (int mod_id, std::optional< ProgressNode * > progress_node={}) override
 Not supported by this type.
 
virtual void cleanup () override
 Deletes the config file and all profile files.
 
virtual std::vector< std::vector< std::string > > getAutoTags () override
 Getter for mod tags.
 
virtual std::vector< std::pair< std::filesystem::path, int > > getExternallyModifiedFiles (std::optional< ProgressNode * > progress_node={}) const override
 Not supported by this Deployer type.
 
virtual void keepOrRevertFileModifications (const FileChangeChoices &changes_to_keep) override
 Not supported by this Deployer type.
 
virtual void updateDeployedFilesForMod (int mod_id, std::optional< ProgressNode * > progress_node={}) const override
 Updates the deployed files for one mod to match those in the mod's source directory. This is not supported for this deployer type.
 
virtual void fixInvalidLinkDeployMode () override
 Since this deployer type does not use normal deployment methods, this does nothing.
 
virtual void setDeployMode (DeployMode deploy_mode) override
 This deployer always uses copy deploy mode.
 
virtual int getDeployPriority () const override
 Returns the order in which the deploy function of different deployers should be called.
 
virtual bool supportsFileConflicts () const override
 Returns whether or not this deployer type supports showing file conflicts.
 
virtual bool supportsFileBrowsing () const override
 Returns whether or not this deployer type supports browsing mod files.
 
virtual bool idsAreSourceReferences () const override
 Returns whether or not this deployer type uses mod ids as references to source mods. This is usually done by autonomous deployers.
 
- Public Member Functions inherited from Deployer
 Deployer (const std::filesystem::path &source_path, const std::filesystem::path &dest_path, const std::string &name, DeployMode deploy_mode=hard_link)
 Constructor.
 
std::string getDestPath () const
 Getter for path to deployment target directory.
 
std::string getSourcePath () const
 Getter for the path to the deployer's source directory.
 
std::string getName () const
 Getter for deployer name.
 
void setName (const std::string &name)
 Setter for deployer name.
 
void setLoadorder (const std::vector< std::tuple< int, bool > > &loadorder)
 Setter for the load order used for deployment.
 
std::string getType () const
 Returns the type of this deployer, i.e. SIMPLEDEPLOYER.
 
const std::filesystem::path & destPath () const
 Getter for path to deployment target directory.
 
void setDestPath (const std::filesystem::path &path)
 Setter for path to deployment target directory.
 
int getProfile () const
 Getter for the active profile.
 
std::pair< int, std::string > verifyDirectories ()
 Checks if writing to the deployment directory is possible.
 
DeployMode getDeployMode () const
 Getter for the current DeployMode.
 
bool isAutonomous ()
 Getter for is_autonomous_.
 
std::filesystem::path sourcePath () const
 Getter for mod source path.
 
void setSourcePath (const std::filesystem::path &newSourcePath)
 Setter for mod source path.
 
void setLog (const std::function< void(Log::LogLevel, const std::string &)> &newLog)
 Setter for log callback.
 
void updateConflictGroups (std::optional< ProgressNode * > progress_node={})
 Updates conflict_groups_ for the current profile.
 
bool autoUpdateConflictGroups () const
 Getter for auto_update_conflict_groups_.
 
void setAutoUpdateConflictGroups (bool status)
 Setter for auto_update_conflict_groups_.
 
std::optional< bool > getModStatus (int mod_id)
 Searches the load order for the given mod id and returns the corresponding mods activation status, if found.
 
virtual bool supportsSorting () const
 Returns whether or not this deployer type supports sorting mods.
 
virtual bool supportsReordering () const
 Returns whether or not this deployer type supports reordering mods.
 

Static Public Attributes

static constexpr int ACTION_ADD_GROUNDCOVER_TAG = 0
 Action id for adding a groundcover tag.
 
static constexpr int ACTION_REMOVE_GROUNDCOVER_TAG = 1
 Action id for removing a groundcover tag.
 

Private Member Functions

void writePlugins () const override
 Wrapper for writePluginsPrivate.
 
bool initPluginFile ()
 Initializes the plugin file, if it does not exist.
 
void readPluginTags ()
 Reads the plugin tags from disk.
 
virtual void writePluginTags () const override
 Wrapper for writePluginTagsPrivate.
 
virtual void updatePluginTags () override
 Wrapper for updatePluginTagsPrivate.
 
void updateTagVector ()
 Adds all tags from the tag map to the tags_ vector.
 
void updatePluginTagsPrivate ()
 Updates the tag_map_ for every plugin.
 
void writePluginTagsPrivate () const
 Writes plugins to the OpenMW config file.
 
void writePluginsToOpenMwConfig (const std::string &line_prefix, const std::regex &line_regex, std::function< bool(int)> plugin_filter) const
 Writes a subset of plugins to the OpenMW config file.
 
void writePluginsPrivate () const
 Writes the plugins to disk.
 

Private Attributes

int num_groundcover_plugins_ = 0
 Number of plugins with groundcover tag.
 
int num_openmw_plugins_ = 0
 Number of plugins with openmw tag.
 
int num_es_plugins_ = 0
 Number of plugins with es plugin tag.
 
int num_scripts_plugins_ = 0
 Number of script plugins.
 
std::map< std::string, std::set< std::string > > tag_map_
 Maps plugins to a set of tags.
 
std::set< std::string > groundcover_plugins_
 Names of groundcover plugins.
 

Static Private Attributes

static constexpr std::string OPEN_MW_CONFIG_FILE_NAME = "openmw.cfg"
 Name of the OpenMW config file.
 
static constexpr std::string GROUNDCOVER_TAG = "Groundcover"
 Name of the groundcover tag.
 
static constexpr std::string OPENMW_TAG = "OpenMW"
 Name of the open mw tag.
 
static constexpr std::string ES_PLUGIN_TAG = "ES-Plugin"
 Name of the es plugin tag.
 
static constexpr std::string SCRIPTS_PLUGIN_TAG = "Scripts"
 Name of the es plugin tag.
 

Additional Inherited Members

- Public Types inherited from Deployer
enum  DeployMode { hard_link = 0 , sym_link = 1 , copy = 2 }
 Describes how files should be deployed to the target directory. More...
 
- Protected Member Functions inherited from PluginDeployer
virtual void updatePlugins ()
 Updates current plugins to reflect plugins actually in the source directory.
 
virtual void loadPlugins ()
 Load plugins from the plugins file.
 
virtual void saveSettings () const
 Saves number of profiles and active profile to the config file.
 
virtual void loadSettings ()
 Loads number of profiles and active profile from the config file.
 
virtual void resetSettings ()
 Resets all settings to default values.
 
virtual void restoreUndeployBackupIfExists ()
 If plugin file backups exist, restore it and override the current file.
 
virtual void updateSourceMods ()
 Updates the source mod map with files created by another deployer.
 
virtual void writeSourceMods () const
 Writes the source mods to disk.
 
virtual void readSourceMods ()
 Reads the source mods from disk.
 
std::optional< std::filesystem::path > getRootOfTargetDirectory (std::filesystem::path target) const
 Finds the directory serving as a target directory for the deployer which manages the given target path.
 
std::string hideFile (const std::string &name)
 Converts the given file name to a hidden file by prepending a ".", if necessary.
 
- Protected Member Functions inherited from Deployer
std::pair< std::map< std::filesystem::path, int >, std::map< int, unsigned long > > getDeploymentSourceFilesAndModSizes (const std::vector< int > &loadorder) const
 Creates a pair of maps. One maps relative file paths to the mod id from which that file is to be deployed. The other maps mod ids to their total file size on disk.
 
void backupOrRestoreFiles (const std::map< std::filesystem::path, int > &source_files, const std::map< std::filesystem::path, int > &dest_files) const
 Backs up all files which would be overwritten during deployment and restores all files backed up during previous deployments files which are no longer overwritten.
 
void deployFiles (const std::map< std::filesystem::path, int > &source_files, std::optional< ProgressNode * > progress_node={}) const
 Hard links all given files to target directory.
 
std::map< std::filesystem::path, int > loadDeployedFiles (std::optional< ProgressNode * > progress_node={}, std::filesystem::path dest_path="") const
 Creates a map of currently deployed files to their source mods.
 
void saveDeployedFiles (const std::map< std::filesystem::path, int > &deployed_files, std::optional< ProgressNode * > progress_node={}) const
 Creates a file containing information about currently deployed files.
 
std::vector< std::string > getModFiles (int mod_id, bool include_directories=false) const
 Creates a vector containing every file contained in one mod. Files are represented as paths relative to the mods root directory.
 
bool modPathExists (int mod_id) const
 modPathExists Checks if the directory containing the given mod exists.
 
bool checkModPathExistsAndMaybeLogError (int mod_id) const
 Checks if the directory containing the given mod exists, if not logs an error.
 
void removeManagedDirFile (const std::filesystem::path &directory) const
 Removes a legacy file that is no longer needed and may cause issues.
 
- Protected Attributes inherited from PluginDeployer
std::string config_file_name_ = ".lmmconfig"
 Name of the file containing settings.
 
std::string source_mods_file_name_ = ".lmm_mod_sources"
 Name of the file containing source mod ids for plugins.
 
std::string plugin_file_name_ = "plugins.txt"
 Name of the file containing plugin activation status.
 
std::vector< std::pair< std::string, bool > > plugins_
 Contains names of all plugins and their activation status.
 
int num_profiles_ = 0
 Current number of profiles.
 
std::vector< std::vector< std::string > > tags_
 For every plugin: Every tag associated with that plugin.
 
std::map< std::string, int > source_mods_
 Maps every plugin to a source mod, if that plugin was created by another deployer.
 
std::regex plugin_regex_
 Regex used to match against files in the source directory.
 
std::regex plugin_file_line_regex_
 Regex used to match against lines in the plugin file.
 
std::string tags_file_name_ = ".plugin_tags"
 Name of the file containing loot tags.
 
- Protected Attributes inherited from Deployer
std::string type_ = "Simple Deployer"
 Type of this deployer, e.g. Simple Deployer.
 
std::filesystem::path source_path_
 Path to the directory containing all mods which are to be deployed.
 
std::filesystem::path dest_path_
 Path to the directory where all mods are deployed to.
 
const std::string backup_extension_ = ".lmmbak"
 The file extension appended to backed up files.
 
const std::string deployed_files_name_ = ".lmmfiles"
 The file name for a file in the target directory containing names of deployed files.
 
const std::string managed_dir_file_name_ = ".lmm_managed_dir"
 Name of the file indicating that the directory is managed by a deployer.
 
std::string name_
 The name of this deployer.
 
int current_profile_ = 0
 The currently active profile.
 
std::vector< std::vector< std::tuple< int, bool > > > loadorders_
 One load order per profile consisting of tuples of mod ids and their enabled status.
 
std::vector< std::vector< std::vector< int > > > conflict_groups_
 For every profile: Groups of mods which conflict with each other. The last group contains mods with no conflicts.
 
DeployMode deploy_mode_ = hard_link
 Determines how files should be deployed to the target directory.
 
bool is_autonomous_ = false
 Autonomous deployers manage their own mods and do not rely on ModdedApplication.
 
bool auto_update_conflict_groups_ = false
 If true: Automatically update conflict groups when necessary.
 
std::function< void(Log::LogLevel, const std::string &)> log_
 Callback for logging.
 
- Static Protected Attributes inherited from PluginDeployer
static constexpr std::string EXTENSION = ".lmmprof"
 Appended to profile file names.
 
static constexpr std::string UNDEPLOY_BACKUP_EXTENSION = ".undeplbak"
 File extension for plugins.txt and loadorder.txt backup files.
 

Detailed Description

Autonomous deployer which handles plugin files for OpenMW using LOOT.

Constructor & Destructor Documentation

◆ OpenMwPluginDeployer()

OpenMwPluginDeployer::OpenMwPluginDeployer ( const std::filesystem::path & source_path,
const std::filesystem::path & dest_path,
const std::string & name )

Loads plugins.

Parameters
source_pathPath to the directory containing installed plugins.
dest_pathPath to the directory containing openmw.cfg.
nameA custom name for this instance.
init_tagsIf true: Initializes plugin tags. Disable this for testing purposes with invalid plugin files

Member Function Documentation

◆ applyModAction()

void OpenMwPluginDeployer::applyModAction ( int action,
int mod_id )
overridevirtual

Applies the given mod action to the given mod.

Parameters
actionAction to be applied.
mod_idTarget mod.

Reimplemented from Deployer.

◆ getAutoTagMap()

std::map< std::string, int > OpenMwPluginDeployer::getAutoTagMap ( )
overridevirtual

Returns all available auto tag names.

Returns
The tag names mapped to how many plugins of that tag exist.

Reimplemented from PluginDeployer.

◆ getConflictGroups()

std::vector< std::vector< int > > OpenMwPluginDeployer::getConflictGroups ( ) const
overridevirtual

Groups plugins by whether or not they are scrips, groundcover plugins or neither.

Returns
For every group: The plugin IDs part of that group.

Reimplemented from PluginDeployer.

◆ getModActions()

std::vector< std::pair< std::string, std::string > > OpenMwPluginDeployer::getModActions ( ) const
overridevirtual

Returns names and icon names for additional actions which can be applied to a mod.

Returns
The actions.

Reimplemented from Deployer.

◆ getValidModActions()

std::vector< std::vector< int > > OpenMwPluginDeployer::getValidModActions ( ) const
overridevirtual

Returns a vector containing valid mod actions.

Returns
For every mod: IDs of every valid mod_action which is valid for that mod.

Reimplemented from PluginDeployer.

◆ initPluginFile()

bool OpenMwPluginDeployer::initPluginFile ( )
private

Initializes the plugin file, if it does not exist.

Returns
A bool indicating if the plugin file was created.

◆ sortModsByConflicts()

void OpenMwPluginDeployer::sortModsByConflicts ( std::optional< ProgressNode * > progress_node = {})
overridevirtual

Sort mods by into script, groundcover and normal groups.

Parameters
progress_nodeUsed to inform about the current progress.

Reimplemented from PluginDeployer.

◆ supportsModConflicts()

bool OpenMwPluginDeployer::supportsModConflicts ( ) const
overridevirtual

Returns whether or not this deployer type supports showing mod conflicts.

Returns
False.

Reimplemented from Deployer.

◆ unDeploy()

void OpenMwPluginDeployer::unDeploy ( std::optional< ProgressNode * > progress_node = {})
overridevirtual

If no backup exists: Backs up current plugin file, then reloads all plugins.

Parameters
progress_nodeUsed to inform about the current progress.

Reimplemented from Deployer.

◆ updatePluginTags()

void OpenMwPluginDeployer::updatePluginTags ( )
overrideprivatevirtual

Wrapper for updatePluginTagsPrivate.

Implements PluginDeployer.

◆ writePlugins()

void OpenMwPluginDeployer::writePlugins ( ) const
overrideprivatevirtual

Wrapper for writePluginsPrivate.

Reimplemented from PluginDeployer.

◆ writePluginsToOpenMwConfig()

void OpenMwPluginDeployer::writePluginsToOpenMwConfig ( const std::string & line_prefix,
const std::regex & line_regex,
std::function< bool(int)> plugin_filter ) const
private

Writes a subset of plugins to the OpenMW config file.

Parameters
line_prefixPrefix for the line containing the written plugins.
line_regexRegex matched against lines that should be excluded from existing files.
plugin_filterUsed to filter indices in plugins_. Plugins are written when this returns true.

◆ writePluginTags()

void OpenMwPluginDeployer::writePluginTags ( ) const
overrideprivatevirtual

Wrapper for writePluginTagsPrivate.

Reimplemented from PluginDeployer.


The documentation for this class was generated from the following files: