diff --git a/assets/battery.webp b/assets/battery.webp new file mode 100644 index 0000000..b06289d Binary files /dev/null and b/assets/battery.webp differ diff --git a/assets/battery.webp.import b/assets/battery.webp.import new file mode 100644 index 0000000..1032017 --- /dev/null +++ b/assets/battery.webp.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b0kddtrrun1tc" +path="res://.godot/imported/battery.webp-29ebbc4ec04c0f993175279e162374d5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/battery.webp" +dest_files=["res://.godot/imported/battery.webp-29ebbc4ec04c0f993175279e162374d5.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/big psu.png b/assets/big psu.png new file mode 100644 index 0000000..56ad9b8 Binary files /dev/null and b/assets/big psu.png differ diff --git a/assets/big psu.png.import b/assets/big psu.png.import new file mode 100644 index 0000000..1fec712 --- /dev/null +++ b/assets/big psu.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dd5u5obr0c61q" +path="res://.godot/imported/big psu.png-d20e94e5a552e1303554bd6972afdc56.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/big psu.png" +dest_files=["res://.godot/imported/big psu.png-d20e94e5a552e1303554bd6972afdc56.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/small psu.png b/assets/small psu.png new file mode 100644 index 0000000..9b1478b Binary files /dev/null and b/assets/small psu.png differ diff --git a/assets/small psu.png.import b/assets/small psu.png.import new file mode 100644 index 0000000..d6b9510 --- /dev/null +++ b/assets/small psu.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bmstxerbgdq61" +path="res://.godot/imported/small psu.png-8910d553249f30fc51a0f97c315ad4aa.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/small psu.png" +dest_files=["res://.godot/imported/small psu.png-8910d553249f30fc51a0f97c315ad4aa.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/inv_system/item_data.gd b/inv_system/item_data.gd index a6c7b43..609facb 100644 --- a/inv_system/item_data.gd +++ b/inv_system/item_data.gd @@ -3,3 +3,4 @@ class_name ItemData @export var item_name : String @export var icon : Texture2D +@export var value : String diff --git a/inv_system/item_slot.gd b/inv_system/item_slot.gd index 2f7c856..7c404a1 100644 --- a/inv_system/item_slot.gd +++ b/inv_system/item_slot.gd @@ -3,6 +3,7 @@ class_name ItemSlot @export var icon : TextureRect @export var item: ItemData +@export var label : Label func _ready() -> void: update_ui() @@ -10,10 +11,13 @@ func _ready() -> void: func update_ui(): if not item: icon.texture = null + label.text = "" return icon.texture = item.icon tooltip_text = item.item_name + label.text = item.value + func _get_drag_data(at_position: Vector2) -> Variant: if not item: diff --git a/inv_system/item_slot.tscn b/inv_system/item_slot.tscn index d4845d2..18f5256 100644 --- a/inv_system/item_slot.tscn +++ b/inv_system/item_slot.tscn @@ -1,12 +1,17 @@ -[gd_scene load_steps=3 format=3 uid="uid://dgqs20xf7l8c"] +[gd_scene load_steps=4 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")] +[sub_resource type="LabelSettings" id="LabelSettings_ab1u2"] +outline_size = 5 +outline_color = Color(0, 0, 0, 1) + +[node name="ItemSlot" type="Panel" node_paths=PackedStringArray("icon", "label")] custom_minimum_size = Vector2(64, 64) script = ExtResource("1_m11ft") icon = NodePath("Icon") +label = NodePath("Icon/Label") [node name="Icon" type="TextureRect" parent="."] layout_mode = 1 @@ -21,3 +26,20 @@ grow_vertical = 2 texture = ExtResource("3_0tnt0") expand_mode = 3 stretch_mode = 4 + +[node name="Label" type="Label" parent="Icon"] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -31.0 +offset_top = -14.599998 +offset_right = 30.999998 +offset_bottom = 8.400002 +grow_horizontal = 2 +grow_vertical = 0 +text = "120 GB" +label_settings = SubResource("LabelSettings_ab1u2") +horizontal_alignment = 2 diff --git a/items/battery_item.tres b/items/battery_item.tres new file mode 100644 index 0000000..6f3333f --- /dev/null +++ b/items/battery_item.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" script_class="ItemData" load_steps=3 format=3 uid="uid://bcteljob51wfj"] + +[ext_resource type="Texture2D" uid="uid://b0kddtrrun1tc" path="res://assets/battery.webp" id="1_lh7dq"] +[ext_resource type="Script" uid="uid://dccraom7a7e8d" path="res://inv_system/item_data.gd" id="2_4u113"] + +[resource] +script = ExtResource("2_4u113") +item_name = "Battery" +icon = ExtResource("1_lh7dq") +metadata/_custom_type_script = "uid://dccraom7a7e8d" diff --git a/items/large_psu_item.tres b/items/large_psu_item.tres new file mode 100644 index 0000000..2c4b856 --- /dev/null +++ b/items/large_psu_item.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" script_class="ItemData" load_steps=3 format=3 uid="uid://88v5bcyrgpob"] + +[ext_resource type="Texture2D" uid="uid://dd5u5obr0c61q" path="res://assets/big psu.png" id="1_rjw1c"] +[ext_resource type="Script" uid="uid://dccraom7a7e8d" path="res://inv_system/item_data.gd" id="2_i66kx"] + +[resource] +script = ExtResource("2_i66kx") +item_name = "Large Power Supply Unit" +icon = ExtResource("1_rjw1c") +metadata/_custom_type_script = "uid://dccraom7a7e8d" diff --git a/items/small_psu_item.tres b/items/small_psu_item.tres new file mode 100644 index 0000000..01a49e0 --- /dev/null +++ b/items/small_psu_item.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" script_class="ItemData" load_steps=3 format=3 uid="uid://swd1m0hvep4c"] + +[ext_resource type="Texture2D" uid="uid://bmstxerbgdq61" path="res://assets/small psu.png" id="1_62foo"] +[ext_resource type="Script" uid="uid://dccraom7a7e8d" path="res://inv_system/item_data.gd" id="2_x1n7s"] + +[resource] +script = ExtResource("2_x1n7s") +item_name = "Small Power Supply Unit" +icon = ExtResource("1_62foo") +metadata/_custom_type_script = "uid://dccraom7a7e8d" diff --git a/test.tscn b/test.tscn index 9cb3316..bcdd048 100644 --- a/test.tscn +++ b/test.tscn @@ -1,12 +1,16 @@ -[gd_scene load_steps=8 format=3 uid="uid://dsfal3m4siap2"] +[gd_scene load_steps=12 format=3 uid="uid://dsfal3m4siap2"] [ext_resource type="Script" uid="uid://c6oycdae5wvjf" path="res://inv_system/inventory.gd" id="1_6uqi0"] [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://bcteljob51wfj" path="res://items/battery_item.tres" id="5_00tp4"] [ext_resource type="Resource" uid="uid://c2wbqelme8vy1" path="res://items/ram_item.tres" id="5_g14j6"] +[ext_resource type="Resource" uid="uid://88v5bcyrgpob" path="res://items/large_psu_item.tres" id="6_77dp3"] +[ext_resource type="Resource" uid="uid://swd1m0hvep4c" path="res://items/small_psu_item.tres" id="7_5tkv4"] [ext_resource type="PackedScene" uid="uid://dgqs20xf7l8c" path="res://inv_system/item_slot.tscn" id="7_xersf"] +[ext_resource type="Script" uid="uid://cbta38dhunndc" path="res://tooltip.gd" id="11_77dp3"] [node name="Control" type="Control" node_paths=PackedStringArray("bin_inventory", "loot_button")] layout_mode = 3 @@ -18,7 +22,7 @@ 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")]) +loot_pool = Array[ExtResource("2_ehkex")]([ExtResource("3_ykrsh"), ExtResource("5_g14j6"), ExtResource("5_00tp4"), ExtResource("6_77dp3"), ExtResource("7_5tkv4")]) [node name="TextureRect" type="TextureRect" parent="."] layout_mode = 1 @@ -66,7 +70,6 @@ columns = 5 [node name="ItemSlot" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 -item = ExtResource("3_ykrsh") [node name="ItemSlot2" parent="InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer" instance=ExtResource("7_xersf")] layout_mode = 2 @@ -189,4 +192,19 @@ grow_horizontal = 2 grow_vertical = 0 text = "Return to workshop" +[node name="Tooltip" type="PanelContainer" parent="." node_paths=PackedStringArray("tooltip_label")] +layout_mode = 1 +offset_right = 161.0 +offset_bottom = 40.0 +mouse_filter = 2 +script = ExtResource("11_77dp3") +tooltip_label = NodePath("VBoxContainer/Label") + +[node name="VBoxContainer" type="VBoxContainer" parent="Tooltip"] +layout_mode = 2 + +[node name="Label" type="Label" parent="Tooltip/VBoxContainer"] +layout_mode = 2 +text = "Item Name" + [connection signal="pressed" from="LootButton" to="." method="_on_loot_button_pressed"] diff --git a/tooltip.gd b/tooltip.gd new file mode 100644 index 0000000..fa11a57 --- /dev/null +++ b/tooltip.gd @@ -0,0 +1,12 @@ +extends PanelContainer + +@export var tooltip_label : Label + +# 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: + global_position = get_global_mouse_position() + Vector2(1,1) diff --git a/tooltip.gd.uid b/tooltip.gd.uid new file mode 100644 index 0000000..3b9d929 --- /dev/null +++ b/tooltip.gd.uid @@ -0,0 +1 @@ +uid://cbta38dhunndc