mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-25 22:09:35 +00:00
Switch to two-parts ini file: general and custom.
Custom section is read-only.
This commit is contained in:
parent
e02faac217
commit
45fbd275ec
|
@ -11,6 +11,9 @@
|
|||
|
||||
#include "Settings.h"
|
||||
|
||||
static const char * strIniFileName = "GLideN64.ini";
|
||||
static const char * strCustomSettingsFileName = "GLideN64.custom.ini";
|
||||
|
||||
static
|
||||
void _loadSettings(QSettings & settings)
|
||||
{
|
||||
|
@ -87,15 +90,15 @@ void _loadSettings(QSettings & settings)
|
|||
settings.endGroup();
|
||||
}
|
||||
|
||||
void loadSettings(const QString & _strFileName)
|
||||
void loadSettings(const QString & _strIniFolder)
|
||||
{
|
||||
// QSettings settings("Emulation", "GLideN64");
|
||||
QSettings settings(_strFileName, QSettings::IniFormat);
|
||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
||||
config.version = settings.value("version").toInt();
|
||||
if (config.version != CONFIG_VERSION_CURRENT) {
|
||||
config.resetToDefaults();
|
||||
settings.clear();
|
||||
writeSettings(_strFileName);
|
||||
writeSettings(_strIniFolder);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -105,10 +108,10 @@ void loadSettings(const QString & _strFileName)
|
|||
config.generalEmulation.hacks = hacks;
|
||||
}
|
||||
|
||||
void writeSettings(const QString & _strFileName)
|
||||
void writeSettings(const QString & _strIniFolder)
|
||||
{
|
||||
// QSettings settings("Emulation", "GLideN64");
|
||||
QSettings settings(_strFileName, QSettings::IniFormat);
|
||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
||||
settings.setValue("version", config.version);
|
||||
|
||||
settings.beginGroup("video");
|
||||
|
@ -203,9 +206,9 @@ u32 Adler32(u32 crc, const void *buffer, u32 count)
|
|||
return (s2 << 16) | s1;
|
||||
}
|
||||
|
||||
void loadCustomRomSettings(const QString & _strFileName, const char * _strRomName)
|
||||
void loadCustomRomSettings(const QString & _strIniFolder, const char * _strRomName)
|
||||
{
|
||||
QSettings settings(_strFileName, QSettings::IniFormat);
|
||||
QSettings settings(_strIniFolder + "/" + strCustomSettingsFileName, QSettings::IniFormat);
|
||||
config.version = settings.value("version").toInt();
|
||||
if (config.version != CONFIG_VERSION_CURRENT)
|
||||
return;
|
||||
|
@ -215,7 +218,7 @@ void loadCustomRomSettings(const QString & _strFileName, const char * _strRomNam
|
|||
for (int i = 0; i < bytes.length() && bASCII; ++i)
|
||||
bASCII = bytes.at(i) >= 0;
|
||||
|
||||
const QString romName = bASCII ? QString::fromLatin1(_strRomName).toUpper() : QString::number(Adler32(0xFFFFFFFF, bytes.data(), bytes.length()), 16);
|
||||
const QString romName = bASCII ? QString::fromLatin1(_strRomName).toUpper() : QString::number(Adler32(0xFFFFFFFF, bytes.data(), bytes.length()), 16).toUpper();
|
||||
if (settings.childGroups().indexOf(romName) < 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
void loadSettings(const QString & _strFileName);
|
||||
void writeSettings(const QString & _strFileName);
|
||||
void loadCustomRomSettings(const QString & _strFileName, const char * _strRomName);
|
||||
void loadSettings(const QString & _strIniFolder);
|
||||
void writeSettings(const QString & _strIniFolder);
|
||||
void loadCustomRomSettings(const QString & _strIniFolder, const char * _strRomName);
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
||||
|
|
|
@ -7,30 +7,23 @@
|
|||
|
||||
Config config;
|
||||
|
||||
static
|
||||
void _getIniFileName(wchar_t * _buf)
|
||||
{
|
||||
api().FindPluginPath(_buf);
|
||||
wcscat(_buf, L"/GLideN64.ini");
|
||||
}
|
||||
|
||||
void Config_DoConfig(/*HWND hParent*/)
|
||||
{
|
||||
wchar_t strIniFileName[PLUGIN_PATH_SIZE];
|
||||
_getIniFileName(strIniFileName);
|
||||
wchar_t strIniFolderPath[PLUGIN_PATH_SIZE];
|
||||
api().FindPluginPath(strIniFolderPath);
|
||||
|
||||
const bool bRestart = RunConfig(strIniFileName);
|
||||
const bool bRestart = RunConfig(strIniFolderPath);
|
||||
if (config.generalEmulation.enableCustomSettings != 0)
|
||||
LoadCustomRomSettings(strIniFileName, RSP.romname);
|
||||
LoadCustomRomSettings(strIniFolderPath, RSP.romname);
|
||||
if (bRestart)
|
||||
video().restart();
|
||||
}
|
||||
|
||||
void Config_LoadConfig()
|
||||
{
|
||||
wchar_t strIniFileName[PLUGIN_PATH_SIZE];
|
||||
_getIniFileName(strIniFileName);
|
||||
LoadConfig(strIniFileName);
|
||||
wchar_t strIniFolderPath[PLUGIN_PATH_SIZE];
|
||||
api().FindPluginPath(strIniFolderPath);
|
||||
LoadConfig(strIniFolderPath);
|
||||
if (config.generalEmulation.enableCustomSettings != 0)
|
||||
LoadCustomRomSettings(strIniFileName, RSP.romname);
|
||||
LoadCustomRomSettings(strIniFolderPath, RSP.romname);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user