Add show_menu and hide_menu ESC commands

Fixes godot-escoria/escoria-issues#48
Fix: tween was stopped_all before starting


Fix: reload locale from settings in ESCGame

Since main menu and pause menu are now loaded from ESCGame and not from escoria.gd, this must be done here.
Fix: small crash in load game

But save and load are broken at the moment...
Fix: check save and load after main menu changes


Required fixes


Fix: manage the game scene better in show and hide_menu


Enh: transition back in to the previous room if there was one


Fix a bug occurring where change_scene awaits forever for setup to end


Reworked change_scene and esc_room implementation to avoid yielding


Added a controller variable to allow new event run in events_manager


Don't empty the events queue if the running_event was interrupted


Fixed transitions and automatic transitions in change_scene

Added trace log level (for esc_compiler in particular)
Fixed various bugs in ESC scripts
Fix a bug where exit_scene happened multiple times where fast walking

Needed to clear the event queue
Fixes ready event was run because BYPASS_LAST_SCENE wrongly set


Inverted parameter "disable_automatic_transitions"

for change_scene, hide_menu, show_menu commands
Fix broken sched_event


Fixes as requested in PR
This commit is contained in:
Julian Murgia
2021-11-11 22:20:36 +01:00
parent 59c03dd9e2
commit c86b802cbb
56 changed files with 998 additions and 317 deletions

View File

@@ -1,4 +1,6 @@
:setup
> [eq ESC_LAST_SCENE room2]
teleport player r1_r_exit
# Set player look left
@@ -6,8 +8,8 @@
stop
:ready
set_sound_state _music res://game/sfx/contemplation.ogg true
> [!room1_visited]

View File

@@ -26,10 +26,25 @@ editor_debug_mode = 1
[node name="advice" type="Label" parent="background"]
anchor_right = 0.023274
anchor_bottom = 0.018018
margin_left = 90.0
margin_top = 59.0
margin_right = 338.0
margin_bottom = 118.0
custom_fonts/font = ExtResource( 3 )
text = "Don't click immediately!
Player will walk around the room,
but you can interrupt him if you want."
__meta__ = {
"_edit_use_anchors_": false
}
[node name="advice2" type="Label" parent="background"]
anchor_right = 0.023274
anchor_bottom = 0.018018
margin_left = 90.2752
margin_top = 120.824
margin_top = 170.824
margin_right = 270.275
margin_bottom = 155.824
margin_bottom = 205.824
custom_fonts/font = ExtResource( 3 )
text = "Move : left click
Fast move : double left click"

View File

@@ -2,6 +2,7 @@
:setup
> [r2_bridge_closed]
# Make set_state IMMEDIATE to reach the final frame immediately
set_state r2_bridge bridge_close true
@@ -13,6 +14,7 @@
# Set player look left
set_angle player 180
stop
> [eq ESC_LAST_SCENE room3]
teleport player r2_r_exit
# Set player look left
@@ -25,7 +27,8 @@
set_interactive r2_right_platform false
#set_interactive r2_bridge false
stop
:ready

View File

@@ -1,4 +1,6 @@
:setup
> [eq ESC_LAST_SCENE room3]
teleport player l_exit
# Set player look right

View File

@@ -1,5 +1,6 @@
:setup
# Disable wrench item if present in the inventory
> [i/r5_wrench]
set_active r5_wrench false

View File

@@ -1,4 +1,5 @@
:setup
> [eq ESC_LAST_SCENE room5]
teleport player r6_l_exit
# Set player look right

View File

@@ -1,5 +1,6 @@
:setup
> [eq ESC_LAST_SCENE room9]
teleport player r10_l_exit
# Set player look right

2
game/rooms/room11/esc/right_exit.esc Executable file → Normal file
View File

@@ -1,5 +1,5 @@
:exit_scene
set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false
transition fade_black out
change_scene "res://game/rooms/room12/room12.tscn" true
change_scene "res://game/rooms/room12/room12.tscn" false

View File

@@ -1,5 +1,6 @@
:setup
set_state _music off false
> [eq ESC_LAST_SCENE room10]

View File

@@ -5,6 +5,10 @@
teleport player r12_l_exit
# Set player look right
set_angle player 180
# Transition in
transition curtain in
stop
> [eq ESC_LAST_SCENE room13]
teleport player r12_r_exit

View File

@@ -1,3 +1,3 @@
:exit_scene
#set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false
#change_scene "res://game/rooms/room14/room14.tscn"
change_scene "res://game/rooms/room14/room14.tscn"

View File

@@ -2,4 +2,5 @@
:setup
:ready

View File

@@ -1,13 +1,12 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_terrain.gd" type="Script" id=1]
[ext_resource path="res://game/rooms/room12/background.tscn" type="PackedScene" id=2]
[ext_resource path="res://game/rooms/room13/background.tscn" type="PackedScene" id=2]
[ext_resource path="res://game/fonts/caslonantique.tres" type="DynamicFont" id=3]
[ext_resource path="res://game/characters/mark/mark.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=5]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=6]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=7]
[ext_resource path="res://game/rooms/room12/r_door.tscn" type="PackedScene" id=8]
[ext_resource path="res://game/rooms/room13/r_door.tscn" type="PackedScene" id=8]
[sub_resource type="NavigationPolygon" id=1]
vertices = PoolVector2Array( 1168.92, 640.557, 1182.53, 588.863, 1269.59, 622.872, 1275.03, 799.721, 864.626, 613.518, 1143.08, 613.35, -9.16094, 803.802, 386.666, 618.012, 129.634, 615.792, 84.5821, 654.06, -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698 )
@@ -70,7 +69,7 @@ global_id = "r12_l_exit"
[node name="r_door" parent="Hotspots" instance=ExtResource( 8 )]
global_id = "r13_r_exit"
esc_script = "res://game/rooms/room12/esc/right_exit.esc"
esc_script = "res://game/rooms/room13/esc/right_exit.esc"
default_action = "use"
[node name="ESCLocation" type="Position2D" parent="Hotspots/r_door"]
@@ -102,7 +101,3 @@ __meta__ = {
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hotspots/Hint"]
position = Vector2( 651.176, 177.775 )
shape = SubResource( 2 )
[node name="mark" parent="." instance=ExtResource( 4 )]
visible = false
position = Vector2( 620.216, 504.362 )

View File

@@ -0,0 +1,30 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_background.gd" type="Script" id=1]
[node name="background" type="TextureRect"]
margin_right = 1289.0
margin_bottom = 555.0
mouse_filter = 2
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="l_platform" type="Line2D" parent="."]
position = Vector2( 2, -266 )
points = PoolVector2Array( -2.96298, 712.01, 129.973, 614.429, 1167.5, 612.894, 1274.59, 669.705, 1273.25, 812.694, 2.36697, 811.043, 2.36697, 713.389 )
[node name="l_door" type="Line2D" parent="."]
position = Vector2( 0, -266 )
points = PoolVector2Array( 6.61201, 704.409, 6.61203, 389.558, 87.755, 339.775, 87.5463, 649.784 )
__meta__ = {
"_editor_description_": ""
}
[node name="r_door" type="Line2D" parent="."]
position = Vector2( 0, -267.828 )
points = PoolVector2Array( 1175.07, 620.086, 1171.24, 311.267, 1274.8, 356.87, 1278.31, 672.412, 1188.64, 624.843 )
__meta__ = {
"_editor_description_": ""
}

View File

@@ -0,0 +1,13 @@
:use
# Show main menu, automatic transitions ENABLED
show_menu main true
# wait 2 seconds
wait 2
# Hide main menu, automatic transitions ENABLED
hide_menu main true

View File

@@ -0,0 +1,37 @@
:use
# This event demonstrates the following:
#- fade out to black
#- show the main menu (automatic transition disabled to manage those manually)
#- wait 2 seconds
#- change scene (automatic transition disabled to managed those manually) to reload this same room
# 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 true
# Do not transition here either, as change_scene ends the execution of this script

View File

@@ -0,0 +1,13 @@
:use
# Show pause menu, automatic transition are disabled by default
# So we can manage them manually using `transition` ESC command
show_menu pause
# wait 2 seconds
wait 2
# Hide pause menu, automatic transition are disabled by default
# So we can manage them manually using `transition` ESC command
hide_menu pause

View File

@@ -0,0 +1,5 @@
:exit_scene
set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false
change_scene "res://game/rooms/room13/room13.tscn"

View File

@@ -0,0 +1,3 @@
:exit_scene
#set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false
#change_scene "res://game/rooms/room15/room15.tscn"

View File

@@ -0,0 +1,29 @@
:setup
> [eq ESC_LAST_SCENE room13]
teleport player r14_l_exit
# Set player look right
set_angle player 90
stop
> [eq ESC_LAST_SCENE room15]
teleport player r14_r_exit
# Set player look left
set_angle player 270
stop
# If we're coming from the same room as this one, we manage the player's position
# AND the transition IN manually
> [eq ESC_LAST_SCENE room14]
teleport player start
# Set player look left
set_angle player 270
# Fade in from black
transition fade_black in
stop
:ready

View File

@@ -0,0 +1,25 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=1]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=2]
[node name="r_door" type="Area2D"]
pause_mode = 1
script = ExtResource( 1 )
__meta__ = {
"_editor_description_": ""
}
global_id = "r1_r_exit"
esc_script = "res://game/rooms/room01/esc/right_exit.esc"
is_exit = true
tooltip_name = "Exit"
default_action = "walk"
dialog_color = Color( 1, 1, 1, 1 )
animations = null
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
polygon = PoolVector2Array( 1177.94, 348.61, 1175.95, 45.3759, 1276.06, 92.0953, 1277.95, 399.407 )
[node name="Position2D" type="Position2D" parent="."]
position = Vector2( 1225.47, 353.99 )
script = ExtResource( 2 )

View File

@@ -0,0 +1,151 @@
[gd_scene load_steps=11 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_terrain.gd" type="Script" id=1]
[ext_resource path="res://game/rooms/room14/background.tscn" type="PackedScene" id=2]
[ext_resource path="res://game/fonts/caslonantique.tres" type="DynamicFont" id=3]
[ext_resource path="res://game/characters/mark/mark.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=5]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=6]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=7]
[ext_resource path="res://game/rooms/room14/r_door.tscn" type="PackedScene" id=8]
[ext_resource path="res://game/items/escitems/button.tscn" type="PackedScene" id=9]
[sub_resource type="NavigationPolygon" id=1]
vertices = PoolVector2Array( 1168.92, 640.557, 1182.53, 588.863, 1269.59, 622.872, 1275.03, 799.721, 864.626, 613.518, 1143.08, 613.35, -9.16094, 803.802, 386.666, 618.012, 129.634, 615.792, 84.5821, 654.06, -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698 )
polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 5, 0, 3, 6, 7 ), PoolIntArray( 8, 7, 6, 9 ), PoolIntArray( 9, 6, 10, 11, 12 ) ]
outlines = [ PoolVector2Array( -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698, 84.5821, 654.06, 129.634, 615.792, 386.666, 618.012, 864.626, 613.518, 1143.08, 613.35, 1168.92, 640.557, 1182.53, 588.863, 1269.59, 622.872, 1275.03, 799.721, -9.16094, 803.802 ) ]
[node name="room14" type="Node2D"]
script = ExtResource( 6 )
__meta__ = {
"_edit_vertical_guides_": [ ]
}
global_id = "room14"
esc_script = "res://game/rooms/room14/esc/room14.esc"
player_scene = ExtResource( 4 )
camera_limits = [ Rect2( 0, 0, 1289, 555 ) ]
[node name="background" parent="." instance=ExtResource( 2 )]
[node name="room_label" type="Label" parent="background"]
margin_right = 92.0
margin_bottom = 21.0
custom_fonts/font = ExtResource( 3 )
text = "ROOM 14"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="walkable_area" type="Navigation2D" parent="."]
script = ExtResource( 1 )
[node name="platform" type="NavigationPolygonInstance" parent="walkable_area"]
position = Vector2( 6.73163, -264.779 )
navpoly = SubResource( 1 )
__meta__ = {
"_editor_description_": ""
}
[node name="Hotspots" type="Node" parent="."]
[node name="l_door" type="Area2D" parent="Hotspots"]
pause_mode = 1
script = ExtResource( 7 )
global_id = "r14_l_exit"
esc_script = "res://game/rooms/room14/esc/left_exit.esc"
is_exit = true
tooltip_name = "Left exit"
default_action = "use"
dialog_color = Color( 1, 1, 1, 1 )
animations = null
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/l_door"]
polygon = PoolVector2Array( 0.328762, 440.897, 1.85199, 119.926, 85.9517, 74.6212, 87.1409, 377.869 )
[node name="Position2D" type="Position2D" parent="Hotspots/l_door"]
position = Vector2( 37.4521, 392.045 )
script = ExtResource( 5 )
global_id = "r12_l_exit"
[node name="r_door" parent="Hotspots" instance=ExtResource( 8 )]
global_id = "r14_r_exit"
esc_script = "res://game/rooms/room14/esc/right_exit.esc"
default_action = "use"
[node name="ESCLocation" type="Position2D" parent="Hotspots/r_door"]
position = Vector2( 1231.78, 360.624 )
script = ExtResource( 5 )
[node name="start" type="Position2D" parent="Hotspots"]
position = Vector2( 243.677, 455.569 )
script = ExtResource( 5 )
global_id = "start"
is_start_location = true
interaction_direction = 180
[node name="show_main_menu" parent="." instance=ExtResource( 9 )]
global_id = "button_main_menu"
esc_script = "res://game/rooms/room14/esc/button_main_menu.esc"
[node name="ESCLocation" type="Position2D" parent="show_main_menu"]
position = Vector2( 343.887, 381.305 )
script = ExtResource( 5 )
[node name="Label" type="Label" parent="show_main_menu"]
margin_left = 285.569
margin_top = 194.216
margin_right = 408.569
margin_bottom = 259.216
text = "Show main menu
with autmatic
transitions enabled
"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="show_pause_menu" parent="." instance=ExtResource( 9 )]
position = Vector2( 233.415, 0 )
global_id = "button_pause_menu"
esc_script = "res://game/rooms/room14/esc/button_pause_menu.esc"
[node name="ESCLocation" type="Position2D" parent="show_pause_menu"]
position = Vector2( 343.887, 381.305 )
script = ExtResource( 5 )
[node name="Label" type="Label" parent="show_pause_menu"]
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
__meta__ = {
"_edit_use_anchors_": false
}
[node name="show_main_change_scene" 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"
[node name="ESCLocation" type="Position2D" parent="show_main_change_scene"]
position = Vector2( 343.887, 381.305 )
script = ExtResource( 5 )
[node name="Label" type="Label" parent="show_main_change_scene"]
margin_left = 277.027
margin_top = 194.0
margin_right = 428.027
margin_bottom = 259.0
text = "Show main menu with
manual transition
and change_scene with
manual transition"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}

View File

@@ -0,0 +1,18 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_terrain.gd" type="Script" id=1]
[sub_resource type="NavigationPolygon" id=1]
vertices = PoolVector2Array( 1168.92, 640.557, 1182.53, 588.863, 1269.59, 622.872, 1275.03, 799.721, 129.634, 615.792, 1143.08, 613.35, -9.16094, 803.802, 84.5821, 654.06, -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698 )
polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 5, 0, 3, 6, 7 ), PoolIntArray( 7, 6, 8, 9, 10 ) ]
outlines = [ PoolVector2Array( -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698, 84.5821, 654.06, 129.634, 615.792, 1143.08, 613.35, 1168.92, 640.557, 1182.53, 588.863, 1269.59, 622.872, 1275.03, 799.721, -9.16094, 803.802 ) ]
[node name="walkable_area" type="Navigation2D"]
script = ExtResource( 1 )
[node name="platform" type="NavigationPolygonInstance" parent="."]
position = Vector2( 6.73163, -264.779 )
navpoly = SubResource( 1 )
__meta__ = {
"_editor_description_": ""
}

View File

@@ -1,15 +1,14 @@
:init
set_sound_state _music res://game/sfx/Game-Menu_Looping.mp3 true
spawn _main_menu res://addons/escoria-core/ui_library/menus/main_menu/main_menu.tscn false
set_active _main_menu true
# Showing main menu with automatic transition DISABLED
show_menu main
:newgame
# Hide main menu
set_active _main_menu false
# 1/ Simple scene
change_scene res://game/rooms/room01/room01.tscn
@@ -47,4 +46,9 @@ change_scene res://game/rooms/room01/room01.tscn
# 12/ Event flags tests 2
#change_scene res://game/rooms/room12/room12.tscn
# 13/
#change_scene res://game/rooms/room13/room13.tscn
# 14/
#change_scene res://game/rooms/room14/room14.tscn