Patch: configurable hotkeys
Posted: 07 Jul 2008 15:18
This patch allows the customization of hotkeys. As a starting point, (nearly) all now existing hotkeys were made customizable. Some additional functions which can be assigned hotkeys were included.
There exists no GUI right now, so the customization has to be done in the config file. There are some new sections in the form of [hotkey_*] defined for the config file, which each hold the hotkeys for one toolbar/window. If one of the expected sections is not found, the defaults are loaded and on program exit, they are written to the config file. Invalid hotkeys are deleted from the config file.
It is possible to assign more than one command to one keycode, so it is possible to use kind of macros (e.g.: you could bind RailAuto and Remove to one key). The commands are executed in the order they are read from the config file.
If a keycode is handled by a toolbar, it is not passed on to a higher level. So you can define the same keycode in global/game and a toolbar (e.g. rail) and depending on wether the rail toolbar is open, the global/game or the rail function is used (this makes it possible to use 'A' as autorail and - if road toolbar is open - as autoroad (which was my primary motivation for writing this patch)).
For a detailed information on how to specify the hotkeys and a list of supported toolbars/windows, keys and commands please see the attached textfile.
There are also StringIDs defined for all commands. They are not yet used, but are placeholders for a planned GUI.
The mod-ignore version does ignore additionally pressed modifier keys. So for example if the user pressed STRG+ALT+T and a hotkey is only defined for STRG+T, STRG+T is executed. This is only experimental, and there are some issues with it. Stick with the main version, if you do not really need that behaviour.
Changelog:
v1.0:
There exists no GUI right now, so the customization has to be done in the config file. There are some new sections in the form of [hotkey_*] defined for the config file, which each hold the hotkeys for one toolbar/window. If one of the expected sections is not found, the defaults are loaded and on program exit, they are written to the config file. Invalid hotkeys are deleted from the config file.
It is possible to assign more than one command to one keycode, so it is possible to use kind of macros (e.g.: you could bind RailAuto and Remove to one key). The commands are executed in the order they are read from the config file.
If a keycode is handled by a toolbar, it is not passed on to a higher level. So you can define the same keycode in global/game and a toolbar (e.g. rail) and depending on wether the rail toolbar is open, the global/game or the rail function is used (this makes it possible to use 'A' as autorail and - if road toolbar is open - as autoroad (which was my primary motivation for writing this patch)).
For a detailed information on how to specify the hotkeys and a list of supported toolbars/windows, keys and commands please see the attached textfile.
There are also StringIDs defined for all commands. They are not yet used, but are placeholders for a planned GUI.
The mod-ignore version does ignore additionally pressed modifier keys. So for example if the user pressed STRG+ALT+T and a hotkey is only defined for STRG+T, STRG+T is executed. This is only experimental, and there are some issues with it. Stick with the main version, if you do not really need that behaviour.
Changelog:
v1.0:
- Changed the patch to do not include the StringIDs.
- Codechanges: splitted OnKeyPress event in order to avoid code repetitions
- Codechange: cleaned constructor of the descendants of HotkeyWindow (repetitive code)
- Added: command "ZoomToCursor" was added to global section
- Documentation: Added a lot of documentation; Now conform to doxygen format codestyle
- Fix: missing vehicle owner check on hotkey execution in order_gui.cpp
- Codechange: using a defined constant for determining the modifier keys (less magic numbers)
- Codechange: Splitted the terraform section into terraform_game and terraform_editor and defined commands for each section accordingly
- Codechange: Defined an own enum for every section.
- Codechange: Using the _build_*_proc arrays for executing the procedures for toolbars. This requires matching enums for those sections.
- Codechange: Giving an int as parameter to HandleProcNr to be able to pass the different enums.
- Added: Some commands were added:
- [game]: ToggleFastForward
- [editor]: ToggleFastForward
- No mod-ignore version any more as there are too many conceptual problems.
- Fix: Hotkeys were deleted on config save.
- Codechange: since r14260, trunk merges keycode for "normal" 0-9 keys and keypad 0-9 keys (FS#2277). Therefore the special keys NUM_0 to NUM_9 are no longer valid.
- Added: possibility to specify arbitrary keycodes by using "Kc%d" with "%d" being the numerical value of the keycode.
- Fix: Specifying an keycode which would have also a string representation by numeric value did result in a duplicate hotkey entry on saving the config file.
- Codechange: Due to changes in trunk code, the command Transfer in the hotkey_order section is no longer valid.
- Codechange: In trunk code, all 'patches' references were removed. To stay consistent, the old "ShowPatchOptions" command is now "ShowAdvancedSettings" (like it is used in trunk too).
- Made ToggleBoundingBoxes configurable in order to be able to use Ctrl+B for other commands. So in [global] section there is a new command: ToggleBoundingBoxes