recipie book autoloading working

This commit is contained in:
Tabby 2026-01-12 19:55:40 +11:00
parent e8c1f85a5b
commit 4f899c13f9
8 changed files with 134 additions and 10 deletions

View file

@ -4,6 +4,7 @@ class_name RecipeCard
@export var grid_container : GridContainer
var ingredient_slots : Array[ItemSlot]
@export var output_slot : ItemSlot
@export var output_label : Label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@ -26,3 +27,4 @@ func show_recipe(recipe : CraftRecipe):
output_slot.item = recipe.output
output_slot.update_ui()
output_slot.block_taking = true
output_label.text = recipe.output.item_name

View file

@ -6,10 +6,11 @@
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_8t2l7"]
size = Vector2(32, 32)
[node name="Recipe Card" type="PanelContainer" node_paths=PackedStringArray("grid_container", "output_slot")]
[node name="Recipe Card" type="PanelContainer" node_paths=PackedStringArray("grid_container", "output_slot", "output_label")]
script = ExtResource("1_8t2l7")
grid_container = NodePath("HBoxContainer/GridContainer")
output_slot = NodePath("HBoxContainer/VBoxContainer/ItemSlot10")
output_label = NodePath("HBoxContainer/VBoxContainer/Label")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2

View file

@ -4,14 +4,17 @@ extends PanelContainer
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
RecipeManager.recipes_loaded.connect(recipes_loaded)
pass # Replace with function body.
var test_card = load("res://crafting/recipe book/recipe_card.tscn").instantiate() as RecipeCard
var recipe : CraftRecipe = load("res://crafting/crafts/computer_craft.tres")
print(recipe)
test_card.show_recipe(recipe)
vbox.add_child(test_card)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func recipes_loaded():
for recipe in RecipeManager.craft_recipes:
var new_card = load("res://crafting/recipe book/recipe_card.tscn").instantiate() as RecipeCard
new_card.show_recipe(recipe)
vbox.add_child(new_card)