mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-24 21:39:35 +00:00
parent
2322f5f53f
commit
6a1a4b590d
|
@ -4,7 +4,8 @@
|
|||
#include <string>
|
||||
#include "Types.h"
|
||||
|
||||
#define CONFIG_VERSION_CURRENT 22U
|
||||
#define CONFIG_WITH_PROFILES 23U
|
||||
#define CONFIG_VERSION_CURRENT 23U
|
||||
|
||||
#define BILINEAR_3POINT 0
|
||||
#define BILINEAR_STANDARD 1
|
||||
|
|
|
@ -331,11 +331,24 @@ void ConfigDialog::setIniPath(const QString & _strIniPath)
|
|||
|
||||
ui->translationsComboBox->insertItems(0, translationLanguages);
|
||||
ui->translationsComboBox->setCurrentIndex(listIndex);
|
||||
|
||||
// Profile
|
||||
ui->profilesComboBox->blockSignals(true);
|
||||
const QStringList aProfiles = getProfiles(m_strIniPath);
|
||||
ui->profilesComboBox->addItems(aProfiles);
|
||||
ui->profilesComboBox->setCurrentIndex(aProfiles.indexOf(getCurrentProfile(m_strIniPath)));
|
||||
ui->profilesComboBox->blockSignals(false);
|
||||
ui->removeProfilePushButton->setEnabled(ui->profilesComboBox->count() > 1);
|
||||
}
|
||||
|
||||
void ConfigDialog::setRomName(const char * _romName)
|
||||
{
|
||||
m_romName = _romName;
|
||||
const bool bRomNameIsEmpty = _romName == nullptr || strlen(_romName) == 0;
|
||||
m_romName = bRomNameIsEmpty ? nullptr : _romName;
|
||||
ui->customSettingsCheckBox->setEnabled(bRomNameIsEmpty);
|
||||
ui->profilesComboBox->setEnabled(bRomNameIsEmpty);
|
||||
ui->removeProfilePushButton->setEnabled(bRomNameIsEmpty && ui->profilesComboBox->count() > 1);
|
||||
ui->addProfilePushButton->setEnabled(bRomNameIsEmpty);
|
||||
}
|
||||
|
||||
ConfigDialog::ConfigDialog(QWidget *parent, Qt::WindowFlags f) :
|
||||
|
@ -525,10 +538,10 @@ void ConfigDialog::accept()
|
|||
if (ui->dumpDetailCheckBox->isChecked())
|
||||
config.debug.dumpMode |= DEBUG_DETAIL;
|
||||
|
||||
if (config.generalEmulation.enableCustomSettings != 0 && m_romName != nullptr && strlen(m_romName) != 0)
|
||||
if (config.generalEmulation.enableCustomSettings != 0 && m_romName != nullptr)
|
||||
saveCustomRomSettings(m_strIniPath, m_romName);
|
||||
|
||||
writeSettings(m_strIniPath);
|
||||
else
|
||||
writeSettings(m_strIniPath);
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
@ -707,6 +720,9 @@ void ConfigDialog::on_tabWidget_currentChanged(int tab)
|
|||
|
||||
void ConfigDialog::on_customSettingsCheckBox_clicked()
|
||||
{
|
||||
if (m_romName == nullptr)
|
||||
return;
|
||||
|
||||
if (ui->customSettingsCheckBox->isChecked()) {
|
||||
loadCustomRomSettings(m_strIniPath, m_romName);
|
||||
config.generalEmulation.enableCustomSettings = 1;
|
||||
|
@ -720,7 +736,7 @@ void ConfigDialog::on_customSettingsCheckBox_clicked()
|
|||
|
||||
void ConfigDialog::setTitle()
|
||||
{
|
||||
if (config.generalEmulation.enableCustomSettings != 0 && m_romName != nullptr && strlen(m_romName) != 0) {
|
||||
if (config.generalEmulation.enableCustomSettings != 0 && m_romName != nullptr) {
|
||||
QString title(tr("GLideN64 Settings for "));
|
||||
title += QString::fromLatin1(m_romName);
|
||||
setWindowTitle(title);
|
||||
|
@ -728,3 +744,64 @@ void ConfigDialog::setTitle()
|
|||
setWindowTitle(tr("GLideN64 Settings"));
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigDialog::on_profilesComboBox_currentIndexChanged(const QString &profile)
|
||||
{
|
||||
changeProfile(m_strIniPath, profile);
|
||||
_init();
|
||||
}
|
||||
|
||||
void ConfigDialog::on_addProfilePushButton_clicked()
|
||||
{
|
||||
QString profile = ui->profilesComboBox->currentText();
|
||||
if (profile.isEmpty()) {
|
||||
QMessageBox msgBox(QMessageBox::Warning, tr("Cannot add profile"),
|
||||
tr("Empty profile name."),
|
||||
QMessageBox::Ok, this
|
||||
);
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
if (getProfiles(m_strIniPath).contains(profile)) {
|
||||
QString msg(tr("Profile \""));
|
||||
msg += profile + tr("\" already exists.");
|
||||
QMessageBox msgBox(QMessageBox::Warning, tr("Cannot add profile"), msg, QMessageBox::Ok, this);
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
addProfile(m_strIniPath, profile);
|
||||
ui->profilesComboBox->addItem(profile);
|
||||
for (int i = 0; i < ui->profilesComboBox->count(); ++i) {
|
||||
if (ui->profilesComboBox->itemText(i) == profile) {
|
||||
ui->profilesComboBox->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ui->removeProfilePushButton->setDisabled(false);
|
||||
}
|
||||
|
||||
void ConfigDialog::on_removeProfilePushButton_clicked()
|
||||
{
|
||||
if (ui->profilesComboBox->count() < 2)
|
||||
return;
|
||||
|
||||
QString profile = ui->profilesComboBox->currentText();
|
||||
if (!getProfiles(m_strIniPath).contains(profile))
|
||||
return;
|
||||
QString msg(tr("Are you sure you want to remove profile \""));
|
||||
msg += profile + "\"";
|
||||
QMessageBox msgBox(QMessageBox::Warning, tr("Remove profile"),
|
||||
msg, QMessageBox::Yes | QMessageBox::Cancel, this);
|
||||
msgBox.setDefaultButton(QMessageBox::Cancel);
|
||||
msgBox.setButtonText(QMessageBox::Yes, tr("Yes"));
|
||||
msgBox.setButtonText(QMessageBox::Cancel, tr("Cancel"));
|
||||
if (msgBox.exec() == QMessageBox::Yes) {
|
||||
removeProfile(m_strIniPath, profile);
|
||||
ui->profilesComboBox->blockSignals(true);
|
||||
ui->profilesComboBox->removeItem(ui->profilesComboBox->currentIndex());
|
||||
changeProfile(m_strIniPath, ui->profilesComboBox->itemText(ui->profilesComboBox->currentIndex()));
|
||||
ui->profilesComboBox->blockSignals(false);
|
||||
_init();
|
||||
ui->removeProfilePushButton->setDisabled(ui->profilesComboBox->count() < 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,12 @@ private slots:
|
|||
|
||||
void on_customSettingsCheckBox_clicked();
|
||||
|
||||
void on_profilesComboBox_currentIndexChanged(const QString &arg1);
|
||||
|
||||
void on_addProfilePushButton_clicked();
|
||||
|
||||
void on_removeProfilePushButton_clicked();
|
||||
|
||||
private:
|
||||
void _init();
|
||||
void _getTranslations(QStringList & _translationFiles) const;
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
|
||||
static const char * strIniFileName = "GLideN64.ini";
|
||||
static const char * strCustomSettingsFileName = "GLideN64.custom.ini";
|
||||
static QString strUserProfile("User");
|
||||
|
||||
static
|
||||
void _loadSettings(QSettings & settings)
|
||||
{
|
||||
config.translationFile = settings.value("translation", config.translationFile.c_str()).toString().toLocal8Bit().constData();
|
||||
config.version = settings.value("version").toInt();
|
||||
|
||||
settings.beginGroup("video");
|
||||
config.video.fullscreenWidth = settings.value("fullscreenWidth", config.video.fullscreenWidth).toInt();
|
||||
|
@ -127,22 +128,45 @@ void _loadSettings(QSettings & settings)
|
|||
|
||||
void loadSettings(const QString & _strIniFolder)
|
||||
{
|
||||
// QSettings settings("Emulation", "GLideN64");
|
||||
const u32 hacks = config.generalEmulation.hacks;
|
||||
|
||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
||||
config.version = settings.value("version").toInt();
|
||||
if (config.version != CONFIG_VERSION_CURRENT) {
|
||||
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();
|
||||
settings.clear();
|
||||
writeSettings(_strIniFolder);
|
||||
config.generalEmulation.hacks = hacks;
|
||||
return;
|
||||
config.translationFile = configTranslationFile.toLocal8Bit().constData();
|
||||
if (configVersion < CONFIG_WITH_PROFILES) {
|
||||
settings.clear();
|
||||
settings.setValue("version", configVersion);
|
||||
settings.setValue("profile", strUserProfile);
|
||||
settings.setValue("translation", config.translationFile.c_str());
|
||||
settings.beginGroup(strUserProfile);
|
||||
writeSettings(_strIniFolder);
|
||||
settings.endGroup();
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
config.resetToDefaults();
|
||||
_loadSettings(settings);
|
||||
config.generalEmulation.hacks = hacks;
|
||||
}
|
||||
|
||||
void writeSettings(const QString & _strIniFolder)
|
||||
|
@ -150,8 +174,11 @@ void writeSettings(const QString & _strIniFolder)
|
|||
// QSettings settings("Emulation", "GLideN64");
|
||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
||||
settings.setValue("version", config.version);
|
||||
|
||||
settings.setValue("translation", config.translationFile.c_str());
|
||||
QString profile = settings.value("profile", strUserProfile).toString();
|
||||
|
||||
settings.beginGroup(profile);
|
||||
settings.setValue("version", config.version);
|
||||
|
||||
settings.beginGroup("video");
|
||||
settings.setValue("fullscreenWidth", config.video.fullscreenWidth);
|
||||
|
@ -245,6 +272,8 @@ void writeSettings(const QString & _strIniFolder)
|
|||
settings.beginGroup("debug");
|
||||
settings.setValue("dumpMode", config.debug.dumpMode);
|
||||
settings.endGroup();
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -297,6 +326,7 @@ void loadCustomRomSettings(const QString & _strIniFolder, const char * _strRomNa
|
|||
settings.beginGroup(romName);
|
||||
_loadSettings(settings);
|
||||
settings.endGroup();
|
||||
config.version = CONFIG_VERSION_CURRENT;
|
||||
}
|
||||
|
||||
void saveCustomRomSettings(const QString & _strIniFolder, const char * _strRomName)
|
||||
|
@ -400,3 +430,39 @@ QString getTranslationFile()
|
|||
{
|
||||
return config.translationFile.c_str();
|
||||
}
|
||||
|
||||
QStringList getProfiles(const QString & _strIniFolder)
|
||||
{
|
||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
||||
return settings.childGroups();
|
||||
}
|
||||
|
||||
QString getCurrentProfile(const QString & _strIniFolder)
|
||||
{
|
||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
||||
return settings.value("profile", strUserProfile).toString();
|
||||
}
|
||||
|
||||
void changeProfile(const QString & _strIniFolder, const QString & _strProfile)
|
||||
{
|
||||
{
|
||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
||||
settings.setValue("profile", _strProfile);
|
||||
}
|
||||
loadSettings(_strIniFolder);
|
||||
}
|
||||
|
||||
void addProfile(const QString & _strIniFolder, const QString & _strProfile)
|
||||
{
|
||||
{
|
||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
||||
settings.setValue("profile", _strProfile);
|
||||
}
|
||||
writeSettings(_strIniFolder);
|
||||
}
|
||||
|
||||
void removeProfile(const QString & _strIniFolder, const QString & _strProfile)
|
||||
{
|
||||
QSettings settings(_strIniFolder + "/" + strIniFileName, QSettings::IniFormat);
|
||||
settings.remove(_strProfile);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@ void writeSettings(const QString & _strIniFolder);
|
|||
void loadCustomRomSettings(const QString & _strIniFolder, const char * _strRomName);
|
||||
void saveCustomRomSettings(const QString & _strIniFolder, const char * _strRomName);
|
||||
QString getTranslationFile();
|
||||
QStringList getProfiles(const QString & _strIniFolder);
|
||||
QString getCurrentProfile(const QString & _strIniFolder);
|
||||
void changeProfile(const QString & _strIniFolder, const QString & _strProfile);
|
||||
void addProfile(const QString & _strIniFolder, const QString & _strProfile);
|
||||
void removeProfile(const QString & _strIniFolder, const QString & _strProfile);
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
||||
|
|
|
@ -1000,6 +1000,38 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="addProfilePushButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="removeProfilePushButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="profilesComboBox">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Profile:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in New Issue
Block a user