feat: disallows user input during scene changes
This commit is contained in:
committed by
Julian Murgia
parent
acfb3d9ddd
commit
c9c7cd2dfa
@@ -51,6 +51,9 @@ func register_reserved_globals() -> void:
|
||||
# - enable_automatic_transitions: Whether to play the transition between rooms
|
||||
# automatically or to leave the responsibility to the developer.
|
||||
func change_scene(room_path: String, enable_automatic_transitions: bool) -> void:
|
||||
# We're changing scenes, so users shouldn't be able to do stuff during.
|
||||
escoria.game_scene.disable_all_input()
|
||||
|
||||
# Clear the event queue to remove other events (there could be duplicate
|
||||
# events in there so we avoid running these multiple times). Also sets a
|
||||
# flag indicating a changing scene and interrupts any other currently-running
|
||||
@@ -323,6 +326,9 @@ func _perform_script_events(room: ESCRoom) -> void:
|
||||
# Hide main and pause menus
|
||||
escoria.game_scene.hide_main_menu()
|
||||
escoria.game_scene.unpause_game()
|
||||
|
||||
# Make sure user input is allowed
|
||||
escoria.game_scene.enable_all_input()
|
||||
|
||||
# Maybe this is ok to put in set_scene_finish() above? But it might be a bit
|
||||
# confusing to not see the matching camera.current updates.
|
||||
|
||||
@@ -463,3 +463,21 @@ func escoria_show_ui():
|
||||
# Manage signal room_deady from main.gd.
|
||||
func _on_room_ready():
|
||||
room_ready_for_inputs = true
|
||||
|
||||
|
||||
# Disallows all input to the UI.
|
||||
func disable_all_input() -> void:
|
||||
# If we aren't part of a tree yet, we sure can't get the tree.
|
||||
if get_tree() == null:
|
||||
return
|
||||
|
||||
get_tree().get_root().set_disable_input(true)
|
||||
|
||||
|
||||
# Allows all UI input.
|
||||
func enable_all_input() -> void:
|
||||
# If we aren't part of a tree yet, we sure can't get the tree.
|
||||
if get_tree() == null:
|
||||
return
|
||||
|
||||
get_tree().get_root().set_disable_input(false)
|
||||
|
||||
Reference in New Issue
Block a user