Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add player customizable button hotkeys #326

Merged

Conversation

Spartan322
Copy link
Member

Fix potential button generation fail for invalid hotkeys

@Spartan322 Spartan322 added bug Something isn't working enhancement New feature or request labels Dec 14, 2024
Copy link
Contributor

@Hop311 Hop311 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • On Windows the initially loaded keybindings are fine but anything I change them to doesn't work and the original biinding keeps working instead. Also the original binding has "(Unicode)" after it in the options menu controls UI which disappears after changing the binding, not even coming back when you type in the original binding manually.
  • This doesn't allow setting shortcuts on anything without a shortcut already set in the defines, even shortcut = "" won't generate an action that can be customised
  • We should start thinking about how to display shortcuts in tooltips, depending on how complicated it is to generate a string representation of a key binding we should either cache or just always create a shortcut section for the tooltip and add it automatically any time the tooltip is updated. We'd need to detect when to update the shortcut text too if it's cached, and maybe refresh the tooltip when bindings change. Even if they're otherwise empty, tooltips should generate with the shortcut displayed at the minimum.

extension/src/openvic-extension/utility/UITools.cpp Outdated Show resolved Hide resolved
extension/src/openvic-extension/utility/UITools.cpp Outdated Show resolved Hide resolved
@Spartan322
Copy link
Member Author

Also the original binding has "(Unicode)" after it in the options menu controls UI which disappears after changing the binding

That is irrelevant, that's just a product of what is required to try and somewhat mimic what Victoria 2 tries to do.

This doesn't allow setting shortcuts on anything without a shortcut already set in the defines, even shortcut = "" won't generate an action that can be customised

Its not intended to be, this is not intended to add hotkeys to things that don't have them, this only would allow customizing things that already have hotkeys.

We should start thinking about how to display shortcuts in tooltips, depending on how complicated it is to generate a string representation of a key binding we should either cache or just always create a shortcut section for the tooltip and add it automatically any time the tooltip is updated. We'd need to detect when to update the shortcut text too if it's cached, and maybe refresh the tooltip when bindings change. Even if they're otherwise empty, tooltips should generate with the shortcut displayed at the minimum.

Why would we need to cache it? Godot makes this trivial to do already, it already tries to do it automatically by displaying the first valid event key in a tooltip which is why I call set_shortcut_in_tooltip(false) as its obnoxious with our preexisting tooltip, you can just get a textual representation of the InputEvent.

@Spartan322 Spartan322 marked this pull request as draft December 15, 2024 01:38
@Spartan322 Spartan322 force-pushed the add/customizable-hotkeys branch from bd46e99 to 4670910 Compare December 15, 2024 13:33
Hop311
Hop311 previously approved these changes Dec 15, 2024
Copy link
Contributor

@Hop311 Hop311 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shortcuts are working including new ones like manually adding shortcut = "F" to button_goto in menubar.gui to open the search panel with shift+F, although I can't see the new actions in the Options/Control menu at all now 😕

@Spartan322 Spartan322 force-pushed the add/customizable-hotkeys branch 5 times, most recently from 8fef7b5 to 7aafc8c Compare December 16, 2024 02:49
@Spartan322 Spartan322 marked this pull request as ready for review December 16, 2024 03:13
@Spartan322 Spartan322 force-pushed the add/customizable-hotkeys branch from 7aafc8c to 0b0d0a1 Compare December 16, 2024 07:18
Hop311
Hop311 previously approved these changes Dec 16, 2024
Copy link
Contributor

@Hop311 Hop311 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We get a bunch of warnings from UI elements with the same name but different values, not sure if these are fine to ignore or if we want to be able to handle them separately (e.g. create a 2-suffixed version if a regular action already exists)

WARNING: 'button_rallypoint_checkbox_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_rallypoint_merge_checkbox_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_rallypoint_checkbox_naval_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_rallypoint_merge_checkbox_naval_hotkey' already found in InputMap with different values, reusing hotkey     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_rallypoint_checkbox_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_rallypoint_merge_checkbox_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_rallypoint_checkbox_naval_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_rallypoint_merge_checkbox_naval_hotkey' already found in InputMap with different values, reusing hotkey     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)
Mapmode set to "Terrain Mapmode" (index: 0, identifier: mapmode_terrain)
WARNING: 'button_close_hotkey' already found in InputMap with different values, reusing hotkey
     at: try_create_shortcut_action_for_button (extension\src\openvic-extension\utility\UITools.cpp:172)

extension/src/openvic-extension/utility/UITools.cpp Outdated Show resolved Hide resolved
extension/src/openvic-extension/utility/UITools.cpp Outdated Show resolved Hide resolved
game/addons/keychain/Keychain.gd Show resolved Hide resolved
Fix potential button generation fail for invalid hotkeys
Add Keychain action grouping organization
Change default action map_zoom_in from Q to Shift+Q
Change default action map_zoom_out from E to Shift+E

Add `Keychain.reload_keychain` signal
Add `keep_binding_check` Callable to Keychain.gd
	Prevents removal of unfounded action bindings

Update Orama-Interactive/Keychain@0ddeb6f
@Spartan322 Spartan322 merged commit c31ab38 into OpenVicProject:master Dec 16, 2024
9 checks passed
@Spartan322 Spartan322 deleted the add/customizable-hotkeys branch December 16, 2024 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants