ESCItemWithTooltip.actionN_target_texts dictionaries
This commit is contained in:
@@ -6,7 +6,11 @@ class_name ESCItemWithTooltip, "res://addons/escoria-core/design/esc_item.svg"
|
||||
export(String) var action1_text = ""
|
||||
# Action 2 Label text
|
||||
export(String) var action2_text = ""
|
||||
# Action 3 tooltip text in inventory
|
||||
# Action 3 tooltip text if item in inventory
|
||||
export(String) var action3_text = ""
|
||||
# Action 3 tooltip text in inventory
|
||||
# Action 4 tooltip text if item in inventory
|
||||
export(String) var action4_text = ""
|
||||
# Action 3 tooltip texts if item is target. Dictionary with tool's global id as key.
|
||||
export(Dictionary) var action3_target_texts = {}
|
||||
# Action 4 tooltip texts if item is target. Dictionary with tool's global id as key.
|
||||
export(Dictionary) var action4_target_texts = {}
|
||||
|
||||
@@ -140,6 +140,9 @@ func set_target2(target2: String) -> void:
|
||||
|
||||
|
||||
# Update the tooltip text.
|
||||
# * If waiting for target item: get text from action*_target_texts dictionaries using current_tool as key
|
||||
# * If item is in inventory: use action3_text and action4_text variables
|
||||
# * Else: use action1_text and action2_text variables
|
||||
func update_tooltip_text():
|
||||
if(current_target_object == null):
|
||||
return
|
||||
@@ -147,8 +150,8 @@ func update_tooltip_text():
|
||||
var item_in_inventory = escoria.inventory_manager.inventory_has(current_target_object.global_id)
|
||||
var waiting_for_target_item = escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM
|
||||
|
||||
var action1_text = current_target_object.action3_text if item_in_inventory or waiting_for_target_item else current_target_object.action1_text
|
||||
var action2_text = current_target_object.action4_text if item_in_inventory or waiting_for_target_item else current_target_object.action2_text
|
||||
var action1_text = get_action_target_text(current_target_object.action3_target_texts) if waiting_for_target_item else current_target_object.action3_text if item_in_inventory else current_target_object.action1_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 != "";
|
||||
@@ -157,6 +160,9 @@ func update_tooltip_text():
|
||||
$tooltip2.visible = action2_text != "";
|
||||
|
||||
|
||||
func get_action_target_text(action_target_texts: Dictionary):
|
||||
var action_target_text = action_target_texts.get(escoria.action_manager.current_tool.global_id)
|
||||
return action_target_text if action_target_text else ""
|
||||
|
||||
# Update the tooltip size according to the text.
|
||||
func update_size():
|
||||
|
||||
@@ -69,8 +69,8 @@ combine_when_selected_action_is_in = [ "action4" ]
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
action1_text = "Esto es una puerta y tiene una descripcion mu larga"
|
||||
action2_text = "Entrar! con descricion..."
|
||||
action3_text = "Usar la bombona con la puerta?"
|
||||
action4_text = "Lanzarla contra la puerta"
|
||||
action3_target_texts = { "i_bombona2": "Usar la bombona con la puerta?" }
|
||||
action4_target_texts = { "i_bombona2": "Lanzarla contra la puerta" }
|
||||
animations = SubResource( 2 )
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/entrada_cocina"]
|
||||
|
||||
Reference in New Issue
Block a user