diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f28239b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +charset = utf-8 diff --git a/.gitattributes b/.gitattributes index dfe0770..8ad74f7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ -# Auto detect text files and perform LF normalization -* text=auto +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore index 50335d9..0af181c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,3 @@ # Godot 4+ specific ignores .godot/ -.nomedia - -# Godot-specific ignores -.import/ -export.cfg -export_credentials.cfg - -# Imported translations (automatically generated from CSV files) -*.translation - -# Mono-specific ignores -.mono/ -data_*/ -mono_crash.*.json +/android/ diff --git a/README.md b/README.md index 3688f37..9c89ad3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ # RepurposedJam +- used this tutorial for the basic inventory starter: https://www.youtube.com/watch?v=JUR1qQ79eJY + +## Todo +- [ ] make my own better tooltips +- [ ] border for currently hovered slot +- [ ] saving and loading inventory/game? +- [ ] crafting system (3x3 inventory with shaped recipies) +- [ ] loot system (provides random assortment of items from the ewaste bin) +- [ ] selling things + +Submission day: Jan 19th 8AM diff --git a/assets/hdd.png b/assets/hdd.png new file mode 100644 index 0000000..6532602 Binary files /dev/null and b/assets/hdd.png differ diff --git a/assets/hdd.png.import b/assets/hdd.png.import new file mode 100644 index 0000000..ff12989 --- /dev/null +++ b/assets/hdd.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c1ja7ug8bkxne" +path="res://.godot/imported/hdd.png-c14328920d63cd2455593c266c0e1877.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/hdd.png" +dest_files=["res://.godot/imported/hdd.png-c14328920d63cd2455593c266c0e1877.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/assets/ram.png b/assets/ram.png new file mode 100644 index 0000000..64d873f Binary files /dev/null and b/assets/ram.png differ diff --git a/assets/ram.png.import b/assets/ram.png.import new file mode 100644 index 0000000..c62363f --- /dev/null +++ b/assets/ram.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dquer6m8lapux" +path="res://.godot/imported/ram.png-c6c16747428068ac97ec4acf800fb111.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ram.png" +dest_files=["res://.godot/imported/ram.png-c6c16747428068ac97ec4acf800fb111.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/icon.svg b/icon.svg new file mode 100644 index 0000000..c6bbb7d --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..2940f96 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b7jp850fqpa0j" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/inv_system/inventory.gd b/inv_system/inventory.gd new file mode 100644 index 0000000..da9a3c1 --- /dev/null +++ b/inv_system/inventory.gd @@ -0,0 +1,22 @@ +extends PanelContainer + + +# 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 Input.get_current_cursor_shape() == CURSOR_FORBIDDEN: + DisplayServer.cursor_set_shape(DisplayServer.CURSOR_ARROW) + +var data_bk +func _notification(what: int) -> void: + if what == Node.NOTIFICATION_DRAG_BEGIN: + data_bk = get_viewport().gui_get_drag_data() + if what == Node.NOTIFICATION_DRAG_END: + if not is_drag_successful(): + if data_bk: + data_bk.icon.show() + data_bk = null diff --git a/inv_system/inventory.gd.uid b/inv_system/inventory.gd.uid new file mode 100644 index 0000000..10f3092 --- /dev/null +++ b/inv_system/inventory.gd.uid @@ -0,0 +1 @@ +uid://c6oycdae5wvjf diff --git a/inv_system/item_data.gd b/inv_system/item_data.gd new file mode 100644 index 0000000..a6c7b43 --- /dev/null +++ b/inv_system/item_data.gd @@ -0,0 +1,5 @@ +extends Resource +class_name ItemData + +@export var item_name : String +@export var icon : Texture2D diff --git a/inv_system/item_data.gd.uid b/inv_system/item_data.gd.uid new file mode 100644 index 0000000..b60e5c0 --- /dev/null +++ b/inv_system/item_data.gd.uid @@ -0,0 +1 @@ +uid://dccraom7a7e8d diff --git a/inv_system/item_slot.gd b/inv_system/item_slot.gd new file mode 100644 index 0000000..5c745bd --- /dev/null +++ b/inv_system/item_slot.gd @@ -0,0 +1,41 @@ +extends Panel + +@export var icon : TextureRect +@export var item: ItemData + +func _ready() -> void: + update_ui() + +func update_ui(): + if not item: + icon.texture = null + return + + icon.texture = item.icon + tooltip_text = item.item_name + +func _get_drag_data(at_position: Vector2) -> Variant: + if not item: + return + + var preview = duplicate() + var c = Control.new() + c.add_child(preview) + preview.position -= Vector2(32,32) + preview.self_modulate = Color.TRANSPARENT + c.modulate = Color(c.modulate,0.5) + set_drag_preview(c) + icon.hide() + return self + +func _can_drop_data(at_position: Vector2, data: Variant) -> bool: + return true + +func _drop_data(at_position: Vector2, data: Variant) -> void: + var temp = item + item = data.item + data.item = temp + icon.show() + data.icon.show() + update_ui() + data.update_ui() diff --git a/inv_system/item_slot.gd.uid b/inv_system/item_slot.gd.uid new file mode 100644 index 0000000..43b5705 --- /dev/null +++ b/inv_system/item_slot.gd.uid @@ -0,0 +1 @@ +uid://cpd04flfh5nlc diff --git a/items/hdd_item.tres b/items/hdd_item.tres new file mode 100644 index 0000000..0797b40 --- /dev/null +++ b/items/hdd_item.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" script_class="ItemData" load_steps=3 format=3 uid="uid://bepkdyf7dn1y0"] + +[ext_resource type="Texture2D" uid="uid://c1ja7ug8bkxne" path="res://assets/hdd.png" id="1_8xwf0"] +[ext_resource type="Script" uid="uid://dccraom7a7e8d" path="res://inv_system/item_data.gd" id="1_r24a6"] + +[resource] +script = ExtResource("1_r24a6") +item_name = "Hard Disk Drive" +icon = ExtResource("1_8xwf0") +metadata/_custom_type_script = "uid://dccraom7a7e8d" diff --git a/items/ram_item.tres b/items/ram_item.tres new file mode 100644 index 0000000..7ce632b --- /dev/null +++ b/items/ram_item.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" script_class="ItemData" load_steps=3 format=3 uid="uid://c2wbqelme8vy1"] + +[ext_resource type="Script" uid="uid://dccraom7a7e8d" path="res://inv_system/item_data.gd" id="1_0t7ph"] +[ext_resource type="Texture2D" uid="uid://dquer6m8lapux" path="res://assets/ram.png" id="1_bfuag"] + +[resource] +script = ExtResource("1_0t7ph") +item_name = "Ram Stick" +icon = ExtResource("1_bfuag") +metadata/_custom_type_script = "uid://dccraom7a7e8d" diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..69209bf --- /dev/null +++ b/project.godot @@ -0,0 +1,21 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Repurposed Jam" +run/main_scene="uid://dsfal3m4siap2" +config/features=PackedStringArray("4.5", "GL Compatibility") +config/icon="res://icon.svg" + +[rendering] + +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" diff --git a/test.tscn b/test.tscn new file mode 100644 index 0000000..79aea8c --- /dev/null +++ b/test.tscn @@ -0,0 +1,259 @@ +[gd_scene load_steps=6 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="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"] + +[node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="InventoryPanel" type="PanelContainer" parent="."] +layout_mode = 0 +offset_left = 51.0 +offset_top = 67.0 +offset_right = 403.0 +offset_bottom = 549.0 +script = ExtResource("1_6uqi0") + +[node name="MarginContainer" type="MarginContainer" parent="InventoryPanel"] +layout_mode = 2 +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="VBoxContainer" type="VBoxContainer" parent="InventoryPanel/MarginContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="InventoryPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Inventory 1" + +[node name="ScrollContainer" type="ScrollContainer" parent="InventoryPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="GridContainer" type="GridContainer" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer"] +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) +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) +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) +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) +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) +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) +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) +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) +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) +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) +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="ItemSlot10" type="Panel" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" node_paths=PackedStringArray("icon")] +custom_minimum_size = Vector2(64, 64) +layout_mode = 2 +script = ExtResource("1_8uh7m") +icon = NodePath("Icon") + +[node name="Icon" type="TextureRect" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer/ItemSlot10"] +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