summaryrefslogtreecommitdiff
path: root/src/ship_cmd.cpp
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2007-02-10 13:37:32 +0000
committerbjarni <bjarni@openttd.org>2007-02-10 13:37:32 +0000
commit89b362a622a0e12eef1b11083a1f9aff0f70030a (patch)
tree59906a996e65dbe3ecf41015b0f876d77b68498a /src/ship_cmd.cpp
parentced80aadaa8041ef731750ee88d8f56645408d9b (diff)
downloadopenttd-89b362a622a0e12eef1b11083a1f9aff0f70030a.tar.xz
(svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
-Codechange: depot windows default now makes a 1x1 matrix and resize the window by block size*number of blocks This will make less vehicle type specific code and easier to read resizing based on sprite sizes
Diffstat (limited to 'src/ship_cmd.cpp')
-rw-r--r--src/ship_cmd.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index e95a660ec..82408ad23 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -27,6 +27,7 @@
#include "newgrf_text.h"
#include "newgrf_sound.h"
#include "date.h"
+#include "spritecache.h"
static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
@@ -59,6 +60,32 @@ void DrawShipEngine(int x, int y, EngineID engine, SpriteID pal)
DrawSprite(6 + _ship_sprites[spritenum], pal, x, y);
}
+/** Get the size of the sprite of a ship sprite heading west (used for lists)
+ * @param engine The engine to get the sprite from
+ * @param &width The width of the sprite
+ * @param &height The height of the sprite
+ */
+void GetShipSpriteSize(EngineID engine, uint &width, uint &height)
+{
+ SpriteID spritenum = ShipVehInfo(engine)->image_index;
+ SpriteID custom_sprite = 0;
+
+ if (is_custom_sprite(spritenum)) {
+ custom_sprite = GetCustomVehicleIcon(engine, DIR_W);
+ spritenum = orig_ship_vehicle_info[engine - SHIP_ENGINES_INDEX].image_index;
+ }
+ if (custom_sprite == 0) {
+ spritenum = 6 + _ship_sprites[spritenum];
+ } else {
+ spritenum = custom_sprite;
+ }
+
+ const Sprite *spr = GetSprite(spritenum);
+
+ width = spr->width;
+ height = spr->height;
+}
+
int GetShipImage(const Vehicle* v, Direction direction)
{
int spritenum = v->spritenum;