Skip to content

Commit

Permalink
actually save path settings in instance-local config
Browse files Browse the repository at this point in the history
  • Loading branch information
Arisotura committed Nov 18, 2024
1 parent bca0457 commit b491e99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/frontend/qt_sdl/EmuInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ std::string EmuInstance::getSavestateName(int slot)
{
std::string ext = ".ml";
ext += (char)('0'+slot);
return getAssetPath(false, globalCfg.GetString("SavestatePath"), ext);
return getAssetPath(false, localCfg.GetString("SavestatePath"), ext);
}

bool EmuInstance::savestateExists(int slot)
Expand Down Expand Up @@ -752,7 +752,7 @@ bool EmuInstance::loadState(const std::string& filename)
previousSaveFile = ndsSave->GetPath();

std::string savefile = filename.substr(lastSep(filename)+1);
savefile = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav", savefile);
savefile = getAssetPath(false, localCfg.GetString("SaveFilePath"), ".sav", savefile);
savefile += instanceFileSuffix();
ndsSave->SetPath(savefile, true);
}
Expand Down Expand Up @@ -803,7 +803,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, globalCfg.GetString("SaveFilePath"), ".sav", savefile);
savefile = getAssetPath(false, localCfg.GetString("SaveFilePath"), ".sav", savefile);
savefile += instanceFileSuffix();
ndsSave->SetPath(savefile, false);
}
Expand Down Expand Up @@ -839,7 +839,7 @@ void EmuInstance::loadCheats()
{
unloadCheats();

std::string filename = getAssetPath(false, globalCfg.GetString("CheatFilePath"), ".mch");
std::string filename = getAssetPath(false, localCfg.GetString("CheatFilePath"), ".mch");

// TODO: check for error (malformed cheat file, ...)
cheatFile = std::make_unique<ARCodeFile>(filename);
Expand Down Expand Up @@ -1405,7 +1405,7 @@ void EmuInstance::reset()
if ((cartType != -1) && ndsSave)
{
std::string oldsave = ndsSave->GetPath();
std::string newsave = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav");
std::string newsave = getAssetPath(false, localCfg.GetString("SaveFilePath"), ".sav");
newsave += instanceFileSuffix();
if (oldsave != newsave)
ndsSave->SetPath(newsave, false);
Expand All @@ -1414,7 +1414,7 @@ void EmuInstance::reset()
if ((gbaCartType != -1) && gbaSave)
{
std::string oldsave = gbaSave->GetPath();
std::string newsave = getAssetPath(true, globalCfg.GetString("SaveFilePath"), ".sav");
std::string newsave = getAssetPath(true, localCfg.GetString("SaveFilePath"), ".sav");
newsave += instanceFileSuffix();
if (oldsave != newsave)
gbaSave->SetPath(newsave, false);
Expand Down Expand Up @@ -1863,7 +1863,7 @@ bool EmuInstance::loadROM(QStringList filepath, bool reset)
u32 savelen = 0;
std::unique_ptr<u8[]> savedata = nullptr;

std::string savname = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav");
std::string savname = getAssetPath(false, localCfg.GetString("SaveFilePath"), ".sav");
std::string origsav = savname;
savname += instanceFileSuffix();

Expand Down Expand Up @@ -2022,7 +2022,7 @@ bool EmuInstance::loadGBAROM(QStringList filepath)
u32 savelen = 0;
std::unique_ptr<u8[]> savedata = nullptr;

std::string savname = getAssetPath(true, globalCfg.GetString("SaveFilePath"), ".sav");
std::string savname = getAssetPath(true, localCfg.GetString("SaveFilePath"), ".sav");
std::string origsav = savname;
savname += instanceFileSuffix();

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/qt_sdl/PathSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ PathSettingsDialog::PathSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne

emuInstance = ((MainWindow*)parent)->getEmuInstance();

auto& cfg = emuInstance->getGlobalConfig();
auto& cfg = emuInstance->getLocalConfig();
ui->txtSaveFilePath->setText(cfg.GetQString("SaveFilePath"));
ui->txtSavestatePath->setText(cfg.GetQString("SavestatePath"));
ui->txtCheatFilePath->setText(cfg.GetQString("CheatFilePath"));
Expand Down Expand Up @@ -108,7 +108,7 @@ void PathSettingsDialog::done(int r)
QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Ok)
return;

auto& cfg = emuInstance->getGlobalConfig();
auto& cfg = emuInstance->getLocalConfig();
cfg.SetQString("SaveFilePath", ui->txtSaveFilePath->text());
cfg.SetQString("SavestatePath", ui->txtSavestatePath->text());
cfg.SetQString("CheatFilePath", ui->txtCheatFilePath->text());
Expand Down

0 comments on commit b491e99

Please sign in to comment.