diff options
| -rw-r--r-- | src/createinstancedialog.cpp | 55 | ||||
| -rw-r--r-- | src/createinstancedialog.h | 1 | ||||
| -rw-r--r-- | src/createinstancedialog.ui | 79 | ||||
| -rw-r--r-- | src/instancemanagerdialog.cpp | 6 | ||||
| -rw-r--r-- | src/main.cpp | 10 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 26 | ||||
| -rw-r--r-- | src/settings.cpp | 40 | ||||
| -rw-r--r-- | src/settings.h | 5 |
8 files changed, 178 insertions, 44 deletions
diff --git a/src/createinstancedialog.cpp b/src/createinstancedialog.cpp index 4308969e..5db6d685 100644 --- a/src/createinstancedialog.cpp +++ b/src/createinstancedialog.cpp @@ -214,6 +214,16 @@ protected: }; +class InfoPage : public Page +{ +public: + InfoPage(CreateInstanceDialog& dlg) + : Page(dlg) + { + } +}; + + class TypePage : public Page { public: @@ -345,7 +355,7 @@ public: void warnUnrecognized(const QString& path) { QString supportedGames; - for (auto* game : m_pc.plugins<MOBase::IPluginGame>()) { + for (auto* game : sortedGamePlugins()) { supportedGames += "<li>" + game->gameName() + "</li>"; } @@ -381,6 +391,21 @@ private: Game* m_selection; + std::vector<MOBase::IPluginGame*> sortedGamePlugins() const + { + std::vector<MOBase::IPluginGame*> v; + + for (auto* game : m_pc.plugins<MOBase::IPluginGame>()) { + v.push_back(game); + } + + std::sort(v.begin(), v.end(), [](auto* a, auto* b) { + return (a->gameName() < b->gameName()); + }); + + return v; + } + Game* findGame(MOBase::IPluginGame* game) { for (auto& g : m_games) { @@ -396,7 +421,7 @@ private: { m_games.clear(); - for (auto* game : m_pc.plugins<MOBase::IPluginGame>()) { + for (auto* game : sortedGamePlugins()) { m_games.push_back(std::make_unique<Game>(game)); } } @@ -563,9 +588,9 @@ private: .title(QObject::tr("Unrecognized game")) .main(QObject::tr("Unrecognized game")) .content(QObject::tr( - "The folder %1 does not seem to contain installation for " + "The folder %1 does not seem to contain an installation for " "<span style=\"white-space: nowrap; font-weight: bold;\">%2</span> or " - "any other game Mod Organizer can manage.") + "for any other game Mod Organizer can manage.") .arg(path) .arg(game->gameName())) .button({ @@ -800,6 +825,11 @@ public: ui->pathPages->setCurrentIndex(0); } + bool skip() const override + { + return (m_dlg.selectedType() == CreateInstanceDialog::Portable); + } + bool ready() const override { return checkPaths(); @@ -900,11 +930,13 @@ CreateInstanceDialog::CreateInstanceDialog( ui->setupUi(this); m_originalNext = ui->next->text(); + m_pages.push_back(std::make_unique<InfoPage>(*this)); m_pages.push_back(std::make_unique<TypePage>(*this)); m_pages.push_back(std::make_unique<GamePage>(*this)); m_pages.push_back(std::make_unique<EditionsPage>(*this)); m_pages.push_back(std::make_unique<NamePage>(*this)); m_pages.push_back(std::make_unique<PathsPage>(*this)); + m_pages.push_back(std::make_unique<InfoPage>(*this)); ui->pages->setCurrentIndex(0); @@ -926,10 +958,21 @@ const PluginContainer& CreateInstanceDialog::pluginContainer() return m_pc; } +bool CreateInstanceDialog::isOnLastPage() const +{ + for (int i=ui->pages->currentIndex() + 1; i < ui->pages->count(); ++i) { + if (!m_pages[i]->skip()) { + return false; + } + } + + return true; +} + void CreateInstanceDialog::next() { const auto i = ui->pages->currentIndex(); - const auto last = (i == (ui->pages->count() - 1)); + const auto last = isOnLastPage(); if (last) { finish(); @@ -997,7 +1040,7 @@ void CreateInstanceDialog::selectPage(std::size_t i) void CreateInstanceDialog::updateNavigation() { const auto i = ui->pages->currentIndex(); - const auto last = (i == (ui->pages->count() - 1)); + const auto last = isOnLastPage(); ui->next->setEnabled(m_pages[i]->ready()); ui->back->setEnabled(i > 0); diff --git a/src/createinstancedialog.h b/src/createinstancedialog.h index ac1c30b6..02608c8d 100644 --- a/src/createinstancedialog.h +++ b/src/createinstancedialog.h @@ -36,6 +36,7 @@ public: void finish(); void updateNavigation(); + bool isOnLastPage() const; Types selectedType() const; MOBase::IPluginGame* selectedGame() const; diff --git a/src/createinstancedialog.ui b/src/createinstancedialog.ui index 98cbe96e..72d73020 100644 --- a/src/createinstancedialog.ui +++ b/src/createinstancedialog.ui @@ -60,6 +60,24 @@ <property name="currentIndex"> <number>0</number> </property> + <widget class="QWidget" name="page_10"> + <layout class="QVBoxLayout" name="verticalLayout_21"> + <item> + <widget class="QLabel" name="label_15"> + <property name="text"> + <string><h3>What is an instance?</h3> +<p>An instance is a full set of mods, downloads, profiles and configuration for a game. Each game must be managed in its own instance. Mod Organizer can freely switch between instances.</p></string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> <widget class="QWidget" name="page"> <layout class="QVBoxLayout" name="verticalLayout_3"> <item> @@ -823,6 +841,67 @@ </item> </layout> </widget> + <widget class="QWidget" name="page_11"> + <layout class="QVBoxLayout" name="verticalLayout_22"> + <item> + <widget class="QWidget" name="widget_18" native="true"> + <layout class="QVBoxLayout" name="verticalLayout_24"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label_16"> + <property name="text"> + <string><h3>Confirmation</h3></string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_17"> + <property name="text"> + <string>The instance is about to be created. Review the information below and press 'Finish'.</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QWidget" name="widget_19" native="true"> + <layout class="QVBoxLayout" name="verticalLayout_23"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QPlainTextEdit" name="plainTextEdit"> + <property name="textInteractionFlags"> + <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> </widget> </item> <item> diff --git a/src/instancemanagerdialog.cpp b/src/instancemanagerdialog.cpp index 566f1aad..26e8eae1 100644 --- a/src/instancemanagerdialog.cpp +++ b/src/instancemanagerdialog.cpp @@ -8,6 +8,12 @@ #include "shared/appconfig.h" #include <iplugingame.h> +void openInstanceManager(PluginContainer& pc, QWidget* parent) +{ + InstanceManagerDialog dlg(pc, parent); + dlg.exec(); +} + class InstanceInfo { public: diff --git a/src/main.cpp b/src/main.cpp index 71fb0bbd..58e22466 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -270,6 +270,8 @@ std::optional<int> handleCommandLine( return {}; } +void openInstanceManager(PluginContainer& pc, QWidget* parent); + int runApplication( MOApplication &application, const cl::CommandLine& cl, SingleInstance &instance, const QString &dataPath) @@ -298,8 +300,9 @@ int runApplication( try { - Settings settings(dataPath + "/" + QString::fromStdWString(AppConfig::iniFileName())); - settings.setGlobalInstance(); + Settings settings( + dataPath + "/" + QString::fromStdWString(AppConfig::iniFileName()), + true); log::getDefault().setLevel(settings.diagnostics().logLevel()); @@ -434,8 +437,7 @@ int runApplication( QTimer::singleShot(std::chrono::milliseconds(1), [&] { - InstanceManagerDialog dlg(*pluginContainer, &mainWindow); - dlg.exec(); + openInstanceManager(*pluginContainer, &mainWindow); }); res = application.exec(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 65c1d65c..c2d83e36 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5952,20 +5952,24 @@ void MainWindow::on_actionNotifications_triggered() scheduleCheckForProblems(); } +void openInstanceManager(PluginContainer& pc, QWidget* parent); + void MainWindow::on_actionChange_Game_triggered() { - if (m_OrganizerCore.settings().interface().showChangeGameConfirmation()) { - const auto r = QMessageBox::question( - this, tr("Are you sure?"), tr("This will restart MO, continue?"), - QMessageBox::Yes | QMessageBox::Cancel); + openInstanceManager(m_PluginContainer, this); - if (r != QMessageBox::Yes) { - return; - } - } - - InstanceManager::instance().clearCurrentInstance(); - ExitModOrganizer(Exit::Restart); + //if (m_OrganizerCore.settings().interface().showChangeGameConfirmation()) { + // const auto r = QMessageBox::question( + // this, tr("Are you sure?"), tr("This will restart MO, continue?"), + // QMessageBox::Yes | QMessageBox::Cancel); + // + // if (r != QMessageBox::Yes) { + // return; + // } + //} + // + //InstanceManager::instance().clearCurrentInstance(); + //ExitModOrganizer(Exit::Restart); } void MainWindow::setCategoryListVisible(bool visible) diff --git a/src/settings.cpp b/src/settings.cpp index 43e7a4fa..8db9c623 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -61,33 +61,31 @@ QString toString(EndorsementState s) Settings *Settings::s_Instance = nullptr; -Settings::Settings(const QString& path) : +Settings::Settings(const QString& path, bool globalInstance) : m_Settings(path, QSettings::IniFormat), - m_Game(m_Settings), m_Geometry(m_Settings), m_Widgets(m_Settings), - m_Colors(m_Settings), m_Plugins(m_Settings), m_Paths(m_Settings), - m_Network(m_Settings), m_Nexus(*this, m_Settings), m_Steam(*this, m_Settings), + m_Game(m_Settings), m_Geometry(m_Settings), + m_Widgets(m_Settings, globalInstance), m_Colors(m_Settings), + m_Plugins(m_Settings), m_Paths(m_Settings), m_Network(m_Settings), + m_Nexus(*this, m_Settings), m_Steam(*this, m_Settings), m_Interface(m_Settings), m_Diagnostics(m_Settings) { + if (globalInstance) { + if (s_Instance != nullptr) { + throw std::runtime_error("second instance of \"Settings\" created"); + } else { + s_Instance = this; + } + } } Settings::~Settings() { - MOBase::QuestionBoxMemory::setCallbacks({}, {}, {}); - if (s_Instance == this) { + MOBase::QuestionBoxMemory::setCallbacks({}, {}, {}); s_Instance = nullptr; } } -void Settings::setGlobalInstance() -{ - if (s_Instance != nullptr) { - throw std::runtime_error("second instance of \"Settings\" created"); - } else { - s_Instance = this; - } -} - Settings &Settings::instance() { if (s_Instance == nullptr) { @@ -1011,13 +1009,15 @@ void GeometrySettings::restoreDocks(QMainWindow* mw) const } -WidgetSettings::WidgetSettings(QSettings& s) +WidgetSettings::WidgetSettings(QSettings& s, bool globalInstance) : m_Settings(s) { - MOBase::QuestionBoxMemory::setCallbacks( - [this](auto&& w, auto&& f){ return questionButton(w, f); }, - [this](auto&& w, auto&& b){ setQuestionWindowButton(w, b); }, - [this](auto&& w, auto&& f, auto&& b){ setQuestionFileButton(w, f, b); }); + if (globalInstance) { + MOBase::QuestionBoxMemory::setCallbacks( + [this](auto&& w, auto&& f){ return questionButton(w, f); }, + [this](auto&& w, auto&& b){ setQuestionWindowButton(w, b); }, + [this](auto&& w, auto&& f, auto&& b){ setQuestionFileButton(w, f, b); }); + } } std::optional<int> WidgetSettings::index(const QComboBox* cb) const diff --git a/src/settings.h b/src/settings.h index 84102c72..a8c527d6 100644 --- a/src/settings.h +++ b/src/settings.h @@ -195,7 +195,7 @@ private: class WidgetSettings { public: - WidgetSettings(QSettings& s); + WidgetSettings(QSettings& s, bool globalInstance); // selected index for a combobox // @@ -677,11 +677,10 @@ class Settings : public QObject Q_OBJECT; public: - Settings(const QString& path); + Settings(const QString& path, bool globalInstance=false); ~Settings(); static Settings &instance(); - void setGlobalInstance(); // name of the ini file // |
