class_name InputMapMenu extends AbstractConfigMenu @onready var _actual_menu := ( $'OuterMargin/Content/ActualMenu' ) @onready var _content := _actual_menu.get_node( ^'./ContentScrollContainer/ContentInnerMargin/Content' ) var _hlists := {} var _originals := {} func _connect_signals() -> void: _button_apply.visible = false for action in InputMap.get_actions(): if not action.begins_with('ui_'): var label := Label.new() var hlist := ( preload('res://ui/EditableHorizontalList.tscn').instantiate() ) as EditableHorizontalList _hlists[action] = hlist _content.add_child(label) _content.add_child(hlist) label.text = action.capitalize() func _pull_settings() -> void: for action in _hlists: var hlist := _hlists[action] as EditableHorizontalList hlist.clear() _originals[action] = [] for event in InputMap.action_get_events(action): var item := hlist.insert() var picker := (preload( 'res://ui/OptionsMenu/InputEventPicker.tscn' ).instantiate()) as InputEventPicker item.content.add_child(picker) picker.event = event picker.update_label() _originals[action].push_back(event) func _push_settings() -> void: for action in _hlists: InputMap.action_erase_events(action) var hlist := _hlists[action] as EditableHorizontalList for item in hlist.item_array: var picker := item.content.get_child(0) as InputEventPicker if picker.event: InputMap.action_add_event(action, picker.event) func _revert_changes() -> void: for action in _hlists: var hlist := _hlists[action] as EditableHorizontalList hlist.clear() for event in _originals[action]: var item := hlist.insert() var picker := (preload( 'res://ui/OptionsMenu/InputEventPicker.tscn' ).instantiate()) as InputEventPicker item.content.add_child(picker) picker.event = event picker.update_label() func _restore_defaults() -> void: InputMap.load_from_project_settings() _pull_settings()