unified tooltips as dictionary (#8)
## Changes - From one variable for each tooltip to dictionary - Should not break the game. ## How to test - Run game - In `cocina_delante` every tooltip yould appear as always. - The rest of the rooms/items appear without tooltip. ## Side effects - `set_tooltip` ESC command doesn't work untill `tooltip` is set to the in the new way. It changes the tooltip to every object without the new tooltip. - Should be gone when we update every object. Reviewed-on: gymkhana/gymkhana#8 Co-authored-by: oier <oierbravo@gmail.com> Co-committed-by: oier <oierbravo@gmail.com>
This commit is contained in:
@@ -14,6 +14,8 @@ export(String) var action3_text = ""
|
||||
# Action 4 tooltip text if item in inventory
|
||||
export(String) var action4_text = ""
|
||||
|
||||
export(Dictionary) var tooltips = {}
|
||||
|
||||
# Action 3 tooltip texts if item is target. Dictionary with tool's global id as key.
|
||||
export(Dictionary) var action3_target_texts = {}
|
||||
|
||||
@@ -69,7 +71,7 @@ func highlight(value: bool):
|
||||
isHighlighted = 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")):
|
||||
|
||||
@@ -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 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
|
||||
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") if item_in_inventory else get_tooltip_from_current_target("action1")
|
||||
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") if item_in_inventory else get_tooltip_from_current_target("action2")
|
||||
|
||||
$tooltip1/label.text = action1_text
|
||||
$tooltip1.visible = !hidden and action1_text != "";
|
||||
@@ -164,7 +164,11 @@ func update_tooltip_text():
|
||||
$tooltip2/label.text = action2_text
|
||||
$tooltip2.visible = !hidden and action2_text != "";
|
||||
|
||||
|
||||
func get_tooltip_from_current_target(verb):
|
||||
var tooltips = current_target_object.get('tooltips')
|
||||
if(tooltips.has(verb)):
|
||||
return tooltips.get(verb)
|
||||
return ""
|
||||
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 ""
|
||||
|
||||
@@ -123,7 +123,7 @@ func _exit_tree():
|
||||
func _input(event: InputEvent) -> void:
|
||||
if escoria.get_escoria().is_ready_for_inputs():
|
||||
if event is InputEventMouseMotion:
|
||||
#_current_mouse_pos = get_global_mouse_position()
|
||||
#_current_mouse_pos = get_global_mouse_position() # Escoria core
|
||||
_current_mouse_pos = get_viewport().get_mouse_position()
|
||||
update_tooltip_following_mouse_position(tooltip_node)
|
||||
update_tooltip_following_mouse_position(tooltip2_node)
|
||||
@@ -404,7 +404,7 @@ func calculateMousePosition(size: Vector2):
|
||||
size.x / 2
|
||||
size.y / 2
|
||||
#escoria.logger.info(self, "_current_mouse_pos" + String(_current_mouse_pos.x) + " gameSize: " + escoria.game_size.x)
|
||||
|
||||
|
||||
#return _current_mouse_pos - size
|
||||
return _current_mouse_pos
|
||||
|
||||
|
||||
Reference in New Issue
Block a user