diff options
| author | Qudix <17361645+Qudix@users.noreply.github.com> | 2020-11-14 00:36:57 -0600 |
|---|---|---|
| committer | Qudix <17361645+Qudix@users.noreply.github.com> | 2020-11-14 00:36:57 -0600 |
| commit | 24991bf5fb1dcf4ccee1090285bec10b3a20bf81 (patch) | |
| tree | 49a9444ae24e25263ebee6ea601e4c5bb239447a /src | |
| parent | 125fc7a82e5ddf51b91f834661f7de9356831714 (diff) | |
| parent | 579f94b5b6014ad4a97b23eb2a26ab69f007aa6a (diff) | |
Merge branch 'master' of https://github.com/ModOrganizer2/modorganizer into master
Diffstat (limited to 'src')
| -rw-r--r-- | src/aboutdialog.ui | 5 | ||||
| -rw-r--r-- | src/createinstancedialog.cpp | 10 | ||||
| -rw-r--r-- | src/instancemanager.cpp | 6 | ||||
| -rw-r--r-- | src/instancemanager.h | 5 | ||||
| -rw-r--r-- | src/instancemanagerdialog.cpp | 6 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 2 | ||||
| -rw-r--r-- | src/moapplication.cpp | 18 |
7 files changed, 43 insertions, 9 deletions
diff --git a/src/aboutdialog.ui b/src/aboutdialog.ui index 88cc96e3..f4cb29d5 100644 --- a/src/aboutdialog.ui +++ b/src/aboutdialog.ui @@ -496,6 +496,11 @@ </item>
<item>
<property name="text">
+ <string notr="true">Qudix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
<string notr="true">reedts</string>
</property>
</item>
diff --git a/src/createinstancedialog.cpp b/src/createinstancedialog.cpp index 47cb9d5c..a4e3c336 100644 --- a/src/createinstancedialog.cpp +++ b/src/createinstancedialog.cpp @@ -131,7 +131,7 @@ CreateInstanceDialog::CreateInstanceDialog( ui->pages->setCurrentIndex(0); ui->launch->setChecked(true); - if (!m_settings) + if (!InstanceManager::singleton().hasAnyInstances()) { // first run of MO, there are no instances yet, force launch ui->launch->setEnabled(false); @@ -314,6 +314,10 @@ void CreateInstanceDialog::finish() }; + // don't restart if this is the first instance, it'll be selected and opened + const bool mustRestart = InstanceManager::singleton().hasAnyInstances(); + + try { std::vector<std::unique_ptr<DirectoryCreator>> dirs; @@ -396,9 +400,7 @@ void CreateInstanceDialog::finish() if (ui->launch->isChecked()) { InstanceManager::singleton().setCurrentInstance(ci.instanceName); - if (m_settings) { - // don't restart without settings, it happens on startup when there are - // no instances + if (mustRestart) { ExitModOrganizer(Exit::Restart); m_switching = true; } diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp index 4191f850..2753fc4c 100644 --- a/src/instancemanager.cpp +++ b/src/instancemanager.cpp @@ -538,6 +538,12 @@ void InstanceManager::overrideProfile(const QString& profileName) m_overrideProfileName = profileName; } +void InstanceManager::clearOverrides() +{ + m_overrideInstanceName = {}; + m_overrideProfileName = {}; +} + std::optional<Instance> InstanceManager::currentInstance() const { const QString profile = m_overrideProfileName ? diff --git a/src/instancemanager.h b/src/instancemanager.h index 4f8b01c7..981aed43 100644 --- a/src/instancemanager.h +++ b/src/instancemanager.h @@ -232,6 +232,11 @@ public: // void overrideProfile(const QString& profileName); + // clears instance and profile overrides, used when restarting MO to select + // another instance + // + void clearOverrides(); + // returns a game plugin that considers the given directory valid // // this will check for an INI file in the directory and use its game name diff --git a/src/instancemanagerdialog.cpp b/src/instancemanagerdialog.cpp index ff76e121..2497d8d8 100644 --- a/src/instancemanagerdialog.cpp +++ b/src/instancemanagerdialog.cpp @@ -580,13 +580,17 @@ void InstanceManagerDialog::onSelection() void InstanceManagerDialog::createNew() { - CreateInstanceDialog dlg(m_pc, &Settings::instance(), this); + // there might not be settings available; the dialog can be shown when the + // last selected instance doesn't exist anymore + CreateInstanceDialog dlg(m_pc, Settings::maybeInstance(), this); + if (dlg.exec() != QDialog::Accepted) { return; } if (dlg.switching()) { // restarting MO + accept(); return; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 52d97270..b09e3dcc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1966,7 +1966,7 @@ void MainWindow::refreshSaveList() files.append(it.fileInfo()); } std::sort(files.begin(), files.end(), [](auto const& lhs, auto const& rhs) { - return lhs.fileTime(QFileDevice::FileModificationTime) < rhs.fileTime(QFileDevice::FileModificationTime); + return lhs.fileTime(QFileDevice::FileModificationTime) > rhs.fileTime(QFileDevice::FileModificationTime); }); for (const QFileInfo &file : files) { diff --git a/src/moapplication.cpp b/src/moapplication.cpp index 9139acbb..e7ac3926 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -170,12 +170,13 @@ int MOApplication::run(MOMultiProcess& multiProcess) {
try
{
- // resets things when MO is "restarted"
- resetForRestart();
-
tt.stop();
+
const auto r = doOneRun(multiProcess);
+
if (r == RestartExitCode) {
+ // resets things when MO is "restarted"
+ resetForRestart();
continue;
}
@@ -396,6 +397,10 @@ std::optional<Instance> MOApplication::getCurrentInstance() if (!currentInstance)
{
+ // clear any overrides that might have been given on the command line
+ m.clearOverrides();
+ m_cl.clear();
+
currentInstance = selectInstance();
}
else
@@ -403,6 +408,10 @@ std::optional<Instance> MOApplication::getCurrentInstance() if (!QDir(currentInstance->directory()).exists()) {
// the previously used instance doesn't exist anymore
+ // clear any overrides that might have been given on the command line
+ m.clearOverrides();
+ m_cl.clear();
+
if (m.hasAnyInstances()) {
MOShared::criticalOnTop(QObject::tr(
"Instance at '%1' not found. Select another instance.")
@@ -466,6 +475,9 @@ void MOApplication::resetForRestart() // don't reprocess command line
m_cl.clear();
+
+ // clear instance and profile overrides
+ InstanceManager::singleton().clearOverrides();
}
bool MOApplication::setStyleFile(const QString& styleName)
|
