OpenTTD

Tasklist

FS#2194 - Patch: scroll with arrow keys in server list

Attached to Project: OpenTTD
Opened by Manuel Wolf (Roujin) - Wednesday, 06 August 2008, 12:20 GMT
Last edited by Remko Bijker (Rubidium) - Wednesday, 22 October 2008, 20:22 GMT
Type Patch
Category Core
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

Details

This patch allows to scroll with the arrow keys in the network server list.
It also scrolls the list down/up to the selected server if it is outside the currently displayed range.

Please comment.
This task depends upon

Closed by  Remko Bijker (Rubidium)
Wednesday, 22 October 2008, 20:22 GMT
Reason for closing:  Implemented
Additional comments about closing:  In r14517.
Comment by Manuel Wolf (Roujin) - Wednesday, 06 August 2008, 16:19 GMT
After glx's suggestion to save the currently selected server's position instead of searching through the list every time, here's a second version.

It also features scrolling to the selected server when clicking on the "last visited server" panel.

Please comment.
Comment by Manuel Wolf (Roujin) - Wednesday, 06 August 2008, 17:54 GMT
Fixed two small style mistakes.
Comment by Manuel Wolf (Roujin) - Monday, 20 October 2008, 21:19 GMT
Update to r14505, now also includes pageup, pagedown, home and end keys - they do what is obvious. Also fixed the issue that 0 is a valid position in the list, and switched to uint16, which the number of servers should never reach.

Please comment (pretty please?)...
Comment by Remko Bijker (Rubidium) - Tuesday, 21 October 2008, 09:26 GMT
+typedef uint16 ServerListPosition;
+enum {SLP_INVALID = 0xFFFF};
You can better use static const ServerListPosition SLP_INVALID = 0xFFFF; here so you don't have to cast in "? : " statements with SLP_INVALID.

Furthermore this->list_position can be -1 or 0 in OnKeyPress which might cause segmentation faults. So I think you should ignore keypresses when there are no servers in the list.
Comment by Manuel Wolf (Roujin) - Tuesday, 21 October 2008, 14:54 GMT
Thanks for your feedback! I will implement the two suggestions as soon as I can and reupload it here then.
Comment by Manuel Wolf (Roujin) - Tuesday, 21 October 2008, 20:07 GMT
Here's the new version with the two changes.

Loading...