Show action3 and action4 if waiting for target item

This commit is contained in:
2023-03-08 00:40:48 +01:00
parent 8795986053
commit b09e949153
5 changed files with 14 additions and 34 deletions

View File

@@ -144,11 +144,11 @@ func update_tooltip_text():
if(current_target_object == null):
return
var itemInInventory = escoria.inventory_manager.inventory_has(current_target_object.global_id)
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.action1_text if !itemInInventory else current_target_object.action3_text
var action2_text = current_target_object.action2_text if !itemInInventory else current_target_object.action4_text
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
$tooltip1/label.text = action1_text
$tooltip1.visible = action1_text != "";

View File

@@ -241,24 +241,20 @@ func element_unfocused() -> void:
## ITEMS ##
func click_on_item(item_global_id: String, event: InputEvent, action: String) -> void:
# If we are using an inventory item reset mouse cursor
# If we are using an inventory item reset mouse cursor and use inventory actions (change action1 for action3 and action2 for action4)
if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
Input.set_custom_mouse_cursor(null)
# If we are awaiting input action use inventory actions (change action1 for action3 and action2 for action4)
if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
action = ACTION3 if action == ACTION1 else ACTION4
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 (action == ACTION1 && target_obj.action1_text != "") || (action == ACTION2 && target_obj is ESCItemWithTooltip && target_obj.action2_text != ""):
# Hide tooltip if some action is being performed
if escoria.action_manager.action_state == ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
$tooltip_layer/tooltip.hide()
func left_click_on_item(item_global_id: String, event: InputEvent) -> void:
@@ -415,11 +411,9 @@ func correctPosition(tooltip: ESCRichTooltip, size: Vector2, mouse_position: Vec
func _on_event_done(return_code: int, _event_name: String):
escoria.logger.info(self, "EVENT DONE! code=" + String(return_code))
# if return_code == ESCExecution.RC_OK:
# escoria.action_manager.clear_current_action()
# Show tooltips, they were hiddeen while performing action
$tooltip_layer/tooltip.show()
#$tooltip_layer/tooltip2.show()
# Show tooltips, they were hidden while performing action
$tooltip_layer/tooltip.update_tooltip_text()
func _on_MenuButton_pressed() -> void:

View File

@@ -1,15 +1,2 @@
:action1
say player "Es naranja"
:action2
say player "Voy a cogerla"
set_active i_bombona false
inventory_add i_bombona
# :action3
# say player "Es el segundo bolsillo más grande que he visto nunca"
:action4
say player "Antes era una bombona pero ahora es una llave inglesa."
say player "¿Esto es real?"
say player "¿Vivo en Matrix?"

View File

@@ -10,6 +10,6 @@ inventory_add i_bombona2
say player "Es el segundo bolsillo más grande que he visto nunca"
:action4
say player "Tiene pinta de dibujo animado"
say player "¡¡Al meterla en mi bolsillo se ha convertido en un dibujo animado!!"
say player "¿Esto es real?"
say player "¿Vivo en Matrix?"

View File

@@ -69,6 +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"
animations = SubResource( 2 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/entrada_cocina"]
@@ -90,9 +92,6 @@ combine_when_selected_action_is_in = [ ]
inventory_texture = ExtResource( 29 )
dialog_color = Color( 1, 1, 1, 1 )
action1_text = "Mirar bombona"
action2_text = "Coger bombona"
action3_text = "¿Cómo ha entrado en mi bolsillo?"
action4_text = "¿Por qué es una llave inglesa?"
animations = null
[node name="bombona2" parent="Hotspots" instance=ExtResource( 27 )]