feat: add names to dragons
This commit is contained in:
parent
f07b28d2dc
commit
ca4959af32
10 changed files with 91 additions and 15 deletions
|
@ -10,8 +10,9 @@ class_name DragonEditor
|
|||
@export var shirt_outfits: DragonOutfit
|
||||
@export var shoes_outfits: DragonOutfit
|
||||
|
||||
@onready var dragon_name: LineEdit = $CanvasLayer/LineEdit
|
||||
|
||||
signal on_create_dragon(hat: Texture2D, shirt: Texture2D, shoes: Texture2D)
|
||||
signal on_create_dragon(hat: Texture2D, shirt: Texture2D, shoes: Texture2D, dragon_name: String)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -37,5 +38,7 @@ func _on_change_shoes_pressed() -> void:
|
|||
|
||||
|
||||
func _on_create_pressed() -> void:
|
||||
on_create_dragon.emit(hat.texture, shirt.texture, shoes.texture)
|
||||
if dragon_name.text.is_empty():
|
||||
return
|
||||
on_create_dragon.emit(hat.texture, shirt.texture, shoes.texture, dragon_name.text)
|
||||
queue_free()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://fut42ruut302"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://fut42ruut302"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bfuos2kgfgber" path="res://scenes/dragon_editor/dragon_editor.gd" id="1_8vkll"]
|
||||
[ext_resource type="Texture2D" uid="uid://fdqnc2qrrvn1" path="res://assets/sprites/icon.svg" id="2_un5ur"]
|
||||
|
@ -8,6 +8,7 @@
|
|||
[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_1ivi1"]
|
||||
[ext_resource type="Texture2D" uid="uid://dc2uk6tqtwl4n" path="res://assets/sprites/shirt.png" id="4_6sr44"]
|
||||
[ext_resource type="Texture2D" uid="uid://8srlwinjr3tt" path="res://assets/sprites/shoes.png" id="5_wby0j"]
|
||||
[ext_resource type="Script" uid="uid://mhudiyt5gnt1" path="res://scenes/dragon_editor/line_edit.gd" id="9_xhgxf"]
|
||||
|
||||
[node name="DragonEditor" type="Window"]
|
||||
title = "Dragon Editor"
|
||||
|
@ -116,6 +117,16 @@ grow_vertical = 2
|
|||
texture = ExtResource("5_wby0j")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="CanvasLayer"]
|
||||
offset_left = 59.0
|
||||
offset_top = 372.0
|
||||
offset_right = 250.0
|
||||
offset_bottom = 403.0
|
||||
placeholder_text = "NOM"
|
||||
alignment = 1
|
||||
max_length = 8
|
||||
script = ExtResource("9_xhgxf")
|
||||
|
||||
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
|
||||
[connection signal="pressed" from="CanvasLayer/VBoxContainer/change_hat" to="." method="_on_change_hat_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/VBoxContainer/change_shirt" to="." method="_on_change_shirt_pressed"]
|
||||
|
|
11
scenes/dragon_editor/line_edit.gd
Normal file
11
scenes/dragon_editor/line_edit.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends LineEdit
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
connect("text_changed", _text_to_upper)
|
||||
|
||||
|
||||
func _text_to_upper(new_text: String):
|
||||
var last_caret_column = caret_column
|
||||
text = new_text.to_upper()
|
||||
caret_column = last_caret_column
|
1
scenes/dragon_editor/line_edit.gd.uid
Normal file
1
scenes/dragon_editor/line_edit.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://mhudiyt5gnt1
|
Loading…
Add table
Add a link
Reference in a new issue