diff options
Diffstat (limited to 'launcher/settings')
-rw-r--r-- | launcher/settings/INISettingsObject.cpp | 25 | ||||
-rw-r--r-- | launcher/settings/INISettingsObject.h | 5 | ||||
-rw-r--r-- | launcher/settings/Setting.h | 2 |
3 files changed, 29 insertions, 3 deletions
diff --git a/launcher/settings/INISettingsObject.cpp b/launcher/settings/INISettingsObject.cpp index 12513403..da962ee9 100644 --- a/launcher/settings/INISettingsObject.cpp +++ b/launcher/settings/INISettingsObject.cpp @@ -16,7 +16,30 @@ #include "INISettingsObject.h" #include "Setting.h" -INISettingsObject::INISettingsObject(const QString &path, QObject *parent) +#include <QDebug> +#include <QFile> + +INISettingsObject::INISettingsObject(QStringList paths, QObject *parent) + : SettingsObject(parent) +{ + auto first_path = paths.constFirst(); + for (auto path : paths) { + if (!QFile::exists(path)) + continue; + + if (path != first_path && QFile::exists(path)) { + // Copy the fallback to the preferred path. + QFile::copy(path, first_path); + qDebug() << "Copied settings from" << path << "to" << first_path; + break; + } + } + + m_filePath = first_path; + m_ini.loadFile(first_path); +} + +INISettingsObject::INISettingsObject(QString path, QObject* parent) : SettingsObject(parent) { m_filePath = path; diff --git a/launcher/settings/INISettingsObject.h b/launcher/settings/INISettingsObject.h index 26cc32e5..d2f448a9 100644 --- a/launcher/settings/INISettingsObject.h +++ b/launcher/settings/INISettingsObject.h @@ -28,7 +28,10 @@ class INISettingsObject : public SettingsObject { Q_OBJECT public: - explicit INISettingsObject(const QString &path, QObject *parent = 0); + /** 'paths' is a list of INI files to try, in order, for fallback support. */ + explicit INISettingsObject(QStringList paths, QObject* parent = nullptr); + + explicit INISettingsObject(QString path, QObject* parent = nullptr); /*! * \brief Gets the path to the INI file. diff --git a/launcher/settings/Setting.h b/launcher/settings/Setting.h index 9a5b8210..86007c13 100644 --- a/launcher/settings/Setting.h +++ b/launcher/settings/Setting.h @@ -33,7 +33,7 @@ public: * Construct a Setting * * Synonyms are all the possible names used in the settings object, in order of preference. - * First synonym is the ID, which identifies the setting in PolyMC. + * First synonym is the ID, which identifies the setting in Prism Launcher. * * defVal is the default value that will be returned when the settings object * doesn't have any value for this setting. |