mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
GLideNUI: allow loading default settings from GLideN64.default.ini
This commit is contained in:
parent
5aa389a86b
commit
32312e0b05
|
@ -799,7 +799,7 @@ void ConfigDialog::on_buttonBox_clicked(QAbstractButton *button)
|
||||||
msgBox.setButtonText(QMessageBox::Cancel, tr("Cancel"));
|
msgBox.setButtonText(QMessageBox::Cancel, tr("Cancel"));
|
||||||
if (msgBox.exec() == QMessageBox::RestoreDefaults) {
|
if (msgBox.exec() == QMessageBox::RestoreDefaults) {
|
||||||
const u32 enableCustomSettings = config.generalEmulation.enableCustomSettings;
|
const u32 enableCustomSettings = config.generalEmulation.enableCustomSettings;
|
||||||
config.resetToDefaults();
|
resetSettings(m_strIniPath);
|
||||||
config.generalEmulation.enableCustomSettings = enableCustomSettings;
|
config.generalEmulation.enableCustomSettings = enableCustomSettings;
|
||||||
setTitle();
|
setTitle();
|
||||||
setRomName(m_romName);
|
setRomName(m_romName);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
#ifdef OS_WINDOWS
|
#ifdef OS_WINDOWS
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
static const char * strIniFileName = "GLideN64.ini";
|
static const char * strIniFileName = "GLideN64.ini";
|
||||||
|
static const char * strDefaultIniFileName = "GLideN64.default.ini";
|
||||||
static const char * strCustomSettingsFileName = "GLideN64.custom.ini";
|
static const char * strCustomSettingsFileName = "GLideN64.custom.ini";
|
||||||
static QString strUserProfile("User");
|
static QString strUserProfile("User");
|
||||||
|
|
||||||
|
@ -153,54 +155,11 @@ void _loadSettings(QSettings & settings)
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadSettings(const QString & _strIniFolder)
|
static
|
||||||
{
|
void _writeSettingsToFile(const QString & filename)
|
||||||
bool rewriteSettings = false;
|
|
||||||
{
|
|
||||||
const u32 hacks = config.generalEmulation.hacks;
|
|
||||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
|
||||||
const u32 configVersion = settings.value("version", 0).toInt();
|
|
||||||
QString configTranslationFile = settings.value("translation", config.translationFile.c_str()).toString();
|
|
||||||
config.resetToDefaults();
|
|
||||||
config.generalEmulation.hacks = hacks;
|
|
||||||
config.translationFile = configTranslationFile.toLocal8Bit().constData();
|
|
||||||
if (configVersion < CONFIG_WITH_PROFILES) {
|
|
||||||
_loadSettings(settings);
|
|
||||||
config.version = CONFIG_VERSION_CURRENT;
|
|
||||||
settings.clear();
|
|
||||||
settings.setValue("version", CONFIG_VERSION_CURRENT);
|
|
||||||
settings.setValue("profile", strUserProfile);
|
|
||||||
settings.setValue("translation", config.translationFile.c_str());
|
|
||||||
settings.beginGroup(strUserProfile);
|
|
||||||
writeSettings(_strIniFolder);
|
|
||||||
settings.endGroup();
|
|
||||||
}
|
|
||||||
QString profile = settings.value("profile", strUserProfile).toString();
|
|
||||||
if (settings.childGroups().indexOf(profile) >= 0) {
|
|
||||||
settings.beginGroup(profile);
|
|
||||||
_loadSettings(settings);
|
|
||||||
settings.endGroup();
|
|
||||||
} else
|
|
||||||
rewriteSettings = true;
|
|
||||||
if (config.version != CONFIG_VERSION_CURRENT)
|
|
||||||
rewriteSettings = true;
|
|
||||||
}
|
|
||||||
if (rewriteSettings) {
|
|
||||||
// Keep settings up-to-date
|
|
||||||
{
|
|
||||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
|
||||||
QString profile = settings.value("profile", strUserProfile).toString();
|
|
||||||
settings.remove(profile);
|
|
||||||
}
|
|
||||||
config.version = CONFIG_VERSION_CURRENT;
|
|
||||||
writeSettings(_strIniFolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeSettings(const QString & _strIniFolder)
|
|
||||||
{
|
{
|
||||||
// QSettings settings("Emulation", "GLideN64");
|
// QSettings settings("Emulation", "GLideN64");
|
||||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
QSettings settings(filename, QSettings::IniFormat);
|
||||||
settings.setValue("version", config.version);
|
settings.setValue("version", config.version);
|
||||||
settings.setValue("translation", config.translationFile.c_str());
|
settings.setValue("translation", config.translationFile.c_str());
|
||||||
QString profile = settings.value("profile", strUserProfile).toString();
|
QString profile = settings.value("profile", strUserProfile).toString();
|
||||||
|
@ -331,6 +290,72 @@ void writeSettings(const QString & _strIniFolder)
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void _loadSettingsFromFile(const QString & filename)
|
||||||
|
{
|
||||||
|
bool rewriteSettings = false;
|
||||||
|
{
|
||||||
|
const u32 hacks = config.generalEmulation.hacks;
|
||||||
|
QSettings settings(filename, QSettings::IniFormat);
|
||||||
|
const u32 configVersion = settings.value("version", 0).toInt();
|
||||||
|
QString configTranslationFile = settings.value("translation", config.translationFile.c_str()).toString();
|
||||||
|
config.resetToDefaults();
|
||||||
|
config.generalEmulation.hacks = hacks;
|
||||||
|
config.translationFile = configTranslationFile.toLocal8Bit().constData();
|
||||||
|
if (configVersion < CONFIG_WITH_PROFILES) {
|
||||||
|
_loadSettings(settings);
|
||||||
|
config.version = CONFIG_VERSION_CURRENT;
|
||||||
|
settings.clear();
|
||||||
|
settings.setValue("version", CONFIG_VERSION_CURRENT);
|
||||||
|
settings.setValue("profile", strUserProfile);
|
||||||
|
settings.setValue("translation", config.translationFile.c_str());
|
||||||
|
settings.beginGroup(strUserProfile);
|
||||||
|
_writeSettingsToFile(filename);
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
QString profile = settings.value("profile", strUserProfile).toString();
|
||||||
|
if (settings.childGroups().indexOf(profile) >= 0) {
|
||||||
|
settings.beginGroup(profile);
|
||||||
|
_loadSettings(settings);
|
||||||
|
settings.endGroup();
|
||||||
|
} else
|
||||||
|
rewriteSettings = true;
|
||||||
|
if (config.version != CONFIG_VERSION_CURRENT)
|
||||||
|
rewriteSettings = true;
|
||||||
|
}
|
||||||
|
if (rewriteSettings) {
|
||||||
|
// Keep settings up-to-date
|
||||||
|
{
|
||||||
|
QSettings settings(filename, QSettings::IniFormat);
|
||||||
|
QString profile = settings.value("profile", strUserProfile).toString();
|
||||||
|
settings.remove(profile);
|
||||||
|
}
|
||||||
|
config.version = CONFIG_VERSION_CURRENT;
|
||||||
|
_writeSettingsToFile(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadSettings(const QString & _strIniFolder)
|
||||||
|
{
|
||||||
|
_loadSettingsFromFile(_strIniFolder + "/" + strIniFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeSettings(const QString & _strIniFolder)
|
||||||
|
{
|
||||||
|
_writeSettingsToFile(_strIniFolder + "/" + strIniFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetSettings(const QString & _strIniFolder)
|
||||||
|
{
|
||||||
|
QString defaultSettingsFilename = _strIniFolder + "/" + strDefaultIniFileName;
|
||||||
|
QFile defaultFile(defaultSettingsFilename);
|
||||||
|
if (defaultFile.exists()) {
|
||||||
|
_loadSettingsFromFile(defaultSettingsFilename);
|
||||||
|
} else {
|
||||||
|
config.resetToDefaults();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
u32 Adler32(u32 crc, const void *buffer, u32 count)
|
u32 Adler32(u32 crc, const void *buffer, u32 count)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
void loadSettings(const QString & _strIniFolder);
|
void loadSettings(const QString & _strIniFolder);
|
||||||
void writeSettings(const QString & _strIniFolder);
|
void writeSettings(const QString & _strIniFolder);
|
||||||
|
void resetSettings(const QString & _strIniFolder);
|
||||||
void loadCustomRomSettings(const QString & _strIniFolder, const char * _strRomName);
|
void loadCustomRomSettings(const QString & _strIniFolder, const char * _strRomName);
|
||||||
void saveCustomRomSettings(const QString & _strIniFolder, const char * _strRomName);
|
void saveCustomRomSettings(const QString & _strIniFolder, const char * _strRomName);
|
||||||
QString getTranslationFile();
|
QString getTranslationFile();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user