(Menu) Refactor MENU_SETTINGS_NETPLAY_DELAY_FRAMES

This commit is contained in:
twinaphex 2014-08-01 17:16:35 +02:00
parent d6b84b351d
commit 8c87ea7233
2 changed files with 11 additions and 10 deletions

View File

@ -395,7 +395,8 @@ static void menu_common_entries_init(menu_handle_t *menu, unsigned menu_type)
file_list_push(menu->selection_buf, current_setting->short_description, MENU_SETTINGS_NETPLAY_SPECTATOR_MODE_ENABLE, 0);
file_list_push(menu->selection_buf, "Host IP Address", MENU_SETTINGS_NETPLAY_HOST_IP_ADDRESS, 0);
file_list_push(menu->selection_buf, "TCP/UDP Port", MENU_SETTINGS_NETPLAY_TCP_UDP_PORT, 0);
file_list_push(menu->selection_buf, "Delay Frames", MENU_SETTINGS_NETPLAY_DELAY_FRAMES, 0);
if ((current_setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "netplay_delay_frames")))
file_list_push(menu->selection_buf, current_setting->short_description, MENU_SETTINGS_NETPLAY_DELAY_FRAMES, 0);
#endif
break;
case MENU_SETTINGS_PATH_OPTIONS:
@ -4509,15 +4510,8 @@ static int menu_common_setting_set(unsigned setting, unsigned action)
*g_extern.netplay_server = '\0';
break;
case MENU_SETTINGS_NETPLAY_DELAY_FRAMES:
if (action == MENU_ACTION_LEFT)
{
if (g_extern.netplay_sync_frames != 0)
g_extern.netplay_sync_frames--;
}
else if (action == MENU_ACTION_RIGHT)
g_extern.netplay_sync_frames++;
else if (action == MENU_ACTION_START)
g_extern.netplay_sync_frames = 0;
if ((current_setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "netplay_delay_frames")))
menu_common_setting_set_current_unsigned_integer(current_setting, 1, action, true, false);
break;
case MENU_SETTINGS_NETPLAY_TCP_UDP_PORT:
if (action == MENU_ACTION_OK)

View File

@ -954,6 +954,8 @@ static void general_read_handler(const void *data)
*setting->value.boolean = g_extern.netplay_is_client;
else if (!strcmp(setting->name, "netplay_spectator_mode_enable"))
*setting->value.boolean = g_extern.netplay_is_spectate;
else if (!strcmp(setting->name, "netplay_delay_frames"))
*setting->value.unsigned_integer = g_extern.netplay_sync_frames;
#endif
else if (!strcmp(setting->name, "log_verbosity"))
*setting->value.boolean = g_extern.verbosity;
@ -1314,6 +1316,10 @@ static void general_write_handler(const void *data)
if (g_extern.netplay_is_spectate)
*g_extern.netplay_server = '\0';
}
else if (!strcmp(setting->name, "netplay_delay_frames"))
{
g_extern.netplay_sync_frames = *setting->value.unsigned_integer;
}
#endif
else if (!strcmp(setting->name, "log_verbosity"))
g_extern.verbosity = *setting->value.boolean;
@ -1639,6 +1645,7 @@ rarch_setting_t* setting_data_get_list(void)
CONFIG_BOOL(g_extern.netplay_enable, "netplay_enable", "Netplay Enable", false, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
CONFIG_BOOL(g_extern.netplay_is_client, "netplay_mode", "Netplay Client Enable", false, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
CONFIG_BOOL(g_extern.netplay_is_spectate, "netplay_spectator_mode_enable", "Netplay Spectator Enable", false, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
CONFIG_UINT(g_extern.netplay_sync_frames, "netplay_delay_frames", "Netplay Delay Frames", 0, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 10)
END_SUB_GROUP()
END_GROUP()
#endif