Merge pull request #17844 from JoeOsborn/add-save-load-sram-commands
This commit is contained in:
commit
4b6d315ad6
29
command.c
29
command.c
|
@ -809,6 +809,35 @@ bool command_play_replay_slot(command_t *cmd, const char *arg)
|
|||
#endif
|
||||
}
|
||||
|
||||
bool command_save_savefiles(command_t *cmd, const char* arg)
|
||||
{
|
||||
char reply[4];
|
||||
bool ret;
|
||||
size_t _len = strlcpy(reply, "OK", sizeof(reply));
|
||||
reply[ _len] = '\n';
|
||||
reply[++_len] = '\0';
|
||||
/* In the future, this should probably send each saved file path
|
||||
to the replier. */
|
||||
ret = command_event(CMD_EVENT_SAVE_FILES, NULL);
|
||||
if (!ret)
|
||||
strlcpy(reply, "NO", sizeof(reply));
|
||||
cmd->replier(cmd, reply, _len);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool command_load_savefiles(command_t *cmd, const char* arg)
|
||||
{
|
||||
char reply[4];
|
||||
bool ret;
|
||||
size_t _len = strlcpy(reply, "OK", sizeof(reply));
|
||||
reply[ _len] = '\n';
|
||||
reply[++_len] = '\0';
|
||||
ret = command_event(CMD_EVENT_LOAD_FILES, NULL);
|
||||
if (!ret)
|
||||
strlcpy(reply, "NO", sizeof(reply));
|
||||
cmd->replier(cmd, reply, _len);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(HAVE_CHEEVOS)
|
||||
bool command_read_ram(command_t *cmd, const char *arg)
|
||||
|
|
|
@ -258,6 +258,7 @@ enum event_command
|
|||
CMD_EVENT_AI_SERVICE_CALL,
|
||||
/* Misc. */
|
||||
CMD_EVENT_SAVE_FILES,
|
||||
CMD_EVENT_LOAD_FILES,
|
||||
CMD_EVENT_CONTROLLER_INIT,
|
||||
CMD_EVENT_DISCORD_INIT,
|
||||
CMD_EVENT_PRESENCE_UPDATE,
|
||||
|
@ -420,6 +421,8 @@ bool command_get_config_param(command_t *cmd, const char* arg);
|
|||
bool command_show_osd_msg(command_t *cmd, const char* arg);
|
||||
bool command_load_state_slot(command_t *cmd, const char* arg);
|
||||
bool command_play_replay_slot(command_t *cmd, const char* arg);
|
||||
bool command_save_savefiles(command_t *cmd, const char* arg);
|
||||
bool command_load_savefiles(command_t *cmd, const char* arg);
|
||||
#ifdef HAVE_CHEEVOS
|
||||
bool command_read_ram(command_t *cmd, const char *arg);
|
||||
bool command_write_ram(command_t *cmd, const char *arg);
|
||||
|
@ -446,6 +449,9 @@ static const struct cmd_action_map action_map[] = {
|
|||
|
||||
{ "LOAD_STATE_SLOT",command_load_state_slot, "<slot number>"},
|
||||
{ "PLAY_REPLAY_SLOT",command_play_replay_slot, "<slot number>"},
|
||||
|
||||
{ "SAVE_FILES", command_save_savefiles, "No argument"},
|
||||
{ "LOAD_FILES", command_load_savefiles, "No argument"},
|
||||
};
|
||||
|
||||
static const struct cmd_map map[] = {
|
||||
|
|
|
@ -15646,6 +15646,10 @@ MSG_HASH(
|
|||
MSG_CHEEVOS_LOAD_STATE_PREVENTED_BY_HARDCORE_MODE,
|
||||
"You must pause or disable Achievements Hardcore Mode to load states."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_CHEEVOS_LOAD_SAVEFILE_PREVENTED_BY_HARDCORE_MODE,
|
||||
"You must pause or disable Achievements Hardcore Mode to load srm saves."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_CHEEVOS_HARDCORE_MODE_DISABLED,
|
||||
"A save state was loaded. Achievements Hardcore Mode disabled for the current session."
|
||||
|
|
|
@ -4117,6 +4117,7 @@ enum msg_hash_enums
|
|||
MSG_CHEAT_SEARCH_DELETE_MATCH_SUCCESS,
|
||||
MSG_CHEEVOS_LOGGED_IN_AS_USER,
|
||||
MSG_CHEEVOS_LOAD_STATE_PREVENTED_BY_HARDCORE_MODE,
|
||||
MSG_CHEEVOS_LOAD_SAVEFILE_PREVENTED_BY_HARDCORE_MODE,
|
||||
MSG_CHEEVOS_HARDCORE_MODE_DISABLED,
|
||||
MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT,
|
||||
MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST,
|
||||
|
|
16
retroarch.c
16
retroarch.c
|
@ -3020,8 +3020,19 @@ bool command_event(enum event_command cmd, void *data)
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
case CMD_EVENT_LOAD_FILES:
|
||||
#ifdef HAVE_CHEEVOS
|
||||
if (rcheevos_hardcore_active())
|
||||
{
|
||||
const char *_msg = msg_hash_to_str(MSG_CHEEVOS_LOAD_SAVEFILE_PREVENTED_BY_HARDCORE_MODE);
|
||||
runloop_msg_queue_push(_msg, strlen(_msg), 0, 180, true, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_WARNING);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return event_load_save_files(runloop_st->flags & RUNLOOP_FLAG_IS_SRAM_LOAD_DISABLED);
|
||||
case CMD_EVENT_SAVE_FILES:
|
||||
event_save_files(
|
||||
return event_save_files(
|
||||
runloop_st->flags & RUNLOOP_FLAG_USE_SRAM,
|
||||
#if defined(HAVE_ZLIB)
|
||||
settings->bools.save_file_compression,
|
||||
|
@ -3033,8 +3044,7 @@ bool command_event(enum event_command cmd, void *data)
|
|||
#else
|
||||
NULL
|
||||
#endif
|
||||
);
|
||||
break;
|
||||
);
|
||||
case CMD_EVENT_OVERLAY_UNLOAD:
|
||||
#ifdef HAVE_OVERLAY
|
||||
input_overlay_unload();
|
||||
|
|
Loading…
Reference in New Issue