FS#337 - highlight vehicles properly in rail depot window

Attached to Project: OpenTTD
Opened by GrimRC (GrimRC) - Friday, 08 September 2006, 12:31 GMT
Type Patch
Category Interface
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


My patch makes the rail depot window highlight trains' and their wagons properly when dragging. Currently, only the clicked vehicle is highlighted, but with my patch, all selected vehicles are highlighted when the 'ctrl' key is pressed. This makes it clearer that pressing 'ctrl' allows dragging of large chunks of a train, rather than just one component, as when 'ctrl' is not pressed.

Attached is a screenshot showing rail vehicle dragging, with the patch applied.
This task depends upon

Closed by  Zdeněk Sojka (SmatZ)
Saturday, 05 April 2008, 12:36 GMT
Reason for closing:  Implemented
Additional comments about closing:  Bug fixed in r12166
Highlight implemented in r12576
Cursor change won't be implemented
Comment by GrimRC (GrimRC) - Sunday, 17 September 2006, 15:52 GMT
I've created 3 new patches. Below, they are shown diagrammatically like sets.

drag_bug-fix.patch ⊂ highlight.patch ⊂ train_drag.patch

'drag_bug-fix.patch' fixes a bug in the dragging mechanism, whereby changing the mouse-mode with the keyboard (say bulldozer mode) would not cancel the vehicle selection in a depot window properly. A screenshot of the bug, 'drag_bug.png', is attached.

'highlight.patch' contains 'drag_bug-fix.patch'. It highlights selected vehicles (plural!) properly in a train depot window (when dragging with the ctrl key held down); this can almost be considered a second bug-fix. A screenshot demonstrating the improved dragging behaviour is attached as 'highlight.png'.

'train_drag.patch' contains 'highlight.patch', and improves train vehicle dragging even further by changing the mouse cursor sprite to several vehicles when dragging with the ctrl key, rather than just one particular vehicle; this can almost be considered a bug-fix, too. It works by adding an array of sprites and another array of their offsets to struct 'CursorVars'. The current implementation does not remove the old cursor sprite method, but just supplements it. This may not be desirable, as it is basically redundant. I can improve the way this patch works if needed; for example, I could remove the old sprite cursor method and make all cursor-dependent code use the new, proposed method (my sprite array). A screenshot is attached as 'train_drag.png', demonstrating the new, more correct and prettier dragging behaviour.

Summarising, all 3 patches seem bug-free, and the first 2 patches seem clean. The third, biggest and more experimental patch 'train_drag.patch' might need criticism, as it might not quite be how 'pretty train dragging' should be implemented. The patches apply to trunk R6472.
Comment by GrimRC (GrimRC) - Sunday, 17 September 2006, 15:54 GMT
The patches & screenshots (I accidentally hit 'add comment') attached.