diff options
| author | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2021-01-10 10:25:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-10 10:25:37 +0100 |
| commit | 80e44a9e3ade61695b4807a3a900d2866138ecac (patch) | |
| tree | 1ef9904664d8d34dba6692bbf5325aea8c199d08 /src/modinfo.h | |
| parent | eaec140f7c823012c09536175d8917dddcacdb7c (diff) | |
| parent | 4a0ce804ea486744e5f6140a0ce4538d99e21ce3 (diff) | |
Merge pull request #1338 from Holt59/collapsible-separators
Collapsible separators (and refactoring).
Diffstat (limited to 'src/modinfo.h')
| -rw-r--r-- | src/modinfo.h | 110 |
1 files changed, 54 insertions, 56 deletions
diff --git a/src/modinfo.h b/src/modinfo.h index 42abe51e..08ed94f8 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -23,6 +23,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "imodinterface.h" #include "versioninfo.h" +class OrganizerCore; class PluginContainer; class QDir; class QDateTime; @@ -107,12 +108,9 @@ public: // Static functions: /** * @brief Read the mod directory and Mod ModInfo objects for all subdirectories. */ - static void updateFromDisc(const QString &modDirectory, - MOShared::DirectoryEntry **directoryStructure, - PluginContainer *pluginContainer, - bool displayForeign, - std::size_t refreshThreadCount, - MOBase::IPluginGame const *game); + static void updateFromDisc( + const QString &modDirectory, OrganizerCore& core, + bool displayForeign, std::size_t refreshThreadCount); static void clear() { s_Collection.clear(); s_ModsByName.clear(); s_ModsByModID.clear(); } @@ -178,6 +176,11 @@ public: // Static functions: static unsigned int getIndex(const QString &name); /** + * @brief Retrieve the overwrite mod. + */ + static ModInfo::Ptr getOverwrite() { return s_Overwrite; } + + /** * @brief Find the first mod that fulfills the filter function (after no particular order). * * @param filter A function to filter mods by. Should return true for a match. @@ -206,30 +209,6 @@ public: // Static functions: QString gameName, QVariantList updateData, bool addOldMods = false, bool markUpdated = false); /** - * @brief Create a new mod from the specified directory and add it to the collection. - * - * @param dir Directory to create from. - * - * @return pointer to the info-structure of the newly created/added mod. - */ - static ModInfo::Ptr createFrom( - PluginContainer *pluginContainer, const MOBase::IPluginGame *game, - const QDir &dir, MOShared::DirectoryEntry **directoryStructure); - - /** - * @brief Create a new "foreign-managed" mod from a tuple of plugin and archives. - * - * @param espName Name of the plugin. - * @param bsaNames Names of archives. - * - * @return a new mod. - */ - static ModInfo::Ptr createFromPlugin( - const QString &modName, const QString &espName, const QStringList &bsaNames, - ModInfo::EModType modType, const MOBase::IPluginGame* game, - MOShared::DirectoryEntry **directoryStructure, PluginContainer *pluginContainer); - - /** * @brief Check wheter a name corresponds to a separator or not, * * @return whether the given name is used for separators. @@ -379,6 +358,11 @@ public: // IModInterface implementations / Re-declaration virtual std::shared_ptr<const MOBase::IFileTree> fileTree() const = 0; /** + * @return true if this object represents a regular mod. + */ + virtual bool isRegular() const { return false; } + + /** * @return true if this object represents the overwrite mod. */ virtual bool isOverwrite() const { return false; } @@ -481,22 +465,9 @@ public: // Mutable operations: */ virtual bool setName(const QString& name) = 0; - /** - * @brief Deletes the mod from the disc. This does not update the global ModInfo structure or - * indices. - * - * @return true on success, false otherwise. - */ - virtual bool remove() = 0; - public: // Methods after this do not come from IModInterface: /** - * @return true if this mod is a regular mod, false otherwise. - */ - virtual bool isRegular() const { return false; } - - /** * @return true if this mod is empty, false otherwise. */ virtual bool isEmpty() const { return false; } @@ -964,7 +935,7 @@ protected: /** * */ - ModInfo(PluginContainer *pluginContainer); + ModInfo(OrganizerCore& core); /** * @brief Prefetch content for this mod. @@ -974,32 +945,59 @@ protected: * using multiple threads for all the mods. */ virtual void prefetch() = 0; - - static void updateIndices(); static bool ByName(const ModInfo::Ptr &LHS, const ModInfo::Ptr &RHS); protected: - static std::vector<ModInfo::Ptr> s_Collection; - static std::map<QString, unsigned int> s_ModsByName; + // the mod list + OrganizerCore& m_Core; + + // the index of the mod in s_Collection, only valid after updateIndices() + int m_Index; int m_PrimaryCategory; std::set<int> m_Categories; - MOBase::VersionInfo m_Version; - bool m_PluginSelected = false; -private: +protected: + + friend class OrganizerCore; + + /** + * @brief Create a new mod from the specified directory and add it to the collection. + * + * @param dir Directory to create from. + * + * @return pointer to the info-structure of the newly created/added mod. + */ + static ModInfo::Ptr createFrom(const QDir& dir, OrganizerCore& core); + + /** + * @brief Create a new "foreign-managed" mod from a tuple of plugin and archives. + * + * @param espName Name of the plugin. + * @param bsaNames Names of archives. + * + * @return a new mod. + */ + static ModInfo::Ptr createFromPlugin( + const QString& modName, const QString& espName, const QStringList& bsaNames, + ModInfo::EModType modType, OrganizerCore& core); + + static ModInfo::Ptr createFromOverwrite(OrganizerCore& core); - static void createFromOverwrite(PluginContainer* pluginContainer, - const MOBase::IPluginGame* game, - MOShared::DirectoryEntry** directoryStructure); + // update the m_Index attribute of all mods and the various mapping + // + static void updateIndices(); -private: +protected: static QMutex s_Mutex; - static std::map<std::pair<QString, int>, std::vector<unsigned int> > s_ModsByModID; + static std::vector<ModInfo::Ptr> s_Collection; + static ModInfo::Ptr s_Overwrite; + static std::map<QString, unsigned int> s_ModsByName; + static std::map<std::pair<QString, int>, std::vector<unsigned int>> s_ModsByModID; static int s_NextID; }; |
