From 250ab93c1518308de97b84dfc4c8a46b6eb8b796 Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Fri, 10 Feb 2023 00:25:46 +0100 Subject: [PATCH] inventory soort van --- GUI-item.tscn | 20 ++++++++++++++ GUI.tscn | 61 ++++++++++++++++++++++++++++++++++++++++++ Kamer.tscn | 51 ++--------------------------------- Scripts/GUI-item.gd | 8 ++++++ Scripts/Gui.gd | 12 +++++++++ Scripts/Slot.gd | 1 + Scripts/ladekast.gd | 1 + Scripts/lichtkastje.gd | 1 + 8 files changed, 106 insertions(+), 49 deletions(-) create mode 100644 GUI-item.tscn create mode 100644 GUI.tscn create mode 100644 Scripts/GUI-item.gd diff --git a/GUI-item.tscn b/GUI-item.tscn new file mode 100644 index 0000000..f1babb5 --- /dev/null +++ b/GUI-item.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=2 format=3 uid="uid://b71qdaj8exhbs"] + +[ext_resource type="Script" path="res://Scripts/GUI-item.gd" id="1_5hhdw"] + +[node name="SubViewportContainer" type="SubViewportContainer"] +script = ExtResource("1_5hhdw") + +[node name="SubViewport" type="SubViewport" parent="."] +own_world_3d = true +transparent_bg = true +handle_input_locally = false +size = Vector2i(100, 100) +render_target_update_mode = 4 + +[node name="Camera3D" type="Camera3D" parent="SubViewport"] + +[node name="Item Position" type="Node3D" parent="SubViewport/Camera3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.25) + +[node name="OmniLight3D" type="OmniLight3D" parent="SubViewport/Camera3D"] diff --git a/GUI.tscn b/GUI.tscn new file mode 100644 index 0000000..8d7ebc7 --- /dev/null +++ b/GUI.tscn @@ -0,0 +1,61 @@ +[gd_scene load_steps=2 format=3 uid="uid://d2run4kti7u53"] + +[ext_resource type="Script" path="res://Scripts/Gui.gd" id="1_nawr5"] + +[node name="Gui" type="CanvasLayer"] +script = ExtResource("1_nawr5") + +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +metadata/_edit_use_anchors_ = true + +[node name="BottleService" type="VFlowContainer" parent="Control"] +layout_mode = 1 +anchors_preset = 11 +anchor_left = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -200.0 +grow_horizontal = 0 +grow_vertical = 2 +size_flags_horizontal = 8 +size_flags_vertical = 8 +alignment = 2 + +[node name="Panel" type="Panel" parent="Control/BottleService"] +visible = false +custom_minimum_size = Vector2(200, 100) +layout_mode = 2 + +[node name="RichTextLabel" type="RichTextLabel" parent="Control/BottleService/Panel"] +custom_minimum_size = Vector2(200, 100) +layout_mode = 2 +offset_top = 4.0 +offset_right = 200.0 +offset_bottom = 104.0 +text = "Je moeder" + +[node name="Button" type="Button" parent="Control/BottleService/Panel/RichTextLabel"] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -22.0 +offset_bottom = 31.0 +grow_horizontal = 0 +text = "✕" + +[node name="HFlowContainer" type="HFlowContainer" parent="Control"] +layout_mode = 1 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_top = -100.0 +offset_right = 1000.0 +grow_vertical = 0 diff --git a/Kamer.tscn b/Kamer.tscn index 25bf3ea..7f2b844 100644 --- a/Kamer.tscn +++ b/Kamer.tscn @@ -18,7 +18,7 @@ [ext_resource type="AudioStream" uid="uid://wphketv7cs0b" path="res://Audio/D.mp3" id="15_k8hy3"] [ext_resource type="AudioStream" uid="uid://csa4bd0pvp5as" path="res://Audio/pianomuziek.mp3" id="17_1cw2k"] [ext_resource type="FontFile" uid="uid://ba6teo1asddxo" path="res://Fonts/Galimer-ExtraLight.ttf" id="17_7yj1s"] -[ext_resource type="Script" path="res://Scripts/Gui.gd" id="18_80vxw"] +[ext_resource type="PackedScene" uid="uid://d2run4kti7u53" path="res://GUI.tscn" id="19_3ubs2"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4hp81"] transparency = 1 @@ -288,53 +288,6 @@ stream = ExtResource("17_1cw2k") volume_db = -6.191 autoplay = true -[node name="Gui" type="CanvasLayer" parent="." index="18"] -script = ExtResource("18_80vxw") - -[node name="Control" type="Control" parent="Gui" index="0"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 -metadata/_edit_use_anchors_ = true - -[node name="BottleService" type="VFlowContainer" parent="Gui/Control" index="0"] -layout_mode = 1 -anchors_preset = 11 -anchor_left = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = -200.0 -grow_horizontal = 0 -grow_vertical = 2 -size_flags_horizontal = 8 -size_flags_vertical = 8 -alignment = 2 - -[node name="Panel" type="Panel" parent="Gui/Control/BottleService" index="0"] -visible = false -custom_minimum_size = Vector2(200, 100) -layout_mode = 2 - -[node name="RichTextLabel" type="RichTextLabel" parent="Gui/Control/BottleService/Panel" index="0"] -custom_minimum_size = Vector2(200, 100) -layout_mode = 2 -offset_top = 4.0 -offset_right = 200.0 -offset_bottom = 104.0 -text = "Je moeder" - -[node name="Button" type="Button" parent="Gui/Control/BottleService/Panel/RichTextLabel" index="1"] -layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -22.0 -offset_bottom = 31.0 -grow_horizontal = 0 -text = "✕" +[node name="Gui" parent="." index="18" instance=ExtResource("19_3ubs2")] [connection signal="input_event" from="FlashLight/FlashLight" to="Player" method="_on_flash_light_input_event"] diff --git a/Scripts/GUI-item.gd b/Scripts/GUI-item.gd new file mode 100644 index 0000000..9dcbe93 --- /dev/null +++ b/Scripts/GUI-item.gd @@ -0,0 +1,8 @@ +extends SubViewportContainer + +func add_item(mesh: Node): + $"SubViewport/Camera3D/Item Position".add_child(mesh) + +func _process(delta): + if $"SubViewport/Camera3D/Item Position".get_child_count() > 0: + $"SubViewport/Camera3D/Item Position".get_child(0).rotation.y += delta diff --git a/Scripts/Gui.gd b/Scripts/Gui.gd index 52d9180..ce3915c 100644 --- a/Scripts/Gui.gd +++ b/Scripts/Gui.gd @@ -28,6 +28,18 @@ func message(msg: String, title: String = ""): func _process(delta): timer += delta + #$"Control/HFlowContainer/SubViewportContainer/SubViewport/Camera3D/Item Position".get_child(0).rotation.y += delta + #$Control/SubViewportContainer/SubViewport/Camera3D/sleutel.rotation.y += delta +func add_item(mesh: Node): + var subviewport = preload("res://GUI-item.tscn").instantiate() + $Control/HFlowContainer.add_child(subviewport) + subviewport.add_item(mesh) + print_tree() + +func clear_items(): + for child in $Control/HFlowContainer.get_children(): + child.queue_free() + func _on_close_pressed(node): node.get_parent().queue_free() diff --git a/Scripts/Slot.gd b/Scripts/Slot.gd index 8be317a..54f6c80 100644 --- a/Scripts/Slot.gd +++ b/Scripts/Slot.gd @@ -4,6 +4,7 @@ var combination func _ready(): combination = randi() % 10000 + print(combination) $".."/CombiCode.mesh.text = "%04d" % combination #met leading 0'en func get_number(): diff --git a/Scripts/ladekast.gd b/Scripts/ladekast.gd index e49478b..e67f168 100644 --- a/Scripts/ladekast.gd +++ b/Scripts/ladekast.gd @@ -20,3 +20,4 @@ func _on_sleutel_input_event(_camera, event, _position, _normal, _shape_idx): $Kast/Drawer/Sleutel.visible = false get_node("../Player").has_key = true get_node("../Player/Pickup").playing = true + $"../Gui".add_item(preload("res://Objects/sleutel.tscn").instantiate()) diff --git a/Scripts/lichtkastje.gd b/Scripts/lichtkastje.gd index a99ad7d..43bb463 100644 --- a/Scripts/lichtkastje.gd +++ b/Scripts/lichtkastje.gd @@ -14,6 +14,7 @@ func _on_lock_input_event(_camera, event, _position, _normal, _shape_idx): $Deur.visible = false $Lock.visible = false $Lock/DeurOpen.playing = true + $"../Gui".clear_items() func _on_lever_input_event(_camera, event, _position, _normal, _shape_idx):