From f0347fa6d82fdc8f286db54b5b7ab0abdb2cfd78 Mon Sep 17 00:00:00 2001 From: Oier Bravo Urtasun Date: Sun, 29 Oct 2023 23:50:29 +0100 Subject: [PATCH] Highlitght only when actions are present. --- .../esc/esc_action_manager_monkey.gd | 27 +++++++++++++++++++ .../esc_rich_tooltip.gd | 1 - .../escoria-ui-return-monkey-island/game.gd | 11 +++++--- .../ESCItemComponentOutline.gd | 4 +-- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/gymkhana/addons/escoria-ui-return-monkey-island/esc/esc_action_manager_monkey.gd b/gymkhana/addons/escoria-ui-return-monkey-island/esc/esc_action_manager_monkey.gd index 78f5d0ca..7d60f9e7 100644 --- a/gymkhana/addons/escoria-ui-return-monkey-island/esc/esc_action_manager_monkey.gd +++ b/gymkhana/addons/escoria-ui-return-monkey-island/esc/esc_action_manager_monkey.gd @@ -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 "" + diff --git a/gymkhana/addons/escoria-ui-return-monkey-island/esc_rich_tooltip.gd b/gymkhana/addons/escoria-ui-return-monkey-island/esc_rich_tooltip.gd index da9c5a4c..73ccf42f 100644 --- a/gymkhana/addons/escoria-ui-return-monkey-island/esc_rich_tooltip.gd +++ b/gymkhana/addons/escoria-ui-return-monkey-island/esc_rich_tooltip.gd @@ -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 != ""; diff --git a/gymkhana/addons/escoria-ui-return-monkey-island/game.gd b/gymkhana/addons/escoria-ui-return-monkey-island/game.gd index b3e8ee15..a092ca4d 100644 --- a/gymkhana/addons/escoria-ui-return-monkey-island/game.gd +++ b/gymkhana/addons/escoria-ui-return-monkey-island/game.gd @@ -252,11 +252,14 @@ 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: - 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: $tooltip_layer/tooltip.set_target("") diff --git a/gymkhana/addons/escoria-ui-return-monkey-island/item_components/ESCItemComponentOutline.gd b/gymkhana/addons/escoria-ui-return-monkey-island/item_components/ESCItemComponentOutline.gd index 92eb2f3f..95f8daaa 100644 --- a/gymkhana/addons/escoria-ui-return-monkey-island/item_components/ESCItemComponentOutline.gd +++ b/gymkhana/addons/escoria-ui-return-monkey-island/item_components/ESCItemComponentOutline.gd @@ -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()