Skip to content

Commit

Permalink
Changed how pausing the emulator is handled to allow frame advancing
Browse files Browse the repository at this point in the history
Where previously the emulator thread was halted, frame advancing mode is now enabled instead

This commit also removes the "Enable Frame Advancing" option due to being obsolete
  • Loading branch information
OpenSauce04 committed Aug 7, 2024
1 parent 7b0fbdf commit b93e51c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
28 changes: 8 additions & 20 deletions src/lime_qt/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014 Citra Emulator Project
// Copyright Citra Emulator Project / Lime3DS Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

Expand Down Expand Up @@ -639,8 +639,6 @@ void GMainWindow::InitializeHotkeys() { // TODO: This code kind of sucks
link_action_shortcut(ui->action_Capture_Screenshot, QStringLiteral("Capture Screenshot"));
link_action_shortcut(ui->action_Screen_Layout_Swap_Screens, swap_screens);
link_action_shortcut(ui->action_Screen_Layout_Upright_Screens, rotate_screens);
link_action_shortcut(ui->action_Enable_Frame_Advancing,
QStringLiteral("Toggle Frame Advancing"));
link_action_shortcut(ui->action_Advance_Frame, QStringLiteral("Advance Frame"));
link_action_shortcut(ui->action_Load_from_Newest_Slot, QStringLiteral("Load from Newest Slot"));
link_action_shortcut(ui->action_Save_to_Oldest_Slot, QStringLiteral("Save to Oldest Slot"));
Expand Down Expand Up @@ -946,16 +944,8 @@ void GMainWindow::ConnectMenuEvents() {
connect_menu(ui->action_Save_Movie, &GMainWindow::OnSaveMovie);
connect_menu(ui->action_Movie_Read_Only_Mode,
[this](bool checked) { movie.SetReadOnly(checked); });
connect_menu(ui->action_Enable_Frame_Advancing, [this] {
if (emulation_running) {
system.frame_limiter.SetFrameAdvancing(ui->action_Enable_Frame_Advancing->isChecked());
ui->action_Advance_Frame->setEnabled(ui->action_Enable_Frame_Advancing->isChecked());
}
});
connect_menu(ui->action_Advance_Frame, [this] {
if (emulation_running && system.frame_limiter.IsFrameAdvancing()) {
ui->action_Enable_Frame_Advancing->setChecked(true);
ui->action_Advance_Frame->setEnabled(true);
system.frame_limiter.AdvanceFrame();
}
});
Expand All @@ -980,7 +970,8 @@ void GMainWindow::ConnectMenuEvents() {
}

void GMainWindow::UpdateMenuState() {
const bool is_paused = !emu_thread || !emu_thread->IsRunning();
const bool is_paused =
!emu_thread || !emu_thread->IsRunning() || system.frame_limiter.IsFrameAdvancing();

const std::array running_actions{
ui->action_Stop,
Expand All @@ -998,6 +989,7 @@ void GMainWindow::UpdateMenuState() {
}

ui->action_Capture_Screenshot->setEnabled(emulation_running && !is_paused);
ui->action_Advance_Frame->setEnabled(emulation_running && is_paused);

if (emulation_running && is_paused) {
ui->action_Pause->setText(tr("&Continue"));
Expand Down Expand Up @@ -1417,12 +1409,7 @@ void GMainWindow::BootGame(const QString& filename) {
movie_playback_path.clear();
}

if (ui->action_Enable_Frame_Advancing->isChecked()) {
ui->action_Advance_Frame->setEnabled(true);
system.frame_limiter.SetFrameAdvancing(true);
} else {
ui->action_Advance_Frame->setEnabled(false);
}
ui->action_Advance_Frame->setEnabled(false);

if (video_dumping_on_start) {
StartVideoDumping(video_dumping_path);
Expand Down Expand Up @@ -2302,6 +2289,7 @@ void GMainWindow::OnStartGame() {
PreventOSSleep();

emu_thread->SetRunning(true);
system.frame_limiter.SetFrameAdvancing(false);
graphics_api_button->setEnabled(false);
qRegisterMetaType<Core::System::ResultStatus>("Core::System::ResultStatus");
qRegisterMetaType<std::string>("std::string");
Expand Down Expand Up @@ -2331,7 +2319,7 @@ void GMainWindow::OnRestartGame() {
}

void GMainWindow::OnPauseGame() {
emu_thread->SetRunning(false);
system.frame_limiter.SetFrameAdvancing(true);
qt_cameras->PauseCameras();

play_time_manager->Stop();
Expand All @@ -2346,7 +2334,7 @@ void GMainWindow::OnPauseGame() {

void GMainWindow::OnPauseContinueGame() {
if (emulation_running) {
if (emu_thread->IsRunning()) {
if (emu_thread->IsRunning() && !system.frame_limiter.IsFrameAdvancing()) {
OnPauseGame();
} else {
OnStartGame();
Expand Down
17 changes: 1 addition & 16 deletions src/lime_qt/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,8 @@
<addaction name="action_Movie_Read_Only_Mode"/>
<addaction name="action_Save_Movie"/>
</widget>
<widget class="QMenu" name="menu_Frame_Advance">
<property name="title">
<string>Frame Advance</string>
</property>
<addaction name="action_Enable_Frame_Advancing"/>
<addaction name="action_Advance_Frame"/>
</widget>
<addaction name="action_Advance_Frame"/>
<addaction name="menu_Movie"/>
<addaction name="menu_Frame_Advance"/>
<addaction name="separator"/>
<addaction name="action_Capture_Screenshot"/>
<addaction name="action_Dump_Video"/>
Expand Down Expand Up @@ -404,14 +397,6 @@
<string>Read-Only Mode</string>
</property>
</action>
<action name="action_Enable_Frame_Advancing">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Enable Frame Advancing</string>
</property>
</action>
<action name="action_Advance_Frame">
<property name="enabled">
<bool>false</bool>
Expand Down

0 comments on commit b93e51c

Please sign in to comment.