#ifndef MODORGANIZER_CREATEINSTANCEDIALOGPAGES_INCLUDED #define MODORGANIZER_CREATEINSTANCEDIALOGPAGES_INCLUDED #include #include #include #include "createinstancedialog.h" namespace MOBase { class IPluginGame; } namespace cid { QString makeDefaultPath(const std::wstring& dir); class PathChecker { public: PathChecker(QLabel* existsLabel, QLabel* invalidLabel); QString sanitizeFileName(const QString& name) const; // same thing as above, but allows path separators and colons // QString sanitizePath(const QString& path) const; bool checkName(QString parentDir, QString name) const; bool checkPath(QString path) const; private: QLabel* m_exists; QString m_existsOriginal; QLabel* m_invalid; QString m_invalidOriginal; void setPossiblePlaceholder( QLabel* label, const QString& s, const QString& arg) const; }; class Page { public: Page(CreateInstanceDialog& dlg); virtual bool ready() const; virtual bool skip() const; virtual void activated(); void updateNavigation(); void next(); virtual CreateInstanceDialog::Types selectedInstanceType() const; virtual MOBase::IPluginGame* selectedGame() const; virtual QString selectedGameLocation() const; virtual QString selectedGameEdition() const; virtual QString selectedInstanceName() const; virtual CreateInstanceDialog::Paths selectedPaths() const; protected: Ui::CreateInstanceDialog* ui; CreateInstanceDialog& m_dlg; const PluginContainer& m_pc; }; class InfoPage : public Page { public: InfoPage(CreateInstanceDialog& dlg); }; class TypePage : public Page { public: TypePage(CreateInstanceDialog& dlg); bool ready() const override; CreateInstanceDialog::Types selectedInstanceType() const override; void global(); void portable(); private: CreateInstanceDialog::Types m_type; }; class GamePage : public Page { public: GamePage(CreateInstanceDialog& dlg); bool ready() const override; MOBase::IPluginGame* selectedGame() const override; QString selectedGameLocation() const override; void select(MOBase::IPluginGame* game); void selectCustom(); void warnUnrecognized(const QString& path); private: struct Game { MOBase::IPluginGame* game = nullptr; QCommandLinkButton* button = nullptr; QString dir; bool installed = false; Game(MOBase::IPluginGame* g); Game(const Game&) = delete; Game& operator=(const Game&) = delete; }; std::vector> m_games; Game* m_selection; std::vector sortedGamePlugins() const; Game* findGame(MOBase::IPluginGame* game); void createGames(); void updateButton(Game* g); void selectButton(Game* g); QCommandLinkButton* createCustomButton(); void createGameButton(Game* g); void fillList(); Game* checkInstallation(const QString& path, Game* g); MOBase::IPluginGame* findAnotherGame(const QString& path); bool confirmUnknown(const QString& path, MOBase::IPluginGame* game); MOBase::IPluginGame* confirmOtherGame( const QString& path, MOBase::IPluginGame* selectedGame, MOBase::IPluginGame* guessedGame); }; class EditionsPage : public Page { public: EditionsPage(CreateInstanceDialog& dlg); bool ready() const override; bool skip() const override; void activated() override; QString selectedGameEdition() const override; void select(const QString& variant); private: MOBase::IPluginGame* m_previousGame; std::vector m_buttons; QString m_selection; void fillList(); }; class NamePage : public Page { public: NamePage(CreateInstanceDialog& dlg); bool ready() const override; bool skip() const override; void activated() override; QString selectedInstanceName() const override; private: PathChecker m_checker; QString m_originalLabel; bool m_modified; bool m_okay; void onChanged(); void updateWarnings(); }; class PathsPage : public Page { public: PathsPage(CreateInstanceDialog& dlg); bool ready() const override; void activated() override; CreateInstanceDialog::Paths selectedPaths() const override; private: PathChecker m_checker, m_advancedChecker; QString m_lastInstanceName; void onChanged(); bool checkPaths() const; bool checkAdvancedPath(const QString& path) const; bool checkVarPath(QString path) const; void onAdvanced(); void setPaths(const QString& name, bool force); void setIfEmpty(QLineEdit* e, const QString& path, bool force); }; class ConfirmationPage : public Page { public: ConfirmationPage(CreateInstanceDialog& dlg); void activated() override; QString toLocalizedString(CreateInstanceDialog::Types t) const; QString makeReview() const; QString dirLine(const QString& caption, const QString& path) const; }; } // namespace #endif // MODORGANIZER_CREATEINSTANCEDIALOGPAGES_INCLUDED