static void window_player_list_refresh_list(rct_window *w) { w->no_list_items = network_get_num_players(); w->list_item_positions[0] = 0; w->selected_list_item = -1; window_invalidate(w); }
static void window_multiplayer_players_resize(rct_window *w) { window_set_resize(w, 420, 124, 500, 450); w->no_list_items = network_get_num_players(); w->list_item_positions[0] = 0; w->selected_list_item = -1; window_invalidate(w); }
static void window_player_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex) { int y; gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ColourMapA[w->colours[1]].mid_light); y = 0; for (int i = 0; i < network_get_num_players(); i++) { if (y > dpi->y + dpi->height) { break; } if (y + 11 >= dpi->y) { char buffer[300]; char* lineCh = buffer; int colour = 0; if (i == w->selected_list_item) { gfx_fill_rect(dpi, 0, y, 800, y + 9, 0x02000031); safe_strncpy(&buffer[0], network_get_player_name(i), sizeof(buffer)); colour = w->colours[2]; } else { if (network_get_player_flags(i) & NETWORK_PLAYER_FLAG_ISSERVER) { lineCh = utf8_write_codepoint(lineCh, FORMAT_BABYBLUE); } else { lineCh = utf8_write_codepoint(lineCh, FORMAT_BLACK); } safe_strncpy(lineCh, network_get_player_name(i), sizeof(buffer) - (lineCh - buffer)); } gfx_clip_string(buffer, 230); gfx_draw_string(dpi, buffer, colour, 0, y - 1); lineCh = buffer; int ping = network_get_player_ping(i); if (ping <= 100) { lineCh = utf8_write_codepoint(lineCh, FORMAT_GREEN); } else if (ping <= 250) { lineCh = utf8_write_codepoint(lineCh, FORMAT_YELLOW); } else { lineCh = utf8_write_codepoint(lineCh, FORMAT_RED); } sprintf(lineCh, "%d ms", ping); gfx_draw_string(dpi, buffer, colour, 240, y - 1); } y += 10; } }
static void window_multiplayer_players_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height) { sint32 i; if (w->selected_list_item != -1) { w->selected_list_item = -1; window_invalidate(w); } *height = network_get_num_players() * 10; i = *height - window_multiplayer_players_widgets[WIDX_LIST].bottom + window_multiplayer_players_widgets[WIDX_LIST].top + 21; if (i < 0) i = 0; if (i < w->scrolls[0].v_top) { w->scrolls[0].v_top = i; window_invalidate(w); } }
static void window_multiplayer_players_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex) { sint32 y; y = 0; for (sint32 i = 0; i < network_get_num_players(); i++) { if (y > dpi->y + dpi->height) { break; } if (y + 11 >= dpi->y) { char buffer[300]; // Draw player name char* lineCh = buffer; sint32 colour = COLOUR_BLACK; if (i == w->selected_list_item) { gfx_filter_rect(dpi, 0, y, 800, y + 9, PALETTE_DARKEN_1); safe_strcpy(buffer, network_get_player_name(i), sizeof(buffer)); colour = w->colours[2]; } else { if (network_get_player_flags(i) & NETWORK_PLAYER_FLAG_ISSERVER) { lineCh = utf8_write_codepoint(lineCh, FORMAT_BABYBLUE); } else { lineCh = utf8_write_codepoint(lineCh, FORMAT_BLACK); } safe_strcpy(lineCh, network_get_player_name(i), sizeof(buffer) - (lineCh - buffer)); } gfx_clip_string(buffer, 230); gfx_draw_string(dpi, buffer, colour, 0, y - 1); // Draw group name lineCh = buffer; sint32 group = network_get_group_index(network_get_player_group(i)); if (group != -1) { lineCh = utf8_write_codepoint(lineCh, FORMAT_BLACK); safe_strcpy(lineCh, network_get_group_name(group), sizeof(buffer) - (lineCh - buffer)); gfx_clip_string(buffer, 80); gfx_draw_string(dpi, buffer, colour, 173, y - 1); } // Draw last action sint32 action = network_get_player_last_action(i, 2000); set_format_arg(0, rct_string_id, STR_ACTION_NA); if (action != -999) { set_format_arg(0, rct_string_id, network_get_action_name_string_id(action)); } gfx_draw_string_left_clipped(dpi, STR_BLACK_STRING, gCommonFormatArgs, COLOUR_BLACK, 256, y - 1, 100); // Draw ping lineCh = buffer; sint32 ping = network_get_player_ping(i); if (ping <= 100) { lineCh = utf8_write_codepoint(lineCh, FORMAT_GREEN); } else if (ping <= 250) { lineCh = utf8_write_codepoint(lineCh, FORMAT_YELLOW); } else { lineCh = utf8_write_codepoint(lineCh, FORMAT_RED); } snprintf(lineCh, sizeof(buffer) - (lineCh - buffer), "%d ms", ping); gfx_draw_string(dpi, buffer, colour, 356, y - 1); } y += 10; } }