diff options
-rw-r--r-- | main_gui.c | 35 | ||||
-rw-r--r-- | network.c | 3 | ||||
-rw-r--r-- | network_client.c | 10 | ||||
-rw-r--r-- | network_gui.c | 24 | ||||
-rw-r--r-- | network_gui.h | 3 |
5 files changed, 26 insertions, 49 deletions
diff --git a/main_gui.c b/main_gui.c index bf991e88f..caebe5afa 100644 --- a/main_gui.c +++ b/main_gui.c @@ -2359,7 +2359,6 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) void ShowSelectGameWindow(void); -extern void ShowJoinStatusWindowAfterJoin(void); void SetupColorsAndInitialWindow(void) { @@ -2377,32 +2376,20 @@ void SetupColorsAndInitialWindow(void) width = _screen.width; height = _screen.height; + w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL); + AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), 0); + // XXX: these are not done switch (_game_mode) { - case GM_MENU: - w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL); - AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), 0); - ShowSelectGameWindow(); - break; - case GM_NORMAL: - w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL); - AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), 0); - - ShowVitalWindows(); - - /* Bring joining GUI to front till the client is really joined */ - if (_networking && !_network_server) - ShowJoinStatusWindowAfterJoin(); - - break; - case GM_EDITOR: - w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL); - AssignWindowViewport(w, 0, 0, width, height, 0, 0); + default: NOT_REACHED(); + case GM_MENU: + ShowSelectGameWindow(); + break; - ShowVitalWindows(); - break; - default: - NOT_REACHED(); + case GM_NORMAL: + case GM_EDITOR: + ShowVitalWindows(); + break; } } @@ -29,6 +29,7 @@ #include "network_server.h" #include "network_udp.h" #include "network_gamelist.h" +#include "network_gui.h" #include "console.h" /* IConsoleCmdExec */ #include <stdarg.h> /* va_list */ #include "md5.h" @@ -47,7 +48,6 @@ static byte _network_clients_connected = 0; static uint16 _network_client_index = NETWORK_SERVER_INDEX + 1; /* Some externs / forwards */ -extern void ShowJoinStatusWindow(void); extern void StateGameLoop(void); // Function that looks up the CI for a given client-index @@ -689,6 +689,7 @@ static bool NetworkConnect(const char *hostname, int port) // in client mode, only the first client field is used. it's pointing to the server. NetworkAllocClient(s); + _network_join_status = NETWORK_JOIN_STATUS_CONNECTING; ShowJoinStatusWindow(); return true; diff --git a/network_client.c b/network_client.c index ef0ae0e03..39a12c28c 100644 --- a/network_client.c +++ b/network_client.c @@ -497,6 +497,8 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) _switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR; return NETWORK_RECV_STATUS_SAVEGAME; } + /* If the savegame has successfully loaded, ALL windows have been removed, + * only toolbar/statusbar and gamefield are visible */ _opt_ptr = &_opt; // during a network game you are always in-game @@ -510,18 +512,16 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) SetLocalPlayer(PLAYER_SPECTATOR); - if (_network_playas == PLAYER_SPECTATOR) { - // The client wants to be a spectator.. - DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); - } else { + if (_network_playas != PLAYER_SPECTATOR) { /* We have arrived and ready to start playing; send a command to make a new player; * the server will give us a client-id and let us in */ + _network_join_status = NETWORK_JOIN_STATUS_REGISTERING; + ShowJoinStatusWindow(); NetworkSend_Command(0, 0, 0, CMD_PLAYER_CTRL, NULL); } } else { // take control over an existing company SetLocalPlayer(_network_playas); - DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); } } diff --git a/network_gui.c b/network_gui.c index 4c994872c..d0dd5df4c 100644 --- a/network_gui.c +++ b/network_gui.c @@ -1416,8 +1416,7 @@ static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) case WE_CLICK: switch (e->we.click.widget) { - case 0: /* Close 'X' */ - case 3: /* Disconnect button */ + case 2: /* Disconnect button */ NetworkDisconnect(); DeleteWindow(w); SwitchMode(SM_MENU); @@ -1439,8 +1438,7 @@ static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) } static const Widget _network_join_status_window_widget[] = { -{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, -{ WWT_CAPTION, RESIZE_NONE, 14, 11, 249, 0, 13, STR_NETWORK_CONNECTING, STR_018C_WINDOW_TITLE_DRAG_THIS}, +{ WWT_CAPTION, RESIZE_NONE, 14, 0, 249, 0, 13, STR_NETWORK_CONNECTING, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_PANEL, RESIZE_NONE, 14, 0, 249, 14, 84, 0x0, STR_NULL}, { WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 75, 175, 69, 80, STR_NETWORK_DISCONNECT, STR_NULL}, { WIDGETS_END}, @@ -1449,26 +1447,18 @@ static const Widget _network_join_status_window_widget[] = { static const WindowDesc _network_join_status_window_desc = { WDP_CENTER, WDP_CENTER, 250, 85, WC_NETWORK_STATUS_WINDOW, 0, - WDF_STD_TOOLTIPS | WDF_DEF_WIDGET, + WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_MODAL, _network_join_status_window_widget, NetworkJoinStatusWindowWndProc, }; void ShowJoinStatusWindow(void) { + Window *w; DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); - _network_join_status = NETWORK_JOIN_STATUS_CONNECTING; - AllocateWindowDesc(&_network_join_status_window_desc); -} - -void ShowJoinStatusWindowAfterJoin(void) -{ - /* This is a special instant of ShowJoinStatusWindow, because - it is opened after the map is loaded, but the client maybe is not - done registering itself to the server */ - DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); - _network_join_status = NETWORK_JOIN_STATUS_REGISTERING; - AllocateWindowDesc(&_network_join_status_window_desc); + w = AllocateWindowDesc(&_network_join_status_window_desc); + /* Parent the status window to the lobby */ + if (w != NULL) w->parent = FindWindowById(WC_NETWORK_WINDOW, 0); } static void SendChat(const char *buf, DestType type, byte dest) diff --git a/network_gui.h b/network_gui.h index 9b9dbdace..aa4313eba 100644 --- a/network_gui.h +++ b/network_gui.h @@ -10,7 +10,7 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt); void ShowNetworkGiveMoneyWindow(byte player); // PlayerID void ShowNetworkChatQueryWindow(DestType type, byte dest); -void ShowJoinStatusWindowAfterJoin(void); +void ShowJoinStatusWindow(void); void ShowNetworkGameWindow(void); void ShowClientList(void); @@ -19,7 +19,6 @@ void ShowClientList(void); static inline void ShowNetworkChatQueryWindow(byte desttype, byte dest) {} static inline void ShowClientList(void) {} -static inline void ShowJoinStatusWindowAfterJoin(void) {} static inline void ShowNetworkGameWindow(void) {} #endif /* ENABLE_NETWORK */ |