(svn r27667) -Codechange: Add VehicleSpriteSeq::GetBounds and Draw.

This commit is contained in:
frosch
2016-10-16 14:58:38 +00:00
parent d2393b4f6c
commit c175067ed9
11 changed files with 118 additions and 73 deletions

View File

@@ -86,10 +86,11 @@ void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID s
VehicleSpriteSeq seq;
v->GetImage(rtl ? DIR_E : DIR_W, image_type, &seq);
const Sprite *real_sprite = GetSprite(seq.sprite, ST_NORMAL);
Rect rect;
seq.GetBounds(&rect);
int width = UnScaleGUI(real_sprite->width);
int x_offs = UnScaleGUI(real_sprite->x_offs);
int width = UnScaleGUI(rect.right - rect.left + 1);
int x_offs = UnScaleGUI(rect.left);
int x = rtl ? right - width - x_offs : left - x_offs;
bool helicopter = v->subtype == AIR_HELICOPTER;
@@ -97,18 +98,18 @@ void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID s
int heli_offs = 0;
PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
DrawSprite(seq.sprite, pal, x, y + y_offs);
seq.Draw(x, y + y_offs, pal, v->vehstatus & VS_CRASHED);
if (helicopter) {
const Aircraft *a = Aircraft::From(v);
VehicleSpriteSeq rotor_seq;
GetCustomRotorSprite(a, true, image_type, &rotor_seq);
if (!rotor_seq.IsValid()) rotor_seq.Set(SPR_ROTOR_STOPPED);
heli_offs = ScaleGUITrad(5);
DrawSprite(rotor_seq.sprite, PAL_NONE, x, y + y_offs - heli_offs);
rotor_seq.Draw(x, y + y_offs - heli_offs, PAL_NONE, false);
}
if (v->index == selection) {
x += x_offs;
y += UnScaleGUI(real_sprite->y_offs) + y_offs - heli_offs;
DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleGUI(real_sprite->height) + heli_offs + 1, COLOUR_WHITE, FR_BORDERONLY);
y += UnScaleGUI(rect.top) + y_offs - heli_offs;
DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleGUI(rect.bottom - rect.top + 1) + heli_offs + 1, COLOUR_WHITE, FR_BORDERONLY);
}
}