diff options
author | frosch <frosch@openttd.org> | 2016-08-15 18:33:52 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2016-08-15 18:33:52 +0000 |
commit | ddc920521215c38ab7e96bebb929b313758268df (patch) | |
tree | 7cf2b7ca745d1d95af0d13b82d6b7f834913e0a6 /src/vehicle_gui.cpp | |
parent | cff2b493653eda314f997f998b297621eeb9e190 (diff) | |
download | openttd-ddc920521215c38ab7e96bebb929b313758268df.tar.xz |
(svn r27630) -Codechange: Deduplicate code to attach vehicle to cursor.
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r-- | src/vehicle_gui.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 1f03319ed..03f9ef225 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -2861,3 +2861,20 @@ int GetVehicleWidth(Vehicle *v, EngineImageType image_type) return vehicle_width; } + +/** + * Set the mouse cursor to look like a vehicle. + * @param v Vehicle + * @param image_type Type of vehicle image to use. + */ +void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type) +{ + bool rtl = _current_text_dir == TD_RTL; + + _cursor.sprite_count = 1; + _cursor.sprite_seq[0].sprite = v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DEPOT); + _cursor.sprite_seq[0].pal = GetVehiclePalette(v); + _cursor.sprite_pos[0].x = v->IsGroundVehicle() ? (16 - v->GetGroundVehicleCache()->cached_veh_length * 2) * (rtl ? -1 : 1) : 0; + + UpdateCursorSize(); +} |