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
|
||||
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 \
|
||||
else command_params[0]
|
||||
|
||||
escoria.dialog_player.say(
|
||||
player_character_global_id,
|
||||
speaking_character_global_id,
|
||||
command_params[2],
|
||||
command_params[1]
|
||||
)
|
||||
|
||||
@@ -331,7 +331,7 @@ func _get_event_to_queue(
|
||||
else:
|
||||
escoria.logger.warn(
|
||||
self,
|
||||
"Invalid action on item" +
|
||||
"Invalid action on item: " +
|
||||
"Trying to run action %s on object %s, " %
|
||||
[
|
||||
action,
|
||||
|
||||
@@ -294,6 +294,13 @@ func _on_mouse_exited_inventory_item() -> void:
|
||||
#
|
||||
# - item: The Escoria item hovered
|
||||
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):
|
||||
escoria.logger.debug(
|
||||
self,
|
||||
@@ -308,13 +315,8 @@ func _on_mouse_entered_item(item: ESCItem) -> void:
|
||||
)
|
||||
_clean_hover_stack()
|
||||
|
||||
if not hover_stack.empty():
|
||||
if item.z_index < hover_stack.back().z_index:
|
||||
hover_stack.insert(hover_stack.size() - 1, item)
|
||||
else:
|
||||
hover_stack.push_back(item)
|
||||
else:
|
||||
hover_stack.push_back(item)
|
||||
hover_stack.push_back(item)
|
||||
hover_stack.sort_custom(HoverStackSorter, "sort_ascending_z_index")
|
||||
|
||||
hotspot_focused = hover_stack.back().global_id
|
||||
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
|
||||
func _on_mouse_left_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||
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):
|
||||
escoria.logger.debug(
|
||||
self,
|
||||
@@ -381,6 +395,18 @@ func _on_mouse_left_double_clicked_item(
|
||||
event: InputEvent
|
||||
) -> void:
|
||||
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):
|
||||
escoria.logger.debug(
|
||||
self,
|
||||
@@ -411,6 +437,18 @@ func _on_mouse_left_double_clicked_item(
|
||||
# - event: The input event from the click
|
||||
func _on_mouse_right_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||
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):
|
||||
escoria.logger.debug(
|
||||
self,
|
||||
@@ -460,3 +498,10 @@ func _clean_hover_stack():
|
||||
# - item: the item to remove from the hover stack
|
||||
func _hover_stack_erase_item(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