mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
some code for SetupColorsAndInitialWindow. Because we know that after a successful load all windows are removed we can setup default windows in this function, and show ShowJoinStatusWindow in PACKET_SERVER_MAP. -Setup the global _network_join_status for ShowJoinStatusWindow in the only two places where the function is called, instead of inside it. -Turn the join status window into a modal window of the network window so it stays on top.
This commit is contained in:
parent
c87fcab772
commit
f475636186
35
main_gui.c
35
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);
|
||||
default: NOT_REACHED();
|
||||
case GM_MENU:
|
||||
ShowSelectGameWindow();
|
||||
break;
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user