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

Function ViewportAddTownStrings

src/viewport.cpp:1372–1393  ·  view source on GitHub ↗

* Add town strings to a viewport. * @param dpi Current viewport area. * @param towns List of towns to add. * @param small Add small versions of strings. */

Source from the content-addressed store, hash-verified

1370 * @param small Add small versions of strings.
1371 */
1372static void ViewportAddTownStrings(DrawPixelInfo *dpi, const std::vector<const Town *> &towns, bool small)
1373{
1374 ViewportStringFlags flags{};
1375 if (small) flags.Set({ViewportStringFlag::Small, ViewportStringFlag::Shadow});
1376
1377 StringID stringid_town = !small && _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_TOWN_NAME;
1378 StringID stringid_town_city = stringid_town;
1379 if (!small) {
1380 stringid_town_city = _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_CITY_POP : STR_VIEWPORT_TOWN_CITY;
1381 }
1382
1383 for (const Town *t : towns) {
1384 std::string *str = ViewportAddString(dpi, &t->cache.sign, flags, INVALID_COLOUR);
1385 if (str == nullptr) continue;
1386
1387 if (t->larger_town) {
1388 *str = GetString(stringid_town_city, t->index, t->cache.population);
1389 } else {
1390 *str = GetString(stringid_town, t->index, t->cache.population);
1391 }
1392 }
1393}
1394
1395/**
1396 * Add sign strings to a viewport.

Callers 1

ViewportAddKdtreeSignsFunction · 0.85

Calls 3

ViewportAddStringFunction · 0.85
GetStringFunction · 0.70
SetMethod · 0.45

Tested by

no test coverage detected