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

@@ -106,7 +106,7 @@ func _calculate_movement(delta: float):
# Movement speed calculation # Movement speed calculation
var movement_speed: float = parent.speed * delta * pow(last_scale.x, 2) * \ var movement_speed: float = parent.speed * delta * pow(last_scale.x, 2) * \
parent.terrain.player_speed_multiplier parent.terrain.player_speed_multiplier
if walk_context.fast: if walk_context.fast:
movement_speed *= parent.terrain.player_doubleclick_speed_multiplier movement_speed *= parent.terrain.player_doubleclick_speed_multiplier
@@ -226,7 +226,8 @@ func walk_to(pos: Vector2, p_walk_context: ESCWalkContext = null) -> void:
if task == MovableTask.WALK: if task == MovableTask.WALK:
if walk_context.target_object == p_walk_context.target_object \ if walk_context.target_object == p_walk_context.target_object \
or walk_context.target_position == p_walk_context.target_position: or walk_context.target_position \
== p_walk_context.target_position:
walk_context.fast = p_walk_context.fast walk_context.fast = p_walk_context.fast
walk_context = p_walk_context walk_context = p_walk_context

View File

@@ -1,8 +1,8 @@
# `change_scene path [disable_automatic_transition] [run_events]` # `change_scene path [enable_automatic_transition=true] [run_events=true]`
# #
# Loads a new scene, specified by "path". # Loads a new scene, specified by "path".
# The `disable_automatic_transition` is a boolean (default false) can be set # The `enable_automatic_transition` is a boolean (default true) can be set
# to true to disable automatic transitions between scenes, to allow you # to false to disable automatic transitions between scenes, to allow you
# to control your transitions manually using the `transition` command. # to control your transitions manually using the `transition` command.
# The `run_events` variable is a boolean (default true) which you never want # The `run_events` variable is a boolean (default true) which you never want
# to set manually! It's there only to benefit save games, so they don't # to set manually! It's there only to benefit save games, so they don't
@@ -18,7 +18,7 @@ func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new( return ESCCommandArgumentDescriptor.new(
1, 1,
[TYPE_STRING, TYPE_BOOL, TYPE_BOOL], [TYPE_STRING, TYPE_BOOL, TYPE_BOOL],
[null, false, true] [null, true, true]
) )
@@ -47,35 +47,51 @@ func validate(arguments: Array) -> bool:
# Run the command # Run the command
func run(command_params: Array) -> int: func run(command_params: Array) -> int:
escoria.logger.info( escoria.logger.info(
"Changing scene to %s (disable_automatic_transition = %s, run_events = %s)" % [ "Changing scene to %s (enable_automatic_transition = %s, run_events = %s)" % [
command_params[0], command_params[0], # scene file
command_params[1], command_params[1], # enable_automatic_transition
command_params[2] command_params[2] # run_events
]) ])
if escoria.main.current_scene \ # Clear the event queue to remove other events (there could be duplicate
and not escoria.globals_manager.get_global("BYPASS_LAST_SCENE"): # events in there so we avoid running these multiple times)
escoria.globals_manager.set_global( escoria.event_manager.clear_event_queue()
"ESC_LAST_SCENE",
escoria.main.current_scene.global_id,
true
)
escoria.event_manager.interrupt_running_event()
if escoria.dialog_player:
escoria.dialog_player.interrupt()
if !command_params[1]: var exited_previous_room = false
if command_params[1] \
and escoria.event_manager._running_event.name \
in ["exit_scene", "room_selector"]:
exited_previous_room = true
escoria.main.scene_transition.transition( escoria.main.scene_transition.transition(
"", "",
ESCTransitionPlayer.TRANSITION_MODE.OUT ESCTransitionPlayer.TRANSITION_MODE.OUT
) )
yield(escoria.main.scene_transition, "transition_done") yield(escoria.main.scene_transition, "transition_done")
# If BYPASS_LAST_SCENE is false, set ESC_LAST_SCENE = current room id
if escoria.main.current_scene \
and not escoria.globals_manager.get_global("BYPASS_LAST_SCENE"):
escoria.globals_manager.set_global(
"ESC_LAST_SCENE",
escoria.main.current_scene.global_id,
true
)
if escoria.globals_manager.get_global("BYPASS_LAST_SCENE"):
escoria.globals_manager.set_global(
"ESC_LAST_SCENE",
null,
true
)
if escoria.dialog_player:
escoria.dialog_player.interrupt()
escoria.inputs_manager.clear_stack() escoria.inputs_manager.clear_stack()
var res_room = escoria.resource_cache.get_resource(command_params[0]) var res_room = escoria.resource_cache.get_resource(command_params[0])
# Load game scene # Load game scene
if not escoria.game_scene: if not escoria.game_scene:
escoria.logger.report_errors( escoria.logger.report_errors(
@@ -87,22 +103,32 @@ func run(command_params: Array) -> int:
) )
if escoria.main.current_scene \ if escoria.main.current_scene \
and escoria.game_scene.get_parent() == escoria.main.current_scene: and escoria.game_scene.get_parent() == escoria.main.current_scene:
escoria.main.current_scene.remove_child(escoria.game_scene) escoria.main.current_scene.remove_child(escoria.game_scene)
# Load room scene # Load room scene
var room_scene = res_room.instance() var room_scene = res_room.instance()
if room_scene: if room_scene:
if command_params[1] \
and escoria.event_manager._running_event.name \
== "room_selector":
room_scene.enabled_automatic_transitions = true
else:
room_scene.enabled_automatic_transitions = command_params[1]
room_scene.exited_previous_room = exited_previous_room
# If the game scene is already in the tree but not a child of the room
# we remove it
if escoria.game_scene.is_inside_tree() \
and escoria.game_scene.get_parent() != room_scene:
var game_parent = escoria.game_scene.get_parent()
game_parent.remove_child(escoria.game_scene)
room_scene.add_child(escoria.game_scene) room_scene.add_child(escoria.game_scene)
room_scene.move_child(escoria.game_scene, 0) room_scene.move_child(escoria.game_scene, 0)
room_scene.game = escoria.game_scene room_scene.game = escoria.game_scene
escoria.main.set_scene(room_scene) escoria.main.set_scene(room_scene)
# If automatic transition is not disabled, play the transition
if not command_params[1]:
escoria.main.scene_transition.transition()
yield(escoria.main.scene_transition, "transition_done")
# Clear queued resources # Clear queued resources
escoria.resource_cache.clear() escoria.resource_cache.clear()
@@ -116,12 +142,4 @@ func run(command_params: Array) -> int:
) )
return ESCExecution.RC_ERROR return ESCExecution.RC_ERROR
# If the ESC_LAST_SCENE global was bypassed, reset bypass variable to false
if escoria.globals_manager.get_global("BYPASS_LAST_SCENE"):
escoria.globals_manager.set_global(
"BYPASS_LAST_SCENE",
false,
true
)
return ESCExecution.RC_OK return ESCExecution.RC_OK

View File

@@ -0,0 +1,65 @@
# `hide_menu main|pause=main [enable_automatic_transition: true|false=false]`
#
# Hides the main or pause menu.
# The `enable_automatic_transition` is a boolean (default false) can be set
# to false to disable automatic transitions between scenes, to allow you
# to control your transitions manually using the `transition` command.
#
# @ESC
extends ESCBaseCommand
class_name HideMenuCommand
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
0,
[TYPE_STRING, TYPE_BOOL],
["main", false]
)
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not arguments[0] in ["main", "pause"]:
escoria.logger.report_errors(
"hide_menu: invalid menu ",
[
"menu %s is invalid" % arguments[0]
]
)
return false
return .validate(arguments)
# 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
)
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:
transition_id = escoria.main.scene_transition.transition()
if command_params[1] and escoria.main.current_scene != null:
while yield(
escoria.main.scene_transition,
"transition_done"
) != transition_id:
pass
return ESCExecution.RC_OK

View File

@@ -19,16 +19,16 @@ func configure() -> ESCCommandArgumentDescriptor:
# Validate wether the given arguments match the command descriptor # Validate wether the given arguments match the command descriptor
func validate(arguments: Array): func validate(arguments: Array):
if not escoria.object_manager.has(arguments[0]): if not escoria.object_manager.has(arguments[1]):
escoria.logger.report_errors( escoria.logger.report_errors(
"play_snd: invalid sound player", "play_snd: invalid sound player",
["Sound player %s not registered" % arguments[0]] ["Sound player %s not registered" % arguments[1]]
) )
return false return false
if not ResourceLoader.exists(arguments[1]): if not ResourceLoader.exists(arguments[0]):
escoria.logger.report_errors( escoria.logger.report_errors(
"play_snd: invalid parameter", "play_snd: invalid parameter",
["File %s not found" % arguments[1]] ["File %s not found" % arguments[0]]
) )
return false return false
return .validate(arguments) return .validate(arguments)

View File

@@ -0,0 +1,72 @@
# `show_menu main|pause=main [enable_automatic_transition: true|false=false]`
#
# Shows the main or pause menu.
# The `enable_automatic_transition` is a boolean (default false) can be set
# to false to disable automatic transitions between scenes, to allow you
# to control your transitions manually using the `transition` command.
#
# @ESC
extends ESCBaseCommand
class_name ShowMenuCommand
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
0,
[TYPE_STRING, TYPE_BOOL],
["main", false]
)
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not arguments[0] in ["main", "pause"]:
escoria.logger.report_errors(
"show_menu: invalid menu ",
[
"menu %s is invalid" % arguments[0]
]
)
return false
return .validate(arguments)
# Run the command
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
)
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()
# Transition in to menu
transition_id = escoria.main.scene_transition.transition()
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()
return ESCExecution.RC_OK

View File

@@ -45,14 +45,19 @@ func validate(arguments: Array):
# Run the command # Run the command
func run(command_params: Array) -> int: func run(command_params: Array) -> int:
escoria.main.scene_transition.transition( var transition_id = escoria.main.scene_transition.transition(
command_params[0], command_params[0],
ESCTransitionPlayer.TRANSITION_MODE.OUT if command_params[1] == "out" \ ESCTransitionPlayer.TRANSITION_MODE.OUT if command_params[1] == "out" \
else ESCTransitionPlayer.TRANSITION_MODE.IN, else ESCTransitionPlayer.TRANSITION_MODE.IN,
command_params[2] command_params[2]
) )
yield( escoria.logger.debug("Starting transition #%s [%s, %s]"
% [transition_id, command_params[0], command_params[1]])
while yield(
escoria.main.scene_transition, escoria.main.scene_transition,
"transition_done" "transition_done"
) ) != transition_id:
pass
escoria.logger.debug("Ending transition #%s [%s, %s]"
% [transition_id, command_params[0], command_params[1]])
return ESCExecution.RC_OK return ESCExecution.RC_OK

View File

@@ -1,6 +1,8 @@
# `wait seconds` # `wait seconds`
# #
# Blocks execution of the current script for a number of seconds specified by the "seconds" parameter. # Blocks execution of the current script for a number of seconds specified by
# the "seconds" parameter.
# - seconds can be either and integer or a floating value
# #
# @ESC # @ESC
extends ESCBaseCommand extends ESCBaseCommand
@@ -11,12 +13,12 @@ class_name WaitCommand
func configure() -> ESCCommandArgumentDescriptor: func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new( return ESCCommandArgumentDescriptor.new(
1, 1,
[TYPE_INT], [[TYPE_INT, TYPE_REAL]],
[null] [null]
) )
# Run the command # Run the command
func run(command_params: Array) -> int: func run(command_params: Array) -> int:
yield(escoria.get_tree().create_timer(command_params[0]), "timeout") yield(escoria.get_tree().create_timer(float(command_params[0])), "timeout")
return ESCExecution.RC_OK return ESCExecution.RC_OK

View File

@@ -104,10 +104,10 @@ func _compile(lines: Array) -> Array:
while lines.size() > 0: while lines.size() > 0:
var line = lines.pop_front() var line = lines.pop_front()
escoria.logger.debug("Parsing line %s" % line) escoria.logger.trace("Parsing line %s" % line)
if comment_regex.search(line) or empty_regex.search(line): if comment_regex.search(line) or empty_regex.search(line):
# Ignore comments and empty lines # Ignore comments and empty lines
escoria.logger.debug("Line is empty or a comment. Skipping.") escoria.logger.trace("Line is empty or a comment. Skipping.")
continue continue
var indent = \ var indent = \
escoria.utils.get_re_group( escoria.utils.get_re_group(
@@ -117,7 +117,7 @@ func _compile(lines: Array) -> Array:
if event_regex.search(line): if event_regex.search(line):
var event = ESCEvent.new(line) var event = ESCEvent.new(line)
escoria.logger.debug("Line is the event %s" % event.name) escoria.logger.trace("Line is the event %s" % event.name)
var event_lines = [] var event_lines = []
while lines.size() > 0: while lines.size() > 0:
var next_line = lines.pop_front() var next_line = lines.pop_front()
@@ -127,7 +127,7 @@ func _compile(lines: Array) -> Array:
lines.push_front(next_line) lines.push_front(next_line)
break break
if event_lines.size() > 0: if event_lines.size() > 0:
escoria.logger.debug( escoria.logger.trace(
"Compiling the next %d lines into the event" % \ "Compiling the next %d lines into the event" % \
event_lines.size() event_lines.size()
) )
@@ -135,7 +135,7 @@ func _compile(lines: Array) -> Array:
returned.append(event) returned.append(event)
elif group_regex.search(line): elif group_regex.search(line):
var group = ESCGroup.new(line) var group = ESCGroup.new(line)
escoria.logger.debug("Line is a group") escoria.logger.trace("Line is a group")
var group_lines = [] var group_lines = []
while lines.size() > 0: while lines.size() > 0:
var next_line = lines.pop_front() var next_line = lines.pop_front()
@@ -153,7 +153,7 @@ func _compile(lines: Array) -> Array:
lines.push_front(next_line) lines.push_front(next_line)
break break
if group_lines.size() > 0: if group_lines.size() > 0:
escoria.logger.debug( escoria.logger.trace(
"Compiling the next %d lines into the group" % \ "Compiling the next %d lines into the group" % \
group_lines.size() group_lines.size()
) )
@@ -161,7 +161,7 @@ func _compile(lines: Array) -> Array:
returned.append(group) returned.append(group)
elif dialog_regex.search(line): elif dialog_regex.search(line):
var dialog = ESCDialog.new(line) var dialog = ESCDialog.new(line)
escoria.logger.debug("Line is a dialog") escoria.logger.trace("Line is a dialog")
var dialog_lines = [] var dialog_lines = []
while lines.size() > 0: while lines.size() > 0:
var next_line = lines.pop_front() var next_line = lines.pop_front()
@@ -178,7 +178,7 @@ func _compile(lines: Array) -> Array:
else: else:
dialog_lines.append(next_line) dialog_lines.append(next_line)
if dialog_lines.size() > 0: if dialog_lines.size() > 0:
escoria.logger.debug( escoria.logger.trace(
"Compiling the next %d lines into the dialog" % \ "Compiling the next %d lines into the dialog" % \
dialog_lines.size() dialog_lines.size()
) )
@@ -188,7 +188,7 @@ func _compile(lines: Array) -> Array:
returned.append(dialog) returned.append(dialog)
elif dialog_option_regex.search(line): elif dialog_option_regex.search(line):
var dialog_option = ESCDialogOption.new(line) var dialog_option = ESCDialogOption.new(line)
escoria.logger.debug( escoria.logger.trace(
"Line is the dialog option %s" % \ "Line is the dialog option %s" % \
dialog_option.option dialog_option.option
) )
@@ -209,7 +209,7 @@ func _compile(lines: Array) -> Array:
lines.push_front(next_line) lines.push_front(next_line)
break break
if dialog_option_lines.size() > 0: if dialog_option_lines.size() > 0:
escoria.logger.debug( escoria.logger.trace(
"Compiling the next %d lines into the event" % \ "Compiling the next %d lines into the event" % \
dialog_option_lines.size() dialog_option_lines.size()
) )
@@ -217,7 +217,7 @@ func _compile(lines: Array) -> Array:
returned.append(dialog_option) returned.append(dialog_option)
elif command_regex.search(line): elif command_regex.search(line):
var command = ESCCommand.new(line) var command = ESCCommand.new(line)
escoria.logger.debug("Line is the command %s" % command.name) escoria.logger.trace("Line is the command %s" % command.name)
returned.append(command) returned.append(command)
else: else:
escoria.logger.report_errors( escoria.logger.report_errors(

View File

@@ -2,6 +2,8 @@
extends Node extends Node
class_name ESCEventManager class_name ESCEventManager
# Emitted when the event started execution
signal event_started(event_name)
# Emitted when the event did finish running # Emitted when the event did finish running
signal event_finished(event_name, return_code) signal event_finished(event_name, return_code)
@@ -19,6 +21,9 @@ var scheduled_events: Array = []
# Currently running event # Currently running event
var _running_event: ESCEvent var _running_event: ESCEvent
# Whether the event manager is allowed to proceed with next event.
var can_process_next_event = true
func _ready(): func _ready():
self.pause_mode = Node.PAUSE_MODE_STOP self.pause_mode = Node.PAUSE_MODE_STOP
@@ -26,8 +31,17 @@ func _ready():
# Handle the events queue and scheduled events # Handle the events queue and scheduled events
func _process(delta: float) -> void: func _process(delta: float) -> void:
if events_queue.size() > 0: if events_queue.size() > 0 and can_process_next_event:
can_process_next_event = false
_running_event = events_queue.pop_front() _running_event = events_queue.pop_front()
escoria.logger.debug(
"esc_event_manager",
[
"Popping event %s from event_queue" \
% _running_event.name if _running_event.get("name") != null \
else str(_running_event)
]
)
if not _running_event.is_connected( if not _running_event.is_connected(
"finished", self, "_on_event_finished" "finished", self, "_on_event_finished"
): ):
@@ -47,12 +61,13 @@ func _process(delta: float) -> void:
[_running_event] [_running_event]
) )
emit_signal("event_started", _running_event.name)
_running_event.run() _running_event.run()
for event in self.scheduled_events: for event in self.scheduled_events:
(event as ESCScheduledEvent).timeout -= delta (event as ESCScheduledEvent).timeout -= delta
if (event as ESCScheduledEvent).timeout <= 0: if (event as ESCScheduledEvent).timeout <= 0:
self.scheduled_events.erase(event) self.scheduled_events.erase(event)
self.events_queue.append(event) self.events_queue.append(event.event)
# Queue a new event to run # Queue a new event to run
@@ -73,10 +88,9 @@ func _on_event_finished(return_code: int, event: ESCEvent) -> void:
event.disconnect("finished", self, "_on_event_finished") event.disconnect("finished", self, "_on_event_finished")
event.disconnect("interrupted", self, "_on_event_finished") event.disconnect("interrupted", self, "_on_event_finished")
_running_event = null _running_event = null
can_process_next_event = true
match(return_code): match(return_code):
ESCExecution.RC_CANCEL: ESCExecution.RC_CANCEL:
self.scheduled_events = []
self.events_queue = []
return_code = ESCExecution.RC_OK return_code = ESCExecution.RC_OK
emit_signal("event_finished", return_code, event.name) emit_signal("event_finished", return_code, event.name)
@@ -85,7 +99,8 @@ func _on_event_finished(return_code: int, event: ESCEvent) -> void:
func interrupt_running_event(): func interrupt_running_event():
if _running_event == null: if _running_event == null:
return return
for event in events_queue:
event.interrupt()
events_queue.clear()
_running_event.interrupt() _running_event.interrupt()
# Clears the event queue.
func clear_event_queue():
events_queue.clear()

View File

@@ -77,5 +77,5 @@ func _init(event_string: String):
# Execute this statement and return its return code # Execute this statement and return its return code
func run() -> int: func run() -> int:
escoria.logger.debug("Starting event %s" % name) escoria.logger.debug("Event %s started" % name)
return .run() return .run()

View File

@@ -40,7 +40,7 @@ func set_state(p_state: String, immediate: bool = false):
if node.has_method("get_animation_player"): if node.has_method("get_animation_player"):
var animation_node: ESCAnimationPlayer = node.get_animation_player() var animation_node: ESCAnimationPlayer = node.get_animation_player()
if animation_node.is_valid(): if animation_node != null and animation_node.is_valid():
animation_node.stop() animation_node.stop()
var actual_animator var actual_animator
if animation_node.has_animation(p_state): if animation_node.has_animation(p_state):

View File

@@ -12,9 +12,12 @@ signal interrupted(return_code)
# The list of ESC commands # The list of ESC commands
var statements: Array = [] var statements: Array = []
# Indicated whether this event was interrupted. # Indicates whether this event was interrupted.
var _is_interrupted: bool = false var _is_interrupted: bool = false
# Indicates whether this event was finished.
var is_finished: bool = false
# Check wether the statement should be run based on its conditions # Check wether the statement should be run based on its conditions
func is_valid() -> bool: func is_valid() -> bool:
@@ -37,8 +40,16 @@ func run() -> int:
var rc = statement.run() var rc = statement.run()
if rc is GDScriptFunctionState: if rc is GDScriptFunctionState:
rc = yield(rc, "completed") rc = yield(rc, "completed")
escoria.logger.debug(
"esc_statement",
["Statement (%s) was completed."
% statement]
)
statement.is_finished = true
if rc == ESCExecution.RC_REPEAT: if rc == ESCExecution.RC_REPEAT:
return self.run() return self.run()
elif rc == ESCExecution.RC_OK:
statement.is_finished = true
elif rc != ESCExecution.RC_OK: elif rc != ESCExecution.RC_OK:
final_rc = rc final_rc = rc
break break
@@ -52,4 +63,11 @@ func interrupt():
escoria.logger.info("Interrupting event %s" % str(self)) escoria.logger.info("Interrupting event %s" % str(self))
_is_interrupted = true _is_interrupted = true
for statement in statements: for statement in statements:
statement.interrupt() if statement.is_finished:
escoria.logger.debug(
"event manager",
["Event %s (%s) is already finished. Won't interrupt."
% [statement.name, str(statement)]]
)
else:
statement.interrupt()

View File

@@ -14,18 +14,28 @@ enum EDITOR_GAME_DEBUG_DISPLAY {
} }
# The main menu node
export(NodePath) var main_menu
# The main menu node
export(NodePath) var pause_menu
# The safe margin around tooltips # The safe margin around tooltips
export(float) var mouse_tooltip_margin = 50.0 export(float) var mouse_tooltip_margin = 50.0
# Which (if any) debug mode for the editor is used
export(EDITOR_GAME_DEBUG_DISPLAY) var editor_debug_mode = \
EDITOR_GAME_DEBUG_DISPLAY.NONE setget _set_editor_debug_mode
# A reference to the node handling tooltips # A reference to the node handling tooltips
var tooltip_node: Object var tooltip_node: Object
# Which (if any) debug mode for the editor is used # Ready function
export(EDITOR_GAME_DEBUG_DISPLAY) var editor_debug_mode = \ func _ready():
EDITOR_GAME_DEBUG_DISPLAY.NONE setget _set_editor_debug_mode escoria.apply_settings(escoria.settings)
# Handle debugging visualizations # Handle debugging visualizations
func _draw(): func _draw():
@@ -273,3 +283,23 @@ func update_tooltip_following_mouse_position(p_position: Vector2):
func _set_editor_debug_mode(p_editor_debug_mode: int) -> void: func _set_editor_debug_mode(p_editor_debug_mode: int) -> void:
editor_debug_mode = p_editor_debug_mode editor_debug_mode = p_editor_debug_mode
update() update()
# Pauses the game. Reimplement to eventually show a specific UI.
func pause_game():
pass
# Unpause the game. Reimplement to eventually hide a specific UI.
func unpause_game():
pass
# Shows the main menu. Reimplement to show a specific UI.
func show_main_menu():
pass
# Hides the main menu. Reimplement to hide a specific UI.
func hide_main_menu():
pass

View File

@@ -307,7 +307,10 @@ func get_animation_player() -> Node:
escoria.logger.warning( escoria.logger.warning(
"Can not find node at path %s" % player_node_path "Can not find node at path %s" % player_node_path
) )
_animation_player = ESCAnimationPlayer.new(get_node(player_node_path)) else:
_animation_player = ESCAnimationPlayer.new(
get_node(player_node_path)
)
return _animation_player return _animation_player

View File

@@ -4,6 +4,13 @@ extends Node2D
class_name ESCRoom, "res://addons/escoria-core/design/esc_room.svg" class_name ESCRoom, "res://addons/escoria-core/design/esc_room.svg"
# Emitted when room has finished ":setup" event.
signal room_setup_done
# Emitted when room has finished ":ready" event.
signal room_ready_done
# Debugging displays for a room # Debugging displays for a room
# NONE: No debug display # NONE: No debug display
# CAMERA_LIMITS: Display the camera limits # CAMERA_LIMITS: Display the camera limits
@@ -23,22 +30,31 @@ export(String, FILE, "*.esc") var esc_script = ""
export(PackedScene) var player_scene export(PackedScene) var player_scene
# The camera limits available in this room # The camera limits available in this room
export(Array, Rect2) var camera_limits: Array = [Rect2()] setget set_camera_limits export(Array, Rect2) var camera_limits: Array \
= [Rect2()] setget set_camera_limits
# The editor debug display mode # The editor debug display mode
export(EditorRoomDebugDisplay) var editor_debug_mode = EditorRoomDebugDisplay.NONE setget set_editor_debug_mode export(EditorRoomDebugDisplay) var editor_debug_mode \
= EditorRoomDebugDisplay.NONE setget set_editor_debug_mode
# The player scene instance # The player scene instance
var player var player
# The game scene instance # The game scene instance
var game var game
# Compiled ESCScript # Compiled ESCScript
var compiled_script: ESCScript var compiled_script: ESCScript
# Whether automatic transition are enabled or not
var enabled_automatic_transitions = true
# Whether this room was run directly with Play Scene (F6)
var is_run_directly = false
# Whether this room was accessed from an exit in a previous room
var exited_previous_room = false
# Start the random number generator when the camera limits should be displayed # Start the random number generator when the camera limits should be displayed
@@ -59,7 +75,8 @@ func _ready():
if Engine.is_editor_hint(): if Engine.is_editor_hint():
return return
game = $game if has_node("game"):
game = $game
if game == null: if game == null:
game = escoria.game_scene game = escoria.game_scene
add_child(game) add_child(game)
@@ -89,31 +106,121 @@ func _ready():
if global_id.empty(): if global_id.empty():
global_id = name global_id = name
# Determine whether this room was run from change_scene or directly
if escoria.main.has_node(name):
is_run_directly = false
else:
is_run_directly = true
perform_script_events()
func perform_script_events():
if esc_script and escoria.event_manager._running_event == null \
or (escoria.event_manager._running_event != null \
and escoria.event_manager._running_event.name != "load"):
if esc_script: # Manage player location at room start
run_script_event("setup")
var rc = yield(escoria.event_manager, "event_finished")
while rc[1] != "setup":
rc = yield(escoria.event_manager, "event_finished")
if rc[0] != ESCExecution.RC_OK:
return rc[0]
if (escoria.globals_manager.get_global("ESC_LAST_SCENE") == null \ if (escoria.globals_manager.get_global("ESC_LAST_SCENE") == null \
or escoria.globals_manager.get_global("ESC_LAST_SCENE").empty()) \ or escoria.globals_manager \
and player != null \ .get_global("ESC_LAST_SCENE").empty()) \
and escoria.object_manager.get_start_location() != null: and player != null \
and escoria.object_manager.get_start_location() != null:
player.teleport(escoria.object_manager.get_start_location().node) player.teleport(escoria.object_manager.get_start_location().node)
# If the room was loaded from change_scene and automatic transitions
# are not disabled, do the transition out now
if enabled_automatic_transitions \
and not is_run_directly \
and not exited_previous_room:
var script_transition_out = escoria.esc_compiler.compile([
":transition_out",
"transition %s out" % ProjectSettings.get_setting(
"escoria/ui/default_transition"
),
"hide_menu main"
])
escoria.event_manager.queue_event(
script_transition_out.events['transition_out']
)
escoria.main.scene_transition.transition() # Run the setup event
yield(escoria.main.scene_transition, "transition_done") _run_script_event("setup")
if enabled_automatic_transitions \
or (
not enabled_automatic_transitions \
and escoria.globals_manager.get_global("BYPASS_LAST_SCENE")
):
var script_transition_in = escoria.esc_compiler.compile([
":transition_in",
"transition %s in" % ProjectSettings.get_setting(
"escoria/ui/default_transition"
),
"wait 0.1"
])
escoria.event_manager.queue_event(
script_transition_in.events['transition_in']
)
var ready_event_added: bool = false
# Run the ready event, if there is one.
if escoria.event_manager._running_event == null \
or (escoria.event_manager._running_event != null \
and escoria.event_manager._running_event.name != "load"):
ready_event_added = _run_script_event("ready")
if ready_event_added:
# Wait for ready event to be done
var rc = yield(escoria.event_manager, "event_finished")
while rc[1] != "ready":
rc = yield(escoria.event_manager, "event_finished")
if rc[0] != ESCExecution.RC_OK:
return rc[0]
# Now that :ready is finished, if BYPASS_LAST_SCENE was true, reset it
# to false and set ESC_LAST_SCENE to current scene
if escoria.globals_manager.get_global("BYPASS_LAST_SCENE"):
escoria.globals_manager.set_global(
"BYPASS_LAST_SCENE",
false,
true
)
escoria.globals_manager.set_global(
"ESC_LAST_SCENE",
escoria.main.current_scene.global_id,
true
)
# Runs the script event from the script attached, if any.
#
# #### Parameters
#
# - event_name: the name of the event to run
#
# *Returns* true if the event was correctly added. Will be false if the event
# does not exist in the script.
func _run_script_event(event_name: String):
if !esc_script:
return false
if compiled_script == null:
compiled_script = escoria.esc_compiler.load_esc_file(esc_script)
run_script_event("ready") if compiled_script.events.has(event_name):
rc = yield(escoria.event_manager, "event_finished") escoria.logger.debug(
while rc[1] != "ready": "esc_room:_run_script_event",
rc = yield(escoria.event_manager, "event_finished") [
if rc[0] != ESCExecution.RC_OK: "Queuing room script event %s" % event_name,
return rc[0] "Composed of %s statements" % str(compiled_script.events[event_name].statements.size())
]
)
escoria.event_manager.queue_event(compiled_script.events[event_name])
return true
else:
return false
# Draw the camera limits visualization if enabled # Draw the camera limits visualization if enabled
func _draw(): func _draw():
@@ -160,16 +267,4 @@ func set_editor_debug_mode(p_editor_debug_mode: int) -> void:
update() update()
# Runs the script event from the script attached, if any
#
# #### Parameters
#
# - event_name: the name of the event to run
func run_script_event(event_name: String):
if !esc_script:
return
if compiled_script == null:
compiled_script = escoria.esc_compiler.load_esc_file(esc_script)
if compiled_script.events.has(event_name):
escoria.event_manager.queue_event(compiled_script.events[event_name])

View File

@@ -9,7 +9,7 @@ var warning_path: String
# Valid log levels # Valid log levels
enum { LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG } enum { LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG, LOG_TRACE }
# A map of log level names to log level ints # A map of log level names to log level ints
@@ -18,9 +18,21 @@ var _level_map: Dictionary = {
"WARNING": LOG_WARNING, "WARNING": LOG_WARNING,
"INFO": LOG_INFO, "INFO": LOG_INFO,
"DEBUG": LOG_DEBUG, "DEBUG": LOG_DEBUG,
"TRACE": LOG_TRACE,
} }
# Log a trace message
#
# #### Parameters
#
# * string: Text to log
# * args: Additional information
func trace(string: String, args = []):
if _get_log_level() >= LOG_TRACE:
var argsstr = str(args) if !args.empty() else ""
printerr("(T)\t" + string + " \t" + argsstr)
# Log a debug message # Log a debug message
# #
# #### Parameters # #### Parameters

View File

@@ -124,17 +124,24 @@ func load_game(id: int):
var load_event = ESCEvent.new(":load") var load_event = ESCEvent.new(":load")
var load_statements = [] var load_statements = []
load_statements.append(
ESCCommand.new(
"transition %s out" %
[ProjectSettings.get_setting("escoria/ui/default_transition")]
)
)
## GLOBALS ## GLOBALS
for k in save_game.globals.keys(): for k in save_game.globals.keys():
load_statements.append( load_statements.append(
ESCCommand.new("set_global %s \"%s\"\n" \ ESCCommand.new("set_global %s \"%s\"\n" \
% [k, save_game.globals[k]]) % [k, save_game.globals[k]])
) )
## ROOM ## ROOM
load_statements.append( load_statements.append(
ESCCommand.new("change_scene %s true" \ ESCCommand.new("change_scene %s true" \
% save_game.main["current_scene_filename"]) % save_game.main["current_scene_filename"])
) )
## OBJECTS ## OBJECTS
@@ -147,36 +154,43 @@ func load_game(id: int):
if save_game.objects[object_global_id].has("interactive"): if save_game.objects[object_global_id].has("interactive"):
load_statements.append(ESCCommand.new("set_interactive %s %s" \ load_statements.append(ESCCommand.new("set_interactive %s %s" \
% [object_global_id, % [object_global_id,
save_game.objects[object_global_id]["interactive"]]) save_game.objects[object_global_id]["interactive"]])
) )
if save_game.objects[object_global_id].has("state"): if save_game.objects[object_global_id].has("state"):
load_statements.append(ESCCommand.new("set_state %s %s true" \ load_statements.append(ESCCommand.new("set_state %s %s true" \
% [object_global_id, % [object_global_id,
save_game.objects[object_global_id]["state"]]) save_game.objects[object_global_id]["state"]])
) )
if save_game.objects[object_global_id].has("global_transform"): if save_game.objects[object_global_id].has("global_transform"):
load_statements.append(ESCCommand.new("teleport_pos %s %s %s" \ load_statements.append(ESCCommand.new("teleport_pos %s %s %s" \
% [object_global_id, % [object_global_id,
int(save_game.objects[object_global_id] \ int(save_game.objects[object_global_id] \
["global_transform"].origin.x), ["global_transform"].origin.x),
int(save_game.objects[object_global_id] \ int(save_game.objects[object_global_id] \
["global_transform"].origin.y)] ["global_transform"].origin.y)]
) )
) )
load_statements.append(ESCCommand.new("set_angle %s %s" \ load_statements.append(ESCCommand.new("set_angle %s %s" \
% [object_global_id, % [object_global_id,
save_game.objects[object_global_id]["last_deg"]]) save_game.objects[object_global_id]["last_deg"]])
) )
if object_global_id == "_music" or object_global_id == "_sound": if object_global_id == "_music" or object_global_id == "_sound":
load_statements.append(ESCCommand.new("set_sound_state %s %s true" \ load_statements.append(ESCCommand.new("set_sound_state %s %s true" \
% [object_global_id, % [object_global_id,
save_game.objects[object_global_id]["state"]]) save_game.objects[object_global_id]["state"]])
) )
load_statements.append(
ESCCommand.new(
"transition %s in" %
[ProjectSettings.get_setting("escoria/ui/default_transition")]
)
)
load_event.statements = load_statements load_event.statements = load_statements
escoria.set_game_paused(false) escoria.set_game_paused(false)
@@ -212,7 +226,8 @@ func save_settings():
# Load the game settings from the settings file # Load the game settings from the settings file
# **Returns** The Resource structure loaded from settings file # **Returns** The Resource structure loaded from settings file
func load_settings() -> Resource: func load_settings() -> Resource:
var save_settings_path: String = settings_folder.plus_file(SETTINGS_TEMPLATE) var save_settings_path: String = \
settings_folder.plus_file(SETTINGS_TEMPLATE)
var file: File = File.new() var file: File = File.new()
if not file.file_exists(save_settings_path): if not file.file_exists(save_settings_path):
escoria.logger.report_warnings( escoria.logger.report_warnings(

View File

@@ -122,7 +122,7 @@ func _init():
# Load settings # Load settings
func _ready(): func _ready():
settings = save_manager.load_settings() settings = save_manager.load_settings()
_on_settings_loaded(settings) apply_settings(settings)
inputs_manager.register_core() inputs_manager.register_core()
if ProjectSettings.get_setting("escoria/main/game_start_script").empty(): if ProjectSettings.get_setting("escoria/main/game_start_script").empty():
logger.report_errors("escoria.gd", logger.report_errors("escoria.gd",
@@ -265,7 +265,7 @@ func do(action: String, params: Array = [], can_interrupt: bool = false) -> void
# #### Parameters # #### Parameters
# #
# * p_settings: Loaded settings # * p_settings: Loaded settings
func _on_settings_loaded(p_settings: ESCSaveSettings) -> void: func apply_settings(p_settings: ESCSaveSettings) -> void:
logger.info("******* settings loaded") logger.info("******* settings loaded")
if p_settings != null: if p_settings != null:
settings = p_settings settings = p_settings

View File

@@ -40,9 +40,10 @@ func set_scene(p_scene: Node) -> void:
if current_scene != null: if current_scene != null:
clear_scene() clear_scene()
if not p_scene in get_children(): if not p_scene.is_inside_tree() or not p_scene in get_children():
add_child(p_scene) add_child(p_scene)
move_child(p_scene, 0) elif p_scene in get_children():
move_child(p_scene, 0)
current_scene = p_scene current_scene = p_scene
check_game_scene_methods() check_game_scene_methods()
@@ -62,7 +63,7 @@ func clear_scene() -> void:
if escoria.game_scene.get_parent() == current_scene: if escoria.game_scene.get_parent() == current_scene:
current_scene.remove_child(escoria.game_scene) current_scene.remove_child(escoria.game_scene)
remove_child(current_scene) current_scene.get_parent().remove_child(current_scene)
current_scene.free() current_scene.free()
current_scene = null current_scene = null

View File

@@ -3,8 +3,11 @@ extends ColorRect
class_name ESCTransitionPlayer class_name ESCTransitionPlayer
# Emitted when the transition was played # Emitted when the transition was played
signal transition_done signal transition_done(transition_id)
# Id of the transition. Allows keeping track of the actual transition
# being played or finished
var transition_id: int = 0
# The valid transition modes # The valid transition modes
enum TRANSITION_MODE { enum TRANSITION_MODE {
@@ -47,26 +50,28 @@ func transition(
transition_name: String = "", transition_name: String = "",
mode: int = TRANSITION_MODE.IN, mode: int = TRANSITION_MODE.IN,
duration: float = 1.0 duration: float = 1.0
) -> void: ) -> int:
if not has_transition(transition_name): if not has_transition(transition_name):
escoria.logger.report_errors( escoria.logger.report_errors(
"transition: Transition %s not found" % transition_name, "transition: Transition %s not found" % transition_name,
[] []
) )
material = ResourceLoader.load(get_transition(transition_name))
var start = 0 material = ResourceLoader.load(get_transition(transition_name))
var end = 1 transition_id += 1
var start = 0.0
var end = 1.0
if mode == TRANSITION_MODE.OUT: if mode == TRANSITION_MODE.OUT:
start = 1 start = 1.0
end = 0 end = 0.0
if _tween.is_active(): if _tween.is_active():
_was_canceled = true _was_canceled = true
_tween.stop_all() _tween.stop_all()
_tween.remove_all() _tween.remove_all()
emit_signal("transition_done", transition_id-1)
_tween.interpolate_property( _tween.interpolate_property(
$".", $".",
@@ -77,7 +82,7 @@ func transition(
) )
_was_canceled = false _was_canceled = false
_tween.start() _tween.start()
return transition_id
# Returns the full path for a transition shader based on its name # Returns the full path for a transition shader based on its name
@@ -112,6 +117,6 @@ func has_transition(name: String) -> bool:
func _on_tween_completed(): func _on_tween_completed():
if not _was_canceled: if not _was_canceled:
emit_signal("transition_done")
_tween.stop_all() _tween.stop_all()
_tween.remove_all() _tween.remove_all()
emit_signal("transition_done", transition_id)

View File

@@ -12,5 +12,3 @@ script = ExtResource( 1 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Tween" type="Tween" parent="."]

View File

@@ -76,7 +76,7 @@ func _on_language_input(event: InputEvent, language: String):
# - value: The new volume level # - value: The new volume level
func _on_sound_volume_changed(value): func _on_sound_volume_changed(value):
escoria.settings["sfx_volume"] = value escoria.settings["sfx_volume"] = value
escoria._on_settings_loaded(escoria.settings) escoria.apply_settings(escoria.settings)
settings_changed = true settings_changed = true
@@ -86,7 +86,7 @@ func _on_sound_volume_changed(value):
# - value: The new volume level # - value: The new volume level
func _on_music_volume_changed(value): func _on_music_volume_changed(value):
escoria.settings["music_volume"] = value escoria.settings["music_volume"] = value
escoria._on_settings_loaded(escoria.settings) escoria.apply_settings(escoria.settings)
settings_changed = true settings_changed = true
@@ -96,7 +96,7 @@ func _on_music_volume_changed(value):
# - value: The new volume level # - value: The new volume level
func _on_general_volume_changed(value): func _on_general_volume_changed(value):
escoria.settings["master_volume"] = value escoria.settings["master_volume"] = value
escoria._on_settings_loaded(escoria.settings) escoria.apply_settings(escoria.settings)
settings_changed = true settings_changed = true
@@ -106,7 +106,7 @@ func _on_general_volume_changed(value):
# - value: The new volume level # - value: The new volume level
func _on_speech_volume_value_changed(value: float) -> void: func _on_speech_volume_value_changed(value: float) -> void:
escoria.settings["speech_volume"] = value escoria.settings["speech_volume"] = value
escoria._on_settings_loaded(escoria.settings) escoria.apply_settings(escoria.settings)
settings_changed = true settings_changed = true
@@ -120,5 +120,5 @@ func _on_apply_pressed():
# The back button was pressed # The back button was pressed
func _on_back_pressed(): func _on_back_pressed():
escoria.settings = backup_settings escoria.settings = backup_settings
escoria._on_settings_loaded(escoria.settings) escoria.apply_settings(escoria.settings)
emit_signal("back_button_pressed") emit_signal("back_button_pressed")

View File

@@ -10,7 +10,7 @@ func _ready():
# Continue the game # Continue the game
func _on_continue_pressed(): func _on_continue_pressed():
escoria.main.current_scene.game.pause_game() escoria.main.current_scene.game.unpause_game()
# Show the save slots # Show the save slots

View File

@@ -16,7 +16,9 @@ func _ready():
"escoria/debug/room_selector_room_dir" "escoria/debug/room_selector_room_dir"
) )
if rooms_folder == "" or \ if rooms_folder == "" or \
not ProjectSettings.get_setting("escoria/debug/enable_room_selector"): not ProjectSettings.get_setting(
"escoria/debug/enable_room_selector"
):
return return
var dir = Directory.new() var dir = Directory.new()
var rooms_list: Array = [] var rooms_list: Array = []
@@ -50,11 +52,12 @@ func _ready():
func _on_button_pressed(): func _on_button_pressed():
escoria.globals_manager.set_global("BYPASS_LAST_SCENE", true, true) escoria.globals_manager.set_global("BYPASS_LAST_SCENE", true, true)
var script = escoria.esc_compiler.compile([ var script = escoria.esc_compiler.compile([
":debug", ":room_selector",
"change_scene %s" % _options_paths[_selected_id] "change_scene %s" % _options_paths[_selected_id]
]) ])
escoria.event_manager.interrupt_running_event() escoria.event_manager.interrupt_running_event()
escoria.event_manager.queue_event(script.events['debug']) escoria.event_manager.clear_event_queue()
escoria.event_manager.queue_event(script.events['room_selector'])

View File

@@ -27,6 +27,11 @@ Implement methods to react to inputs.
- hide_ui() - hide_ui()
- show_ui() - show_ui()
- pause_game()
- unpause_game()
- show_main_menu()
- hide_main_menu()
- _on_event_done(event_name: String) - _on_event_done(event_name: String)
""" """
@@ -36,7 +41,6 @@ onready var tooltip = $ui/Control/panel_down/VBoxContainer/MarginContainer\
/tooltip /tooltip
onready var room_select = $ui/Control/panel_down/VBoxContainer/HBoxContainer\ onready var room_select = $ui/Control/panel_down/VBoxContainer/HBoxContainer\
/MainMargin/VBoxContainer/room_select /MainMargin/VBoxContainer/room_select
onready var pause_menu = $ui/pause_menu
onready var inventory_ui = $ui/Control/panel_down/VBoxContainer/HBoxContainer\ onready var inventory_ui = $ui/Control/panel_down/VBoxContainer/HBoxContainer\
/InventoryMargin/inventory_ui /InventoryMargin/inventory_ui
@@ -195,23 +199,31 @@ func _on_event_done(_event_name: String):
escoria.action_manager.clear_current_action() escoria.action_manager.clear_current_action()
verbs_menu.unselect_actions() verbs_menu.unselect_actions()
func hide_main_menu():
if get_node(main_menu).visible:
get_node(main_menu).hide()
func pause_game(): func show_main_menu():
if pause_menu.visible: if not get_node(main_menu).visible:
pause_menu.hide() get_node(main_menu).show()
func unpause_game():
if get_node(pause_menu).visible:
get_node(pause_menu).hide()
escoria.object_manager.get_object("_camera").node.current = true escoria.object_manager.get_object("_camera").node.current = true
escoria.main.current_scene.game.show_ui() escoria.main.current_scene.game.show_ui()
escoria.main.current_scene.show() escoria.main.current_scene.show()
escoria.set_game_paused(false) escoria.set_game_paused(false)
else:
pause_menu.set_save_enabled(escoria.save_manager.save_enabled) func pause_game():
pause_menu.show() if not get_node(pause_menu).visible:
get_node(pause_menu).set_save_enabled(escoria.save_manager.save_enabled)
get_node(pause_menu).show()
escoria.object_manager.get_object("_camera").node.current = false escoria.object_manager.get_object("_camera").node.current = false
escoria.main.current_scene.game.hide_ui() escoria.main.current_scene.game.hide_ui()
escoria.main.current_scene.hide() escoria.main.current_scene.hide()
escoria.set_game_paused(true) escoria.set_game_paused(true)
func _on_MenuButton_pressed() -> void: func _on_MenuButton_pressed() -> void:
pause_game() pause_game()

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=2] [gd_scene load_steps=12 format=2]
[ext_resource path="res://addons/escoria-ui-9verbs/tooltip/action_target_tooltip.tscn" type="PackedScene" id=1] [ext_resource path="res://addons/escoria-ui-9verbs/tooltip/action_target_tooltip.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/escoria-ui-9verbs/inventory/inventory_ui.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/escoria-ui-9verbs/inventory/inventory_ui.tscn" type="PackedScene" id=2]
@@ -6,6 +6,7 @@
[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/esc_dialog_player.gd" type="Script" id=4] [ext_resource path="res://addons/escoria-core/game/scenes/dialogs/esc_dialog_player.gd" type="Script" id=4]
[ext_resource path="res://addons/escoria-ui-9verbs/game.gd" type="Script" id=5] [ext_resource path="res://addons/escoria-ui-9verbs/game.gd" type="Script" id=5]
[ext_resource path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" type="PackedScene" id=6] [ext_resource path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" type="PackedScene" id=6]
[ext_resource path="res://addons/escoria-core/ui_library/menus/main_menu/main_menu.tscn" type="PackedScene" id=7]
[ext_resource path="res://addons/escoria-ui-9verbs/tooltip/tooltip_action_target.gd" type="Script" id=8] [ext_resource path="res://addons/escoria-ui-9verbs/tooltip/tooltip_action_target.gd" type="Script" id=8]
[ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.tscn" type="PackedScene" id=9] [ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.tscn" type="PackedScene" id=9]
[ext_resource path="res://addons/escoria-ui-9verbs/theme.tres" type="Theme" id=10] [ext_resource path="res://addons/escoria-ui-9verbs/theme.tres" type="Theme" id=10]
@@ -15,6 +16,8 @@ bg_color = Color( 0.6, 0.6, 0.6, 0.5 )
[node name="game" type="Node2D"] [node name="game" type="Node2D"]
script = ExtResource( 5 ) script = ExtResource( 5 )
main_menu = NodePath("ui/main_menu")
pause_menu = NodePath("ui/pause_menu")
[node name="ui" type="CanvasLayer" parent="."] [node name="ui" type="CanvasLayer" parent="."]
@@ -153,6 +156,9 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="main_menu" parent="ui" instance=ExtResource( 7 )]
visible = false
[node name="pause_menu" parent="ui" instance=ExtResource( 9 )] [node name="pause_menu" parent="ui" instance=ExtResource( 9 )]
visible = false visible = false
theme = ExtResource( 10 ) theme = ExtResource( 10 )

View File

@@ -27,6 +27,11 @@ Implement methods to react to inputs.
- hide_ui() - hide_ui()
- show_ui() - show_ui()
- pause_game()
- unpause_game()
- show_main_menu()
- hide_main_menu()
- _on_event_done(event_name: String) - _on_event_done(event_name: String)
""" """
@@ -171,18 +176,27 @@ func _on_event_done(event_name: String):
escoria.action_manager.clear_current_action() escoria.action_manager.clear_current_action()
$CanvasLayer/ui/HBoxContainer/verbs_menu.clear_tool_texture() $CanvasLayer/ui/HBoxContainer/verbs_menu.clear_tool_texture()
func hide_main_menu():
if get_node(main_menu).visible:
get_node(main_menu).hide()
func pause_game(): func show_main_menu():
if $CanvasLayer/pause_menu.visible: if not get_node(main_menu).visible:
$CanvasLayer/pause_menu.hide() get_node(main_menu).show()
func unpause_game():
if get_node(pause_menu).visible:
get_node(pause_menu).hide()
escoria.object_manager.get_object("_camera").node.current = true escoria.object_manager.get_object("_camera").node.current = true
escoria.main.current_scene.game.show_ui() escoria.main.current_scene.game.show_ui()
escoria.main.current_scene.show() escoria.main.current_scene.show()
else:
$CanvasLayer/pause_menu.set_save_enabled( func pause_game():
if not get_node(pause_menu).visible:
get_node(pause_menu).set_save_enabled(
escoria.save_manager.save_enabled escoria.save_manager.save_enabled
) )
$CanvasLayer/pause_menu.show() get_node(pause_menu).show()
escoria.object_manager.get_object("_camera").node.current = false escoria.object_manager.get_object("_camera").node.current = false
escoria.main.current_scene.game.hide_ui() escoria.main.current_scene.game.hide_ui()
escoria.main.current_scene.hide() escoria.main.current_scene.hide()

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=2] [gd_scene load_steps=10 format=2]
[ext_resource path="res://addons/escoria-ui-simplemouse/inventory/inventory_ui.tscn" type="PackedScene" id=1] [ext_resource path="res://addons/escoria-ui-simplemouse/inventory/inventory_ui.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/esc_dialog_player.gd" type="Script" id=2] [ext_resource path="res://addons/escoria-core/game/scenes/dialogs/esc_dialog_player.gd" type="Script" id=2]
@@ -6,11 +6,14 @@
[ext_resource path="res://addons/escoria-ui-simplemouse/verbs_mouseicons.tscn" type="PackedScene" id=4] [ext_resource path="res://addons/escoria-ui-simplemouse/verbs_mouseicons.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/escoria-ui-simplemouse/game.gd" type="Script" id=5] [ext_resource path="res://addons/escoria-ui-simplemouse/game.gd" type="Script" id=5]
[ext_resource path="res://addons/escoria-ui-simplemouse/tooltip/target_tooltip.tscn" type="PackedScene" id=6] [ext_resource path="res://addons/escoria-ui-simplemouse/tooltip/target_tooltip.tscn" type="PackedScene" id=6]
[ext_resource path="res://addons/escoria-core/ui_library/menus/main_menu/main_menu.tscn" type="PackedScene" id=7]
[ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.tscn" type="PackedScene" id=8] [ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.tscn" type="PackedScene" id=8]
[ext_resource path="res://addons/escoria-ui-simplemouse/theme.tres" type="Theme" id=9] [ext_resource path="res://addons/escoria-ui-simplemouse/theme.tres" type="Theme" id=9]
[node name="game" type="Node2D"] [node name="game" type="Node2D"]
script = ExtResource( 5 ) script = ExtResource( 5 )
main_menu = NodePath("CanvasLayer/main_menu")
pause_menu = NodePath("CanvasLayer/pause_menu")
editor_debug_mode = 1 editor_debug_mode = 1
[node name="camera" parent="." instance=ExtResource( 3 )] [node name="camera" parent="." instance=ExtResource( 3 )]
@@ -69,6 +72,9 @@ rect_scale = Vector2( 1, 1 )
visible = false visible = false
theme = ExtResource( 9 ) theme = ExtResource( 9 )
[node name="main_menu" parent="CanvasLayer" instance=ExtResource( 7 )]
visible = false
[node name="dialog_layer" type="CanvasLayer" parent="."] [node name="dialog_layer" type="CanvasLayer" parent="."]
layer = 3 layer = 3

View File

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

View File

@@ -26,10 +26,25 @@ editor_debug_mode = 1
[node name="advice" type="Label" parent="background"] [node name="advice" type="Label" parent="background"]
anchor_right = 0.023274 anchor_right = 0.023274
anchor_bottom = 0.018018 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_left = 90.2752
margin_top = 120.824 margin_top = 170.824
margin_right = 270.275 margin_right = 270.275
margin_bottom = 155.824 margin_bottom = 205.824
custom_fonts/font = ExtResource( 3 ) custom_fonts/font = ExtResource( 3 )
text = "Move : left click text = "Move : left click
Fast move : double left click" Fast move : double left click"

View File

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

View File

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

View File

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

View File

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

View File

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

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

@@ -1,5 +1,5 @@
:exit_scene :exit_scene
set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false
transition fade_black out 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 :setup
set_state _music off false set_state _music off false
> [eq ESC_LAST_SCENE room10] > [eq ESC_LAST_SCENE room10]

View File

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

View File

@@ -1,3 +1,3 @@
:exit_scene :exit_scene
#set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false #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 :setup
:ready :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://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/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_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_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://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] [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 ) 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 )] [node name="r_door" parent="Hotspots" instance=ExtResource( 8 )]
global_id = "r13_r_exit" 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" default_action = "use"
[node name="ESCLocation" type="Position2D" parent="Hotspots/r_door"] [node name="ESCLocation" type="Position2D" parent="Hotspots/r_door"]
@@ -102,7 +101,3 @@ __meta__ = {
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hotspots/Hint"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Hotspots/Hint"]
position = Vector2( 651.176, 177.775 ) position = Vector2( 651.176, 177.775 )
shape = SubResource( 2 ) 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 :init
set_sound_state _music res://game/sfx/Game-Menu_Looping.mp3 true 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 :newgame
# Hide main menu
set_active _main_menu false
# 1/ Simple scene # 1/ Simple scene
change_scene res://game/rooms/room01/room01.tscn 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 # 12/ Event flags tests 2
#change_scene res://game/rooms/room12/room12.tscn #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

View File

@@ -365,6 +365,11 @@ _global_script_classes=[ {
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/enable_terrain.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/enable_terrain.gd"
}, { }, {
"base": "ESCBaseCommand", "base": "ESCBaseCommand",
"class": "HideMenuCommand",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd"
}, {
"base": "ESCBaseCommand",
"class": "IncGlobalCommand", "class": "IncGlobalCommand",
"language": "GDScript", "language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd"
@@ -459,6 +464,11 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/set_state.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/set_state.gd"
}, { }, {
"base": "ESCBaseCommand",
"class": "ShowMenuCommand",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd"
}, {
"base": "SlideCommand", "base": "SlideCommand",
"class": "SlideBlockCommand", "class": "SlideBlockCommand",
"language": "GDScript", "language": "GDScript",
@@ -596,6 +606,7 @@ _global_script_class_icons={
"ESCUtils": "", "ESCUtils": "",
"ESCWalkContext": "", "ESCWalkContext": "",
"EnableTerrainCommand": "", "EnableTerrainCommand": "",
"HideMenuCommand": "",
"IncGlobalCommand": "", "IncGlobalCommand": "",
"InventoryAddCommand": "", "InventoryAddCommand": "",
"InventoryRemoveCommand": "", "InventoryRemoveCommand": "",
@@ -615,6 +626,7 @@ _global_script_class_icons={
"SetSoundStateCommand": "", "SetSoundStateCommand": "",
"SetSpeedCommand": "", "SetSpeedCommand": "",
"SetStateCommand": "", "SetStateCommand": "",
"ShowMenuCommand": "",
"SlideBlockCommand": "", "SlideBlockCommand": "",
"SlideCommand": "", "SlideCommand": "",
"SpawnCommand": "", "SpawnCommand": "",
@@ -671,6 +683,7 @@ debug/terminate_on_warnings=false
debug/terminate_on_errors=true debug/terminate_on_errors=true
debug/development_lang="en" debug/development_lang="en"
ui/tooltip_follows_mouse=false ui/tooltip_follows_mouse=false
ui/default_dialog_scene="res://addons/escoria-core/ui_library/dialogs/floating_dialog_player.tscn"
main/text_lang="fr_FR" main/text_lang="fr_FR"
main/voice_lang="fr_FR" main/voice_lang="fr_FR"
sound/music_volume=1 sound/music_volume=1
@@ -696,8 +709,8 @@ ui/transition_paths=[ "res://addons/escoria-core/game/scenes/transitions/shaders
ui/inventory_item_size=Vector2( 72, 72 ) ui/inventory_item_size=Vector2( 72, 72 )
debug/enable_room_selector=true debug/enable_room_selector=true
debug/room_selector_room_dir="res://game/rooms" debug/room_selector_room_dir="res://game/rooms"
ui/dialog_managers=[ "res://addons/escoria-dialog-simple/esc_dialog_simple.gd" ]
ui/default_dialog_type="floating" ui/default_dialog_type="floating"
ui/dialog_managers=[ "res://addons/escoria-dialog-simple/esc_dialog_simple.gd" ]
dialog_simple/avatars_path="res://game/dialog_avatars" dialog_simple/avatars_path="res://game/dialog_avatars"
dialog_simple/text_speed_per_character=0.1 dialog_simple/text_speed_per_character=0.1
dialog_simple/fast_text_speed_per_character=0.25 dialog_simple/fast_text_speed_per_character=0.25
@@ -707,7 +720,7 @@ dialog_simple/max_time_to_disappear=1.0
esc_show_debug_prompt={ esc_show_debug_prompt={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777245,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777245,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
] ]
} }
switch_action_verb={ switch_action_verb={

View File

@@ -6,8 +6,8 @@
script = ExtResource( 1 ) script = ExtResource( 1 )
escoria_version = "0.1.0" escoria_version = "0.1.0"
game_version = "0.1.0" game_version = "0.1.0"
name = "3" name = "Testtt1"
date = "11/08/2021 21:14" date = "04/11/2021 22:13"
main = { main = {
"current_scene_filename": "res://game/rooms/room01/room01.tscn", "current_scene_filename": "res://game/rooms/room01/room01.tscn",
"last_scene_global_id": "" "last_scene_global_id": ""
@@ -18,24 +18,29 @@ globals = {
"room1_visited": true "room1_visited": true
} }
objects = { objects = {
"bg_music": { "_camera": {
"active": true,
"interactive": true,
"state": "res://game/sfx/contemplation.ogg"
},
"bg_sound": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"camera": { "_music": {
"active": true,
"interactive": true,
"state": "res://game/sfx/contemplation.ogg"
},
"_sound": {
"active": true,
"interactive": true,
"state": "default"
},
"_speech": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"player": { "player": {
"active": true, "active": true,
"global_transform": Transform2D( 1, 0, 0, 1, 621.898, 479.227 ), "global_transform": Transform2D( 1, 0, 0, 1, 399, 480 ),
"interactive": true, "interactive": true,
"last_deg": 71, "last_deg": 71,
"last_dir": 2, "last_dir": 2,
@@ -56,7 +61,7 @@ objects = {
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"r1_left_object_interaction": { "r1_destination_point3": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"
@@ -81,7 +86,7 @@ objects = {
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"r2_left_object_interaction": { "trigger_talk": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"

View File

@@ -6,39 +6,45 @@
script = ExtResource( 1 ) script = ExtResource( 1 )
escoria_version = "0.1.0" escoria_version = "0.1.0"
game_version = "0.1.0" game_version = "0.1.0"
name = "4" name = "Test2"
date = "11/08/2021 21:20" date = "04/11/2021 22:59"
main = { main = {
"current_scene_filename": "res://game/rooms/room01/room01.tscn", "current_scene_filename": "res://game/rooms/room02/room02.tscn",
"last_scene_global_id": "" "last_scene_global_id": ""
} }
globals = { globals = {
"dialog_advance": 0, "dialog_advance": 0,
"dialog_popup_advance": 0, "dialog_popup_advance": 0,
"r2_bridge_closed": true,
"room1_visited": true "room1_visited": true
} }
objects = { objects = {
"bg_music": { "_camera": {
"active": true,
"interactive": true,
"state": "res://game/sfx/contemplation.ogg"
},
"bg_sound": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"camera": { "_music": {
"active": true,
"interactive": true,
"state": "res://game/sfx/contemplation.ogg"
},
"_sound": {
"active": true,
"interactive": true,
"state": "default"
},
"_speech": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"player": { "player": {
"active": true, "active": true,
"global_transform": Transform2D( 1, 0, 0, 1, 994.586, 458.862 ), "global_transform": Transform2D( 1, 0, 0, 1, 1051, 434 ),
"interactive": true, "interactive": true,
"last_deg": 71, "last_deg": 111,
"last_dir": 2, "last_dir": 3,
"state": "default" "state": "default"
}, },
"player_start": { "player_start": {
@@ -46,44 +52,39 @@ objects = {
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"r1_destination_point": { "r2_bridge": {
"active": true,
"interactive": false,
"state": "bridge_close"
},
"r2_button": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"r1_destination_point2": { "r2_button_right": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"r1_left_object_interaction": { "r2_l_exit": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"r1_r_exit": { "r2_player_start": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"r1_start": { "r2_r_exit": {
"active": true, "active": true,
"interactive": true, "interactive": true,
"state": "default" "state": "default"
}, },
"r1_wall_item1": { "r2_right_platform": {
"active": true, "active": true,
"interactive": true, "interactive": false,
"state": "default"
},
"r1_wall_item2": {
"active": true,
"interactive": true,
"state": "default"
},
"r2_left_object_interaction": {
"active": true,
"interactive": true,
"state": "default" "state": "default"
} }
} }

View File

@@ -1,88 +0,0 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/save_data/esc_savegame.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )
escoria_version = "0.1.0"
game_version = "0.1.0"
name = "5"
date = "26/08/2021 08:59"
main = {
"current_scene_filename": "res://game/rooms/room01/room01.tscn",
"last_scene_global_id": ""
}
globals = {
"dialog_advance": 0,
"dialog_popup_advance": 0,
"room1_visited": true
}
objects = {
"bg_music": {
"active": true,
"interactive": true,
"state": "res://game/sfx/contemplation.ogg"
},
"bg_sound": {
"active": true,
"interactive": true,
"state": "default"
},
"camera": {
"active": true,
"interactive": true,
"state": "default"
},
"player": {
"active": true,
"global_transform": Transform2D( 1, 0, 0, 1, 994.586, 458.862 ),
"interactive": true,
"last_dir": 2,
"state": "default"
},
"player_start": {
"active": true,
"interactive": true,
"state": "default"
},
"r1_destination_point": {
"active": true,
"interactive": true,
"state": "default"
},
"r1_destination_point2": {
"active": true,
"interactive": true,
"state": "default"
},
"r1_left_object_interaction": {
"active": true,
"interactive": true,
"state": "default"
},
"r1_r_exit": {
"active": true,
"interactive": true,
"state": "default"
},
"r1_start": {
"active": true,
"interactive": true,
"state": "default"
},
"r1_wall_item1": {
"active": true,
"interactive": true,
"state": "default"
},
"r1_wall_item2": {
"active": true,
"interactive": true,
"state": "default"
},
"r2_left_object_interaction": {
"active": true,
"interactive": true,
"state": "default"
}
}