Implemented ToolSlots including saving/loading, refactored layout of root scene.

main
Martin Felis 2024-09-08 14:00:02 +02:00
parent 2422f72be9
commit 188b871450
9 changed files with 669 additions and 893 deletions

View File

@ -1,9 +1,47 @@
class_name GameUI
extends Control
@onready var tool_slots = %ToolSlots
@onready var tool_container:ItemGrid = %ToolContainer
@onready var game_menu_ui = %GameMenuUI
@onready var inventory_dialog = %InventoryDialog
var picked_up_level_items:Array[NodePath] = []
var _game_scene:Node3D
var _player:Player
var _all_recipes:Array[Recipe] = []
func _ready():
for file in DirAccess.get_files_at("res://data/recipes"):
var resource_file = "res://data/recipes/" + file
var recipe:Recipe = load(resource_file) as Recipe
_all_recipes.append(recipe)
func activate_game_scene(game_scene:Node3D) -> void:
_game_scene = game_scene
if _game_scene != null:
picked_up_level_items = []
if _player != null:
disconnect_player_signals()
_player = game_scene.find_child("Player", true, false)
assert(_player != null)
update_player_signals()
tool_slots.show()
tool_container.displayStacks(_player.inventory.get_tool_item_stacks())
# When saving a game we need to know which items were picked up.
for pickup_item in get_tree().get_nodes_in_group("pickup_item"):
pickup_item.connect("item_picked_up", on_item_pickup)
game_menu_ui.hide()
var game_scene:Node3D
func _on_message_timer_timeout():
%MessagesContainer.visible = false
@ -16,6 +54,18 @@ func _on_player_trigger_message(message):
print(message)
func on_item_pickup(node_path:NodePath):
picked_up_level_items.append(node_path)
func disconnect_player_signals():
_player.disconnect("trigger_message", _on_player_trigger_message)
func update_player_signals():
_player.connect("trigger_message", _on_player_trigger_message)
func _unhandled_key_input(event:InputEvent):
var key_event:InputEventKey = event as InputEventKey
@ -29,17 +79,22 @@ func _unhandled_key_input(event:InputEvent):
func _on_game_menu_ui_visibility_changed():
# Function gets triggered when scene is still in construction. In that
# case just return.
if tool_slots == null or game_scene == null:
if tool_slots == null or _game_scene == null:
return
if %GameMenuUI.visible:
tool_slots.hide()
game_scene.process_mode = Node.PROCESS_MODE_DISABLED
_game_scene.process_mode = Node.PROCESS_MODE_DISABLED
else:
tool_slots.show()
game_scene.process_mode = Node.PROCESS_MODE_INHERIT
_game_scene.process_mode = Node.PROCESS_MODE_INHERIT
func _on_back_to_game_button_pressed():
%GameMenuUI.hide()
func _unhandled_input(event):
if event.is_action_released("toggle_inventory"):
print ("Showing inventory of player " + str(_player))
inventory_dialog.open(_all_recipes, _player.inventory)

View File

@ -50,6 +50,10 @@ func get_item_stacks() -> Array[ItemStack]:
return _content
func get_tool_item_stacks() -> Array[ItemStack]:
return _content.slice(_content.size() - 9)
func clear() -> void:
_content.clear()
_content.resize(INVENTORY_SIZE)

View File

@ -11,7 +11,7 @@ config_version=5
[application]
config/name="TinyBuildAdventure"
run/main_scene="res://scenes/main.tscn"
run/main_scene="res://root_ui.tscn"
config/features=PackedStringArray("4.2", "Forward Plus")
config/icon="res://icon.svg"

View File

@ -3,28 +3,24 @@ extends CanvasLayer
@export var startup_scene:PackedScene
@export var game_scene:PackedScene
@export var autostart_game_scene:bool = true
@onready var ui_panels:Array = [ %MainMenuUI, %NewGameUI, %GameUI, %GameMenuUI ]
@onready var active_ui_panel:Control = null
@onready var inventory_dialog:InventoryDialog = %InventoryDialog
@onready var scene = %Scene
@onready var ui_panels:Array = [ %MainMenuUI, %NewGameUI, %GameUI ]
@onready var active_ui_panel:Control = null
enum ROOT_UI_STATE { UNDEFINED, MENU, GAME }
var _root_ui_state:ROOT_UI_STATE = ROOT_UI_STATE.UNDEFINED
var _all_recipes:Array[Recipe] = []
var _player:Player = null
var current_level_resource:String
# Called when the node enters the scene tree for the first time.
func _ready():
for file in DirAccess.get_files_at("res://data/recipes"):
var resource_file = "res://data/recipes/" + file
var recipe:Recipe = load(resource_file) as Recipe
_all_recipes.append(recipe)
set_root_ui_state(ROOT_UI_STATE.GAME)
if autostart_game_scene:
load_scene(game_scene)
set_root_ui_state(ROOT_UI_STATE.GAME)
else:
set_root_ui_state(ROOT_UI_STATE.MENU)
func activate_ui_panel(ui_panel:Control):
for control in ui_panels:
@ -35,31 +31,86 @@ func activate_ui_panel(ui_panel:Control):
active_ui_panel = ui_panel
func disconnect_player_signals():
_player.disconnect("trigger_message", %GameUI._on_player_trigger_message)
func update_player_signals():
_player.connect("trigger_message", %GameUI._on_player_trigger_message)
func load_scene(scene_resource:PackedScene):
if _player:
disconnect_player_signals()
for child in scene.get_children():
child.queue_free()
child.get_parent().remove_child(child)
for scene_child in scene.get_children():
scene_child.queue_free()
scene_child.get_parent().remove_child(scene_child)
print("Loading level '" + scene_resource.resource_path + "'")
scene.add_child(scene_resource.instantiate())
current_level_resource = scene_resource.resource_path
for pickup_item in get_tree().get_nodes_in_group("pickup_item"):
pickup_item.connect("item_picked_up", get_parent().on_item_pickup)
_player = scene.find_child("Player", true, false)
if _player:
update_player_signals()
func save_game():
var player:Player = scene.find_child("Player", true, false)
if player == null:
push_error("Cannot load game: no player found!")
return
var save_game:SaveGame = SaveGame.new()
save_game.level = current_level_resource
save_game.level_pickup_items = %GameUI.picked_up_level_items
save_game.player_transform = player.global_transform
for node:Node in get_tree().get_nodes_in_group("quest_state"):
save_game.quest_states[node.name] = {}
for property in node.get_property_list():
if (property.usage & PROPERTY_USAGE_STORAGE != 0) and (property.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) != 0:
save_game.quest_states[node.name][property.name] = node.get(property.name)
for item_stack in player.inventory.get_item_stacks():
save_game.inventory.append({"item": item_stack.item, "count": item_stack.count})
ResourceSaver.save(save_game, "user://savegame.tres")
activate_ui_panel(%GameUI)
func load_game():
set_root_ui_state(RootUI.ROOT_UI_STATE.UNDEFINED)
%GameUI.picked_up_level_items.clear()
var save_game:SaveGame = load("user://savegame.tres") as SaveGame
var level_resource:PackedScene = load(save_game.level)
load_scene(level_resource)
var player:Player = scene.find_child("Player", true, false)
if player == null:
push_error("Cannot load game: no player found!")
return
print("main.gd:load_game() Player = " + str(player))
player.global_transform = save_game.player_transform
# Quest state
for node:Node in get_tree().get_nodes_in_group("quest_state"):
for property in node.get_property_list():
if (property.usage & PROPERTY_USAGE_STORAGE != 0) and (property.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) != 0:
node.set(property.name, save_game.quest_states[node.name][property.name])
# Inventory
player.inventory.clear()
var inventory_item_stacks:Array[ItemStack] = player.inventory.get_item_stacks()
assert(inventory_item_stacks.size() >= save_game.inventory.size())
for i in range(save_game.inventory.size()):
inventory_item_stacks[i].item = save_game.inventory[i]["item"]
inventory_item_stacks[i].count = save_game.inventory[i]["count"]
# Picked up items
for item_path in save_game.level_pickup_items:
if get_tree().root.has_node(item_path):
var item_node = get_tree().root.get_node(item_path)
%GameUI.picked_up_level_items.append(item_path)
item_node.queue_free()
set_root_ui_state(RootUI.ROOT_UI_STATE.GAME)
func set_root_ui_state(state:ROOT_UI_STATE):
@ -67,18 +118,18 @@ func set_root_ui_state(state:ROOT_UI_STATE):
return
if state == ROOT_UI_STATE.GAME:
load_scene(game_scene)
%GameUI.game_scene = scene.get_child(0)
%GameUI.activate_game_scene(scene.get_child(0))
activate_ui_panel(%GameUI)
else:
elif state == ROOT_UI_STATE.MENU:
load_scene(startup_scene)
%GameUI.game_scene = null
%GameMenuUI.hide()
%GameUI.activate_game_scene(null)
activate_ui_panel(%MainMenuUI)
_root_ui_state = state
func _on_start_game_button_pressed():
load_scene(game_scene)
set_root_ui_state(ROOT_UI_STATE.GAME)
@ -92,8 +143,3 @@ func _on_new_game_button_pressed():
func _to_main_menu_button_pressed():
set_root_ui_state(ROOT_UI_STATE.MENU)
func _unhandled_input(event):
if event.is_action_released("toggle_inventory"):
inventory_dialog.open(_all_recipes, _player.inventory)

517
root_ui.tscn Normal file
View File

@ -0,0 +1,517 @@
[gd_scene load_steps=11 format=3 uid="uid://c73t0nbuqp68e"]
[ext_resource type="Script" path="res://root_ui.gd" id="1_rjfed"]
[ext_resource type="PackedScene" uid="uid://bo788o53t4rbq" path="res://scenes/startup_scene.tscn" id="2_6rvtu"]
[ext_resource type="PackedScene" uid="uid://cqie4cy0uy1t0" path="res://scenes/game.tscn" id="3_2f0ju"]
[ext_resource type="Theme" uid="uid://dmk7hc81l8gbw" path="res://ui/ui_theme.tres" id="4_ipijj"]
[ext_resource type="Script" path="res://game_ui.gd" id="5_5b1gg"]
[ext_resource type="Script" path="res://ui/inventory_dialog.gd" id="6_o6qry"]
[ext_resource type="PackedScene" uid="uid://dp3fi0g53qrt2" path="res://ui/item_slot.tscn" id="7_fp7as"]
[ext_resource type="PackedScene" uid="uid://bwui4acukq4x6" path="res://ui/ItemGrid.tscn" id="8_b014e"]
[ext_resource type="Script" path="res://ui/game_menu_ui.gd" id="9_ljlw8"]
[ext_resource type="Script" path="res://ui/item_grid.gd" id="10_rnxbp"]
[node name="RootUI" type="CanvasLayer"]
unique_name_in_owner = true
script = ExtResource("1_rjfed")
startup_scene = ExtResource("2_6rvtu")
game_scene = ExtResource("3_2f0ju")
[node name="MainMenuUI" type="PanelContainer" parent="."]
unique_name_in_owner = true
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -199.0
offset_top = -134.5
offset_right = 199.0
offset_bottom = 134.5
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("4_ipijj")
[node name="MarginContainer" type="MarginContainer" parent="MainMenuUI"]
layout_mode = 2
theme_override_constants/margin_left = 60
theme_override_constants/margin_top = 60
theme_override_constants/margin_right = 60
theme_override_constants/margin_bottom = 60
[node name="VBoxContainer" type="VBoxContainer" parent="MainMenuUI/MarginContainer"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="MainMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="NewGameButton" type="Button" parent="MainMenuUI/MarginContainer/VBoxContainer/MarginContainer"]
layout_mode = 2
text = "New Game"
[node name="MarginContainer4" type="MarginContainer" parent="MainMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="OptionsButton" type="Button" parent="MainMenuUI/MarginContainer/VBoxContainer/MarginContainer4"]
layout_mode = 2
text = "Load Game
"
[node name="MarginContainer2" type="MarginContainer" parent="MainMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="OptionsButton" type="Button" parent="MainMenuUI/MarginContainer/VBoxContainer/MarginContainer2"]
layout_mode = 2
text = "Options"
[node name="MarginContainer3" type="MarginContainer" parent="MainMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="QuitButton" type="Button" parent="MainMenuUI/MarginContainer/VBoxContainer/MarginContainer3"]
layout_mode = 2
text = "Quit"
[node name="NewGameUI" type="PanelContainer" parent="."]
unique_name_in_owner = true
visible = false
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -291.0
offset_top = -144.0
offset_right = 291.0
offset_bottom = 144.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("4_ipijj")
[node name="MarginContainer" type="MarginContainer" parent="NewGameUI"]
layout_mode = 2
theme_override_constants/margin_left = 60
theme_override_constants/margin_top = 60
theme_override_constants/margin_right = 60
theme_override_constants/margin_bottom = 60
[node name="VBoxContainer" type="VBoxContainer" parent="NewGameUI/MarginContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="NewGameUI/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
text = "New Game"
[node name="MarginContainer" type="MarginContainer" parent="NewGameUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="HBoxContainer" type="HBoxContainer" parent="NewGameUI/MarginContainer/VBoxContainer/MarginContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="NewGameUI/MarginContainer/VBoxContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
text = "World Name"
[node name="WorldNameEdit" type="TextEdit" parent="NewGameUI/MarginContainer/VBoxContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.0
text = "Brave New World"
scroll_fit_content_height = true
[node name="MarginContainer2" type="MarginContainer" parent="NewGameUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="CheckBox" type="CheckBox" parent="NewGameUI/MarginContainer/VBoxContainer/MarginContainer2"]
layout_mode = 2
text = "Hardcore Mode"
[node name="MarginContainer3" type="MarginContainer" parent="NewGameUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="HBoxContainer" type="HBoxContainer" parent="NewGameUI/MarginContainer/VBoxContainer/MarginContainer3"]
layout_mode = 2
[node name="BackButton" type="Button" parent="NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer"]
layout_mode = 2
text = "Back"
[node name="Control" type="Control" parent="NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="StartGameButton" type="Button" parent="NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer"]
layout_mode = 2
text = "Start
"
[node name="GameUI" type="Control" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource("4_ipijj")
script = ExtResource("5_5b1gg")
[node name="MessagesContainer" type="MarginContainer" parent="GameUI"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -244.5
offset_right = 244.5
offset_bottom = 67.0
grow_horizontal = 2
theme_override_constants/margin_top = 32
[node name="MessageTextEdit" type="TextEdit" parent="GameUI/MessagesContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Picked Up Some Stuff !"
scroll_fit_content_height = true
[node name="MessageTimer" type="Timer" parent="GameUI/MessagesContainer"]
unique_name_in_owner = true
wait_time = 2.0
[node name="InventoryDialog" type="MarginContainer" parent="GameUI"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 40
theme_override_constants/margin_top = 82
theme_override_constants/margin_right = 40
theme_override_constants/margin_bottom = 128
script = ExtResource("6_o6qry")
slot_scene = ExtResource("7_fp7as")
[node name="Panel" type="Panel" parent="GameUI/InventoryDialog"]
layout_mode = 2
[node name="PanelContainer" type="VBoxContainer" parent="GameUI/InventoryDialog/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Title" type="HBoxContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer"]
layout_mode = 2
size_flags_vertical = 0
[node name="Label" type="Label" parent="GameUI/InventoryDialog/Panel/PanelContainer/Title"]
layout_mode = 2
size_flags_horizontal = 3
text = "Inventory"
horizontal_alignment = 1
[node name="CloseButton" type="Button" parent="GameUI/InventoryDialog/Panel/PanelContainer/Title"]
layout_mode = 2
text = " X "
[node name="CraftingUI" type="MarginContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 16
[node name="HBoxContainer" type="HBoxContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI"]
layout_mode = 2
theme_override_constants/separation = 17
[node name="Recipes" type="VBoxContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Label" type="Label" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/Recipes"]
layout_mode = 2
text = "Recipes"
[node name="RecipeList" type="ItemList" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/Recipes"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
theme = ExtResource("4_ipijj")
item_count = 2
item_0/text = "Blab"
item_1/text = "Bloobalb"
[node name="CraftIngredients" type="VBoxContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Label" type="Label" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
text = "Ingredients"
[node name="Panel" type="Panel" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
size_flags_vertical = 3
[node name="CenterContainer" type="CenterContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients/Panel"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -254.5
offset_top = -32.0
offset_right = 254.5
offset_bottom = 32.0
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 3
[node name="IngredientsContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients/Panel/CenterContainer" instance=ExtResource("8_b014e")]
unique_name_in_owner = true
layout_mode = 2
columns = 3
rows = 3
[node name="HBoxContainer" type="HBoxContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
alignment = 1
[node name="Control" type="Control" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
[node name="Label" type="Label" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.2
text = "->"
horizontal_alignment = 1
[node name="CraftResult" type="VBoxContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Label" type="Label" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult"]
layout_mode = 2
text = "Result"
[node name="Panel" type="Panel" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult"]
layout_mode = 2
size_flags_vertical = 3
[node name="CenterContainer" type="CenterContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="ResultsContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/Panel/CenterContainer" instance=ExtResource("8_b014e")]
unique_name_in_owner = true
layout_mode = 2
columns = 1
[node name="HBoxContainer" type="HBoxContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult"]
layout_mode = 2
alignment = 1
[node name="CraftButton" type="Button" parent="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Craft"
[node name="BackpackUI" type="MarginContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 16
[node name="VBoxContainer" type="VBoxContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/BackpackUI"]
layout_mode = 2
[node name="Label" type="Label" parent="GameUI/InventoryDialog/Panel/PanelContainer/BackpackUI/VBoxContainer"]
layout_mode = 2
text = "Backpack"
[node name="InventoryContainer" parent="GameUI/InventoryDialog/Panel/PanelContainer/BackpackUI/VBoxContainer" instance=ExtResource("8_b014e")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
rows = 3
[node name="GameMenuUI" type="PanelContainer" parent="GameUI"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -199.0
offset_top = -215.0
offset_right = 199.0
offset_bottom = 215.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("4_ipijj")
script = ExtResource("9_ljlw8")
[node name="MarginContainer" type="MarginContainer" parent="GameUI/GameMenuUI"]
layout_mode = 2
theme_override_constants/margin_left = 60
theme_override_constants/margin_top = 60
theme_override_constants/margin_right = 60
theme_override_constants/margin_bottom = 60
[node name="VBoxContainer" type="VBoxContainer" parent="GameUI/GameMenuUI/MarginContainer"]
layout_mode = 2
[node name="MarginContainer4" type="MarginContainer" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="SaveGameButton" type="Button" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer4"]
layout_mode = 2
text = "Save Game
"
[node name="MarginContainer6" type="MarginContainer" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="LoadGameButton" type="Button" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer6"]
layout_mode = 2
text = "Load Game
"
[node name="MarginContainer2" type="MarginContainer" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="OptionsButton" type="Button" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer2"]
layout_mode = 2
text = "Options"
[node name="MarginContainer3" type="MarginContainer" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="BackToGameButton" type="Button" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer3"]
layout_mode = 2
text = "Return to Game"
[node name="HSeparator" type="HSeparator" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="MarginContainer5" type="MarginContainer" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="ToMainMenuButton" type="Button" parent="GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer5"]
layout_mode = 2
text = "Back to Main Menu"
[node name="ToolSlots" type="MarginContainer" parent="GameUI"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -87.0
offset_top = -101.0
offset_right = 87.0
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/margin_bottom = 32
[node name="PanelContainer" type="PanelContainer" parent="GameUI/ToolSlots"]
layout_mode = 2
[node name="ToolContainer" type="GridContainer" parent="GameUI/ToolSlots/PanelContainer"]
unique_name_in_owner = true
layout_mode = 2
columns = 9
script = ExtResource("10_rnxbp")
slot_scene = ExtResource("7_fp7as")
[node name="Scene" type="Node3D" parent="."]
unique_name_in_owner = true
[connection signal="pressed" from="MainMenuUI/MarginContainer/VBoxContainer/MarginContainer/NewGameButton" to="." method="_on_new_game_button_pressed"]
[connection signal="pressed" from="MainMenuUI/MarginContainer/VBoxContainer/MarginContainer3/QuitButton" to="." method="_on_quit_button_pressed"]
[connection signal="pressed" from="NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer/BackButton" to="." method="_to_main_menu_button_pressed"]
[connection signal="pressed" from="NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer/StartGameButton" to="." method="_on_start_game_button_pressed"]
[connection signal="visibility_changed" from="GameUI" to="GameUI" method="_on_visibility_changed"]
[connection signal="timeout" from="GameUI/MessagesContainer/MessageTimer" to="GameUI" method="_on_message_timer_timeout"]
[connection signal="pressed" from="GameUI/InventoryDialog/Panel/PanelContainer/Title/CloseButton" to="GameUI/InventoryDialog" method="_on_close_button_pressed"]
[connection signal="item_selected" from="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/Recipes/RecipeList" to="GameUI/InventoryDialog" method="_on_recipe_list_item_selected"]
[connection signal="pressed" from="GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/HBoxContainer/CraftButton" to="GameUI/InventoryDialog" method="_on_craft_button_pressed"]
[connection signal="visibility_changed" from="GameUI/GameMenuUI" to="GameUI" method="_on_game_menu_ui_visibility_changed"]
[connection signal="pressed" from="GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer4/SaveGameButton" to="." method="save_game"]
[connection signal="pressed" from="GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer6/LoadGameButton" to="." method="load_game"]
[connection signal="pressed" from="GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer3/BackToGameButton" to="GameUI" method="_on_back_to_game_button_pressed"]
[connection signal="pressed" from="GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer5/ToMainMenuButton" to="." method="_to_main_menu_button_pressed"]

View File

@ -1,78 +0,0 @@
class_name Main
extends Node
@onready var message_container:Control = %MessagesContainer
@onready var message_textedit:TextEdit = %MessageTextEdit
@onready var root_ui:RootUI = %RootUI
var _picked_up_level_items:Array[NodePath] = []
func save_game():
var player:Player = find_child("Player", true, false)
if player == null:
push_error("Cannot load game: no player found!")
return
var save_game:SaveGame = SaveGame.new()
save_game.level = root_ui.current_level_resource
save_game.level_pickup_items = _picked_up_level_items
save_game.player_transform = player.global_transform
for node:Node in get_tree().get_nodes_in_group("quest_state"):
save_game.quest_states[node.name] = {}
for property in node.get_property_list():
if (property.usage & PROPERTY_USAGE_STORAGE != 0) and (property.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) != 0:
save_game.quest_states[node.name][property.name] = node.get(property.name)
for item_stack in player.inventory.get_item_stacks():
save_game.inventory.append({"item": item_stack.item, "count": item_stack.count})
ResourceSaver.save(save_game, "user://savegame.tres")
root_ui.activate_ui_panel(%GameUI)
func load_game():
_picked_up_level_items.clear()
var save_game:SaveGame = load("user://savegame.tres") as SaveGame
var level_resource:PackedScene = load(save_game.level)
root_ui.load_scene(level_resource)
var player:Player = find_child("Player", true, false)
if player == null:
push_error("Cannot load game: no player found!")
return
player.global_transform = save_game.player_transform
# Quest state
for node:Node in get_tree().get_nodes_in_group("quest_state"):
for property in node.get_property_list():
if (property.usage & PROPERTY_USAGE_STORAGE != 0) and (property.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) != 0:
node.set(property.name, save_game.quest_states[node.name][property.name])
# Inventory
player.inventory.clear()
var inventory_item_stacks:Array[ItemStack] = player.inventory.get_item_stacks()
assert(inventory_item_stacks.size() >= save_game.inventory.size())
for i in range(save_game.inventory.size()):
inventory_item_stacks[i].item = save_game.inventory[i]["item"]
inventory_item_stacks[i].count = save_game.inventory[i]["count"]
# Picked up items
for item_path in save_game.level_pickup_items:
if get_tree().root.has_node(item_path):
var item_node = get_tree().root.get_node(item_path)
_picked_up_level_items.append(item_path)
item_node.queue_free()
root_ui.activate_ui_panel(%GameUI)
func on_item_pickup(node_path:NodePath):
_picked_up_level_items.append(node_path)

View File

@ -1,519 +0,0 @@
[gd_scene load_steps=13 format=3 uid="uid://ck104ww8vi7f1"]
[ext_resource type="Script" path="res://scenes/main.gd" id="1_yidnr"]
[ext_resource type="PackedScene" uid="uid://bo788o53t4rbq" path="res://scenes/startup_scene.tscn" id="2_imuae"]
[ext_resource type="PackedScene" uid="uid://cqie4cy0uy1t0" path="res://scenes/game.tscn" id="2_o3qua"]
[ext_resource type="PackedScene" uid="uid://nob4ibnp0p5u" path="res://ui/tool_container.tscn" id="11_yj24a"]
[ext_resource type="Script" path="res://ui/tool_container.gd" id="12_duobv"]
[ext_resource type="Script" path="res://root_ui.gd" id="13_h24kl"]
[ext_resource type="Theme" uid="uid://dmk7hc81l8gbw" path="res://ui/ui_theme.tres" id="14_bvivl"]
[ext_resource type="Script" path="res://game_ui.gd" id="15_g7bf1"]
[ext_resource type="Script" path="res://ui/inventory_dialog.gd" id="16_18k4v"]
[ext_resource type="PackedScene" uid="uid://dp3fi0g53qrt2" path="res://ui/item_slot.tscn" id="17_rucv3"]
[ext_resource type="PackedScene" uid="uid://bwui4acukq4x6" path="res://ui/ItemGrid.tscn" id="18_fihac"]
[ext_resource type="Script" path="res://ui/game_menu_ui.gd" id="19_krapk"]
[node name="Main" type="Node"]
script = ExtResource("1_yidnr")
[node name="RootUI" type="CanvasLayer" parent="."]
unique_name_in_owner = true
script = ExtResource("13_h24kl")
startup_scene = ExtResource("2_imuae")
game_scene = ExtResource("2_o3qua")
[node name="MainMenuUI" type="PanelContainer" parent="RootUI"]
unique_name_in_owner = true
visible = false
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -199.0
offset_top = -134.5
offset_right = 199.0
offset_bottom = 134.5
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("14_bvivl")
[node name="MarginContainer" type="MarginContainer" parent="RootUI/MainMenuUI"]
layout_mode = 2
theme_override_constants/margin_left = 60
theme_override_constants/margin_top = 60
theme_override_constants/margin_right = 60
theme_override_constants/margin_bottom = 60
[node name="VBoxContainer" type="VBoxContainer" parent="RootUI/MainMenuUI/MarginContainer"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="RootUI/MainMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="NewGameButton" type="Button" parent="RootUI/MainMenuUI/MarginContainer/VBoxContainer/MarginContainer"]
layout_mode = 2
text = "New Game"
[node name="MarginContainer4" type="MarginContainer" parent="RootUI/MainMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="OptionsButton" type="Button" parent="RootUI/MainMenuUI/MarginContainer/VBoxContainer/MarginContainer4"]
layout_mode = 2
text = "Load Game
"
[node name="MarginContainer2" type="MarginContainer" parent="RootUI/MainMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="OptionsButton" type="Button" parent="RootUI/MainMenuUI/MarginContainer/VBoxContainer/MarginContainer2"]
layout_mode = 2
text = "Options"
[node name="MarginContainer3" type="MarginContainer" parent="RootUI/MainMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="QuitButton" type="Button" parent="RootUI/MainMenuUI/MarginContainer/VBoxContainer/MarginContainer3"]
layout_mode = 2
text = "Quit"
[node name="NewGameUI" type="PanelContainer" parent="RootUI"]
unique_name_in_owner = true
visible = false
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -291.0
offset_top = -144.0
offset_right = 291.0
offset_bottom = 144.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("14_bvivl")
[node name="MarginContainer" type="MarginContainer" parent="RootUI/NewGameUI"]
layout_mode = 2
theme_override_constants/margin_left = 60
theme_override_constants/margin_top = 60
theme_override_constants/margin_right = 60
theme_override_constants/margin_bottom = 60
[node name="VBoxContainer" type="VBoxContainer" parent="RootUI/NewGameUI/MarginContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
text = "New Game"
[node name="MarginContainer" type="MarginContainer" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="HBoxContainer" type="HBoxContainer" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
text = "World Name"
[node name="WorldNameEdit" type="TextEdit" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.0
text = "Brave New World"
scroll_fit_content_height = true
[node name="MarginContainer2" type="MarginContainer" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="CheckBox" type="CheckBox" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer2"]
layout_mode = 2
text = "Hardcore Mode"
[node name="MarginContainer3" type="MarginContainer" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="HBoxContainer" type="HBoxContainer" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer3"]
layout_mode = 2
[node name="BackButton" type="Button" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer"]
layout_mode = 2
text = "Back"
[node name="Control" type="Control" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="StartGameButton" type="Button" parent="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer"]
layout_mode = 2
text = "Start
"
[node name="GameUI" type="Control" parent="RootUI"]
unique_name_in_owner = true
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource("14_bvivl")
script = ExtResource("15_g7bf1")
[node name="MessagesContainer" type="MarginContainer" parent="RootUI/GameUI"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -244.5
offset_right = 244.5
offset_bottom = 67.0
grow_horizontal = 2
theme_override_constants/margin_top = 32
[node name="MessageTextEdit" type="TextEdit" parent="RootUI/GameUI/MessagesContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Picked Up Some Stuff !"
scroll_fit_content_height = true
[node name="MessageTimer" type="Timer" parent="RootUI/GameUI/MessagesContainer"]
unique_name_in_owner = true
wait_time = 2.0
[node name="InventoryDialog" type="MarginContainer" parent="RootUI/GameUI"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 40
theme_override_constants/margin_top = 82
theme_override_constants/margin_right = 40
theme_override_constants/margin_bottom = 128
script = ExtResource("16_18k4v")
slot_scene = ExtResource("17_rucv3")
[node name="Panel" type="Panel" parent="RootUI/GameUI/InventoryDialog"]
layout_mode = 2
[node name="PanelContainer" type="VBoxContainer" parent="RootUI/GameUI/InventoryDialog/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Title" type="HBoxContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer"]
layout_mode = 2
size_flags_vertical = 0
[node name="Label" type="Label" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/Title"]
layout_mode = 2
size_flags_horizontal = 3
text = "Inventory"
horizontal_alignment = 1
[node name="CloseButton" type="Button" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/Title"]
layout_mode = 2
text = " X "
[node name="CraftingUI" type="MarginContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 16
[node name="HBoxContainer" type="HBoxContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI"]
layout_mode = 2
theme_override_constants/separation = 17
[node name="Recipes" type="VBoxContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Label" type="Label" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/Recipes"]
layout_mode = 2
text = "Recipes"
[node name="RecipeList" type="ItemList" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/Recipes"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
theme = ExtResource("14_bvivl")
item_count = 2
item_0/text = "Blab"
item_1/text = "Bloobalb"
[node name="CraftIngredients" type="VBoxContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Label" type="Label" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
text = "Ingredients"
[node name="Panel" type="Panel" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
size_flags_vertical = 3
[node name="CenterContainer" type="CenterContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients/Panel"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -254.5
offset_top = -32.0
offset_right = 254.5
offset_bottom = 32.0
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 3
[node name="IngredientsContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients/Panel/CenterContainer" instance=ExtResource("18_fihac")]
unique_name_in_owner = true
layout_mode = 2
columns = 3
rows = 3
[node name="HBoxContainer" type="HBoxContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
alignment = 1
[node name="Control" type="Control" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
[node name="Label" type="Label" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.2
text = "->"
horizontal_alignment = 1
[node name="CraftResult" type="VBoxContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Label" type="Label" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult"]
layout_mode = 2
text = "Result"
[node name="Panel" type="Panel" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult"]
layout_mode = 2
size_flags_vertical = 3
[node name="CenterContainer" type="CenterContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="ResultsContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/Panel/CenterContainer" instance=ExtResource("18_fihac")]
unique_name_in_owner = true
layout_mode = 2
columns = 1
[node name="HBoxContainer" type="HBoxContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult"]
layout_mode = 2
alignment = 1
[node name="CraftButton" type="Button" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Craft"
[node name="BackpackUI" type="MarginContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 16
[node name="VBoxContainer" type="VBoxContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/BackpackUI"]
layout_mode = 2
[node name="Label" type="Label" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/BackpackUI/VBoxContainer"]
layout_mode = 2
text = "Backpack"
[node name="InventoryContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/BackpackUI/VBoxContainer" instance=ExtResource("18_fihac")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
rows = 3
[node name="GameMenuUI" type="PanelContainer" parent="RootUI/GameUI"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -199.0
offset_top = -215.0
offset_right = 199.0
offset_bottom = 215.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("14_bvivl")
script = ExtResource("19_krapk")
[node name="MarginContainer" type="MarginContainer" parent="RootUI/GameUI/GameMenuUI"]
layout_mode = 2
theme_override_constants/margin_left = 60
theme_override_constants/margin_top = 60
theme_override_constants/margin_right = 60
theme_override_constants/margin_bottom = 60
[node name="VBoxContainer" type="VBoxContainer" parent="RootUI/GameUI/GameMenuUI/MarginContainer"]
layout_mode = 2
[node name="MarginContainer4" type="MarginContainer" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="SaveGameButton" type="Button" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer4"]
layout_mode = 2
text = "Save Game
"
[node name="MarginContainer6" type="MarginContainer" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="LoadGameButton" type="Button" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer6"]
layout_mode = 2
text = "Load Game
"
[node name="MarginContainer2" type="MarginContainer" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="OptionsButton" type="Button" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer2"]
layout_mode = 2
text = "Options"
[node name="MarginContainer3" type="MarginContainer" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="BackToGameButton" type="Button" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer3"]
layout_mode = 2
text = "Return to Game"
[node name="HSeparator" type="HSeparator" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="MarginContainer5" type="MarginContainer" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="ToMainMenuButton" type="Button" parent="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer5"]
layout_mode = 2
text = "Back to Main Menu"
[node name="ToolSlots" type="MarginContainer" parent="RootUI/GameUI"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -87.0
offset_top = -101.0
offset_right = 87.0
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/margin_bottom = 32
[node name="PanelContainer" type="PanelContainer" parent="RootUI/GameUI/ToolSlots"]
layout_mode = 2
[node name="ToolContainer" parent="RootUI/GameUI/ToolSlots/PanelContainer" instance=ExtResource("11_yj24a")]
layout_mode = 2
script = ExtResource("12_duobv")
slot_scene = ExtResource("17_rucv3")
[node name="Scene" type="Node3D" parent="."]
unique_name_in_owner = true
[connection signal="pressed" from="RootUI/MainMenuUI/MarginContainer/VBoxContainer/MarginContainer/NewGameButton" to="RootUI" method="_on_new_game_button_pressed"]
[connection signal="pressed" from="RootUI/MainMenuUI/MarginContainer/VBoxContainer/MarginContainer3/QuitButton" to="RootUI" method="_on_quit_button_pressed"]
[connection signal="pressed" from="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer/BackButton" to="RootUI" method="_to_main_menu_button_pressed"]
[connection signal="pressed" from="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer/StartGameButton" to="RootUI" method="_on_start_game_button_pressed"]
[connection signal="timeout" from="RootUI/GameUI/MessagesContainer/MessageTimer" to="RootUI/GameUI" method="_on_message_timer_timeout"]
[connection signal="pressed" from="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/Title/CloseButton" to="RootUI/GameUI/InventoryDialog" method="_on_close_button_pressed"]
[connection signal="item_selected" from="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/Recipes/RecipeList" to="RootUI/GameUI/InventoryDialog" method="_on_recipe_list_item_selected"]
[connection signal="pressed" from="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/HBoxContainer/CraftButton" to="RootUI/GameUI/InventoryDialog" method="_on_craft_button_pressed"]
[connection signal="visibility_changed" from="RootUI/GameUI/GameMenuUI" to="RootUI/GameUI" method="_on_game_menu_ui_visibility_changed"]
[connection signal="pressed" from="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer4/SaveGameButton" to="." method="save_game"]
[connection signal="pressed" from="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer6/LoadGameButton" to="." method="load_game"]
[connection signal="pressed" from="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer3/BackToGameButton" to="RootUI/GameUI" method="_on_back_to_game_button_pressed"]
[connection signal="pressed" from="RootUI/GameUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer5/ToMainMenuButton" to="RootUI" method="_to_main_menu_button_pressed"]

View File

@ -1,248 +0,0 @@
[gd_scene load_steps=9 format=3 uid="uid://cqmnmqjsutedj"]
[ext_resource type="Theme" uid="uid://dmk7hc81l8gbw" path="res://ui/ui_theme.tres" id="1_xu30n"]
[ext_resource type="Script" path="res://game_ui.gd" id="2_vb3s6"]
[ext_resource type="Texture2D" uid="uid://c7fu3paj3b4e8" path="res://assets/3rdparty/kenney/ui-pack-rpg-expansion/PNG/cursorSword_silver.png" id="3_vepel"]
[ext_resource type="Texture2D" uid="uid://drpl0ql1p3pfk" path="res://assets/3rdparty/kenney/ui-pack-rpg-expansion/PNG/cursorSword_gold.png" id="4_ijjgh"]
[ext_resource type="Texture2D" uid="uid://cq8ypeagpedq" path="res://assets/3rdparty/kenney/ui-pack-rpg-expansion/PNG/cursorSword_bronze.png" id="5_4e7rh"]
[ext_resource type="Script" path="res://ui/inventory_dialog.gd" id="6_lssx5"]
[ext_resource type="PackedScene" uid="uid://dp3fi0g53qrt2" path="res://ui/item_slot.tscn" id="7_2r38a"]
[ext_resource type="PackedScene" uid="uid://bwui4acukq4x6" path="res://ui/ItemGrid.tscn" id="8_igemi"]
[node name="GameUI" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource("1_xu30n")
script = ExtResource("2_vb3s6")
[node name="ToolSlots" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -67.0
offset_top = -77.0
offset_right = 67.0
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/margin_bottom = 32
[node name="PanelContainer" type="PanelContainer" parent="ToolSlots"]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="ToolSlots/PanelContainer"]
layout_mode = 2
[node name="Button2" type="Button" parent="ToolSlots/PanelContainer/HBoxContainer"]
layout_mode = 2
icon = ExtResource("3_vepel")
[node name="Button3" type="Button" parent="ToolSlots/PanelContainer/HBoxContainer"]
layout_mode = 2
icon = ExtResource("4_ijjgh")
[node name="Button" type="Button" parent="ToolSlots/PanelContainer/HBoxContainer"]
layout_mode = 2
icon = ExtResource("5_4e7rh")
[node name="MessagesContainer" type="MarginContainer" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -244.5
offset_right = 244.5
offset_bottom = 67.0
grow_horizontal = 2
theme_override_constants/margin_top = 32
[node name="MessageTextEdit" type="TextEdit" parent="MessagesContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Picked Up Some Stuff !"
scroll_fit_content_height = true
[node name="MessageTimer" type="Timer" parent="MessagesContainer"]
unique_name_in_owner = true
wait_time = 2.0
[node name="InventoryDialog" type="MarginContainer" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 40
theme_override_constants/margin_top = 82
theme_override_constants/margin_right = 40
theme_override_constants/margin_bottom = 128
script = ExtResource("6_lssx5")
slot_scene = ExtResource("7_2r38a")
[node name="Panel" type="Panel" parent="InventoryDialog"]
layout_mode = 2
[node name="PanelContainer" type="VBoxContainer" parent="InventoryDialog/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Title" type="HBoxContainer" parent="InventoryDialog/Panel/PanelContainer"]
layout_mode = 2
size_flags_vertical = 0
[node name="Label" type="Label" parent="InventoryDialog/Panel/PanelContainer/Title"]
layout_mode = 2
size_flags_horizontal = 3
text = "Inventory"
horizontal_alignment = 1
[node name="CloseButton" type="Button" parent="InventoryDialog/Panel/PanelContainer/Title"]
layout_mode = 2
text = " X "
[node name="CraftingUI" type="MarginContainer" parent="InventoryDialog/Panel/PanelContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 16
[node name="HBoxContainer" type="HBoxContainer" parent="InventoryDialog/Panel/PanelContainer/CraftingUI"]
layout_mode = 2
theme_override_constants/separation = 17
[node name="Recipes" type="VBoxContainer" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Label" type="Label" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/Recipes"]
layout_mode = 2
text = "Recipes"
[node name="RecipeList" type="ItemList" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/Recipes"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
theme = ExtResource("1_xu30n")
item_count = 2
item_0/text = "Blab"
item_1/text = "Bloobalb"
[node name="CraftIngredients" type="VBoxContainer" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Label" type="Label" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
text = "Ingredients"
[node name="Panel" type="Panel" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
size_flags_vertical = 3
[node name="CenterContainer" type="CenterContainer" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients/Panel"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -254.5
offset_top = -32.0
offset_right = 254.5
offset_bottom = 32.0
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 3
[node name="IngredientsContainer" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients/Panel/CenterContainer" instance=ExtResource("8_igemi")]
unique_name_in_owner = true
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
alignment = 1
[node name="Control" type="Control" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftIngredients"]
layout_mode = 2
[node name="Label" type="Label" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.2
text = "->"
horizontal_alignment = 1
[node name="CraftResult" type="VBoxContainer" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Label" type="Label" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult"]
layout_mode = 2
text = "Result"
[node name="Panel" type="Panel" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult"]
layout_mode = 2
size_flags_vertical = 3
[node name="CenterContainer" type="CenterContainer" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="ResultsContainer" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/Panel/CenterContainer" instance=ExtResource("8_igemi")]
unique_name_in_owner = true
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult"]
layout_mode = 2
alignment = 1
[node name="CraftButton" type="Button" parent="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Craft"
[node name="BackpackUI" type="MarginContainer" parent="InventoryDialog/Panel/PanelContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 16
[node name="VBoxContainer" type="VBoxContainer" parent="InventoryDialog/Panel/PanelContainer/BackpackUI"]
layout_mode = 2
[node name="Label" type="Label" parent="InventoryDialog/Panel/PanelContainer/BackpackUI/VBoxContainer"]
layout_mode = 2
text = "Backpack"
[node name="InventoryContainer" parent="InventoryDialog/Panel/PanelContainer/BackpackUI/VBoxContainer" instance=ExtResource("8_igemi")]
unique_name_in_owner = true
layout_mode = 2
[connection signal="timeout" from="MessagesContainer/MessageTimer" to="." method="_on_message_timer_timeout"]
[connection signal="pressed" from="InventoryDialog/Panel/PanelContainer/Title/CloseButton" to="InventoryDialog" method="_on_close_button_pressed"]
[connection signal="item_selected" from="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/Recipes/RecipeList" to="InventoryDialog" method="_on_recipe_list_item_selected"]
[connection signal="pressed" from="InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/HBoxContainer/CraftButton" to="InventoryDialog" method="_on_craft_button_pressed"]

View File

@ -1 +0,0 @@
extends Node3D