summaryrefslogtreecommitdiff
path: root/addons/escoria-ui-simplemouse/inventory
diff options
context:
space:
mode:
authorRadio <radiohotline@disroot.org>2026-06-04 15:15:11 +0300
committerRadio <radiohotline@disroot.org>2026-06-04 15:15:11 +0300
commit9d74b49ab62908d4acf53dde444413886b8b28e5 (patch)
tree0cb785267ea7e239b19d88684c0d64b9bd5d52f0 /addons/escoria-ui-simplemouse/inventory
parent2c85d452ad02a5f89cd43bad7f9de31d0e4fa0c1 (diff)
escoria setup and old branch archives
Diffstat (limited to 'addons/escoria-ui-simplemouse/inventory')
-rw-r--r--addons/escoria-ui-simplemouse/inventory/inventory_ui.gd88
-rw-r--r--addons/escoria-ui-simplemouse/inventory/inventory_ui.gd.uid1
-rw-r--r--addons/escoria-ui-simplemouse/inventory/inventory_ui.tscn90
3 files changed, 179 insertions, 0 deletions
diff --git a/addons/escoria-ui-simplemouse/inventory/inventory_ui.gd b/addons/escoria-ui-simplemouse/inventory/inventory_ui.gd
new file mode 100644
index 0000000..14cf871
--- /dev/null
+++ b/addons/escoria-ui-simplemouse/inventory/inventory_ui.gd
@@ -0,0 +1,88 @@
+extends ESCInventory
+
+
+# Whether the inventory is visible currently
+var inventory_visible: bool = false
+
+var hovering_inventory_item: bool = false
+
+var _tween: Tween3
+
+var being_closed: bool
+var being_opened: bool
+
+@onready var inventory_scene = $panel
+
+# Height of the title part of the inventory that stays visible when inventory
+# is hidden. To be computed depending on the resolution of the game, hardcoded
+# here for demonstration purpose.
+const _inventory_title_height: int = 34
+
+func _ready() -> void:
+ super._ready()
+ _tween = Tween3.new(self)
+ # Hide inventory by default
+ hide_inventory()
+
+
+func show_inventory():
+ if being_opened:
+ return
+ being_opened = true
+ _tween.stop()
+ _tween.reset()
+ var start_pos_y = inventory_scene.position.y
+ var end_pos_y = get_viewport_rect().size.y - inventory_scene.size.y
+ _tween.interpolate_property(
+ inventory_scene,
+ "position:y",
+ start_pos_y,
+ end_pos_y,
+ 0.4,
+ Tween.TransitionType.TRANS_CUBIC
+ )
+ _tween.play()
+ await _tween.finished
+ _tween.stop()
+ inventory_visible = true
+ being_opened = false
+
+func hide_inventory():
+ if being_closed:
+ return
+ being_closed = true
+ _tween.stop()
+ _tween.reset()
+ var start_pos_y = inventory_scene.position.y
+ var end_pos_y = get_viewport_rect().size.y - _inventory_title_height
+ _tween.interpolate_property(
+ inventory_scene,
+ "position:y",
+ start_pos_y,
+ end_pos_y,
+ 0.4,
+ Tween.TransitionType.TRANS_CUBIC
+ )
+ _tween.play()
+ await _tween.finished
+ _tween.stop()
+ inventory_visible = false
+ being_closed = false
+
+
+func detector_in():
+ if not inventory_visible:
+ inventory_scene.get_node("MarginContainer/ScrollContainer/container").item_focused = false
+ show_inventory()
+ $panel/detector_out.show()
+
+
+func detector_out():
+ if inventory_visible:
+ hide_inventory()
+ $panel/detector_out.hide()
+
+
+
+func _on_detector_out_gui_input(event):
+ detector_out()
diff --git a/addons/escoria-ui-simplemouse/inventory/inventory_ui.gd.uid b/addons/escoria-ui-simplemouse/inventory/inventory_ui.gd.uid
new file mode 100644
index 0000000..17140e9
--- /dev/null
+++ b/addons/escoria-ui-simplemouse/inventory/inventory_ui.gd.uid
@@ -0,0 +1 @@
+uid://cmyyk7qinkift
diff --git a/addons/escoria-ui-simplemouse/inventory/inventory_ui.tscn b/addons/escoria-ui-simplemouse/inventory/inventory_ui.tscn
new file mode 100644
index 0000000..f873643
--- /dev/null
+++ b/addons/escoria-ui-simplemouse/inventory/inventory_ui.tscn
@@ -0,0 +1,90 @@
+[gd_scene load_steps=4 format=3 uid="uid://ciy2hn83a3rim"]
+
+[ext_resource type="Script" uid="uid://cmyyk7qinkift" path="res://addons/escoria-ui-simplemouse/inventory/inventory_ui.gd" id="1"]
+[ext_resource type="Texture2D" uid="uid://yegfvvcmtdnp" path="res://addons/escoria-ui-simplemouse/images/inventory_panel.png" id="2_grkag"]
+[ext_resource type="Script" uid="uid://c4syt26p7mg66" path="res://addons/escoria-core/ui_library/inventory/esc_inventory_container.gd" id="3"]
+
+[node name="inventory_ui" type="Control"]
+custom_minimum_size = Vector2(90, 90)
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+size_flags_horizontal = 0
+size_flags_vertical = 3
+mouse_filter = 2
+script = ExtResource("1")
+inventory_ui_container = NodePath("panel/MarginContainer/ScrollContainer/container")
+
+[node name="panel" type="TextureRect" parent="."]
+custom_minimum_size = Vector2(0, 160)
+layout_mode = 1
+anchors_preset = 10
+anchor_right = 1.0
+offset_top = 866.0
+offset_bottom = 1060.0
+grow_horizontal = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+texture = ExtResource("2_grkag")
+
+[node name="Label" type="Label" parent="panel"]
+layout_mode = 2
+offset_left = 75.0
+offset_top = 6.0
+offset_right = 315.0
+offset_bottom = 29.0
+text = "INVENTORY_LABEL"
+horizontal_alignment = 1
+
+[node name="MarginContainer" type="MarginContainer" parent="panel"]
+layout_mode = 2
+offset_top = 34.0
+offset_right = 1280.0
+offset_bottom = 193.0
+grow_horizontal = 2
+grow_vertical = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+mouse_filter = 2
+theme_override_constants/margin_left = 20
+theme_override_constants/margin_top = 20
+theme_override_constants/margin_right = 20
+theme_override_constants/margin_bottom = 20
+metadata/_edit_lock_ = true
+
+[node name="ScrollContainer" type="ScrollContainer" parent="panel/MarginContainer"]
+layout_mode = 2
+size_flags_horizontal = 3
+mouse_filter = 2
+
+[node name="container" type="HBoxContainer" parent="panel/MarginContainer/ScrollContainer"]
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+mouse_filter = 2
+theme_override_constants/separation = 20
+script = ExtResource("3")
+
+[node name="detector_in" type="Control" parent="panel"]
+anchors_preset = 0
+offset_right = 1281.0
+offset_bottom = 34.0
+mouse_filter = 1
+
+[node name="detector_out" type="Control" parent="panel"]
+layout_mode = 1
+anchor_top = -4.469
+anchor_right = 1.0
+anchor_bottom = 0.18
+offset_top = -0.013916
+offset_bottom = -36.92
+grow_horizontal = 2
+grow_vertical = 2
+mouse_filter = 1
+
+[connection signal="mouse_entered" from="panel/detector_in" to="." method="detector_in"]
+[connection signal="gui_input" from="panel/detector_out" to="." method="_on_detector_out_gui_input"]
+[connection signal="mouse_entered" from="panel/detector_out" to="." method="detector_out"]