From 3c416b16d70f505c3bb5f7e55bd12d54e00ac262 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Tue, 15 Oct 2019 14:41:26 +0200 Subject: [PATCH] Fix display of Connection menu (#354) --- SourceX/DiabloUI/selconn.cpp | 45 +++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/SourceX/DiabloUI/selconn.cpp b/SourceX/DiabloUI/selconn.cpp index ca2f2f56d..d71fe1318 100644 --- a/SourceX/DiabloUI/selconn.cpp +++ b/SourceX/DiabloUI/selconn.cpp @@ -19,17 +19,28 @@ _SNETVERSIONDATA *selconn_FileInfo; DWORD provider; UiArtText SELCONNECT_DIALOG_DESCRIPTION(selconn_Description, { 35, 275, 205, 66 }); + +// Should be in the same order than SELCONN_DIALOG_ITEM +enum { +#ifndef NONET + SELCONN_TCP, +#ifdef BUGGY + SELCONN_UDP, +#endif +#endif + SELCONN_LOOPBACK, +}; + UiListItem SELCONN_DIALOG_ITEMS[] = { #ifndef NONET - { "Client-Server (TCP)", 0 }, + { "Client-Server (TCP)", SELCONN_TCP }, #ifdef BUGGY - { "Peer-to-Peer (UDP)", 1 }, + { "Peer-to-Peer (UDP)", SELCONN_UDP }, #endif - { "Loopback", 2 }, -#else - { "Loopback", 0 }, #endif + { "Loopback", SELCONN_LOOPBACK }, }; + UiItem SELCONNECT_DIALOG[] = { MAINMENU_BACKGROUND, MAINMENU_LOGO, @@ -49,7 +60,7 @@ UiItem SELCONNECT_DIALOG[] = { void selconn_Load() { LoadBackgroundArt("ui_art\\selconn.pcx"); - UiInitList(0, 2, selconn_Focus, selconn_Select, selconn_Esc, SELCONNECT_DIALOG, size(SELCONNECT_DIALOG)); + UiInitList(0, size(SELCONN_DIALOG_ITEMS) - 1, selconn_Focus, selconn_Select, selconn_Esc, SELCONNECT_DIALOG, size(SELCONNECT_DIALOG)); } void selconn_Free() @@ -67,15 +78,19 @@ void selconn_Focus(int value) { int players = MAX_PLRS; switch (value) { - case 0: +#ifndef NONET + case SELCONN_TCP: strcpy(selconn_Description, "All computers must be connected to a TCP-compatible network."); players = MAX_PLRS; break; - case 1: +#ifdef BUGGY + case SELCONN_UDP: strcpy(selconn_Description, "All computers must be connected to a UDP-compatible network."); players = MAX_PLRS; break; - case 2: +#endif +#endif + case SELCONN_LOOPBACK: strcpy(selconn_Description, "Play by yourself with no network exposure."); players = 1; break; @@ -88,13 +103,17 @@ void selconn_Focus(int value) void selconn_Select(int value) { switch (value) { - case 0: +#ifndef NONET + case SELCONN_TCP: provider = 'TCPN'; break; - case 1: +#ifdef BUGGY + case SELCONN_UDP: provider = 'UDPN'; break; - case 2: +#endif +#endif + case SELCONN_LOOPBACK: provider = 'SCBL'; break; } @@ -129,4 +148,4 @@ int UiSelectProvider( return selconn_ReturnValue; } -} +} // namespace dvl