feat: dragon list new format
This commit is contained in:
parent
31e9b4770b
commit
b17c7280ea
5 changed files with 171 additions and 460 deletions
|
@ -1,23 +1,57 @@
|
|||
extends Window
|
||||
class_name DragonList
|
||||
|
||||
@export var dragon_list_entry: PackedScene
|
||||
@export var dragon_list_view: VBoxContainer
|
||||
|
||||
var _library: DragonLibrary
|
||||
@onready var dragger: DraggableWindow = $CanvasLayer/Dragger
|
||||
|
||||
@export var origin_name_label: Label
|
||||
@export var dragon_name_label: Label
|
||||
|
||||
@export var hat: AnimatedSprite2D
|
||||
@export var shirt: AnimatedSprite2D
|
||||
@export var decor: AnimatedSprite2D
|
||||
@export var dragon: AnimatedSprite2D
|
||||
|
||||
@export var hat_outfits: DragonOutfit
|
||||
@export var shirt_outfits: DragonOutfit
|
||||
@export var decor_outfits: DragonOutfit
|
||||
@export var dragon_colors: DragonOutfit
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
dragger.on_drag.connect(_on_drag)
|
||||
|
||||
|
||||
func _on_drag(offset: Vector2i):
|
||||
position += offset
|
||||
|
||||
|
||||
func set_library(library: DragonLibrary):
|
||||
_library = library
|
||||
for d in _library.dragons:
|
||||
append_dragon(d)
|
||||
_show_dragon(library.dragons[0])
|
||||
|
||||
|
||||
func append_dragon(properties: DragonProperties):
|
||||
var dragon: DragonListEntry = dragon_list_entry.instantiate()
|
||||
dragon.set_properties(properties)
|
||||
dragon_list_view.add_child(dragon)
|
||||
func _show_dragon(dragon: DragonProperties):
|
||||
hat.sprite_frames = hat_outfits.get_texture(dragon.hat)
|
||||
shirt.sprite_frames = shirt_outfits.get_texture(dragon.shirt)
|
||||
decor.sprite_frames = decor_outfits.get_texture(dragon.decor)
|
||||
self.dragon.sprite_frames = dragon_colors.get_texture(dragon.color)
|
||||
_restart_animations()
|
||||
|
||||
origin_name_label.text = dragon.origin
|
||||
dragon_name_label.text = dragon.name
|
||||
|
||||
|
||||
func _on_close_requested() -> void:
|
||||
func _restart_animations():
|
||||
hat.set_frame(0)
|
||||
hat.play('idle')
|
||||
shirt.set_frame(0)
|
||||
shirt.play('idle')
|
||||
decor.set_frame(0)
|
||||
decor.play('idle')
|
||||
dragon.set_frame(0)
|
||||
dragon.play('idle')
|
||||
|
||||
|
||||
func _on_close_pressed() -> void:
|
||||
queue_free()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue