32 lines
1.1 KiB
GDScript
32 lines
1.1 KiB
GDScript
extends Control
|
|
|
|
onready var _action_list = $"%ActionKeyList"
|
|
onready var changes_made := false
|
|
|
|
func _ready():
|
|
$InputMapper.connect('profile_changed', self, 'rebuild')
|
|
$InputMapper.initialize_profiles()
|
|
$ProfilesMenu.initialize($InputMapper)
|
|
$ProfilesMenu.grab_focus()
|
|
$InputMapper.change_profile($ProfilesMenu.selected)
|
|
|
|
func rebuild(input_profile):
|
|
_action_list.clear()
|
|
for input_action in input_profile.keys():
|
|
if(input_action.ends_with("_old") || input_action.begins_with(("ui_"))):
|
|
continue
|
|
var line = _action_list.add_input_line(input_action, input_profile[input_action])
|
|
line.connect('change_button_pressed', self, '_on_InputLine_change_button_pressed', [input_action, line])
|
|
|
|
func _on_InputLine_change_button_pressed(action_name, line):
|
|
set_process_input(false)
|
|
var old_event = $InputMapper.get_selected_profile()[action_name]
|
|
$KeySelectMenu.open()
|
|
var event = yield($KeySelectMenu, "key_selected")
|
|
if event == null:
|
|
return
|
|
changes_made = true
|
|
$InputMapper.change_action_key(action_name, old_event, event)
|
|
line.update_key(event)
|
|
set_process_input(true)
|