Author Topic: Contextual Hotkeys  (Read 1053 times)


  • Guest
Contextual Hotkeys
« on: 14 October 2011, 18:51:55 »
 Hey all!
   I don't really know if this exists, but this could be SO useful for a smoother rts experience, and it's probabely quite simple to implement. Would it be possible to have commands on a selected unit activated by a specified keypress? Like in starcraft (1 and 2) or warcraft 3. Maybe it would be possible just to add another command line in the .XML after that, such as maybe '<key-value="B"/>', so for example, build = "b" and farm = "f", so you could build a farm in seconds, but other units would do a different command for "b" or "f" (such as swordman charge?). I think this could be really useful.


  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Contextual Hotkeys
« Reply #1 on: 14 October 2011, 21:24:49 »
This has been a frequent feature request for a long time.  I'd certainly like to see it.


  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Contextual Hotkeys
« Reply #2 on: 14 October 2011, 22:35:56 »
I can't seem to find the original topics discussing this (may have been just a part of other discussions?), but I certainly agree to the usefulness.

To expand, possible examples of how it could work:
Each command would have a "hotkey" element which specifies the key in the same syntax as the hotkey INI.

Code: (Example 1) [Select]
<type value="attack"/>
<name value="attack"/>
<image path="images/swordman_attack.bmp"/>
<move-skill value="charge_skill"/>
<attack-skill value="attack_skill"/>
<hotkey value="Ctrl+A"/>

For "submenu" style commands, such as build, produce, etc, you'd have a new attribute to specify the hotkey. So if your produce skill creates a submenu for produced units, each "produced-unit" tag would have a "hotkey" attribute added.
Code: [Select]
<type value="produce" />
<name value="produce" />
<image path="images/image.bmp" />
<unit name="my_unit" />
<upgrade name="my_upgrade" />
<produce-skill value="produce_skill" />
<produced-unit name="my_unit" number="1" hotkey="Alt+M" />

It'd be more versatile to specify the hotkey on the commands than in the unit's parameters, as it would allow us to add hotkeys to, say, secondary attacks. Naturally, all hotkey elements/attributes would be optional.

If the given hotkey attribute is the same as one defined in keymap.ini, the mod-defined hotkey will prevail (but we'll assume that modders will be smarter than to try and "overwrite" popular hotkeys, eg, no making the move command have the hotkey of "a"). The reason for this is to allow modders more choice, but does require them to be responsible about their choices. Ideally, very few clashes should exist, but there may be legitimate uses, such as making a different attack skill have the hotkey for "a", or perhaps on a building, "m" might be the production hotkey, even though buildings won't have the move command usually associated with "m".

Personally, I'd recommend that modders never overwrite the default keymap.ini hotkeys unless absolutely necessary. You can easily add Ctrl and Alt modifiers to hotkeys, which (currently) the keymap.ini doesn't use at all. It'd also be a good idea for modders to be consistent with their hotkeys. For example, don't use "a" to produce a unit, since "a" would generally be associated with some type of attack. While it's good to use letters similar to the action being performed (eg, copy is Ctrl+C), if there isn't any "empty" slots (eg, you already used "Y", "Shift+Y", "Alt+Y", and "Ctrl+Y" as hotkeys for other actions), it's not necessary (eg, to close a window, Ctrl+W and Alt+F4 are the hotkeys, despite neither seeming to be even slightly related to closing a window).

With the hotkeys being the same as used in the keymap.ini file, the possibilities are as described on the Wiki page (not entirely sure how up to date it is, more keys may be supported). On a side note, it'd be nice if the function keys and number pad number keys could be used, as they are marked as "crash" on that page.
« Last Edit: 18 June 2016, 14:09:33 by filux »
Edit the MegaGlest wiki:

My personal projects:


  • Golem
  • ******
  • Posts: 868
    • View Profile
Re: Contextual Hotkeys
« Reply #3 on: 28 October 2011, 03:09:56 »
Starcraft 2 have a exelent system

just make a grid for buttons 123

now make these ocupyable by ANY skills, and make the button able to have a hoykey plus text.
WiP Game developer.
I do danish translations.
"i break stuff"