diff --git a/crafting/recipe book/recipe_card.gd b/crafting/recipe book/recipe_card.gd index 6e3eb36..24513b7 100644 --- a/crafting/recipe book/recipe_card.gd +++ b/crafting/recipe book/recipe_card.gd @@ -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 diff --git a/crafting/recipe book/recipe_card.tscn b/crafting/recipe book/recipe_card.tscn index 09e9f4c..863dfa9 100644 --- a/crafting/recipe book/recipe_card.tscn +++ b/crafting/recipe book/recipe_card.tscn @@ -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 diff --git a/crafting/recipe book/recipie_book.gd b/crafting/recipe book/recipie_book.gd index 3d21422..5dd4d0b 100644 --- a/crafting/recipe book/recipie_book.gd +++ b/crafting/recipe book/recipie_book.gd @@ -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) diff --git a/crafting/recipeManager.gd b/crafting/recipeManager.gd new file mode 100644 index 0000000..b36b3e2 --- /dev/null +++ b/crafting/recipeManager.gd @@ -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() diff --git a/crafting/recipeManager.gd.uid b/crafting/recipeManager.gd.uid new file mode 100644 index 0000000..449b7fa --- /dev/null +++ b/crafting/recipeManager.gd.uid @@ -0,0 +1 @@ +uid://b76dwpvf6ot3o diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..83dcd69 --- /dev/null +++ b/export_presets.cfg @@ -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}'" diff --git a/inv_system/crafting_panel.gd b/inv_system/crafting_panel.gd index f861338..531cc96 100644 --- a/inv_system/crafting_panel.gd +++ b/inv_system/crafting_panel.gd @@ -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: diff --git a/project.godot b/project.godot index cd87016..1ed5bc4 100644 --- a/project.godot +++ b/project.godot @@ -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]