summaryrefslogtreecommitdiff
path: root/src/createinstancedialogpages.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/createinstancedialogpages.h')
-rw-r--r--src/createinstancedialogpages.h250
1 files changed, 250 insertions, 0 deletions
diff --git a/src/createinstancedialogpages.h b/src/createinstancedialogpages.h
new file mode 100644
index 00000000..e239c196
--- /dev/null
+++ b/src/createinstancedialogpages.h
@@ -0,0 +1,250 @@
+#ifndef MODORGANIZER_CREATEINSTANCEDIALOGPAGES_INCLUDED
+#define MODORGANIZER_CREATEINSTANCEDIALOGPAGES_INCLUDED
+
+#include "createinstancedialog.h"
+#include <filterwidget.h>
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QCommandLinkButton>
+
+namespace MOBase { class IPluginGame; }
+class NexusConnectionUI;
+
+
+namespace cid
+{
+
+QString makeDefaultPath(const std::wstring& dir);
+
+
+class PlaceholderLabel
+{
+public:
+ PlaceholderLabel(QLabel* label);
+ void setText(const QString& arg);
+ void setVisible(bool b);
+
+private:
+ QLabel* m_label;
+ QString m_original;
+};
+
+
+class Page
+{
+public:
+ Page(CreateInstanceDialog& dlg);
+
+ virtual bool ready() const;
+ virtual void activated();
+
+ void setSkip(bool b);
+ bool skip() const;
+
+ void updateNavigation();
+ void next();
+
+ virtual CreateInstanceDialog::Types selectedInstanceType() const;
+ virtual MOBase::IPluginGame* selectedGame() const;
+ virtual QString selectedGameLocation() const;
+ virtual QString selectedGameVariant() const;
+ virtual QString selectedInstanceName() const;
+ virtual CreateInstanceDialog::Paths selectedPaths() const;
+
+protected:
+ Ui::CreateInstanceDialog* ui;
+ CreateInstanceDialog& m_dlg;
+ const PluginContainer& m_pc;
+ bool m_skip;
+
+ virtual bool doSkip() const;
+};
+
+
+class IntroPage : public Page
+{
+public:
+ IntroPage(CreateInstanceDialog& dlg);
+
+protected:
+ bool doSkip() const override;
+};
+
+
+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, const QString& dir={});
+ 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<std::unique_ptr<Game>> m_games;
+ Game* m_selection;
+ MOBase::FilterWidget m_filter;
+
+ std::vector<MOBase::IPluginGame*> sortedGamePlugins() const;
+ Game* findGame(MOBase::IPluginGame* game);
+ void createGames();
+ void updateButton(Game* g);
+ void selectButton(Game* g);
+ void clearButtons();
+ void addButton(QAbstractButton* b);
+ QCommandLinkButton* createCustomButton();
+ void createGameButton(Game* g);
+ void fillList();
+ void onFilter();
+ 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 VariantsPage : public Page
+{
+public:
+ VariantsPage(CreateInstanceDialog& dlg);
+
+ bool ready() const override;
+ void activated() override;
+ QString selectedGameVariant() const override;
+
+ void select(const QString& variant);
+
+protected:
+ bool doSkip() const override;
+
+private:
+ MOBase::IPluginGame* m_previousGame;
+ std::vector<QCommandLinkButton*> m_buttons;
+ QString m_selection;
+
+ void fillList();
+};
+
+
+class NamePage : public Page
+{
+public:
+ NamePage(CreateInstanceDialog& dlg);
+
+ bool ready() const override;
+ void activated() override;
+ QString selectedInstanceName() const override;
+
+protected:
+ bool doSkip() const override;
+
+private:
+ mutable PlaceholderLabel m_label, m_exists, m_invalid;
+ bool m_modified;
+ bool m_okay;
+
+ void onChanged();
+ void updateWarnings();
+ bool checkName(QString parentDir, QString name);
+};
+
+
+class PathsPage : public Page
+{
+public:
+ PathsPage(CreateInstanceDialog& dlg);
+
+ bool ready() const override;
+ void activated() override;
+
+ CreateInstanceDialog::Paths selectedPaths() const override;
+
+private:
+ QString m_lastInstanceName;
+ CreateInstanceDialog::Types m_lastType;
+ PlaceholderLabel m_label;
+ mutable PlaceholderLabel m_simpleExists, m_simpleInvalid;
+ mutable PlaceholderLabel m_advancedExists, m_advancedInvalid;
+
+ void onChanged();
+ bool checkPaths() const;
+ bool checkAdvancedPath(const QString& path) const;
+ QString resolve(const QString& path) const;
+ void onAdvanced();
+ void setPaths(const QString& name, bool force);
+ void setIfEmpty(QLineEdit* e, const QString& path, bool force);
+ bool checkPath(
+ QString path,
+ PlaceholderLabel& existsLabel, PlaceholderLabel& invalidLabel) const;
+};
+
+
+class NexusPage : public Page
+{
+public:
+ NexusPage(CreateInstanceDialog& dlg);
+ ~NexusPage();
+
+ bool ready() const override;
+ void activated() override;
+
+protected:
+ bool doSkip() const override;
+
+private:
+ std::unique_ptr<NexusConnectionUI> m_connectionUI;
+ bool m_skip;
+};
+
+
+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