fix: adds proper player selectable checking in click events; also properly orders hover_stack in ascending z_index order
This commit is contained in:
@@ -105,12 +105,12 @@ func run(command_params: Array) -> int:
|
|||||||
# Replace the names of any globals in "{ }" with their value
|
# Replace the names of any globals in "{ }" with their value
|
||||||
command_params[1] = escoria.globals_manager.replace_globals(command_params[1])
|
command_params[1] = escoria.globals_manager.replace_globals(command_params[1])
|
||||||
|
|
||||||
var player_character_global_id = escoria.main.current_scene.player.global_id \
|
var speaking_character_global_id = escoria.main.current_scene.player.global_id \
|
||||||
if command_params[0].to_upper() == CURRENT_PLAYER_KEYWORD \
|
if command_params[0].to_upper() == CURRENT_PLAYER_KEYWORD \
|
||||||
else command_params[0]
|
else command_params[0]
|
||||||
|
|
||||||
escoria.dialog_player.say(
|
escoria.dialog_player.say(
|
||||||
player_character_global_id,
|
speaking_character_global_id,
|
||||||
command_params[2],
|
command_params[2],
|
||||||
command_params[1]
|
command_params[1]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ func _get_event_to_queue(
|
|||||||
else:
|
else:
|
||||||
escoria.logger.warn(
|
escoria.logger.warn(
|
||||||
self,
|
self,
|
||||||
"Invalid action on item" +
|
"Invalid action on item: " +
|
||||||
"Trying to run action %s on object %s, " %
|
"Trying to run action %s on object %s, " %
|
||||||
[
|
[
|
||||||
action,
|
action,
|
||||||
|
|||||||
@@ -294,6 +294,13 @@ func _on_mouse_exited_inventory_item() -> void:
|
|||||||
#
|
#
|
||||||
# - item: The Escoria item hovered
|
# - item: The Escoria item hovered
|
||||||
func _on_mouse_entered_item(item: ESCItem) -> void:
|
func _on_mouse_entered_item(item: ESCItem) -> void:
|
||||||
|
if item as ESCPlayer and not (item as ESCPlayer).selectable:
|
||||||
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Ignoring mouse entering player %s: Player not selectable." % [item.global_id]
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
if not escoria.action_manager.is_object_actionable(item.global_id):
|
if not escoria.action_manager.is_object_actionable(item.global_id):
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
self,
|
self,
|
||||||
@@ -308,13 +315,8 @@ func _on_mouse_entered_item(item: ESCItem) -> void:
|
|||||||
)
|
)
|
||||||
_clean_hover_stack()
|
_clean_hover_stack()
|
||||||
|
|
||||||
if not hover_stack.empty():
|
hover_stack.push_back(item)
|
||||||
if item.z_index < hover_stack.back().z_index:
|
hover_stack.sort_custom(HoverStackSorter, "sort_ascending_z_index")
|
||||||
hover_stack.insert(hover_stack.size() - 1, item)
|
|
||||||
else:
|
|
||||||
hover_stack.push_back(item)
|
|
||||||
else:
|
|
||||||
hover_stack.push_back(item)
|
|
||||||
|
|
||||||
hotspot_focused = hover_stack.back().global_id
|
hotspot_focused = hover_stack.back().global_id
|
||||||
escoria.main.current_scene.game.element_focused(hotspot_focused)
|
escoria.main.current_scene.game.element_focused(hotspot_focused)
|
||||||
@@ -347,6 +349,18 @@ func _on_mouse_exited_item(item: ESCItem) -> void:
|
|||||||
# - event: The input event from the click
|
# - event: The input event from the click
|
||||||
func _on_mouse_left_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
func _on_mouse_left_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||||
if input_mode == INPUT_ALL:
|
if input_mode == INPUT_ALL:
|
||||||
|
if item as ESCPlayer and not (item as ESCPlayer).selectable:
|
||||||
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Ignoring left click on player %s: Player not selectable." % [item.global_id]
|
||||||
|
)
|
||||||
|
|
||||||
|
if not hover_stack.empty():
|
||||||
|
var next_item = hover_stack.pop_back()
|
||||||
|
_on_mouse_left_clicked_item(next_item, event)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
if not escoria.action_manager.is_object_actionable(item.global_id):
|
if not escoria.action_manager.is_object_actionable(item.global_id):
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
self,
|
self,
|
||||||
@@ -381,6 +395,18 @@ func _on_mouse_left_double_clicked_item(
|
|||||||
event: InputEvent
|
event: InputEvent
|
||||||
) -> void:
|
) -> void:
|
||||||
if input_mode == INPUT_ALL:
|
if input_mode == INPUT_ALL:
|
||||||
|
if item as ESCPlayer and not (item as ESCPlayer).selectable:
|
||||||
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Ignoring double-left click on player %s: Player not selectable." % [item.global_id]
|
||||||
|
)
|
||||||
|
|
||||||
|
if not hover_stack.empty():
|
||||||
|
var next_item = hover_stack.pop_back()
|
||||||
|
_on_mouse_left_double_clicked_item(next_item, event)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
if not escoria.action_manager.is_object_actionable(item.global_id):
|
if not escoria.action_manager.is_object_actionable(item.global_id):
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
self,
|
self,
|
||||||
@@ -411,6 +437,18 @@ func _on_mouse_left_double_clicked_item(
|
|||||||
# - event: The input event from the click
|
# - event: The input event from the click
|
||||||
func _on_mouse_right_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
func _on_mouse_right_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||||
if input_mode == INPUT_ALL:
|
if input_mode == INPUT_ALL:
|
||||||
|
if item as ESCPlayer and not (item as ESCPlayer).selectable:
|
||||||
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Ignoring right click on player %s: Player not selectable." % [item.global_id]
|
||||||
|
)
|
||||||
|
|
||||||
|
if not hover_stack.empty():
|
||||||
|
var next_item = hover_stack.pop_back()
|
||||||
|
_on_mouse_right_clicked_item(next_item, event)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
if not escoria.action_manager.is_object_actionable(item.global_id):
|
if not escoria.action_manager.is_object_actionable(item.global_id):
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
self,
|
self,
|
||||||
@@ -460,3 +498,10 @@ func _clean_hover_stack():
|
|||||||
# - item: the item to remove from the hover stack
|
# - item: the item to remove from the hover stack
|
||||||
func _hover_stack_erase_item(item):
|
func _hover_stack_erase_item(item):
|
||||||
hover_stack.erase(item)
|
hover_stack.erase(item)
|
||||||
|
|
||||||
|
|
||||||
|
class HoverStackSorter:
|
||||||
|
static func sort_ascending_z_index(a, b):
|
||||||
|
if a.z_index < b.z_index:
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user