1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-19 04:29:09 +00:00

Add: Identify cities on the main viewport by appending an icon to their names (#14504)

Co-authored-by: Peter Nelson <peter1138@openttd.org>
This commit is contained in:
Su
2025-08-15 21:49:25 +01:00
committed by GitHub
parent 3d806d6a65
commit 85af200788
10 changed files with 36 additions and 6 deletions

Binary file not shown.

View File

@@ -1 +1 @@
a4a727b03a7cd07ee0499231f7f233f4 eb8390a0569e66ec417c64ad254f9d05

View File

@@ -844,3 +844,9 @@
// U+E29D: Small left arrow // U+E29D: Small left arrow
-1 * 6 12 01 01 01 9D E2 -1 * 6 12 01 01 01 9D E2
-1 sprites/chars.png 8bpp 10 430 5 5 0 1 normal -1 sprites/chars.png 8bpp 10 430 5 5 0 1 normal
// U+E29B: Town
// U+E29C: City
-1 * 6 12 01 00 02 9B E2
-1 sprites/chars.png 8bpp 20 430 10 10 0 0 normal
-1 sprites/chars.png 8bpp 40 430 10 10 0 0 normal

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -5875,6 +5875,8 @@ STR_SAVEGAME_NAME_SPECTATOR :Spectator, {1:S
# Viewport strings # Viewport strings
STR_VIEWPORT_TOWN_POP :{TOWN} ({COMMA}) STR_VIEWPORT_TOWN_POP :{TOWN} ({COMMA})
STR_VIEWPORT_TOWN_CITY :{TOWN} {CITY_ICON}
STR_VIEWPORT_TOWN_CITY_POP :{TOWN} ({COMMA}) {CITY_ICON}
STR_VIEWPORT_STATION :{STATION} {STATION_FEATURES} STR_VIEWPORT_STATION :{STATION} {STATION_FEATURES}
# Simple strings to get specific types of data # Simple strings to get specific types of data

View File

@@ -437,6 +437,8 @@ std::string TranslateTTDPatchCodes(uint32_t grfid, uint8_t language_id, bool all
break; break;
} }
case 0x9B: builder.PutUtf8(SCC_TOWN); break;
case 0x9C: builder.PutUtf8(SCC_CITY); break;
case 0x9E: builder.PutUtf8(0x20AC); break; // Euro case 0x9E: builder.PutUtf8(0x20AC); break; // Euro
case 0x9F: builder.PutUtf8(0x0178); break; // Y with diaeresis case 0x9F: builder.PutUtf8(0x0178); break; // Y with diaeresis
case 0xA0: builder.PutUtf8(SCC_UP_ARROW); break; case 0xA0: builder.PutUtf8(SCC_UP_ARROW); break;

View File

@@ -171,6 +171,8 @@ enum StringControlCode : uint16_t {
* These are mapped to the original glyphs */ * These are mapped to the original glyphs */
SCC_LESS_THAN = SCC_SPRITE_START + 0x3C, SCC_LESS_THAN = SCC_SPRITE_START + 0x3C,
SCC_GREATER_THAN = SCC_SPRITE_START + 0x3E, SCC_GREATER_THAN = SCC_SPRITE_START + 0x3E,
SCC_TOWN = SCC_SPRITE_START + 0x9B,
SCC_CITY = SCC_SPRITE_START + 0x9C,
SCC_LEFT_ARROW = SCC_SPRITE_START + 0x9D, SCC_LEFT_ARROW = SCC_SPRITE_START + 0x9D,
SCC_UP_ARROW = SCC_SPRITE_START + 0xA0, SCC_UP_ARROW = SCC_SPRITE_START + 0xA0,
SCC_DOWN_ARROW = SCC_SPRITE_START + 0xAA, SCC_DOWN_ARROW = SCC_SPRITE_START + 0xAA,

View File

@@ -146,6 +146,8 @@ static const CmdStruct _cmd_structs[] = {
{"RIGHT_ARROW", EmitSingleChar, SCC_RIGHT_ARROW, 0, std::nullopt, {CmdFlag::DontCount}}, {"RIGHT_ARROW", EmitSingleChar, SCC_RIGHT_ARROW, 0, std::nullopt, {CmdFlag::DontCount}},
{"SMALL_LEFT_ARROW", EmitSingleChar, SCC_LESS_THAN, 0, std::nullopt, {CmdFlag::DontCount}}, {"SMALL_LEFT_ARROW", EmitSingleChar, SCC_LESS_THAN, 0, std::nullopt, {CmdFlag::DontCount}},
{"SMALL_RIGHT_ARROW", EmitSingleChar, SCC_GREATER_THAN, 0, std::nullopt, {CmdFlag::DontCount}}, {"SMALL_RIGHT_ARROW", EmitSingleChar, SCC_GREATER_THAN, 0, std::nullopt, {CmdFlag::DontCount}},
{"TOWN_ICON", EmitSingleChar, SCC_TOWN, 0, std::nullopt, {CmdFlag::DontCount}},
{"CITY_ICON", EmitSingleChar, SCC_CITY, 0, std::nullopt, {CmdFlag::DontCount}},
/* The following are directional formatting codes used to get the RTL strings right: /* The following are directional formatting codes used to get the RTL strings right:
* http://www.unicode.org/unicode/reports/tr9/#Directional_Formatting_Codes */ * http://www.unicode.org/unicode/reports/tr9/#Directional_Formatting_Codes */

View File

@@ -398,10 +398,17 @@ void Town::UpdateVirtCoord()
if (this->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(this->index)); if (this->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(this->index));
std::string town_string = GetString(STR_TOWN_NAME, this->index); std::string town_string;
if (this->larger_town) {
town_string = GetString(_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_CITY_POP : STR_VIEWPORT_TOWN_CITY, this->index, this->cache.population);
} else {
town_string = GetString(_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_TOWN_NAME, this->index, this->cache.population);
}
this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_BASE, this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_BASE,
_settings_client.gui.population_in_label ? GetString(STR_VIEWPORT_TOWN_POP, this->index, this->cache.population) : town_string, town_string,
town_string); GetString(STR_TOWN_NAME, this->index, this->cache.population)
);
_viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeTown(this->index)); _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeTown(this->index));

View File

@@ -1359,12 +1359,21 @@ static void ViewportAddTownStrings(DrawPixelInfo *dpi, const std::vector<const T
ViewportStringFlags flags{}; ViewportStringFlags flags{};
if (small) flags.Set({ViewportStringFlag::Small, ViewportStringFlag::Shadow}); if (small) flags.Set({ViewportStringFlag::Small, ViewportStringFlag::Shadow});
StringID stringid = !small && _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_TOWN_NAME; StringID stringid_town = !small && _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_TOWN_NAME;
StringID stringid_town_city = stringid_town;
if (!small) {
stringid_town_city = _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_CITY_POP : STR_VIEWPORT_TOWN_CITY;
}
for (const Town *t : towns) { for (const Town *t : towns) {
std::string *str = ViewportAddString(dpi, &t->cache.sign, flags, INVALID_COLOUR); std::string *str = ViewportAddString(dpi, &t->cache.sign, flags, INVALID_COLOUR);
if (str == nullptr) continue; if (str == nullptr) continue;
*str = GetString(stringid, t->index, t->cache.population); if (t->larger_town) {
*str = GetString(stringid_town_city, t->index, t->cache.population);
} else {
*str = GetString(stringid_town, t->index, t->cache.population);
}
} }
} }