port PathSettings
This commit is contained in:
parent
5855e93f43
commit
038f7a9171
|
@ -78,10 +78,6 @@ int MPRecvTimeout;
|
||||||
std::string LANDevice;
|
std::string LANDevice;
|
||||||
bool DirectLAN;
|
bool DirectLAN;
|
||||||
|
|
||||||
std::string SaveFilePath;
|
|
||||||
std::string SavestatePath;
|
|
||||||
std::string CheatFilePath;
|
|
||||||
|
|
||||||
int64_t RTCOffset;
|
int64_t RTCOffset;
|
||||||
|
|
||||||
bool DSBatteryLevelOkay;
|
bool DSBatteryLevelOkay;
|
||||||
|
|
|
@ -192,10 +192,6 @@ extern int MPRecvTimeout;
|
||||||
extern std::string LANDevice;
|
extern std::string LANDevice;
|
||||||
extern bool DirectLAN;
|
extern bool DirectLAN;
|
||||||
|
|
||||||
extern std::string SaveFilePath;
|
|
||||||
extern std::string SavestatePath;
|
|
||||||
extern std::string CheatFilePath;
|
|
||||||
|
|
||||||
extern int64_t RTCOffset;
|
extern int64_t RTCOffset;
|
||||||
|
|
||||||
extern bool DSBatteryLevelOkay;
|
extern bool DSBatteryLevelOkay;
|
||||||
|
|
|
@ -423,7 +423,7 @@ std::string EmuInstance::getSavestateName(int slot)
|
||||||
{
|
{
|
||||||
std::string ext = ".ml";
|
std::string ext = ".ml";
|
||||||
ext += (char)('0'+slot);
|
ext += (char)('0'+slot);
|
||||||
return getAssetPath(false, Config::SavestatePath, ext);
|
return getAssetPath(false, globalCfg.GetString("SavestatePath"), ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmuInstance::savestateExists(int slot)
|
bool EmuInstance::savestateExists(int slot)
|
||||||
|
@ -496,7 +496,7 @@ bool EmuInstance::loadState(const std::string& filename)
|
||||||
previousSaveFile = ndsSave->GetPath();
|
previousSaveFile = ndsSave->GetPath();
|
||||||
|
|
||||||
std::string savefile = filename.substr(lastSep(filename)+1);
|
std::string savefile = filename.substr(lastSep(filename)+1);
|
||||||
savefile = getAssetPath(false, Config::SaveFilePath, ".sav", savefile);
|
savefile = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav", savefile);
|
||||||
savefile += Platform::InstanceFileSuffix();
|
savefile += Platform::InstanceFileSuffix();
|
||||||
ndsSave->SetPath(savefile, true);
|
ndsSave->SetPath(savefile, true);
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ bool EmuInstance::saveState(const std::string& filename)
|
||||||
if (globalCfg.GetBool("Savestate.RelocSRAM") && ndsSave)
|
if (globalCfg.GetBool("Savestate.RelocSRAM") && ndsSave)
|
||||||
{
|
{
|
||||||
std::string savefile = filename.substr(lastSep(filename)+1);
|
std::string savefile = filename.substr(lastSep(filename)+1);
|
||||||
savefile = getAssetPath(false, Config::SaveFilePath, ".sav", savefile);
|
savefile = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav", savefile);
|
||||||
savefile += Platform::InstanceFileSuffix();
|
savefile += Platform::InstanceFileSuffix();
|
||||||
ndsSave->SetPath(savefile, false);
|
ndsSave->SetPath(savefile, false);
|
||||||
}
|
}
|
||||||
|
@ -587,7 +587,7 @@ void EmuInstance::loadCheats()
|
||||||
{
|
{
|
||||||
unloadCheats();
|
unloadCheats();
|
||||||
|
|
||||||
std::string filename = getAssetPath(false, Config::CheatFilePath, ".mch");
|
std::string filename = getAssetPath(false, globalCfg.GetString("CheatFilePath"), ".mch");
|
||||||
|
|
||||||
// TODO: check for error (malformed cheat file, ...)
|
// TODO: check for error (malformed cheat file, ...)
|
||||||
cheatFile = new ARCodeFile(filename);
|
cheatFile = new ARCodeFile(filename);
|
||||||
|
@ -1107,7 +1107,7 @@ void EmuInstance::reset()
|
||||||
if ((cartType != -1) && ndsSave)
|
if ((cartType != -1) && ndsSave)
|
||||||
{
|
{
|
||||||
std::string oldsave = ndsSave->GetPath();
|
std::string oldsave = ndsSave->GetPath();
|
||||||
std::string newsave = getAssetPath(false, Config::SaveFilePath, ".sav");
|
std::string newsave = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav");
|
||||||
newsave += Platform::InstanceFileSuffix();
|
newsave += Platform::InstanceFileSuffix();
|
||||||
if (oldsave != newsave)
|
if (oldsave != newsave)
|
||||||
ndsSave->SetPath(newsave, false);
|
ndsSave->SetPath(newsave, false);
|
||||||
|
@ -1116,7 +1116,7 @@ void EmuInstance::reset()
|
||||||
if ((gbaCartType != -1) && gbaSave)
|
if ((gbaCartType != -1) && gbaSave)
|
||||||
{
|
{
|
||||||
std::string oldsave = gbaSave->GetPath();
|
std::string oldsave = gbaSave->GetPath();
|
||||||
std::string newsave = getAssetPath(true, Config::SaveFilePath, ".sav");
|
std::string newsave = getAssetPath(true, globalCfg.GetString("SaveFilePath"), ".sav");
|
||||||
newsave += Platform::InstanceFileSuffix();
|
newsave += Platform::InstanceFileSuffix();
|
||||||
if (oldsave != newsave)
|
if (oldsave != newsave)
|
||||||
gbaSave->SetPath(newsave, false);
|
gbaSave->SetPath(newsave, false);
|
||||||
|
@ -1564,7 +1564,7 @@ bool EmuInstance::loadROM(QStringList filepath, bool reset)
|
||||||
u32 savelen = 0;
|
u32 savelen = 0;
|
||||||
std::unique_ptr<u8[]> savedata = nullptr;
|
std::unique_ptr<u8[]> savedata = nullptr;
|
||||||
|
|
||||||
std::string savname = getAssetPath(false, Config::SaveFilePath, ".sav");
|
std::string savname = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav");
|
||||||
std::string origsav = savname;
|
std::string origsav = savname;
|
||||||
savname += Platform::InstanceFileSuffix();
|
savname += Platform::InstanceFileSuffix();
|
||||||
|
|
||||||
|
@ -1706,7 +1706,7 @@ bool EmuInstance::loadGBAROM(QStringList filepath)
|
||||||
u32 savelen = 0;
|
u32 savelen = 0;
|
||||||
std::unique_ptr<u8[]> savedata = nullptr;
|
std::unique_ptr<u8[]> savedata = nullptr;
|
||||||
|
|
||||||
std::string savname = getAssetPath(true, Config::SaveFilePath, ".sav");
|
std::string savname = getAssetPath(true, globalCfg.GetString("SaveFilePath"), ".sav");
|
||||||
std::string origsav = savname;
|
std::string origsav = savname;
|
||||||
savname += Platform::InstanceFileSuffix();
|
savname += Platform::InstanceFileSuffix();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
#include "PathSettingsDialog.h"
|
#include "PathSettingsDialog.h"
|
||||||
#include "ui_PathSettingsDialog.h"
|
#include "ui_PathSettingsDialog.h"
|
||||||
|
@ -45,15 +46,26 @@ PathSettingsDialog::PathSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
ui->txtSaveFilePath->setText(QString::fromStdString(Config::SaveFilePath));
|
emuInstance = ((MainWindow*)parent)->getEmuInstance();
|
||||||
ui->txtSavestatePath->setText(QString::fromStdString(Config::SavestatePath));
|
|
||||||
ui->txtCheatFilePath->setText(QString::fromStdString(Config::CheatFilePath));
|
auto& cfg = emuInstance->getGlobalConfig();
|
||||||
|
ui->txtSaveFilePath->setText(cfg.GetQString("SaveFilePath"));
|
||||||
|
ui->txtSavestatePath->setText(cfg.GetQString("SavestatePath"));
|
||||||
|
ui->txtCheatFilePath->setText(cfg.GetQString("CheatFilePath"));
|
||||||
|
|
||||||
int inst = Platform::InstanceID();
|
int inst = Platform::InstanceID();
|
||||||
if (inst > 0)
|
if (inst > 0)
|
||||||
ui->lblInstanceNum->setText(QString("Configuring paths for instance %1").arg(inst+1));
|
ui->lblInstanceNum->setText(QString("Configuring paths for instance %1").arg(inst+1));
|
||||||
else
|
else
|
||||||
ui->lblInstanceNum->hide();
|
ui->lblInstanceNum->hide();
|
||||||
|
|
||||||
|
#define SET_ORIGVAL(type, val) \
|
||||||
|
for (type* w : findChildren<type*>(nullptr)) \
|
||||||
|
w->setProperty("user_originalValue", w->val());
|
||||||
|
|
||||||
|
SET_ORIGVAL(QLineEdit, text);
|
||||||
|
|
||||||
|
#undef SET_ORIGVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
PathSettingsDialog::~PathSettingsDialog()
|
PathSettingsDialog::~PathSettingsDialog()
|
||||||
|
@ -67,13 +79,24 @@ void PathSettingsDialog::done(int r)
|
||||||
|
|
||||||
if (r == QDialog::Accepted)
|
if (r == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
std::string saveFilePath = ui->txtSaveFilePath->text().toStdString();
|
bool modified = false;
|
||||||
std::string savestatePath = ui->txtSavestatePath->text().toStdString();
|
|
||||||
std::string cheatFilePath = ui->txtCheatFilePath->text().toStdString();
|
|
||||||
|
|
||||||
if ( saveFilePath != Config::SaveFilePath
|
#define CHECK_ORIGVAL(type, val) \
|
||||||
|| savestatePath != Config::SavestatePath
|
if (!modified) for (type* w : findChildren<type*>(nullptr)) \
|
||||||
|| cheatFilePath != Config::CheatFilePath)
|
{ \
|
||||||
|
QVariant v = w->val(); \
|
||||||
|
if (v != w->property("user_originalValue")) \
|
||||||
|
{ \
|
||||||
|
modified = true; \
|
||||||
|
break; \
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_ORIGVAL(QLineEdit, text);
|
||||||
|
|
||||||
|
#undef CHECK_ORIGVAL
|
||||||
|
|
||||||
|
if (modified)
|
||||||
{
|
{
|
||||||
if (RunningSomething
|
if (RunningSomething
|
||||||
&& QMessageBox::warning(this, "Reset necessary to apply changes",
|
&& QMessageBox::warning(this, "Reset necessary to apply changes",
|
||||||
|
@ -81,9 +104,10 @@ void PathSettingsDialog::done(int r)
|
||||||
QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Ok)
|
QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Ok)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Config::SaveFilePath = saveFilePath;
|
auto& cfg = emuInstance->getGlobalConfig();
|
||||||
Config::SavestatePath = savestatePath;
|
cfg.SetQString("SaveFilePath", ui->txtSaveFilePath->text());
|
||||||
Config::CheatFilePath = cheatFilePath;
|
cfg.SetQString("SavestatePath", ui->txtSavestatePath->text());
|
||||||
|
cfg.SetQString("CheatFilePath", ui->txtCheatFilePath->text());
|
||||||
|
|
||||||
Config::Save();
|
Config::Save();
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
namespace Ui { class PathSettingsDialog; }
|
namespace Ui { class PathSettingsDialog; }
|
||||||
class PathSettingsDialog;
|
class PathSettingsDialog;
|
||||||
|
|
||||||
|
class EmuInstance;
|
||||||
|
|
||||||
class PathSettingsDialog : public QDialog
|
class PathSettingsDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -62,6 +64,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PathSettingsDialog* ui;
|
Ui::PathSettingsDialog* ui;
|
||||||
|
EmuInstance* emuInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PATHSETTINGSDIALOG_H
|
#endif // PATHSETTINGSDIALOG_H
|
||||||
|
|
Loading…
Reference in New Issue