network_gui.c
changeset 5683 dca046ba7aa3
parent 5682 eeddbbacd4ac
equal deleted inserted replaced
5682:eeddbbacd4ac 5683:dca046ba7aa3
  1414 		DrawFrameRect(20, 18, (int)((w->width - 20) * progress / 100), 28, 10, 0);
  1414 		DrawFrameRect(20, 18, (int)((w->width - 20) * progress / 100), 28, 10, 0);
  1415 	}	break;
  1415 	}	break;
  1416 
  1416 
  1417 	case WE_CLICK:
  1417 	case WE_CLICK:
  1418 		switch (e->we.click.widget) {
  1418 		switch (e->we.click.widget) {
  1419 			case 0: /* Close 'X' */
  1419 			case 2: /* Disconnect button */
  1420 			case 3: /* Disconnect button */
       
  1421 				NetworkDisconnect();
  1420 				NetworkDisconnect();
  1422 				DeleteWindow(w);
  1421 				DeleteWindow(w);
  1423 				SwitchMode(SM_MENU);
  1422 				SwitchMode(SM_MENU);
  1424 				ShowNetworkGameWindow();
  1423 				ShowNetworkGameWindow();
  1425 				break;
  1424 				break;
  1437 			break;
  1436 			break;
  1438 	}
  1437 	}
  1439 }
  1438 }
  1440 
  1439 
  1441 static const Widget _network_join_status_window_widget[] = {
  1440 static const Widget _network_join_status_window_widget[] = {
  1442 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
  1441 {    WWT_CAPTION,   RESIZE_NONE,    14,     0,   249,     0,    13, STR_NETWORK_CONNECTING, STR_018C_WINDOW_TITLE_DRAG_THIS},
  1443 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   249,     0,    13, STR_NETWORK_CONNECTING, STR_018C_WINDOW_TITLE_DRAG_THIS},
       
  1444 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,    84, 0x0,                    STR_NULL},
  1442 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,    84, 0x0,                    STR_NULL},
  1445 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    75,   175,    69,    80, STR_NETWORK_DISCONNECT, STR_NULL},
  1443 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    75,   175,    69,    80, STR_NETWORK_DISCONNECT, STR_NULL},
  1446 {   WIDGETS_END},
  1444 {   WIDGETS_END},
  1447 };
  1445 };
  1448 
  1446 
  1449 static const WindowDesc _network_join_status_window_desc = {
  1447 static const WindowDesc _network_join_status_window_desc = {
  1450 	WDP_CENTER, WDP_CENTER, 250, 85,
  1448 	WDP_CENTER, WDP_CENTER, 250, 85,
  1451 	WC_NETWORK_STATUS_WINDOW, 0,
  1449 	WC_NETWORK_STATUS_WINDOW, 0,
  1452 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
  1450 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_MODAL,
  1453 	_network_join_status_window_widget,
  1451 	_network_join_status_window_widget,
  1454 	NetworkJoinStatusWindowWndProc,
  1452 	NetworkJoinStatusWindowWndProc,
  1455 };
  1453 };
  1456 
  1454 
  1457 void ShowJoinStatusWindow(void)
  1455 void ShowJoinStatusWindow(void)
  1458 {
  1456 {
       
  1457 	Window *w;
  1459 	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
  1458 	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
  1460 	_network_join_status = NETWORK_JOIN_STATUS_CONNECTING;
  1459 	w = AllocateWindowDesc(&_network_join_status_window_desc);
  1461 	AllocateWindowDesc(&_network_join_status_window_desc);
  1460 	/* Parent the status window to the lobby */
  1462 }
  1461 	if (w != NULL) w->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
  1463 
       
  1464 void ShowJoinStatusWindowAfterJoin(void)
       
  1465 {
       
  1466 	/* This is a special instant of ShowJoinStatusWindow, because
       
  1467 	    it is opened after the map is loaded, but the client maybe is not
       
  1468 	    done registering itself to the server */
       
  1469 	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
       
  1470 	_network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
       
  1471 	AllocateWindowDesc(&_network_join_status_window_desc);
       
  1472 }
  1462 }
  1473 
  1463 
  1474 static void SendChat(const char *buf, DestType type, byte dest)
  1464 static void SendChat(const char *buf, DestType type, byte dest)
  1475 {
  1465 {
  1476 	if (buf[0] == '\0') return;
  1466 	if (buf[0] == '\0') return;