summaryrefslogtreecommitdiff
path: root/src/aircraft_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
commit0c8078ae29c2ac5f03d295aebf273150224cb55e (patch)
tree59906a996e65dbe3ecf41015b0f876d77b68498a /src/aircraft_cmd.cpp
parent356e47f1087b56244694a646eb73ee6c9264a229 (diff)
downloadopenttd-0c8078ae29c2ac5f03d295aebf273150224cb55e.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/aircraft_cmd.cpp')
-rw-r--r--src/aircraft_cmd.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 1d31c55c2..f3d990eaa 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -26,6 +26,7 @@
#include "newgrf_text.h"
#include "newgrf_sound.h"
#include "date.h"
+#include "spritecache.h"
// this maps the terminal to its corresponding state and block flag
// currently set for 10 terms, 4 helipads
@@ -165,6 +166,31 @@ void DrawAircraftEngine(int x, int y, EngineID engine, SpriteID pal)
}
}
+/** Get the size of the sprite of an aircraft 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 GetAircraftSpriteSize(EngineID engine, uint &width, uint &height)
+{
+ const AircraftVehicleInfo* avi = AircraftVehInfo(engine);
+ int spritenum = avi->image_index;
+ SpriteID sprite = (6 + _aircraft_sprite[spritenum]);
+
+ if (is_custom_sprite(spritenum)) {
+ sprite = GetCustomVehicleIcon(engine, DIR_W);
+ if (sprite == 0) {
+ spritenum = orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
+ sprite = (6 + _aircraft_sprite[spritenum]);
+ }
+ }
+
+ const Sprite *spr = GetSprite(sprite);
+
+ width = spr->width ;
+ height = spr->height;
+}
+
static int32 EstimateAircraftCost(const AircraftVehicleInfo *avi)
{
return avi->base_cost * (_price.aircraft_base >> 3) >> 5;