From 9d2687e7d41cb9f0f757fd515c3479d6e22edf3a Mon Sep 17 00:00:00 2001
From: Albert Liu <45282415+ggrtk@users.noreply.github.com>
Date: Wed, 7 Oct 2020 07:59:39 -0700
Subject: [PATCH 1/2] Qt: Provide warning in auto updater on settings version
increase
---
src/duckstation-qt/autoupdaterdialog.cpp | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/duckstation-qt/autoupdaterdialog.cpp b/src/duckstation-qt/autoupdaterdialog.cpp
index 9e1dce0d3..bd018be3d 100644
--- a/src/duckstation-qt/autoupdaterdialog.cpp
+++ b/src/duckstation-qt/autoupdaterdialog.cpp
@@ -256,6 +256,7 @@ void AutoUpdaterDialog::getChangesComplete(QNetworkReply* reply)
const QJsonArray commits(doc_object["commits"].toArray());
bool update_will_break_save_states = false;
+ bool update_increases_settings_version = false;
for (const QJsonValue& commit : commits)
{
@@ -274,6 +275,9 @@ void AutoUpdaterDialog::getChangesComplete(QNetworkReply* reply)
if (message.contains(QStringLiteral("[SAVEVERSION+]")))
update_will_break_save_states = true;
+
+ if (message.contains(QStringLiteral("[SETTINGSVERSION+]")))
+ update_increases_settings_version = true;
}
changes_html += "";
@@ -285,6 +289,13 @@ void AutoUpdaterDialog::getChangesComplete(QNetworkReply* reply)
"before installing this update or you will lose progress.
"));
}
+ if (update_increases_settings_version)
+ {
+ changes_html.prepend(
+ tr("Settings Warning
Installing this update will reset your program configuration. Please note "
+ "that you will have to reconfigure your settings after this update.
"));
+ }
+
changes_html += tr("Installing this update will download %1 MB through your internet connection.
")
.arg(static_cast(m_download_size) / 1000000.0, 0, 'f', 2);
From 94d7d4cead3fa5ebc44e0735fb05cb537ae77c00 Mon Sep 17 00:00:00 2001
From: Albert Liu <45282415+ggrtk@users.noreply.github.com>
Date: Wed, 7 Oct 2020 20:43:50 -0700
Subject: [PATCH 2/2] Qt: Show dialog on startup for settings version mismatch
For the QMessageBox to appear, error reporting is performed again after
main window creation.
---
src/duckstation-qt/main.cpp | 2 ++
src/duckstation-qt/mainwindow.cpp | 7 +++++++
src/duckstation-qt/mainwindow.h | 4 ++++
src/frontend-common/common_host_interface.cpp | 11 +++++++++--
src/frontend-common/common_host_interface.h | 6 ++++++
5 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/duckstation-qt/main.cpp b/src/duckstation-qt/main.cpp
index 66bf4bf51..92a8f03da 100644
--- a/src/duckstation-qt/main.cpp
+++ b/src/duckstation-qt/main.cpp
@@ -55,6 +55,8 @@ int main(int argc, char* argv[])
window->startupUpdateCheck();
}
+ window->reportSettingsVersionMismatchString();
+
int result = app.exec();
window.reset();
diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp
index 09ea254bf..ada85e362 100644
--- a/src/duckstation-qt/mainwindow.cpp
+++ b/src/duckstation-qt/mainwindow.cpp
@@ -1088,6 +1088,13 @@ void MainWindow::startupUpdateCheck()
checkForUpdates(false);
}
+void MainWindow::reportSettingsVersionMismatchString()
+{
+ const QString mismatch_str = QString::fromStdString(m_host_interface->GetSettingsVersionMismatchString());
+ if (!mismatch_str.isEmpty())
+ reportError(mismatch_str);
+}
+
void MainWindow::updateDebugMenuVisibility()
{
const bool visible = m_host_interface->GetBoolSettingValue("Main", "ShowDebugMenu", false);
diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h
index 3dc7c83cf..85e9b6137 100644
--- a/src/duckstation-qt/mainwindow.h
+++ b/src/duckstation-qt/mainwindow.h
@@ -30,6 +30,10 @@ public:
/// Performs update check if enabled in settings.
void startupUpdateCheck();
+ /// Reports m_host_interface's settings version mismatch string. Does nothing if string is empty (no settings version
+ /// mismatch detected).
+ void reportSettingsVersionMismatchString();
+
public Q_SLOTS:
/// Updates debug menu visibility (hides if disabled).
void updateDebugMenuVisibility();
diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp
index 5579d36de..499525347 100644
--- a/src/frontend-common/common_host_interface.cpp
+++ b/src/frontend-common/common_host_interface.cpp
@@ -1995,8 +1995,10 @@ void CommonHostInterface::CheckSettings(SettingsInterface& si)
if (settings_version == SETTINGS_VERSION)
return;
- ReportFormattedError("Settings version %d does not match expected version %d, resetting", settings_version,
- SETTINGS_VERSION);
+ m_settings_version_mismatch_str = StringUtil::StdStringFromFormat(
+ "Settings version %d does not match expected version %d, resetting", settings_version, SETTINGS_VERSION);
+ ReportError(m_settings_version_mismatch_str.c_str());
+
si.Clear();
si.SetIntValue("Main", "SettingsVersion", SETTINGS_VERSION);
SetDefaultSettings(si);
@@ -2101,6 +2103,11 @@ void CommonHostInterface::CheckForSettingsChanges(const Settings& old_settings)
UpdateInputMap();
}
+const std::string& CommonHostInterface::GetSettingsVersionMismatchString() const
+{
+ return m_settings_version_mismatch_str;
+}
+
void CommonHostInterface::SetTimerResolutionIncreased(bool enabled)
{
if (m_timer_resolution_increased == enabled)
diff --git a/src/frontend-common/common_host_interface.h b/src/frontend-common/common_host_interface.h
index e21a6b92d..07ad70d97 100644
--- a/src/frontend-common/common_host_interface.h
+++ b/src/frontend-common/common_host_interface.h
@@ -174,6 +174,10 @@ public:
/// Reloads post processing shaders with the current configuration.
void ReloadPostProcessingShaders();
+ /// Returns an empty string if no settings version mismatch was detected, non-empty otherwise. Should not be called
+ /// before CheckSettings(SettingsInterface& si).
+ const std::string& GetSettingsVersionMismatchString() const;
+
protected:
enum : u32
{
@@ -371,6 +375,8 @@ private:
// running in batch mode? i.e. exit after stopping emulation
bool m_batch_mode = false;
+ std::string m_settings_version_mismatch_str;
+
#ifdef WITH_DISCORD_PRESENCE
// discord rich presence
bool m_discord_presence_enabled = false;