Unciv
Unciv copied to clipboard
Configurable key bindings - Requests and Discussion
Context
Unciv may get configurable keyboard key bindings in the near future (PR #8802). Since there are many functions that may be candidates for such a binding, implementing them all is a work in progress and might take a long time. Please bundle any and all requests / comments / criticism on that feature here in this issue.
Goal
Maintain and prioritize a list of desired functions to get a configurable key binding. Possibly discover usages we might otherwise miss.
Status
- [x] Access to configuration gated by switch on "Debug" page
- [ ] Has open PRs
Framework stuff
- Interoperability with reusable components (API level)
- [x] Popup
- [x] WASD Listener
- [x] onActivation
- [ ] TabbedPager
- [x] UncivTooltip
- [x] ExpanderTab?
- [ ] UncivSlider?
- [ ] Civilopedia migration to TabbedPager?
- [x] UnitActions are dependent on the "Show more" state, but should not be
List of Contexts / Bindings
- [x] Main Menu
- [x] Resume, Quickstart, New, Load
- [x] Editor, Multiplayer, Mods, Options
- [x] Civilopedia - same binding as WorldScreen
- [x] World Screen
- [x] Next turn with alternate
- [x] Civilopedia
- [x] Empire Overview
- [x] F2-F10 Various info screens
- [x] F11 F12 Quicksave/Load
- [x] Options, Save, Load, Toggle UI
- [x] Toogle display (Resources, Yields, Worked, Movements)
- [x] Zoom In/Out
- [x] Panning with WASD and Arrow keys
- [x] Show Capital (Home)
- [ ] ~Multiselect (Shift) - Not straightforward~ Nope won't do
- [x] Unit Actions
- [x] All of them as far as I know
- [x] City Screen
- [x] Left/Right arrows
- [x] Buy construction, Buy tile
- [x] Stats breakdown (new)
- [x] .. new ones for the top right expanders open/close??
- [x] .. new ones for switching production focus??
- [x] .. new ones for opening+jumping-to the construction categories (left-side expanders)??
- [ ] Popups
- [x] Confirm / Reject types of Dialog
- [x] Confirm / Yes
- [x] Reject / No
- [ ] Options Popup
- [ ] F12 - dev option - likely won't do
- [ ] New bindings to navigate tabs? - see TabbedPager mention
- [ ] Conquered city
- [ ] Annex
- [ ] Destroy
- [ ] Liberate
- [ ] Puppet
- [ ] Raze
- [x] Confirm / Reject types of Dialog
- [ ] Picker Screens
- [ ] Load / Save
- [ ] Improvement picker - how to deal with improvement json
shortcutKey
? - [ ] Change any general Picker Screen Confirm/Cancel stuff?
- [ ] ... ?
- [ ] Civilopedia
- Arrow Navigation (↔ Categories, ↕ Entries)
- Category selection by Letter (are the current keys translation-dependent?)
I just tried the button assignment tab in the settings. It looks a bit complicated😵 In terms of user-friendly experience (all these drop-downs, along with hovering). The drop-down lists contain characters from gamepads and shift+key characters (although you can't assign them via hover)
Didn't you think of something more common and simple? For example, just a non-editible text field, which indicates the current binding. When a user clicks on the field, it is highlighted in a different color, and then: either the user clicks ESC and the binding does not change or the user presses some button and it is binded to the corresponding action.
And here is a list of standard assignments.
World screen: WASD/Arrows - Scroll map on the world screen PageUp - Hide more unit actions PageDown - Show more unit actions Del - Disabnd unit Tab - Move here/Swap unit Z - Wait LShift - Select multiple units(I didn't know it was possible😲) Space or N - Next unit or turn E - Empire overview (last viewed page) + - Zoom in - - Zoom out Home - center on capital or open its city screen if already centered F1 - Open Civilopedia F2 - Empire overview Trades F3 - Empire overview Units F4 - Empire overview Diplomacy F5 - Social policies F6 - Technologies F7 - Empire overview Cities F8 - Victory Progress F9 - Empire overview Stats F10 - Empire overview Resources F11 - Quicksave F12 - Quickload Ctrl-R - Toggle tile resource display Ctrl-Y - Toggle tile yield display Ctrl-O - Game options Ctrl-S - Save game Ctrl-L - Load game Ctrl-U - Toggle UI
City screen: Left,Right - On the city screen change selected city B - Buy selected construction T - Buy selected tile
Map editor: Up/Down - Move selection in the map editor(did not find out what it means) Ctrl+I - View tab Ctrl+N - Generate tab Ctrl+G - Generate partial tab Ctrl+E - Edit tab: 1-5 - Brush size Ctrl+F - Brush floodfill T - Terrain F - Features W - Wonders R - Resources I - Improvements V - Rivers S - Starting locations Ctrl+L - Load tab Ctrl+S - Save tab Ctrl+D - Mods tab Ctrl+O - Options tab: Ctrl+C - Copy map Ctrl+V - Paste map
Options: LShift, RShift - Something with the sliders, I don't know what; UncivSlider.kt line 202 F12 - Generate translations in the Options, Advanced tab
File list(e.g. save file list): Up/Down - Change selected entry PageUp/PageDown - Scroll the entry list Home/End - Go to the start/end of the entry list
Save/Load screen: Ctrl+C - Copy save Ctrl+V - Paste save Ctrl+A - Show autosaves
Civilopedia controls: Left/Right - Change tabs Up/Down - Change selected entry PageUp/PageDown - Scroll the entry list Home/End - Go to the start/end of the entry list
Popups: Space or Enter - Confirm popup
Conquered city popup: A - Annex D - Destroy L - Liberate P - Puppet R - Raze
just tried
Thank you!
characters from gamepads
Yup, that's a problem I didn't want to hardcode and am waiting for Eureka. That's the almost complete list from Input.java - how can one guess what some people may actually have on their gaming keyboards and what's completely esoteric? I don't have an F24, but you can buy them... Another json listing allowed codes? Nah. waiting for better idea.
non-editible text field
Hmmm... History and geriatric unflexibility? First I had a plain TextFíeld and parsed the string. Then I did the SelectBox, then I tried building that KeyCapturingButton as Add-on - I thought that would be increasing complexity, but that hover-capture thing was surprisingly simple. Since all that is relatively encapsulated, no biggie to change.
drop-down lists contain shift+key characters
You still misunderstand. That's keycodes, no correlation to shift or alt. Physical keys as they would look on an Imperial (sorry, en-US) layout. Virtual keys. Those characters don't really represent ASCII at that point but the picture on the yankee keyboard - and there all of them are unshifted. They're abstract labels just to recognize a piece of hardware. That's why I tried to translate those. Or think of it like this - take sandpaper and remove all print on your keyboard. It still works, every key will deliver a unique Integer. Paint arbitrary names on them and associate those with the Integers - the system works, keys can be recognized reliably - no text semantics needed. Interpretation into the "character" as in linguistings realm comes much later, and there starts the cultural differences not before. And Gdx doesn't do "culturally interpreted" as per OS keyboard settings at all with just one Exception I know of - TextField... Exception Ctrl-*, the Ctrl up/down is tracked manually in my code, Gdx doesn't help there - much. There's isKeyPressed but if you have the listener anyway it's faster to track oneself..... Yup, and lastly an ASCII Ctrl-character generated from the virtual key name which is why they're still swapped on qwertz or azerty.
list of
Nice. I had forgotten a couple of them, but in turn I remember one or two you missed (City buy construction B buy tile T,...). I'll collate, but not today.
Another json listing allowed codes? Nah. waiting for better idea.
That's why I suggest to abandon the drop-down lists in favor of a text field (which will display only keys that the user can actually press), or a button, or something else that can display text and be highlighted when you click on it.
Since all that is relatively encapsulated, no biggie to change.
I'm not speaking from the point of view of a coder or the complexity of the code. I'm sharing my impressions of using the interface, based on my experience and habits gained in other games.
Physical keys as they would look on an Imperial (sorry, en-US) layout. Virtual keys.
There are keyboards with separate buttons for @,# and : ? Hm...🤔
one or two you missed
My list based on the results of the Input.Keys.* search, I haven't seen the ones you mentioned.
I don't have an F24, but you can buy them...
I googled, and there are only dinosaurs there...🦖
And on the latest version, an exception when opening Options:
java.lang.ExceptionInInitializerError
at com.unciv.ui.popups.options.KeyBindingsTab$KeyboardBindingWidget.<init>(KeyBindingsTab.kt:74)
at com.unciv.ui.popups.options.KeyBindingsTab.<init>(KeyBindingsTab.kt:42)
at com.unciv.ui.popups.options.OptionsPopup.showOrHideKeyBindings$core(OptionsPopup.kt:193)
at com.unciv.ui.popups.options.OptionsPopup.<init>(OptionsPopup.kt:125)
at com.unciv.ui.screens.basescreen.BaseScreen.openOptionsPopup(BaseScreen.kt:166)
at com.unciv.ui.screens.basescreen.BaseScreen.openOptionsPopup$default(BaseScreen.kt:165)
at com.unciv.ui.screens.mainmenuscreen.MainMenuScreen$optionsTable$1.invoke(MainMenuScreen.kt:187)
at com.unciv.ui.screens.mainmenuscreen.MainMenuScreen$optionsTable$1.invoke(MainMenuScreen.kt:186)
at com.unciv.ui.components.extensions.Scene2dExtensionsKt$onActivation$1.invoke(Scene2dExtensions.kt:190)
at com.unciv.ui.components.extensions.Scene2dExtensionsKt$onActivation$1.invoke(Scene2dExtensions.kt:188)
at com.unciv.ui.components.extensions.ActorAttachments.activate(Scene2dExtensions.kt:136)
at com.unciv.ui.components.extensions.Scene2dExtensionsKt.activate(Scene2dExtensions.kt:179)
at com.unciv.ui.components.extensions.ActorAttachments$addActivationAction$2.clicked(Scene2dExtensions.kt:147)
at com.badlogic.gdx.scenes.scene2d.utils.ClickListener.touchUp(ClickListener.java:88)
at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:71)
at com.badlogic.gdx.scenes.scene2d.Stage.touchUp(Stage.java:355)
at com.unciv.ui.screens.basescreen.UncivStage.access$touchUp$s80204510(UncivStage.kt:18)
at com.unciv.ui.screens.basescreen.UncivStage$touchUp$1.invoke(UncivStage.kt:90)
at com.unciv.ui.screens.basescreen.UncivStage$touchUp$1.invoke(UncivStage.kt:90)
at com.unciv.ui.crashhandling.CrashHandlingExtensionsKt$wrapCrashHandling$1.invoke(CrashHandlingExtensions.kt:17)
at com.unciv.ui.screens.basescreen.UncivStage.touchUp(UncivStage.kt:90)
at com.badlogic.gdx.InputEventQueue.drain(InputEventQueue.java:70)
at com.badlogic.gdx.backends.lwjgl3.DefaultLwjgl3Input.update(DefaultLwjgl3Input.java:189)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:378)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:192)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:166)
at com.unciv.app.desktop.DesktopLauncher.main(DesktopLauncher.kt:76)
Caused by: java.lang.NullPointerException: toString(keyCode) must not be null
at com.unciv.ui.components.extensions.GdxKeyCodeFixes.toString(Scene2dExtensions.kt:578)
at com.unciv.ui.components.KeysSelectBox.<clinit>(KeysSelectBox.kt:49)
... 27 more
abandon the drop-down
Seen that way pretty obviousy a Good Thing (tm)
exception when opening Options
I know that one, but I never PR'ed that version or did I? At least the fix isn't pushed anywhere yet. Was an interesting and after all obvious lesson.
Input.Keys.* search
Then someday I'll do "Find Usages" on KeyCharAndCode.constructor(char: Char) and KeyCharAndCode.ctrl(Char), that should find most of the rest. Or trace all of the KeyShortcutDispatcher.add calls
Ctrl-R - Toggle tile resource display Ctrl-Y - Toggle tile yield display
Did you find them in code? I missed them and searched in vain - if they're on the actor itself, then the current next PR is in error.
Did you find them in code? I missed them and searched in vain - if they're on the actor itself, then the current next PR is in error.
Nah, this was taken from civiloledia. I checked in version 4.4.9 these combinations do not work, so I was tricked...
Strange history - I introduce those two keys in 3875, two hours later Yair removes them, and back then it seems I understood why...
Yair removes them
he deleted everything related to the buttons on the minimap in dbc3bcb5a1c956ce0e5dccc2c255562dad411d35, moreover, you thanked him😀
..moreover.. yup that's what I said, but I can't be too obvious now can I? I think the thanks was due to me being mortified I had forgotten to run unit tests locally before pushing.
I need to test something... Hello @SomeTroglodyte
Can you include Esc
key and game shutdown popup
keybind?
On 4.10.11 win64, Esc cannot be assigned for other keybind.
And there is no "Game shutdown" entry on settings - key.
I want to use Esc for main menu key on world screen.
Esc cannot be assigned for other keybind.
Yes, intentional. The tutorial should even say so. Correlated with the key being made 1:1 equivalent with Android's "back" button. There's just so many hardcoded places (20 uses), and having that one constant really makes things easier.
And the game shutdown popup is treated as a generic popup, so its yes/no are bindable together with all other such popups. Could be made a separate entry, yes - but without the first one not much sense, right?
Wow i've never noticed Android back button shows shutdown popup!.. But if it's hardcoded, i should make a new issue. Why should we see shutdown popup in world screen directly? I've never seen this behavior except Unciv. It's so strange.
I've grown used to it...
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 15 days.
Since you're probably getting a notification anyways, might as well ping. @SomeTroglodyte if this is done or something you can close this. Give the more generic nature of this as key bindings discussion, I'll give it a label