recipie book autoloading working
This commit is contained in:
parent
e8c1f85a5b
commit
4f899c13f9
8 changed files with 134 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
49
crafting/recipeManager.gd
Normal file
49
crafting/recipeManager.gd
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
extends Node
|
||||
|
||||
signal recipes_loaded
|
||||
var craft_recipes : Array[CraftRecipe]
|
||||
var crafts_dir : String = "res://crafting/crafts/"
|
||||
var scavenge_recipes : Array[ScavengeRecipe]
|
||||
var scavenges_dir : String = "res://crafting/scavenges/"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
load_recipes()
|
||||
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func load_recipes():
|
||||
## CRAFTS
|
||||
var dir = DirAccess.open(crafts_dir)
|
||||
if dir:
|
||||
dir.list_dir_begin()
|
||||
var file_name = dir.get_next()
|
||||
while file_name != "":
|
||||
|
||||
# do something with the file
|
||||
if (file_name.get_extension() == "remap"):
|
||||
file_name = file_name.replace('.remap', '')
|
||||
print(crafts_dir + file_name)
|
||||
craft_recipes.append(load(crafts_dir + file_name) as CraftRecipe)
|
||||
file_name = dir.get_next()
|
||||
|
||||
## SCAVENGES
|
||||
dir = DirAccess.open(scavenges_dir)
|
||||
if dir:
|
||||
dir.list_dir_begin()
|
||||
var file_name = dir.get_next()
|
||||
while file_name != "":
|
||||
|
||||
# do something with the file
|
||||
if (file_name.get_extension() == "remap"):
|
||||
file_name = file_name.replace('.remap', '')
|
||||
print(crafts_dir + file_name)
|
||||
craft_recipes.append(load(scavenges_dir + file_name) as ScavengeRecipe)
|
||||
file_name = dir.get_next()
|
||||
|
||||
recipes_loaded.emit()
|
||||
1
crafting/recipeManager.gd.uid
Normal file
1
crafting/recipeManager.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b76dwpvf6ot3o
|
||||
67
export_presets.cfg
Normal file
67
export_presets.cfg
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
[preset.0]
|
||||
|
||||
name="Windows Desktop"
|
||||
platform="Windows Desktop"
|
||||
runnable=true
|
||||
advanced_options=false
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../../Exports/Repurposed/Windows/RepurposedJam.exe"
|
||||
patches=PackedStringArray()
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
seed=0
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
script_export_mode=2
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
debug/export_console_wrapper=1
|
||||
binary_format/embed_pck=true
|
||||
texture_format/s3tc_bptc=true
|
||||
texture_format/etc2_astc=false
|
||||
shader_baker/enabled=false
|
||||
binary_format/architecture="x86_64"
|
||||
codesign/enable=false
|
||||
codesign/timestamp=true
|
||||
codesign/timestamp_server_url=""
|
||||
codesign/digest_algorithm=1
|
||||
codesign/description=""
|
||||
codesign/custom_options=PackedStringArray()
|
||||
application/modify_resources=true
|
||||
application/icon=""
|
||||
application/console_wrapper_icon=""
|
||||
application/icon_interpolation=4
|
||||
application/file_version=""
|
||||
application/product_version=""
|
||||
application/company_name=""
|
||||
application/product_name=""
|
||||
application/file_description=""
|
||||
application/copyright=""
|
||||
application/trademarks=""
|
||||
application/export_angle=0
|
||||
application/export_d3d12=0
|
||||
application/d3d12_agility_sdk_multiarch=true
|
||||
ssh_remote_deploy/enabled=false
|
||||
ssh_remote_deploy/host="user@host_ip"
|
||||
ssh_remote_deploy/port="22"
|
||||
ssh_remote_deploy/extra_args_ssh=""
|
||||
ssh_remote_deploy/extra_args_scp=""
|
||||
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
|
||||
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
|
||||
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
|
||||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
|
||||
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
|
||||
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
|
||||
Start-ScheduledTask -TaskName godot_remote_debug
|
||||
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
|
||||
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
|
||||
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
|
||||
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
|
||||
Remove-Item -Recurse -Force '{temp_dir}'"
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
extends Inventory
|
||||
|
||||
@export var action_button : Button
|
||||
@export var craft_recipes : Array[CraftRecipe]
|
||||
@export var scavenge_recipes : Array[ScavengeRecipe]
|
||||
#@export var craft_recipes : Array[CraftRecipe]
|
||||
#@export var scavenge_recipes : Array[ScavengeRecipe]
|
||||
var matched_recipe : Recipe
|
||||
#@export var no_style : StyleBox
|
||||
@export var assemble_style : StyleBox
|
||||
|
|
@ -46,7 +46,7 @@ func check_recipes():
|
|||
item_to_scavenge = slot.item
|
||||
break
|
||||
|
||||
for recipe in scavenge_recipes:
|
||||
for recipe in RecipeManager.scavenge_recipes:
|
||||
if recipe.input.item_name == item_to_scavenge.item_name:
|
||||
matched_recipe = recipe
|
||||
style_scavenge()
|
||||
|
|
@ -54,7 +54,7 @@ func check_recipes():
|
|||
|
||||
elif filled_slots() > 1:
|
||||
# check crafting recipes
|
||||
var possible_recipes : Array[CraftRecipe] = craft_recipes.duplicate()
|
||||
var possible_recipes : Array[CraftRecipe] = RecipeManager.craft_recipes.duplicate()
|
||||
for x in range(9):
|
||||
for recipe in possible_recipes:
|
||||
if recipe.ingredients[x] and slots[x].item:
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ Tooltip="*res://tooltip.tscn"
|
|||
PlayerInventory="*res://inv_system/player_inventory.tscn"
|
||||
Clock="*res://time_system/clock.tscn"
|
||||
MouseTweaks="*res://mouseTweaks.gd"
|
||||
RecipeManager="*res://crafting/recipeManager.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue