From 40c433580f69006a42dc27a6444ebd9a6cccc440 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Fri, 1 May 2020 18:00:31 +0200 Subject: Update ModInfo classes to handle plugin game and clean some declarations. --- src/modinfo.h | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'src/modinfo.h') diff --git a/src/modinfo.h b/src/modinfo.h index 34b1ecdf..d611fa87 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -319,11 +319,23 @@ public: virtual void setNotes(const QString ¬es) = 0; /** - * @brief set/change the source game of this mod + * @brief set/change the game plgin for this mod * - * @param gameName the source game shortName + * @param gamePlugin the game plugin */ - virtual void setGameName(const QString &gameName) = 0; + virtual void setGamePlugin(const MOBase::IPluginGame* gamePlugin) = 0; + + /** + * @brief set the name of this mod + * + * set the name of this mod. This will also update the name of the + * directory that contains this mod + * + * @param name new name of the mod + * @return true on success, false if the new name can't be used (i.e. because the new + * directory name wouldn't be valid) + **/ + virtual bool setName(const QString& name) = 0; /** * @brief set/change the nexus mod id of this mod @@ -336,7 +348,7 @@ public: * @brief set/change the version of this mod * @param version new version of the mod */ - virtual void setVersion(const MOBase::VersionInfo &version); + virtual void setVersion(const MOBase::VersionInfo &version) override; /** * @brief Controls if mod should be highlighted based on plugin selection @@ -382,7 +394,7 @@ public: virtual void addCategory(const QString &categoryName) override; virtual bool removeCategory(const QString &categoryName) override; - virtual QStringList categories() override; + virtual QStringList categories() const override; /** * update the endorsement state for the mod. This only changes the @@ -645,12 +657,12 @@ public: /* *@return the color choosen by the user for the mod/separator */ - virtual QColor getColor() { return QColor(); } + virtual QColor getColor() const { return QColor(); } /* *@return true if the color has been set successfully. */ - virtual void setColor(QColor color) { } + virtual void setColor(QColor) { } /** * @brief adds the information that a file has been installed into this mod @@ -709,12 +721,12 @@ public: /** * @brief updates the mod to flag it as converted in order to ignore the alternate game warning */ - virtual void markConverted(bool converted) {} + virtual void markConverted(bool) {} /** * @brief updates the mod to flag it as valid in order to ignore the invalid game data flag */ - virtual void markValidated(bool validated) {} + virtual void markValidated(bool) {} /** * @brief reads meta information from disk @@ -729,32 +741,32 @@ public: /** * @return retrieve list of mods (as mod index) that are overwritten by this one. Updates may be delayed */ - virtual std::set getModOverwrite() { return std::set(); } + virtual std::set getModOverwrite() const { return std::set(); } /** * @return list of mods (as mod index) that overwrite this one. Updates may be delayed */ - virtual std::set getModOverwritten() { return std::set(); } + virtual std::set getModOverwritten() const { return std::set(); } /** * @return retrieve list of mods (as mod index) with archives that are overwritten by this one. Updates may be delayed */ - virtual std::set getModArchiveOverwrite() { return std::set(); } + virtual std::set getModArchiveOverwrite() const { return std::set(); } /** * @return list of mods (as mod index) with archives that overwrite this one. Updates may be delayed */ - virtual std::set getModArchiveOverwritten() { return std::set(); } + virtual std::set getModArchiveOverwritten() const { return std::set(); } /** * @return retrieve list of mods (as mod index) with archives that are overwritten by thos mod's loose files. Updates may be delayed */ - virtual std::set getModArchiveLooseOverwrite() { return std::set(); } + virtual std::set getModArchiveLooseOverwrite() const { return std::set(); } /** * @return list of mods (as mod index) with loose files that overwrite this one's archive files. Updates may be delayed */ - virtual std::set getModArchiveLooseOverwritten() { return std::set(); } + virtual std::set getModArchiveLooseOverwritten() const { return std::set(); } /** * @brief update conflict information @@ -804,6 +816,13 @@ protected: static void updateIndices(); static bool ByName(const ModInfo::Ptr &LHS, const ModInfo::Ptr &RHS); + /** + * @brief check if the content of this mod is valid. + * + * @return true if the content is valid, false otherwize. + **/ + virtual bool doTestValid() const = 0; + private: static void createFromOverwrite(PluginContainer *pluginContainer, -- cgit v1.3.1 From c391c2b584a309f64f87dd5e00b0083279e6211c Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Tue, 19 May 2020 18:00:12 +0200 Subject: Rollback to setGameName instead of setGamePlugin for mod interface. --- src/modinfo.h | 10 +++++----- src/modinfobackup.h | 2 +- src/modinfodialognexus.cpp | 2 +- src/modinfoforeign.h | 2 +- src/modinfooverwrite.h | 2 +- src/modinforegular.cpp | 6 ++---- src/modinforegular.h | 18 ++++++++++-------- src/modinfoseparator.h | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/modinfo.h') diff --git a/src/modinfo.h b/src/modinfo.h index d611fa87..2c108378 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -319,11 +319,11 @@ public: virtual void setNotes(const QString ¬es) = 0; /** - * @brief set/change the game plgin for this mod - * - * @param gamePlugin the game plugin - */ - virtual void setGamePlugin(const MOBase::IPluginGame* gamePlugin) = 0; + * @brief set/change the source game of this mod + * + * @param gameName the source game shortName + */ + virtual void setGameName(const QString& gameName) = 0; /** * @brief set the name of this mod diff --git a/src/modinfobackup.h b/src/modinfobackup.h index bc340b3e..9eba545c 100644 --- a/src/modinfobackup.h +++ b/src/modinfobackup.h @@ -16,7 +16,7 @@ public: virtual bool updateIgnored() const override { return false; } virtual bool downgradeAvailable() const override { return false; } virtual bool updateNXMInfo() override { return false; } - virtual void setGamePlugin(const MOBase::IPluginGame*) override {} + virtual void setGameName(const QString& gameName) override {} virtual void setNexusID(int) override {} virtual void endorse(bool) override {} virtual int getFixedPriority() const override { return -1; } diff --git a/src/modinfodialognexus.cpp b/src/modinfodialognexus.cpp index 447beea6..8d99d230 100644 --- a/src/modinfodialognexus.cpp +++ b/src/modinfodialognexus.cpp @@ -324,7 +324,7 @@ void NexusTab::onSourceGameChanged() for (auto game : plugin().plugins()) { if (game->gameName() == ui->sourceGame->currentText()) { - mod().setGamePlugin(game); + mod().setGameName(game->gameShortName()); mod().setLastNexusQuery(QDateTime::fromSecsSinceEpoch(0)); refreshData(mod().getNexusID()); return; diff --git a/src/modinfoforeign.h b/src/modinfoforeign.h index 0c15c7a4..da2c865b 100644 --- a/src/modinfoforeign.h +++ b/src/modinfoforeign.h @@ -22,7 +22,7 @@ public: virtual bool setName(const QString&) override { return false; } virtual void setComments(const QString&) override {} virtual void setNotes(const QString&) override {} - virtual void setGamePlugin(const MOBase::IPluginGame*) override {} + virtual void setGameName(const QString& gameName) override {} virtual void setNexusID(int) override {} virtual void setNewestVersion(const MOBase::VersionInfo&) override {} virtual void ignoreUpdate(bool) override {} diff --git a/src/modinfooverwrite.h b/src/modinfooverwrite.h index 10d405bd..0bcf6f27 100644 --- a/src/modinfooverwrite.h +++ b/src/modinfooverwrite.h @@ -24,7 +24,7 @@ public: virtual bool setName(const QString&) override { return false; } virtual void setComments(const QString&) override {} virtual void setNotes(const QString&) override {} - virtual void setGamePlugin(const MOBase::IPluginGame*) override {} + virtual void setGameName(const QString& gameName) override {} virtual void setNexusID(int) override {} virtual void setNewestVersion(const MOBase::VersionInfo&) override {} virtual void ignoreUpdate(bool) override {} diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index d248f530..a1ef5701 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -468,12 +468,10 @@ void ModInfoRegular::setNotes(const QString ¬es) m_MetaInfoChanged = true; } -void ModInfoRegular::setGamePlugin(const MOBase::IPluginGame* gamePlugin) +void ModInfoRegular::setGameName(const QString& gameName) { - m_GamePlugin = gamePlugin; - m_GameName = gamePlugin->gameShortName(); + m_GameName = gameName; m_MetaInfoChanged = true; - testValid(); } void ModInfoRegular::setNexusID(int modID) diff --git a/src/modinforegular.h b/src/modinforegular.h index b4a7bfd2..75b24a6b 100644 --- a/src/modinforegular.h +++ b/src/modinforegular.h @@ -105,11 +105,11 @@ public: void setNotes(const QString ¬es) override; /** - * @brief set/change the game plgin for this mod - * - * @param gamePlugin the game plugin - */ - virtual void setGamePlugin(const MOBase::IPluginGame* gamePlugin) override; + * @brief set/change the source game of this mod + * + * @param gameName the source game shortName + */ + virtual void setGameName(const QString& gameName) override; /** * @brief set/change the nexus mod id of this mod @@ -432,9 +432,11 @@ private: QString m_CustomURL; bool m_HasCustomURL; - // Storing both the game name and game plugin since we can have a game - // name that is not one of the primary names of the game plugin: - const MOBase::IPluginGame* m_GamePlugin; + // Current game plugin running in MO2: + MOBase::IPluginGame const* m_GamePlugin; + + // Game name for the mod, can be different from the actual game running in MO2 + // e.g., for Skyrim / Skyrim SE. QString m_GameName; mutable QStringList m_Archives; diff --git a/src/modinfoseparator.h b/src/modinfoseparator.h index d715d548..80734bcf 100644 --- a/src/modinfoseparator.h +++ b/src/modinfoseparator.h @@ -21,7 +21,7 @@ public: virtual bool setName(const QString& name); virtual int getNexusID() const override { return -1; } - virtual void setGamePlugin(const MOBase::IPluginGame* /*gamePlugin*/) override {} + virtual void setGameName(const QString& gameName) override {} virtual void setNexusID(int /*modID*/) override {} virtual void endorse(bool /*doEndorse*/) override {} virtual void ignoreUpdate(bool /*ignore*/) override {} -- cgit v1.3.1