Limo
A simple mod manager
Loading...
Searching...
No Matches
openmwplugindeployer.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "plugindeployer.h"
9#include <set>
10
11
16{
17public:
26 OpenMwPluginDeployer(const std::filesystem::path& source_path,
27 const std::filesystem::path& dest_path,
28 const std::string& name);
29
31 static constexpr int ACTION_ADD_GROUNDCOVER_TAG = 0;
33 static constexpr int ACTION_REMOVE_GROUNDCOVER_TAG = 1;
34
39 virtual void unDeploy(std::optional<ProgressNode*> progress_node = {}) override;
44 virtual std::vector<std::vector<int>> getConflictGroups() const override;
49 virtual std::map<std::string, int> getAutoTagMap() override;
54 virtual void sortModsByConflicts(std::optional<ProgressNode*> progress_node = {}) override;
59 virtual bool supportsModConflicts() const override;
64 virtual std::vector<std::pair<std::string, std::string>> getModActions() const override;
69 virtual std::vector<std::vector<int>> getValidModActions() const override;
75 virtual void applyModAction(int action, int mod_id) override;
76
77private:
79 static constexpr std::string OPEN_MW_CONFIG_FILE_NAME = "openmw.cfg";
81 static constexpr std::string GROUNDCOVER_TAG = "Groundcover";
83 static constexpr std::string OPENMW_TAG = "OpenMW";
85 static constexpr std::string ES_PLUGIN_TAG = "ES-Plugin";
87 static constexpr std::string SCRIPTS_PLUGIN_TAG = "Scripts";
88
98 std::map<std::string, std::set<std::string>> tag_map_;
100 std::set<std::string> groundcover_plugins_;
101
103 void writePlugins() const override;
108 bool initPluginFile();
110 void readPluginTags();
112 virtual void writePluginTags() const override;
114 virtual void updatePluginTags() override;
116 void updateTagVector();
120 void writePluginTagsPrivate() const;
128 void writePluginsToOpenMwConfig(const std::string& line_prefix, const std::regex& line_regex,
129 std::function<bool(int)> plugin_filter) const;
131 void writePluginsPrivate() const;
132};
bool initPluginFile()
Initializes the plugin file, if it does not exist.
Definition openmwplugindeployer.cpp:148
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.
Definition openmwplugindeployer.cpp:102
static constexpr std::string ES_PLUGIN_TAG
Name of the es plugin tag.
Definition openmwplugindeployer.h:85
virtual std::vector< std::vector< int > > getConflictGroups() const override
Groups plugins by whether or not they are scrips, groundcover plugins or neither.
Definition openmwplugindeployer.cpp:53
static constexpr std::string OPENMW_TAG
Name of the open mw tag.
Definition openmwplugindeployer.h:83
std::map< std::string, std::set< std::string > > tag_map_
Maps plugins to a set of tags.
Definition openmwplugindeployer.h:98
int num_es_plugins_
Number of plugins with es plugin tag.
Definition openmwplugindeployer.h:94
void writePluginsPrivate() const
Writes the plugins to disk.
Definition openmwplugindeployer.cpp:369
void updatePluginTagsPrivate()
Updates the tag_map_ for every plugin.
Definition openmwplugindeployer.cpp:262
int num_groundcover_plugins_
Number of plugins with groundcover tag.
Definition openmwplugindeployer.h:90
static constexpr std::string OPEN_MW_CONFIG_FILE_NAME
Name of the OpenMW config file.
Definition openmwplugindeployer.h:79
OpenMwPluginDeployer(const std::filesystem::path &source_path, const std::filesystem::path &dest_path, const std::string &name)
Loads plugins.
Definition openmwplugindeployer.cpp:13
static constexpr int ACTION_REMOVE_GROUNDCOVER_TAG
Action id for removing a groundcover tag.
Definition openmwplugindeployer.h:33
virtual void writePluginTags() const override
Wrapper for writePluginTagsPrivate.
Definition openmwplugindeployer.cpp:235
void writePluginTagsPrivate() const
Writes plugins to the OpenMW config file.
Definition openmwplugindeployer.cpp:293
virtual std::map< std::string, int > getAutoTagMap() override
Returns all available auto tag names.
Definition openmwplugindeployer.cpp:74
void readPluginTags()
Reads the plugin tags from disk.
Definition openmwplugindeployer.cpp:183
void updateTagVector()
Adds all tags from the tag map to the tags_ vector.
Definition openmwplugindeployer.cpp:245
virtual void updatePluginTags() override
Wrapper for updatePluginTagsPrivate.
Definition openmwplugindeployer.cpp:240
static constexpr int ACTION_ADD_GROUNDCOVER_TAG
Action id for adding a groundcover tag.
Definition openmwplugindeployer.h:31
static constexpr std::string GROUNDCOVER_TAG
Name of the groundcover tag.
Definition openmwplugindeployer.h:81
std::set< std::string > groundcover_plugins_
Names of groundcover plugins.
Definition openmwplugindeployer.h:100
static constexpr std::string SCRIPTS_PLUGIN_TAG
Name of the es plugin tag.
Definition openmwplugindeployer.h:87
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.
Definition openmwplugindeployer.cpp:314
void writePlugins() const override
Wrapper for writePluginsPrivate.
Definition openmwplugindeployer.cpp:143
int num_scripts_plugins_
Number of script plugins.
Definition openmwplugindeployer.h:96
int num_openmw_plugins_
Number of plugins with openmw tag.
Definition openmwplugindeployer.h:92
virtual void sortModsByConflicts(std::optional< ProgressNode * > progress_node={}) override
Sort mods by into script, groundcover and normal groups.
Definition openmwplugindeployer.cpp:81
virtual void applyModAction(int action, int mod_id) override
Applies the given mod action to the given mod.
Definition openmwplugindeployer.cpp:123
virtual bool supportsModConflicts() const override
Returns whether or not this deployer type supports showing mod conflicts.
Definition openmwplugindeployer.cpp:97
virtual std::vector< std::vector< int > > getValidModActions() const override
Returns a vector containing valid mod actions.
Definition openmwplugindeployer.cpp:107
virtual void unDeploy(std::optional< ProgressNode * > progress_node={}) override
If no backup exists: Backs up current plugin file, then reloads all plugins.
Definition openmwplugindeployer.cpp:42
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 PluginDeployer class.