diff options
author | frosch <frosch@openttd.org> | 2009-07-18 12:34:19 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-07-18 12:34:19 +0000 |
commit | e8c2992ae698e63c437807a15504999493b1060b (patch) | |
tree | b49230ca1c6be6e2916b642db513591e96912454 /src/roadveh_cmd.cpp | |
parent | 36576371c05edf9a3498196d7ebdb8824a6910d1 (diff) | |
download | openttd-e8c2992ae698e63c437807a15504999493b1060b.tar.xz |
(svn r16872) -Codechange: Add RoadVehicle::GetDisplayImageWidth and simplify DrawRoadVehImage.
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r-- | src/roadveh_cmd.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 50a7d4e95..811a0e422 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -85,6 +85,22 @@ static const Trackdir _roadveh_depot_exit_trackdir[DIAGDIR_END] = { TRACKDIR_X_NE, TRACKDIR_Y_SE, TRACKDIR_X_SW, TRACKDIR_Y_NW }; +/** + * Get the width of a road vehicle image in the GUI. + * @param offset Additional offset for positioning the sprite; set to NULL if not needed + * @return Width in pixels + */ +int RoadVehicle::GetDisplayImageWidth(Point *offset) const +{ + int reference_width = ROADVEHINFO_DEFAULT_VEHICLE_WIDTH; + + if (offset != NULL) { + offset->x = reference_width / 2; + offset->y = 0; + } + return this->rcache.cached_veh_length * reference_width / 8; +} + static SpriteID GetRoadVehIcon(EngineID engine) { uint8 spritenum = RoadVehInfo(engine)->image_index; |