summaryrefslogtreecommitdiff
path: root/src/town_gui.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2012-04-17 19:44:41 +0000
committermichi_cc <michi_cc@openttd.org>2012-04-17 19:44:41 +0000
commita2b2bc36205868f836fb2599c401cdfd4dfa7c1e (patch)
treee6d9f2e8c1613a932e4390aaf7b136e92ccb5187 /src/town_gui.cpp
parent8b65e041ebd4104bba8b21fc0f9a2b8ff99c3414 (diff)
downloadopenttd-a2b2bc36205868f836fb2599c401cdfd4dfa7c1e.tar.xz
(svn r24141) -Feature: Display rating in the town directory window. (Inspired by patch from MagicBuzz)
Diffstat (limited to 'src/town_gui.cpp')
-rw-r--r--src/town_gui.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 0f7f4e399..36b74a52b 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -727,15 +727,31 @@ public:
DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y, STR_TOWN_DIRECTORY_NONE);
break;
}
+
/* At least one town available. */
+ bool rtl = _current_text_dir == TD_RTL;
+ Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
+ int text_left = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : icon_size.width + 2);
+ int text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? icon_size.width + 2 : 0);
+ int icon_x = rtl ? r.right - WD_FRAMERECT_RIGHT - icon_size.width : r.left + WD_FRAMERECT_LEFT;
+
for (uint i = this->vscroll->GetPosition(); i < this->towns.Length(); i++) {
const Town *t = this->towns[i];
-
assert(t->xy != INVALID_TILE);
+ /* Draw rating icon. */
+ if (_game_mode == GM_EDITOR || !HasBit(t->have_ratings, _local_company)) {
+ DrawSprite(SPR_TOWN_RATING_NA, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
+ } else {
+ SpriteID icon = SPR_TOWN_RATING_APALLING;
+ if (t->ratings[_local_company] > RATING_VERYPOOR) icon = SPR_TOWN_RATING_MEDIOCRE;
+ if (t->ratings[_local_company] > RATING_GOOD) icon = SPR_TOWN_RATING_GOOD;
+ DrawSprite(icon, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
+ }
+
SetDParam(0, t->index);
SetDParam(1, t->population);
- DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TOWN_DIRECTORY_TOWN);
+ DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, STR_TOWN_DIRECTORY_TOWN);
y += this->resize.step_height;
if (++n == this->vscroll->GetCapacity()) break; // max number of towns in 1 window
@@ -767,6 +783,9 @@ public:
SetDParam(1, 10000000); // 10^7
d = maxdim(d, GetStringBoundingBox(STR_TOWN_DIRECTORY_TOWN));
}
+ Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
+ d.width += icon_size.width + 2;
+ d.height = max(d.height, icon_size.height);
resize->height = d.height;
d.height *= 5;
d.width += padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;