Skip to content

Commit

Permalink
Sort keybindings by translated name (mbrlabs#185)
Browse files Browse the repository at this point in the history
* Sort keybindings by translated name

* Rename function
  • Loading branch information
MrApplejuice authored Jul 19, 2022
1 parent 65a5230 commit dac390f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lorien/UI/Dialogs/KeyBindingsList.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,29 @@ func _ready() -> void:
_add_key_dialog.connect("hide", self, "_bind_key_dialog_hidden")
GlobalSignals.connect("language_changed", self, "_populate_input_list")

# -------------------------------------------------------------------------------------------------
func _compare_second_element(a: Array, b: Array) -> bool:
return a[1] < b[1]

# -------------------------------------------------------------------------------------------------
func _populate_input_list() -> void:
for c in _grid.get_children():
_grid.remove_child(c)

var collected_keybinding_args := []
for action in Utils.bindable_actions():
var translated_action = Utils.translate_action(action)
var shortcuts = []
for _event in InputMap.get_action_list(action):
if _event is InputEventKey:
var event = _event as InputEventKey
shortcuts.append(event)

collected_keybinding_args.append([action, translated_action, shortcuts])

_new_keybinding_entry(action, translated_action, shortcuts)
collected_keybinding_args.sort_custom(self, "_compare_second_element")
for args in collected_keybinding_args:
callv("_new_keybinding_entry", args)

# -------------------------------------------------------------------------------------------------
func _new_keybinding_entry(action_name: String, readable_name: String, events: Array) -> void:
Expand Down

0 comments on commit dac390f

Please sign in to comment.