Opened 10 years ago

Closed 4 years ago

Last modified 3 years ago

#2604 closed defect (fixed)

Hotkey editor

Reported by: Adrian Owned by: wraitii
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.

Attachments (2)

screenshot1272.png (1.7 MB ) - added by elexis 6 years ago.
screenshot1271.png (1.6 MB ) - added by elexis 6 years ago.
laying around since Aug 19 2017

Change History (17)

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

comment:7 by Itms, 5 years ago

Component: Core engineUI – Miscellaneous
Priority: Should HaveMust Have

This looks beautiful elexis. I hope we can have this in at some point!

comment:8 by nani, 5 years ago

elexis what do we need to do to get this on the game? If you want I can offer myself to review it (this week can't, next one sure) if you upload it to phab.

comment:9 by elexis, 5 years ago

The Tax Court has stated that: "It is well established that an exempt organization is entitled to pay reasonable compensation for services without endangering its exemption" and that "the law places no duty on individuals operating charitable organizations to donate their services; they are entitled to reasonable compensation for their efforts."(World Family Corporation v. Commissioner, 81 T.C. 958, 969 (1983), Reasonable Compensation by Jean Wright and Jay H. Rotz).

comment:10 by elexis, 5 years ago

Summary: Implement a GUI for setting the hotkeysHotkey editor

comment:11 by elexis, 5 years ago

In 22845:

Implement JS support for GUI object "hotkey" setting missing from rP804, refs #567, #2604, rP8444.

Allows JS GUI to assign hotkeys to GUI objects from JS instead of XML.

Differential Revision:
Comments By: nani
Tested By: nani, Jenkins
Tested on: clang, VS2015

comment:12 by elexis, 5 years ago

In 23076:

Implement session event subscription system and rewrite TopPanel, PlayerViewControl, GameSpeed, Pausing, ObjectivesDialog to use object orientation, refs #5387.

New controller classes: PlayerViewControl, PauseControl, GameSpeedControl
New viewer classes: ObjectivesDialog, PauseOverlay, FollowPlayer, TopPanel (BuildLabel, CivIcon, CounterManager, CounterPopulation, CounterResource refs rP21071/D1113, GameSpeedButton, ObjectivesDialogButton)

New events: SimulationUpdate, EntitySelectionChange, ViewedPlayerChange, PreViewedPlayerChangeHandler, PlayerIDChange, PlayersInit, PlayersFinished, Pause, DiplomacyColorsChange, HotkeyChange, refs #2604
Improves GUI onSimuationUpdate performance without selected entities by allegedly 30%.

Delete misleading dead code resign command from leaveGame and rename to endGame. The command is not sent via network (see rP14732) nor processed in simulation, because the Game instance is deleted immediately thereafter, introduced in rP8234, refs rP14772, rP17548, rP18441.
Remove explicitResume 0 value from rP17423 and rP20644 which should have been a false if defined, and is equivalent to the default.
Restore fast forwarding option from rP20577/D595 for developers changing the perspective to observer or player following rP21149.
Add pausing for the delete dialog missing following rP10194.

Differential Revision:

comment:13 by wraitii, 4 years ago

Owner: set to wraitii
Resolution: fixed
Status: newclosed

In 24215:

Let players remap hotkeys in-game, fix default hotkeys being qwerty-specific.

  • Provide a "Hotkey" screen to let players remap hotkeys in-game using a convenient setup.
  • Make all .cfg hotkeys refer to scancodes (i.e. position on the keyboard), so that default hotkeys now translate correctly for AZERTY, QWERTZ and other layouts.
  • 'BackSpace' is now an alias for 'Delete', and works for killing units. This fixes #1917, as macs don't have a proper delete key and would need to use Fn+Del otherwise. This shifts "timewarp" to Shift+BackSpace.

Functionally, this switches hotkeys to scancodes, as that makes more sense (they are combinations of key positions, not actual text output).
SDL includes are cleaned and key names are reused.

Fixes #2850, Fixes #2604, Refs #1810, Fixes #1917.

Follows work in rP19624.

Various diffs tested by: Angen, Stan, Freagarach

Comments by: Nescio

Differential Revision:

comment:14 by Stan, 4 years ago

Milestone: BacklogAlpha 24

comment:15 by wraitii, 3 years ago

In 24793:

Hotkey editor fix: don't modify hotkeys in place.

The hotkey editor could modify hotkeys despite the changes being cancelled.

Refs #2604, Fixes #5982

Differential Revision:

Note: See TracTickets for help on using tickets.