Removed ESCController and greatly reworked ESCActionManager (#480)
This commit is contained in:
@@ -82,6 +82,8 @@ func left_click_on_bg(position: Vector2) -> void:
|
||||
true
|
||||
)
|
||||
escoria.action_manager.clear_current_action()
|
||||
escoria.action_manager.clear_current_tool()
|
||||
tooltip.clear()
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
|
||||
@@ -93,6 +95,8 @@ func right_click_on_bg(position: Vector2) -> void:
|
||||
true
|
||||
)
|
||||
escoria.action_manager.clear_current_action()
|
||||
escoria.action_manager.clear_current_tool()
|
||||
tooltip.clear()
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
|
||||
@@ -111,21 +115,72 @@ 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
|
||||
tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
if escoria.action_manager.current_action != "use" \
|
||||
and escoria.action_manager.current_tool == null:
|
||||
if target_obj is ESCItem:
|
||||
verbs_menu.set_by_name(target_obj.default_action)
|
||||
match escoria.action_manager.action_state:
|
||||
# Don't change the tooltip if an action input is completed
|
||||
# (ie verb+item(+target)) because the action is now being executed
|
||||
# and the tooltip is already set because the item was focused
|
||||
# (see element_focused() and inventory_item_focused())
|
||||
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
|
||||
return
|
||||
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
|
||||
tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
# Hovering an ESCItem highlights its default action
|
||||
if escoria.action_manager.current_action != "use" and target_obj is ESCItem:
|
||||
verbs_menu.set_by_name(target_obj.default_action)
|
||||
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
|
||||
tooltip.set_target2(target_obj.tooltip_name)
|
||||
|
||||
|
||||
func element_unfocused() -> void:
|
||||
tooltip.clear()
|
||||
match escoria.action_manager.action_state:
|
||||
# Don't change the tooltip if an action input is completed
|
||||
# (ie verb+item(+target)) because the action is now being executed
|
||||
# and the tooltip is already set because the item was focused
|
||||
# (see element_focused() and inventory_item_focused())
|
||||
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
|
||||
return
|
||||
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
|
||||
tooltip.set_target("")
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
|
||||
tooltip.set_target2("")
|
||||
|
||||
|
||||
|
||||
## ITEMS ##
|
||||
func left_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [item_global_id, event], true)
|
||||
|
||||
var target_obj = escoria.object_manager.get_object(
|
||||
item_global_id
|
||||
).node
|
||||
|
||||
match escoria.action_manager.action_state:
|
||||
# Don't change the tooltip if an action input is completed
|
||||
# (ie verb+item(+target)) because the action is now being executed
|
||||
# and the tooltip is already set because the item was focused
|
||||
# (see element_focused() and inventory_item_focused())
|
||||
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
|
||||
return
|
||||
|
||||
# Just clicked on the item
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
|
||||
tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
# Clicked on item and now we're awaiting a target item
|
||||
# This means we clicked the tool and we now need a target
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
|
||||
tooltip.set_target(target_obj.tooltip_name, true)
|
||||
|
||||
|
||||
|
||||
func right_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
@@ -140,7 +195,29 @@ func left_double_click_on_item(item_global_id: String, event: InputEvent) -> voi
|
||||
## INVENTORY ##
|
||||
func left_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [inventory_item_global_id, event])
|
||||
|
||||
|
||||
var target_obj = escoria.object_manager.get_object(
|
||||
inventory_item_global_id
|
||||
).node
|
||||
|
||||
match escoria.action_manager.action_state:
|
||||
# Don't change the tooltip if an action input is completed
|
||||
# (ie verb+item(+target)) because the action is now being executed
|
||||
# and the tooltip is already set because the item was focused
|
||||
# (see element_focused() and inventory_item_focused())
|
||||
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
|
||||
return
|
||||
|
||||
# Just clicked on the inventory item: do nothing special
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
|
||||
return
|
||||
|
||||
# Clicked on inventory item and now we're awaiting a target item
|
||||
# This means we clicked the tool and we now need a target
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
|
||||
tooltip.set_target(target_obj.tooltip_name, true)
|
||||
|
||||
|
||||
func right_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.action_manager.set_current_action(verbs_menu.selected_action)
|
||||
@@ -153,20 +230,45 @@ func left_double_click_on_inventory_item(_inventory_item_global_id: String, _eve
|
||||
|
||||
func inventory_item_focused(inventory_item_global_id: String) -> void:
|
||||
var target_obj = escoria.object_manager.get_object(
|
||||
inventory_item_global_id
|
||||
).node
|
||||
tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
if escoria.action_manager.current_action != "use" \
|
||||
and escoria.action_manager.current_tool == null:
|
||||
if target_obj is ESCItem:
|
||||
verbs_menu.set_by_name(target_obj.default_action_inventory)
|
||||
inventory_item_global_id
|
||||
).node
|
||||
|
||||
match escoria.action_manager.action_state:
|
||||
# Don't change the tooltip if an action input is completed
|
||||
# (ie verb+item(+target)) because the action is now being executed
|
||||
# and the tooltip is already set because the item was focused
|
||||
# (see element_focused() and inventory_item_focused())
|
||||
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
|
||||
return
|
||||
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
|
||||
tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
# Hovering an ESCItem highlights its default action
|
||||
if escoria.action_manager.current_action != "use" and target_obj is ESCItem:
|
||||
verbs_menu.set_by_name(target_obj.default_action)
|
||||
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
|
||||
tooltip.set_target2(target_obj.tooltip_name)
|
||||
|
||||
|
||||
func inventory_item_unfocused() -> void:
|
||||
tooltip.set_target("")
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
|
||||
match escoria.action_manager.action_state:
|
||||
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
|
||||
# Don't change the tooltip if an action input is completed
|
||||
# (ie verb+item(+target)) because the action is now being executed
|
||||
return
|
||||
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
|
||||
tooltip.set_target("")
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
|
||||
tooltip.set_target2("")
|
||||
|
||||
|
||||
func open_inventory():
|
||||
pass
|
||||
@@ -237,3 +339,4 @@ func _on_MenuButton_pressed() -> void:
|
||||
|
||||
func _on_action_finished() -> void:
|
||||
verbs_menu.unselect_actions()
|
||||
tooltip.clear()
|
||||
|
||||
@@ -1,30 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends ESCTooltip
|
||||
|
||||
|
||||
func update_tooltip_text():
|
||||
bbcode_text = \"[center]\"
|
||||
|
||||
if !current_action.empty():
|
||||
bbcode_text += current_action
|
||||
bbcode_text += \"\\t\"
|
||||
|
||||
bbcode_text += current_target
|
||||
|
||||
if waiting_for_target2 and current_target2.empty():
|
||||
bbcode_text += \"\\t\"
|
||||
bbcode_text += current_prep
|
||||
|
||||
if !current_target2.empty():
|
||||
bbcode_text += \"\\t\"
|
||||
bbcode_text += current_prep
|
||||
bbcode_text += \"\\t\"
|
||||
bbcode_text += current_target2
|
||||
|
||||
bbcode_text += \"[/center]\"
|
||||
"
|
||||
[ext_resource path="res://addons/escoria-ui-9verbs/tooltip/tooltip_action_target.gd" type="Script" id=1]
|
||||
|
||||
[node name="tooltip" type="RichTextLabel"]
|
||||
anchor_right = 1.0
|
||||
@@ -32,7 +8,7 @@ anchor_bottom = 1.0
|
||||
bbcode_enabled = true
|
||||
bbcode_text = "[center][/center]"
|
||||
scroll_active = false
|
||||
script = SubResource( 1 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user