MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawDetails

Method DrawDetails

src/fios_gui.cpp:546–632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544 }
545
546 void DrawDetails(const Rect &r) const
547 {
548 /* Header panel */
549 int HEADER_HEIGHT = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.Vertical();
550
551 Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext);
552 Rect tr = r.Shrink(WidgetDimensions::scaled.frametext);
553 tr.top += HEADER_HEIGHT;
554
555 /* Create the nice lighter rectangle at the details top */
556 GfxFillRect(r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.bevel.left, WidgetDimensions::scaled.bevel.top, WidgetDimensions::scaled.bevel.right, 0), GetColourGradient(COLOUR_GREY, SHADE_LIGHTEST));
557 DrawString(hr.left, hr.right, hr.top, STR_SAVELOAD_DETAIL_CAPTION, TC_FROMSTRING, SA_HOR_CENTER);
558
559 if (this->selected == nullptr) return;
560
561 /* Details panel */
562 tr.bottom -= GetCharacterHeight(FS_NORMAL) - 1;
563 if (tr.top > tr.bottom) return;
564
565 if (!_load_check_data.checkable) {
566 /* Old savegame, no information available */
567 DrawString(tr, STR_SAVELOAD_DETAIL_NOT_AVAILABLE);
568 tr.top += GetCharacterHeight(FS_NORMAL);
569 } else if (_load_check_data.error != INVALID_STRING_ID) {
570 /* Incompatible / broken savegame */
571 tr.top = DrawStringMultiLine(tr, GetString(_load_check_data.error, _load_check_data.error_msg), TC_RED);
572 } else {
573 /* Mapsize */
574 DrawString(tr, GetString(STR_NETWORK_SERVER_LIST_MAP_SIZE, _load_check_data.map_size_x, _load_check_data.map_size_y));
575 tr.top += GetCharacterHeight(FS_NORMAL);
576 if (tr.top > tr.bottom) return;
577
578 /* Climate */
579 if (to_underlying(_load_check_data.landscape) < NUM_LANDSCAPE) {
580 DrawString(tr, GetString(STR_NETWORK_SERVER_LIST_LANDSCAPE, STR_CLIMATE_TEMPERATE_LANDSCAPE + to_underlying(_load_check_data.landscape)));
581 tr.top += GetCharacterHeight(FS_NORMAL);
582 }
583
584 tr.top += WidgetDimensions::scaled.vsep_normal;
585 if (tr.top > tr.bottom) return;
586
587 /* Start date (if available) */
588 if (_load_check_data.starting_year != 0) {
589 DrawString(tr, GetString(STR_NETWORK_SERVER_LIST_START_DATE, TimerGameCalendar::ConvertYMDToDate(_load_check_data.starting_year, 0, 1)));
590 tr.top += GetCharacterHeight(FS_NORMAL);
591 }
592 if (tr.top > tr.bottom) return;
593
594 /* Hide current date for scenarios */
595 if (this->abstract_filetype != FT_SCENARIO) {
596 /* Current date */
597 DrawString(tr, GetString(STR_NETWORK_SERVER_LIST_CURRENT_DATE, _load_check_data.current_date));
598 tr.top += GetCharacterHeight(FS_NORMAL);
599 }
600
601 /* Hide the NewGRF stuff when saving. We also hide the button. */
602 if (this->fop == SLO_LOAD && (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO)) {
603 tr.top += WidgetDimensions::scaled.vsep_normal;

Callers 1

DrawWidgetMethod · 0.95

Calls 11

GetCharacterHeightFunction · 0.85
GetColourGradientFunction · 0.85
to_underlyingFunction · 0.85
VerticalMethod · 0.80
ShrinkMethod · 0.80
WithHeightMethod · 0.80
GfxFillRectFunction · 0.70
DrawStringFunction · 0.70
DrawStringMultiLineFunction · 0.70
GetStringFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected