extends HBoxContainer

signal change_button_pressed

export var button_size: Vector2 = Vector2(30,30)
export var interactable: bool = false

func initialize(action_name, event):
  $Action.text = action_name.capitalize()
  $Key.add_child(create_controller_button(event))

func update_key(event):
  $Key.remove_child($Key.get_child(0))
  $Key.add_child(create_controller_button(event))

func create_controller_button(event) -> ControllerButton:
  var event_path = ControllerIcons._convert_event_to_path(event)
  var controller_button: ControllerButton = ControllerButton.new()
  controller_button.path = event_path
  if(!interactable):
    controller_button.focus_mode = FOCUS_NONE
    controller_button.enabled_focus_mode = FOCUS_NONE
    controller_button.mouse_filter = MOUSE_FILTER_IGNORE
  controller_button.rect_size = button_size
  controller_button.expand_icon = true
  return controller_button

func _on_ChangeButton_pressed():
  emit_signal('change_button_pressed')
