(svn r24141) -Feature: Display rating in the town directory window. (Inspired by patch from MagicBuzz)

pull/155/head
michi_cc 12 years ago
parent 08d884bce8
commit 3e5dc26ded

Binary file not shown.

@ -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.

@ -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.

@ -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.

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 25 KiB

@ -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;

@ -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;

Loading…
Cancel
Save