mirror of https://github.com/snes9xgit/snes9x.git
Add an undo load state option.
This commit is contained in:
parent
f9e80ab932
commit
583e4b740d
|
@ -385,6 +385,8 @@ S9xAutoSaveSRAM (void)
|
||||||
void
|
void
|
||||||
S9xLoadState (const char *filename)
|
S9xLoadState (const char *filename)
|
||||||
{
|
{
|
||||||
|
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
|
||||||
|
|
||||||
if (S9xUnfreezeGame (filename))
|
if (S9xUnfreezeGame (filename))
|
||||||
{
|
{
|
||||||
sprintf (buf, "%s loaded", filename);
|
sprintf (buf, "%s loaded", filename);
|
||||||
|
@ -528,13 +530,16 @@ S9xQuickLoadSlot (int slot)
|
||||||
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR, def,
|
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR, def,
|
||||||
slot);
|
slot);
|
||||||
|
|
||||||
|
if (file_exists (filename))
|
||||||
|
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
|
||||||
|
|
||||||
if (S9xUnfreezeGame (filename))
|
if (S9xUnfreezeGame (filename))
|
||||||
{
|
{
|
||||||
snprintf (buf, PATH_MAX, "%s.%03d loaded", def, slot);
|
snprintf (buf, PATH_MAX, "%s.%03d loaded", def, slot);
|
||||||
S9xSetInfoString (buf);
|
S9xSetInfoString (buf);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
static const char *digits = "t123456789";
|
static const char *digits = "t123456789";
|
||||||
|
|
||||||
_splitpath (Memory.ROMFilename, drive, dir, def, ext);
|
_splitpath (Memory.ROMFilename, drive, dir, def, ext);
|
||||||
|
@ -543,18 +548,21 @@ S9xQuickLoadSlot (int slot)
|
||||||
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR,
|
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR,
|
||||||
def, digits[slot]);
|
def, digits[slot]);
|
||||||
|
|
||||||
|
if (file_exists (filename))
|
||||||
|
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
|
||||||
|
|
||||||
if (S9xUnfreezeGame (filename))
|
if (S9xUnfreezeGame (filename))
|
||||||
{
|
{
|
||||||
snprintf (buf, PATH_MAX,
|
snprintf (buf, PATH_MAX,
|
||||||
"Loaded ZSNES freeze file %s.zs%c",
|
"Loaded ZSNES freeze file %s.zs%c",
|
||||||
def, digits [slot]);
|
def, digits [slot]);
|
||||||
S9xSetInfoString (buf);
|
S9xSetInfoString (buf);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
S9xMessage (S9X_ERROR,
|
S9xMessage (S9X_ERROR,
|
||||||
S9X_FREEZE_FILE_NOT_FOUND,
|
S9X_FREEZE_FILE_NOT_FOUND,
|
||||||
"Freeze file not found");
|
"Freeze file not found");
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,6 +460,15 @@ event_load_state (GtkWidget *widget, gpointer data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
event_load_state_undo (GtkWidget *widget, gpointer data)
|
||||||
|
{
|
||||||
|
S9xUnfreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
event_load_state_file (GtkWidget *widget, gpointer data)
|
event_load_state_file (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
|
@ -585,6 +594,7 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
|
||||||
{ "on_port_activate", G_CALLBACK (event_port) },
|
{ "on_port_activate", G_CALLBACK (event_port) },
|
||||||
{ "load_save_state", G_CALLBACK (event_load_state) },
|
{ "load_save_state", G_CALLBACK (event_load_state) },
|
||||||
{ "load_state_file", G_CALLBACK (event_load_state_file) },
|
{ "load_state_file", G_CALLBACK (event_load_state_file) },
|
||||||
|
{ "load_state_undo", G_CALLBACK (event_load_state_undo) },
|
||||||
{ "save_save_state", G_CALLBACK (event_save_state) },
|
{ "save_save_state", G_CALLBACK (event_save_state) },
|
||||||
{ "save_state_file", G_CALLBACK (event_save_state_file) },
|
{ "save_state_file", G_CALLBACK (event_save_state_file) },
|
||||||
{ "drawingarea_button_press", G_CALLBACK (event_button_press) },
|
{ "drawingarea_button_press", G_CALLBACK (event_button_press) },
|
||||||
|
|
|
@ -1334,6 +1334,21 @@
|
||||||
<signal name="activate" handler="load_state_file" swapped="no"/>
|
<signal name="activate" handler="load_state_file" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSeparatorMenuItem" id="undoseparator">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkMenuItem" id="load_state_undo">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">_Undo Load State</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="load_state_undo" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
Loading…
Reference in New Issue