Issue 320 (#396) - Mobile fixes
Co-authored-by: Dennis Ploeger <develop@dieploegers.de> Co-authored-by: dploeger <dploeger@users.noreply.github.com>
This commit is contained in:
@@ -59,6 +59,8 @@ func run(command_params: Array) -> int:
|
||||
escoria.main.current_scene.global_id,
|
||||
true
|
||||
)
|
||||
|
||||
escoria.event_manager.interrupt_running_event()
|
||||
|
||||
if !command_params[1]:
|
||||
escoria.main.scene_transition.transition_out()
|
||||
|
||||
@@ -6,6 +6,9 @@ class_name ESCActionManager
|
||||
# The current action was changed
|
||||
signal action_changed
|
||||
|
||||
# Emitted, when an action has been completed
|
||||
signal action_finished
|
||||
|
||||
|
||||
# Current verb used
|
||||
var current_action: String = "" setget set_current_action
|
||||
@@ -109,6 +112,7 @@ func activate(
|
||||
if event_returned[0] == ESCExecution.RC_OK:
|
||||
escoria.action_manager\
|
||||
.clear_current_action()
|
||||
emit_signal("action_finished")
|
||||
return event_returned[0]
|
||||
else:
|
||||
var errors = [
|
||||
@@ -120,14 +124,14 @@ func activate(
|
||||
]
|
||||
if combine_with.node.combine_is_one_way:
|
||||
errors.append(
|
||||
"Reason: %s's item interaction " +\
|
||||
"is one-way." % combine_with.global_id
|
||||
("Reason: %s's item interaction " +\
|
||||
"is one-way.") % combine_with.global_id
|
||||
)
|
||||
escoria.logger.report_warnings(
|
||||
"ESCActionManager.activate: Invalid action",
|
||||
errors
|
||||
)
|
||||
|
||||
emit_signal("action_finished")
|
||||
return ESCExecution.RC_ERROR
|
||||
else:
|
||||
escoria.logger.report_warnings(
|
||||
@@ -140,13 +144,15 @@ func activate(
|
||||
combine_with.global_id
|
||||
]
|
||||
]
|
||||
)
|
||||
)
|
||||
emit_signal("action_finished")
|
||||
return ESCExecution.RC_ERROR
|
||||
else:
|
||||
# We're missing a target here.
|
||||
# Tell the Label to add a conjunction and wait for another
|
||||
# click to add the target to p_param. Until then, return
|
||||
current_tool = target
|
||||
emit_signal("action_finished")
|
||||
return ESCExecution.RC_OK
|
||||
else:
|
||||
escoria.logger.report_warnings(
|
||||
@@ -175,6 +181,7 @@ func activate(
|
||||
)
|
||||
if event_returned[0] == ESCExecution.RC_OK:
|
||||
escoria.action_manager.clear_current_action()
|
||||
emit_signal("action_finished")
|
||||
return event_returned[0]
|
||||
else:
|
||||
escoria.logger.report_warnings(
|
||||
@@ -186,4 +193,5 @@ func activate(
|
||||
]
|
||||
]
|
||||
)
|
||||
emit_signal("action_finished")
|
||||
return ESCExecution.RC_ERROR
|
||||
|
||||
@@ -67,9 +67,6 @@ func _enter_tree():
|
||||
shape.set_extents(size / 2)
|
||||
area.shape_owner_add_shape(sid, shape)
|
||||
|
||||
# Handle inputs to the Area2D ourself
|
||||
area.connect("input_event", self, "manage_input")
|
||||
|
||||
add_child(area)
|
||||
|
||||
# Disable mouse filter events and connect our own events to the ESC input
|
||||
@@ -84,27 +81,30 @@ func _ready():
|
||||
# Manage inputs reaching the Area2D and emit the events to the input manager
|
||||
#
|
||||
# #### Parameters
|
||||
# - _viewport: (not used)
|
||||
# - event: Event received
|
||||
# - _shape_idx: (not used)
|
||||
func manage_input(_viewport, event, _shape_idx) -> void:
|
||||
func _input(event) -> void:
|
||||
if not escoria.current_state == escoria.GAME_STATE.DEFAULT:
|
||||
return
|
||||
if event.is_action_pressed("switch_action_verb"):
|
||||
if event.button_index == BUTTON_WHEEL_UP:
|
||||
emit_signal("mouse_wheel_up")
|
||||
elif event.button_index == BUTTON_WHEEL_DOWN:
|
||||
emit_signal("mouse_wheel_down")
|
||||
if event is InputEventMouseButton:
|
||||
if event is InputEventMouseButton and event.is_pressed():
|
||||
var p = get_global_mouse_position()
|
||||
if event.doubleclick:
|
||||
if event.button_index == BUTTON_LEFT:
|
||||
emit_signal("double_left_click_on_bg", p)
|
||||
var size
|
||||
if get_texture():
|
||||
size = get_texture().get_size()
|
||||
else:
|
||||
if event.is_pressed():
|
||||
if event.button_index == BUTTON_LEFT:
|
||||
emit_signal("left_click_on_bg", p)
|
||||
if event.button_index == BUTTON_RIGHT:
|
||||
emit_signal("right_click_on_bg", p)
|
||||
|
||||
size = rect_size
|
||||
if Rect2(rect_position, size).has_point(p):
|
||||
if event.doubleclick and event.button_index == BUTTON_LEFT:
|
||||
emit_signal("double_left_click_on_bg", p)
|
||||
elif event.button_index == BUTTON_LEFT:
|
||||
emit_signal("left_click_on_bg", p)
|
||||
elif event.button_index == BUTTON_RIGHT:
|
||||
emit_signal("right_click_on_bg", p)
|
||||
|
||||
|
||||
# Calculate the actual area taken by this background depending on its
|
||||
# Texture or set size
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# "click on background" -> player walks to position
|
||||
# "click on item" -> player walks to item then performs the action defined
|
||||
# by current verb
|
||||
|
||||
class_name ESCController
|
||||
|
||||
|
||||
|
||||
@@ -162,8 +162,6 @@ func _ready():
|
||||
connect("mouse_entered", self, "_on_mouse_entered")
|
||||
if not self.is_connected("mouse_exited", self, "_on_mouse_exited"):
|
||||
connect("mouse_exited", self, "_on_mouse_exited")
|
||||
if not self.is_connected("input_event", self, "manage_input"):
|
||||
connect("input_event", self, "manage_input")
|
||||
|
||||
# Register and connect all elements to Escoria backoffice.
|
||||
if not Engine.is_editor_hint():
|
||||
@@ -265,6 +263,39 @@ func _ready():
|
||||
_movable.last_scale = scale
|
||||
_movable.update_terrain()
|
||||
|
||||
# Manage mouse button clicks on this item by sending out signals
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - event: Triggered event
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not escoria.current_state == escoria.GAME_STATE.DEFAULT:
|
||||
return
|
||||
if event is InputEventMouseButton and event.is_pressed():
|
||||
var p = get_global_mouse_position()
|
||||
var mouse_in_shape: bool = false
|
||||
var colliders = get_world_2d().direct_space_state.intersect_point(
|
||||
p,
|
||||
32,
|
||||
[],
|
||||
2147483647,
|
||||
true,
|
||||
true
|
||||
)
|
||||
for _owner in get_shape_owners():
|
||||
for _shape_id in range(0, shape_owner_get_shape_count(_owner)):
|
||||
for _collider in colliders:
|
||||
if _collider.collider == self and\
|
||||
_collider.shape == _shape_id:
|
||||
mouse_in_shape = true
|
||||
if mouse_in_shape:
|
||||
if event.doubleclick and event.button_index == BUTTON_LEFT:
|
||||
emit_signal("mouse_double_left_clicked_item", self, event)
|
||||
elif event.button_index == BUTTON_LEFT:
|
||||
emit_signal("mouse_left_clicked_item", self, event)
|
||||
elif event.button_index == BUTTON_RIGHT:
|
||||
emit_signal("mouse_right_clicked_item", self, event)
|
||||
|
||||
|
||||
# Return the animation player node
|
||||
func get_animation_player() -> Node:
|
||||
@@ -291,9 +322,6 @@ func get_interact_position() -> Vector2:
|
||||
var interact_position = null
|
||||
for c in get_children():
|
||||
if c is Position2D:
|
||||
if c.get_owner() == self:
|
||||
interact_position = global_position
|
||||
continue
|
||||
interact_position = c.global_position
|
||||
|
||||
if interact_position == null and collision != null:
|
||||
@@ -302,31 +330,6 @@ func get_interact_position() -> Vector2:
|
||||
return interact_position
|
||||
|
||||
|
||||
# Manage mouse button clicks on this item by sending out signals
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - _viewport: not used
|
||||
# - event: Triggered event
|
||||
# - _shape_idx: not used
|
||||
func manage_input(
|
||||
_viewport: Viewport,
|
||||
event: InputEvent,
|
||||
_shape_idx: int
|
||||
) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
|
||||
if event.doubleclick:
|
||||
if event.button_index == BUTTON_LEFT:
|
||||
emit_signal("mouse_double_left_clicked_item", self, event)
|
||||
else:
|
||||
if event.is_pressed():
|
||||
if event.button_index == BUTTON_LEFT:
|
||||
emit_signal("mouse_left_clicked_item", self, event)
|
||||
elif event.button_index == BUTTON_RIGHT:
|
||||
emit_signal("mouse_right_clicked_item", self, event)
|
||||
|
||||
|
||||
# React to the mouse entering the item by emitting the respective signal
|
||||
func _on_mouse_entered():
|
||||
emit_signal("mouse_entered_item", self)
|
||||
|
||||
@@ -21,7 +21,7 @@ var input_mode = INPUT_ALL
|
||||
# A LIFO stack of hovered items
|
||||
var hover_stack: Array = []
|
||||
|
||||
# The global id fo the topmost item from the hover_stack
|
||||
# The global id of the topmost item from the hover_stack
|
||||
var hotspot_focused: String = ""
|
||||
|
||||
|
||||
@@ -261,6 +261,7 @@ func _on_mouse_left_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||
if input_mode == INPUT_ALL:
|
||||
if hover_stack.empty() or hover_stack.back() == item:
|
||||
escoria.logger.info("Item left clicked", [item.global_id, event])
|
||||
hotspot_focused = item.global_id
|
||||
escoria.main.current_scene.game.left_click_on_item(
|
||||
item.global_id,
|
||||
event
|
||||
@@ -279,6 +280,7 @@ func _on_mouse_left_double_clicked_item(
|
||||
) -> void:
|
||||
if input_mode == INPUT_ALL:
|
||||
escoria.logger.info("Item left double clicked", [item.global_id, event])
|
||||
hotspot_focused = item.global_id
|
||||
escoria.main.current_scene.game.left_double_click_on_item(
|
||||
item.global_id,
|
||||
event
|
||||
@@ -294,6 +296,7 @@ func _on_mouse_left_double_clicked_item(
|
||||
func _on_mouse_right_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||
if input_mode == INPUT_ALL:
|
||||
escoria.logger.info("Item right clicked", [item.global_id, event])
|
||||
hotspot_focused = item.global_id
|
||||
escoria.main.current_scene.game.right_click_on_item(
|
||||
item.global_id,
|
||||
event
|
||||
|
||||
@@ -68,11 +68,11 @@ func _get_voice_file(key: String, start: String = "") -> String:
|
||||
if _voice_file != "":
|
||||
return _voice_file
|
||||
else:
|
||||
if file_name == "%s.%s" % [
|
||||
if file_name == "%s.%s.import" % [
|
||||
key,
|
||||
ProjectSettings.get("escoria/sound/speech_extension")
|
||||
]:
|
||||
return start.plus_file(file_name)
|
||||
return start.plus_file(file_name.trim_suffix(".import"))
|
||||
file_name = _dir.get_next()
|
||||
return ""
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@ func _on_dialog_line_typed(object, key):
|
||||
|
||||
# Ending the dialog
|
||||
func _on_dialog_finished():
|
||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||
emit_signal("dialog_line_finished")
|
||||
queue_free()
|
||||
|
||||
|
||||
@@ -91,5 +91,4 @@ func _on_dialog_finished():
|
||||
current_character.stop_talking()
|
||||
emit_signal("dialog_line_finished")
|
||||
escoria.dialog_player.is_speaking = false
|
||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||
queue_free()
|
||||
|
||||
Reference in New Issue
Block a user