summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-06-22 21:15:27 +0000
committerpeter1138 <peter1138@openttd.org>2006-06-22 21:15:27 +0000
commit3753d0b602cc8bc13db9e4022e6b4b97fbfd161c (patch)
tree4762f0c461eb14f87e356bff742e769215de191f
parent84deeb78476cf8247c14e13c0276925167ee2e45 (diff)
downloadopenttd-3753d0b602cc8bc13db9e4022e6b4b97fbfd161c.tar.xz
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
-rw-r--r--aircraft_cmd.c2
-rw-r--r--aircraft_gui.c6
-rw-r--r--newgrf_engine.c10
-rw-r--r--newgrf_engine.h6
-rw-r--r--newgrf_spritegroup.h2
5 files changed, 18 insertions, 8 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 53502a983..9d3d4a7ec 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -123,7 +123,7 @@ SpriteID GetRotorImage(const Vehicle *v)
w = v->next->next;
if (is_custom_sprite(v->spritenum)) {
- SpriteID spritenum = GetCustomRotorSprite(v);
+ SpriteID spritenum = GetCustomRotorSprite(v, false);
if (spritenum != 0) return spritenum;
}
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 204f5ad48..d4ec54d8f 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -79,7 +79,11 @@ static void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selectio
{
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
DrawSprite(GetAircraftImage(v, DIR_W) | pal, x + 25, y + 10);
- if (v->subtype == 0) DrawSprite(SPR_ROTOR_STOPPED, x + 25, y + 5);
+ if (v->subtype == 0) {
+ SpriteID rotor_sprite = GetCustomRotorSprite(v, true);
+ if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
+ DrawSprite(rotor_sprite, x + 25, y + 5);
+ }
if (v->index == selection) {
DrawFrameRect(x - 1, y - 1, x + 58, y + 21, 0xF, FR_BORDERONLY);
}
diff --git a/newgrf_engine.c b/newgrf_engine.c
index 577d53c34..442614df9 100644
--- a/newgrf_engine.c
+++ b/newgrf_engine.c
@@ -660,7 +660,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x1C: return v->y_pos;
case 0x1D: return v->y_pos & 0xFF;
case 0x1E: return v->z_pos;
- case 0x1F: return v->direction;
+ case 0x1F: return object->info_view ? DIR_W : v->direction;
case 0x28: return v->cur_image;
case 0x29: return v->cur_image & 0xFF;
case 0x32: return v->vehstatus;
@@ -799,6 +799,8 @@ static inline void NewVehicleResolver(ResolverObject *res, const Vehicle *v)
res->u.vehicle.self = v;
res->u.vehicle.parent = (v != NULL && v->type == VEH_Train) ? GetFirstVehicleInChain(v) : v;
+ res->info_view = false;
+
res->callback = 0;
res->callback_param1 = 0;
res->callback_param2 = 0;
@@ -842,7 +844,7 @@ SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction dire
}
-SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle *v)
+SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle *v, bool info_view)
{
const SpriteGroup *group;
ResolverObject object;
@@ -855,6 +857,8 @@ SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle *v)
NewVehicleResolver(&object, v);
+ object.info_view = info_view;
+
group = heli_rotor_custom_sprites[engine - AIRCRAFT_ENGINES_INDEX];
group = Resolve(group, &object);
@@ -862,7 +866,7 @@ SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle *v)
if (v == NULL) return group->g.result.sprite;
- return group->g.result.sprite + (v->next->next->u.air.state % group->g.result.num_sprites);
+ return group->g.result.sprite + (info_view ? 0 : (v->next->next->u.air.state % group->g.result.num_sprites));
}
diff --git a/newgrf_engine.h b/newgrf_engine.h
index af42ff148..1f268118b 100644
--- a/newgrf_engine.h
+++ b/newgrf_engine.h
@@ -22,9 +22,9 @@ void SetWagonOverrideSprites(EngineID engine, const struct SpriteGroup *group, b
void SetCustomEngineSprites(EngineID engine, byte cargo, const struct SpriteGroup *group);
void SetRotorOverrideSprites(EngineID engine, const struct SpriteGroup *group);
SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle* v, Direction direction);
-SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle* v);
-#define GetCustomRotorSprite(v) GetRotorOverrideSprite(v->engine_type, v)
-#define GetCustomRotorIcon(et) GetRotorOverrideSprite(et, NULL)
+SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle* v, bool info_view);
+#define GetCustomRotorSprite(v, i) GetRotorOverrideSprite(v->engine_type, v, i)
+#define GetCustomRotorIcon(et) GetRotorOverrideSprite(et, NULL, true)
/* Forward declaration of GRFFile, to avoid unnecessary inclusion of newgrf.h
* elsewhere... */
diff --git a/newgrf_spritegroup.h b/newgrf_spritegroup.h
index 471299abb..ad3507a5f 100644
--- a/newgrf_spritegroup.h
+++ b/newgrf_spritegroup.h
@@ -165,6 +165,8 @@ typedef struct ResolverObject {
uint32 reseed;
VarSpriteGroupScope scope;
+ bool info_view; ///< Indicates if the item is being drawn in an info window
+
union {
struct {
const struct Vehicle *self;