Highlitght only when actions are present.
This commit is contained in:
@@ -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
|
and (current_action in current_tool.node.combine_when_selected_action_is_in
|
||||||
# MODIFIED FOR RETURN TO MONKEY UI
|
# MODIFIED FOR RETURN TO MONKEY UI
|
||||||
or current_action in obj.node.target_when_selected_action_is_in)
|
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 ""
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ func update_tooltip_text():
|
|||||||
|
|
||||||
$tooltip1/label.text = action1_text
|
$tooltip1/label.text = action1_text
|
||||||
$tooltip1.visible = !hidden and action1_text != "";
|
$tooltip1.visible = !hidden and action1_text != "";
|
||||||
|
|
||||||
$tooltip2/label.text = action2_text
|
$tooltip2/label.text = action2_text
|
||||||
$tooltip2.visible = !hidden and action2_text != "";
|
$tooltip2.visible = !hidden and action2_text != "";
|
||||||
|
|
||||||
|
|||||||
@@ -252,11 +252,14 @@ func element_focused(element_id: String) -> void:
|
|||||||
if target_obj is ESCItem or ESCItemWithTooltip:
|
if target_obj is ESCItem or ESCItemWithTooltip:
|
||||||
$tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
|
$tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
|
||||||
$tooltip_layer/tooltip.set_target_object(target_obj)
|
$tooltip_layer/tooltip.set_target_object(target_obj)
|
||||||
target_obj.get_component('outline').highlight(true)
|
|
||||||
if last_target != null:
|
|
||||||
last_target.get_component('outline').highlight(false)
|
|
||||||
last_target = target_obj
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
func element_unfocused() -> void:
|
func element_unfocused() -> void:
|
||||||
$tooltip_layer/tooltip.set_target("")
|
$tooltip_layer/tooltip.set_target("")
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ func highlight(value: bool):
|
|||||||
isHighlighted = value
|
isHighlighted = value
|
||||||
|
|
||||||
func _process(_delta: float):
|
func _process(_delta: float):
|
||||||
# if not escoria.action_manager.is_object_actionable(get_global_id()):
|
if(outline == null):
|
||||||
# return
|
return
|
||||||
if isHighlighted != lastHighlightState:
|
if isHighlighted != lastHighlightState:
|
||||||
if isHighlighted:
|
if isHighlighted:
|
||||||
outline.show()
|
outline.show()
|
||||||
|
|||||||
Reference in New Issue
Block a user