Keyboard Shortcut Overhaul

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
Buggi
Engineer
Engineer
Posts: 124
Joined: 02 Feb 2005 19:03
Location: Now in North Dakota

Keyboard Shortcut Overhaul

Post by Buggi »

I'm a MAJOR user of Keyboard shortcuts and I think most games do a fairly good job at this... OpenTTD is not one of them. The number of times I have to click the mouse while playing is extreme when compared to the average.

Since this game is a major mouse user, and as I'm right handed, my left hand is left to the keyboard... so here are the suggested changes that would benefit all life.

(The most optimum would be to have them in a config file.)

It seems the main keypress captures occur in
MainWindowWndProc(..) in main_gui.c

So, here they are.
{
For the Main window:
"t" for rail build menu (_last_built_railtype) : "t"rain
"r" for road build menu
I like having a short cut for "l"andscape, but an easier one to get when playing would be "z" (no hand movement needed)
"a" for airports
"s" for ships
"w" for town directory
"q" for the map of world
"f" for the finance window
"i" for industry directory
Ctrl+"i" for fund new industry
"F1" is Pause
"p" is pause
"home" centers on HQ (if built)

Alt+"a" for aircraft listing
Alt+"s" for ship listing
Alt+"t" for train listing
Alt+"r" for road vehicle listing
Alt+"f" is fast speed

Ctrl+"s" for screenshot
Ctrl+Alt+"s" for large screenshot

Now for submenus! {variable}_gui.c

For Landscaping:
Ctrl+"e" for planting trees toolbar
Alt+"e" for planting "trees of random type" (I do this a lot)
Alt+"g" for placing a sign
Alt+"b" for buying land
"d" is always demolish, regardless of menu
"e" for even landscaping
Alt+"z" for lower land
Ctrl+"z" for raise land

Rail build menu:
"a" stays auto, awesome feature!! (overrides airports when this menu is active)
"s" for signal (also overrides ships when this menu is active)
Shift+"s" for presignal (I have yet to understand their use...)
Ctrl+"s" for placing NE station 'drag and drop'
Alt+"s" for placing NW station 'drag and drop'
"e" for depot menu, followed by "1, 2, 3, 4" for the different directions, clockwise
"b" stays bridge
also Ctrl + "b" to maintain continuity
Ctrl + "t" for tunnel
Ctrl + "w" for waypoint
"c" stays convert
"r" stays remove
"z" for landscape
"del" to close (or "." on the numpad)

Road build menu:
Alt+"q" for NW road
Alt+"w" for NE road
"r" for remove
"b" for bus stop menu (1, 2, 3, 4 for direction)
Alt + "t" for truck stop (1, 2 ,3, 4 again)
"e" for depot (1, 2, 3, 4 again)
Ctrl + "b" for bridge
Ctrl + "t" for tunnel
"z" for landscape
"del" to close (or "." on the numpad)

Ship Build Menu:
"c" for canal
Ctrl+"c" for lock
"e" for depot (1, 2)
Ctrl+"d" for dock
"b" for bouy
"z" for landscape
"del" to close (or "." on the numpad)

Airport Build menu
"b" for build
-> Followed by "s" for small, "c" for city, "e" for metropolitian, Ctrl+"t" for International, "r" for heliport
"z" for landscape
"del" to close (or "." on the numpad)

In all build menus for all station types
"h" to turn highlighting on and off

In all vehicle order dialogs (HUGE time saver)
"g" is Goto
"f" is full load (overrides finance window when giving orders)
}

Now if you want me to actually write the code so you just have to copy and paste it in, just ask. I think this would GREATLY enhance gameplay.

A couple scenarios to consider. You load a game up fresh... you want build a new train route from A to B...
"q" (click starting place on map)
"t"
Ctrl(or Alt)+"s" click and place station
"a"
Place rail as needed to destination
Ctrl(or Alt)+"s" click and place station
"e"+(1-4) for depot
Click depot, click engine, buy, click wagons, buy, click orders
"g" Click first station
"g" click second station
Click the entry for first station and hit "f" for full load
Close box, click to start and your done.

7 mouse clicks when you discount placing track and buying the train.

Now how about playing... You've placed orders for a train and got it going, now you want to work on a city and build some buses...
"del" to close windows
"w" for towns, click desired town
"r" for road menu
"b"+(1-4) place station
"b"+(1-4) place station
"e"+(1-4) place depot
Click Depot
Buy bus
Click Orders
"g" click first station
"g" click second station
Close orders, and start

11 mouse clicks total.

If possible, it would be nice to be able to capture the numpad while deciding direction on depots... 1, 7, 9, and 3 could easily be used for directions...

Side note:
Finally, would it be possible to "drag and drop" the buying of land? (Instead of one square at a time.)
-Buggi
Programmer and TTD fan...
StarLite
Engineer
Engineer
Posts: 52
Joined: 02 Apr 2004 14:27
Contact:

Post by StarLite »

I just got used to the shortcuts.
1 thing I would like to see is to have the shortcuts for the landscape menu working even when its now opened.
Keys to rotate depots would be goooood as well :)
User avatar
ThorRune
Tycoon
Tycoon
Posts: 5762
Joined: 09 Oct 2003 14:00
Location: Nordland, Norway
Contact:

Post by ThorRune »

That sounds endlessly much better!
Alcohol is not the answer, it just makes you forget the question.
Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Post by Moriarty »

Brilliant ideas. Give that person a nobel prize in hot-key allocation. ;)
User avatar
Buggi
Engineer
Engineer
Posts: 124
Joined: 02 Feb 2005 19:03
Location: Now in North Dakota

Post by Buggi »

Thank you! :D

Did I miss anything? I did a lot of work to make sure there were no conflicts.

-----------------------------------edit----------------------------------------
Well I've got the source up and running on my dev machine and I think I can make the above changes happen, it's just a matter of getting the MAIN source updated. (The source that matters :) )

I am a programmer after all :)
-Buggi
Programmer and TTD fan...
Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Post by Moriarty »

Let's see if i can complicate things.
i don't see why the present F keys can't remain as they are. They are logical (a line of F keys for the line of commands). Plus it would save having to use other keys for those functions (i.e. the mini-map, or the town listing which you propose should be openable with new hotkeys).
This would allow you to just use the letter W for rail waypoints, rather than ctrl, w.
Also, letter T should do tunnels, rather than ctrl-T.
At present it's quite possible to open the construction menus using Shift f7 to shift - f10.


Something else to consider, numerous shortcuts there would maybe make more sense clustered together so as to make them easier to access, as when they are accessed chances are the player will need related functions. However not everyone has qwerty keyboard layouts, so a hot-key editor would be helpful.

Also, in-sync with the above point, if the same selection of keys were used for construction functions, it would make it simpler to memorise the keyboard shortcuts (even if they wern't as logical) as there would be less.
i.e. at present 1,2,3,4 create different direction railway tracks. The keys 1 and 2 also allow road to be built when in that menu.
User avatar
Celestar
Director
Director
Posts: 574
Joined: 02 Jul 2004 10:56
Contact:

Post by Celestar »

I'm all for a major overhaul of the shortcuts, but it is very difficult and requires a major rewrite. Why? Because openttd currently doesn't understand the concept of an "active" window. So all keypresses go to ALL windows, and then it goes "first come, first serve". I'm willing to change that, but unfortunately I have very little time currently for coding.

Celestar
User avatar
Buggi
Engineer
Engineer
Posts: 124
Joined: 02 Feb 2005 19:03
Location: Now in North Dakota

Post by Buggi »

And I have quite a bit of time for coding.

Plus I graduate with my CS major in about 3 months and then I'll have LOTS of time to code.

I'm still trying to track how the logic of events are traced in the code... What fires the events and how they are thrown in subsequent layers.

And y'all need to start using more descriptive variable names. :)

Oh, to the Shift-F keys... I say BAH! My fingers can't do that and the point of my layout was to prevent the use of both hands for the vast majority of features.

In a perfect world, the new key layout would be controled via a cfg file and a nice hotkey edit dialog, but the amount of work that would take given the engine is _crazy_ :D It would take a LOT of widgets :shock:
-Buggi
Programmer and TTD fan...
Nanaki13
Traffic Manager
Traffic Manager
Posts: 151
Joined: 08 Jan 2005 16:08

Post by Nanaki13 »

The best solution would be custom keyboard shortcuts in the config file.
I don't have the qwerty layout or anything similar. I'd love to be able to choose my own keys. We could even leave the edit dialog out, i'd be happy to edit the config file by hand as long as it would give me my keys. :)
And a list of them in the game would be nice. (dunno if there is 1 already)
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

You don't need an ingame gui, just a nicely reworked shortcut system ingame with sane default values and overrides being able to get loaded from the config file.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
User avatar
Buggi
Engineer
Engineer
Posts: 124
Joined: 02 Feb 2005 19:03
Location: Now in North Dakota

Post by Buggi »

Consider me on it!

*cracks his knuckles*

Okay, how can I do this and not have every single nightly over-write my work?

^_^;;
-Buggi
Programmer and TTD fan...
User avatar
Celestar
Director
Director
Posts: 574
Joined: 02 Jul 2004 10:56
Contact:

Post by Celestar »

Use svn (subversion).

Manual:
http://svnbook.red-bean.com/
or "man svn".

Celestar
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Buggi wrote:Consider me on it!

*cracks his knuckles*

Okay, how can I do this and not have every single nightly over-write my work?

^_^;;
Sign_de started to do some work on it but somehow just disappeared. Look here: http://t-x-c.gotdns.org/openttd/patches/dynkeys.patch for inspiration :)

We need some functions that assign shortcuts to windows either based on their WINDOW_ID or functionname, and the shortcut is only active for those windows, independent of which are open. You also need to think about global shortcuts, etc. Good luck :)
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Post by Moriarty »

Seems everyone likes the idea of putting them into openttd.cfg, however I propose that they be put into their own config file ("keyboard.cfg" or whatever). The reason being because then the configs could be shared with greater ease.
If player can share them, then a number of different setups could end up circulation for different layouts, or even just different play styles.

And if the config file loading function is written properly, all you'd have to do is send it a different filename to load, so it's not even any extra work beyond about 5 seconds.
User avatar
Buggi
Engineer
Engineer
Posts: 124
Joined: 02 Feb 2005 19:03
Location: Now in North Dakota

Post by Buggi »

I already know how I'm going to do it. I'm going to use the cfg structure that the code already knows how to handle, I'm just going to create my own structure.

ottdkeys.cfg:

[main]
pause_game = F1|"p"|'pause'
build_road = "r"
build_rail = "t"
.
.
.

[rail]
auto_rail = "a"
build_signal = "s"
build_station_NE = 'ctrl'+"s"
build_station_NW = 'alt'+"s"
.
.
.

..etc

The ini structure is already there for groups and everything, coding it to handle "ctrl" and "alt" and such is going to be joyous :)

Anyone know the key codes for every key (for the code)? :shock:

Anyway, I figure it's the best way to handle such a dynamic system without a major intrusion in the code.
-Buggi
Programmer and TTD fan...
User avatar
Dundee
Engineer
Engineer
Posts: 112
Joined: 28 Nov 2004 04:35
Location: Sydney, Australia

Post by Dundee »

Moriarty wrote:Seems everyone likes the idea of putting them into openttd.cfg, however I propose that they be put into their own config file ("keyboard.cfg" or whatever). The reason being because then the configs could be shared with greater ease.
I think they should probably be bundled with the other player options (as opposed to game/server options) into a separate file

At the bottom of this page I shared my thoughts on the issue of options and a suggestion as to how I would like to see them split up.
User avatar
Buggi
Engineer
Engineer
Posts: 124
Joined: 02 Feb 2005 19:03
Location: Now in North Dakota

Post by Buggi »

I appreciate the feedback Dundee, but I'm not doing a major overhaul of the game. Reorganizing everything would take a substantial investement of time.

Have you looked at the source code? It's not exactly easy reading. I've coded for many years, so I can actually read it, but to someone new to the field, it looks egyptian. :)
-Buggi
Programmer and TTD fan...
User avatar
Buggi
Engineer
Engineer
Posts: 124
Joined: 02 Feb 2005 19:03
Location: Now in North Dakota

Post by Buggi »

Yeah I'm replying to my own post... sue me, I'm tired. :P

After much head-scratching and work I think I may have a solution to the active window issue. :D Although every solution I come up with seems to edit every _gui file... :shock:

I would like to impliment the core in it's own .h and .c files... like ottdkeys.h and ottdkeys.c as the config file I'm generating is ottdkeys.cfg.

I'm all about continuity. Now, I've got svn all going nicely, however I haven't been able to "lock" files so far... :(

Anyway, back to coding. :D
-Buggi
Programmer and TTD fan...
nzhook
Engineer
Engineer
Posts: 115
Joined: 02 Jul 2004 13:15
Location: NZ
Contact:

Post by nzhook »

My thoughts:
Im sure there is some reason for using the console system somewhere, emulate games such as quake and stuff:
bind ctrl-a openrailtoolbar

I know that would take a bit more work, but in terms of portablity between people it would be great (and in game editing)


SVN is great, you dont need to lock a file. Make your change, when you next do a SVN update it will pull down the source and 'merge' it with your code. If it cant understand how to merge it (eg. there are modifications in the changed version which are also modified in your version) it will let you know and give you two files.
User avatar
hawk
Traffic Manager
Traffic Manager
Posts: 221
Joined: 05 Sep 2004 00:26
Location: Brisbane Australia

Post by hawk »

I think customised keyboard shortcuts would be better.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 4 guests