Both Undo options now write distinct messages in the OSD when buffers

are empty, when undoing fails and when undoing is successful.

Aside from some TODO/FIXME areas added by this fork, the features in the
fork are now complete.
This commit is contained in:
Arzed Five 2016-06-10 20:12:43 +01:00
parent 8a0b258fcd
commit 8e20b9e938
3 changed files with 43 additions and 27 deletions

View File

@ -1597,12 +1597,25 @@ static void command_event_save_state(const char *path,
static void command_event_undo_save_state(char *s, size_t len) static void command_event_undo_save_state(char *s, size_t len)
{ {
if (content_undo_save_buf_is_empty())
{
/* TODO/FIXME - use msg_hash_to_str here */
snprintf(s, len, "%s",
"No save state has been overwritten yet.");
return;
}
if (!content_undo_save_state()) if (!content_undo_save_state())
{ {
snprintf(s, len, "%s \"%s\".", snprintf(s, len, "%s \"%s\".",
msg_hash_to_str(MSG_FAILED_TO_UNDO_SAVE_STATE), msg_hash_to_str(MSG_FAILED_TO_UNDO_SAVE_STATE),
"RAM"); "RAM");
return;
} }
/* TODO/FIXME - use msg_hash_to_str here */
snprintf(s, len, "%s",
"Restored old save state.");
} }
/** /**
@ -1635,12 +1648,26 @@ static void command_event_load_state(const char *path, char *s, size_t len)
static void command_event_undo_load_state(char *s, size_t len) static void command_event_undo_load_state(char *s, size_t len)
{ {
if (content_undo_load_buf_is_empty())
{
/* TODO/FIXME - use msg_hash_to_str here */
snprintf(s, len, "%s",
"No state has been loaded yet.");
return;
}
if (!content_undo_load_state()) if (!content_undo_load_state())
{ {
snprintf(s, len, "%s \"%s\".", snprintf(s, len, "%s \"%s\".",
msg_hash_to_str(MSG_FAILED_TO_UNDO_LOAD_STATE), msg_hash_to_str(MSG_FAILED_TO_UNDO_LOAD_STATE),
"RAM"); "RAM");
} return;
}
/* TODO/FIXME - use msg_hash_to_str here */
snprintf(s, len, "%s",
"Undid load state.");
} }
static void command_event_main_state(unsigned cmd) static void command_event_main_state(unsigned cmd)

View File

@ -79,6 +79,10 @@ bool content_init(void);
/* Resets the state and savefile backup buffers */ /* Resets the state and savefile backup buffers */
bool content_reset_savestate_backups(); bool content_reset_savestate_backups();
/* Checks if the buffers are empty */
bool content_undo_load_buf_is_empty();
bool content_undo_save_buf_is_empty();
RETRO_END_DECLS RETRO_END_DECLS
#endif #endif

View File

@ -65,18 +65,6 @@ struct sram_block
**/ **/
bool content_undo_load_state() bool content_undo_load_state()
{ {
if (undo_load_buf.data == NULL || undo_load_buf.size == 0) {
/* TODO/FIXME - Use msg_hash_to_str in here */
/* TODO/FIXME - Should we be using runloop_msg_queue_push in here? */
RARCH_LOG("%s\n",
"No load state to undo.");
runloop_msg_queue_push("No load state to undo.", 2, 180, true);
/* Even though there was no undo, signal this as a success */
return true;
}
unsigned i; unsigned i;
//ssize_t size; //ssize_t size;
retro_ctx_serialize_info_t serial_info; retro_ctx_serialize_info_t serial_info;
@ -191,9 +179,7 @@ bool content_undo_load_state()
RARCH_ERR("%s \"%s\".\n", RARCH_ERR("%s \"%s\".\n",
msg_hash_to_str(MSG_FAILED_TO_UNDO_LOAD_STATE), msg_hash_to_str(MSG_FAILED_TO_UNDO_LOAD_STATE),
undo_load_buf.path); undo_load_buf.path);
} else { }
runloop_msg_queue_push("Undid load state.", 2, 180, true);
}
return ret; return ret;
} }
@ -206,15 +192,6 @@ bool content_undo_load_state()
**/ **/
bool content_undo_save_state() bool content_undo_save_state()
{ {
if (undo_save_buf.data == NULL || undo_save_buf.size == 0)
{
/* TODO/FIXME - Use msg_hash_to_str in here */
RARCH_LOG("%s\n",
"No save state to undo.");
runloop_msg_queue_push("No save state to undo.", 2, 180, false);
return true;
}
bool ret = filestream_write_file(undo_save_buf.path, undo_save_buf.data, undo_save_buf.size); bool ret = filestream_write_file(undo_save_buf.path, undo_save_buf.data, undo_save_buf.size);
/* Wipe the save file buffer as it's intended to be one use only */ /* Wipe the save file buffer as it's intended to be one use only */
@ -230,8 +207,6 @@ bool content_undo_save_state()
RARCH_ERR("%s \"%s\".\n", RARCH_ERR("%s \"%s\".\n",
msg_hash_to_str(MSG_FAILED_TO_UNDO_SAVE_STATE), msg_hash_to_str(MSG_FAILED_TO_UNDO_SAVE_STATE),
undo_save_buf.path); undo_save_buf.path);
} else {
runloop_msg_queue_push("Undid save state.", 2, 180, true);
} }
return ret; return ret;
@ -512,3 +487,13 @@ bool content_reset_savestate_backups()
return true; return true;
} }
bool content_undo_load_buf_is_empty()
{
return undo_load_buf.data == NULL || undo_load_buf.size == 0;
}
bool content_undo_save_buf_is_empty()
{
return undo_save_buf.data == NULL || undo_save_buf.size == 0;
}