diff options
author | rubidium <rubidium@openttd.org> | 2008-07-20 19:21:18 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-07-20 19:21:18 +0000 |
commit | fec49bcc83b2f5f813feee136382cbe367486e92 (patch) | |
tree | 6fcf8a160a5a544d096084931b801439776c3b40 | |
parent | 690859bf570094d1d59f6e1e3b7009d64bc022d7 (diff) | |
download | openttd-fec49bcc83b2f5f813feee136382cbe367486e92.tar.xz |
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
-rw-r--r-- | src/depot_gui.cpp | 14 | ||||
-rw-r--r-- | src/gfx.cpp | 5 | ||||
-rw-r--r-- | src/gfx_type.h | 1 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index cbec1179c..bace1d19f 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -513,6 +513,20 @@ struct DepotWindow : Window { this->sel = v->index; this->SetDirty(); SetObjectToPlaceWnd(image, GetVehiclePalette(v), VHM_DRAG, this); + + switch (v->type) { + case VEH_TRAIN: + _cursor.short_vehicle_offset = 16 - v->u.rail.cached_veh_length * 2; + break; + + case VEH_ROAD: + _cursor.short_vehicle_offset = 16 - v->u.road.cached_veh_length * 2; + break; + + default: + _cursor.short_vehicle_offset = 0; + break; + } _cursor.vehchain = _ctrl_pressed; } } break; diff --git a/src/gfx.cpp b/src/gfx.cpp index 8cd3cefaa..e57327446 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1008,7 +1008,7 @@ void DrawMouseCursor() } w = _cursor.size.x; - x = _cursor.pos.x + _cursor.offs.x; + x = _cursor.pos.x + _cursor.offs.x + _cursor.short_vehicle_offset; if (x < 0) { w += x; x = 0; @@ -1036,7 +1036,7 @@ void DrawMouseCursor() /* Draw cursor on screen */ _cur_dpi = &_screen; - DrawSprite(_cursor.sprite, _cursor.pal, _cursor.pos.x, _cursor.pos.y); + DrawSprite(_cursor.sprite, _cursor.pal, _cursor.pos.x + _cursor.short_vehicle_offset, _cursor.pos.y); _video_driver->MakeDirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y); @@ -1287,6 +1287,7 @@ static void SetCursorSprite(SpriteID cursor, SpriteID pal) cv->offs.y = p->y_offs; cv->dirty = true; + cv->short_vehicle_offset = 0; } static void SwitchAnimatedCursor() diff --git a/src/gfx_type.h b/src/gfx_type.h index 983b95205..4d5a3654a 100644 --- a/src/gfx_type.h +++ b/src/gfx_type.h @@ -113,6 +113,7 @@ struct AnimCursor { struct CursorVars { Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement Point draw_pos, draw_size; ///< position and size bounding-box for drawing + int short_vehicle_offset; ///< offset of the X for short vehicles SpriteID sprite; ///< current image of cursor SpriteID pal; |