#pragma once #include "stringutil.h" #include #include #include #include #include "FomodInstallerWindow.h" #include "lib/Logger.h" #include "xml/FomodInfoFile.h" #include "xml/ModuleConfiguration.h" #include #include #include class FomodInstallerWindow; using namespace MOBase; using namespace std; using ParsedFilesTuple = std::tuple, std::unique_ptr, QStringList>; class FomodPlusInstaller final : public IPluginInstallerSimple { Q_OBJECT Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller) Q_PLUGIN_METADATA(IID "io.clearing.FomodPlus" FILE "fomodplus.json") public: bool init(IOrganizer* organizer) override; // constant values [[nodiscard]] QString name() const override { return StringConstants::Plugin::NAME.data(); } [[nodiscard]] QString author() const override { return StringConstants::Plugin::AUTHOR.data(); } [[nodiscard]] QString description() const override { return StringConstants::Plugin::DESCRIPTION.data(); } [[nodiscard]] VersionInfo version() const override { return { 1, 0, 0, VersionInfo::RELEASE_FINAL }; } [[nodiscard]] unsigned int priority() const override { return 999; /* Above installer_fomod's highest priority. */ } [[nodiscard]] std::vector > requirements() const override; [[nodiscard]] bool isManualInstaller() const override { return false; } [[nodiscard]] bool isArchiveSupported(std::shared_ptr tree) const override; [[nodiscard]] QList settings() const override; std::pair getExistingFomodJson(const GuessedValue& modName, const int& nexusId, const int& stepsInCurrentFomod) const; void clearPriorInstallData(); EInstallResult install(GuessedValue& modName, std::shared_ptr& tree, QString& version, int& nexusID) override; void onInstallationStart(QString const& archive, bool reinstallation, IModInterface* currentMod) override; void onInstallationEnd(EInstallResult result, IModInterface* newMod) override; [[nodiscard]] bool shouldShowImages() const; [[nodiscard]] bool shouldShowNotifications() const; bool shouldShowSidebarFilter() const; [[nodiscard]] bool shouldAutoRestoreChoices() const; [[nodiscard]] bool isWizardIntegrated() const; void toggleShouldShowImages() const; QString getSelectedColor() const; private: Logger& log = Logger::getInstance(); IOrganizer* mOrganizer = nullptr; QString mFomodPath{}; std::shared_ptr mFomodJson{ nullptr }; bool mInstallerUsed{ false }; std::shared_ptr mFomodContent{ nullptr }; std::unique_ptr mFomodDb; /** * @brief Retrieve the tree entry corresponding to the fomod directory. * * @param tree Tree to look-up the directory in. * * @return the entry corresponding to the fomod directory in the tree, or a null * pointer if the entry was not found. */ [[nodiscard]] static shared_ptr findFomodDirectory(const shared_ptr& tree); [[nodiscard]] static QDialog::DialogCode showInstallerWindow(const shared_ptr& window); [[nodiscard]] ParsedFilesTuple parseFomodFiles(const shared_ptr& tree); static void appendImageFiles(vector >& entries, const shared_ptr& tree); void appendPluginFiles(vector >& entries, const shared_ptr& tree); void setupUiInjection() const; void toggleFeature(bool enabled) const; [[nodiscard]] bool shouldFallbackToLegacyInstaller() const; void logMessage(const LogLevel level, const std::string& message) const { log.logMessage(level, "[INSTALLER] " + message); } };