feat: Several fixes and optimizations (#467)
Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
@@ -24,7 +24,7 @@ const COMPARISON_DESCRIPTION = [
|
||||
"Checking if %s %s %s equals %s",
|
||||
"Checking if %s %s %s greater than %s",
|
||||
"Checking if %s %s %s less than %s",
|
||||
"Checking if %s is %s active%s"
|
||||
"Checking if %s %s %s active%s"
|
||||
]
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ func _init(comparison_string: String):
|
||||
# Run this comparison against the globals
|
||||
func run() -> bool:
|
||||
var global_name = self.flag
|
||||
|
||||
|
||||
escoria.logger.debug(
|
||||
COMPARISON_DESCRIPTION[self.comparison] % [
|
||||
"inventory item" if self.inventory else "global value",
|
||||
@@ -130,7 +130,7 @@ func run() -> bool:
|
||||
self.comparison_value:
|
||||
return_value = true
|
||||
elif self.comparison == COMPARISON_ACTIVITY and \
|
||||
escoria.object_manager.has_object(global_name) and \
|
||||
escoria.object_manager.has(global_name) and \
|
||||
escoria.object_manager.get_object(global_name).active:
|
||||
return_value = true
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ func stop():
|
||||
# - name: The animation name to play
|
||||
# - backwards: Play backwards
|
||||
func play(name: String, backwards: bool = false):
|
||||
if _is_animation_player:
|
||||
if _is_animation_player and _animation_player.current_animation != "":
|
||||
_animation_player.seek(0)
|
||||
else:
|
||||
elif not _is_animation_player:
|
||||
_animated_sprite.frame = 0
|
||||
_current_animation = name
|
||||
if backwards and _is_animation_player:
|
||||
|
||||
@@ -34,7 +34,7 @@ func perform_walk(
|
||||
if destination.node is ESCLocation:
|
||||
target_position = destination.node.global_position
|
||||
else:
|
||||
target_position = destination.node.interact_position
|
||||
target_position = destination.node.get_interact_position()
|
||||
|
||||
var walk_context = ESCWalkContext.new(
|
||||
destination,
|
||||
@@ -127,7 +127,7 @@ func perform_inputevent_on_object(
|
||||
var player_global_pos = escoria.main.current_scene.player.global_position
|
||||
var clicked_position = event.position
|
||||
|
||||
if not player_global_pos == destination_position:
|
||||
if not player_global_pos.is_equal_approx(destination_position):
|
||||
dont_interact = true
|
||||
|
||||
# If no interaction should happen after player has arrived, leave
|
||||
|
||||
@@ -256,34 +256,6 @@ func show_ui():
|
||||
pass
|
||||
|
||||
|
||||
# Function is called if Project setting escoria/ui/tooltip_follows_mouse = true
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - p_position: Position of the mouse
|
||||
func update_tooltip_following_mouse_position(p_position: Vector2):
|
||||
var corrected_position = p_position
|
||||
|
||||
# clamp TOP
|
||||
if tooltip_node.tooltip_distance_to_edge_top(p_position) <= mouse_tooltip_margin:
|
||||
corrected_position.y = mouse_tooltip_margin
|
||||
|
||||
# clamp BOTTOM
|
||||
if tooltip_node.tooltip_distance_to_edge_bottom(p_position + tooltip_node.rect_size) <= mouse_tooltip_margin:
|
||||
corrected_position.y = escoria.game_size.y - mouse_tooltip_margin - tooltip_node.rect_size.y
|
||||
|
||||
# clamp LEFT
|
||||
if tooltip_node.tooltip_distance_to_edge_left(p_position - tooltip_node.rect_size/2) <= mouse_tooltip_margin:
|
||||
corrected_position.x = mouse_tooltip_margin
|
||||
|
||||
# clamp RIGHT
|
||||
if tooltip_node.tooltip_distance_to_edge_right(p_position + tooltip_node.rect_size/2) <= mouse_tooltip_margin:
|
||||
corrected_position.x = escoria.game_size.x - mouse_tooltip_margin - tooltip_node.rect_size.x
|
||||
|
||||
tooltip_node.anchor_right = 0.2
|
||||
tooltip_node.rect_position = corrected_position + tooltip_node.offset_from_cursor
|
||||
|
||||
|
||||
# Set the Editor debug mode
|
||||
func _set_editor_debug_mode(p_editor_debug_mode: int) -> void:
|
||||
editor_debug_mode = p_editor_debug_mode
|
||||
|
||||
@@ -299,10 +299,13 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
if mouse_in_shape:
|
||||
if event.doubleclick and event.button_index == BUTTON_LEFT:
|
||||
emit_signal("mouse_double_left_clicked_item", self, event)
|
||||
get_tree().set_input_as_handled()
|
||||
elif event.button_index == BUTTON_LEFT:
|
||||
emit_signal("mouse_left_clicked_item", self, event)
|
||||
get_tree().set_input_as_handled()
|
||||
elif event.button_index == BUTTON_RIGHT:
|
||||
emit_signal("mouse_right_clicked_item", self, event)
|
||||
get_tree().set_input_as_handled()
|
||||
|
||||
|
||||
# Return the animation player node
|
||||
|
||||
Reference in New Issue
Block a user