1
0
Fork 0

(svn r13135) -Codechange: make a class of the NetworkJoinStatusWindow.

release/0.7
rubidium 2008-05-17 08:00:13 +00:00
parent 27c3d210c4
commit edb2e77035
1 changed files with 55 additions and 53 deletions

View File

@ -1597,13 +1597,16 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt)
ShowQueryString(STR_EMPTY, caption, 20, 180, FindWindowById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL); ShowQueryString(STR_EMPTY, caption, 20, 180, FindWindowById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL);
} }
struct NetworkJoinStatusWindow : Window {
static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) NetworkJoinStatusWindow(const WindowDesc *desc) : Window(desc)
{
this->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
}
virtual void OnPaint()
{ {
switch (e->event) {
case WE_PAINT: {
uint8 progress; // used for progress bar uint8 progress; // used for progress bar
DrawWindowWidgets(w); DrawWindowWidgets(this);
DrawStringCentered(125, 35, STR_NETWORK_CONNECTING_1 + _network_join_status, TC_GREY); DrawStringCentered(125, 35, STR_NETWORK_CONNECTING_1 + _network_join_status, TC_GREY);
switch (_network_join_status) { switch (_network_join_status) {
@ -1626,27 +1629,28 @@ static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e)
} }
/* Draw nice progress bar :) */ /* Draw nice progress bar :) */
DrawFrameRect(20, 18, (int)((w->width - 20) * progress / 100), 28, 10, FR_NONE); DrawFrameRect(20, 18, (int)((this->width - 20) * progress / 100), 28, 10, FR_NONE);
} break; }
case WE_CLICK: virtual void OnClick(Point pt, int widget)
if (e->we.click.widget == 2) { //Disconnect button {
if (widget == 2) { //Disconnect button
NetworkDisconnect(); NetworkDisconnect();
SwitchMode(SM_MENU); SwitchMode(SM_MENU);
ShowNetworkGameWindow(); ShowNetworkGameWindow();
} }
break; }
case WE_ON_EDIT_TEXT: virtual void OnQueryTextFinished(char *str)
if (StrEmpty(e->we.edittext.str)) { {
if (StrEmpty(str)) {
NetworkDisconnect(); NetworkDisconnect();
ShowNetworkGameWindow(); ShowNetworkGameWindow();
} else { } else {
SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, e->we.edittext.str); SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, str);
}
break;
} }
} }
};
static const Widget _network_join_status_window_widget[] = { static const Widget _network_join_status_window_widget[] = {
{ WWT_CAPTION, RESIZE_NONE, 14, 0, 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},
@ -1660,15 +1664,13 @@ static const WindowDesc _network_join_status_window_desc = {
WC_NETWORK_STATUS_WINDOW, WC_NONE, WC_NETWORK_STATUS_WINDOW, WC_NONE,
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_MODAL, WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_MODAL,
_network_join_status_window_widget, _network_join_status_window_widget,
NetworkJoinStatusWindowWndProc, NULL,
}; };
void ShowJoinStatusWindow() void ShowJoinStatusWindow()
{ {
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
Window *w = new Window(&_network_join_status_window_desc); new NetworkJoinStatusWindow(&_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, int dest) static void SendChat(const char *buf, DestType type, int dest)