void MultiplayerConfig(TXT_UNCAST_ARG(widget), void *user_data) { txt_window_t *window; txt_label_t *label; txt_table_t *table; char buf[10]; int i; window = TXT_NewWindow("Multiplayer Configuration"); TXT_SetWindowHelpURL(window, MULTI_CONFIG_HELP_URL); TXT_AddWidgets(window, TXT_NewStrut(0, 1), TXT_NewHorizBox(TXT_NewLabel("Player name: "), TXT_NewInputBox(&net_player_name, 25), NULL), TXT_NewStrut(0, 1), TXT_NewSeparator("Chat macros"), NULL); table = TXT_NewTable(2); for (i=0; i<10; ++i) { M_snprintf(buf, sizeof(buf), "#%i ", i + 1); label = TXT_NewLabel(buf); TXT_SetFGColor(label, TXT_COLOR_BRIGHT_CYAN); TXT_AddWidgets(table, label, TXT_NewInputBox(&chat_macros[(i + 1) % 10], 40), NULL); } TXT_AddWidget(window, table); }
void MultiplayerConfig(void) { txt_window_t *window; txt_label_t *label; txt_table_t *table; char buf[10]; int i; window = TXT_NewWindow("Multiplayer Configuration"); TXT_AddWidgets(window, TXT_NewStrut(0, 1), TXT_NewHorizBox(TXT_NewLabel("Player name: "), TXT_NewInputBox(&net_player_name, 25), NULL), TXT_NewStrut(0, 1), TXT_NewSeparator("Chat macros"), NULL); table = TXT_NewTable(2); for (i=0; i<10; ++i) { sprintf(buf, "#%i ", i + 1); label = TXT_NewLabel(buf); TXT_SetFGColor(label, TXT_COLOR_BRIGHT_CYAN); TXT_AddWidgets(table, label, TXT_NewInputBox(&chat_macros[(i + 1) % 10], 40), NULL); } TXT_AddWidget(window, table); }
static void UpdateGUI(void) { txt_window_action_t *startgame; char buf[50]; unsigned int i; // If the value of max_players changes, we must rebuild the // contents of the window. This includes when the first // waiting data packet is received. if (net_client_received_wait_data) { if (net_client_wait_data.max_players != old_max_players) { BuildWindow(); } } else { return; } for (i = 0; i < net_client_wait_data.max_players; ++i) { txt_color_t color = TXT_COLOR_BRIGHT_WHITE; if ((signed) i == net_client_wait_data.consoleplayer) { color = TXT_COLOR_YELLOW; } TXT_SetFGColor(player_labels[i], color); TXT_SetFGColor(ip_labels[i], color); if (i < net_client_wait_data.num_players) { TXT_SetLabel(player_labels[i], net_client_wait_data.player_names[i]); TXT_SetLabel(ip_labels[i], net_client_wait_data.player_addrs[i]); } else { TXT_SetLabel(player_labels[i], ""); TXT_SetLabel(ip_labels[i], ""); } } if (net_client_wait_data.num_drones > 0) { sprintf(buf, " (+%i observer clients)", net_client_wait_data.num_drones); TXT_SetLabel(drone_label, buf); } else { TXT_SetLabel(drone_label, ""); } if (net_client_wait_data.is_controller) { startgame = TXT_NewWindowAction(' ', "Start game"); TXT_SignalConnect(startgame, "pressed", StartGame, NULL); } else { startgame = NULL; } TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, startgame); }