Right click on inventory items

This commit is contained in:
2023-02-16 17:29:30 +01:00
parent 6f1d2d89da
commit 551aa1fd05
5 changed files with 35 additions and 17 deletions

View File

@@ -15,11 +15,11 @@ export(int) var action1_y = 0
# The text for the tooltip of action2
export(String) var tooltip2_name
# Action1 enabled in inventory
export(bool) var inventory_action1_enabled
# Action1 tooltip text in inventory
export(String) var inventory_action1_text
# Action2 enabled in inventory
export(bool) var inventory_action2_enabled
# Action2 tooltip text in inventory
export(String) var inventory_action2_text
#$tooltips.visible = true;
var action1Tooltip: Object

View File

@@ -260,19 +260,33 @@ func left_double_click_on_item(item_global_id: String, event: InputEvent) -> voi
## INVENTORY ##
func click_on_inventory_item(item_global_id: String, event: InputEvent, action: String) -> void:
escoria.action_manager.set_current_action(action)
var target_obj = escoria.object_manager.get_object(item_global_id).node
escoria.action_manager.do(
escoria.action_manager.ACTION.ITEM_LEFT_CLICK,
[item_global_id, event],
true
)
if (target_obj is ESCItemWithTooltip) && (action == ACTION1 && target_obj.inventory_action1_text != "") || (action == ACTION2 && target_obj.inventory_action2_text != ""):
$tooltip_layer/tooltip.hide()
$tooltip_layer/tooltip2.hide()
func left_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
click_on_item(inventory_item_global_id, event, ACTION1)
click_on_inventory_item(inventory_item_global_id, event, ACTION1)
func right_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
click_on_item(inventory_item_global_id, event, ACTION2)
click_on_inventory_item(inventory_item_global_id, event, ACTION2)
func inventory_item_focused(inventory_item_global_id: String) -> void:
var target_obj = escoria.object_manager.get_object(inventory_item_global_id).node
if target_obj is ESCItem && target_obj.inventory_action1_enabled:
$tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
if (target_obj is ESCItemWithTooltip) && target_obj.inventory_action2_enabled:
$tooltip_layer/tooltip2.set_target(target_obj.tooltip2_name)
if target_obj is ESCItemWithTooltip:
$tooltip_layer/tooltip.set_target(target_obj.inventory_action1_text)
$tooltip_layer/tooltip2.set_target(target_obj.inventory_action2_text)
func inventory_item_unfocused() -> void: