La-Torreta-del-Drac/scenes/dragon_editor/dragon_editor.gd
2025-04-11 17:03:19 +02:00

62 lines
1.5 KiB
GDScript

extends Window
class_name DragonEditor
@onready var hat: TextureRect = $CanvasLayer/Dragon/Hat
@onready var shirt: TextureRect = $CanvasLayer/Dragon/Shirt
@onready var shoes: TextureRect = $CanvasLayer/Dragon/Shoes
@onready var dragon: TextureRect = $CanvasLayer/Dragon
@export var hat_outfits: DragonOutfit
@export var shirt_outfits: DragonOutfit
@export var shoes_outfits: DragonOutfit
@export var dragon_colors: DragonOutfit
@onready var dragon_name: LineEdit = $CanvasLayer/NameLabel/LineEdit
@onready var dragger: DraggableWindow = $CanvasLayer/Dragger
signal on_create_dragon(hat: Texture2D, shirt: Texture2D, shoes: Texture2D, dragon_name: String)
func _ready() -> void:
hat.texture = null
shirt.texture = null
shoes.texture = null
dragger.on_drag.connect(_on_drag)
func _on_drag(offset: Vector2i):
position += offset
func _on_next_color_pressed() -> void:
dragon.texture = dragon_colors.pick_next()
func _on_previous_color_pressed() -> void:
dragon.texture = dragon_colors.pick_previous()
func _on_change_hat_pressed() -> void:
hat.texture = hat_outfits.pick_next()
func _on_change_shirt_pressed() -> void:
shirt.texture = shirt_outfits.pick_next()
func _on_change_shoes_pressed() -> void:
shoes.texture = shoes_outfits.pick_next()
func _on_create_pressed() -> void:
if dragon_name.text.is_empty():
return
on_create_dragon.emit(hat.texture, shirt.texture, shoes.texture, dragon_name.text)
queue_free()
func _on_close_pressed() -> void:
queue_free()