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

Method GetDesiredInfoHeight

src/town_gui.cpp:534–559  ·  view source on GitHub ↗

* Gets the desired height for the information panel. * @return the desired height in pixels. */

Source from the content-addressed store, hash-verified

532 * @return the desired height in pixels.
533 */
534 uint GetDesiredInfoHeight(int width) const
535 {
536 uint aimed_height = static_cast<uint>(1 + CargoSpec::town_production_cargoes[TPE_PASSENGERS].size() + CargoSpec::town_production_cargoes[TPE_MAIL].size()) * GetCharacterHeight(FS_NORMAL);
537
538 bool first = true;
539 for (int i = TAE_BEGIN; i < TAE_END; i++) {
540 if (this->town->goal[i] == 0) continue;
541 if (this->town->goal[i] == TOWN_GROWTH_WINTER && (TileHeight(this->town->xy) < LowestSnowLine() || this->town->cache.population <= 90)) continue;
542 if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue;
543
544 if (first) {
545 aimed_height += GetCharacterHeight(FS_NORMAL);
546 first = false;
547 }
548 aimed_height += GetCharacterHeight(FS_NORMAL);
549 }
550 aimed_height += GetCharacterHeight(FS_NORMAL);
551
552 if (_settings_game.economy.station_noise_level) aimed_height += GetCharacterHeight(FS_NORMAL);
553
554 if (!this->town->text.empty()) {
555 aimed_height += GetStringHeight(this->town->text.GetDecodedString(), width - WidgetDimensions::scaled.framerect.Horizontal());
556 }
557
558 return aimed_height;
559 }
560
561 void ResizeWindowAsNeeded()
562 {

Callers

nothing calls this directly

Calls 9

GetCharacterHeightFunction · 0.85
TileHeightFunction · 0.85
LowestSnowLineFunction · 0.85
GetTropicZoneFunction · 0.85
GetStringHeightFunction · 0.85
GetDecodedStringMethod · 0.80
HorizontalMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected