feat: ability to share dragons

This commit is contained in:
Gerard Gascón 2025-04-09 16:49:50 +02:00
parent 3919df1805
commit 029ad6d45f
15 changed files with 203 additions and 30 deletions

View file

@ -0,0 +1,35 @@
extends Window
class_name DragonAdder
@export var hat_outfits: DragonOutfit
@export var shirt_outfits: DragonOutfit
@export var shoes_outfits: DragonOutfit
var code_generator: CodeGenerator
@onready var line_edit: LineEdit = $CanvasLayer/LineEdit
signal dragon_added(dragon_name: String, hat: Texture2D, shirt: Texture2D, shoes: Texture2D)
func _ready() -> void:
code_generator = CodeGenerator.new(hat_outfits, shirt_outfits, shoes_outfits)
func _on_button_pressed() -> void:
var dragon: Dictionary = code_generator.descrypt(line_edit.text)
if dragon['name'] == null:
return
var name: String = dragon['name']
var hat: Texture2D = dragon['hat']
var shirt: Texture2D = dragon['shirt']
var shoes: Texture2D = dragon['shoes']
dragon_added.emit(name, hat, shirt, shoes)
queue_free()
func _on_close_requested() -> void:
queue_free()

View file

@ -0,0 +1 @@
uid://b1fnwy6wnufw1

View file

@ -0,0 +1,62 @@
[gd_scene load_steps=6 format=3 uid="uid://oqa2ry73vqjf"]
[ext_resource type="Script" uid="uid://b1fnwy6wnufw1" path="res://scenes/dragon_adder/dragon_adder.gd" id="1_x83p2"]
[ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_33u3u"]
[ext_resource type="Script" uid="uid://mhudiyt5gnt1" path="res://scenes/dragon_editor/line_edit.gd" id="2_77mmq"]
[ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="3_xb0i6"]
[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_nf61g"]
[node name="DragonAdder" type="Window"]
position = Vector2i(0, 36)
size = Vector2i(500, 300)
transient = true
exclusive = true
script = ExtResource("1_x83p2")
hat_outfits = ExtResource("2_33u3u")
shirt_outfits = ExtResource("3_xb0i6")
shoes_outfits = ExtResource("4_nf61g")
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Button" type="Button" parent="CanvasLayer"]
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -32.0
offset_top = -31.0
offset_right = 32.0
grow_horizontal = 2
grow_vertical = 0
text = "afegeix"
[node name="LineEdit" type="LineEdit" parent="CanvasLayer"]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -214.0
offset_top = -29.0
offset_right = 214.0
offset_bottom = 29.0
grow_horizontal = 2
grow_vertical = 2
placeholder_text = "CODI"
alignment = 1
max_length = 22
script = ExtResource("2_77mmq")
[node name="Label" type="Label" parent="CanvasLayer"]
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -59.5
offset_right = 59.5
offset_bottom = 23.0
grow_horizontal = 2
text = "afegeix un drac"
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
[connection signal="pressed" from="CanvasLayer/Button" to="." method="_on_button_pressed"]