mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 12:20:14 +00:00
New pause implementation
This commit is contained in:
parent
e64114f6a6
commit
40d59f085f
@ -137,7 +137,6 @@ GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread) :
|
|||||||
NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(child->width(), child->height()));
|
NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(child->width(), child->height()));
|
||||||
|
|
||||||
BackupGeometry();
|
BackupGeometry();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::moveContext()
|
void GRenderWindow::moveContext()
|
||||||
@ -287,11 +286,11 @@ void GRenderWindow::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,un
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::focusInEvent(QFocusEvent*) {
|
void GRenderWindow::focusInEvent(QFocusEvent*) {
|
||||||
if (emu_thread && UISettings::values.pause_onfocuslost) emit gotFocus();
|
emit focusChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::focusOutEvent(QFocusEvent*) {
|
void GRenderWindow::focusOutEvent(QFocusEvent*) {
|
||||||
if (emu_thread && UISettings::values.pause_onfocuslost) emit lostFocus();
|
emit focusChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::OnEmulationStarting(EmuThread* emu_thread) {
|
void GRenderWindow::OnEmulationStarting(EmuThread* emu_thread) {
|
||||||
|
@ -136,10 +136,8 @@ public slots:
|
|||||||
signals:
|
signals:
|
||||||
/// Emitted when the window is closed
|
/// Emitted when the window is closed
|
||||||
void Closed();
|
void Closed();
|
||||||
/// Emitted when the window got focus
|
/// Emitted when the window focus changed
|
||||||
void gotFocus();
|
void focusChanged(bool hasFocus);
|
||||||
/// Emitted when the window lost focus
|
|
||||||
void lostFocus();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override;
|
void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override;
|
||||||
|
@ -186,8 +186,7 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr)
|
|||||||
connect(this, SIGNAL(EmulationStarting(EmuThread*)), graphicsTracingWidget, SLOT(OnEmulationStarting(EmuThread*)));
|
connect(this, SIGNAL(EmulationStarting(EmuThread*)), graphicsTracingWidget, SLOT(OnEmulationStarting(EmuThread*)));
|
||||||
connect(this, SIGNAL(EmulationStopping()), graphicsTracingWidget, SLOT(OnEmulationStopping()));
|
connect(this, SIGNAL(EmulationStopping()), graphicsTracingWidget, SLOT(OnEmulationStopping()));
|
||||||
|
|
||||||
connect(render_window, SIGNAL(gotFocus()), this, SLOT(OnStartGame()));
|
connect(render_window, SIGNAL(focusChanged(bool)), this, SLOT(OnFocusChanged(bool)));
|
||||||
connect(render_window, SIGNAL(lostFocus()), this, SLOT(OnPauseGame()));
|
|
||||||
|
|
||||||
// Setup hotkeys
|
// Setup hotkeys
|
||||||
RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
|
RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
|
||||||
@ -472,6 +471,8 @@ void GMainWindow::OnStartGame() {
|
|||||||
ui.action_Stop->setEnabled(true);
|
ui.action_Stop->setEnabled(true);
|
||||||
|
|
||||||
render_window->setFocus();
|
render_window->setFocus();
|
||||||
|
|
||||||
|
emulation_paused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnPauseGame() {
|
void GMainWindow::OnPauseGame() {
|
||||||
@ -480,12 +481,30 @@ void GMainWindow::OnPauseGame() {
|
|||||||
ui.action_Start->setEnabled(true);
|
ui.action_Start->setEnabled(true);
|
||||||
ui.action_Pause->setEnabled(false);
|
ui.action_Pause->setEnabled(false);
|
||||||
ui.action_Stop->setEnabled(true);
|
ui.action_Stop->setEnabled(true);
|
||||||
|
|
||||||
|
emulation_paused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnStopGame() {
|
void GMainWindow::OnStopGame() {
|
||||||
ShutdownGame();
|
ShutdownGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GMainWindow::OnFocusChanged(bool hasFocus) {
|
||||||
|
// The focus change does not impact actual emulator state if:
|
||||||
|
// - the option is disabled
|
||||||
|
// - the emulation is not started
|
||||||
|
// - the emulation has been paused through menu
|
||||||
|
if(!UISettings::values.pause_onfocuslost ||
|
||||||
|
!emu_thread ||
|
||||||
|
emulation_paused)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (hasFocus)
|
||||||
|
emu_thread->SetRunning(true);
|
||||||
|
else // focus lost
|
||||||
|
emu_thread->SetRunning(false);
|
||||||
|
}
|
||||||
|
|
||||||
void GMainWindow::ToggleWindowMode() {
|
void GMainWindow::ToggleWindowMode() {
|
||||||
if (ui.action_Single_Window_Mode->isChecked()) {
|
if (ui.action_Single_Window_Mode->isChecked()) {
|
||||||
// Render in the main window...
|
// Render in the main window...
|
||||||
@ -521,6 +540,10 @@ void GMainWindow::OnConfigure() {
|
|||||||
render_window->ReloadSetKeymaps();
|
render_window->ReloadSetKeymaps();
|
||||||
config->Save();
|
config->Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure the emulation is running when all pauses are disabled
|
||||||
|
if (emu_thread && !UISettings::values.pause_onfocuslost && !emulation_paused)
|
||||||
|
emu_thread->SetRunning(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnCreateGraphicsSurfaceViewer() {
|
void GMainWindow::OnCreateGraphicsSurfaceViewer() {
|
||||||
|
@ -98,6 +98,8 @@ private slots:
|
|||||||
void OnStartGame();
|
void OnStartGame();
|
||||||
void OnPauseGame();
|
void OnPauseGame();
|
||||||
void OnStopGame();
|
void OnStopGame();
|
||||||
|
/// Called whenever the render window focus is changed
|
||||||
|
void OnFocusChanged(bool hasFocus);
|
||||||
/// Called whenever a user selects a game in the game list widget.
|
/// Called whenever a user selects a game in the game list widget.
|
||||||
void OnGameListLoadFile(QString game_path);
|
void OnGameListLoadFile(QString game_path);
|
||||||
void OnMenuLoadFile();
|
void OnMenuLoadFile();
|
||||||
@ -118,6 +120,8 @@ private:
|
|||||||
|
|
||||||
std::unique_ptr<Config> config;
|
std::unique_ptr<Config> config;
|
||||||
|
|
||||||
|
// Whether emulation has been paused (through menus)
|
||||||
|
bool emulation_paused = false;
|
||||||
// Whether emulation is currently running in Citra.
|
// Whether emulation is currently running in Citra.
|
||||||
bool emulation_running = false;
|
bool emulation_running = false;
|
||||||
std::unique_ptr<EmuThread> emu_thread;
|
std::unique_ptr<EmuThread> emu_thread;
|
||||||
|
Loading…
Reference in New Issue
Block a user