Merge pull request #12565 from LillyJadeKatrin/retroachievements-bugfix

Retain Save State Folder
This commit is contained in:
Mai 2024-02-07 14:03:12 -05:00 committed by GitHub
commit ca81d8b8a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 6 deletions

View File

@ -15,5 +15,6 @@ const Info<bool> MAIN_USE_GAME_COVERS{{System::Main, "General", "UseGameCovers"}
#endif
const Info<bool> MAIN_FOCUSED_HOTKEYS{{System::Main, "General", "HotkeysRequireFocus"}, true};
const Info<bool> MAIN_RECURSIVE_ISO_PATHS{{System::Main, "General", "RecursiveISOPaths"}, false};
const Info<std::string> MAIN_CURRENT_STATE_PATH{{System::Main, "General", "CurrentStatePath"}, ""};
} // namespace Config

View File

@ -19,5 +19,6 @@ extern const Info<bool> MAIN_USE_DISCORD_PRESENCE;
extern const Info<bool> MAIN_USE_GAME_COVERS;
extern const Info<bool> MAIN_FOCUSED_HOTKEYS;
extern const Info<bool> MAIN_RECURSIVE_ISO_PATHS;
extern const Info<std::string> MAIN_CURRENT_STATE_PATH;
} // namespace Config

View File

@ -45,6 +45,7 @@
#include "Core/Config/AchievementSettings.h"
#include "Core/Config/MainSettings.h"
#include "Core/Config/NetplaySettings.h"
#include "Core/Config/UISettings.h"
#include "Core/Config/WiimoteSettings.h"
#include "Core/Core.h"
#include "Core/FreeLookManager.h"
@ -1404,18 +1405,24 @@ void MainWindow::ShowInfinityBase()
void MainWindow::StateLoad()
{
QString path =
DolphinFileDialog::getOpenFileName(this, tr("Select a File"), QDir::currentPath(),
tr("All Save States (*.sav *.s##);; All Files (*)"));
QString dialog_path = (Config::Get(Config::MAIN_CURRENT_STATE_PATH).empty()) ?
QDir::currentPath() :
QString::fromStdString(Config::Get(Config::MAIN_CURRENT_STATE_PATH));
QString path = DolphinFileDialog::getOpenFileName(
this, tr("Select a File"), dialog_path, tr("All Save States (*.sav *.s##);; All Files (*)"));
Config::SetBase(Config::MAIN_CURRENT_STATE_PATH, QFileInfo(path).dir().path().toStdString());
if (!path.isEmpty())
State::LoadAs(path.toStdString());
}
void MainWindow::StateSave()
{
QString path =
DolphinFileDialog::getSaveFileName(this, tr("Select a File"), QDir::currentPath(),
tr("All Save States (*.sav *.s##);; All Files (*)"));
QString dialog_path = (Config::Get(Config::MAIN_CURRENT_STATE_PATH).empty()) ?
QDir::currentPath() :
QString::fromStdString(Config::Get(Config::MAIN_CURRENT_STATE_PATH));
QString path = DolphinFileDialog::getSaveFileName(
this, tr("Select a File"), dialog_path, tr("All Save States (*.sav *.s##);; All Files (*)"));
Config::SetBase(Config::MAIN_CURRENT_STATE_PATH, QFileInfo(path).dir().path().toStdString());
if (!path.isEmpty())
State::SaveAs(path.toStdString());
}