set_tooltip command

This commit is contained in:
2023-09-04 19:34:23 +02:00
parent c00c52eee4
commit 3a3a0bc982
3 changed files with 31 additions and 17 deletions

View File

@@ -71,7 +71,7 @@ func highlight(value: bool):
highlight = value
func set_tooltip(action: String, text: String):
set(action + "_text", text)
tooltips[action] = text
func _input(event):
if(event.is_action_pressed("ui_show_hints")):

View File

@@ -155,8 +155,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 = get_action_target_text(current_target_object.action3_target_texts) if waiting_for_target_item else get_tooltip_from_object("action3",current_target_object) if item_in_inventory else get_tooltip_from_object("action1",current_target_object)
var action2_text = get_action_target_text(current_target_object.action4_target_texts) if waiting_for_target_item else get_tooltip_from_object("action4",current_target_object) if item_in_inventory else get_tooltip_from_object("action2",current_target_object)
var action1_text = get_action_target_text(current_target_object.action3_target_texts) if waiting_for_target_item else get_tooltip_from_current_target("action3",current_target_object) if item_in_inventory else get_tooltip_from_current_target("action1",current_target_object)
var action2_text = get_action_target_text(current_target_object.action4_target_texts) if waiting_for_target_item else get_tooltip_from_current_target("action4",current_target_object) if item_in_inventory else get_tooltip_from_current_target("action2",current_target_object)
$tooltip1/label.text = action1_text
$tooltip1.visible = !hidden and action1_text != "";
@@ -164,8 +164,8 @@ func update_tooltip_text():
$tooltip2/label.text = action2_text
$tooltip2.visible = !hidden and action2_text != "";
func get_tooltip_from_object(verb, object):
var tooltips = object.get('tooltips')
func get_tooltip_from_current_target(verb, object):
var tooltips = current_target_object.get('tooltips')
if(tooltips.has(verb)):
return tooltips.get(verb)
return ""

View File

@@ -46,8 +46,10 @@ esc_script = "res://gymkhana/rooms/turno_cocina/despensa/esc/puerta_exterior.esc
is_exit = true
combine_when_selected_action_is_in = [ ]
dialog_color = Color( 1, 1, 1, 1 )
action1_text = "Salir fuera"
animations = null
tooltips = {
"action1": "Salir fuera"
}
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="puerta_exterior"]
position = Vector2( 129, -721 )
@@ -73,8 +75,10 @@ global_id = "turno_cocina_despensa_cebolla_izq"
esc_script = "res://gymkhana/rooms/turno_cocina/despensa/esc/cebolla_izq.esc"
combine_when_selected_action_is_in = [ ]
dialog_color = Color( 1, 1, 1, 1 )
action1_text = "Mirar cebollas"
action2_text = "Coger cebollas"
tooltips = {
"action1": "Mirar cebollas",
"action2": "Coger cebollas"
}
animations = null
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="cebolla izq"]
@@ -94,8 +98,10 @@ global_id = "turno_cocina_despensa_cebolla_der"
esc_script = "res://gymkhana/rooms/turno_cocina/despensa/esc/cebolla_der.esc"
combine_when_selected_action_is_in = [ ]
dialog_color = Color( 1, 1, 1, 1 )
action1_text = "Mirar cebollas"
action2_text = "Coger cebollas"
tooltips = {
"action1": "Mirar cebollas",
"action2": "Coger cebollas"
}
animations = null
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="cebolla der"]
@@ -115,8 +121,10 @@ global_id = "turno_cocina_despensa_bidon_der"
esc_script = "res://gymkhana/rooms/turno_cocina/despensa/esc/bidon_der.esc"
combine_when_selected_action_is_in = [ ]
dialog_color = Color( 1, 1, 1, 1 )
action1_text = "Mirar dentro"
action2_text = "Coger"
tooltips = {
"action1": "Mirar dentro",
"action2": "Coger"
}
animations = null
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="bidon_der"]
@@ -136,8 +144,10 @@ global_id = "turno_cocina_despensa_bidon_izq"
esc_script = "res://gymkhana/rooms/turno_cocina/despensa/esc/bidon_der.esc"
combine_when_selected_action_is_in = [ ]
dialog_color = Color( 1, 1, 1, 1 )
action1_text = "Mirar dentro"
action2_text = "Coger"
tooltips = {
"action1": "Mirar dentro",
"action2": "Coger"
}
animations = null
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="bidon_izq"]
@@ -152,7 +162,9 @@ script = ExtResource( 5 )
[node name="turno_cocina_patata_grande" parent="." instance=ExtResource( 7 )]
position = Vector2( 440, 161 )
scale = Vector2( 0.880435, 0.88735 )
action1_text = "Mirar"
tooltips = {
"action1": "Mirar"
}
[node name="ESCLocation2" type="Position2D" parent="turno_cocina_patata_grande"]
position = Vector2( 40.8889, 672.79 )
@@ -175,8 +187,10 @@ global_id = "turno_cocina_despensa_bidon_cntr"
esc_script = "res://gymkhana/rooms/turno_cocina/despensa/esc/bidon_cntr.esc"
combine_when_selected_action_is_in = [ ]
dialog_color = Color( 1, 1, 1, 1 )
action1_text = "Mirar dentro"
action2_text = "Coger"
tooltips = {
"action1": "Mirar dentro",
"action2": "Coger"
}
action3_target_texts = {
"turno_cocina_bol": "Coger lentejas a ojo",
"turno_cocina_peso_bol": "Coger las lentejas exactas"