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

Contains all mods and Deployer objects used for one target application. Stores internal state in a JSON file. More...

#include <moddedapplication.h>

Collaboration diagram for ModdedApplication:

Public Member Functions

 ModdedApplication (std::filesystem::path staging_dir, std::string name="", std::string command="", std::filesystem::path icon_path="", std::string app_version="")
 If a JSON settings file already exists in app_mod_dir, it is used to construct this object.
 
void deployMods ()
 Deploys mods using all Deployer objects of this application.
 
void deployModsFor (std::vector< int > deployers)
 Deploys mods using Deployer objects with given ids.
 
void unDeployMods ()
 Undeploys mods for all managed deployers.
 
void unDeployModsFor (std::vector< int > deployers)
 Undeploys mods for the given deployers.
 
void installMod (const AddModInfo &info)
 Installs a new mod using the given Installer type.
 
void uninstallMods (const std::vector< int > &mod_ids, const std::string &installer_type="")
 Uninstalls the given mods, this includes deleting all installed files.
 
void changeLoadorder (int deployer, int from_index, int to_index)
 Moves a mod from one position in the load order to another for given Deployer.
 
void addModToDeployer (int deployer, int mod_id, bool update_conflicts=true, std::optional< ProgressNode * > progress_node={})
 Appends a new mod to the load order for given Deployer.
 
void removeModFromDeployer (int deployer, int mod_id, bool update_conflicts=true, std::optional< ProgressNode * > progress_node={})
 Removes a mod from the load order for given Deployer.
 
void setModStatus (int deployer, int mod_id, bool status)
 Enables or disables the given mod in the load order for given Deployer.
 
void addDeployer (const EditDeployerInfo &info)
 Adds a new Deployer of given type.
 
void removeDeployer (int deployer, bool cleanup)
 Removes a Deployer.
 
std::vector< std::string > getDeployerNames () const
 Creates a vector containing the names of all Deployer objects.
 
std::vector< ModInfogetModInfo () const
 Creates a vector containing information about all installed mods, stored in ModInfo objects.
 
std::vector< std::tuple< int, bool > > getLoadorder (int deployer) const
 Getter for the current mod load order of one Deployer.
 
const std::filesystem::path & getStagingDir () const
 Getter for the path to the staging directory. This is where all installed mods are stored.
 
void setStagingDir (std::string staging_dir, bool move_existing)
 Setter for the path to the staging directory. This is where all installed mods are stored.
 
const std::string & name () const
 Getter for the name of this application.
 
void setName (const std::string &newName)
 Setter for the name of this application.
 
int getNumDeployers () const
 Returns the number of Deployer objects for this application.
 
const std::string & getConfigFileName () const
 Getter for the name of the file used to store this objects internal state.
 
void changeModName (int mod_id, const std::string &new_name)
 Changes the name of an installed mod.
 
std::vector< ConflictInfogetFileConflicts (int deployer, int mod_id, bool show_disabled) const
 Checks for file conflicts of given mod with all other mods in the load order for one Deployer.
 
AppInfo getAppInfo () const
 Fills an AppInfo object with information about this object.
 
void addTool (const Tool &tool)
 Adds a new tool to this application.
 
void removeTool (int tool_id)
 Removes a tool.
 
std::vector< ToolgetTools () const
 Getter for the tools of this application.
 
const std::string & command () const
 Getter for the command used to run this application.
 
void setCommand (const std::string &newCommand)
 Setter for the command used to run this application.
 
void editDeployer (int deployer, const EditDeployerInfo &info)
 Used to set type, name and target directory for one deployer.
 
std::unordered_set< int > getModConflicts (int deployer, int mod_id)
 Checks for conflicts with other mods for one Deployer. Two mods are conflicting if they share at least one file.
 
void setProfile (int profile)
 Sets the currently active profile.
 
void addProfile (const EditProfileInfo &info)
 Adds a new profile and optionally copies it's load order from an existing profile.
 
void removeProfile (int profile)
 Removes a profile.
 
std::vector< std::string > getProfileNames () const
 Returns a vector containing the names of all profiles.
 
void editProfile (int profile, const EditProfileInfo &info)
 Used to set the name of a profile.
 
void editTool (int tool_id, const Tool &new_tool)
 Used to replace an existing tool with a new tool.
 
std::tuple< int, std::string, std::string > verifyDeployerDirectories ()
 Checks if files can be deployed.
 
void addModToGroup (int mod_id, int group, std::optional< ProgressNode * > progress_node={})
 Adds a mod to an existing group and makes the mod the active member of that group.
 
void removeModFromGroup (int mod_id, bool update_conflicts=true, std::optional< ProgressNode * > progress_node={})
 Removes a mod from it's group.
 
void createGroup (int first_mod_id, int second_mod_id, std::optional< ProgressNode * > progress_node={})
 Creates a new group containing the two given mods. A group is a set of mods where only one member, the active member, will be deployed.
 
void changeActiveGroupMember (int group, int mod_id, std::optional< ProgressNode * > progress_node={})
 Changes the active member of given group to given mod.
 
void changeModVersion (int mod_id, const std::string &new_version)
 Sets the given mod's version to the given new version.
 
int getNumGroups ()
 Returns the number of groups.
 
bool modHasGroup (int mod_id)
 Checks if given mod belongs to any group.
 
int getModGroup (int mod_id)
 Returns the group to which the given mod belongs.
 
void sortModsByConflicts (int deployer)
 Sorts the load order by grouping mods which contain conflicting files.
 
std::vector< std::vector< int > > getConflictGroups (int deployer)
 Returns the conflicts groups for the current profile of given deployer.
 
void updateModDeployers (const std::vector< int > &mod_ids, const std::vector< bool > &deployers)
 Updates which deployer should manage given mods.
 
std::filesystem::path iconPath () const
 Getter for icon_path_.
 
void setIconPath (const std::filesystem::path &icon_path)
 Setter for icon_path_.
 
void extractArchive (const std::filesystem::path &source, const std::filesystem::path &target)
 Extracts the given archive to the given location.
 
DeployerInfo getDeployerInfo (int deployer)
 Creates DeployerInfo for one Deployer.
 
void setLog (const std::function< void(Log::LogLevel, const std::string &)> &newLog)
 Setter for log callback.
 
void addBackupTarget (const std::filesystem::path &path, const std::string &name, const std::vector< std::string > &backup_names)
 Adds a new target file or directory to be managed by the BackupManager.
 
void removeBackupTarget (int target_id)
 Removes the given backup target by deleting all backups, except for the active one, and all config files.
 
void removeAllBackupTargets ()
 Removes all targets by deleting all backups, except for the active ones, and all config files.
 
void addBackup (int target_id, const std::string &name, int source)
 Adds a new backup for the given target by copying the currently active backup.
 
void removeBackup (int target_id, int backup_id)
 Deletes the given backup for given target.
 
void setActiveBackup (int target_id, int backup_id)
 Changes the currently active backup for the given target.
 
std::vector< BackupTargetgetBackupTargets () const
 Returns a vector containing information about all managed backup targets.
 
void setBackupName (int target_id, int backup_id, const std::string &name)
 Changes the name of the given backup for the given target.
 
void setBackupTargetName (int target_id, const std::string &name)
 Changes the name of the given backup target.
 
void overwriteBackup (int target_id, int source_backup, int dest_backup)
 Deletes all files in the dest backup and replaces them with the files from the source backup.
 
void cleanupFailedInstallation ()
 Performs a cleanup for the previous installation.
 
void setProgressCallback (const std::function< void(float)> &progress_callback)
 Sets the callback function used to inform about the current task's progress.
 
void uninstallGroupMembers (const std::vector< int > &mod_ids)
 Uninstalls all mods which are inactive group members of any group which contains any of the given mods.
 
void addManualTag (const std::string &tag_name)
 Adds a new tag with the given name. Fails if a tag by that name already exists.
 
void removeManualTag (const std::string &tag_name, bool update_map=true)
 Removes the tag with the given name, if it exists.
 
void changeManualTagName (const std::string &old_name, const std::string &new_name, bool update_map=true)
 Changes the name of the given tag to the given new name. Fails if a tag by the given name exists.
 
void addTagsToMods (const std::vector< std::string > &tag_names, const std::vector< int > &mod_ids)
 Adds the given tags to all given mods.
 
void removeTagsFromMods (const std::vector< std::string > &tag_names, const std::vector< int > &mod_ids)
 Removes the given tags from the given mods.
 
void setTagsForMods (const std::vector< std::string > &tag_names, const std::vector< int > mod_ids)
 Sets the tags for all given mods to the given tags.
 
void editManualTags (const std::vector< EditManualTagAction > &actions)
 Performs the given editing actions on the manual tags.
 
void addAutoTag (const std::string &tag_name, const std::string &expression, const std::vector< TagCondition > &conditions, bool update)
 Adds a new auto tag.
 
void addAutoTag (const Json::Value &json_tag, bool update)
 Adds a new auto tag from the given Json object.
 
void removeAutoTag (const std::string &tag_name, bool update)
 Removes the given auto tag.
 
void renameAutoTag (const std::string &old_name, const std::string &new_name, bool update)
 Changes the name of the given auto tag to the given new name. Fails if a tag by the given name exists.
 
void changeAutoTagEvaluator (const std::string &tag_name, const std::string &expression, const std::vector< TagCondition > &conditions, bool update)
 Changes the given tags evaluator according to the given expression and conditions.
 
void editAutoTags (const std::vector< EditAutoTagAction > &actions)
 Performs the given editing actions on the auto tags.
 
void reapplyAutoTags ()
 Reapply all auto tags to all mods.
 
void updateAutoTags (const std::vector< int > mod_ids)
 Reapplies auto tags to the specified mods.
 
void deleteAllData ()
 Deletes all data for this app.
 
void setAppVersion (const std::string &app_version)
 Sets the app version of the currently active profile to the given version.
 
void setModSources (int mod_id, const std::string &local_source, const std::string &remote_source)
 Sets the given mods local and remote sources to the given paths.
 
nexus::Page getNexusPage (int mod_id)
 Fetches data from NexusMods for the given mod.
 
void checkForModUpdates ()
 Checks for updates for all mods.
 
void checkModsForUpdates (const std::vector< int > &mod_ids)
 Checks for updates for mods with the given ids.
 
void suppressUpdateNotification (const std::vector< int > &mod_ids)
 Temporarily disables update notifications for the given mods. This is done by setting the mods remote_update_time to the installation_time.
 
std::string getDownloadUrl (const std::string &nxm_url)
 Generates a download URL from the given NexusMods nxm Url.
 
std::string getDownloadUrlForFile (int nexus_file_id, const std::string &mod_url)
 Generates a download URL from the given NexusMods mod id and file id.
 
std::string getNexusPageUrl (const std::string &nxm_url)
 Generates a NexusMods mod page URL from the given nxm URL.
 
std::string downloadMod (const std::string &url, std::function< void(float)> progress_callback)
 Downloads the file from the given url to staging_dir_ / _download.
 
ExternalChangesInfo getExternalChanges (int deployer)
 Checks if files deployed by the given deployer have been externally overwritten.
 
void keepOrRevertFileModifications (int deployer, const FileChangeChoices &changes_to_keep) const
 Currently only supports hard link deployment. For every given file: Moves the modified file into the source mods directory and links it back in, if the changes are to be kept. Else: Deletes that file and restores the original link.
 
void fixInvalidHardLinkDeployers ()
 For all deployers: If using hard links that can't be created, switch to sym links.
 
void exportConfiguration (const std::vector< int > &deployers, const std::vector< std::string > &auto_tags)
 Exports configurations for the given deployers and the given auto tags to a json file. Does not include mods.
 
void updateIgnoredFiles (int deployer)
 Updates the file ignore list for ReverseDeployers.
 
void addModToIgnoreList (int deployer, int mod_id)
 Adds the given mod to the ignore list of the given ReverseDeployer.
 
void applyModAction (int deployer, int action, int mod_id)
 Applies the given mod action to the given mod.
 

Static Public Member Functions

static int verifyStagingDir (std::filesystem::path staging_dir)
 Verifies if reading/ writing to the staging directory is possible and if the JSON file containing information about installed mods can be parsed.
 

Static Public Attributes

static const std::string CONFIG_FILE_NAME = "lmm_mods.json"
 Name of the file used to store this objects internal state.
 

Private Member Functions

void updateSettings (bool write=false)
 Updates json_settings_ with the current state of this object.
 
void writeSettings () const
 Writes json_settings_ to a file at app_mod_dir_/CONFIG_FILE_NAME.
 
void readSettings ()
 Reads json_settings_ from a file at app_mod_dir_/CONFIG_FILE_NAME.
 
void updateState (bool read=false)
 Updates the internal state of this object to the state stored in json_settings_.
 
std::string getModName (int mod_id) const
 Returns the name of a mod.
 
void updateDeployerGroups (std::optional< ProgressNode * > progress_node={})
 Updates the load order for every Deployer to reflect the current mod groups.
 
void splitMod (int mod_id, int deployer)
 If given mod contains a sub-directory managed by a deployer that is not the given deployer, creates a new mod which contains that sub-directory.
 
void replaceMod (const AddModInfo &info)
 Replaces an existing mod with the mod specified by the given argument.
 
void updateManualTagMap ()
 Updates manual_tag_map_ with the information contained in manual_tags_.
 
void updateAutoTagMap ()
 Updates auto_tag_map_ with the information contained in auto_tags_.
 
void performUpdateCheck (const std::vector< int > &target_mod_indices)
 Checks for available updates for mods with the given index in installed_mods_.
 
std::string generalizeSteamPath (const std::string &path)
 Checks if the given path belongs to a steam installation or prefix directory. Replaces installation or prefix path components with tokens.
 
void updateSteamIconPath ()
 If the icon path is a steam path: Update it to the new format.
 

Private Attributes

std::string name_
 The name of this application.
 
Json::Value json_settings_
 Contains the internal state of this object.
 
std::filesystem::path staging_dir_
 The path to the staging directory containing all installed mods.
 
std::vector< Modinstalled_mods_
 Contains all currently installed mods.
 
std::vector< std::unique_ptr< Deployer > > deployers_
 Contains every Deployer used by this application.
 
std::vector< Tooltools_
 Contains all tools for this application.
 
std::string command_ = ""
 The command used to run this application.
 
int current_profile_ = 0
 The currently active profile id.
 
std::vector< std::string > profile_names_
 Contains names of all profiles.
 
std::vector< std::vector< int > > groups_
 For every group: A vector containing every mod in that group.
 
std::map< int, int > group_map_
 Maps mods to their groups.
 
std::vector< int > active_group_members_
 Contains the active member of every group.
 
std::map< int, std::string > installer_map_
 Maps mods to the installer used during their installation.
 
std::filesystem::path icon_path_
 Path to this applications icon.
 
std::function< void(Log::LogLevel, const std::string &)> log_
 Callback for logging.
 
BackupManager bak_man_
 Manages all backups for this application.
 
int last_mod_id_ = -1
 Id of the most recently installed mod.
 
std::vector< ManualTagmanual_tags_
 Contains all known manually managed tags.
 
std::map< int, std::vector< std::string > > manual_tag_map_
 Maps mod ids to a vector of manual tags associated with that mod.
 
std::vector< AutoTagauto_tags_
 Contains all known auto tags.
 
std::map< int, std::vector< std::string > > auto_tag_map_
 Maps mod ids to a vector of auto tags associated with that mod.
 
std::vector< std::string > app_versions_
 For every profile: The version of the app managed by that profile.
 
std::function< void(float)> progress_callback_ = [](float f) {}
 Callback used to inform about the current task's progress.
 
std::string download_dir_ = "_download"
 The subdirectory used to store downloads.
 
std::string export_file_name = "exported_config"
 File name used to store exported deployers and auto tags.
 

Detailed Description

Contains all mods and Deployer objects used for one target application. Stores internal state in a JSON file.

Constructor & Destructor Documentation

◆ ModdedApplication()

ModdedApplication::ModdedApplication ( std::filesystem::path staging_dir,
std::string name = "",
std::string command = "",
std::filesystem::path icon_path = "",
std::string app_version = "" )

If a JSON settings file already exists in app_mod_dir, it is used to construct this object.

Parameters
staging_dirPath to staging directory where all installed mods are stored.
nameName of target application.
commandCommand used to run target application.
icon_pathPath to an icon for this application.
Exceptions
Json::LogicErrorIndicates a logic error, e.g. trying to convert "123" to a bool, while parsing.
Json::RuntimeErrorIndicates a syntax error in the JSON file.
ParseErrorIndicates a semantic error while parsing the JSON file, e.g. the active member of a group is not part of that group.

Member Function Documentation

◆ addAutoTag() [1/2]

void ModdedApplication::addAutoTag ( const Json::Value & json_tag,
bool update )

Adds a new auto tag from the given Json object.

Parameters
json_tagJson object representing the new auto tag.
updateIf true: Update the auto tag map and the settings.
Exceptions
std::runtime_errorIf a tag by that name exists.

◆ addAutoTag() [2/2]

void ModdedApplication::addAutoTag ( const std::string & tag_name,
const std::string & expression,
const std::vector< TagCondition > & conditions,
bool update )

Adds a new auto tag.

Parameters
nameThe new tags name.
expressionExpression used for the new tags evaluator.
conditionsConditions used for the new tags evaluator.
updateIf true: Update the auto tag map and the settings.
Exceptions
std::runtime_errorIf a tag by that name exists.

◆ addBackup()

void ModdedApplication::addBackup ( int target_id,
const std::string & name,
int source )

Adds a new backup for the given target by copying the currently active backup.

Parameters
target_idTarget for which to create a new backup.
nameDisplay name for the new backup.
sourceBackup from which to copy files to create the new backup. If -1: copy currently active backup.

◆ addBackupTarget()

void ModdedApplication::addBackupTarget ( const std::filesystem::path & path,
const std::string & name,
const std::vector< std::string > & backup_names )

Adds a new target file or directory to be managed by the BackupManager.

Parameters
pathPath to the target file or directory.
nameDisplay name for this target.
backup_namesDisplay names for initial backups. Must contain at least one.

◆ addDeployer()

void ModdedApplication::addDeployer ( const EditDeployerInfo & info)

Adds a new Deployer of given type.

Parameters
infoContains all data needed to create a deployer, e.g. its name.

◆ addManualTag()

void ModdedApplication::addManualTag ( const std::string & tag_name)

Adds a new tag with the given name. Fails if a tag by that name already exists.

Parameters
tag_nameName for the new tag.
Exceptions
std::runtime_errorIf a tag by that name exists.

◆ addModToDeployer()

void ModdedApplication::addModToDeployer ( int deployer,
int mod_id,
bool update_conflicts = true,
std::optional< ProgressNode * > progress_node = {} )

Appends a new mod to the load order for given Deployer.

Parameters
deployerThe target Deployer
mod_idId of the mod to be added.
update_conflictsUpdates the target deployers conflict groups only if this is true.
progress_nodeUsed to inform about the current progress.

◆ addModToGroup()

void ModdedApplication::addModToGroup ( int mod_id,
int group,
std::optional< ProgressNode * > progress_node = {} )

Adds a mod to an existing group and makes the mod the active member of that group.

Parameters
mod_idThe mod's id.
groupThe target group.
progress_nodeUsed to inform about the current progress.

◆ addModToIgnoreList()

void ModdedApplication::addModToIgnoreList ( int deployer,
int mod_id )

Adds the given mod to the ignore list of the given ReverseDeployer.

Parameters
deployerTarget deployer.
mod_idMod to be ignored.

◆ addProfile()

void ModdedApplication::addProfile ( const EditProfileInfo & info)

Adds a new profile and optionally copies it's load order from an existing profile.

Parameters
infoContains the data for the new profile.

◆ addTagsToMods()

void ModdedApplication::addTagsToMods ( const std::vector< std::string > & tag_names,
const std::vector< int > & mod_ids )

Adds the given tags to all given mods.

Parameters
tag_nameTarget tags name.
mod_idsTarget mod ids.

◆ addTool()

void ModdedApplication::addTool ( const Tool & tool)

Adds a new tool to this application.

Parameters
toolThe new tool.

◆ applyModAction()

void ModdedApplication::applyModAction ( int deployer,
int action,
int mod_id )

Applies the given mod action to the given mod.

Parameters
deployerTarget deployer.
actionAction to be applied.
mod_idTarget mod.

◆ changeActiveGroupMember()

void ModdedApplication::changeActiveGroupMember ( int group,
int mod_id,
std::optional< ProgressNode * > progress_node = {} )

Changes the active member of given group to given mod.

Parameters
groupTarget group.
mod_idThe new active member.
progress_nodeUsed to inform about the current progress.

◆ changeAutoTagEvaluator()

void ModdedApplication::changeAutoTagEvaluator ( const std::string & tag_name,
const std::string & expression,
const std::vector< TagCondition > & conditions,
bool update )

Changes the given tags evaluator according to the given expression and conditions.

Parameters
tag_nameTarget auto tag.
expressionNew expression to be used.
conditionsConditions for the new expression.
updateIf true: Update the auto tag map.

◆ changeLoadorder()

void ModdedApplication::changeLoadorder ( int deployer,
int from_index,
int to_index )

Moves a mod from one position in the load order to another for given Deployer.

Parameters
deployerThe target Deployer.
from_indexIndex of mod to be moved.
to_indexDestination index.

◆ changeManualTagName()

void ModdedApplication::changeManualTagName ( const std::string & old_name,
const std::string & new_name,
bool update_map = true )

Changes the name of the given tag to the given new name. Fails if a tag by the given name exists.

Parameters
old_nameName of the target tag.
new_nameTarget tags new name.
update_mapIf true: Update the manual tag map.
Exceptions
std::runtime_errorIf a tag with the given new_name exists.

◆ changeModName()

void ModdedApplication::changeModName ( int mod_id,
const std::string & new_name )

Changes the name of an installed mod.

Parameters
mod_idId of the target mod.
new_nameThe new name.

◆ changeModVersion()

void ModdedApplication::changeModVersion ( int mod_id,
const std::string & new_version )

Sets the given mod's version to the given new version.

Parameters
mod_idTarget mod.
new_versionThe new version.

◆ checkModsForUpdates()

void ModdedApplication::checkModsForUpdates ( const std::vector< int > & mod_ids)

Checks for updates for mods with the given ids.

Parameters
mod_idsIds of the mods for which to check for updates.

◆ command()

const std::string & ModdedApplication::command ( ) const

Getter for the command used to run this application.

Returns
The command.

◆ createGroup()

void ModdedApplication::createGroup ( int first_mod_id,
int second_mod_id,
std::optional< ProgressNode * > progress_node = {} )

Creates a new group containing the two given mods. A group is a set of mods where only one member, the active member, will be deployed.

Parameters
first_mod_idFirst mod. This will be the active member of the new group.
second_mod_idSecond mod.
progress_nodeUsed to inform about the current progress.

◆ deployModsFor()

void ModdedApplication::deployModsFor ( std::vector< int > deployers)

Deploys mods using Deployer objects with given ids.

Parameters
deployersThe Deployer ids used for deployment.

◆ downloadMod()

std::string ModdedApplication::downloadMod ( const std::string & url,
std::function< void(float)> progress_callback )

Downloads the file from the given url to staging_dir_ / _download.

Parameters
urlUrl from which to download the file.
Returns
The path to the downloaded file.

◆ editAutoTags()

void ModdedApplication::editAutoTags ( const std::vector< EditAutoTagAction > & actions)

Performs the given editing actions on the auto tags.

Parameters
actionsEditing actions.

◆ editDeployer()

void ModdedApplication::editDeployer ( int deployer,
const EditDeployerInfo & info )

Used to set type, name and target directory for one deployer.

Parameters
deployerTarget Deployer.
infoContains all data needed to edit a deployer, e.g. its new name.

◆ editManualTags()

void ModdedApplication::editManualTags ( const std::vector< EditManualTagAction > & actions)

Performs the given editing actions on the manual tags.

Parameters
actionsEditing actions.

◆ editProfile()

void ModdedApplication::editProfile ( int profile,
const EditProfileInfo & info )

Used to set the name of a profile.

Parameters
profileTarget Profile
infoContains the new profile data.

◆ editTool()

void ModdedApplication::editTool ( int tool_id,
const Tool & new_tool )

Used to replace an existing tool with a new tool.

Parameters
tool_idTarget tool to be replaced.
new_toolThe new tool.

◆ exportConfiguration()

void ModdedApplication::exportConfiguration ( const std::vector< int > & deployers,
const std::vector< std::string > & auto_tags )

Exports configurations for the given deployers and the given auto tags to a json file. Does not include mods.

Parameters
deployersDeployers to export.
auto_tagsAuto tags to export.

◆ extractArchive()

void ModdedApplication::extractArchive ( const std::filesystem::path & source,
const std::filesystem::path & target )

Extracts the given archive to the given location.

Parameters
sourceSource path.
targetExtraction target path.

◆ generalizeSteamPath()

std::string ModdedApplication::generalizeSteamPath ( const std::string & path)
private

Checks if the given path belongs to a steam installation or prefix directory. Replaces installation or prefix path components with tokens.

Parameters
pathPath to check.
Returns
If no steam paths are found: The input path, else: The modified path.

◆ getAppInfo()

AppInfo ModdedApplication::getAppInfo ( ) const

Fills an AppInfo object with information about this object.

Returns
The AppInfo object.

◆ getBackupTargets()

std::vector< BackupTarget > ModdedApplication::getBackupTargets ( ) const

Returns a vector containing information about all managed backup targets.

Returns
The vector.

◆ getConfigFileName()

const std::string & ModdedApplication::getConfigFileName ( ) const

Getter for the name of the file used to store this objects internal state.

Returns
The name.

◆ getConflictGroups()

std::vector< std::vector< int > > ModdedApplication::getConflictGroups ( int deployer)

Returns the conflicts groups for the current profile of given deployer.

Parameters
deployerTarget Deployer.
Returns
The conflict info.

◆ getDeployerInfo()

DeployerInfo ModdedApplication::getDeployerInfo ( int deployer)

Creates DeployerInfo for one Deployer.

Parameters
deployerTarget deployer.

◆ getDeployerNames()

std::vector< std::string > ModdedApplication::getDeployerNames ( ) const

Creates a vector containing the names of all Deployer objects.

Returns
The vector.

◆ getDownloadUrl()

std::string ModdedApplication::getDownloadUrl ( const std::string & nxm_url)

Generates a download URL from the given NexusMods nxm Url.

Parameters
nxm_urlThe nxm URL used.
Returns
The download URL.

◆ getDownloadUrlForFile()

std::string ModdedApplication::getDownloadUrlForFile ( int nexus_file_id,
const std::string & mod_url )

Generates a download URL from the given NexusMods mod id and file id.

Parameters
nexus_file_idFile id of the mod.
mod_urlUrl to the mod page on NexusMods.
Returns
The download URL.

◆ getExternalChanges()

ExternalChangesInfo ModdedApplication::getExternalChanges ( int deployer)

Checks if files deployed by the given deployer have been externally overwritten.

Parameters
deployerDeployer to check.
Returns
Contains data about overwritten files.

◆ getFileConflicts()

std::vector< ConflictInfo > ModdedApplication::getFileConflicts ( int deployer,
int mod_id,
bool show_disabled ) const

Checks for file conflicts of given mod with all other mods in the load order for one Deployer.

Parameters
deployerThe target Deployer
mod_idMod to be checked.
show_disabledIf true: Also check for conflicts with disabled mods.
Returns
A vector with information about conflicts with every other mod.

◆ getLoadorder()

std::vector< std::tuple< int, bool > > ModdedApplication::getLoadorder ( int deployer) const

Getter for the current mod load order of one Deployer.

Parameters
deployerThe target Deployer.
Returns
The load order.

◆ getModConflicts()

std::unordered_set< int > ModdedApplication::getModConflicts ( int deployer,
int mod_id )

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

Parameters
deployerTarget Deployer.
mod_idThe mod to be checked.
Returns
A set of mod ids which conflict with the given mod.

◆ getModGroup()

int ModdedApplication::getModGroup ( int mod_id)

Returns the group to which the given mod belongs.

Parameters
mod_idTarget mod.
Returns
The group, or -1 if the mod has no group.

◆ getModInfo()

std::vector< ModInfo > ModdedApplication::getModInfo ( ) const

Creates a vector containing information about all installed mods, stored in ModInfo objects.

Returns
The vector.

◆ getModName()

std::string ModdedApplication::getModName ( int mod_id) const
private

Returns the name of a mod.

Parameters
mod_idThe mod.
Returns
The name.
Exceptions
Json::LogicErrorIndicates a logic error, e.g. trying to convert "123" to a bool, while parsing.
Json::RuntimeErrorIndicates a syntax error in the JSON file.
ParseErrorIndicates a semantic error while parsing the JSON file, e.g. the active member of a group is not part of that group.

◆ getNexusPage()

nexus::Page ModdedApplication::getNexusPage ( int mod_id)

Fetches data from NexusMods for the given mod.

Parameters
mod_idTarget mod id.
Returns
A Mod object containing all data from NexusMods regarding that mod.

◆ getNexusPageUrl()

std::string ModdedApplication::getNexusPageUrl ( const std::string & nxm_url)

Generates a NexusMods mod page URL from the given nxm URL.

Parameters
nxm_urlThe nxm Url used. This is usually generated through the NexusMods website.
Returns
The NexusMods mod page URL.

◆ getNumDeployers()

int ModdedApplication::getNumDeployers ( ) const

Returns the number of Deployer objects for this application.

Returns
The number of Deployers.

◆ getNumGroups()

int ModdedApplication::getNumGroups ( )

Returns the number of groups.

Returns
The number of groups.

◆ getProfileNames()

std::vector< std::string > ModdedApplication::getProfileNames ( ) const

Returns a vector containing the names of all profiles.

Returns
The vector.

◆ getStagingDir()

const sfs::path & ModdedApplication::getStagingDir ( ) const

Getter for the path to the staging directory. This is where all installed mods are stored.

Returns
The path.

◆ getTools()

std::vector< Tool > ModdedApplication::getTools ( ) const

Getter for the tools of this application.

Returns
A vector of tools.

◆ installMod()

void ModdedApplication::installMod ( const AddModInfo & info)

Installs a new mod using the given Installer type.

Parameters
infoContains all data needed to install the mod.

◆ keepOrRevertFileModifications()

void ModdedApplication::keepOrRevertFileModifications ( int deployer,
const FileChangeChoices & changes_to_keep ) const

Currently only supports hard link deployment. For every given file: Moves the modified file into the source mods directory and links it back in, if the changes are to be kept. Else: Deletes that file and restores the original link.

Parameters
deployerTarget deployer.
changes_to_keepContains paths to modified files, the id of the mod currently responsible for that file and a bool which indicates whether or not changes to that file should be kept.

◆ modHasGroup()

bool ModdedApplication::modHasGroup ( int mod_id)

Checks if given mod belongs to any group.

Parameters
mod_idTarget mod.
Returns
True if mod belongs to a group, else: False.

◆ name()

const std::string & ModdedApplication::name ( ) const

Getter for the name of this application.

Returns
The name.

◆ overwriteBackup()

void ModdedApplication::overwriteBackup ( int target_id,
int source_backup,
int dest_backup )

Deletes all files in the dest backup and replaces them with the files from the source backup.

Parameters
target_idBackup target.
source_backupBackup from which to copy files.
dest_backupTarget for data deletion.

◆ performUpdateCheck()

void ModdedApplication::performUpdateCheck ( const std::vector< int > & target_mod_indices)
private

Checks for available updates for mods with the given index in installed_mods_.

Parameters
target_mod_indicesTarget mod indices.

◆ removeAutoTag()

void ModdedApplication::removeAutoTag ( const std::string & tag_name,
bool update )

Removes the given auto tag.

Parameters
nameTag to be removed.
updateIf true: Update the auto tag map and the settings.

◆ removeBackup()

void ModdedApplication::removeBackup ( int target_id,
int backup_id )

Deletes the given backup for given target.

Parameters
target_idTarget from which to delete a backup.
backup_idBackup to remove.

◆ removeBackupTarget()

void ModdedApplication::removeBackupTarget ( int target_id)

Removes the given backup target by deleting all backups, except for the active one, and all config files.

Parameters
target_idTarget to remove.

◆ removeDeployer()

void ModdedApplication::removeDeployer ( int deployer,
bool cleanup )

Removes a Deployer.

Parameters
deployerThe Deployer.
cleanupIf true: Remove all currently deployed files and restore backups.

◆ removeManualTag()

void ModdedApplication::removeManualTag ( const std::string & tag_name,
bool update_map = true )

Removes the tag with the given name, if it exists.

Parameters
tag_nameTag to be removed.
update_mapIf true: Update the manual tag map.

◆ removeModFromDeployer()

void ModdedApplication::removeModFromDeployer ( int deployer,
int mod_id,
bool update_conflicts = true,
std::optional< ProgressNode * > progress_node = {} )

Removes a mod from the load order for given Deployer.

Parameters
deployerThe target Deployer
mod_idId of the mod to be removed.
update_conflictsUpdates the target deployers conflict groups only if this is true.
progress_nodeUsed to inform about the current progress.

◆ removeModFromGroup()

void ModdedApplication::removeModFromGroup ( int mod_id,
bool update_conflicts = true,
std::optional< ProgressNode * > progress_node = {} )

Removes a mod from it's group.

Parameters
mod_idTarget mod.
update_conflictsIf true: Update relevant conflict groups.
progress_nodeUsed to inform about the current progress.

◆ removeProfile()

void ModdedApplication::removeProfile ( int profile)

Removes a profile.

Parameters
profileThe profile to be removed.

◆ removeTagsFromMods()

void ModdedApplication::removeTagsFromMods ( const std::vector< std::string > & tag_names,
const std::vector< int > & mod_ids )

Removes the given tags from the given mods.

Parameters
tag_nameTarget tags name.
mod_idsTarget mod ids.

◆ removeTool()

void ModdedApplication::removeTool ( int tool_id)

Removes a tool.

Parameters
tool_idThe tool's id.

◆ renameAutoTag()

void ModdedApplication::renameAutoTag ( const std::string & old_name,
const std::string & new_name,
bool update )

Changes the name of the given auto tag to the given new name. Fails if a tag by the given name exists.

Parameters
old_nameName of the target tag.
new_nameTarget tags new name.
updateIf true: Update the auto tag map.
Exceptions
std::runtime_errorIf a tag with the given new_name exists.

◆ replaceMod()

void ModdedApplication::replaceMod ( const AddModInfo & info)
private

Replaces an existing mod with the mod specified by the given argument.

Parameters
infoContains all data needed to install the mod.

◆ setActiveBackup()

void ModdedApplication::setActiveBackup ( int target_id,
int backup_id )

Changes the currently active backup for the given target.

Parameters
target_idTarget for which to change the active backup.
backup_idNew active backup.

◆ setAppVersion()

void ModdedApplication::setAppVersion ( const std::string & app_version)

Sets the app version of the currently active profile to the given version.

Parameters
app_versionThe new app version.

◆ setBackupName()

void ModdedApplication::setBackupName ( int target_id,
int backup_id,
const std::string & name )

Changes the name of the given backup for the given target.

Parameters
target_idBackup target.
backup_idBackup to be edited.
nameThe new name.

◆ setBackupTargetName()

void ModdedApplication::setBackupTargetName ( int target_id,
const std::string & name )

Changes the name of the given backup target.

Parameters
target_idBackup target.
nameThe new name.

◆ setCommand()

void ModdedApplication::setCommand ( const std::string & newCommand)

Setter for the command used to run this application.

Parameters
newCommandThe new command.

◆ setIconPath()

void ModdedApplication::setIconPath ( const std::filesystem::path & icon_path)

Setter for icon_path_.

Parameters
icon_pathThe new icon path

◆ setModSources()

void ModdedApplication::setModSources ( int mod_id,
const std::string & local_source,
const std::string & remote_source )

Sets the given mods local and remote sources to the given paths.

Parameters
mod_idTarget mod id.
local_sourcePath to a local archive or directory used for mod installation.
remote_sourceRemote URL from which the mod was downloaded.

◆ setModStatus()

void ModdedApplication::setModStatus ( int deployer,
int mod_id,
bool status )

Enables or disables the given mod in the load order for given Deployer.

Parameters
deployerThe target Deployer
mod_idMod to be edited.
statusThe new status.

◆ setName()

void ModdedApplication::setName ( const std::string & newName)

Setter for the name of this application.

Parameters
newNameThe new name.

◆ setProfile()

void ModdedApplication::setProfile ( int profile)

Sets the currently active profile.

Parameters
profileThe new profile.

◆ setProgressCallback()

void ModdedApplication::setProgressCallback ( const std::function< void(float)> & progress_callback)

Sets the callback function used to inform about the current task's progress.

Parameters
progress_callbackThe function.

◆ setStagingDir()

void ModdedApplication::setStagingDir ( std::string staging_dir,
bool move_existing )

Setter for the path to the staging directory. This is where all installed mods are stored.

Parameters
staging_dirThe new staging directory path.
move_existingIf true: Move all installed mods to the new directory.
Exceptions
Json::LogicErrorIndicates a logic error, e.g. trying to convert "123" to a bool, while parsing.
Json::RuntimeErrorIndicates a syntax error in the JSON file.
ParseErrorIndicates a semantic error while parsing the JSON file, e.g. the active member of a group is not part of that group.

◆ setTagsForMods()

void ModdedApplication::setTagsForMods ( const std::vector< std::string > & tag_names,
const std::vector< int > mod_ids )

Sets the tags for all given mods to the given tags.

Parameters
tag_namesNames of the new tags.
mod_idsTarget mod ids.

◆ sortModsByConflicts()

void ModdedApplication::sortModsByConflicts ( int deployer)

Sorts the load order by grouping mods which contain conflicting files.

Parameters
deployerDeployer for which the currently active load order is to be sorted.

◆ splitMod()

void ModdedApplication::splitMod ( int mod_id,
int deployer )
private

If given mod contains a sub-directory managed by a deployer that is not the given deployer, creates a new mod which contains that sub-directory.

Parameters
mod_idMod to check.
deployerDeployer which currently manages the given mod.

◆ suppressUpdateNotification()

void ModdedApplication::suppressUpdateNotification ( const std::vector< int > & mod_ids)

Temporarily disables update notifications for the given mods. This is done by setting the mods remote_update_time to the installation_time.

Parameters
mod_idsIds of the mods for which update notifications are to be disabled.

◆ unDeployModsFor()

void ModdedApplication::unDeployModsFor ( std::vector< int > deployers)

Undeploys mods for the given deployers.

Parameters
deployersTarget deployers.

◆ uninstallGroupMembers()

void ModdedApplication::uninstallGroupMembers ( const std::vector< int > & mod_ids)

Uninstalls all mods which are inactive group members of any group which contains any of the given mods.

Parameters
mod_idsIds of the mods for which to uninstall group members.

◆ uninstallMods()

void ModdedApplication::uninstallMods ( const std::vector< int > & mod_ids,
const std::string & installer_type = "" )

Uninstalls the given mods, this includes deleting all installed files.

Parameters
mod_idIds of the mods to be uninstalled.
installer_typeThe Installer type used. If an empty string is given, the Installer used during installation is used.

◆ updateAutoTags()

void ModdedApplication::updateAutoTags ( const std::vector< int > mod_ids)

Reapplies auto tags to the specified mods.

Parameters
mod_idsMods to which auto tags are to be reapplied.

◆ updateDeployerGroups()

void ModdedApplication::updateDeployerGroups ( std::optional< ProgressNode * > progress_node = {})
private

Updates the load order for every Deployer to reflect the current mod groups.

Parameters
progress_nodeUsed to inform about the current progress.

◆ updateIgnoredFiles()

void ModdedApplication::updateIgnoredFiles ( int deployer)

Updates the file ignore list for ReverseDeployers.

Parameters
deployerTarget deployer.

◆ updateModDeployers()

void ModdedApplication::updateModDeployers ( const std::vector< int > & mod_ids,
const std::vector< bool > & deployers )

Updates which deployer should manage given mods.

Parameters
mod_idVector of mod ids to be added.
deployersBool for every deployer, indicating if the mods should be managed by that deployer.

◆ updateSettings()

void ModdedApplication::updateSettings ( bool write = false)
private

Updates json_settings_ with the current state of this object.

Parameters
writeIf true: write json_settings_ to a file after updating.

◆ updateState()

void ModdedApplication::updateState ( bool read = false)
private

Updates the internal state of this object to the state stored in json_settings_.

Parameters
readIf true: Read json_settings_ from a file before updating.

◆ verifyDeployerDirectories()

std::tuple< int, std::string, std::string > ModdedApplication::verifyDeployerDirectories ( )

Checks if files can be deployed.

Returns
A tuple containing: A return code: 0: No error, 1: Error while writing to a deployer's source directory, 2: Error while creating a hard link, 3: Error while writing to a deployer's target directory. The deployer's target path (if an error occured, else ""). A more detailed error message (if an error occured, else "").

◆ verifyStagingDir()

int ModdedApplication::verifyStagingDir ( std::filesystem::path staging_dir)
static

Verifies if reading/ writing to the staging directory is possible and if the JSON file containing information about installed mods can be parsed.

Parameters
staging_dirPath to the staging directory.
Returns
A code indicating success(0), an IO error(1) or an error during JSON parsing(2).

Member Data Documentation

◆ app_versions_

std::vector<std::string> ModdedApplication::app_versions_
private

For every profile: The version of the app managed by that profile.

This does not refer to a ModdedApplication object but rather the actually modded application.

◆ log_

std::function<void(Log::LogLevel, const std::string&)> ModdedApplication::log_
private
Initial value:
const std::string& b) {}
LogLevel
Represents the importance of a log message.
Definition log.h:19

Callback for logging.


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