Added hover stack to manage overlapping Area2Ds
Added room selector in demo scenes Modified dialogues in room 1, fixed bug in room 8 and 9
This commit is contained in:
@@ -375,7 +375,7 @@ func change_scene(params, context, run_events=true):
|
||||
# Finally we add the setup on to of the events stack so that it is ran first
|
||||
run_event(events["setup"])
|
||||
|
||||
escoria.inputs_manager.is_hotspot_focused = false
|
||||
escoria.inputs_manager.hotspot_focused = ""
|
||||
if !scenes_cache_list.has(params[0]):
|
||||
scenes_cache_list.push_back(params[0])
|
||||
scenes_cache[room_scene.global_id] = params[0]
|
||||
@@ -431,7 +431,7 @@ func superpose_scene(params, context, run_events=true):
|
||||
get_node("/root").add_child(room_scene)
|
||||
|
||||
|
||||
escoria.inputs_manager.is_hotspot_focused = false
|
||||
escoria.inputs_manager.hotspot_focused = false
|
||||
if !scenes_cache_list.has(params[0]):
|
||||
scenes_cache_list.push_back(params[0])
|
||||
if room_scene.get("global_id"):
|
||||
|
||||
@@ -9,8 +9,8 @@ func get_class():
|
||||
ESCItem is a Sprite that defines an item, potentially interactive
|
||||
"""
|
||||
|
||||
signal mouse_entered_item(global_id)
|
||||
signal mouse_exited_item
|
||||
signal mouse_entered_item(item)
|
||||
signal mouse_exited_item(item)
|
||||
signal mouse_left_clicked_item(global_id)
|
||||
signal mouse_double_left_clicked_item(global_id)
|
||||
signal mouse_right_clicked_item(global_id)
|
||||
@@ -183,10 +183,10 @@ func manage_input(viewport : Viewport, event : InputEvent, shape_idx : int):
|
||||
|
||||
|
||||
func _on_mouse_entered():
|
||||
emit_signal("mouse_entered_item", global_id)
|
||||
emit_signal("mouse_entered_item", self)
|
||||
|
||||
func _on_mouse_exited():
|
||||
emit_signal("mouse_exited_item")
|
||||
emit_signal("mouse_exited_item", self)
|
||||
|
||||
################################################################################
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ func do(action : String, params : Array = []) -> void:
|
||||
match action:
|
||||
"walk":
|
||||
# Reset current action.
|
||||
esc_runner.set_current_action("")
|
||||
esc_runner.clear_current_action()
|
||||
|
||||
# Check moving object.
|
||||
if !escoria.esc_runner.check_obj(params[0], "escoria.do(walk)"):
|
||||
@@ -262,7 +262,6 @@ func ev_left_click_on_item(obj, event, default_action = false):
|
||||
|
||||
# If no interaction should happen after player has arrived, leave immediately.
|
||||
if dont_interact:
|
||||
print("DONT INTERACT WAS TRUE")
|
||||
return
|
||||
|
||||
var player_global_pos = main.current_scene.player.global_position
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
tool
|
||||
extends Node
|
||||
|
||||
var is_hotspot_focused : bool
|
||||
onready var hover_stack : Array = []
|
||||
onready var hotspot_focused : String = ""
|
||||
|
||||
|
||||
func _ready():
|
||||
set_process_input(true)
|
||||
@@ -13,19 +15,19 @@ func _input(event):
|
||||
###################################################################################
|
||||
|
||||
func _on_left_click_on_bg(position : Vector2):
|
||||
if !is_hotspot_focused:
|
||||
if hotspot_focused.empty():
|
||||
printt("Left click on background at ", str(position))
|
||||
escoria.main.current_scene.game.left_click_on_bg(position)
|
||||
|
||||
|
||||
func _on_double_left_click_on_bg(position : Vector2):
|
||||
if !is_hotspot_focused:
|
||||
if hotspot_focused.empty():
|
||||
printt("Double left click on background at ", str(position))
|
||||
escoria.main.current_scene.game.left_double_click_on_bg(position)
|
||||
|
||||
|
||||
func _on_right_click_on_bg(position : Vector2):
|
||||
if !is_hotspot_focused:
|
||||
if hotspot_focused.empty():
|
||||
printt("Right click on background at ", str(position))
|
||||
escoria.main.current_scene.game.right_click_on_bg(position)
|
||||
|
||||
@@ -54,15 +56,31 @@ func _on_mouse_exited_inventory_item() -> void:
|
||||
|
||||
##################################################################################
|
||||
|
||||
func _on_mouse_entered_item(item_global_id : String) -> void:
|
||||
printt("Item focused : ", item_global_id)
|
||||
is_hotspot_focused = true
|
||||
escoria.main.current_scene.game.element_focused(item_global_id)
|
||||
func _on_mouse_entered_item(item : ESCItem) -> void:
|
||||
printt("Item focused : ", item.global_id)
|
||||
|
||||
if !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)
|
||||
|
||||
hotspot_focused = hover_stack.back().global_id
|
||||
escoria.main.current_scene.game.element_focused(item.global_id)
|
||||
|
||||
func _on_mouse_exited_item() -> void:
|
||||
print("Item unfocused")
|
||||
is_hotspot_focused = false
|
||||
escoria.main.current_scene.game.element_unfocused()
|
||||
|
||||
func _on_mouse_exited_item(item : ESCItem) -> void:
|
||||
printt("Item unfocused : ", item.global_id)
|
||||
hover_stack.erase(item)
|
||||
if hover_stack.empty():
|
||||
hotspot_focused = ""
|
||||
escoria.main.current_scene.game.element_unfocused()
|
||||
else:
|
||||
hotspot_focused = hover_stack.back().global_id
|
||||
escoria.main.current_scene.game.element_focused(hotspot_focused)
|
||||
|
||||
|
||||
func _on_mouse_left_clicked_item(item_global_id : String, event : InputEvent) -> void:
|
||||
printt("Item left clicked", item_global_id, event)
|
||||
|
||||
@@ -179,3 +179,8 @@ func check_game_scene_methods():
|
||||
assert(current_scene.game.has_method("inventory_item_unfocused"))
|
||||
|
||||
assert(current_scene.game.has_method("mousewheel_action"))
|
||||
|
||||
assert(current_scene.game.has_method("hide_ui"))
|
||||
assert(current_scene.game.has_method("show_ui"))
|
||||
assert(current_scene.game.has_method("_on_event_done"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user