summaryrefslogtreecommitdiff
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
parent8b65e041ebd4104bba8b21fc0f9a2b8ff99c3414 (diff)
downloadopenttd-a2b2bc36205868f836fb2599c401cdfd4dfa7c1e.tar.xz
(svn r24141) -Feature: Display rating in the town directory window. (Inspired by patch from MagicBuzz)
-rw-r--r--bin/baseset/openttd.grfbin823799 -> 824029 bytes
-rw-r--r--bin/baseset/orig_dos.obg2
-rw-r--r--bin/baseset/orig_dos_de.obg2
-rw-r--r--bin/baseset/orig_win.obg2
-rw-r--r--media/extra_grf/openttdgui.nfo6
-rw-r--r--media/extra_grf/openttdgui.pngbin25022 -> 25977 bytes
-rw-r--r--src/table/sprites.h7
-rw-r--r--src/town_gui.cpp23
8 files changed, 35 insertions, 7 deletions
diff --git a/bin/baseset/openttd.grf b/bin/baseset/openttd.grf
index 0bb0e510f..4e536fe39 100644
--- a/bin/baseset/openttd.grf
+++ b/bin/baseset/openttd.grf
Binary files differ
diff --git a/bin/baseset/orig_dos.obg b/bin/baseset/orig_dos.obg
index 37367e18c..cae703171 100644
--- a/bin/baseset/orig_dos.obg
+++ b/bin/baseset/orig_dos.obg
@@ -55,7 +55,7 @@ TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
TRGC.GRF = ed446637e034104c5559b32c18afe78d
TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6
-OPENTTD.GRF = c36f871b2bdf6dc964101541d2ede4aa
+OPENTTD.GRF = 8be64b2a9d1904b0402d65e991dc4ae4
[origin]
default = You can find it on your Transport Tycoon Deluxe CD-ROM.
diff --git a/bin/baseset/orig_dos_de.obg b/bin/baseset/orig_dos_de.obg
index 4836f9df9..2c95953a5 100644
--- a/bin/baseset/orig_dos_de.obg
+++ b/bin/baseset/orig_dos_de.obg
@@ -55,7 +55,7 @@ TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
TRGC.GRF = ed446637e034104c5559b32c18afe78d
TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
TRGT.GRF = fcde1d7e8a74197d72a62695884b909e
-OPENTTD.GRF = c36f871b2bdf6dc964101541d2ede4aa
+OPENTTD.GRF = 8be64b2a9d1904b0402d65e991dc4ae4
[origin]
default = You can find it on your Transport Tycoon Deluxe CD-ROM.
diff --git a/bin/baseset/orig_win.obg b/bin/baseset/orig_win.obg
index c0f4786cc..e4b735545 100644
--- a/bin/baseset/orig_win.obg
+++ b/bin/baseset/orig_win.obg
@@ -55,7 +55,7 @@ TRGIR.GRF = 0c2484ff6be49fc63a83be6ab5c38f32
TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b
TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1
TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8
-OPENTTD.GRF = c36f871b2bdf6dc964101541d2ede4aa
+OPENTTD.GRF = 8be64b2a9d1904b0402d65e991dc4ae4
[origin]
default = You can find it on your Transport Tycoon Deluxe CD-ROM.
diff --git a/media/extra_grf/openttdgui.nfo b/media/extra_grf/openttdgui.nfo
index c0127a975..064e772f1 100644
--- a/media/extra_grf/openttdgui.nfo
+++ b/media/extra_grf/openttdgui.nfo
@@ -7,7 +7,7 @@
// See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
//
-1 * 0 0C "OpenTTD GUI graphics"
- -1 * 3 05 15 A2
+ -1 * 3 05 15 A6
-1 sprites/openttdgui.png 8bpp 66 8 64 31 -31 7 normal
-1 sprites/openttdgui.png 8bpp 146 8 64 31 -31 7 normal
-1 sprites/openttdgui.png 8bpp 226 8 64 31 -31 7 normal
@@ -170,3 +170,7 @@
-1 sprites/openttdgui.png 8bpp 194 440 13 10 0 -2 normal
-1 sprites/openttdgui.png 8bpp 215 440 9 10 0 0 normal
-1 sprites/openttdgui.png 8bpp 232 440 8 10 0 0 normal
+ -1 sprites/openttdgui.png 8bpp 248 440 8 8 0 0 normal
+ -1 sprites/openttdgui.png 8bpp 264 440 8 8 0 0 normal
+ -1 sprites/openttdgui.png 8bpp 280 440 8 8 0 0 normal
+ -1 sprites/openttdgui.png 8bpp 296 440 8 8 0 0 normal
diff --git a/media/extra_grf/openttdgui.png b/media/extra_grf/openttdgui.png
index 702d700fe..3211258e1 100644
--- a/media/extra_grf/openttdgui.png
+++ b/media/extra_grf/openttdgui.png
Binary files differ
diff --git a/src/table/sprites.h b/src/table/sprites.h
index 8320e2c52..db78222b2 100644
--- a/src/table/sprites.h
+++ b/src/table/sprites.h
@@ -56,7 +56,7 @@ static const SpriteID SPR_LARGE_SMALL_WINDOW = 682;
/** Extra graphic spritenumbers */
static const SpriteID SPR_OPENTTD_BASE = 4896;
-static const uint16 OPENTTD_SPRITE_COUNT = 162;
+static const uint16 OPENTTD_SPRITE_COUNT = 166;
/* Halftile-selection sprites */
static const SpriteID SPR_HALFTILE_SELECTION_FLAT = SPR_OPENTTD_BASE;
@@ -147,6 +147,11 @@ static const SpriteID SPR_GROUP_REPLACE_OFF_ROADVEH = SPR_OPENTTD_BASE + 131;
static const SpriteID SPR_GROUP_REPLACE_OFF_SHIP = SPR_OPENTTD_BASE + 132;
static const SpriteID SPR_GROUP_REPLACE_OFF_AIRCRAFT = SPR_OPENTTD_BASE + 133;
+static const SpriteID SPR_TOWN_RATING_NA = SPR_OPENTTD_BASE + 162;
+static const SpriteID SPR_TOWN_RATING_APALLING = SPR_OPENTTD_BASE + 163;
+static const SpriteID SPR_TOWN_RATING_MEDIOCRE = SPR_OPENTTD_BASE + 164;
+static const SpriteID SPR_TOWN_RATING_GOOD = SPR_OPENTTD_BASE + 165;
+
static const SpriteID SPR_IMG_SWITCH_TOOLBAR = SPR_OPENTTD_BASE + 144;
static const SpriteID SPR_SIGNALS_BASE = SPR_OPENTTD_BASE + OPENTTD_SPRITE_COUNT;
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;