feat: Rewrote inventory handling basing on ESCItems (#417)
Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>esc_inventory_item</title>
|
||||
<defs>
|
||||
<linearGradient x1="0%" y1="32.9861111%" x2="100%" y2="67.0138889%" id="linearGradient-1">
|
||||
<stop stop-color="#D4FF2A" offset="0%"></stop>
|
||||
<stop stop-color="#81D135" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<linearGradient x1="0%" y1="0%" x2="100%" y2="100%" id="linearGradient-2">
|
||||
<stop stop-color="#D4FF2A" offset="0%"></stop>
|
||||
<stop stop-color="#81D135" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="esc_inventory_item" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Group-Copy" transform="translate(2.000000, 4.000000)">
|
||||
<rect id="Rectangle" fill="url(#linearGradient-1)" x="0" y="1" width="12" height="7" rx="1"></rect>
|
||||
<path d="M10.2857143,0 C11.2324881,0 12,0.8954305 12,2 L12,7 C12,8.1045695 11.2324881,9 10.2857143,9 L1.71428571,9 C0.767511857,9 0,8.1045695 0,7 L0,2 C0,0.8954305 0.767511857,0 1.71428571,0 L10.2857143,0 Z M10.2857143,1 L1.71428571,1 C1.27471214,1 0.912422434,1.38604019 0.862909484,1.88337887 L0.857142857,2 L0.857142857,7 C0.857142857,7.51283584 1.18803445,7.93550716 1.61432475,7.99327227 L1.71428571,8 L10.2857143,8 C10.7252879,8 11.0875776,7.61395981 11.1370905,7.11662113 L11.1428571,7 L11.1428571,2 C11.1428571,1.48716416 10.8119656,1.06449284 10.3856753,1.00672773 L10.2857143,1 Z" id="Rectangle" fill="#1B2F0D" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
<path d="M13,2 L13,12 L3,12 L3,2 L13,2 Z" id="Rectangle-Copy" fill="url(#linearGradient-2)" fill-rule="nonzero"></path>
|
||||
<path d="M13,2 L13,12 L3,12 L3,2 L13,2 Z M12,3 L4,3 L4,11 L12,11 L12,3 Z" id="Rectangle" fill="#1B2F0D" fill-rule="nonzero"></path>
|
||||
<g id="Group" transform="translate(1.000000, 6.000000)">
|
||||
<rect id="Rectangle" fill="url(#linearGradient-1)" x="1" y="1" width="12" height="7"></rect>
|
||||
<path d="M9,0 L9,5 L5,5 L5,0 L9,0 Z M8,1 L6,1 L6,4 L8,4 L8,1 Z" id="Rectangle" fill="#1B2F0D" fill-rule="nonzero"></path>
|
||||
<path d="M12,0 C13.1045695,0 14,0.8954305 14,2 L14,7 C14,8.1045695 13.1045695,9 12,9 L2,9 C0.8954305,9 0,8.1045695 0,7 L0,2 C0,0.8954305 0.8954305,0 2,0 L12,0 Z M12,1 L2,1 C1.48716416,1 1.06449284,1.38604019 1.00672773,1.88337887 L1,2 L1,7 C1,7.51283584 1.38604019,7.93550716 1.88337887,7.99327227 L2,8 L12,8 C12.5128358,8 12.9355072,7.61395981 12.9932723,7.11662113 L13,7 L13,2 C13,1.48716416 12.6139598,1.06449284 12.1166211,1.00672773 L12,1 Z" id="Rectangle" fill="#1B2F0D" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.7 KiB |
@@ -1,95 +1,15 @@
|
||||
# The inventory representation of an ESC item if pickable
|
||||
extends TextureButton
|
||||
class_name ESCInventoryItem, \
|
||||
"res://addons/escoria-core/design/esc_inventory_item.svg"
|
||||
|
||||
|
||||
# Signal emitted when the item was left clicked
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - item_id: Global ID of the clicked item
|
||||
signal mouse_left_inventory_item(item_id)
|
||||
|
||||
# Signal emitted when the item was right clicked
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - item_id: Global ID of the clicked item
|
||||
signal mouse_right_inventory_item(item_id)
|
||||
|
||||
# Signal emitted when the item was double clicked
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - item_id: Global ID of the clicked item
|
||||
signal mouse_double_left_inventory_item(item_id)
|
||||
|
||||
# Signal emitted when the item was focused
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - item_id: Global ID of the clicked item
|
||||
signal inventory_item_focused(item_id)
|
||||
|
||||
# Signal emitted when the item is not focused anymore
|
||||
signal inventory_item_unfocused()
|
||||
# Basic information about an inventory item
|
||||
class_name ESCInventoryItem
|
||||
|
||||
|
||||
# Global ID of the ESCItem that uses this ESCInventoryItem
|
||||
# Will be set by ESCItem automatically
|
||||
var global_id
|
||||
var global_id: String = ""
|
||||
|
||||
# The texture for the item
|
||||
var texture: Texture = null
|
||||
|
||||
|
||||
# Connect input handlers
|
||||
func _ready():
|
||||
connect("gui_input", self, "_on_inventory_item_gui_input")
|
||||
connect("mouse_entered", self, "_on_inventory_item_mouse_enter")
|
||||
connect("mouse_exited", self, "_on_inventory_item_mouse_exit")
|
||||
func _init(p_item: ESCItem) -> void:
|
||||
global_id = p_item.global_id
|
||||
texture = p_item._get_inventory_texture()
|
||||
|
||||
|
||||
# Handle the gui input and emit the respective signals
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - event: The event received
|
||||
func _on_inventory_item_gui_input(event: InputEvent):
|
||||
if InputMap.has_action("switch_action_verb") \
|
||||
and event.is_action_pressed("switch_action_verb"):
|
||||
if event.button_index == BUTTON_WHEEL_UP:
|
||||
escoria.inputs_manager._on_mousewheel_action(-1)
|
||||
elif event.button_index == BUTTON_WHEEL_DOWN:
|
||||
escoria.inputs_manager._on_mousewheel_action(1)
|
||||
if event is InputEventMouseButton:
|
||||
# var p = get_global_mouse_position()
|
||||
if event.doubleclick:
|
||||
if event.button_index == BUTTON_LEFT:
|
||||
emit_signal(
|
||||
"mouse_double_left_inventory_item",
|
||||
global_id,
|
||||
event
|
||||
)
|
||||
else:
|
||||
if event.is_pressed():
|
||||
if event.button_index == BUTTON_LEFT:
|
||||
emit_signal(
|
||||
"mouse_left_inventory_item",
|
||||
global_id,
|
||||
event
|
||||
)
|
||||
if event.button_index == BUTTON_RIGHT:
|
||||
emit_signal(
|
||||
"mouse_right_inventory_item",
|
||||
global_id,
|
||||
event
|
||||
)
|
||||
|
||||
|
||||
# Handle mouse entering the item and send the respecitve signal
|
||||
func _on_inventory_item_mouse_enter():
|
||||
emit_signal("inventory_item_focused", global_id)
|
||||
|
||||
|
||||
# Handle mouse leaving the item and send the respecitve signal
|
||||
func _on_inventory_item_mouse_exit():
|
||||
emit_signal("inventory_item_unfocused")
|
||||
|
||||
@@ -103,9 +103,9 @@ export(bool) var combine_is_one_way = false
|
||||
# A false value is useful for items in the background, such as buttons.
|
||||
export(bool) var use_from_inventory_only = false
|
||||
|
||||
# Scene based on ESCInventoryItem used in inventory for the object if it is
|
||||
# picked up, that displays and handles the item
|
||||
export(PackedScene) var inventory_item_scene_file: PackedScene
|
||||
# The visual representation for this item when its in the inventory
|
||||
export(Texture) var inventory_texture: Texture = null \
|
||||
setget ,_get_inventory_texture
|
||||
|
||||
# Color used for dialogs
|
||||
export(Color) var dialog_color = ColorN("white")
|
||||
@@ -124,25 +124,22 @@ export(float) var v_speed_damp: float = 1.0
|
||||
export(NodePath) var animation_player_node: NodePath = "" \
|
||||
setget _set_animation_player_node
|
||||
|
||||
|
||||
# ESCAnimationsResource (for walking, idling...)
|
||||
var animations: ESCAnimationResource
|
||||
|
||||
# Reference to the animation node (null if none was found)
|
||||
var animation_sprite = null
|
||||
|
||||
# Reference to the sprite node
|
||||
var _sprite_node: Node = null
|
||||
|
||||
# Reference to the current terrain
|
||||
var terrain: ESCTerrain
|
||||
|
||||
# Reference to this items collision shape node
|
||||
var collision: Node
|
||||
|
||||
# The representation of this item in the scene. Will
|
||||
# be loaded, if inventory_item_scene_file is set.
|
||||
var inventory_item: ESCInventoryItem = null setget ,_get_inventory_item
|
||||
|
||||
# Reference to the sprite node
|
||||
var _sprite_node: Node = null
|
||||
|
||||
# The movable subnode
|
||||
var _movable: ESCMovable = null
|
||||
@@ -464,15 +461,6 @@ func _update_terrain(rc: int, event_name: String) -> void:
|
||||
_movable.update_terrain(event_name)
|
||||
|
||||
|
||||
# Get inventory item from the inventory item scene
|
||||
# **Returns** The inventory item of this ESCitem
|
||||
func _get_inventory_item() -> ESCInventoryItem:
|
||||
if not inventory_item and inventory_item_scene_file:
|
||||
inventory_item = inventory_item_scene_file.instance()
|
||||
inventory_item.global_id = self.global_id
|
||||
return inventory_item
|
||||
|
||||
|
||||
func _get_property_list():
|
||||
var properties = []
|
||||
properties.append({
|
||||
@@ -505,3 +493,15 @@ func _set_animation_player_node(node_path: NodePath):
|
||||
)
|
||||
|
||||
animation_player_node = node_path
|
||||
|
||||
|
||||
# Returns either the set inventory texture or the texture of a TextureRect
|
||||
# found as a child if it is null
|
||||
func _get_inventory_texture() -> Texture:
|
||||
if inventory_texture == null:
|
||||
for c in get_children():
|
||||
if c is TextureRect or c is Sprite:
|
||||
return c.texture
|
||||
return null
|
||||
else:
|
||||
return inventory_texture
|
||||
|
||||
@@ -64,25 +64,26 @@ func add_new_item_by_id(item_id: String) -> void:
|
||||
"Check item's id in ESCORIA_ALL_ITEMS scene."
|
||||
]
|
||||
)
|
||||
var item_inventory_button = (
|
||||
escoria.object_manager.get_object(item_id).node as ESCItem
|
||||
).inventory_item.duplicate()
|
||||
item_inventory_button.global_id = item_id
|
||||
items_ids_in_inventory[item_id] = item_inventory_button
|
||||
get_node(inventory_ui_container).add_item(item_inventory_button)
|
||||
|
||||
var inventory_item = ESCInventoryItem.new(
|
||||
escoria.object_manager.get_object(item_id).node
|
||||
)
|
||||
var inventory_item_button = get_node(
|
||||
inventory_ui_container
|
||||
).add_item(inventory_item)
|
||||
|
||||
items_ids_in_inventory[item_id] = inventory_item
|
||||
|
||||
if not escoria.object_manager.has(item_id):
|
||||
escoria.object_manager.register_object(
|
||||
ESCObject.new(
|
||||
item_id,
|
||||
item_inventory_button
|
||||
inventory_item_button
|
||||
),
|
||||
true
|
||||
)
|
||||
|
||||
item_inventory_button.visible = true
|
||||
|
||||
escoria.inputs_manager.register_inventory_item(item_inventory_button)
|
||||
escoria.inputs_manager.register_inventory_item(inventory_item_button)
|
||||
|
||||
|
||||
# remove item fromInventory UI using its id set in its scene
|
||||
@@ -117,7 +118,6 @@ func remove_item_by_id(item_id: String) -> void:
|
||||
)
|
||||
|
||||
get_node(inventory_ui_container).remove_item(item_inventory_button)
|
||||
item_inventory_button.queue_free()
|
||||
items_ids_in_inventory.erase(item_id)
|
||||
|
||||
|
||||
|
||||
107
addons/escoria-core/library/inventory/esc_inventory_button.gd
Normal file
@@ -0,0 +1,107 @@
|
||||
# The inventory representation of an ESC item if pickable (only used by
|
||||
# the inventory components)
|
||||
extends TextureButton
|
||||
class_name ESCInventoryButton
|
||||
|
||||
|
||||
# Signal emitted when the item was left clicked
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - item_id: Global ID of the clicked item
|
||||
signal mouse_left_inventory_item(item_id)
|
||||
|
||||
# Signal emitted when the item was right clicked
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - item_id: Global ID of the clicked item
|
||||
signal mouse_right_inventory_item(item_id)
|
||||
|
||||
# Signal emitted when the item was double clicked
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - item_id: Global ID of the clicked item
|
||||
signal mouse_double_left_inventory_item(item_id)
|
||||
|
||||
# Signal emitted when the item was focused
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - item_id: Global ID of the clicked item
|
||||
signal inventory_item_focused(item_id)
|
||||
|
||||
# Signal emitted when the item is not focused anymore
|
||||
signal inventory_item_unfocused()
|
||||
|
||||
|
||||
# Global ID of the ESCItem that uses this ESCInventoryItem
|
||||
var global_id: String = ""
|
||||
|
||||
|
||||
func _init(p_item: ESCInventoryItem) -> void:
|
||||
global_id = p_item.global_id
|
||||
texture_normal = p_item.texture
|
||||
expand = true
|
||||
stretch_mode = TextureButton.STRETCH_KEEP_ASPECT
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
rect_size = ProjectSettings.get_setting("escoria/ui/inventory_item_size")
|
||||
rect_min_size = ProjectSettings.get_setting(
|
||||
"escoria/ui/inventory_item_size"
|
||||
)
|
||||
|
||||
# Connect input handlers
|
||||
func _ready():
|
||||
connect("gui_input", self, "_on_inventory_item_gui_input")
|
||||
connect("mouse_entered", self, "_on_inventory_item_mouse_enter")
|
||||
connect("mouse_exited", self, "_on_inventory_item_mouse_exit")
|
||||
|
||||
|
||||
# Handle the gui input and emit the respective signals
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - event: The event received
|
||||
func _on_inventory_item_gui_input(event: InputEvent):
|
||||
if InputMap.has_action("switch_action_verb") \
|
||||
and event.is_action_pressed("switch_action_verb"):
|
||||
if event.button_index == BUTTON_WHEEL_UP:
|
||||
escoria.inputs_manager._on_mousewheel_action(-1)
|
||||
elif event.button_index == BUTTON_WHEEL_DOWN:
|
||||
escoria.inputs_manager._on_mousewheel_action(1)
|
||||
if event is InputEventMouseButton:
|
||||
# var p = get_global_mouse_position()
|
||||
if event.doubleclick:
|
||||
if event.button_index == BUTTON_LEFT:
|
||||
emit_signal(
|
||||
"mouse_double_left_inventory_item",
|
||||
global_id,
|
||||
event
|
||||
)
|
||||
else:
|
||||
if event.is_pressed():
|
||||
if event.button_index == BUTTON_LEFT:
|
||||
emit_signal(
|
||||
"mouse_left_inventory_item",
|
||||
global_id,
|
||||
event
|
||||
)
|
||||
if event.button_index == BUTTON_RIGHT:
|
||||
emit_signal(
|
||||
"mouse_right_inventory_item",
|
||||
global_id,
|
||||
event
|
||||
)
|
||||
|
||||
|
||||
# Handle mouse entering the item and send the respecitve signal
|
||||
func _on_inventory_item_mouse_enter():
|
||||
emit_signal("inventory_item_focused", global_id)
|
||||
|
||||
|
||||
# Handle mouse leaving the item and send the respecitve signal
|
||||
func _on_inventory_item_mouse_exit():
|
||||
emit_signal("inventory_item_unfocused")
|
||||
@@ -0,0 +1,31 @@
|
||||
# Inventory container handler that acts as a base for UIs inventory containers
|
||||
extends Control
|
||||
class_name ESCInventoryContainer
|
||||
|
||||
|
||||
# Get wether the inventory container currently is empty
|
||||
# **Returns** Wether the container is empty or not
|
||||
func is_empty() -> bool:
|
||||
return get_child_count() > 0
|
||||
|
||||
# Add a new item into the container and return the control generated for it
|
||||
# so its events can be handled by the inputs manager
|
||||
#
|
||||
# #### Parameters
|
||||
# - inventory_item: Item to add
|
||||
# **Returns** The button generated for the item
|
||||
func add_item(inventory_item: ESCInventoryItem) -> ESCInventoryButton:
|
||||
var button = ESCInventoryButton.new(inventory_item)
|
||||
add_child(button)
|
||||
return button
|
||||
|
||||
|
||||
# Remove an item from the container
|
||||
#
|
||||
# #### Parameters
|
||||
# - inventory_item: Item to remove
|
||||
func remove_item(inventory_item: ESCInventoryItem):
|
||||
for c in get_children():
|
||||
if c is ESCInventoryButton and c.global_id == inventory_item.global_id:
|
||||
remove_child(c)
|
||||
c.queue_free()
|
||||
@@ -98,6 +98,16 @@ func set_escoria_ui_settings():
|
||||
"type": TYPE_STRING_ARRAY,
|
||||
"hint": PROPERTY_HINT_DIR
|
||||
})
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/ui/inventory_item_size"):
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/inventory_item_size",
|
||||
Vector2(72, 72)
|
||||
)
|
||||
ProjectSettings.add_property_info({
|
||||
"name": "escoria/ui/inventory_item_size",
|
||||
"type": TYPE_VECTOR2
|
||||
})
|
||||
|
||||
|
||||
# Prepare the settings in the Escoria main category
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/inventory/inventory_ui.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/escoria-ui-9verbs/inventory/inventory_ui_container.gd" type="Script" id=3]
|
||||
[ext_resource path="res://addons/escoria-core/library/inventory/esc_inventory_container.gd" type="Script" id=3]
|
||||
|
||||
[node name="inventory_ui" type="PanelContainer"]
|
||||
margin_right = 600.0
|
||||
@@ -17,10 +17,14 @@ margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 593.0
|
||||
margin_bottom = 168.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="ScrollContainer"]
|
||||
margin_right = 586.0
|
||||
margin_bottom = 161.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_constants/vseparation = 16
|
||||
custom_constants/hseparation = 16
|
||||
columns = 4
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
extends Control
|
||||
|
||||
"""
|
||||
This script is totally user-defined. It does exactly what the user wants the
|
||||
inventory to look like. It only requires 4 functions to be defined:
|
||||
- is_empty() -> bool
|
||||
- get_items() -> Array
|
||||
- add_item(inventory_item: ESCInventoryItem)
|
||||
- remove_item(inventory_item: ESCInventoryItem)
|
||||
The user is free to implement these methods the way s-he likes.
|
||||
"""
|
||||
|
||||
var current_nodes_in_container = {}
|
||||
|
||||
func is_empty() -> bool:
|
||||
return get_child_count() > 0
|
||||
|
||||
func get_items() -> Array:
|
||||
return current_nodes_in_container.keys()
|
||||
|
||||
func add_item(inventory_item: ESCInventoryItem):
|
||||
var center_container = CenterContainer.new()
|
||||
center_container.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
center_container.connect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||
center_container.connect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
||||
# center_container.connect("gui_input", self, "_on_gui_input", [inventory_item])
|
||||
center_container.add_child(inventory_item)
|
||||
add_child(center_container)
|
||||
current_nodes_in_container[inventory_item] = center_container
|
||||
|
||||
func remove_item(inventory_item: ESCInventoryItem):
|
||||
var node_to_remove = current_nodes_in_container[inventory_item]
|
||||
current_nodes_in_container.erase(node_to_remove)
|
||||
node_to_remove.disconnect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||
node_to_remove.disconnect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
||||
# node_to_remove.disconnect("pressed", self, "_on_gui_input")
|
||||
remove_child(node_to_remove)
|
||||
node_to_remove.queue_free()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource path="res://addons/escoria-ui-simplemouse/inventory/inventory_ui.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/escoria-ui-simplemouse/images/inventory_bg.png" type="Texture" id=2]
|
||||
[ext_resource path="res://addons/escoria-ui-simplemouse/inventory/inventory_ui_container.gd" type="Script" id=3]
|
||||
[ext_resource path="res://addons/escoria-core/library/inventory/esc_inventory_container.gd" type="Script" id=3]
|
||||
[ext_resource path="res://addons/escoria-ui-simplemouse/images/frame.png" type="Texture" id=5]
|
||||
[ext_resource path="res://addons/escoria-ui-simplemouse/images/inventory_icon.png" type="Texture" id=6]
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
extends Control
|
||||
|
||||
"""
|
||||
This script is totally user-defined. It does exactly what the user wants the
|
||||
inventory to look like. It only requires 4 functions to be defined:
|
||||
- is_empty() -> bool
|
||||
- get_items() -> Array
|
||||
- add_item(inventory_item: ESCInventoryItem)
|
||||
- remove_item(inventory_item: ESCInventoryItem)
|
||||
The user is free to implement these methods the way s-he likes.
|
||||
"""
|
||||
|
||||
var current_nodes_in_container = {}
|
||||
|
||||
func is_empty() -> bool:
|
||||
return get_child_count() > 0
|
||||
|
||||
func get_items() -> Array:
|
||||
return current_nodes_in_container.keys()
|
||||
|
||||
func add_item(inventory_item: ESCInventoryItem):
|
||||
var center_container = CenterContainer.new()
|
||||
center_container.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
center_container.connect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||
center_container.connect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
||||
center_container.add_child(inventory_item)
|
||||
add_child(center_container)
|
||||
current_nodes_in_container[inventory_item] = center_container
|
||||
|
||||
func remove_item(inventory_item: ESCInventoryItem):
|
||||
var node_to_remove = current_nodes_in_container[inventory_item]
|
||||
current_nodes_in_container.erase(node_to_remove)
|
||||
node_to_remove.disconnect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||
node_to_remove.disconnect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
||||
remove_child(node_to_remove)
|
||||
node_to_remove.queue_free()
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_inventory_item.gd" type="Script" id=1]
|
||||
[ext_resource path="res://game/items/textures/genericItem_color_127.png" type="Texture" id=2]
|
||||
|
||||
[node name="bottle" type="TextureButton"]
|
||||
margin_right = 50.0
|
||||
margin_bottom = 140.0
|
||||
texture_normal = ExtResource( 2 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -1,14 +0,0 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_inventory_item.gd" type="Script" id=1]
|
||||
[ext_resource path="res://game/items/textures/genericItem_color_038.png" type="Texture" id=2]
|
||||
|
||||
[node name="empty_sheet" type="TextureButton"]
|
||||
margin_right = 98.0
|
||||
margin_bottom = 124.0
|
||||
texture_normal = ExtResource( 2 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
global_id = "r5_empty_sheet"
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -1,14 +0,0 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_inventory_item.gd" type="Script" id=1]
|
||||
[ext_resource path="res://game/rooms/room05/items/filled_sheet.png" type="Texture" id=2]
|
||||
|
||||
[node name="filled_sheet" type="TextureButton"]
|
||||
margin_right = 88.0
|
||||
margin_bottom = 124.0
|
||||
texture_normal = ExtResource( 2 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
global_id = "r5_filled_sheet"
|
||||
|
Before Width: | Height: | Size: 918 B After Width: | Height: | Size: 918 B |
@@ -1,14 +0,0 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://game/items/textures/genericItem_color_026.png" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_inventory_item.gd" type="Script" id=2]
|
||||
|
||||
[node name="pen" type="TextureButton"]
|
||||
margin_right = 42.0
|
||||
margin_bottom = 74.0
|
||||
texture_normal = ExtResource( 1 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
global_id = "r5_pen"
|
||||
@@ -1,23 +1,24 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://game/items/inventory/empty_sheet.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=2]
|
||||
[ext_resource path="res://game/rooms/room05/items/empty_sheet.png" type="Texture" id=3]
|
||||
[ext_resource path="res://game/items/inventory/empty_sheet.png" type="Texture" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 86.9568, 115.211 )
|
||||
|
||||
[node name="empty_sheet" type="Area2D"]
|
||||
pause_mode = 1
|
||||
script = ExtResource( 2 )
|
||||
global_id = "r5_empty_sheet"
|
||||
esc_script = "res://game/items/escitems/empty_sheet.esc"
|
||||
esc_script = "res://game/items/inventory/empty_sheet.esc"
|
||||
tooltip_name = "Empty sheet"
|
||||
default_action = "look"
|
||||
default_action_inventory = "look"
|
||||
combine_if_action_used_among = PoolStringArray( "use", "give" )
|
||||
use_from_inventory_only = true
|
||||
inventory_item_scene_file = ExtResource( 1 )
|
||||
inventory_texture = ExtResource( 3 )
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
animations = null
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 3 )
|
||||
@@ -1,22 +1,25 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=1]
|
||||
[ext_resource path="res://game/items/inventory/filled_sheet.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://game/items/inventory/filled_sheet.png" type="Texture" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
|
||||
[node name="filled_sheet" type="Area2D"]
|
||||
pause_mode = 1
|
||||
script = ExtResource( 1 )
|
||||
global_id = "r5_filled_sheet"
|
||||
esc_script = "res://game/items/escitems/filled_sheet.esc"
|
||||
esc_script = "res://game/items/inventory/filled_sheet.esc"
|
||||
tooltip_name = "Filled sheet"
|
||||
combine_if_action_used_among = PoolStringArray( "use", "give" )
|
||||
combine_is_one_way = true
|
||||
use_from_inventory_only = true
|
||||
inventory_item_scene_file = ExtResource( 2 )
|
||||
inventory_texture = ExtResource( 3 )
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
animations = null
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
@@ -1,23 +1,24 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://game/rooms/room05/items/pen.png" type="Texture" id=1]
|
||||
[ext_resource path="res://game/items/inventory/pen.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://game/items/inventory/pen.png" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 51.8881, 43.8187 )
|
||||
|
||||
[node name="pen" type="Area2D"]
|
||||
pause_mode = 1
|
||||
script = ExtResource( 3 )
|
||||
global_id = "r5_pen"
|
||||
esc_script = "res://game/items/escitems/pen.esc"
|
||||
esc_script = "res://game/items/inventory/pen.esc"
|
||||
tooltip_name = "Pen"
|
||||
default_action = "look"
|
||||
default_action_inventory = "look"
|
||||
combine_if_action_used_among = PoolStringArray( "use", "give" )
|
||||
use_from_inventory_only = true
|
||||
inventory_item_scene_file = ExtResource( 2 )
|
||||
inventory_texture = ExtResource( 1 )
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
animations = null
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
@@ -1,23 +1,24 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://game/items/inventory/wrench.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=2]
|
||||
[ext_resource path="res://game/rooms/room05/items/wrench.png" type="Texture" id=3]
|
||||
[ext_resource path="res://game/items/inventory/wrench.png" type="Texture" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 44.696, 49.0953 )
|
||||
|
||||
[node name="wrench" type="Area2D"]
|
||||
pause_mode = 1
|
||||
script = ExtResource( 2 )
|
||||
global_id = "r5_wrench"
|
||||
esc_script = "res://game/items/escitems/wrench.esc"
|
||||
esc_script = "res://game/items/inventory/wrench.esc"
|
||||
tooltip_name = "Wrench"
|
||||
default_action = "look"
|
||||
default_action_inventory = "look"
|
||||
combine_if_action_used_among = PoolStringArray( "use" )
|
||||
use_from_inventory_only = true
|
||||
inventory_item_scene_file = ExtResource( 1 )
|
||||
inventory_texture = ExtResource( 3 )
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
animations = null
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 3 )
|
||||
@@ -1,7 +1,6 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://game/items/textures/genericItem_color_127.png" type="Texture" id=1]
|
||||
[ext_resource path="res://game/items/inventory/bottle.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
@@ -12,13 +11,13 @@ pause_mode = 1
|
||||
z_index = 1
|
||||
script = ExtResource( 3 )
|
||||
global_id = "r9_bottle"
|
||||
esc_script = "res://game/items/escitems/bottle.esc"
|
||||
esc_script = "res://game/items/inventory/bottle.esc"
|
||||
tooltip_name = "Bottle"
|
||||
default_action = "pickup"
|
||||
default_action_inventory = "look"
|
||||
combine_if_action_used_among = PoolStringArray( "use" )
|
||||
use_from_inventory_only = true
|
||||
inventory_item_scene_file = ExtResource( 2 )
|
||||
inventory_texture = ExtResource( 1 )
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
animations = null
|
||||
|
||||
@@ -4,7 +4,7 @@ say player "It seems even more useful now that I picked it up." [i/r5_wrench]
|
||||
stop
|
||||
|
||||
:pickup
|
||||
set_global i/r5_wrench true
|
||||
inventory_add r5_wrench
|
||||
set_active r5_wrench false
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 857 B After Width: | Height: | Size: 857 B |
@@ -1,14 +0,0 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://game/items/textures/genericItem_color_004.png" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_inventory_item.gd" type="Script" id=2]
|
||||
|
||||
[node name="wrench" type="TextureButton"]
|
||||
margin_right = 70.0
|
||||
margin_bottom = 88.0
|
||||
texture_normal = ExtResource( 1 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
global_id = "r5_wrench"
|
||||
@@ -7,9 +7,9 @@
|
||||
[ext_resource path="res://game/rooms/room05/item_wall/item_wall.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=6]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=7]
|
||||
[ext_resource path="res://game/items/escitems/r5_wrench.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://game/items/escitems/r5_empty_sheet.tscn" type="PackedScene" id=9]
|
||||
[ext_resource path="res://game/items/escitems/r5_pen.tscn" type="PackedScene" id=10]
|
||||
[ext_resource path="res://game/items/inventory/r5_wrench.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://game/items/inventory/r5_empty_sheet.tscn" type="PackedScene" id=9]
|
||||
[ext_resource path="res://game/items/inventory/r5_pen.tscn" type="PackedScene" id=10]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=11]
|
||||
|
||||
[sub_resource type="NavigationPolygon" id=1]
|
||||
@@ -140,24 +140,18 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="wrench" parent="Hotspots" instance=ExtResource( 8 )]
|
||||
pause_mode = 1
|
||||
position = Vector2( 257.269, 435.892 )
|
||||
interaction_direction = 2
|
||||
animations = null
|
||||
|
||||
[node name="Position2D" type="Position2D" parent="Hotspots/wrench"]
|
||||
position = Vector2( -77.4207, 0 )
|
||||
script = ExtResource( 11 )
|
||||
|
||||
[node name="pen" parent="Hotspots" instance=ExtResource( 10 )]
|
||||
pause_mode = 1
|
||||
position = Vector2( 909.908, 443.451 )
|
||||
animations = null
|
||||
|
||||
[node name="empty_sheet" parent="Hotspots" instance=ExtResource( 9 )]
|
||||
pause_mode = 1
|
||||
position = Vector2( 1059.84, 440.932 )
|
||||
animations = null
|
||||
|
||||
[node name="player_start" type="Position2D" parent="."]
|
||||
position = Vector2( 76.7617, 437.649 )
|
||||
|
||||
@@ -85,9 +85,11 @@ tracks/2/keys = {
|
||||
}
|
||||
|
||||
[node name="closet" type="Area2D"]
|
||||
pause_mode = 1
|
||||
script = ExtResource( 1 )
|
||||
default_action = "use"
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
animations = null
|
||||
|
||||
[node name="base" type="Line2D" parent="."]
|
||||
position = Vector2( 1.12247, 0 )
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
[ext_resource path="res://game/rooms/room02/button/button.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://game/rooms/room09/r_door.tscn" type="PackedScene" id=9]
|
||||
[ext_resource path="res://game/items/textures/genericItem_color_127.png" type="Texture" id=10]
|
||||
[ext_resource path="res://game/items/escitems/r9_bottle.tscn" type="PackedScene" id=11]
|
||||
[ext_resource path="res://game/items/inventory/r9_bottle.tscn" type="PackedScene" id=11]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=12]
|
||||
|
||||
[sub_resource type="NavigationPolygon" id=1]
|
||||
@@ -95,12 +95,10 @@ position = Vector2( 1198.65, 391.058 )
|
||||
script = ExtResource( 12 )
|
||||
|
||||
[node name="r9_closet_left" parent="Hotspots" instance=ExtResource( 5 )]
|
||||
pause_mode = 1
|
||||
position = Vector2( 435.233, 64.1518 )
|
||||
global_id = "r9_closet_left"
|
||||
esc_script = "res://game/rooms/room09/esc/closet_left.esc"
|
||||
tooltip_name = "Left closet"
|
||||
animations = null
|
||||
|
||||
[node name="Position2D" type="Position2D" parent="Hotspots/r9_closet_left"]
|
||||
position = Vector2( 69.9246, 318.898 )
|
||||
@@ -118,12 +116,10 @@ position = Vector2( -26.727, 543.448 )
|
||||
script = ExtResource( 12 )
|
||||
|
||||
[node name="r9_closet_middle" parent="Hotspots" instance=ExtResource( 5 )]
|
||||
pause_mode = 1
|
||||
position = Vector2( 572.963, 65.2113 )
|
||||
global_id = "r9_closet_middle"
|
||||
esc_script = "res://game/rooms/room09/esc/closet_middle.esc"
|
||||
tooltip_name = "Middle closet"
|
||||
animations = null
|
||||
|
||||
[node name="Position2D" type="Position2D" parent="Hotspots/r9_closet_middle"]
|
||||
position = Vector2( 65.6867, 317.839 )
|
||||
@@ -141,12 +137,10 @@ position = Vector2( -26.727, 543.448 )
|
||||
script = ExtResource( 12 )
|
||||
|
||||
[node name="r9_closet_right" parent="Hotspots" instance=ExtResource( 5 )]
|
||||
pause_mode = 1
|
||||
position = Vector2( 710.693, 66.2707 )
|
||||
global_id = "r9_closet_right"
|
||||
esc_script = "res://game/rooms/room09/esc/closet_right.esc"
|
||||
tooltip_name = "Right closet"
|
||||
animations = null
|
||||
|
||||
[node name="Position2D" type="Position2D" parent="Hotspots/r9_closet_right"]
|
||||
position = Vector2( 64.6273, 316.779 )
|
||||
@@ -194,6 +188,7 @@ esc_script = "res://game/rooms/room09/esc/stand.esc"
|
||||
interaction_direction = 2
|
||||
tooltip_name = "Stand"
|
||||
default_action = "look"
|
||||
inventory_texture = ExtResource( 10 )
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
animations = null
|
||||
|
||||
|
||||
@@ -215,6 +215,16 @@ _global_script_classes=[ {
|
||||
"path": "res://addons/escoria-core/game/scenes/inventory/inventory_ui.gd"
|
||||
}, {
|
||||
"base": "TextureButton",
|
||||
"class": "ESCInventoryButton",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/escoria-core/library/inventory/esc_inventory_button.gd"
|
||||
}, {
|
||||
"base": "Control",
|
||||
"class": "ESCInventoryContainer",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/escoria-core/library/inventory/esc_inventory_container.gd"
|
||||
}, {
|
||||
"base": "Reference",
|
||||
"class": "ESCInventoryItem",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/escoria-core/game/core-scripts/esc_inventory_item.gd"
|
||||
@@ -546,7 +556,9 @@ _global_script_class_icons={
|
||||
"ESCGroup": "",
|
||||
"ESCInputsManager": "",
|
||||
"ESCInventory": "",
|
||||
"ESCInventoryItem": "res://addons/escoria-core/design/esc_inventory_item.svg",
|
||||
"ESCInventoryButton": "",
|
||||
"ESCInventoryContainer": "",
|
||||
"ESCInventoryItem": "",
|
||||
"ESCInventoryManager": "",
|
||||
"ESCItem": "res://addons/escoria-core/design/esc_item.svg",
|
||||
"ESCLocation": "res://addons/escoria-core/design/esc_location.svg",
|
||||
@@ -637,7 +649,7 @@ search_in_file_extensions=PoolStringArray( "gd", "shader", "esc" )
|
||||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PoolStringArray( "res://addons/escoria-core/plugin.cfg", "res://addons/escoria-ui-simplemouse/plugin.cfg" )
|
||||
enabled=PoolStringArray( "res://addons/escoria-core/plugin.cfg", "res://addons/escoria-ui-9verbs/plugin.cfg" )
|
||||
|
||||
[escoria]
|
||||
|
||||
@@ -646,7 +658,7 @@ main/force_quit=true
|
||||
debug/terminate_on_warnings=false
|
||||
debug/terminate_on_errors=true
|
||||
debug/development_lang="en"
|
||||
ui/tooltip_follows_mouse=true
|
||||
ui/tooltip_follows_mouse=false
|
||||
ui/default_dialog_scene="res://game/ui/commons/dialogs/dialog_label.tscn"
|
||||
main/text_lang="fr_FR"
|
||||
main/voice_lang="fr_FR"
|
||||
@@ -658,13 +670,13 @@ main/command_directories=[ "res://addons/escoria-core/game/core-scripts/esc/comm
|
||||
debug/log_level="DEBUG"
|
||||
platform/skip_cache=false
|
||||
platform/skip_cache.mobile=true
|
||||
ui/items_autoregister_path="res://game/items/escitems/"
|
||||
ui/items_autoregister_path="res://game/items/inventory"
|
||||
main/game_version="0.1.0"
|
||||
main/savegames_path="res://saves/"
|
||||
main/settings_path="user://"
|
||||
main/escoria_version=""
|
||||
sound/speech_enabled=1
|
||||
ui/game_scene="res://addons/escoria-ui-simplemouse/game.tscn"
|
||||
ui/game_scene="res://addons/escoria-ui-9verbs/game.tscn"
|
||||
ui/dialogs_chooser="res://game/ui/commons/dialogs/text_dialog_choice.tscn"
|
||||
sound/speech_folder="res://game/speech"
|
||||
sound/speech_extension="ogg"
|
||||
@@ -672,6 +684,7 @@ ui/default_transition="curtain"
|
||||
ui/transition_paths=[ "res://addons/escoria-core/game/scenes/transitions/shaders/" ]
|
||||
ui/main_menu_scene="res://game/ui/commons/main_menu/main_menu.tscn"
|
||||
ui/pause_menu_scene="res://game/ui/commons/pause_menu/pause_menu.tscn"
|
||||
ui/inventory_item_size=Vector2( 72, 72 )
|
||||
|
||||
[input]
|
||||
|
||||
|
||||