feat: changed approach for disabling input during scene transitions; this should be cleaner and also delays re-enabling of input until after transition in is finished (if there is one)
This commit is contained in:
committed by
Julian Murgia
parent
85947794b9
commit
954e014cbf
@@ -27,11 +27,13 @@ const RESERVED_GLOBALS = {
|
|||||||
# ESC commands kept around for references to their command names.
|
# ESC commands kept around for references to their command names.
|
||||||
var _transition: TransitionCommand
|
var _transition: TransitionCommand
|
||||||
var _wait: WaitCommand
|
var _wait: WaitCommand
|
||||||
|
var _accept_input: AcceptInputCommand
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
_transition = TransitionCommand.new()
|
_transition = TransitionCommand.new()
|
||||||
_wait = WaitCommand.new()
|
_wait = WaitCommand.new()
|
||||||
|
_accept_input = AcceptInputCommand.new()
|
||||||
|
|
||||||
|
|
||||||
# Registers all reserved global flags for use.
|
# Registers all reserved global flags for use.
|
||||||
@@ -52,7 +54,7 @@ func register_reserved_globals() -> void:
|
|||||||
# automatically or to leave the responsibility to the developer.
|
# automatically or to leave the responsibility to the developer.
|
||||||
func change_scene(room_path: String, enable_automatic_transitions: bool) -> void:
|
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.
|
# We're changing scenes, so users shouldn't be able to do stuff during.
|
||||||
escoria.game_scene.disable_all_input()
|
escoria.inputs_manager.input_mode = escoria.inputs_manager.INPUT_NONE
|
||||||
|
|
||||||
# Clear the event queue to remove other events (there could be duplicate
|
# 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
|
# events in there so we avoid running these multiple times). Also sets a
|
||||||
@@ -327,9 +329,6 @@ func _perform_script_events(room: ESCRoom) -> void:
|
|||||||
escoria.game_scene.hide_main_menu()
|
escoria.game_scene.hide_main_menu()
|
||||||
escoria.game_scene.unpause_game()
|
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
|
# 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.
|
# confusing to not see the matching camera.current updates.
|
||||||
new_player_camera.make_current()
|
new_player_camera.make_current()
|
||||||
@@ -347,29 +346,35 @@ func _perform_script_events(room: ESCRoom) -> void:
|
|||||||
|
|
||||||
escoria.inputs_manager.hotspot_focused = ""
|
escoria.inputs_manager.hotspot_focused = ""
|
||||||
|
|
||||||
|
var command_strings: PoolStringArray = []
|
||||||
|
|
||||||
|
command_strings.append("%s%s" % [ESCEvent.PREFIX, escoria.event_manager.EVENT_TRANSITION_IN])
|
||||||
|
|
||||||
if room.enabled_automatic_transitions \
|
if room.enabled_automatic_transitions \
|
||||||
or (
|
or (
|
||||||
not room.enabled_automatic_transitions \
|
not room.enabled_automatic_transitions \
|
||||||
and escoria.globals_manager.get_global( \
|
and escoria.globals_manager.get_global( \
|
||||||
escoria.room_manager.GLOBAL_FORCE_LAST_SCENE_NULL)
|
escoria.room_manager.GLOBAL_FORCE_LAST_SCENE_NULL)
|
||||||
):
|
):
|
||||||
var script_transition_in = escoria.esc_compiler.compile([
|
|
||||||
"%s%s" % [ESCEvent.PREFIX, escoria.event_manager.EVENT_TRANSITION_IN],
|
command_strings.append("%s %s in" %
|
||||||
"%s %s in" %
|
[
|
||||||
[
|
_transition.get_command_name(),
|
||||||
_transition.get_command_name(),
|
escoria.project_settings_manager.get_setting(
|
||||||
escoria.project_settings_manager.get_setting(
|
escoria.project_settings_manager.DEFAULT_TRANSITION
|
||||||
escoria.project_settings_manager.DEFAULT_TRANSITION
|
)
|
||||||
)
|
]
|
||||||
],
|
|
||||||
"%s 0.1" % _wait.get_command_name()
|
|
||||||
],
|
|
||||||
get_class()
|
|
||||||
)
|
|
||||||
escoria.event_manager.queue_event(
|
|
||||||
script_transition_in.events[escoria.event_manager.EVENT_TRANSITION_IN],
|
|
||||||
true
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
command_strings.append("%s 0.1" % _wait.get_command_name())
|
||||||
|
|
||||||
|
command_strings.append("%s ALL" % _accept_input.get_command_name())
|
||||||
|
|
||||||
|
var script_transition_in = escoria.esc_compiler.compile(command_strings, get_class())
|
||||||
|
|
||||||
|
escoria.event_manager.queue_event(
|
||||||
|
script_transition_in.events[escoria.event_manager.EVENT_TRANSITION_IN]
|
||||||
|
)
|
||||||
|
|
||||||
var ready_event_added: bool = false
|
var ready_event_added: bool = false
|
||||||
# Run the ready event, if there is one.
|
# Run the ready event, if there is one.
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ func _exit_tree():
|
|||||||
"_on_action_finished"
|
"_on_action_finished"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
escoria.main.disconnect(
|
||||||
|
"room_ready",
|
||||||
|
self,
|
||||||
|
"_on_room_ready"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Ready function
|
# Ready function
|
||||||
func _ready():
|
func _ready():
|
||||||
@@ -463,21 +469,3 @@ func escoria_show_ui():
|
|||||||
# Manage signal room_deady from main.gd.
|
# Manage signal room_deady from main.gd.
|
||||||
func _on_room_ready():
|
func _on_room_ready():
|
||||||
room_ready_for_inputs = true
|
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