Retain Save State Folder

Adds a setting field under the hood to retain which folder the player last saved/loaded a state to/from, so that the dialog box to select a state to save/load reopens at that folder.
This commit is contained in:
LillyJadeKatrin 2024-02-05 19:41:25 -05:00
parent 9240f579ea
commit 1ed7b35710
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());
}