(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
This commit is contained in:
bjarni
2007-02-10 13:37:32 +00:00
parent 356e47f108
commit 0c8078ae29
7 changed files with 184 additions and 55 deletions

View File

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