From 1b6b313787cd3c6e029472c09d77a5bbd4724a18 Mon Sep 17 00:00:00 2001 From: Toad King Date: Sun, 12 Aug 2012 03:38:23 -0400 Subject: [PATCH] (RGUI) add savestate support --- console/rgui/rgui.c | 32 +++++++++++++++++++++++++++++--- console/rgui/rgui.h | 3 +++ gx/gx_input.c | 6 +++--- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/console/rgui/rgui.c b/console/rgui/rgui.c index a7594b6484..315f4fe9b4 100644 --- a/console/rgui/rgui.c +++ b/console/rgui/rgui.c @@ -321,6 +321,9 @@ static void render_text(rgui_handle_t *rgui) snprintf(type_str, sizeof(type_str), "(DEV)"); w = 5; break; + case RGUI_SETTINGS_SAVESTATE_SLOT: + snprintf(type_str, sizeof(type_str), "%d", g_extern.state_slot); + break; case RGUI_SETTINGS_VIDEO_FILTER: snprintf(type_str, sizeof(type_str), g_settings.video.smooth ? "Bilinear filtering" : "Point filtering"); break; @@ -406,6 +409,25 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t switch (setting) { + case RGUI_SETTINGS_SAVESTATE_SLOT: + if (action == RGUI_ACTION_START) + rarch_settings_default(S_DEF_SAVE_STATE); + else if (action == RGUI_ACTION_LEFT) + rarch_settings_change(S_SAVESTATE_DECREMENT); + else if (action == RGUI_ACTION_RIGHT) + rarch_settings_change(S_SAVESTATE_INCREMENT); + break; + case RGUI_SETTINGS_SAVESTATE_SAVE: + case RGUI_SETTINGS_SAVESTATE_LOAD: + if (action == RGUI_ACTION_OK) + { + if (setting == RGUI_SETTINGS_SAVESTATE_SAVE) + rarch_save_state(); + else + rarch_load_state(); + rarch_settings_change(S_RETURN_TO_GAME); + } + break; case RGUI_SETTINGS_VIDEO_FILTER: if (action == RGUI_ACTION_START) rarch_settings_default(S_DEF_HW_TEXTURE_FILTER); @@ -490,9 +512,7 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t #ifdef GEKKO snprintf(g_console.launch_app_on_exit, sizeof(g_console.launch_app_on_exit), "boot.dol"); #endif - g_console.return_to_launcher = true; - g_console.mode_switch = MODE_EXIT; - g_console.menu_enable = false; + rarch_settings_change(S_RETURN_TO_LAUNCHER); } break; // controllers @@ -550,6 +570,12 @@ static void rgui_settings_populate_entries(rgui_handle_t *rgui) { rgui_list_clear(rgui->folder_buf); + if (g_console.ingame_menu_enable) + { + RGUI_MENU_ITEM("Savestate Slot", RGUI_SETTINGS_SAVESTATE_SLOT); + RGUI_MENU_ITEM("Save State", RGUI_SETTINGS_SAVESTATE_SAVE); + RGUI_MENU_ITEM("Load State", RGUI_SETTINGS_SAVESTATE_LOAD); + } RGUI_MENU_ITEM("Hardware filtering", RGUI_SETTINGS_VIDEO_FILTER); #ifdef HW_RVL RGUI_MENU_ITEM("VI Trap filtering", RGUI_SETTINGS_VIDEO_SOFT_FILTER); diff --git a/console/rgui/rgui.h b/console/rgui/rgui.h index b210cc6911..ddf97874a4 100644 --- a/console/rgui/rgui.h +++ b/console/rgui/rgui.h @@ -33,6 +33,9 @@ typedef enum RGUI_SETTINGS, // settings options are done here too + RGUI_SETTINGS_SAVESTATE_SLOT, + RGUI_SETTINGS_SAVESTATE_SAVE, + RGUI_SETTINGS_SAVESTATE_LOAD, RGUI_SETTINGS_VIDEO_FILTER, #ifdef HW_RVL RGUI_SETTINGS_VIDEO_SOFT_FILTER, diff --git a/gx/gx_input.c b/gx/gx_input.c index 889ff85a65..d4d8b20a10 100644 --- a/gx/gx_input.c +++ b/gx/gx_input.c @@ -464,14 +464,14 @@ static bool gx_key_pressed(void *data, int key) if(g_console.menu_enable) { g_console.mode_switch = MODE_MENU; - SET_TIMER_EXPIRATION(gx, 30); - retval = g_console.menu_enable; + g_console.ingame_menu_enable = true; + SET_TIMER_EXPIRATION(gx, 30); } if(quit_rarch) g_console.mode_switch = MODE_EXIT; - retval = g_console.menu_enable; + retval = g_console.menu_enable; return retval; } default: