feat: dragon list view

This commit is contained in:
Gerard Gascón 2025-04-09 13:59:41 +02:00
parent 577926e8fc
commit 3919df1805
17 changed files with 409 additions and 4 deletions

View file

@ -0,0 +1,32 @@
[gd_scene load_steps=6 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)
transient = true
exclusive = 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="."]
[node name="ScrollContainer" type="ScrollContainer" parent="CanvasLayer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/ScrollContainer"]
layout_mode = 2
[connection signal="close_requested" from="." to="." method="_on_close_requested"]

View file

@ -0,0 +1,17 @@
extends Control
class_name DragonListEntry
@export var texture_rect: TextureRect
@export var name_label: Label
@export var code_label: Label
var code_generator: CodeGenerator
@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)

View file

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

View file

@ -0,0 +1,30 @@
extends Window
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)
func append_dragon(name: String, hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
var dragon: DragonListEntry = dragon_list_entry.instantiate()
dragon.set_properties(name, hat, shirt, shoes)
dragon_list_view.add_child(dragon)
func _on_close_requested() -> void:
queue_free()

View file

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

View file

@ -0,0 +1,52 @@
[gd_scene load_steps=7 format=3 uid="uid://bs45hvb2mpw4k"]
[ext_resource type="Texture2D" uid="uid://fdqnc2qrrvn1" path="res://assets/sprites/icon.svg" id="1_4i8li"]
[ext_resource type="Script" uid="uid://d1bq5f35wptxt" path="res://scenes/dragon_list/dragon_list_entry.gd" id="1_s7he7"]
[ext_resource type="FontFile" uid="uid://dn8qanm8tctb2" path="res://assets/fonts/Montserrat-Regular.ttf" id="2_s7he7"]
[ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_y33em"]
[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")]
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")
hat_outfits = ExtResource("2_y33em")
shirt_outfits = ExtResource("3_84ie0")
shoes_outfits = ExtResource("4_xvxt0")
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 0
offset_left = 8.0
offset_top = 8.0
offset_right = 128.0
offset_bottom = 128.0
texture = ExtResource("1_4i8li")
expand_mode = 1
[node name="Name" type="Label" parent="."]
layout_mode = 0
offset_left = 132.0
offset_top = 4.0
offset_right = 449.0
offset_bottom = 128.0
scale = Vector2(0.8, 1)
theme_override_fonts/font = ExtResource("2_s7he7")
theme_override_font_sizes/font_size = 36
text = "AAAAAAAA"
[node name="Code" type="Label" parent="."]
layout_mode = 0
offset_left = 132.0
offset_top = 8.0
offset_right = 530.0
offset_bottom = 72.0
scale = Vector2(0.8, 1)
theme_override_fonts/font = ExtResource("2_s7he7")
theme_override_font_sizes/font_size = 21
text = "AAAAAAAAAAAAAAAAAAAAAA"
vertical_alignment = 2