This commit is contained in:
2023-09-22 00:50:03 +02:00
parent ebbaec2abf
commit 38dece6947
6 changed files with 71 additions and 8 deletions

View File

@@ -0,0 +1,11 @@
extends Node
class_name ESCCombinable
var _combinations:Array
func _init(combinations: Array)-> void:
_combinations = combinations
func check(action: String) -> bool:
return action in _combinations

View File

@@ -0,0 +1,11 @@
extends Node
class_name ESCTargetable
var _targets:Array
func _init(targets: Array)-> void:
_targets = targets
func check(action: String) -> bool:
return action in _targets

View File

@@ -297,8 +297,8 @@ func _set_tool_and_action(obj: ESCObject, default_action: bool):
# Check if current_action and current_tool are already set
if current_action and current_tool:
# MODIFIED FOR RETURN TO MONKEY UI
if (not current_action in escoria.action_manager\
.current_tool.node.combine_when_selected_action_is_in and not current_action in obj.node.target_when_selected_action_is_in):
if (not escoria.action_manager\
.current_tool.node.is_combinable(current_action) and not obj.node.is_targetable(current_action)):
current_tool = obj
tool_just_set = true
elif default_action:
@@ -306,7 +306,7 @@ func _set_tool_and_action(obj: ESCObject, default_action: bool):
current_action = obj.node.default_action_inventory
else:
current_action = obj.node.default_action
elif current_action in obj.node.combine_when_selected_action_is_in:
elif obj.node.is_combinable(current_action):
current_tool = obj
tool_just_set = true
return tool_just_set
@@ -320,6 +320,6 @@ func _set_tool_and_action(obj: ESCObject, default_action: bool):
func _check_item_needs_combine_obj(obj: ESCObject) -> bool:
return current_action \
and current_tool \
and (current_action in current_tool.node.combine_when_selected_action_is_in
and (current_tool.node.is_combinable(current_action)
# MODIFIED FOR RETURN TO MONKEY UI
or current_action in obj.node.target_when_selected_action_is_in)
or obj.node.is_targetable(current_action))

View File

@@ -32,6 +32,27 @@ var lastHighlightState: bool
var active: bool
# The targetable subnode
var _targetable: ESCTargetable = null
# Whether this item is targetable.
export(bool) var _is_targetable = false
func is_targetable(action: String) -> bool:
if !_is_targetable:
return false
return _targetable.check(action)
# The targetable subnode
var _combinable: ESCCombinable = null
# Whether this item is targetable.
export(bool) var _is_combinable = false
func is_combinable(action: String) -> bool:
if !_is_targetable:
return false
return _combinable.check(action)
# React to the mouse entering the item by emitting the respective signal
func mouse_entered():
active = true
@@ -54,6 +75,14 @@ func _ready():
##outline.offset = Vector2(1,1)
collision.add_child(outline)
outline.hide()
if _is_targetable:
_targetable = ESCTargetable.new(target_when_selected_action_is_in)
add_child(_targetable)
if _is_combinable:
_combinable = ESCCombinable.new(combine_when_selected_action_is_in)
add_child(_targetable)
func _process(_delta) -> void:
if(is_interactive == false):

View File

@@ -249,7 +249,7 @@ func left_double_click_on_bg(position: Vector2) -> void:
func element_focused(element_id: String) -> void:
var target_obj = escoria.object_manager.get_object(element_id).node
if target_obj is ESCItem or ESCItemWithTooltip:
if target_obj is ESCItem:
$tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
$tooltip_layer/tooltip.set_target_object(target_obj)
target_obj.highlight(true)
@@ -332,7 +332,7 @@ func right_click_on_inventory_item(inventory_item_global_id: String, event: Inpu
func inventory_item_focused(inventory_item_global_id: String) -> void:
var target_obj = escoria.object_manager.get_object(inventory_item_global_id).node
if target_obj is ESCItemWithTooltip:
if target_obj is ESCItem:
$tooltip_layer/tooltip.set_target(target_obj.action3_text)
$tooltip_layer/tooltip.set_target_object(target_obj)
@@ -397,7 +397,7 @@ func apply_custom_settings(custom_settings: Dictionary):
func get_custom_data() -> Dictionary:
return {
"ui_type": "simplemouse"
"ui_type": "rtmi-ui"
}