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,34 +530,40 @@ 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";
|
||||||
|
|
||||||
|
_splitpath (Memory.ROMFilename, drive, dir, def, ext);
|
||||||
|
|
||||||
|
snprintf (filename, PATH_MAX, "%s%s%s.zs%c",
|
||||||
|
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR,
|
||||||
|
def, digits[slot]);
|
||||||
|
|
||||||
|
if (file_exists (filename))
|
||||||
|
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
|
||||||
|
|
||||||
|
if (S9xUnfreezeGame (filename))
|
||||||
{
|
{
|
||||||
static const char *digits = "t123456789";
|
snprintf (buf, PATH_MAX,
|
||||||
|
"Loaded ZSNES freeze file %s.zs%c",
|
||||||
_splitpath (Memory.ROMFilename, drive, dir, def, ext);
|
def, digits [slot]);
|
||||||
|
S9xSetInfoString (buf);
|
||||||
snprintf (filename, PATH_MAX, "%s%s%s.zs%c",
|
return;
|
||||||
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR,
|
|
||||||
def, digits[slot]);
|
|
||||||
|
|
||||||
if (S9xUnfreezeGame (filename))
|
|
||||||
{
|
|
||||||
snprintf (buf, PATH_MAX,
|
|
||||||
"Loaded ZSNES freeze file %s.zs%c",
|
|
||||||
def, digits [slot]);
|
|
||||||
S9xSetInfoString (buf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
S9xMessage (S9X_ERROR,
|
|
||||||
S9X_FREEZE_FILE_NOT_FOUND,
|
|
||||||
"Freeze file not found");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
S9xMessage (S9X_ERROR,
|
||||||
|
S9X_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