Highlitght only when actions are present.

This commit is contained in:
2023-10-29 23:50:29 +01:00
parent 9c0af41ddd
commit f0347fa6d8
4 changed files with 36 additions and 7 deletions

View File

@@ -323,3 +323,30 @@ func _check_item_needs_combine_obj(obj: ESCObject) -> bool:
and (current_action in current_tool.node.combine_when_selected_action_is_in
# MODIFIED FOR RETURN TO MONKEY UI
or current_action in obj.node.target_when_selected_action_is_in)
func has_actions(current_target_object):
if(current_target_object == null):
return
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_current_target("action3",current_target_object) if item_in_inventory else get_tooltip_from_current_target("action1",current_target_object)
if(action1_text != ""):
return true
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)
if(action2_text != ""):
return true
return false
func get_tooltip_from_current_target(verb,current_target_object):
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 ""

View File

@@ -164,7 +164,6 @@ func update_tooltip_text():
$tooltip1/label.text = action1_text
$tooltip1.visible = !hidden and action1_text != "";
$tooltip2/label.text = action2_text
$tooltip2.visible = !hidden and action2_text != "";

View File

@@ -252,9 +252,12 @@ func element_focused(element_id: String) -> void:
if target_obj is ESCItem or ESCItemWithTooltip:
$tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
$tooltip_layer/tooltip.set_target_object(target_obj)
target_obj.get_component('outline').highlight(true)
if last_target != null:
if is_instance_valid(last_target):
last_target.get_component('outline').highlight(false)
if(escoria.action_manager.has_actions(target_obj)):
target_obj.get_component('outline').highlight(true)
last_target = target_obj

View File

@@ -25,8 +25,8 @@ func highlight(value: bool):
isHighlighted = value
func _process(_delta: float):
# if not escoria.action_manager.is_object_actionable(get_global_id()):
# return
if(outline == null):
return
if isHighlighted != lastHighlightState:
if isHighlighted:
outline.show()