Set tooltips as hidden while performing actions

This commit is contained in:
2023-03-10 18:38:51 +01:00
parent 99d2b89a4e
commit 9569d4f30f
2 changed files with 15 additions and 8 deletions

View File

@@ -28,7 +28,6 @@ export(Vector2) var offset_from_cursor_action2 = Vector2(5,-5)
# Activates debug mode. If enabled, shows the label with a white background.
export(bool) var debug_mode = false setget set_debug_mode
# Infinitive verb
var current_action: String
@@ -54,6 +53,9 @@ var debug_texturerect_node: TextureRect
# Indicates whether the current room is loaded and ready
var _room_is_ready: bool = false
# Tooltips are hidden
var hidden: bool = false
signal tooltip_size_updated
# Connect relevant functions
@@ -157,10 +159,10 @@ func update_tooltip_text():
var action2_text = get_action_target_text(current_target_object.action4_target_texts) if waiting_for_target_item else current_target_object.action4_text if item_in_inventory else current_target_object.action2_text
$tooltip1/label.text = action1_text
$tooltip1.visible = action1_text != "";
$tooltip1.visible = !hidden and action1_text != "";
$tooltip2/label.text = action2_text
$tooltip2.visible = action2_text != "";
$tooltip2.visible = !hidden and action2_text != "";
func get_action_target_text(action_target_texts: Dictionary):
@@ -249,6 +251,8 @@ func tooltip_distance_to_edge_right(position: Vector2):
func show():
escoria.logger.info(self, "show")
hidden = false
update_tooltip_text()
# if _room_is_ready:
# $tooltip1.visible = true;
# $tooltip2.visible = true;
@@ -264,6 +268,10 @@ func hide():
#$label.visible = false;
#$background.visible = false;
func setHidden():
hidden = true
hide()
# Clear the tooltip targets texts
func clear():
waiting_for_target2 = false

View File

@@ -255,7 +255,7 @@ func click_on_item(item_global_id: String, event: InputEvent, action: String) ->
# Hide tooltip if some action is being performed
if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
$tooltip_layer/tooltip.hide()
$tooltip_layer/tooltip.setHidden()
func left_click_on_item(item_global_id: String, event: InputEvent) -> void:
click_on_item(item_global_id, event, ACTION1)
@@ -291,9 +291,8 @@ func click_on_inventory_item(item_global_id: String, event: InputEvent, action:
)
# Hide tooltip if some action is being performed
# if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
if (target_obj is ESCItemWithTooltip) && (action == ACTION3 && target_obj.action3_text != "") || (action == ACTION4 && target_obj.action4_text != ""):
$tooltip_layer/tooltip.hide()
if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
$tooltip_layer/tooltip.setHidden()
func left_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
click_on_inventory_item(inventory_item_global_id, event, ACTION3)
@@ -423,7 +422,7 @@ func _on_event_done(return_code: int, _event_name: String):
Input.set_custom_mouse_cursor(null)
# Show tooltips, they were hidden while performing action
$tooltip_layer/tooltip.update_tooltip_text()
$tooltip_layer/tooltip.show()
func _on_MenuButton_pressed() -> void: