Skip to content

Commit

Permalink
fix: forces all show_menu and hide_menu commands to use auto transiti…
Browse files Browse the repository at this point in the history
…ons since the pause menu pauses the game, blocking further ESC script commands from running; updates room 14 for now
  • Loading branch information
BHSDuncan authored and StraToN committed May 31, 2023
1 parent 3077907 commit 6dd0a2c
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 207 deletions.
43 changes: 18 additions & 25 deletions addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,8 +16,8 @@ class_name HideMenuCommand
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
0,
[TYPE_STRING, TYPE_BOOL],
["main", false]
[TYPE_STRING],
["main"]
)


Expand All @@ -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:
Expand Down
69 changes: 28 additions & 41 deletions addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,8 +16,8 @@ class_name ShowMenuCommand
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
0,
[TYPE_STRING, TYPE_BOOL],
["main", false]
[TYPE_STRING],
["main"]
)


Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion game/rooms/room12/esc/transition_blackout.esc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ say player "Blackout"
transition fade_black out 0.0
wait 1
transition fade_black in 0.0
accept_input ALL
accept_input ALL
7 changes: 3 additions & 4 deletions game/rooms/room14/esc/button_main_menu.esc
Original file line number Diff line number Diff line change
@@ -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"
say player "button main menu"
41 changes: 0 additions & 41 deletions game/rooms/room14/esc/button_main_menu_change_scene.esc

This file was deleted.

30 changes: 0 additions & 30 deletions game/rooms/room14/esc/button_main_menu_change_scene_auto.esc

This file was deleted.

12 changes: 4 additions & 8 deletions game/rooms/room14/esc/button_pause_menu.esc
Original file line number Diff line number Diff line change
@@ -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"
say player "Button pause menu"
2 changes: 1 addition & 1 deletion game/rooms/room14/esc/room14.esc
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
queue_event worker moveworker _queuedemo true
queue_event worker2 moveworker2 _queuedemo



57 changes: 1 addition & 56 deletions game/rooms/room14/room14.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down

0 comments on commit 6dd0a2c

Please sign in to comment.