feat: pulling dragons from server working

This commit is contained in:
Gerard Gascón 2025-04-12 00:21:07 +02:00
parent 50bc814367
commit b080ab7bf4
11 changed files with 46 additions and 193 deletions

View file

@ -1,10 +1,7 @@
[gd_scene load_steps=6 format=3 uid="uid://tubxrqxjic6r"]
[gd_scene load_steps=3 format=3 uid="uid://tubxrqxjic6r"]
[ext_resource type="PackedScene" uid="uid://bs45hvb2mpw4k" path="res://scenes/dragon_list/dragon_properties.tscn" id="1_4vct3"]
[ext_resource type="Script" uid="uid://dm8d0ikf1n8qa" path="res://scenes/dragon_list/dragon_list_view.gd" id="1_q7g8i"]
[ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="3_xxwat"]
[ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="4_7mhmu"]
[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="5_h4iwm"]
[node name="DragonList" type="Window" node_paths=PackedStringArray("dragon_list_view")]
size = Vector2i(450, 700)
@ -12,9 +9,6 @@ always_on_top = true
script = ExtResource("1_q7g8i")
dragon_list_entry = ExtResource("1_4vct3")
dragon_list_view = NodePath("CanvasLayer/ScrollContainer/VBoxContainer")
hat_outfits = ExtResource("3_xxwat")
shirt_outfits = ExtResource("4_7mhmu")
shoes_outfits = ExtResource("5_h4iwm")
[node name="CanvasLayer" type="CanvasLayer" parent="."]

View file

@ -3,15 +3,13 @@ class_name DragonListEntry
@export var texture_rect: TextureRect
@export var name_label: Label
@export var code_label: Label
var code_generator: CodeGenerator
@export var origin_label: Label
@export var hat_outfits: DragonOutfit
@export var shirt_outfits: DragonOutfit
@export var shoes_outfits: DragonOutfit
func set_properties(name: String, hat: Texture2D, shirt: Texture2D, shoes: Texture2D) -> void:
name_label.text = name
code_label.text = CodeGenerator.new(hat_outfits, shirt_outfits, shoes_outfits).encrypt(hat, shirt, shoes, name)
func set_properties(properties: DragonProperties) -> void:
name_label.text = properties.name
origin_label.text = properties.origin

View file

@ -4,25 +4,18 @@ class_name DragonList
@export var dragon_list_entry: PackedScene
@export var dragon_list_view: VBoxContainer
@export var hat_outfits: DragonOutfit
@export var shirt_outfits: DragonOutfit
@export var shoes_outfits: DragonOutfit
var _library: DragonLibrary
func set_library(library: DragonLibrary):
_library = library
for d in _library.dragons:
var hat: Texture2D = hat_outfits.get_texture(d['hat'])
var shirt: Texture2D = shirt_outfits.get_texture(d['shirt'])
var shoes: Texture2D = shoes_outfits.get_texture(d['shoes'])
append_dragon(d['name'], hat, shirt, shoes)
#
append_dragon(d)
func append_dragon(name: String, hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
func append_dragon(properties: DragonProperties):
var dragon: DragonListEntry = dragon_list_entry.instantiate()
dragon.set_properties(name, hat, shirt, shoes)
dragon.set_properties(properties)
dragon_list_view.add_child(dragon)

View file

@ -7,14 +7,14 @@
[ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="3_84ie0"]
[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_xvxt0"]
[node name="DragonProperties" type="Control" node_paths=PackedStringArray("texture_rect", "name_label", "code_label")]
[node name="DragonProperties" type="Control" node_paths=PackedStringArray("texture_rect", "name_label", "origin_label")]
custom_minimum_size = Vector2(0, 128)
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_s7he7")
texture_rect = NodePath("TextureRect")
name_label = NodePath("Name")
code_label = NodePath("Code")
origin_label = NodePath("Origin")
hat_outfits = ExtResource("2_y33em")
shirt_outfits = ExtResource("3_84ie0")
shoes_outfits = ExtResource("4_xvxt0")
@ -39,7 +39,7 @@ theme_override_fonts/font = ExtResource("2_s7he7")
theme_override_font_sizes/font_size = 36
text = "AAAAAAAA"
[node name="Code" type="Label" parent="."]
[node name="Origin" type="Label" parent="."]
layout_mode = 0
offset_left = 132.0
offset_top = 8.0