summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2016-10-16 14:58:38 +0000
committerfrosch <frosch@openttd.org>2016-10-16 14:58:38 +0000
commitc175067ed9c17d43feaf356cd575dddddd699889 (patch)
treef865fa356c59ab450aa1c93a22f024f15d675224 /src/roadveh_cmd.cpp
parentd2393b4f6c89b75a90452fe68ab8a1cfbd8c353f (diff)
downloadopenttd-c175067ed9c17d43feaf356cd575dddddd699889.tar.xz
(svn r27667) -Codechange: Add VehicleSpriteSeq::GetBounds and Draw.
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index e956787b0..9b541a766 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -162,11 +162,13 @@ void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID eng
VehicleSpriteSeq seq;
GetRoadVehIcon(engine, image_type, &seq);
- const Sprite *real_sprite = GetSprite(seq.sprite, ST_NORMAL);
+ Rect rect;
+ seq.GetBounds(&rect);
preferred_x = Clamp(preferred_x,
- left - UnScaleGUI(real_sprite->x_offs),
- right - UnScaleGUI(real_sprite->width) - UnScaleGUI(real_sprite->x_offs));
- DrawSprite(seq.sprite, pal, preferred_x, y);
+ left - UnScaleGUI(rect.left),
+ right - UnScaleGUI(rect.right));
+
+ seq.Draw(preferred_x, y, pal, pal == PALETTE_CRASH);
}
/**
@@ -183,12 +185,13 @@ void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs
VehicleSpriteSeq seq;
GetRoadVehIcon(engine, image_type, &seq);
- const Sprite *spr = GetSprite(seq.sprite, ST_NORMAL);
+ Rect rect;
+ seq.GetBounds(&rect);
- width = UnScaleGUI(spr->width);
- height = UnScaleGUI(spr->height);
- xoffs = UnScaleGUI(spr->x_offs);
- yoffs = UnScaleGUI(spr->y_offs);
+ width = UnScaleGUI(rect.right - rect.left + 1);
+ height = UnScaleGUI(rect.bottom - rect.top + 1);
+ xoffs = UnScaleGUI(rect.left);
+ yoffs = UnScaleGUI(rect.top);
}
/**