mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Core/Boot: Refactor storage of boot-to-savestate data into a separate class.
This commit is contained in:
@ -197,7 +197,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||
const std::list<std::string> paths_list = options.all("exec");
|
||||
const std::vector<std::string> paths{std::make_move_iterator(std::begin(paths_list)),
|
||||
std::make_move_iterator(std::end(paths_list))};
|
||||
boot = BootParameters::GenerateFromFile(paths, save_state_path);
|
||||
boot = BootParameters::GenerateFromFile(
|
||||
paths, BootSessionData(save_state_path, DeleteSavestateAfterBoot::No));
|
||||
game_specified = true;
|
||||
}
|
||||
else if (options.is_set("nand_title"))
|
||||
@ -216,7 +217,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||
}
|
||||
else if (!args.empty())
|
||||
{
|
||||
boot = BootParameters::GenerateFromFile(args.front(), save_state_path);
|
||||
boot = BootParameters::GenerateFromFile(
|
||||
args.front(), BootSessionData(save_state_path, DeleteSavestateAfterBoot::No));
|
||||
game_specified = true;
|
||||
}
|
||||
|
||||
|
@ -244,8 +244,13 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters,
|
||||
|
||||
if (!movie_path.empty())
|
||||
{
|
||||
if (Movie::PlayInput(movie_path, &m_pending_boot->savestate_path))
|
||||
std::optional<std::string> savestate_path;
|
||||
if (Movie::PlayInput(movie_path, &savestate_path))
|
||||
{
|
||||
m_pending_boot->boot_session_data.SetSavestateData(std::move(savestate_path),
|
||||
DeleteSavestateAfterBoot::No);
|
||||
emit RecordingStatusChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -768,14 +773,16 @@ void MainWindow::Play(const std::optional<std::string>& savestate_path)
|
||||
std::shared_ptr<const UICommon::GameFile> selection = m_game_list->GetSelectedGame();
|
||||
if (selection)
|
||||
{
|
||||
StartGame(selection->GetFilePath(), ScanForSecondDisc::Yes, savestate_path);
|
||||
StartGame(selection->GetFilePath(), ScanForSecondDisc::Yes,
|
||||
std::make_unique<BootSessionData>(savestate_path, DeleteSavestateAfterBoot::No));
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString default_path = QString::fromStdString(Config::Get(Config::MAIN_DEFAULT_ISO));
|
||||
if (!default_path.isEmpty() && QFile::exists(default_path))
|
||||
{
|
||||
StartGame(default_path, ScanForSecondDisc::Yes, savestate_path);
|
||||
StartGame(default_path, ScanForSecondDisc::Yes,
|
||||
std::make_unique<BootSessionData>(savestate_path, DeleteSavestateAfterBoot::No));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -978,7 +985,7 @@ void MainWindow::ScreenShot()
|
||||
}
|
||||
|
||||
void MainWindow::ScanForSecondDiscAndStartGame(const UICommon::GameFile& game,
|
||||
const std::optional<std::string>& savestate_path)
|
||||
std::unique_ptr<BootSessionData> boot_session_data)
|
||||
{
|
||||
auto second_game = m_game_list->FindSecondDisc(game);
|
||||
|
||||
@ -986,35 +993,37 @@ void MainWindow::ScanForSecondDiscAndStartGame(const UICommon::GameFile& game,
|
||||
if (second_game != nullptr)
|
||||
paths.push_back(second_game->GetFilePath());
|
||||
|
||||
StartGame(paths, savestate_path);
|
||||
StartGame(paths, std::move(boot_session_data));
|
||||
}
|
||||
|
||||
void MainWindow::StartGame(const QString& path, ScanForSecondDisc scan,
|
||||
const std::optional<std::string>& savestate_path)
|
||||
std::unique_ptr<BootSessionData> boot_session_data)
|
||||
{
|
||||
StartGame(path.toStdString(), scan, savestate_path);
|
||||
StartGame(path.toStdString(), scan, std::move(boot_session_data));
|
||||
}
|
||||
|
||||
void MainWindow::StartGame(const std::string& path, ScanForSecondDisc scan,
|
||||
const std::optional<std::string>& savestate_path)
|
||||
std::unique_ptr<BootSessionData> boot_session_data)
|
||||
{
|
||||
if (scan == ScanForSecondDisc::Yes)
|
||||
{
|
||||
std::shared_ptr<const UICommon::GameFile> game = m_game_list->FindGame(path);
|
||||
if (game != nullptr)
|
||||
{
|
||||
ScanForSecondDiscAndStartGame(*game, savestate_path);
|
||||
ScanForSecondDiscAndStartGame(*game, std::move(boot_session_data));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
StartGame(BootParameters::GenerateFromFile(path, savestate_path));
|
||||
StartGame(BootParameters::GenerateFromFile(
|
||||
path, boot_session_data ? std::move(*boot_session_data) : BootSessionData()));
|
||||
}
|
||||
|
||||
void MainWindow::StartGame(const std::vector<std::string>& paths,
|
||||
const std::optional<std::string>& savestate_path)
|
||||
std::unique_ptr<BootSessionData> boot_session_data)
|
||||
{
|
||||
StartGame(BootParameters::GenerateFromFile(paths, savestate_path));
|
||||
StartGame(BootParameters::GenerateFromFile(
|
||||
paths, boot_session_data ? std::move(*boot_session_data) : BootSessionData()));
|
||||
}
|
||||
|
||||
void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
|
||||
@ -1818,8 +1827,7 @@ void MainWindow::ShowRiivolutionBootWidget(const UICommon::GameFile& game)
|
||||
std::vector<std::string> paths = {game.GetFilePath()};
|
||||
if (second_game != nullptr)
|
||||
paths.push_back(second_game->GetFilePath());
|
||||
std::unique_ptr<BootParameters> boot_params =
|
||||
BootParameters::GenerateFromFile(paths, std::nullopt);
|
||||
std::unique_ptr<BootParameters> boot_params = BootParameters::GenerateFromFile(paths);
|
||||
if (!boot_params)
|
||||
return;
|
||||
if (!std::holds_alternative<BootParameters::Disc>(boot_params->parameters))
|
||||
|
@ -15,6 +15,7 @@ class QStackedWidget;
|
||||
class QString;
|
||||
|
||||
class BreakpointWidget;
|
||||
class BootSessionData;
|
||||
struct BootParameters;
|
||||
class CheatsManager;
|
||||
class CodeWidget;
|
||||
@ -132,13 +133,13 @@ private:
|
||||
};
|
||||
|
||||
void ScanForSecondDiscAndStartGame(const UICommon::GameFile& game,
|
||||
const std::optional<std::string>& savestate_path = {});
|
||||
std::unique_ptr<BootSessionData> boot_session_data = nullptr);
|
||||
void StartGame(const QString& path, ScanForSecondDisc scan,
|
||||
const std::optional<std::string>& savestate_path = {});
|
||||
std::unique_ptr<BootSessionData> boot_session_data = nullptr);
|
||||
void StartGame(const std::string& path, ScanForSecondDisc scan,
|
||||
const std::optional<std::string>& savestate_path = {});
|
||||
std::unique_ptr<BootSessionData> boot_session_data = nullptr);
|
||||
void StartGame(const std::vector<std::string>& paths,
|
||||
const std::optional<std::string>& savestate_path = {});
|
||||
std::unique_ptr<BootSessionData> boot_session_data = nullptr);
|
||||
void StartGame(std::unique_ptr<BootParameters>&& parameters);
|
||||
void ShowRenderWidget();
|
||||
void HideRenderWidget(bool reinit = true, bool is_exit = false);
|
||||
|
Reference in New Issue
Block a user