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

Autonomous Deployer which handles plugins for Fallout 3, Fallout 4, Fallout New Vegas, Fallout 4 VR, Starfield, Morrowind, Oblivion, Skyrim, Skyrim SE and Skyrim VR. More...

#include <lootdeployer.h>

Inheritance diagram for LootDeployer:
Collaboration diagram for LootDeployer:

Public Member Functions

 LootDeployer (const std::filesystem::path &source_path, const std::filesystem::path &dest_path, const std::string &name, bool init_tags=true, bool perform_init=true)
 Loads plugins and identifies the app type to be managed.
 
virtual void unDeploy (std::optional< ProgressNode * > progress_node={}) override
 If no backup exists: Backs up current plugin file, then reloads all plugins.
 
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 loadorder.txt and plugin.txt to the ones saved in the new profile.
 
virtual std::unordered_set< int > getModConflicts (int mod_id, std::optional< ProgressNode * > progress_node={}) override
 Checks for conflicts with other mods. Two mods are conflicting if they share at least one record.
 
virtual void sortModsByConflicts (std::optional< ProgressNode * > progress_node={}) override
 Sorts the current load order using LOOT. Uses a masterlist.yaml appropriate for the game managed by this deployer and optionally a userlist.yaml in the target directory. Saves the new load order to disk after sorting.
 
virtual void cleanup () override
 Deletes the config file and all profile files.
 
virtual std::map< std::string, int > getAutoTagMap () override
 Returns all available auto tag names.
 
- 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::vector< int > > getConflictGroups () const override
 Conflict groups are not supported by this type.
 
virtual std::vector< std::string > getModNames () const override
 Generates a vector of names for every plugin.
 
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::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.
 
virtual std::vector< std::vector< int > > getValidModActions () const override
 Returns a vector containing valid mod actions.
 
- 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.
 
virtual bool supportsModConflicts () const
 Returns whether or not this deployer type supports showing mod conflicts.
 
virtual std::vector< std::pair< std::string, std::string > > getModActions () const
 Returns names and icon names for additional actions which can be applied to a mod.
 
virtual void applyModAction (int action, int mod_id)
 Applies the given mod action to the given mod.
 

Static Public Attributes

static const std::map< loot::GameType, std::string > DEFAULT_LIST_URLS
 Maps game type to a URL pointing to the masterlist.yaml for that type.
 
static std::map< loot::GameType, std::string > LIST_URLS
 Has to be initialized with the URLs actually used for downloading masterlists.
 
static const std::string DEFAULT_PRELUDE_URL
 Default URL used to download the masterlist prelude.
 
static std::string PRELUDE_URL
 URL actually used to download the prelude.yaml file. Has to be initialized.
 

Protected Member Functions

virtual void writePlugins () const override
 Writes current load order to plugins.txt and loadorder.txt.
 
virtual void saveSettings () const override
 Saves number of profiles, active profile, list_download_time_ and auto_update_lists_ to the config file.
 
void loadSettings () override
 Wrapper for loadSettingsPrivate.
 
void updateAppType ()
 Identifies the type of game in the source directory using signature files.
 
virtual void updateMasterList ()
 Downloads a new masterlist.yaml, if the current one is older than a day.
 
virtual void resetSettings () override
 Wrapper for resetSettingsPrivate.
 
void setupPluginFiles ()
 Creates plugin.txt and loadorder.txt files if they do not exist.
 
virtual void updatePluginTags () override
 Wrapper for updatePluginTagsPrivate.
 
void readPluginTags ()
 Reads tags_ from disk.
 
virtual void downloadList (std::string url, const std::string &file_name)
 Downloads the file from the given URL and stores it at dest_path_/file_name.
 
virtual void restoreUndeployBackupIfExists () override
 If loadorder and plugin file backups exist, restore them and override the current files.
 
void loadSettingsPrivate ()
 Loads number of profiles, active profile, list_download_time_ and auto_update_lists_ from the config file.
 
void resetSettingsPrivate ()
 Resets all settings to default values.
 
void updatePluginTagsPrivate ()
 Updates the loot plugin tags for every currently loaded plugin.
 
- 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 writePluginTags () const
 Writes the current tags_ to disk.
 
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

std::string app_plugin_file_name_
 Name of the file containing plugin load order, as read by the target app.
 
loot::GameType app_type_
 Type of game to be managed.
 
long list_download_time_ = 0
 Timestamp representing the last time the masterlist.yaml was updated.
 
bool auto_update_lists_ = true
 If true: Automatically download new master lists.
 
int num_light_plugins_ = 0
 Current number of light plugins.
 
int num_master_plugins_ = 0
 Current number of master plugins.
 
int num_standard_plugins_ = 0
 Current number of standard plugins.
 
- 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

static constexpr std::string LOADORDER_FILE_NAME = "loadorder.txt"
 Name of the file containing plugin load order.
 
static const std::map< loot::GameType, std::filesystem::path > TYPE_IDENTIFIERS
 Maps supported game type to a path to a file unique to that type.
 
static constexpr std::string LIGHT_PLUGIN = "Light"
 Name of a light plugin tag.
 
static constexpr std::string MASTER_PLUGIN = "Master"
 Name of a master plugin tag.
 
static constexpr std::string STANDARD_PLUGIN = "Standard"
 Name of a standard plugin tag.
 
static const std::map< loot::GameType, std::string > PLUGIN_FILE_NAMES
 Maps loot game types to the default name used to store plugins.
 
static const std::set< loot::GameType > APP_TYPE_WITH_FILE_MOD_ORDER
 All app types which use file modification times as plugin load order.
 
- 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.
 

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...
 

Detailed Description

Autonomous Deployer which handles plugins for Fallout 3, Fallout 4, Fallout New Vegas, Fallout 4 VR, Starfield, Morrowind, Oblivion, Skyrim, Skyrim SE and Skyrim VR.

Constructor & Destructor Documentation

◆ LootDeployer()

LootDeployer::LootDeployer ( const std::filesystem::path & source_path,
const std::filesystem::path & dest_path,
const std::string & name,
bool init_tags = true,
bool perform_init = true )

Loads plugins and identifies the app type to be managed.

Parameters
source_pathPath to the directory containing installed plugins.
dest_pathPath to the directory containing plugins.txt and loadorder.txt.
nameA custom name for this instance.
init_tagsIf true: Initializes plugin tags. Disable this for testing purposes with invalid plugin files
perform_initIf true: Perform initialization.

Member Function Documentation

◆ addProfile()

void LootDeployer::addProfile ( int source = -1)
overridevirtual

Adds a new profile and optionally copies it's load order from an existing profile. Profiles are stored in the target directory.

Parameters
sourceThe profile to be copied. A value of -1 indicates no copy.

Reimplemented from PluginDeployer.

◆ cleanup()

void LootDeployer::cleanup ( )
overridevirtual

Deletes the config file and all profile files.

Reimplemented from PluginDeployer.

◆ getAutoTagMap()

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

Returns all available auto tag names.

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

Reimplemented from PluginDeployer.

◆ getModConflicts()

std::unordered_set< int > LootDeployer::getModConflicts ( int mod_id,
std::optional< ProgressNode * > progress_node = {} )
overridevirtual

Checks for conflicts with other mods. Two mods are conflicting if they share at least one record.

Parameters
mod_idThe mod to be checked.
progress_nodeUsed to inform about the current progress.
Returns
A set of mod ids which conflict with the given mod.

Reimplemented from PluginDeployer.

◆ loadSettings()

void LootDeployer::loadSettings ( )
overrideprotectedvirtual

Wrapper for loadSettingsPrivate.

Reimplemented from PluginDeployer.

◆ removeProfile()

void LootDeployer::removeProfile ( int profile)
overridevirtual

Removes a profile.

Parameters
profileThe profile to be removed.

Reimplemented from PluginDeployer.

◆ resetSettings()

void LootDeployer::resetSettings ( )
overrideprotectedvirtual

Wrapper for resetSettingsPrivate.

Reimplemented from PluginDeployer.

◆ restoreUndeployBackupIfExists()

void LootDeployer::restoreUndeployBackupIfExists ( )
overrideprotectedvirtual

If loadorder and plugin file backups exist, restore them and override the current files.

Reimplemented from PluginDeployer.

◆ saveSettings()

void LootDeployer::saveSettings ( ) const
overrideprotectedvirtual

Saves number of profiles, active profile, list_download_time_ and auto_update_lists_ to the config file.

Reimplemented from PluginDeployer.

◆ setProfile()

void LootDeployer::setProfile ( int profile)
overridevirtual

Setter for the active profile. Changes the currently active loadorder.txt and plugin.txt to the ones saved in the new profile.

Parameters
profileThe new profile.

Reimplemented from PluginDeployer.

◆ sortModsByConflicts()

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

Sorts the current load order using LOOT. Uses a masterlist.yaml appropriate for the game managed by this deployer and optionally a userlist.yaml in the target directory. Saves the new load order to disk after sorting.

Parameters
progress_nodeUsed to inform about the current progress.

Reimplemented from PluginDeployer.

◆ unDeploy()

void LootDeployer::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 LootDeployer::updatePluginTags ( )
overrideprotectedvirtual

Wrapper for updatePluginTagsPrivate.

Implements PluginDeployer.

◆ writePlugins()

void LootDeployer::writePlugins ( ) const
overrideprotectedvirtual

Writes current load order to plugins.txt and loadorder.txt.

Reimplemented from PluginDeployer.

Member Data Documentation

◆ APP_TYPE_WITH_FILE_MOD_ORDER

const std::set<loot::GameType> LootDeployer::APP_TYPE_WITH_FILE_MOD_ORDER
inlinestaticprotected
Initial value:
= {
loot::GameType::fo3,
loot::GameType::fonv,
loot::GameType::tes4
}

All app types which use file modification times as plugin load order.

◆ DEFAULT_LIST_URLS

const std::map<loot::GameType, std::string> LootDeployer::DEFAULT_LIST_URLS
inlinestatic
Initial value:
= {
{ loot::GameType::fo3,
"https://raw.githubusercontent.com/loot/fallout3/v0.21/masterlist.yaml" },
{ loot::GameType::fo4,
"https://raw.githubusercontent.com/loot/fallout4/v0.21/masterlist.yaml" },
{ loot::GameType::fo4vr,
"https://raw.githubusercontent.com/loot/fallout4vr/v0.21/masterlist.yaml" },
{ loot::GameType::fonv,
"https://raw.githubusercontent.com/loot/falloutnv/v0.21/masterlist.yaml" },
{ loot::GameType::starfield,
"https://raw.githubusercontent.com/loot/starfield/v0.21/masterlist.yaml" },
{ loot::GameType::tes3,
"https://raw.githubusercontent.com/loot/morrowind/v0.21/masterlist.yaml" },
{ loot::GameType::tes4,
"https://raw.githubusercontent.com/loot/oblivion/v0.21/masterlist.yaml" },
{ loot::GameType::tes5, "https://raw.githubusercontent.com/loot/skyrim/v0.21/masterlist.yaml" },
{ loot::GameType::tes5se,
"https://raw.githubusercontent.com/loot/skyrimse/v0.21/masterlist.yaml" },
{ loot::GameType::tes5vr,
"https://raw.githubusercontent.com/loot/skyrimvr/v0.21/masterlist.yaml" }
}

Maps game type to a URL pointing to the masterlist.yaml for that type.

◆ DEFAULT_PRELUDE_URL

const std::string LootDeployer::DEFAULT_PRELUDE_URL
inlinestatic
Initial value:
=
"https://raw.githubusercontent.com/loot/prelude/v0.21/prelude.yaml"

Default URL used to download the masterlist prelude.

◆ PLUGIN_FILE_NAMES

const std::map<loot::GameType, std::string> LootDeployer::PLUGIN_FILE_NAMES
inlinestaticprotected
Initial value:
= {
{ loot::GameType::fo3, "plugins.txt" }, { loot::GameType::fo4, "plugins.txt" },
{ loot::GameType::fo4vr, "plugins.txt" }, { loot::GameType::fonv, "plugins.txt" },
{ loot::GameType::starfield, "plugins.txt" }, { loot::GameType::tes3, "plugins.txt" },
{ loot::GameType::tes4, "Plugins.txt" }, { loot::GameType::tes5, "plugins.txt" },
{ loot::GameType::tes5se, "plugins.txt" }, { loot::GameType::tes5vr, "plugins.txt" }
}

Maps loot game types to the default name used to store plugins.

◆ TYPE_IDENTIFIERS

const std::map<loot::GameType, std::filesystem::path> LootDeployer::TYPE_IDENTIFIERS
inlinestaticprotected
Initial value:
= {
{ loot::GameType::fo3, "Fallout3.esm" },
{ loot::GameType::fo4, "Fallout4.esm" },
{ loot::GameType::fo4vr, "Fallout4_VR.esm" },
{ loot::GameType::fonv, "FalloutNV.esm" },
{ loot::GameType::starfield, "Starfield.esm" },
{ loot::GameType::tes3, "Morrowind.esm" },
{ loot::GameType::tes4, "Oblivion.esm" },
{ loot::GameType::tes5, std::filesystem::path("..") / "TESV.exe" },
{ loot::GameType::tes5se, std::filesystem::path("..") / "SkyrimSE.exe" },
{ loot::GameType::tes5vr, "SkyrimVR.esm" }
}

Maps supported game type to a path to a file unique to that type.


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