Limo
A simple mod manager
Loading...
Searching...
No Matches
lootdeployer.h
Go to the documentation of this file.
1
5#pragma once
6
7#include "deployer.h"
8#include "loot/api.h"
9#include "plugindeployer.h"
10#include <json/json.h>
11
12
19{
20public:
30 LootDeployer(const std::filesystem::path& source_path,
31 const std::filesystem::path& dest_path,
32 const std::string& name,
33 bool init_tags = true,
34 bool perform_init = true);
35
37 static inline const std::map<loot::GameType, std::string> DEFAULT_LIST_URLS = {
38 { loot::GameType::fo3,
39 "https://raw.githubusercontent.com/loot/fallout3/v0.21/masterlist.yaml" },
40 { loot::GameType::fo4,
41 "https://raw.githubusercontent.com/loot/fallout4/v0.21/masterlist.yaml" },
42 { loot::GameType::fo4vr,
43 "https://raw.githubusercontent.com/loot/fallout4vr/v0.21/masterlist.yaml" },
44 { loot::GameType::fonv,
45 "https://raw.githubusercontent.com/loot/falloutnv/v0.21/masterlist.yaml" },
46 { loot::GameType::starfield,
47 "https://raw.githubusercontent.com/loot/starfield/v0.21/masterlist.yaml" },
48 { loot::GameType::tes3,
49 "https://raw.githubusercontent.com/loot/morrowind/v0.21/masterlist.yaml" },
50 { loot::GameType::tes4,
51 "https://raw.githubusercontent.com/loot/oblivion/v0.21/masterlist.yaml" },
52 { loot::GameType::tes5, "https://raw.githubusercontent.com/loot/skyrim/v0.21/masterlist.yaml" },
53 { loot::GameType::tes5se,
54 "https://raw.githubusercontent.com/loot/skyrimse/v0.21/masterlist.yaml" },
55 { loot::GameType::tes5vr,
56 "https://raw.githubusercontent.com/loot/skyrimvr/v0.21/masterlist.yaml" }
57 };
58
59 static inline std::map<loot::GameType, std::string> LIST_URLS;
61 static inline const std::string DEFAULT_PRELUDE_URL =
62 "https://raw.githubusercontent.com/loot/prelude/v0.21/prelude.yaml";
64 static inline std::string PRELUDE_URL;
65
70 virtual void unDeploy(std::optional<ProgressNode*> progress_node = {}) override;
76 virtual void addProfile(int source = -1) override;
81 virtual void removeProfile(int profile) override;
87 virtual void setProfile(int profile) override;
95 virtual std::unordered_set<int> getModConflicts(
96 int mod_id,
97 std::optional<ProgressNode*> progress_node = {}) override;
104 virtual void sortModsByConflicts(std::optional<ProgressNode*> progress_node = {}) override;
106 virtual void cleanup() override;
111 virtual std::map<std::string, int> getAutoTagMap() override;
112
113protected:
115 static constexpr std::string LOADORDER_FILE_NAME = "loadorder.txt";
117 static inline const std::map<loot::GameType, std::filesystem::path> TYPE_IDENTIFIERS = {
118 { loot::GameType::fo3, "Fallout3.esm" },
119 { loot::GameType::fo4, "Fallout4.esm" },
120 { loot::GameType::fo4vr, "Fallout4_VR.esm" },
121 { loot::GameType::fonv, "FalloutNV.esm" },
122 { loot::GameType::starfield, "Starfield.esm" },
123 { loot::GameType::tes3, "Morrowind.esm" },
124 { loot::GameType::tes4, "Oblivion.esm" },
125 { loot::GameType::tes5, std::filesystem::path("..") / "TESV.exe" },
126 { loot::GameType::tes5se, std::filesystem::path("..") / "SkyrimSE.exe" },
127 { loot::GameType::tes5vr, "SkyrimVR.esm" }
128 };
129
130 static constexpr std::string LIGHT_PLUGIN = "Light";
132 static constexpr std::string MASTER_PLUGIN = "Master";
134 static constexpr std::string STANDARD_PLUGIN = "Standard";
136 static inline const std::map<loot::GameType, std::string> PLUGIN_FILE_NAMES = {
137 { loot::GameType::fo3, "plugins.txt" }, { loot::GameType::fo4, "plugins.txt" },
138 { loot::GameType::fo4vr, "plugins.txt" }, { loot::GameType::fonv, "plugins.txt" },
139 { loot::GameType::starfield, "plugins.txt" }, { loot::GameType::tes3, "plugins.txt" },
140 { loot::GameType::tes4, "Plugins.txt" }, { loot::GameType::tes5, "plugins.txt" },
141 { loot::GameType::tes5se, "plugins.txt" }, { loot::GameType::tes5vr, "plugins.txt" }
142 };
143
144 static inline const std::set<loot::GameType> APP_TYPE_WITH_FILE_MOD_ORDER = {
145 loot::GameType::fo3,
146 loot::GameType::fonv,
147 loot::GameType::tes4
148 };
149
153 loot::GameType app_type_;
164
166 virtual void writePlugins() const override;
171 virtual void saveSettings() const override;
173 void loadSettings() override;
175 void updateAppType();
177 virtual void updateMasterList();
179 virtual void resetSettings() override;
181 void setupPluginFiles();
183 virtual void updatePluginTags() override;
185 void readPluginTags();
187 virtual void downloadList(std::string url, const std::string& file_name);
189 virtual void restoreUndeployBackupIfExists() override;
194 void loadSettingsPrivate();
199};
void updateAppType()
Identifies the type of game in the source directory using signature files.
Definition lootdeployer.cpp:337
void setupPluginFiles()
Creates plugin.txt and loadorder.txt files if they do not exist.
Definition lootdeployer.cpp:387
static constexpr std::string MASTER_PLUGIN
Name of a master plugin tag.
Definition lootdeployer.h:132
static std::map< loot::GameType, std::string > LIST_URLS
Has to be initialized with the URLs actually used for downloading masterlists.
Definition lootdeployer.h:59
long list_download_time_
Timestamp representing the last time the masterlist.yaml was updated.
Definition lootdeployer.h:155
static constexpr std::string LOADORDER_FILE_NAME
Name of the file containing plugin load order.
Definition lootdeployer.h:115
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.
Definition lootdeployer.cpp:436
void readPluginTags()
Reads tags_ from disk.
Definition lootdeployer.cpp:399
std::string app_plugin_file_name_
Name of the file containing plugin load order, as read by the target app.
Definition lootdeployer.h:151
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.
Definition lootdeployer.h:117
static constexpr std::string LIGHT_PLUGIN
Name of a light plugin tag.
Definition lootdeployer.h:130
virtual void writePlugins() const override
Writes current load order to plugins.txt and loadorder.txt.
Definition lootdeployer.cpp:279
virtual std::map< std::string, int > getAutoTagMap() override
Returns all available auto tag names.
Definition lootdeployer.cpp:272
void loadSettings() override
Wrapper for loadSettingsPrivate.
Definition lootdeployer.cpp:332
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.
Definition lootdeployer.cpp:16
virtual void cleanup() override
Deletes the config file and all profile files.
Definition lootdeployer.cpp:257
static const std::set< loot::GameType > APP_TYPE_WITH_FILE_MOD_ORDER
All app types which use file modification times as plugin load order.
Definition lootdeployer.h:144
void updatePluginTagsPrivate()
Updates the loot plugin tags for every currently loaded plugin.
Definition lootdeployer.cpp:523
static std::string PRELUDE_URL
URL actually used to download the prelude.yaml file. Has to be initialized.
Definition lootdeployer.h:64
bool auto_update_lists_
If true: Automatically download new master lists.
Definition lootdeployer.h:157
void resetSettingsPrivate()
Resets all settings to default values.
Definition lootdeployer.cpp:515
static constexpr std::string STANDARD_PLUGIN
Name of a standard plugin tag.
Definition lootdeployer.h:134
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.
Definition lootdeployer.h:37
virtual void updateMasterList()
Downloads a new masterlist.yaml, if the current one is older than a day.
Definition lootdeployer.cpp:363
int num_master_plugins_
Current number of master plugins.
Definition lootdeployer.h:161
virtual void saveSettings() const override
Saves number of profiles, active profile, list_download_time_ and auto_update_lists_ to the config fi...
Definition lootdeployer.cpp:317
virtual void addProfile(int source=-1) override
Adds a new profile and optionally copies it's load order from an existing profile....
Definition lootdeployer.cpp:66
virtual void removeProfile(int profile) override
Removes a profile.
Definition lootdeployer.cpp:94
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.
Definition lootdeployer.cpp:138
int num_standard_plugins_
Current number of standard plugins.
Definition lootdeployer.h:163
loot::GameType app_type_
Type of game to be managed.
Definition lootdeployer.h:153
virtual void setProfile(int profile) override
Setter for the active profile. Changes the currently active loadorder.txt and plugin....
Definition lootdeployer.cpp:110
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 t...
Definition lootdeployer.cpp:159
virtual void resetSettings() override
Wrapper for resetSettingsPrivate.
Definition lootdeployer.cpp:382
virtual void unDeploy(std::optional< ProgressNode * > progress_node={}) override
If no backup exists: Backs up current plugin file, then reloads all plugins.
Definition lootdeployer.cpp:45
static const std::string DEFAULT_PRELUDE_URL
Default URL used to download the masterlist prelude.
Definition lootdeployer.h:61
int num_light_plugins_
Current number of light plugins.
Definition lootdeployer.h:159
static const std::map< loot::GameType, std::string > PLUGIN_FILE_NAMES
Maps loot game types to the default name used to store plugins.
Definition lootdeployer.h:136
virtual void restoreUndeployBackupIfExists() override
If loadorder and plugin file backups exist, restore them and override the current files.
Definition lootdeployer.cpp:465
void loadSettingsPrivate()
Loads number of profiles, active profile, list_download_time_ and auto_update_lists_ from the config ...
Definition lootdeployer.cpp:486
virtual void updatePluginTags() override
Wrapper for updatePluginTagsPrivate.
Definition lootdeployer.cpp:394
PluginDeployer(const std::filesystem::path &source_path, const std::filesystem::path &dest_path, const std::string &name)
Constructor.
Definition plugindeployer.cpp:17
Header for the Deployer class.
Header for the PluginDeployer class.