hud.gd 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. extends Control
  2. @onready var commands_list = $ScrollContainer/VBoxContainer
  3. const packed_command_node = preload("res://scenes/hud/command_node/command_node.tscn")
  4. signal run_commands(list)
  5. func _on_move_pressed() -> void:
  6. var command_node = packed_command_node.instantiate()
  7. command_node.set_command_texture(BaseLevel.Commands.MOVE)
  8. commands_list.add_child(command_node)
  9. func _on_rotate_left_pressed() -> void:
  10. var command_node = packed_command_node.instantiate()
  11. command_node.set_command_texture(BaseLevel.Commands.ROTATE_LEFT)
  12. commands_list.add_child(command_node)
  13. func _on_rotate_right_pressed() -> void:
  14. var command_node = packed_command_node.instantiate()
  15. command_node.set_command_texture(BaseLevel.Commands.ROTATE_RIGHT)
  16. commands_list.add_child(command_node)
  17. func _on_cancel_pressed() -> void:
  18. var count := commands_list.get_child_count()
  19. if count == 0:
  20. return
  21. commands_list.get_children()[count - 1].queue_free()
  22. func _on_run_pressed() -> void:
  23. run_commands.emit(commands_list.get_children())