diff --git a/README.md b/README.md index 9c89ad3..64b6863 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,8 @@ - [ ] selling things Submission day: Jan 19th 8AM + +# Maintain motivation by setting milestones and showing progress when you reach them! +1. [ ] Gettign a random assortment of loot from the ewaste bin +2. [ ] Crafting with that stuff +3. [ ] Selling the stuff diff --git a/assets/ewase bins.png b/assets/ewase bins.png new file mode 100644 index 0000000..40cbfd8 Binary files /dev/null and b/assets/ewase bins.png differ diff --git a/assets/ewase bins.png.import b/assets/ewase bins.png.import new file mode 100644 index 0000000..f026bf7 --- /dev/null +++ b/assets/ewase bins.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dj487wauiay6i" +path="res://.godot/imported/ewase bins.png-5bcc97e23130dd4c008282bb644f0d84.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ewase bins.png" +dest_files=["res://.godot/imported/ewase bins.png-5bcc97e23130dd4c008282bb644f0d84.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/demo_scene.gd b/demo_scene.gd new file mode 100644 index 0000000..c5edff8 --- /dev/null +++ b/demo_scene.gd @@ -0,0 +1,31 @@ +extends Control + +@export var bin_inventory : Inventory +@export var loot_button : Button +@export var loot_pool : Array[ItemData] + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_loot_button_pressed() -> void: + loot_button.hide() + bin_inventory.show() + bin_inventory.add_item(pick_random_item()) + bin_inventory.add_item(pick_random_item()) + bin_inventory.add_item(pick_random_item()) + bin_inventory.add_item(pick_random_item()) + bin_inventory.add_item(pick_random_item()) + bin_inventory.add_item(pick_random_item()) + bin_inventory.add_item(pick_random_item()) + bin_inventory.add_item(pick_random_item()) + +func pick_random_item() -> ItemData: + var icount = loot_pool.size() + return loot_pool[randi() % icount] diff --git a/demo_scene.gd.uid b/demo_scene.gd.uid new file mode 100644 index 0000000..9ce4b1d --- /dev/null +++ b/demo_scene.gd.uid @@ -0,0 +1 @@ +uid://dal8g1ce37r3w diff --git a/inv_system/endless_slot.gd b/inv_system/endless_slot.gd new file mode 100644 index 0000000..8f2c25b --- /dev/null +++ b/inv_system/endless_slot.gd @@ -0,0 +1,16 @@ +extends ItemSlot +# broken experiement, do not use in current state +var duplicate_item : ItemData + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + if item and not duplicate_item: + duplicate_item = item + + if duplicate_item: + item = duplicate_item diff --git a/inv_system/endless_slot.gd.uid b/inv_system/endless_slot.gd.uid new file mode 100644 index 0000000..b7a9cdf --- /dev/null +++ b/inv_system/endless_slot.gd.uid @@ -0,0 +1 @@ +uid://dtstlahhdlaqy diff --git a/inv_system/inventory.gd b/inv_system/inventory.gd index da9a3c1..a6749f0 100644 --- a/inv_system/inventory.gd +++ b/inv_system/inventory.gd @@ -1,8 +1,16 @@ extends PanelContainer +class_name Inventory +@export var inventory_name : String = "Inventory" +@export var slots : Array[ItemSlot] +@export_group("Node References") +@export var grid : GridContainer +@export var inv_label : Label # Called when the node enters the scene tree for the first time. func _ready() -> void: + slots.assign(grid.get_children()) + inv_label.text = inventory_name pass # Replace with function body. @@ -20,3 +28,15 @@ func _notification(what: int) -> void: if data_bk: data_bk.icon.show() data_bk = null + +#attempts to add the provided item to the inventory, returns true on success +func add_item(item : ItemData) -> bool: + for slot in slots: + if slot.item == null: + slot.item = item + slot.update_ui() + return true # item placed successfully + return false # theres no space to add the item + + + diff --git a/inv_system/item_slot.gd b/inv_system/item_slot.gd index 5c745bd..2f7c856 100644 --- a/inv_system/item_slot.gd +++ b/inv_system/item_slot.gd @@ -1,4 +1,5 @@ extends Panel +class_name ItemSlot @export var icon : TextureRect @export var item: ItemData diff --git a/inv_system/item_slot.tscn b/inv_system/item_slot.tscn new file mode 100644 index 0000000..d4845d2 --- /dev/null +++ b/inv_system/item_slot.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=3 format=3 uid="uid://dgqs20xf7l8c"] + +[ext_resource type="Script" uid="uid://cpd04flfh5nlc" path="res://inv_system/item_slot.gd" id="1_m11ft"] +[ext_resource type="Texture2D" uid="uid://b7jp850fqpa0j" path="res://icon.svg" id="3_0tnt0"] + +[node name="ItemSlot" type="Panel" node_paths=PackedStringArray("icon")] +custom_minimum_size = Vector2(64, 64) +script = ExtResource("1_m11ft") +icon = NodePath("Icon") + +[node name="Icon" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.1 +anchor_top = 0.1 +anchor_right = 0.8 +anchor_bottom = 0.9 +offset_right = 6.4000015 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_0tnt0") +expand_mode = 3 +stretch_mode = 4 diff --git a/test.tscn b/test.tscn index 79aea8c..9cb3316 100644 --- a/test.tscn +++ b/test.tscn @@ -1,26 +1,45 @@ -[gd_scene load_steps=6 format=3 uid="uid://dsfal3m4siap2"] +[gd_scene load_steps=8 format=3 uid="uid://dsfal3m4siap2"] [ext_resource type="Script" uid="uid://c6oycdae5wvjf" path="res://inv_system/inventory.gd" id="1_6uqi0"] -[ext_resource type="Script" uid="uid://cpd04flfh5nlc" path="res://inv_system/item_slot.gd" id="1_8uh7m"] -[ext_resource type="Texture2D" uid="uid://b7jp850fqpa0j" path="res://icon.svg" id="1_37kl0"] +[ext_resource type="Texture2D" uid="uid://dj487wauiay6i" path="res://assets/ewase bins.png" id="1_g14j6"] +[ext_resource type="Script" uid="uid://dal8g1ce37r3w" path="res://demo_scene.gd" id="1_vbegm"] +[ext_resource type="Script" uid="uid://dccraom7a7e8d" path="res://inv_system/item_data.gd" id="2_ehkex"] [ext_resource type="Resource" uid="uid://bepkdyf7dn1y0" path="res://items/hdd_item.tres" id="3_ykrsh"] [ext_resource type="Resource" uid="uid://c2wbqelme8vy1" path="res://items/ram_item.tres" id="5_g14j6"] +[ext_resource type="PackedScene" uid="uid://dgqs20xf7l8c" path="res://inv_system/item_slot.tscn" id="7_xersf"] -[node name="Control" type="Control"] +[node name="Control" type="Control" node_paths=PackedStringArray("bin_inventory", "loot_button")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +script = ExtResource("1_vbegm") +bin_inventory = NodePath("BinPanel") +loot_button = NodePath("LootButton") +loot_pool = Array[ExtResource("2_ehkex")]([ExtResource("3_ykrsh"), ExtResource("5_g14j6")]) -[node name="InventoryPanel" type="PanelContainer" parent="."] +[node name="TextureRect" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("1_g14j6") +expand_mode = 3 + +[node name="InventoryPanel" type="PanelContainer" parent="." node_paths=PackedStringArray("grid", "inv_label")] layout_mode = 0 offset_left = 51.0 offset_top = 67.0 offset_right = 403.0 offset_bottom = 549.0 script = ExtResource("1_6uqi0") +inventory_name = "Your Items" +grid = NodePath("MarginContainer/VBoxContainer/ScrollContainer/GridContainer") +inv_label = NodePath("MarginContainer/VBoxContainer/Label") [node name="MarginContainer" type="MarginContainer" parent="InventoryPanel"] layout_mode = 2 @@ -45,215 +64,129 @@ layout_mode = 2 size_flags_vertical = 3 columns = 5 -[node name="ItemSlot" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="ItemSlot" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") item = ExtResource("3_ykrsh") -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 -grow_horizontal = 2 -grow_vertical = 2 -texture = ExtResource("1_37kl0") -expand_mode = 3 -stretch_mode = 4 - -[node name="ItemSlot11" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="ItemSlot2" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") -item = ExtResource("5_g14j6") -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot11"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 -grow_horizontal = 2 -grow_vertical = 2 -texture = ExtResource("1_37kl0") -expand_mode = 3 -stretch_mode = 4 - -[node name="ItemSlot2" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="ItemSlot3" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot2"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 -grow_horizontal = 2 -grow_vertical = 2 -expand_mode = 3 -stretch_mode = 4 - -[node name="ItemSlot3" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="ItemSlot4" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot3"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 -grow_horizontal = 2 -grow_vertical = 2 -expand_mode = 3 -stretch_mode = 4 - -[node name="ItemSlot4" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="ItemSlot5" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot4"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 -grow_horizontal = 2 -grow_vertical = 2 -expand_mode = 3 -stretch_mode = 4 - -[node name="ItemSlot5" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="ItemSlot6" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot5"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 -grow_horizontal = 2 -grow_vertical = 2 -expand_mode = 3 -stretch_mode = 4 - -[node name="ItemSlot6" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="ItemSlot7" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot6"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 -grow_horizontal = 2 -grow_vertical = 2 -expand_mode = 3 -stretch_mode = 4 - -[node name="ItemSlot7" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="ItemSlot8" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot7"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 -grow_horizontal = 2 -grow_vertical = 2 -expand_mode = 3 -stretch_mode = 4 - -[node name="ItemSlot8" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="ItemSlot9" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot8"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 -grow_horizontal = 2 -grow_vertical = 2 -expand_mode = 3 -stretch_mode = 4 - -[node name="ItemSlot9" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="ItemSlot10" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot9"] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 -grow_horizontal = 2 -grow_vertical = 2 -expand_mode = 3 -stretch_mode = 4 +[node name="BinPanel" type="PanelContainer" parent="." node_paths=PackedStringArray("grid", "inv_label")] +visible = false +layout_mode = 0 +offset_left = 714.0 +offset_top = 386.0 +offset_right = 1066.0 +offset_bottom = 563.0 +script = ExtResource("1_6uqi0") +inventory_name = "E-waste Recycling Bin" +grid = NodePath("MarginContainer/VBoxContainer/ScrollContainer/GridContainer") +inv_label = NodePath("MarginContainer/VBoxContainer/Label") -[node name="ItemSlot10" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] -custom_minimum_size = Vector2(64, 64) +[node name="MarginContainer" type="MarginContainer" parent="BinPanel"] layout_mode = 2 -script = ExtResource("1_8uh7m") -icon = NodePath("Icon") +theme_override_constants/margin_left = 5 +theme_override_constants/margin_top = 5 +theme_override_constants/margin_right = 5 +theme_override_constants/margin_bottom = 5 -[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot10"] +[node name="VBoxContainer" type="VBoxContainer" parent="BinPanel/MarginContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="BinPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Inventory 1" + +[node name="ScrollContainer" type="ScrollContainer" parent="BinPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="GridContainer" type="GridContainer" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer"] +layout_mode = 2 +size_flags_vertical = 3 +columns = 5 + +[node name="ItemSlot12" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] +layout_mode = 2 + +[node name="ItemSlot13" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] +layout_mode = 2 + +[node name="ItemSlot14" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] +layout_mode = 2 + +[node name="ItemSlot15" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] +layout_mode = 2 + +[node name="ItemSlot16" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] +layout_mode = 2 + +[node name="ItemSlot17" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] +layout_mode = 2 + +[node name="ItemSlot18" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] +layout_mode = 2 + +[node name="ItemSlot19" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] +layout_mode = 2 + +[node name="ItemSlot20" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] +layout_mode = 2 + +[node name="ItemSlot21" parent="BinPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] +layout_mode = 2 + +[node name="LootButton" type="Button" parent="."] layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.1 -anchor_top = 0.1 -anchor_right = 0.8 -anchor_bottom = 0.9 -offset_right = 6.4000015 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -74.0 +offset_top = -15.5 +offset_right = 74.0 +offset_bottom = 15.5 grow_horizontal = 2 grow_vertical = 2 -expand_mode = 3 -stretch_mode = 4 +text = "Loot E-waste bins!" + +[node name="ReturnButton" type="Button" 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 = -81.0 +offset_top = -31.0 +offset_right = 81.0 +grow_horizontal = 2 +grow_vertical = 0 +text = "Return to workshop" + +[connection signal="pressed" from="LootButton" to="." method="_on_loot_button_pressed"]