Can toggle rewind enable in runtime.

This commit is contained in:
Themaister 2013-03-16 14:28:10 +01:00
parent 92fba644b7
commit e3c85b174c
3 changed files with 15 additions and 9 deletions

View File

@ -606,15 +606,19 @@ static int rgui_settings_toggle_setting(unsigned setting, rgui_action_t action,
switch (setting)
{
case RGUI_SETTINGS_REWIND_ENABLE:
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_LEFT || action == RGUI_ACTION_RIGHT)
if (action == RGUI_ACTION_OK ||
action == RGUI_ACTION_LEFT ||
action == RGUI_ACTION_RIGHT)
{
menu_settings_set(S_REWIND);
if (g_extern.lifecycle_mode_state & (1ULL << MODE_INFO_DRAW))
menu_settings_msg(S_MSG_RESTART_RARCH, 180);
if (g_settings.rewind_enable)
rarch_init_rewind();
}
else if (action == RGUI_ACTION_START)
{
g_settings.rewind_enable = false;
rarch_deinit_rewind();
}
break;
case RGUI_SETTINGS_REWIND_GRANULARITY:
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT)

View File

@ -647,6 +647,8 @@ void rarch_render_cached_frame(void);
void rarch_init_msg_queue(void);
void rarch_deinit_msg_queue(void);
void rarch_input_poll(void);
void rarch_init_rewind(void);
void rarch_deinit_rewind(void);
void rarch_load_state(void);
void rarch_save_state(void);

View File

@ -1432,9 +1432,9 @@ static void deinit_cheats(void)
cheat_manager_free(g_extern.cheat);
}
static void init_rewind(void)
void rarch_init_rewind(void)
{
if (!g_settings.rewind_enable)
if (!g_settings.rewind_enable || g_extern.state_manager)
return;
g_extern.state_size = pretro_serialize_size();
@ -1469,7 +1469,7 @@ static void init_rewind(void)
RARCH_WARN("Failed to init rewind buffer. Rewinding will be disabled.\n");
}
static void deinit_rewind(void)
void rarch_deinit_rewind(void)
{
if (g_extern.state_manager)
state_manager_free(g_extern.state_manager);
@ -2802,7 +2802,7 @@ int rarch_main_init(int argc, char *argv[])
#ifdef HAVE_NETPLAY
if (!g_extern.netplay)
#endif
init_rewind();
rarch_init_rewind();
init_libretro_cbs();
init_controllers();
@ -2971,7 +2971,7 @@ void rarch_main_deinit(void)
#ifdef HAVE_NETPLAY
if (!g_extern.netplay)
#endif
deinit_rewind();
rarch_deinit_rewind();
deinit_cheats();