From 6dd0a2cd1958d7dbd7542aa85b09596e4fd14255 Mon Sep 17 00:00:00 2001 From: Duncan Brown Date: Wed, 31 May 2023 12:21:52 -0400 Subject: [PATCH] fix: forces all show_menu and hide_menu commands to use auto transitions since the pause menu pauses the game, blocking further ESC script commands from running; updates room 14 for now --- .../core-scripts/esc/commands/hide_menu.gd | 43 +++++------- .../core-scripts/esc/commands/show_menu.gd | 69 ++++++++----------- game/rooms/room12/esc/transition_blackout.esc | 2 +- game/rooms/room14/esc/button_main_menu.esc | 7 +- .../esc/button_main_menu_change_scene.esc | 41 ----------- .../button_main_menu_change_scene_auto.esc | 30 -------- game/rooms/room14/esc/button_pause_menu.esc | 12 ++-- game/rooms/room14/esc/room14.esc | 2 +- game/rooms/room14/room14.tscn | 57 +-------------- 9 files changed, 56 insertions(+), 207 deletions(-) delete mode 100644 game/rooms/room14/esc/button_main_menu_change_scene.esc delete mode 100644 game/rooms/room14/esc/button_main_menu_change_scene_auto.esc diff --git a/addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd b/addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd index 8e057dc9f..bf58b789b 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd @@ -1,18 +1,11 @@ -# `hide_menu menu_type [enable_automatic_transition]` +# `hide_menu menu_type` # -# Hides either the main menu or the pause menu. The enable_automatic_transition -# parameter can be used to specify if Escoria manages the graphical transition -# for you or not. -# Setting `enable_automatic_transition` to false allows you to manage the -# transition effect for your room as it transitions in and out. Place a -# `transition` command in the room's `setup` event to manage the look of the -# transition in, and in the room's `exit_scene` event to manage the look of the -# transition out. +# Hides either the main menu or the pause menu. Transitions from the menu using +# the default transition type (set in the Escoria project settings). # # **Parameters** # # - *menu_type*: Which menu to hide. Can be either `main` or `pause` (default: `main`) -# - *enable_automatic_transition*: Whether to automatically transition from the menu (default: `false`) # # @ESC extends ESCBaseCommand @@ -23,8 +16,8 @@ class_name HideMenuCommand func configure() -> ESCCommandArgumentDescriptor: return ESCCommandArgumentDescriptor.new( 0, - [TYPE_STRING, TYPE_BOOL], - ["main", false] + [TYPE_STRING], + ["main"] ) @@ -45,26 +38,26 @@ func validate(arguments: Array): # Run the command func run(command_params: Array) -> int: var transition_id: int - if command_params[1]: - # Transition out from menu - transition_id = escoria.main.scene_transition.transition( - "", - ESCTransitionPlayer.TRANSITION_MODE.OUT - ) - if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT: - while yield( - escoria.main.scene_transition, - "transition_done" - ) != transition_id: - pass + # Transition out from menu + transition_id = escoria.main.scene_transition.transition( + "", + ESCTransitionPlayer.TRANSITION_MODE.OUT + ) + + if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT: + while yield( + escoria.main.scene_transition, + "transition_done" + ) != transition_id: + pass if command_params[0] == "main": escoria.game_scene.hide_main_menu() elif command_params[0] == "pause": escoria.game_scene.unpause_game() - if command_params[1] and escoria.main.current_scene != null: + if escoria.main.current_scene != null: transition_id = escoria.main.scene_transition.transition() if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT: diff --git a/addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd b/addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd index 53ec8d0a3..c8dd5dd7d 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd @@ -1,18 +1,11 @@ -# `show_menu menu_type [enable_automatic_transition]` +# `show_menu menu_type` # -# Shows either the main menu or the pause menu. The enable_automatic_transition -# parameter can be used to specify if Escoria manages the graphical transition to -# the menu or not. -# Setting `enable_automatic_transition` to false allows you to manage the -# transition effect for your menu as it transitions in and out. Place a -# `transition` command in the menu's `setup` event to manage the look of the -# transition in, and in the menu's `exit_scene` event to manage the look of the -# transition out. +# Shows either the main menu or the pause menu. Transitions to the menu using +# the default transition type (set in the Escoria project settings). # # **Parameters** # # - *menu_type*: Which menu to show. Can be either `main` or `pause` (default: `main`) -# - *enable_automatic_transition*: Whether to automatically transition to the menu (default: `false`) # # @ESC extends ESCBaseCommand @@ -23,8 +16,8 @@ class_name ShowMenuCommand func configure() -> ESCCommandArgumentDescriptor: return ESCCommandArgumentDescriptor.new( 0, - [TYPE_STRING, TYPE_BOOL], - ["main", false] + [TYPE_STRING], + ["main"] ) @@ -47,39 +40,33 @@ func run(command_params: Array) -> int: if not escoria.game_scene.is_inside_tree(): escoria.add_child(escoria.game_scene) - if command_params[1]: - # Transition out from current scene - var transition_id = escoria.main.scene_transition.transition( - "", - ESCTransitionPlayer.TRANSITION_MODE.OUT - ) + # Transition out from current scene + var transition_id = escoria.main.scene_transition.transition( + "", + ESCTransitionPlayer.TRANSITION_MODE.OUT + ) - if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT: - while yield( - escoria.main.scene_transition, - "transition_done" - ) != transition_id: - pass + if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT: + while yield( + escoria.main.scene_transition, + "transition_done" + ) != transition_id: + pass - if command_params[0] == "main": - escoria.game_scene.show_main_menu() - elif command_params[0] == "pause": - escoria.game_scene.pause_game() + if command_params[0] == "main": + escoria.game_scene.show_main_menu() + elif command_params[0] == "pause": + escoria.game_scene.pause_game() - # Transition in to menu - transition_id = escoria.main.scene_transition.transition() + # Transition in to menu + transition_id = escoria.main.scene_transition.transition() - if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT: - while yield( - escoria.main.scene_transition, - "transition_done" - ) != transition_id: - pass - else: - if command_params[0] == "main": - escoria.game_scene.show_main_menu() - elif command_params[0] == "pause": - escoria.game_scene.pause_game() + if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT: + while yield( + escoria.main.scene_transition, + "transition_done" + ) != transition_id: + pass return ESCExecution.RC_OK diff --git a/game/rooms/room12/esc/transition_blackout.esc b/game/rooms/room12/esc/transition_blackout.esc index 553b634a1..093fc3c25 100644 --- a/game/rooms/room12/esc/transition_blackout.esc +++ b/game/rooms/room12/esc/transition_blackout.esc @@ -4,4 +4,4 @@ say player "Blackout" transition fade_black out 0.0 wait 1 transition fade_black in 0.0 -accept_input ALL \ No newline at end of file +accept_input ALL diff --git a/game/rooms/room14/esc/button_main_menu.esc b/game/rooms/room14/esc/button_main_menu.esc index d07fc1975..485937bc1 100644 --- a/game/rooms/room14/esc/button_main_menu.esc +++ b/game/rooms/room14/esc/button_main_menu.esc @@ -1,15 +1,14 @@ :use - # Show main menu, automatic transitions ENABLED -show_menu main true +show_menu main # wait 2 seconds wait 2 # Hide main menu, automatic transitions ENABLED -hide_menu main true +hide_menu main :look -say player "button main menu" \ No newline at end of file +say player "button main menu" diff --git a/game/rooms/room14/esc/button_main_menu_change_scene.esc b/game/rooms/room14/esc/button_main_menu_change_scene.esc deleted file mode 100644 index 0fd43a926..000000000 --- a/game/rooms/room14/esc/button_main_menu_change_scene.esc +++ /dev/null @@ -1,41 +0,0 @@ - -:use - -# This event demonstrates the following: -#- fade out to black -#- show the pause menu (automatic transition disabled to manage those manually) -#- wait 2 seconds -#- change scene (automatic transition disabled to manage those manually) to reload this same room - -set_global transition_manual true - -# Fade out to black -transition fade_black out -wait 2 - -# Show main menu, automatic transition DISABLED -show_menu pause - -# Showing menu -transition shards in - -# Wait 2 seconds on menu -wait 2 - -# Transition out before hiding menu -transition fade_black out - -# Hide the menu -hide_menu pause -wait 1 - -# Do NOT transition IN as this transition will be managed by the room's :setup event! -# If you transition IN here instead of room's :setup event, you will show the previous room - -# Change scene to same scene, disabled automatic transition -change_scene res://game/rooms/room14/room14.tscn false - -# Do not transition here either, as change_scene ends the execution of this script - -:look -say player "Button change scene" \ No newline at end of file diff --git a/game/rooms/room14/esc/button_main_menu_change_scene_auto.esc b/game/rooms/room14/esc/button_main_menu_change_scene_auto.esc deleted file mode 100644 index 56df7245f..000000000 --- a/game/rooms/room14/esc/button_main_menu_change_scene_auto.esc +++ /dev/null @@ -1,30 +0,0 @@ - -:use - -# This event demonstrates the following: -#- fade out to black -#- show the pause menu (automatic transition disabled to manage those manually) -#- wait 2 seconds -#- change scene (automatic transition enabled) to reload this same room - -set_global transition_manual false - -# Fade out to black -transition fade_black out -wait 2 - -# Show main menu, automatic transition DISABLED -show_menu pause - -# Showing menu -transition shards in - -# Wait 2 seconds on menu -wait 2 - -# Change scene to same scene, enabled automatic transition -change_scene res://game/rooms/room14/room14.tscn - - -:look -say player "Button change scene auto" \ No newline at end of file diff --git a/game/rooms/room14/esc/button_pause_menu.esc b/game/rooms/room14/esc/button_pause_menu.esc index 38b64f2ee..c66e72efd 100644 --- a/game/rooms/room14/esc/button_pause_menu.esc +++ b/game/rooms/room14/esc/button_pause_menu.esc @@ -1,16 +1,12 @@ :use -# Show pause menu, automatic transition are disabled by default -# So we can manage them manually using `transition` ESC command +# Show pause menu show_menu pause -# wait 2 seconds +# Wait 2 seconds (this will run AFTER the pause menu is closed since the pause +# menu also pauses the game) wait 2 -# Hide pause menu, automatic transition are disabled by default -# So we can manage them manually using `transition` ESC command -hide_menu pause - :look -say player "Button pause menu" \ No newline at end of file +say player "Button pause menu" diff --git a/game/rooms/room14/esc/room14.esc b/game/rooms/room14/esc/room14.esc index d18a29240..3515ae36e 100644 --- a/game/rooms/room14/esc/room14.esc +++ b/game/rooms/room14/esc/room14.esc @@ -44,4 +44,4 @@ queue_event worker moveworker _queuedemo true queue_event worker2 moveworker2 _queuedemo - \ No newline at end of file + diff --git a/game/rooms/room14/room14.tscn b/game/rooms/room14/room14.tscn index 20ddff10a..d105327bc 100644 --- a/game/rooms/room14/room14.tscn +++ b/game/rooms/room14/room14.tscn @@ -115,13 +115,8 @@ margin_top = 194.216 margin_right = 408.569 margin_bottom = 259.216 text = "Show main menu -with automatic -transitions enabled " align = 1 -__meta__ = { -"_edit_use_anchors_": false -} [node name="show_pause_menu" parent="." instance=ExtResource( 9 )] position = Vector2( 233.415, 0 ) @@ -138,58 +133,8 @@ margin_left = 273.915 margin_top = 194.216 margin_right = 413.915 margin_bottom = 242.216 -text = "Show pause menu -with NO transition -(manual or automatic)" -align = 1 - -[node name="show_pause_change_scene_manual" parent="." instance=ExtResource( 9 )] -position = Vector2( 463.318, 0 ) -global_id = "button_main_change_scene" -esc_script = "res://game/rooms/room14/esc/button_main_menu_change_scene.esc" -combine_when_selected_action_is_in = [ ] - -[node name="ESCLocation" type="Position2D" parent="show_pause_change_scene_manual"] -position = Vector2( 343.887, 381.305 ) -script = ExtResource( 5 ) - -[node name="Label" type="Label" parent="show_pause_change_scene_manual"] -margin_left = 277.027 -margin_top = 194.0 -margin_right = 428.027 -margin_bottom = 259.0 -text = "Show pause menu with -manual transition -and change_scene with -manual transition" +text = "Show pause menu" align = 1 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="show_pause_change_scene_auto" parent="." instance=ExtResource( 9 )] -position = Vector2( 676.318, 0 ) -global_id = "button_pause_change_scene_auto" -esc_script = "res://game/rooms/room14/esc/button_main_menu_change_scene_auto.esc" -combine_when_selected_action_is_in = [ ] - -[node name="ESCLocation" type="Position2D" parent="show_pause_change_scene_auto"] -position = Vector2( 343.887, 381.305 ) -script = ExtResource( 5 ) - -[node name="Label" type="Label" parent="show_pause_change_scene_auto"] -margin_left = 277.027 -margin_top = 194.0 -margin_right = 428.027 -margin_bottom = 259.0 -text = "Show pause menu with -manual transition -and change_scene with -automatic transition" -align = 1 -__meta__ = { -"_edit_use_anchors_": false -} [node name="worker" parent="." instance=ExtResource( 10 )] position = Vector2( 204.268, 376.233 )