From 89b362a622a0e12eef1b11083a1f9aff0f70030a Mon Sep 17 00:00:00 2001 From: bjarni Date: Sat, 10 Feb 2007 13:37:32 +0000 Subject: (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 --- src/ship_cmd.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/ship_cmd.cpp') 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; -- cgit v1.2.3-70-g09d2