src/network/network_gui.cpp
branchNewGRF_ports
changeset 6743 cabfaa4a0295
parent 6720 35756db7e577
child 6868 7eb395287b3d
equal deleted inserted replaced
6742:1337d6c9b97b 6743:cabfaa4a0295
    85 	INVALID_STRING_ID
    85 	INVALID_STRING_ID
    86 };
    86 };
    87 
    87 
    88 static StringID _language_dropdown[NETLANG_COUNT + 1] = {STR_NULL};
    88 static StringID _language_dropdown[NETLANG_COUNT + 1] = {STR_NULL};
    89 
    89 
    90 void SortNetworkLanguages() {
    90 void SortNetworkLanguages()
       
    91 {
    91 	/* Init the strings */
    92 	/* Init the strings */
    92 	if (_language_dropdown[0] == STR_NULL) {
    93 	if (_language_dropdown[0] == STR_NULL) {
    93 		for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown[i] = STR_NETWORK_LANG_ANY + i;
    94 		for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown[i] = STR_NETWORK_LANG_ANY + i;
    94 		_language_dropdown[NETLANG_COUNT] = INVALID_STRING_ID;
    95 		_language_dropdown[NETLANG_COUNT] = INVALID_STRING_ID;
    95 	}
    96 	}
   228 	network_d *nd = &WP(w, network_ql_d).n;
   229 	network_d *nd = &WP(w, network_ql_d).n;
   229 	list_d *ld = &WP(w, network_ql_d).l;
   230 	list_d *ld = &WP(w, network_ql_d).l;
   230 
   231 
   231 	switch (e->event) {
   232 	switch (e->event) {
   232 	case WE_CREATE: /* Focus input box */
   233 	case WE_CREATE: /* Focus input box */
       
   234 		w->vscroll.cap = 13;
       
   235 		w->resize.step_height = NET_PRC__SIZE_OF_ROW;
       
   236 
   233 		nd->field = 3;
   237 		nd->field = 3;
   234 		nd->server = NULL;
   238 		nd->server = NULL;
   235 
   239 
   236 		WP(w, network_ql_d).sort_list = NULL;
   240 		WP(w, network_ql_d).sort_list = NULL;
   237 		ld->flags = VL_REBUILD | (_ng_sorting.order ? VL_DESC : VL_NONE);
   241 		ld->flags = VL_REBUILD | (_ng_sorting.order ? VL_DESC : VL_NONE);
   264 		DrawWindowWidgets(w);
   268 		DrawWindowWidgets(w);
   265 
   269 
   266 		DrawEditBox(w, &WP(w, network_ql_d).q, 3);
   270 		DrawEditBox(w, &WP(w, network_ql_d).q, 3);
   267 
   271 
   268 		DrawString(9, 23, STR_NETWORK_CONNECTION, 2);
   272 		DrawString(9, 23, STR_NETWORK_CONNECTION, 2);
   269 		DrawString(210, 23, STR_NETWORK_PLAYER_NAME, 2);
   273 		DrawString(w->widget[3].left - 100, 23, STR_NETWORK_PLAYER_NAME, 2);
   270 
   274 
   271 		/* Sort based on widgets: name, clients, compatibility */
   275 		/* Sort based on widgets: name, clients, compatibility */
   272 		switch (ld->sort_type) {
   276 		switch (ld->sort_type) {
   273 			case 6 - 6: DoDrawString(arrow, w->widget[6].right - 10, 42, 0x10); break;
   277 			case 6 - 6: DoDrawString(arrow, w->widget[6].right - 10, 42, 0x10); break;
   274 			case 7 - 6: DoDrawString(arrow, w->widget[7].right - 10, 42, 0x10); break;
   278 			case 7 - 6: DoDrawString(arrow, w->widget[7].right - 10, 42, 0x10); break;
   296 
   300 
   297 				SetDParam(0, cur_item->info.clients_on);
   301 				SetDParam(0, cur_item->info.clients_on);
   298 				SetDParam(1, cur_item->info.clients_max);
   302 				SetDParam(1, cur_item->info.clients_max);
   299 				SetDParam(2, cur_item->info.companies_on);
   303 				SetDParam(2, cur_item->info.companies_on);
   300 				SetDParam(3, cur_item->info.companies_max);
   304 				SetDParam(3, cur_item->info.companies_max);
   301 				DrawStringCentered(210, y, STR_NETWORK_GENERAL_ONLINE, 2);
   305 				DrawStringCentered(w->widget[7].left + 39, y, STR_NETWORK_GENERAL_ONLINE, 2);
   302 
   306 
   303 				// only draw icons if the server is online
   307 				// only draw icons if the server is online
   304 				if (cur_item->online) {
   308 				if (cur_item->online) {
   305 					// draw a lock if the server is password protected.
   309 					// draw a lock if the server is password protected.
   306 					if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, w->widget[8].left + 5, y - 1);
   310 					if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, w->widget[8].left + 5, y - 1);
   317 				if (++n == w->vscroll.cap) break; // max number of games in the window
   321 				if (++n == w->vscroll.cap) break; // max number of games in the window
   318 			}
   322 			}
   319 		}
   323 		}
   320 
   324 
   321 		/* Draw the right menu */
   325 		/* Draw the right menu */
   322 		GfxFillRect(311, 43, 539, 92, 157);
   326 		GfxFillRect(w->widget[15].left + 1, 43, w->widget[15].right - 1, 92, 157);
   323 		if (sel == NULL) {
   327 		if (sel == NULL) {
   324 			DrawStringCentered(425, 58, STR_NETWORK_GAME_INFO, 0);
   328 			DrawStringCentered(w->widget[15].left + 115, 58, STR_NETWORK_GAME_INFO, 0);
   325 		} else if (!sel->online) {
   329 		} else if (!sel->online) {
   326 			SetDParamStr(0, sel->info.server_name);
   330 			SetDParamStr(0, sel->info.server_name);
   327 			DrawStringCentered(425, 68, STR_ORANGE, 0); // game name
   331 			DrawStringCentered(w->widget[15].left + 115, 68, STR_ORANGE, 0); // game name
   328 
   332 
   329 			DrawStringCentered(425, 132, STR_NETWORK_SERVER_OFFLINE, 0); // server offline
   333 			DrawStringCentered(w->widget[15].left + 115, 132, STR_NETWORK_SERVER_OFFLINE, 0); // server offline
   330 		} else { // show game info
   334 		} else { // show game info
   331 			uint16 y = 100;
   335 			uint16 y = 100;
   332 			const uint16 x = w->widget[15].left + 5;
   336 			const uint16 x = w->widget[15].left + 5;
   333 
   337 
   334 			DrawStringCentered(425, 48, STR_NETWORK_GAME_INFO, 0);
   338 			DrawStringCentered(w->widget[15].left + 115, 48, STR_NETWORK_GAME_INFO, 0);
   335 
   339 
   336 
   340 
   337 			SetDParamStr(0, sel->info.server_name);
   341 			SetDParamStr(0, sel->info.server_name);
   338 			DrawStringCenteredTruncated(w->widget[15].left, w->widget[15].right, 62, STR_ORANGE, 16); // game name
   342 			DrawStringCenteredTruncated(w->widget[15].left, w->widget[15].right, 62, STR_ORANGE, 16); // game name
   339 
   343 
   378 			y += 10;
   382 			y += 10;
   379 
   383 
   380 			y += 2;
   384 			y += 2;
   381 
   385 
   382 			if (!sel->info.compatible) {
   386 			if (!sel->info.compatible) {
   383 				DrawStringCentered(425, y, sel->info.version_compatible ? STR_NETWORK_GRF_MISMATCH : STR_NETWORK_VERSION_MISMATCH, 0); // server mismatch
   387 				DrawStringCentered(w->widget[15].left + 115, y, sel->info.version_compatible ? STR_NETWORK_GRF_MISMATCH : STR_NETWORK_VERSION_MISMATCH, 0); // server mismatch
   384 			} else if (sel->info.clients_on == sel->info.clients_max) {
   388 			} else if (sel->info.clients_on == sel->info.clients_max) {
   385 				// Show: server full, when clients_on == clients_max
   389 				// Show: server full, when clients_on == clients_max
   386 				DrawStringCentered(425, y, STR_NETWORK_SERVER_FULL, 0); // server full
   390 				DrawStringCentered(w->widget[15].left + 115, y, STR_NETWORK_SERVER_FULL, 0); // server full
   387 			} else if (sel->info.use_password) {
   391 			} else if (sel->info.use_password) {
   388 				DrawStringCentered(425, y, STR_NETWORK_PASSWORD, 0); // password warning
   392 				DrawStringCentered(w->widget[15].left + 115, y, STR_NETWORK_PASSWORD, 0); // password warning
   389 			}
   393 			}
   390 
   394 
   391 			y += 10;
   395 			y += 10;
   392 		}
   396 		}
   393 	} break;
   397 	} break;
   394 
   398 
   395 	case WE_CLICK:
   399 	case WE_CLICK:
   396 		nd->field = e->we.click.widget;
   400 		nd->field = e->we.click.widget;
   397 		switch (e->we.click.widget) {
   401 		switch (e->we.click.widget) {
   398 		case 0: case 14: /* Close 'X' | Cancel button */
   402 		case 14: // Cancel button
   399 			DeleteWindowById(WC_NETWORK_WINDOW, 0);
   403 			DeleteWindowById(WC_NETWORK_WINDOW, 0);
   400 			break;
   404 			break;
   401 		case 4: case 5:
   405 		case 4: case 5:
   402 			ShowDropDownMenu(w, _lan_internet_types_dropdown, _network_lan_internet, 5, 0, 0); // do it for widget 5
   406 			ShowDropDownMenu(w, _lan_internet_types_dropdown, _network_lan_internet, 5, 0, 0); // do it for widget 5
   403 			break;
   407 			break;
   505 	case WE_ON_EDIT_TEXT:
   509 	case WE_ON_EDIT_TEXT:
   506 		NetworkAddServer(e->we.edittext.str);
   510 		NetworkAddServer(e->we.edittext.str);
   507 		NetworkRebuildHostList();
   511 		NetworkRebuildHostList();
   508 		break;
   512 		break;
   509 
   513 
       
   514 	case WE_RESIZE: {
       
   515 		w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
       
   516 
       
   517 		w->widget[9].data = (w->vscroll.cap << 8) + 1;
       
   518 
       
   519 		int widget_width = w->widget[11].right - w->widget[11].left;
       
   520 		int space = (w->width - 4 * widget_width - 25) / 3;
       
   521 
       
   522 		int offset = 10;
       
   523 		for (uint i = 0; i < 4; i++) {
       
   524 			w->widget[11 + i].left  = offset;
       
   525 			offset += widget_width;
       
   526 			w->widget[11 + i].right = offset;
       
   527 			offset += space;
       
   528 		}
       
   529 	} break;
       
   530 
   510 	case WE_DESTROY: /* Nicely clean up the sort-list */
   531 	case WE_DESTROY: /* Nicely clean up the sort-list */
   511 		free(WP(w, network_ql_d).sort_list);
   532 		free(WP(w, network_ql_d).sort_list);
   512 		break;
   533 		break;
   513 	}
   534 	}
   514 }
   535 }
   515 
   536 
   516 static const Widget _network_game_window_widgets[] = {
   537 static const Widget _network_game_window_widgets[] = {
   517 {   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
   538 {   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
   518 {    WWT_CAPTION,   RESIZE_NONE,   BGC,    11,   549,     0,    13, STR_NETWORK_MULTIPLAYER,     STR_NULL},
   539 {    WWT_CAPTION,   RESIZE_RIGHT,  BGC,    11,   449,     0,    13, STR_NETWORK_MULTIPLAYER,     STR_NULL},
   519 {      WWT_PANEL,   RESIZE_NONE,   BGC,     0,   549,    14,   263, 0x0,                         STR_NULL},
   540 {      WWT_PANEL,   RESIZE_RB,     BGC,     0,   449,    14,   263, 0x0,                         STR_NULL},
   520 
   541 
   521 /* LEFT SIDE */
   542 /* LEFT SIDE */
   522 {      WWT_PANEL,   RESIZE_NONE,   BGC,   310,   461,    22,    33, 0x0,                         STR_NETWORK_ENTER_NAME_TIP},
   543 {      WWT_PANEL,   RESIZE_LR,     BGC,   290,   440,    22,    33, 0x0,                         STR_NETWORK_ENTER_NAME_TIP},
   523 
   544 
   524 {      WWT_INSET,   RESIZE_NONE,   BGC,    90,   181,    22,    33, STR_NETWORK_COMBO1,          STR_NETWORK_CONNECTION_TIP},
   545 {      WWT_INSET,   RESIZE_NONE,   BGC,    90,   181,    22,    33, STR_NETWORK_COMBO1,          STR_NETWORK_CONNECTION_TIP},
   525 {    WWT_TEXTBTN,   RESIZE_NONE,   BGC,   170,   180,    23,    32, STR_0225,                    STR_NETWORK_CONNECTION_TIP},
   546 {    WWT_TEXTBTN,   RESIZE_NONE,   BGC,   170,   180,    23,    32, STR_0225,                    STR_NETWORK_CONNECTION_TIP},
   526 
   547 
   527 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    10,   170,    42,    53, STR_NETWORK_GAME_NAME,       STR_NETWORK_GAME_NAME_TIP},
   548 { WWT_PUSHTXTBTN,   RESIZE_RIGHT,  BTC,    10,    70,    42,    53, STR_NETWORK_GAME_NAME,       STR_NETWORK_GAME_NAME_TIP},
   528 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   171,   250,    42,    53, STR_NETWORK_CLIENTS_CAPTION, STR_NETWORK_CLIENTS_CAPTION_TIP},
   549 { WWT_PUSHTXTBTN,   RESIZE_LR,     BTC,    71,   150,    42,    53, STR_NETWORK_CLIENTS_CAPTION, STR_NETWORK_CLIENTS_CAPTION_TIP},
   529 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   251,   290,    42,    53, STR_EMPTY,                   STR_NETWORK_INFO_ICONS_TIP},
   550 { WWT_PUSHTXTBTN,   RESIZE_LR,     BTC,   151,   190,    42,    53, STR_EMPTY,                   STR_NETWORK_INFO_ICONS_TIP},
   530 
   551 
   531 {     WWT_MATRIX,   RESIZE_NONE,   BGC,    10,   290,    54,   236, (13 << 8) + 1,               STR_NETWORK_CLICK_GAME_TO_SELECT},
   552 {     WWT_MATRIX,   RESIZE_RB,     BGC,    10,   190,    54,   236, (13 << 8) + 1,               STR_NETWORK_CLICK_GAME_TO_SELECT},
   532 {  WWT_SCROLLBAR,   RESIZE_NONE,   BGC,   291,   302,    42,   236, STR_NULL,                    STR_0190_SCROLL_BAR_SCROLLS_LIST},
   553 {  WWT_SCROLLBAR,   RESIZE_LRB,    BGC,   191,   202,    42,   236, STR_NULL,                    STR_0190_SCROLL_BAR_SCROLLS_LIST},
   533 
   554 
   534 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    30,   130,   246,   257, STR_NETWORK_FIND_SERVER,     STR_NETWORK_FIND_SERVER_TIP},
   555 { WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,    10,   110,   246,   257, STR_NETWORK_FIND_SERVER,     STR_NETWORK_FIND_SERVER_TIP},
   535 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   180,   280,   246,   257, STR_NETWORK_ADD_SERVER,      STR_NETWORK_ADD_SERVER_TIP},
   556 { WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   118,   218,   246,   257, STR_NETWORK_ADD_SERVER,      STR_NETWORK_ADD_SERVER_TIP},
   536 
   557 
   537 /* RIGHT SIDE */
   558 /* RIGHT SIDE */
   538 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   315,   415,   246,   257, STR_NETWORK_START_SERVER,    STR_NETWORK_START_SERVER_TIP},
   559 { WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   226,   326,   246,   257, STR_NETWORK_START_SERVER,    STR_NETWORK_START_SERVER_TIP},
   539 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   430,   535,   246,   257, STR_012E_CANCEL,             STR_NULL},
   560 { WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   334,   434,   246,   257, STR_012E_CANCEL,             STR_NULL},
   540 
   561 
   541 {      WWT_PANEL,   RESIZE_NONE,   BGC,   310,   540,    42,   236, 0x0,                         STR_NULL},
   562 {      WWT_PANEL,   RESIZE_LRB,    BGC,   210,   440,    42,   236, 0x0,                         STR_NULL},
   542 
   563 
   543 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   315,   415,   215,   226, STR_NETWORK_JOIN_GAME,       STR_NULL},
   564 { WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   215,   315,   215,   226, STR_NETWORK_JOIN_GAME,       STR_NULL},
   544 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   430,   535,   215,   226, STR_NETWORK_REFRESH,         STR_NETWORK_REFRESH_TIP},
   565 { WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   330,   435,   215,   226, STR_NETWORK_REFRESH,         STR_NETWORK_REFRESH_TIP},
   545 
   566 
   546 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   430,   535,   197,   208, STR_NEWGRF_SETTINGS_BUTTON,  STR_NULL},
   567 { WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   330,   435,   197,   208, STR_NEWGRF_SETTINGS_BUTTON,  STR_NULL},
       
   568 
       
   569 {  WWT_RESIZEBOX,   RESIZE_LRTB,   BGC,   438,   449,   252,   263, 0x0,                         STR_RESIZE_BUTTON },
   547 
   570 
   548 {   WIDGETS_END},
   571 {   WIDGETS_END},
   549 };
   572 };
   550 
   573 
   551 static const WindowDesc _network_game_window_desc = {
   574 static const WindowDesc _network_game_window_desc = {
   552 	WDP_CENTER, WDP_CENTER, 550, 264,
   575 	WDP_CENTER, WDP_CENTER, 450, 264, 550, 264,
   553 	WC_NETWORK_WINDOW, WC_NONE,
   576 	WC_NETWORK_WINDOW, WC_NONE,
   554 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
   577 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
   555 	_network_game_window_widgets,
   578 	_network_game_window_widgets,
   556 	NetworkGameWindowWndProc,
   579 	NetworkGameWindowWndProc,
   557 };
   580 };
   558 
   581 
   559 void ShowNetworkGameWindow()
   582 void ShowNetworkGameWindow()
   579 	w = AllocateWindowDesc(&_network_game_window_desc);
   602 	w = AllocateWindowDesc(&_network_game_window_desc);
   580 	if (w != NULL) {
   603 	if (w != NULL) {
   581 		querystr_d *querystr = &WP(w, network_ql_d).q;
   604 		querystr_d *querystr = &WP(w, network_ql_d).q;
   582 
   605 
   583 		ttd_strlcpy(_edit_str_buf, _network_player_name, lengthof(_edit_str_buf));
   606 		ttd_strlcpy(_edit_str_buf, _network_player_name, lengthof(_edit_str_buf));
   584 		w->vscroll.cap = 13;
       
   585 
       
   586 		querystr->afilter = CS_ALPHANUMERAL;
   607 		querystr->afilter = CS_ALPHANUMERAL;
   587 		InitializeTextBuffer(&querystr->text, _edit_str_buf, lengthof(_edit_str_buf), 120);
   608 		InitializeTextBuffer(&querystr->text, _edit_str_buf, lengthof(_edit_str_buf), 120);
   588 
   609 
   589 		UpdateNetworkGameWindow(true);
   610 		UpdateNetworkGameWindow(true);
   590 	}
   611 	}
   783 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   260,   360,   224,   235, STR_012E_CANCEL,               STR_NULL},
   804 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,   260,   360,   224,   235, STR_012E_CANCEL,               STR_NULL},
   784 {   WIDGETS_END},
   805 {   WIDGETS_END},
   785 };
   806 };
   786 
   807 
   787 static const WindowDesc _network_start_server_window_desc = {
   808 static const WindowDesc _network_start_server_window_desc = {
   788 	WDP_CENTER, WDP_CENTER, 420, 244,
   809 	WDP_CENTER, WDP_CENTER, 420, 244, 420, 244,
   789 	WC_NETWORK_WINDOW, WC_NONE,
   810 	WC_NETWORK_WINDOW, WC_NONE,
   790 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
   811 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
   791 	_network_start_server_window_widgets,
   812 	_network_start_server_window_widgets,
   792 	NetworkStartServerWindowWndProc,
   813 	NetworkStartServerWindowWndProc,
   793 };
   814 };
   992 
  1013 
   993 {   WIDGETS_END},
  1014 {   WIDGETS_END},
   994 };
  1015 };
   995 
  1016 
   996 static const WindowDesc _network_lobby_window_desc = {
  1017 static const WindowDesc _network_lobby_window_desc = {
   997 	WDP_CENTER, WDP_CENTER, 420, 235,
  1018 	WDP_CENTER, WDP_CENTER, 420, 235, 420, 235,
   998 	WC_NETWORK_WINDOW, WC_NONE,
  1019 	WC_NETWORK_WINDOW, WC_NONE,
   999 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
  1020 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
  1000 	_network_lobby_window_widgets,
  1021 	_network_lobby_window_widgets,
  1001 	NetworkLobbyWindowWndProc,
  1022 	NetworkLobbyWindowWndProc,
  1002 };
  1023 };
  1057 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   99,     0,     0,     0, STR_NULL},
  1078 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   99,     0,     0,     0, STR_NULL},
  1058 {   WIDGETS_END},
  1079 {   WIDGETS_END},
  1059 };
  1080 };
  1060 
  1081 
  1061 static WindowDesc _client_list_desc = {
  1082 static WindowDesc _client_list_desc = {
  1062 	WDP_AUTO, WDP_AUTO, 250, 1,
  1083 	WDP_AUTO, WDP_AUTO, 250, 1, 250, 1,
  1063 	WC_CLIENT_LIST, WC_NONE,
  1084 	WC_CLIENT_LIST, WC_NONE,
  1064 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
  1085 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
  1065 	_client_list_widgets,
  1086 	_client_list_widgets,
  1066 	ClientListWndProc
  1087 	ClientListWndProc
  1067 };
  1088 };
  1131 }
  1152 }
  1132 
  1153 
  1133 
  1154 
  1134 
  1155 
  1135 // Help, a action is clicked! What do we do?
  1156 // Help, a action is clicked! What do we do?
  1136 static void HandleClientListPopupClick(byte index, byte clientno) {
  1157 static void HandleClientListPopupClick(byte index, byte clientno)
       
  1158 {
  1137 	// A click on the Popup of the ClientList.. handle the command
  1159 	// A click on the Popup of the ClientList.. handle the command
  1138 	if (index < MAX_CLIENTLIST_ACTION && _clientlist_proc[index] != NULL) {
  1160 	if (index < MAX_CLIENTLIST_ACTION && _clientlist_proc[index] != NULL) {
  1139 		_clientlist_proc[index](clientno);
  1161 		_clientlist_proc[index](clientno);
  1140 	}
  1162 	}
  1141 }
  1163 }
  1164 	}
  1186 	}
  1165 	return true;
  1187 	return true;
  1166 }
  1188 }
  1167 
  1189 
  1168 // Finds the amount of actions in the popup and set the height correct
  1190 // Finds the amount of actions in the popup and set the height correct
  1169 static uint ClientListPopupHeigth() {
  1191 static uint ClientListPopupHeight()
       
  1192 {
  1170 	int i, num = 0;
  1193 	int i, num = 0;
  1171 
  1194 
  1172 	// Find the amount of actions
  1195 	// Find the amount of actions
  1173 	for (i = 0; i < MAX_CLIENTLIST_ACTION; i++) {
  1196 	for (i = 0; i < MAX_CLIENTLIST_ACTION; i++) {
  1174 		if (_clientlist_action[i][0] == '\0') continue;
  1197 		if (_clientlist_action[i][0] == '\0') continue;
  1234 		GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_NONE, lastof(_clientlist_action[i]));
  1257 		GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_NONE, lastof(_clientlist_action[i]));
  1235 		_clientlist_proc[i++] = &ClientList_None;
  1258 		_clientlist_proc[i++] = &ClientList_None;
  1236 	}
  1259 	}
  1237 
  1260 
  1238 	/* Calculate the height */
  1261 	/* Calculate the height */
  1239 	h = ClientListPopupHeigth();
  1262 	h = ClientListPopupHeight();
  1240 
  1263 
  1241 	// Allocate the popup
  1264 	// Allocate the popup
  1242 	w = AllocateWindow(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets);
  1265 	w = AllocateWindow(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets);
  1243 	w->widget[0].bottom = w->widget[0].top + h;
  1266 	w->widget[0].bottom = w->widget[0].top + h;
  1244 	w->widget[0].right = w->widget[0].left + 150;
  1267 	w->widget[0].right = w->widget[0].left + 150;
  1466 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    75,   175,    69,    80, STR_NETWORK_DISCONNECT, STR_NULL},
  1489 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    75,   175,    69,    80, STR_NETWORK_DISCONNECT, STR_NULL},
  1467 {   WIDGETS_END},
  1490 {   WIDGETS_END},
  1468 };
  1491 };
  1469 
  1492 
  1470 static const WindowDesc _network_join_status_window_desc = {
  1493 static const WindowDesc _network_join_status_window_desc = {
  1471 	WDP_CENTER, WDP_CENTER, 250, 85,
  1494 	WDP_CENTER, WDP_CENTER, 250, 85, 250, 85,
  1472 	WC_NETWORK_STATUS_WINDOW, WC_NONE,
  1495 	WC_NETWORK_STATUS_WINDOW, WC_NONE,
  1473 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_MODAL,
  1496 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_MODAL,
  1474 	_network_join_status_window_widget,
  1497 	_network_join_status_window_widget,
  1475 	NetworkJoinStatusWindowWndProc,
  1498 	NetworkJoinStatusWindowWndProc,
  1476 };
  1499 };
  1484 	if (w != NULL) w->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
  1507 	if (w != NULL) w->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
  1485 }
  1508 }
  1486 
  1509 
  1487 static void SendChat(const char *buf, DestType type, int dest)
  1510 static void SendChat(const char *buf, DestType type, int dest)
  1488 {
  1511 {
  1489 	if (buf[0] == '\0') return;
  1512 	if (StrEmpty(buf)) return;
  1490 	if (!_network_server) {
  1513 	if (!_network_server) {
  1491 		SEND_COMMAND(PACKET_CLIENT_CHAT)((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf);
  1514 		SEND_COMMAND(PACKET_CLIENT_CHAT)((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf);
  1492 	} else {
  1515 	} else {
  1493 		NetworkServer_HandleChat((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf, NETWORK_SERVER_INDEX);
  1516 		NetworkServer_HandleChat((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf, NETWORK_SERVER_INDEX);
  1494 	}
  1517 	}
  1692 		break;
  1715 		break;
  1693 	}
  1716 	}
  1694 }
  1717 }
  1695 
  1718 
  1696 static const Widget _chat_window_widgets[] = {
  1719 static const Widget _chat_window_widgets[] = {
  1697 {   WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,  0, 13, STR_00C5,         STR_018B_CLOSE_WINDOW},
  1720 {   WWT_CLOSEBOX, RESIZE_NONE,  14,   0,  10,  0, 13, STR_00C5,         STR_018B_CLOSE_WINDOW},
  1698 {      WWT_PANEL, RESIZE_NONE, 14,  11, 639,  0, 13, 0x0,              STR_NULL}, // background
  1721 {      WWT_PANEL, RESIZE_RIGHT, 14,  11, 319,  0, 13, 0x0,              STR_NULL}, // background
  1699 {      WWT_PANEL, RESIZE_NONE, 14,  75, 577,  1, 12, 0x0,              STR_NULL}, // text box
  1722 {      WWT_PANEL, RESIZE_RIGHT, 14,  75, 257,  1, 12, 0x0,              STR_NULL}, // text box
  1700 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 578, 639,  1, 12, STR_NETWORK_SEND, STR_NULL}, // send button
  1723 { WWT_PUSHTXTBTN, RESIZE_LR,    14, 258, 319,  1, 12, STR_NETWORK_SEND, STR_NULL}, // send button
  1701 {   WIDGETS_END},
  1724 {   WIDGETS_END},
  1702 };
  1725 };
  1703 
  1726 
  1704 static const WindowDesc _chat_window_desc = {
  1727 static const WindowDesc _chat_window_desc = {
  1705 	WDP_CENTER, -26, 640, 14, // x, y, width, height
  1728 	WDP_CENTER, -26, 320, 14, 640, 14, // x, y, width, height
  1706 	WC_SEND_NETWORK_MSG, WC_NONE,
  1729 	WC_SEND_NETWORK_MSG, WC_NONE,
  1707 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
  1730 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
  1708 	_chat_window_widgets,
  1731 	_chat_window_widgets,
  1709 	ChatWindowWndProc
  1732 	ChatWindowWndProc
  1710 };
  1733 };