| 609 | } |
| 610 | |
| 611 | void DrawDetails(const Rect &r) const |
| 612 | { |
| 613 | NetworkGame *sel = this->server; |
| 614 | |
| 615 | Rect tr = r.Shrink(WidgetDimensions::scaled.frametext); |
| 616 | StringID header_msg = this->GetHeaderString(); |
| 617 | int header_height = GetStringHeight(header_msg, tr.Width()) + |
| 618 | (sel == nullptr ? 0 : GetStringHeight(sel->info.server_name, tr.Width())) + |
| 619 | WidgetDimensions::scaled.frametext.Vertical(); |
| 620 | |
| 621 | /* Height for the title banner */ |
| 622 | Rect hr = r.WithHeight(header_height).Shrink(WidgetDimensions::scaled.frametext); |
| 623 | tr.top += header_height; |
| 624 | |
| 625 | /* Draw the right menu */ |
| 626 | /* Create the nice darker rectangle at the details top */ |
| 627 | GfxFillRect(r.WithHeight(header_height).Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(COLOUR_LIGHT_BLUE, SHADE_NORMAL)); |
| 628 | hr.top = DrawStringMultiLine(hr, header_msg, TC_FROMSTRING, SA_HOR_CENTER); |
| 629 | if (sel == nullptr) return; |
| 630 | |
| 631 | hr.top = DrawStringMultiLine(hr, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name |
| 632 | if (sel->status != NGLS_ONLINE) { |
| 633 | tr.top = DrawStringMultiLine(tr, header_msg, TC_FROMSTRING, SA_HOR_CENTER); |
| 634 | } else { // show game info |
| 635 | tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_CLIENTS, sel->info.clients_on, sel->info.clients_max, sel->info.companies_on, sel->info.companies_max)); |
| 636 | |
| 637 | tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_LANDSCAPE, STR_CLIMATE_TEMPERATE_LANDSCAPE + to_underlying(sel->info.landscape))); // landscape |
| 638 | |
| 639 | tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_MAP_SIZE, sel->info.map_width, sel->info.map_height)); // map size |
| 640 | |
| 641 | tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_SERVER_VERSION, sel->info.server_revision)); // server version |
| 642 | |
| 643 | StringID invite_or_address = sel->connection_string.starts_with("+") ? STR_NETWORK_SERVER_LIST_INVITE_CODE : STR_NETWORK_SERVER_LIST_SERVER_ADDRESS; |
| 644 | tr.top = DrawStringMultiLine(tr, GetString(invite_or_address, sel->connection_string)); // server address / invite code |
| 645 | |
| 646 | tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_START_DATE, sel->info.calendar_start)); // start date |
| 647 | |
| 648 | tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_CURRENT_DATE, sel->info.calendar_date)); // current date |
| 649 | |
| 650 | const auto play_time = sel->info.ticks_playing / Ticks::TICKS_PER_SECOND; |
| 651 | tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_PLAY_TIME, play_time / 60 / 60, (play_time / 60) % 60)); // play time |
| 652 | |
| 653 | if (sel->info.gamescript_version != -1) { |
| 654 | tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_GAMESCRIPT, sel->info.gamescript_name, sel->info.gamescript_version)); // gamescript name and version |
| 655 | } |
| 656 | |
| 657 | tr.top += WidgetDimensions::scaled.vsep_wide; |
| 658 | |
| 659 | if (!sel->info.compatible) { |
| 660 | DrawStringMultiLine(tr, sel->info.version_compatible ? STR_NETWORK_SERVER_LIST_GRF_MISMATCH : STR_NETWORK_SERVER_LIST_VERSION_MISMATCH, TC_FROMSTRING, SA_HOR_CENTER); // server mismatch |
| 661 | } else if (sel->info.clients_on == sel->info.clients_max) { |
| 662 | /* Show: server full, when clients_on == max_clients */ |
| 663 | DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_SERVER_FULL, TC_FROMSTRING, SA_HOR_CENTER); // server full |
| 664 | } else if (sel->info.use_password) { |
| 665 | DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_PASSWORD, TC_FROMSTRING, SA_HOR_CENTER); // password warning |
| 666 | } |
| 667 | } |
| 668 | } |
no test coverage detected