basic inventory system ready

This commit is contained in:
Tabby 2026-01-10 18:05:09 +11:00
parent 3f22eeaf9d
commit aee93b8d10
20 changed files with 513 additions and 16 deletions

4
.editorconfig Normal file
View file

@ -0,0 +1,4 @@
root = true
[*]
charset = utf-8

4
.gitattributes vendored
View file

@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization # Normalize EOL for all files that Git considers text files.
* text=auto * text=auto eol=lf

15
.gitignore vendored
View file

@ -1,16 +1,3 @@
# Godot 4+ specific ignores # Godot 4+ specific ignores
.godot/ .godot/
.nomedia /android/
# 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

View file

@ -1,2 +1,13 @@
# RepurposedJam # 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

BIN
assets/hdd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

40
assets/hdd.png.import Normal file
View file

@ -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

BIN
assets/ram.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

40
assets/ram.png.import Normal file
View file

@ -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

1
icon.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 995 B

43
icon.svg.import Normal file
View file

@ -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

22
inv_system/inventory.gd Normal file
View file

@ -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

View file

@ -0,0 +1 @@
uid://c6oycdae5wvjf

5
inv_system/item_data.gd Normal file
View file

@ -0,0 +1,5 @@
extends Resource
class_name ItemData
@export var item_name : String
@export var icon : Texture2D

View file

@ -0,0 +1 @@
uid://dccraom7a7e8d

41
inv_system/item_slot.gd Normal file
View file

@ -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()

View file

@ -0,0 +1 @@
uid://cpd04flfh5nlc

10
items/hdd_item.tres Normal file
View file

@ -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"

10
items/ram_item.tres Normal file
View file

@ -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"

21
project.godot Normal file
View file

@ -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"

259
test.tscn Normal file
View file

@ -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