some fixes
This commit is contained in:
@@ -5,7 +5,11 @@ var item_count_manager: ESCItemCountManager
|
||||
var tooltip_manager: ESCTootltipManager
|
||||
|
||||
func get_item(global_id: String) -> ESCItem:
|
||||
var node = escoria.object_manager.get_object(global_id).node
|
||||
var object = escoria.object_manager.get_object(global_id)
|
||||
if !object:
|
||||
return null
|
||||
|
||||
var node = object.node
|
||||
if not node is ESCItem:
|
||||
escoria.logger.error(
|
||||
"set_tootltip: invalid object",
|
||||
|
||||
@@ -8,6 +8,8 @@ func setTooltip(global_id: String, verb: String, text: String) -> void:
|
||||
|
||||
func getTooltip(global_id, verb):
|
||||
var item = gymkhana.get_item(global_id)
|
||||
if item == null:
|
||||
return ""
|
||||
if(!item.custom_data.has("tooltips")):
|
||||
return ""
|
||||
|
||||
|
||||
@@ -2,6 +2,12 @@ tool
|
||||
extends ESCItem
|
||||
class_name ESCItemWithTooltip, "res://addons/escoria-core/design/esc_item.svg"
|
||||
|
||||
# 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 = {}
|
||||
|
||||
# If action used by player is in this list, this is a valid target (second item in combination)
|
||||
export(Array) var target_when_selected_action_is_in = []
|
||||
|
||||
|
||||
@@ -156,20 +156,20 @@ func update_tooltip_text():
|
||||
if(current_target_object == null):
|
||||
return
|
||||
|
||||
var action1_text = "";
|
||||
var action2_text = "";
|
||||
var left_click_text = "";
|
||||
var right_click_text = "";
|
||||
|
||||
if current_target_object.is_interactive and escoria.current_state == escoria.GAME_STATE.DEFAULT:
|
||||
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
|
||||
|
||||
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")
|
||||
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")
|
||||
left_click_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")
|
||||
right_click_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 != "";
|
||||
$tooltip2/label.text = action2_text
|
||||
$tooltip2.visible = !hidden and action2_text != "";
|
||||
$tooltip1/label.text = left_click_text
|
||||
$tooltip1.visible = !hidden and left_click_text != "";
|
||||
$tooltip2/label.text = right_click_text
|
||||
$tooltip2.visible = !hidden and right_click_text != "";
|
||||
|
||||
func get_tooltip_from_current_target(verb):
|
||||
return gymkhana.tooltip_manager.getTooltip(current_target_object.global_id, verb)
|
||||
|
||||
Reference in New Issue
Block a user