Opened 10 years ago

Last modified 3 years ago

#2604 closed defect

Implement a GUI for setting the hotkeys — at Version 6

Reported by: Adrian Owned by:
Priority: Must Have Milestone: Alpha 24
Component: UI – Miscellaneous Keywords: beta
Cc: azrdev@… Patch:

Description (last modified by elexis)

F.e. in Greek, you have the following problem While in-game, if the system is switched to a Greek layout (and I'm guessing the bug would occur for any non-latin layouts), then the navigation (WASD) and view (QE) keys do not work. But regular users could also benefit by having customisable hotkeys.

Change History (8)

comment:1 by Itms, 10 years ago

Additionally, on AZERTY keyboards, the keys should be changed to fit the layout (i.e. using ZQSD for navigation and AE for view).

comment:2 by sanderd17, 10 years ago

Description: modified (diff)
Summary: letter keys (WASD navigation, etc) don't work with alternative keyboard layoutsImplement a GUI for setting the hotkeys

You can adapt the hotkeys in the settings file (see Manual_Settings for more info). But you're right that we need a GUI for it, and possibly also detect it automatically depending on some system setting. Though that's hard, as for some keys the meaning is in the place it takes (like w is above s, so w is up and s is down, this doesn't make sense for an AZERTY). And sometimes, the meaning of the key is in the symbol (like F for "follow").

comment:3 by azrdev, 8 years ago

Cc: azrdev@… added
Description: modified (diff)

comment:4 by elexis, 8 years ago

1. Main Menu entry and Options page: Since hotkeys are logically part of the config system, the GUI to edit them should be a subset of the options dialog (this way the save, reset, revert and default button can be reused).

To establish some screen space in that options dialog, similar to tabbing a new button "Show hotkeys " ("Show Settings") could be added that will toggle between displaying the hotkeys and the other settings. A new main menu entry under "Tools & Options" pointing to "Hotkeys" can be added so that unfamiliar users find that link directly.

2. Translation: Both the hotkey names and the actual keys assigned to them should be presented in the currently selected language.

Hotkey names and description: Therefore we must grab those from a new translated json file. The object maps from "hotkey category identifier" that includes the title and description of that hotkey category. The category contains a map from "hotkey identifier" to the properties of the hotkey, i.e. title, description and config ID).

{
  "selection": {
     "name": "Selection",
     "description": "Selecting units directly or selecting a subset when dragging",
     "hotkeys" : {
       "hotkey.selection.milonly": {
         "name": "Military units only"
         "description": "Add only military units to the selection"
        },
     },
    ...
   },
   ...
};

Notice the categories don't correspond exactly to the ones from default.cfg but are only meant to ease interaction. (see 5)

SDL Keys: KeyName.cpp contains a struct that maps from SDL key to a proper (currently unused) name that should just be translated:

	{ SDLK_SLASH, "/", TranslateWithContext("hotkey", "ForwardSlash") },
	{ SDLK_SEMICOLON, ";", TranslateWithContext("hotkey", "Semicolon") },
	{ SDLK_a, "A", TranslateWithContext("hotkey", "A") },
	{ SDLK_b, "B", TranslateWithContext("hotkey", "B") },

3. Hotkey page: All available hotkeys should be shown in a table (olist) as known from the lobby or replay menu. It will have a column for the hotkey name, one for the mapped key and potentialy one for the description (otherwise the description could be shown in a tooltip or label). It needs a button to delete the hotkey (#3051) and a button to set the key (should also happen when doubleclicking on that list item).

A temporary window should appear that prompts the user to press a key: 4. Hotkey input dialog: This will be a tricky one as it should disable all hotkeys globally and catch all keys pressed simultaneously until released (including shift, alt and escape).

It needs support for hotkey combinations, i.e. multiple keys pressed simultaneously (f.e. ctrl+1 to store a camera position).

(A sequence of hotkeys, f.e. B to build something, H to build a house as suggested in #1492 / #1312 / #1899 won't be handled inside this dialog. It should rather become two hotkeys.)

Once the user has released a button, the dialog will close automatically and return the pressed SDL hotkeys, which can be converted to ConfigDB entries using SKeycodeMapping.

5. Optional: Hotkey filter dropdown Since there are 147 hotkeys already, we could add a dropdown so that the user sees only a selected category ( all, hotkey, camera, ...)

comment:5 by Imarok, 8 years ago

Keywords: beta added

by elexis, 6 years ago

Attachment: screenshot1272.png added

by elexis, 6 years ago

Attachment: screenshot1271.png added

laying around since Aug 19 2017

comment:6 by elexis, 6 years ago

Description: modified (diff)

laying around since Aug 19 2017

Note: See TracTickets for help on using tickets.