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