| 389 | } |
| 390 | |
| 391 | void DrawWidget(const Rect &r, WidgetID widget) const override |
| 392 | { |
| 393 | if (widget != WID_TV_INFO) return; |
| 394 | |
| 395 | Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); |
| 396 | |
| 397 | DrawString(tr, GetString(STR_TOWN_VIEW_POPULATION_HOUSES, this->town->cache.population, this->town->cache.num_houses)); |
| 398 | tr.top += GetCharacterHeight(FS_NORMAL); |
| 399 | |
| 400 | StringID str_last_period = TimerGameEconomy::UsingWallclockUnits() ? STR_TOWN_VIEW_CARGO_LAST_MINUTE_MAX : STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX; |
| 401 | |
| 402 | for (auto tpe : {TPE_PASSENGERS, TPE_MAIL}) { |
| 403 | for (const CargoSpec *cs : CargoSpec::town_production_cargoes[tpe]) { |
| 404 | CargoType cargo_type = cs->Index(); |
| 405 | auto it = this->town->GetCargoSupplied(cargo_type); |
| 406 | if (it == std::end(this->town->supplied)) { |
| 407 | DrawString(tr, GetString(str_last_period, 1ULL << cargo_type, 0, 0)); |
| 408 | } else { |
| 409 | DrawString(tr, GetString(str_last_period, 1ULL << cargo_type, it->history[LAST_MONTH].transported, it->history[LAST_MONTH].production)); |
| 410 | } |
| 411 | tr.top += GetCharacterHeight(FS_NORMAL); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | bool first = true; |
| 416 | for (int i = TAE_BEGIN; i < TAE_END; i++) { |
| 417 | if (this->town->goal[i] == 0) continue; |
| 418 | if (this->town->goal[i] == TOWN_GROWTH_WINTER && (TileHeight(this->town->xy) < LowestSnowLine() || this->town->cache.population <= 90)) continue; |
| 419 | if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue; |
| 420 | |
| 421 | if (first) { |
| 422 | DrawString(tr, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH); |
| 423 | tr.top += GetCharacterHeight(FS_NORMAL); |
| 424 | first = false; |
| 425 | } |
| 426 | |
| 427 | bool rtl = _current_text_dir == TD_RTL; |
| 428 | |
| 429 | const CargoSpec *cargo = FindFirstCargoWithTownAcceptanceEffect((TownAcceptanceEffect)i); |
| 430 | assert(cargo != nullptr); |
| 431 | |
| 432 | StringID string; |
| 433 | |
| 434 | if (this->town->goal[i] == TOWN_GROWTH_DESERT || this->town->goal[i] == TOWN_GROWTH_WINTER) { |
| 435 | /* For 'original' gameplay, don't show the amount required (you need 1 or more ..) */ |
| 436 | string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL; |
| 437 | if (this->town->received[i].old_act == 0) { |
| 438 | string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_GENERAL; |
| 439 | |
| 440 | if (this->town->goal[i] == TOWN_GROWTH_WINTER && TileHeight(this->town->xy) < GetSnowLine()) { |
| 441 | string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER; |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | DrawString(tr.Indent(20, rtl), GetString(string, cargo->name)); |
| 446 | } else { |
| 447 | string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED; |
| 448 | if (this->town->received[i].old_act < this->town->goal[i]) { |
nothing calls this directly
no test coverage detected