Merge pull request #4921 from fr500/master

NETPLAY menu improvements
This commit is contained in:
Twinaphex 2017-05-16 03:00:19 +02:00 committed by GitHub
commit c035f9597a
20 changed files with 158 additions and 103 deletions

View File

@ -988,6 +988,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"连接到游戏主机")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"作为游戏主机")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"服务器地址")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS,

View File

@ -979,6 +979,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"Verbinde zu einem Netplay-Host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"Starte Hosting")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"Server-Adresse")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS,

View File

@ -898,6 +898,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"Connect to Netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"Start hosting")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"Server Address")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_MODE,

View File

@ -892,6 +892,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"Connexion à l'hôte distant")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"Commencer l'hébergement")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"Adresse IP")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_MODE,

View File

@ -864,6 +864,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"Connetti alla rete ospite")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"Comincia ad ospitare")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"Indirizzo Server")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS,

View File

@ -995,6 +995,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"ネットプレイサーバーに接続")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"ホストする")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"サーバーのIPアドレス")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS,

View File

@ -979,6 +979,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"넷플레이 호스트 연결")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"넷플레이 호스트 시작")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"서버 주소")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS,

View File

@ -898,6 +898,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"Connect to Netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"Start hosting")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"Server Adres")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_MODE,

View File

@ -977,6 +977,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"Conecar ao hospedeiro do netplay")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"Iniciar hospedeiro do netplay")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"Endereço do Servidor")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS,

View File

@ -977,6 +977,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"Conecar ao hospedeiro do netplay")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"Iniciar hospedeiro do netplay")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"Endereço do Servidor")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS,

View File

@ -904,6 +904,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"Подключение к Netplay-хосту")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"Старт хостинг")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"Адрес сервера")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_MODE,

View File

@ -991,6 +991,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"Connect to netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"Start netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"Server Address")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS,

View File

@ -991,6 +991,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT,
"Connect to netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST,
"Start netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST,
"Stop netplay host")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
"Server Address")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_LAN_SCAN_SETTINGS,

View File

@ -3340,6 +3340,66 @@ static int action_ok_push_scan_file(const char *path,
}
#ifdef HAVE_NETWORKING
struct netplay_host_list *lan_hosts;
int lan_room_count;
void netplay_refresh_rooms_menu(file_list_t *list)
{
char s[PATH_MAX_LENGTH];
int i = 0;
int j = 0;
if (netplay_room_count != 0)
{
RARCH_LOG ("Found %d rooms...\n", netplay_room_count);
for (i = 0; i < netplay_room_count; i++)
{
/* Uncomment this to debug mismatched room parameters*/
#if 0
RARCH_LOG("Room Data: %d\n"
"Nickname: %s\n"
"Address: %s\n"
"Port: %d\n"
"Core: %s\n"
"Core Version: %s\n"
"Game: %s\n"
"Game CRC: %08x\n"
"Timestamp: %d\n", room_data->elems[j + 6].data,
netplay_room_list[i].nickname,
netplay_room_list[i].address,
netplay_room_list[i].port,
netplay_room_list[i].corename,
netplay_room_list[i].coreversion,
netplay_room_list[i].gamename,
netplay_room_list[i].gamecrc,
netplay_room_list[i].timestamp);
#endif
j+=8;
if (netplay_room_list[i].lan)
{
snprintf(s, sizeof(s),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME_LAN),
netplay_room_list[i].nickname);
}
else
{
snprintf(s, sizeof(s),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME),
netplay_room_list[i].nickname);
}
menu_entries_append_enum(list,
s,
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM),
MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM,
MENU_ROOM, 0, 0);
}
netplay_rooms_free();
}
}
static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const char *err)
{
char buf[PATH_MAX_LENGTH];
@ -3383,13 +3443,9 @@ finish:
int i = 0;
int j = 0;
int k = 0;
int lan_room_count = 0;
struct netplay_host_list *lan_hosts = NULL;
file_list_t *file_list = menu_entries_get_selection_buf_ptr(0);
#if 1
netplay_discovery_driver_ctl(RARCH_NETPLAY_DISCOVERY_CTL_LAN_GET_RESPONSES, &lan_hosts);
#endif
if (lan_hosts)
lan_room_count = (int)lan_hosts->size;
@ -3408,80 +3464,39 @@ finish:
sizeof(struct netplay_room));
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, file_list);
menu_entries_append_enum(file_list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST),
MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST,
MENU_SETTING_ACTION, 0, 0);
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
{
menu_entries_append_enum(file_list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST),
MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST,
MENU_SETTING_ACTION, 0, 0);
}
else if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER_ENABLED, NULL))
{
menu_entries_append_enum(file_list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT),
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
MENU_SETTING_ACTION, 0, 0);
}
else
{
menu_entries_append_enum(file_list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT),
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
MENU_SETTING_ACTION, 0, 0);
}
menu_entries_append_enum(file_list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS),
MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS,
MENU_SETTING_ACTION, 0, 0);
if (netplay_room_count != 0)
{
RARCH_LOG ("Found %d rooms...\n", netplay_room_count);
for (i = 0; i < netplay_room_count; i++)
{
memcpy(&netplay_room_list[i], netplay_room_get(i), sizeof(netplay_room_list[i]));
/*strlcpy(netplay_room_list[i].nickname,
room_data->elems[j + 0].data,
sizeof(netplay_room_list[i].nickname));
strlcpy(netplay_room_list[i].address,
room_data->elems[j + 1].data,
sizeof(netplay_room_list[i].address));
strlcpy(netplay_room_list[i].corename,
room_data->elems[j + 3].data,
sizeof(netplay_room_list[i].corename));
strlcpy(netplay_room_list[i].coreversion,
room_data->elems[j + 4].data,
sizeof(netplay_room_list[i].coreversion));
strlcpy(netplay_room_list[i].gamename,
room_data->elems[j + 5].data,
sizeof(netplay_room_list[i].gamename));
netplay_room_list[i].port = atoi(room_data->elems[j + 2].data);
netplay_room_list[i].gamecrc = atoi(room_data->elems[j + 6].data);
netplay_room_list[i].timestamp = atoi(room_data->elems[j + 7].data);*/
/* Uncomment this to debug mismatched room parameters*/
#if 0
RARCH_LOG("Room Data: %d\n"
"Nickname: %s\n"
"Address: %s\n"
"Port: %d\n"
"Core: %s\n"
"Core Version: %s\n"
"Game: %s\n"
"Game CRC: %08x\n"
"Timestamp: %d\n", room_data->elems[j + 6].data,
netplay_room_list[i].nickname,
netplay_room_list[i].address,
netplay_room_list[i].port,
netplay_room_list[i].corename,
netplay_room_list[i].coreversion,
netplay_room_list[i].gamename,
netplay_room_list[i].gamecrc,
netplay_room_list[i].timestamp);
#endif
j+=8;
snprintf(s, sizeof(s),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME),
netplay_room_list[i].nickname);
menu_entries_append_enum(file_list,
s,
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM),
MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM,
MENU_ROOM, 0, 0);
}
netplay_rooms_free();
}
for (i = 0; i < netplay_room_count; i++)
memcpy(&netplay_room_list[i], netplay_room_get(i), sizeof(netplay_room_list[i]));
if (lan_room_count != 0)
{
@ -3512,20 +3527,15 @@ finish:
netplay_room_list[i].port = 55435;
netplay_room_list[i].gamecrc = host->content_crc;
netplay_room_list[i].timestamp = 0;
netplay_room_list[i].lan = true;
snprintf(s, sizeof(s),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME_LAN),
netplay_room_list[i].nickname);
menu_entries_append_enum(file_list,
s,
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM),
MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM,
MENU_ROOM, 0, 0);
k++;
}
netplay_room_count += lan_room_count;
}
netplay_refresh_rooms_menu(file_list);
}
}

View File

@ -42,6 +42,7 @@
#ifdef HAVE_NETWORKING
#include <net/net_http_parse.h>
#include "../../network/netplay/netplay.h"
#include "../network/netplay/netplay_discovery.h"
#endif
@ -3126,36 +3127,40 @@ static int menu_displaylist_parse_netplay_room_list(
{
#ifdef HAVE_NETWORKING
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST),
MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST,
MENU_SETTING_ACTION, 0, 0);
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
{
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST),
MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST,
MENU_SETTING_ACTION, 0, 0);
}
else if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER_ENABLED, NULL))
{
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT),
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
MENU_SETTING_ACTION, 0, 0);
}
else
{
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT),
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
MENU_SETTING_ACTION, 0, 0);
}
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS),
MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS,
MENU_SETTING_ACTION, 0, 0);
if (netplay_room_count > 0)
{
unsigned i;
for (i = 0; i < (unsigned)netplay_room_count; i++)
{
char s[PATH_MAX_LENGTH];
s[0] = '\0';
netplay_refresh_rooms_menu(info->list);
snprintf(s, sizeof(s),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME), netplay_room_list[i].nickname);
menu_entries_append_enum(info->list,
s,
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM),
MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM,
MENU_ROOM, 0, 0);
}
}
#endif
return 0;

View File

@ -206,7 +206,9 @@ typedef struct menu_displaylist_ctx_entry
} menu_displaylist_ctx_entry_t;
bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data);
#ifdef HAVE_NETWORKING
void netplay_refresh_rooms_menu(file_list_t *list);
#endif
RETRO_END_DECLS
#endif

View File

@ -922,6 +922,7 @@ enum msg_hash_enums
/* Netplay */
MENU_LABEL(NETPLAY_ENABLE_HOST),
MENU_LABEL(NETPLAY_DISABLE_HOST),
MENU_LABEL(NETPLAY_ENABLE_CLIENT),
MENU_LABEL(NETPLAY_DISCONNECT),
MENU_LABEL(NETPLAY_SETTINGS),

View File

@ -40,6 +40,7 @@ enum rarch_netplay_ctl_state
RARCH_NETPLAY_CTL_ENABLE_CLIENT,
RARCH_NETPLAY_CTL_DISABLE,
RARCH_NETPLAY_CTL_IS_ENABLED,
RARCH_NETPLAY_CTL_IS_SERVER_ENABLED,
RARCH_NETPLAY_CTL_IS_DATA_INITED,
RARCH_NETPLAY_CTL_PAUSE,
RARCH_NETPLAY_CTL_UNPAUSE,

View File

@ -74,6 +74,7 @@ struct netplay_room
int host_method;
bool has_password;
bool has_spectate_password;
bool lan;
bool fixed;
struct netplay_room *next;
};

View File

@ -1271,6 +1271,11 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
ret = false;
goto done;
case RARCH_NETPLAY_CTL_IS_SERVER_ENABLED:
ret = netplay_enabled && !netplay_is_client;
RARCH_LOG("TEST: %d = %d && %d", ret, netplay_enabled, netplay_is_client);
goto done;
default:
goto done;
}
@ -1287,6 +1292,10 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
goto done;
case RARCH_NETPLAY_CTL_IS_ENABLED:
goto done;
case RARCH_NETPLAY_CTL_IS_SERVER_ENABLED:
ret = netplay_enabled && !netplay_is_client;
RARCH_LOG("TEST: %d = %d && %d", ret, netplay_enabled, netplay_is_client);
goto done;
case RARCH_NETPLAY_CTL_POST_FRAME:
netplay_post_frame(netplay_data);
break;