diff --git a/command.c b/command.c index 009b1867b8..be1a4231dc 100644 --- a/command.c +++ b/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) diff --git a/command.h b/command.h index dd08854284..8fa57ec7b3 100644 --- a/command.h +++ b/command.h @@ -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, ""}, { "PLAY_REPLAY_SLOT",command_play_replay_slot, ""}, + + { "SAVE_FILES", command_save_savefiles, "No argument"}, + { "LOAD_FILES", command_load_savefiles, "No argument"}, }; static const struct cmd_map map[] = { diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index a8a92051b6..dc0713421a 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -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." diff --git a/msg_hash.h b/msg_hash.h index 0aea04997f..732f8d5f82 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -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, diff --git a/retroarch.c b/retroarch.c index 1577940750..1a3644c87d 100644 --- a/retroarch.c +++ b/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();