summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt2/MainWindow.cpp
diff options
context:
space:
mode:
authorLeo Lam <leolino.lam@gmail.com>2017-12-26 20:56:06 +0100
committerGitHub <noreply@github.com>2017-12-26 20:56:06 +0100
commit3bc61ed3635f5932cad8b460812ad8545aada4da (patch)
treec74c0da5d6edaf35551038a90f13bf40cbc19f67 /Source/Core/DolphinQt2/MainWindow.cpp
parentc9b78e23a20b3bab7af132ca870b4df8440c2145 (diff)
parent9dd88d76dd1b6fa06b2d3702e39d2773424f6417 (diff)
Merge pull request #6271 from JosJuice/load-state-at-boot
Redesign the ability to load state at boot
Diffstat (limited to 'Source/Core/DolphinQt2/MainWindow.cpp')
-rw-r--r--Source/Core/DolphinQt2/MainWindow.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp
index beefe311c3..99e762cdb8 100644
--- a/Source/Core/DolphinQt2/MainWindow.cpp
+++ b/Source/Core/DolphinQt2/MainWindow.cpp
@@ -15,6 +15,7 @@
#include <QProgressDialog>
#include <future>
+#include <optional>
#include "Common/Version.h"
@@ -164,7 +165,7 @@ void MainWindow::CreateComponents()
m_fifo_window = new FIFOPlayerWindow(this);
connect(m_fifo_window, &FIFOPlayerWindow::LoadFIFORequested, this,
- static_cast<void (MainWindow::*)(const QString&)>(&MainWindow::StartGame));
+ [this](const QString& path) { StartGame(path); });
#if defined(HAVE_XRANDR) && HAVE_XRANDR
m_graphics_window = new GraphicsWindow(
@@ -192,7 +193,7 @@ void MainWindow::ConnectMenuBar()
// Emulation
connect(m_menu_bar, &MenuBar::Pause, this, &MainWindow::Pause);
- connect(m_menu_bar, &MenuBar::Play, this, &MainWindow::Play);
+ connect(m_menu_bar, &MenuBar::Play, this, [this]() { Play(); });
connect(m_menu_bar, &MenuBar::Stop, this, &MainWindow::RequestStop);
connect(m_menu_bar, &MenuBar::Reset, this, &MainWindow::Reset);
connect(m_menu_bar, &MenuBar::Fullscreen, this, &MainWindow::FullScreen);
@@ -278,7 +279,7 @@ void MainWindow::ConnectToolBar()
{
addToolBar(m_tool_bar);
connect(m_tool_bar, &ToolBar::OpenPressed, this, &MainWindow::Open);
- connect(m_tool_bar, &ToolBar::PlayPressed, this, &MainWindow::Play);
+ connect(m_tool_bar, &ToolBar::PlayPressed, this, [this]() { Play(); });
connect(m_tool_bar, &ToolBar::PausePressed, this, &MainWindow::Pause);
connect(m_tool_bar, &ToolBar::StopPressed, this, &MainWindow::RequestStop);
connect(m_tool_bar, &ToolBar::FullScreenPressed, this, &MainWindow::FullScreen);
@@ -290,7 +291,7 @@ void MainWindow::ConnectToolBar()
void MainWindow::ConnectGameList()
{
- connect(m_game_list, &GameList::GameSelected, this, &MainWindow::Play);
+ connect(m_game_list, &GameList::GameSelected, this, [this]() { Play(); });
connect(m_game_list, &GameList::NetPlayHost, this, &MainWindow::NetPlayHost);
connect(m_game_list, &GameList::OpenGeneralSettings, this, &MainWindow::ShowGeneralWindow);
@@ -327,7 +328,7 @@ void MainWindow::Open()
StartGame(file);
}
-void MainWindow::Play()
+void MainWindow::Play(const std::optional<std::string>& savestate_path)
{
// If we're in a paused game, start it up again.
// Otherwise, play the selected game, if there is one.
@@ -343,14 +344,14 @@ void MainWindow::Play()
QSharedPointer<GameFile> selection = m_game_list->GetSelectedGame();
if (selection)
{
- StartGame(selection->GetFilePath());
+ StartGame(selection->GetFilePath(), savestate_path);
}
else
{
auto default_path = QString::fromStdString(SConfig::GetInstance().m_strDefaultISO);
if (!default_path.isEmpty() && QFile::exists(default_path))
{
- StartGame(default_path);
+ StartGame(default_path, savestate_path);
}
else
{
@@ -472,9 +473,9 @@ void MainWindow::ScreenShot()
Core::SaveScreenShot();
}
-void MainWindow::StartGame(const QString& path)
+void MainWindow::StartGame(const QString& path, const std::optional<std::string>& savestate_path)
{
- StartGame(BootParameters::GenerateFromFile(path.toStdString()));
+ StartGame(BootParameters::GenerateFromFile(path.toStdString(), savestate_path));
}
void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
@@ -680,7 +681,7 @@ void MainWindow::NetPlayInit()
m_netplay_dialog = new NetPlayDialog(this);
connect(m_netplay_dialog, &NetPlayDialog::Boot, this,
- static_cast<void (MainWindow::*)(const QString&)>(&MainWindow::StartGame));
+ [this](const QString& path) { StartGame(path); });
connect(m_netplay_dialog, &NetPlayDialog::Stop, this, &MainWindow::RequestStop);
connect(m_netplay_dialog, &NetPlayDialog::rejected, this, &MainWindow::NetPlayQuit);
connect(m_netplay_setup_dialog, &NetPlaySetupDialog::Join, this, &MainWindow::NetPlayJoin);
@@ -938,11 +939,12 @@ void MainWindow::OnPlayRecording()
emit ReadOnlyModeChanged(true);
}
- if (Movie::PlayInput(dtm_file.toStdString()))
+ std::optional<std::string> savestate_path;
+ if (Movie::PlayInput(dtm_file.toStdString(), &savestate_path))
{
emit RecordingStatusChanged(true);
- Play();
+ Play(savestate_path);
}
}