Skip to content

Commit

Permalink
Cheats dialog pauses game if one is playing
Browse files Browse the repository at this point in the history
  • Loading branch information
rdanbrook committed Nov 27, 2012
1 parent f4eb0ea commit 6778410
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions source/linux/cheats.cpp
Expand Up @@ -35,6 +35,7 @@ extern "C" {
#include "callbacks.h"
}

#include "main.h"
#include "uihelp.h"

using namespace Nes::Api;
Expand All @@ -54,6 +55,7 @@ typedef struct
extern Emulator emulator;
extern GtkWidget *mainwindow;
extern char rootname[512];
extern bool wasplaying;

static GtkWidget *cheatwin, *cheattree, *ggedit, *paredit, *genieok, *parok;
static GtkWidget *chopen, *chsave, *chdelete;
Expand Down Expand Up @@ -317,6 +319,15 @@ GtkWidget* create_cheatwindow (void) {
GtkWidget *parvalid;
GtkWidget *chdelete;

bool playing = NstIsPlaying();
if (playing) {
NstStopPlaying();
wasplaying = 1;
}
else { // Set it back to 0 in case the game was paused and the config is opened again
wasplaying = 0;
}

cheatwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (cheatwindow), "Cheat Manager");
gtk_window_set_resizable (GTK_WINDOW (cheatwindow), FALSE);
Expand Down Expand Up @@ -665,6 +676,10 @@ void on_cheatsave_clicked(GtkButton *button, gpointer user_data)

void on_cheatok_clicked(GtkButton *button, gpointer user_data)
{
if (wasplaying) {
NstPlayGame();
}

gtk_widget_destroy(cheatwin);

treeiters.clear();
Expand Down

0 comments on commit 6778410

Please sign in to comment.