summaryrefslogtreecommitdiff
path: root/src/town_gui.cpp
diff options
context:
space:
mode:
authorAlberth289346 <alberth289346@gmail.com>2018-06-23 14:02:50 +0200
committerMichael Lutz <michi@icosahedron.de>2018-06-23 14:02:50 +0200
commit11ba094582ae3eb8ed20f2f47938e18a827d6163 (patch)
tree00b803dc84d55a17e2102074cbac7d6f2ab4e812 /src/town_gui.cpp
parent1a5a95aa49bd191901301f9241a21c02a0579c00 (diff)
downloadopenttd-11ba094582ae3eb8ed20f2f47938e18a827d6163.tar.xz
Feature #4186: Append '(City)' behind cities in the town directory (sbr)
Diffstat (limited to 'src/town_gui.cpp')
-rw-r--r--src/town_gui.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 16de241c6..17449854d 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -747,6 +747,16 @@ public:
}
}
+ /**
+ * Get the string to draw the town name.
+ * @param t Town to draw.
+ * @return The string to use.
+ */
+ static StringID GetTownString(const Town *t)
+ {
+ return t->larger_town ? STR_TOWN_DIRECTORY_CITY : STR_TOWN_DIRECTORY_TOWN;
+ }
+
virtual void DrawWidget(const Rect &r, int widget) const
{
switch (widget) {
@@ -785,7 +795,7 @@ public:
SetDParam(0, t->index);
SetDParam(1, t->cache.population);
- DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, STR_TOWN_DIRECTORY_TOWN);
+ DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, GetTownString(t));
y += this->resize.step_height;
if (++n == this->vscroll->GetCapacity()) break; // max number of towns in 1 window
@@ -824,7 +834,7 @@ public:
SetDParam(0, t->index);
SetDParamMaxDigits(1, 8);
- d = maxdim(d, GetStringBoundingBox(STR_TOWN_DIRECTORY_TOWN));
+ d = maxdim(d, GetStringBoundingBox(GetTownString(t)));
}
Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
d.width += icon_size.width + 2;