Resize the sign (label) of the town after it changes population. */
| 396 | |
| 397 | /** Resize the sign (label) of the town after it changes population. */ |
| 398 | void Town::UpdateVirtCoord() |
| 399 | { |
| 400 | Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE); |
| 401 | |
| 402 | if (this->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(this->index)); |
| 403 | |
| 404 | std::string town_string; |
| 405 | if (this->larger_town) { |
| 406 | town_string = GetString(_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_CITY_POP : STR_VIEWPORT_TOWN_CITY, this->index, this->cache.population); |
| 407 | } else { |
| 408 | town_string = GetString(_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_TOWN_NAME, this->index, this->cache.population); |
| 409 | } |
| 410 | |
| 411 | this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_BASE, |
| 412 | town_string, |
| 413 | GetString(STR_TOWN_NAME, this->index, this->cache.population) |
| 414 | ); |
| 415 | |
| 416 | _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeTown(this->index)); |
| 417 | |
| 418 | SetWindowDirty(WC_TOWN_VIEW, this->index); |
| 419 | } |
| 420 | |
| 421 | /** Update the virtual coords needed to draw the town sign for all towns. */ |
| 422 | void UpdateAllTownVirtCoords() |
no test coverage detected