Big refactor: Fix plugin issues when disabling/reenabling plugins (#598)
Co-authored-by: balloonpopper <5151242+balloonpopper@users.noreply.github.com> Co-authored-by: Duncan Brown <duncan@prometheussoftware.ca>
This commit is contained in:
@@ -142,7 +142,7 @@ func _calculate_movement(delta: float):
|
|||||||
#
|
#
|
||||||
# - angle: the angle X axis and object's facing direction.
|
# - angle: the angle X axis and object's facing direction.
|
||||||
func _perform_walk_orientation(angle: float):
|
func _perform_walk_orientation(angle: float):
|
||||||
last_dir = _get_dir_deg(escoria.utils.get_deg_from_rad(angle),
|
last_dir = _get_dir_deg(ESCUtils.get_deg_from_rad(angle),
|
||||||
parent.animations)
|
parent.animations)
|
||||||
|
|
||||||
var animation_player: ESCAnimationPlayer = \
|
var animation_player: ESCAnimationPlayer = \
|
||||||
@@ -158,15 +158,10 @@ func _perform_walk_orientation(angle: float):
|
|||||||
elif current_animation != animation_to_play and \
|
elif current_animation != animation_to_play and \
|
||||||
not animation_player.has_animation(animation_to_play):
|
not animation_player.has_animation(animation_to_play):
|
||||||
current_animation = animation_to_play
|
current_animation = animation_to_play
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"movable.gd:_process()",
|
self,
|
||||||
[
|
"Character %s has no animation %s\nBypassing the missing animation and movement command."
|
||||||
"Character %s has no animation %s "
|
% [parent.global_id, animation_to_play]
|
||||||
% [parent.global_id, animation_to_play],
|
|
||||||
"Bypassing missing animation and " +
|
|
||||||
"proceed movement."
|
|
||||||
],
|
|
||||||
true
|
|
||||||
)
|
)
|
||||||
|
|
||||||
is_mirrored = parent.animations.directions[last_dir].mirrored
|
is_mirrored = parent.animations.directions[last_dir].mirrored
|
||||||
@@ -181,21 +176,21 @@ func teleport(target: Node) -> void:
|
|||||||
if target.has_method("get_interact_position"):
|
if target.has_method("get_interact_position"):
|
||||||
parent.global_position = target.get_interact_position()
|
parent.global_position = target.get_interact_position()
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"Object %s is teleported at position %s" % [
|
self,
|
||||||
target.name,
|
"Object %s is teleported to position %s."
|
||||||
parent.global_position
|
% [target.name, parent.global_position]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
elif "position" in target:
|
elif "position" in target:
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"Object %s teleported at position %s" %
|
self,
|
||||||
[parent.global_id, str(target.global_position)]
|
"Object %s teleported to position %s."
|
||||||
|
% [parent.global_id, str(target.global_position)]
|
||||||
)
|
)
|
||||||
parent.global_position = target.global_position
|
parent.global_position = target.global_position
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCMovable#teleport()",
|
self,
|
||||||
["Couldn't understand how to manage teleport Target %s" % target]
|
"Target %s could not be teleported. Please configure the interact position parameter or create a child ESCLocation node." % target
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -206,8 +201,9 @@ func teleport(target: Node) -> void:
|
|||||||
# - target: Vector2 target position to teleport to
|
# - target: Vector2 target position to teleport to
|
||||||
func teleport_to(target: Vector2) -> void:
|
func teleport_to(target: Vector2) -> void:
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"Object %s teleported to position %s" %
|
self,
|
||||||
[parent.global_id, str(target)]
|
"Object %s teleported to position %s."
|
||||||
|
% [parent.global_id, str(target)]
|
||||||
)
|
)
|
||||||
parent.global_position = target
|
parent.global_position = target
|
||||||
|
|
||||||
@@ -287,14 +283,16 @@ func walk_stop(pos: Vector2) -> void:
|
|||||||
|
|
||||||
if walk_context.target_object:
|
if walk_context.target_object:
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"%s arrived at %s" % [
|
self,
|
||||||
|
"%s arrived at %s." % [
|
||||||
parent.global_id,
|
parent.global_id,
|
||||||
walk_context.target_object.global_id
|
walk_context.target_object.global_id
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"%s arrived at %s" % [
|
self,
|
||||||
|
"%s arrived at %s." % [
|
||||||
parent.global_id,
|
parent.global_id,
|
||||||
walk_context.target_position
|
walk_context.target_position
|
||||||
]
|
]
|
||||||
@@ -311,7 +309,8 @@ func update_terrain(on_event_finished_name = null) -> void:
|
|||||||
if !parent.terrain or parent.terrain == null \
|
if !parent.terrain or parent.terrain == null \
|
||||||
or !is_instance_valid(parent.terrain):
|
or !is_instance_valid(parent.terrain):
|
||||||
return
|
return
|
||||||
if on_event_finished_name != null and on_event_finished_name != escoria.event_manager.EVENT_SETUP:
|
if on_event_finished_name != null \
|
||||||
|
and on_event_finished_name != ESCEventManager.EVENT_SETUP:
|
||||||
return
|
return
|
||||||
if parent.get("is_exit"):
|
if parent.get("is_exit"):
|
||||||
return
|
return
|
||||||
@@ -376,9 +375,9 @@ func _get_dir_deg(deg: int, animations: ESCAnimationResource) -> int:
|
|||||||
|
|
||||||
# It's an error to have the animations misconfigured
|
# It's an error to have the animations misconfigured
|
||||||
if dir == -1:
|
if dir == -1:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_movable.gd:_get_dir_deg()",
|
self,
|
||||||
["No direction found for " + str(deg)]
|
"No animation has been configured for angle %s." + str(deg)
|
||||||
)
|
)
|
||||||
|
|
||||||
return dir
|
return dir
|
||||||
@@ -414,9 +413,9 @@ func _is_angle_in_interval(
|
|||||||
# - wait float Wait this amount of seconds until continuing with turning around
|
# - wait float Wait this amount of seconds until continuing with turning around
|
||||||
func set_angle(deg: int, wait: float = 0.0) -> void:
|
func set_angle(deg: int, wait: float = 0.0) -> void:
|
||||||
if deg < 0 or deg > 360:
|
if deg < 0 or deg > 360:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"movable.gd:set_angle()",
|
self,
|
||||||
["Invalid degree to turn to " + str(deg)]
|
"Invalid degree to turn to : %s. Valid angles are between 0 and 360." % str(deg)
|
||||||
)
|
)
|
||||||
moved = true
|
moved = true
|
||||||
|
|
||||||
@@ -490,15 +489,15 @@ func _get_angle() -> int:
|
|||||||
# Integer: -1 (anti-clockwise), 1 (clockwise) or 0 (no movement needed).
|
# Integer: -1 (anti-clockwise), 1 (clockwise) or 0 (no movement needed).
|
||||||
func get_shortest_way_to_dir(current_dir: int, target_dir: int) -> int:
|
func get_shortest_way_to_dir(current_dir: int, target_dir: int) -> int:
|
||||||
if current_dir < 0 or current_dir > parent.animations.dir_angles.size() - 1:
|
if current_dir < 0 or current_dir > parent.animations.dir_angles.size() - 1:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_movable.gd:get_shortest_way_to_dir()",
|
self,
|
||||||
["Invalid direction (current_dir) %s" % str(current_dir)]
|
"Invalid direction (current_dir) %s" % str(current_dir)
|
||||||
)
|
)
|
||||||
|
|
||||||
if target_dir < 0 or target_dir > parent.animations.dir_angles.size() - 1:
|
if target_dir < 0 or target_dir > parent.animations.dir_angles.size() - 1:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_movable.gd:get_shortest_way_to_dir()",
|
self,
|
||||||
["Invalid direction (target_dir) %s " % str(target_dir)]
|
"Invalid direction (target_dir) %s " % str(target_dir)
|
||||||
)
|
)
|
||||||
|
|
||||||
if current_dir == target_dir:
|
if current_dir == target_dir:
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ extends ESCBaseCommand
|
|||||||
class_name AcceptInputCommand
|
class_name AcceptInputCommand
|
||||||
|
|
||||||
|
|
||||||
|
# The list of supported input types
|
||||||
|
const SUPPORTED_INPUT_TYPES = ["ALL", "NONE", "SKIP"]
|
||||||
|
|
||||||
|
|
||||||
# Return the descriptor of the arguments of this command
|
# Return the descriptor of the arguments of this command
|
||||||
func configure() -> ESCCommandArgumentDescriptor:
|
func configure() -> ESCCommandArgumentDescriptor:
|
||||||
return ESCCommandArgumentDescriptor.new(
|
return ESCCommandArgumentDescriptor.new(
|
||||||
@@ -36,13 +40,16 @@ func validate(arguments: Array):
|
|||||||
if not .validate(arguments):
|
if not .validate(arguments):
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if not arguments[0] in ["ALL", "NONE", "SKIP"]:
|
if not arguments[0] in SUPPORTED_INPUT_TYPES:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"accept_input: invalid parameter",
|
self,
|
||||||
[
|
"[%s]: invalid parameter. %s is not a valid parameter value." +
|
||||||
"%s is not a valid parameter value (ALL, NONE, SKIP)" %\
|
"Should be one of %s"
|
||||||
arguments[0]
|
% [
|
||||||
]
|
get_command_name(),
|
||||||
|
arguments[0],
|
||||||
|
str(SUPPORTED_INPUT_TYPES)
|
||||||
|
]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -30,11 +30,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"anim: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object. Object with global id %s not found."
|
||||||
"Object with global id %s not found." % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
@@ -56,9 +55,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,11 +31,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"anim_block.gd:validate",
|
self,
|
||||||
[
|
"[%s]: Object with global id %s not found."
|
||||||
"Object with global id %s not found." % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
@@ -62,9 +61,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -48,20 +48,25 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"camera_push: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object. Object global id %s not found."
|
||||||
"Object global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not arguments[2] in SUPPORTED_TRANSITIONS:
|
if not arguments[2] in SUPPORTED_TRANSITIONS:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"camera_shift: invalid transition type",
|
self,
|
||||||
[
|
(
|
||||||
"Transition type {t_type} is not one of the accepted types : {allowed_types}".format(
|
"[{command_name}]: invalid transition type. Transition type {t_type} " +
|
||||||
{"t_type":arguments[2],"allowed_types":SUPPORTED_TRANSITIONS})
|
"is not one of the accepted types : {allowed_types}"
|
||||||
]
|
).format(
|
||||||
|
{
|
||||||
|
"command_name":get_command_name(),
|
||||||
|
"t_type":arguments[2],
|
||||||
|
"allowed_types":SUPPORTED_TRANSITIONS
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@@ -74,16 +79,14 @@ func run(command_params: Array) -> int:
|
|||||||
.push(
|
.push(
|
||||||
escoria.object_manager.get_object(command_params[0]).node,
|
escoria.object_manager.get_object(command_params[0]).node,
|
||||||
command_params[1],
|
command_params[1],
|
||||||
Tween.new().get("TRANS_%s" % command_params[2])
|
ClassDB.class_get_integer_constant("Tween", "TRANS_%s" % command_params[2])
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if escoria.main.current_scene.camera_limits.size() < arguments[0]:
|
if escoria.main.current_scene.camera_limits.size() < arguments[0]:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"camera_set_limits: invalid limits id",
|
self,
|
||||||
[
|
"[%s]: invalid limits id. Camera limit id (%d) is larger than the number of limits defined in this scene (%d)."
|
||||||
"Limit id %d is bigger than limits array size %d" % [
|
% [
|
||||||
|
get_command_name(),
|
||||||
arguments[0],
|
arguments[0],
|
||||||
escoria.main.current_scene.camera_limits.size()
|
escoria.main.current_scene.camera_limits.size()
|
||||||
]
|
]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@@ -55,9 +55,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -36,9 +36,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,11 +32,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[1]):
|
if not escoria.object_manager.has(arguments[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"camera_set_target: invalid object",
|
self,
|
||||||
[
|
"[%s]: Invalid object: Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[1]
|
% [get_command_name(), arguments[1]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@@ -55,9 +54,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -30,11 +30,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if arguments[0] < 0:
|
if arguments[0] < 0:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"camera_set_zoom_height: invalid height",
|
self,
|
||||||
[
|
"[%s]: invalid height. Can't zoom to a negative height (%d)."
|
||||||
"Can't zoom to a negative height %d" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@@ -53,9 +52,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[1]
|
command_params[1]
|
||||||
),
|
),
|
||||||
command_params[2],
|
command_params[2],
|
||||||
Tween.new().get("TRANS_%s" % command_params[3])
|
ClassDB.class_get_integer_constant("Tween", "TRANS_%s" % command_params[3])
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
@@ -59,12 +59,18 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not arguments[3] in SUPPORTED_TRANSITIONS:
|
if not arguments[3] in SUPPORTED_TRANSITIONS:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"camera_shift: invalid transition type",
|
self,
|
||||||
[
|
(
|
||||||
"Transition type {t_type} is not one of the accepted types : {allowed_types}".format(
|
"[{command_name}]: invalid transition type" +
|
||||||
{"t_type":arguments[3],"allowed_types":SUPPORTED_TRANSITIONS})
|
"Transition type {t_type} is not one of the accepted types : {allowed_types}"
|
||||||
]
|
).format(
|
||||||
|
{
|
||||||
|
"command_name": get_command_name(),
|
||||||
|
"t_type":arguments[3],
|
||||||
|
"allowed_types":SUPPORTED_TRANSITIONS
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@@ -73,9 +79,7 @@ func validate(arguments: Array):
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,22 +31,24 @@ func validate(arguments: Array) -> bool:
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not ResourceLoader.exists(arguments[0]):
|
if not ResourceLoader.exists(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"change_scene: Invalid scene",
|
self,
|
||||||
["Scene %s was not found" % arguments[0]]
|
"[%s]: Invalid scene. Scene %s was not found."
|
||||||
|
% [get_command_name(), arguments[0]]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not ResourceLoader.exists(
|
if not ResourceLoader.exists(
|
||||||
escoria.project_settings_manager.get_setting(escoria.project_settings_manager.GAME_SCENE)
|
ESCProjectSettingsManager.get_setting(ESCProjectSettingsManager.GAME_SCENE)
|
||||||
):
|
):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"change_scene: Game scene not found",
|
self,
|
||||||
[
|
"[%s]: Game scene not found. The path set in 'ui/game_scene' was not found: %s."
|
||||||
"The path set in 'ui/game_scene' was not found: %s" % \
|
% [
|
||||||
escoria.project_settings_manager.get_setting(
|
get_command_name(),
|
||||||
escoria.project_settings_manager.GAME_SCENE
|
ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.GAME_SCENE
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@@ -56,10 +58,14 @@ 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 (enable_automatic_transition = %s)" % [
|
self,
|
||||||
command_params[0], # scene file
|
"[%s] Changing scene to %s (enable_automatic_transition = %s)."
|
||||||
command_params[1] # enable_automatic_transition
|
% [
|
||||||
])
|
get_command_name(),
|
||||||
|
command_params[0], # scene file
|
||||||
|
command_params[1] # enable_automatic_transition
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
escoria.room_manager.change_scene(command_params[0], command_params[1])
|
escoria.room_manager.change_scene(command_params[0], command_params[1])
|
||||||
|
|
||||||
@@ -68,9 +74,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -35,24 +35,23 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"custom: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object. Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
elif not escoria.object_manager.get_object(arguments[0]).node.has_node(
|
elif not escoria.object_manager.get_object(arguments[0]).node.has_node(
|
||||||
arguments[1]
|
arguments[1]
|
||||||
):
|
):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"custom: invalid node",
|
self,
|
||||||
[
|
"[%s]: invalid node. Object with global id %s has no child node called %s."
|
||||||
"Object with global id %s has no node %s" % [
|
% [
|
||||||
arguments[0],
|
get_command_name(),
|
||||||
arguments[1],
|
arguments[0],
|
||||||
]
|
arguments[1],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
elif not escoria.object_manager.get_object(arguments[0]).node\
|
elif not escoria.object_manager.get_object(arguments[0]).node\
|
||||||
@@ -62,15 +61,15 @@ func validate(arguments: Array):
|
|||||||
.has_method(
|
.has_method(
|
||||||
arguments[2]
|
arguments[2]
|
||||||
):
|
):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"custom: invalid function",
|
self,
|
||||||
[
|
"[%s]: invalid function. Object with global id %s and node %s has no function called %s."
|
||||||
"Object with global id %s and node %s has no function %s" % [
|
% [
|
||||||
arguments[0],
|
get_command_name(),
|
||||||
arguments[1],
|
arguments[0],
|
||||||
arguments[2],
|
arguments[1],
|
||||||
]
|
arguments[2],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
@@ -84,7 +83,7 @@ func run(command_params: Array) -> int:
|
|||||||
# Global variables can be substituted into the command arguments by wrapping the global
|
# Global variables can be substituted into the command arguments by wrapping the global
|
||||||
# name in braces.
|
# name in braces.
|
||||||
for loop in command_params[3].size():
|
for loop in command_params[3].size():
|
||||||
command_params[3][loop] = escoria.esc_compiler.replace_globals(command_params[3][loop])
|
command_params[3][loop] = escoria.globals_manager.replace_globals(command_params[3][loop])
|
||||||
|
|
||||||
object.node.get_node(command_params[1]).call(
|
object.node.get_node(command_params[1]).call(
|
||||||
command_params[2],
|
command_params[2],
|
||||||
@@ -95,9 +94,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
get_command_name(),
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -27,11 +27,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.globals_manager.get_global(arguments[0]) is int:
|
if not escoria.globals_manager.get_global(arguments[0]) is int:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"dec_global: invalid global",
|
self,
|
||||||
[
|
"[%s]: invalid global. Global %s isn't an integer value."
|
||||||
"Global %s didn't have an integer value." % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -36,11 +36,10 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.room_terrain.current_active_navigation_instance.enabled = true
|
escoria.room_terrain.current_active_navigation_instance.enabled = true
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"EnableTerrainCommand.run: Can not find terrain node",
|
self,
|
||||||
[
|
"[%s]: Can not find terrain node. Terrain node %s could not be found."
|
||||||
"Terrain node %s could not be found" % name
|
% [get_command_name(), name]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_ERROR
|
return ESCExecution.RC_ERROR
|
||||||
|
|
||||||
|
|||||||
@@ -34,11 +34,9 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not arguments[0] in ["main", "pause"]:
|
if not arguments[0] in ["main", "pause"]:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"hide_menu: invalid menu ",
|
self,
|
||||||
[
|
"[%s]: menu %s is invalid." % [get_command_name(), arguments[0]]
|
||||||
"menu %s is invalid" % arguments[0]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -27,19 +27,17 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.globals_manager.has(arguments[0]):
|
if not escoria.globals_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"inc_global: invalid global",
|
self,
|
||||||
[
|
"[%s]: invalid global. Global %s does not exist."
|
||||||
"Global %s does not exist." % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not escoria.globals_manager.get_global(arguments[0]) is int:
|
if not escoria.globals_manager.get_global(arguments[0]) is int:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"inc_global: invalid global",
|
self,
|
||||||
[
|
"[%s]: invalid global. Global %s isn't an integer value."
|
||||||
"Global %s didn't have an integer value." % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -28,11 +28,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if arguments[0].begins_with("i/"):
|
if arguments[0].begins_with("i/"):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"inventory_add: invalid item name",
|
self,
|
||||||
[
|
"[%s]: invalid item name. Item name %s cannot start with 'i/'."
|
||||||
"Item name %s cannot start with 'i/'." % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -33,15 +33,17 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[1]):
|
if not escoria.object_manager.has(arguments[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"play_snd: invalid sound player",
|
self,
|
||||||
["Sound player %s not registered" % arguments[1]]
|
"[%s]: invalid sound player. Sound player %s not registered."
|
||||||
|
% [get_command_name(), arguments[1]]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not ResourceLoader.exists(arguments[0]):
|
if not ResourceLoader.exists(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"play_snd: invalid parameter",
|
self,
|
||||||
["File %s not found" % arguments[0]]
|
"[%s]: invalid parameter. File %s not found."
|
||||||
|
% [get_command_name(), arguments[0]]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
_snd_player = arguments[1]
|
_snd_player = arguments[1]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ func configure() -> ESCCommandArgumentDescriptor:
|
|||||||
# Run the command
|
# Run the command
|
||||||
func run(command_params: Array) -> int:
|
func run(command_params: Array) -> int:
|
||||||
# Replace the names of any globals in "{ }" with their value
|
# Replace the names of any globals in "{ }" with their value
|
||||||
print(escoria.esc_compiler.replace_globals(command_params[0]))
|
print(escoria.globals_manager.replace_globals(command_params[0]))
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,39 +31,31 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"queue_event.gd:validate",
|
self,
|
||||||
[
|
"Object with global id %s not found." % arguments[0]
|
||||||
"Object with global id %s not found" % arguments[0]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
var node = escoria.object_manager.get_object(
|
var node = escoria.object_manager.get_object(
|
||||||
arguments[0]
|
arguments[0]
|
||||||
).node
|
).node
|
||||||
if not "esc_script" in node or node.esc_script == "":
|
if not "esc_script" in node or node.esc_script == "":
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"queue_event.gd:validate",
|
self,
|
||||||
[
|
"Object with global id %s has no ESC script." % arguments[0]
|
||||||
"Object with global id %s has no ESC script" % arguments[0]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
var esc_script = escoria.esc_compiler.load_esc_file(node.esc_script)
|
var esc_script = escoria.esc_compiler.load_esc_file(node.esc_script)
|
||||||
if not arguments[1] in esc_script.events:
|
if not arguments[1] in esc_script.events:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"queue_event.gd:validate",
|
self,
|
||||||
[
|
"Event with name %s not found." % arguments[1]
|
||||||
"Event with name %s not found" % arguments[1]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if arguments[3] and not escoria.event_manager.is_channel_free(arguments[2]):
|
if arguments[3] and not escoria.event_manager.is_channel_free(arguments[2]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"queue_event.gd:validate",
|
self,
|
||||||
[
|
"The queue %s doesn't accept a new event." % arguments[2]
|
||||||
"The queue %s doesn't accept a new event." % arguments[2]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ func validate(arguments: Array) -> bool:
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not ResourceLoader.exists(arguments[0]):
|
if not ResourceLoader.exists(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"queue_resource: Invalid resource",
|
self,
|
||||||
["Resource %s was not found" % arguments[0]]
|
"[%s]: Invalid resource. Resource %s was not found."
|
||||||
|
% [get_command_name(), arguments[0]]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -64,21 +64,18 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"anim: invalid object",
|
self,
|
||||||
[
|
"[%s]: Invalid object: Object with global id %s not found."
|
||||||
"Object with global id %s not found." % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if ProjectSettings.get_setting("escoria/ui/default_dialog_type") == "" \
|
if ESCProjectSettingsManager.get_setting(ESCProjectSettingsManager.DEFAULT_DIALOG_TYPE) == "" \
|
||||||
and arguments[2] == "":
|
and arguments[2] == "":
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"say()",
|
self,
|
||||||
[
|
"[%s]: Project setting '%s' is not set. Please set a default dialog type."
|
||||||
"Project setting 'escoria/ui/default_dialog_type' is not set.",
|
% [get_command_name(), ESCProjectSettingsManager.DEFAULT_DIALOG_TYPE]
|
||||||
"Please set a default dialog type."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
@@ -91,17 +88,15 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.current_state = escoria.GAME_STATE.DIALOG
|
escoria.current_state = escoria.GAME_STATE.DIALOG
|
||||||
|
|
||||||
if !escoria.dialog_player:
|
if !escoria.dialog_player:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"No dialog player registered",
|
self,
|
||||||
[
|
"[%s]: No dialog player was registered and the say command was encountered."
|
||||||
"No dialog player was registered and the say command was" +
|
% get_command_name()
|
||||||
"encountered."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_ERROR
|
return ESCExecution.RC_ERROR
|
||||||
|
|
||||||
# Replace the names of any globals in "{ }" with their value
|
# Replace the names of any globals in "{ }" with their value
|
||||||
command_params[1] = escoria.esc_compiler.replace_globals(command_params[1])
|
command_params[1] = escoria.globals_manager.replace_globals(command_params[1])
|
||||||
|
|
||||||
escoria.dialog_player.say(
|
escoria.dialog_player.say(
|
||||||
command_params[0],
|
command_params[0],
|
||||||
@@ -115,9 +110,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"say",
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,23 +32,22 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[1]):
|
if not escoria.object_manager.has(arguments[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"sched_event: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object. Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[1]
|
% [get_command_name(), arguments[1]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
elif not escoria.object_manager.get_object(arguments[1]).events\
|
elif not escoria.object_manager.get_object(arguments[1]).events\
|
||||||
.has(arguments[2]):
|
.has(arguments[2]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"sched_event: invalid object event",
|
self,
|
||||||
[
|
"[%s]: invalid object event. Object with global id %s has no event %s."
|
||||||
"Object with global id %s has no event %s" % [
|
% [
|
||||||
|
get_command_name(),
|
||||||
arguments[1],
|
arguments[1],
|
||||||
arguments[2],
|
arguments[2],
|
||||||
]
|
]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -28,11 +28,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"set_active: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object. Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -33,11 +33,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"set_angle: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object. Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
@@ -60,4 +59,3 @@ func run(command_params: Array) -> int:
|
|||||||
func interrupt():
|
func interrupt():
|
||||||
# Do nothing
|
# Do nothing
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -27,19 +27,17 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"set_animations: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object. Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not ResourceLoader.exists(arguments[1]):
|
if not ResourceLoader.exists(arguments[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"set_animations: invalid animations",
|
self,
|
||||||
[
|
"[%s]: invalid animation resource. The animation resource %s was not found."
|
||||||
"The animation resource %s was not found" % arguments[1]
|
% [get_command_name(), arguments[1]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -27,11 +27,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"set_interactive: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object. Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -26,11 +26,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"set_speed: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object. Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -34,11 +34,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"set_state: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object. Object %s not found."
|
||||||
"Object %s not found." % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -31,11 +31,9 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not arguments[0] in ["main", "pause"]:
|
if not arguments[0] in ["main", "pause"]:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"show_menu: invalid menu ",
|
self,
|
||||||
[
|
"[%s]: menu %s is invalid." % [get_command_name(), arguments[0]]
|
||||||
"menu %s is invalid" % arguments[0]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -35,19 +35,17 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"slide: invalid first object",
|
self,
|
||||||
[
|
"[%s]: invalid first object. Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not escoria.object_manager.has(arguments[1]):
|
if not escoria.object_manager.has(arguments[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"slide: invalid second object",
|
self,
|
||||||
[
|
"[%s]: invalid second object. Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[1]
|
% [get_command_name(), arguments[1]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
@@ -80,6 +78,8 @@ func _slide_object(
|
|||||||
|
|
||||||
var tween = Tween.new()
|
var tween = Tween.new()
|
||||||
(escoria.main as Node).add_child(tween)
|
(escoria.main as Node).add_child(tween)
|
||||||
|
|
||||||
|
tween.connect("tween_completed", self, "_on_tween_completed")
|
||||||
|
|
||||||
var duration = source.node.position.distance_to(
|
var duration = source.node.position.distance_to(
|
||||||
destination.node.position
|
destination.node.position
|
||||||
@@ -115,3 +115,7 @@ func run(command_params: Array) -> int:
|
|||||||
func interrupt():
|
func interrupt():
|
||||||
for tween in _tweens:
|
for tween in _tweens:
|
||||||
tween.stop_all()
|
tween.stop_all()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_tween_completed(tween: Tween):
|
||||||
|
tween.queue_free()
|
||||||
|
|||||||
@@ -31,27 +31,24 @@ func validate(arguments: Array):
|
|||||||
|
|
||||||
if arguments[0].empty() \
|
if arguments[0].empty() \
|
||||||
or arguments[0] in escoria.object_manager.RESERVED_OBJECTS:
|
or arguments[0] in escoria.object_manager.RESERVED_OBJECTS:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"spawn: invalid global_id",
|
self,
|
||||||
[
|
"[%s]: global_id (%s) is invalid. The global_id was either empty or is reserved."
|
||||||
"global_id %s is invalid" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not ResourceLoader.exists(arguments[1]):
|
if not ResourceLoader.exists(arguments[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"spawn: invalid scene path",
|
self,
|
||||||
[
|
"[%s]: Invalid scene path: %s not found."
|
||||||
"Scene with path %s not found" % arguments[1]
|
% [get_command_name(), arguments[1]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if arguments[3] and not escoria.object_manager.has(arguments[3]):
|
if arguments[3] and not escoria.object_manager.has(arguments[3]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"spawn: invalid object",
|
self,
|
||||||
[
|
"[%s]: invalid object: Object with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[3]
|
% [get_command_name(), arguments[3]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
@@ -83,11 +80,10 @@ func run(command_params: Array) -> int:
|
|||||||
command_params[2]
|
command_params[2]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"spawn: Invalid scene",
|
self,
|
||||||
[
|
"[%s]: Invalid scene. Failed to load scene %s."
|
||||||
"Failed loading scene %s" % command_params[1]
|
% [get_command_name(), command_params[1]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"stop_snd: invalid sound player",
|
self,
|
||||||
["Sound player %s not registered" % arguments[0]]
|
"[%s]: invalid sound player. Sound player %s not registered."
|
||||||
|
% [get_command_name(), arguments[0]]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
_snd_player = arguments[0]
|
_snd_player = arguments[0]
|
||||||
|
|||||||
@@ -28,19 +28,17 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"teleport: invalid first object",
|
self,
|
||||||
[
|
"[%s]: invalid first object. Object to teleport with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not escoria.object_manager.has(arguments[1]):
|
if not escoria.object_manager.has(arguments[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"teleport: invalid second object",
|
self,
|
||||||
[
|
"[%s]: invalid second object. Destination location to teleport to with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[1]
|
% [get_command_name(), arguments[1]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -28,11 +28,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"teleport_pos: invalid first object",
|
self,
|
||||||
[
|
"[%s]: invalid first object. Object to teleport with global id %s not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -30,19 +30,18 @@ func validate(arguments: Array):
|
|||||||
|
|
||||||
if not escoria.main.scene_transition.has_transition(arguments[0]) \
|
if not escoria.main.scene_transition.has_transition(arguments[0]) \
|
||||||
and not arguments[0].empty():
|
and not arguments[0].empty():
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"transition: argument invalid",
|
self,
|
||||||
[
|
"[%s]: argument invalid. Transition with name '%s' doesn't exist."
|
||||||
"transition with name '%s' doesn't exist" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not arguments[1] in ["in", "out"]:
|
if not arguments[1] in ["in", "out"]:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"transition: argument invalid",
|
self,
|
||||||
[
|
"[%s]: argument invalid" +
|
||||||
"'in' or 'out' expected, but got '%s'" % arguments[1]
|
"Transition type 'in' or 'out' expected, but '%s' was provided."
|
||||||
]
|
% [get_command_name(), arguments[1]]
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
@@ -58,19 +57,27 @@ func run(command_params: Array) -> int:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if transition_id == ESCTransitionPlayer.TRANSITION_ID_INSTANT:
|
if transition_id == ESCTransitionPlayer.TRANSITION_ID_INSTANT:
|
||||||
escoria.logger.debug("Performing instant transition.")
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Performing instant transition."
|
||||||
|
)
|
||||||
escoria.main.scene_transition.reset_shader_cutoff()
|
escoria.main.scene_transition.reset_shader_cutoff()
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
escoria.logger.debug("Starting transition #%s [%s, %s]"
|
escoria.logger.debug(
|
||||||
% [transition_id, command_params[0], command_params[1]])
|
self,
|
||||||
|
"Starting transition #%s [%s, %s]."
|
||||||
|
% [transition_id, command_params[0], command_params[1]]
|
||||||
|
)
|
||||||
while yield(
|
while yield(
|
||||||
escoria.main.scene_transition,
|
escoria.main.scene_transition,
|
||||||
"transition_done"
|
"transition_done"
|
||||||
) != transition_id:
|
) != transition_id:
|
||||||
pass
|
pass
|
||||||
escoria.logger.debug("Ending transition #%s [%s, %s]"
|
escoria.logger.debug(
|
||||||
% [transition_id, command_params[0], command_params[1]])
|
self,
|
||||||
|
"Ending transition #%s [%s, %s]."
|
||||||
|
% [transition_id, command_params[0], command_params[1]])
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,19 +35,17 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"turn_to: invalid object",
|
self,
|
||||||
[
|
"[%s]: The object to turn with global id %s was not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not escoria.object_manager.has(arguments[1]):
|
if not escoria.object_manager.has(arguments[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"turn_to: invalid target object",
|
self,
|
||||||
[
|
"[%s]: The object to turn towards with global id %s was not found."
|
||||||
"Object with global id %s not found" % arguments[1]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
@@ -65,9 +63,7 @@ func run(command_params: Array) -> int:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"turn_to",
|
self,
|
||||||
[
|
"[%s] interrupt() function not implemented." % get_command_name()
|
||||||
"Interrupt() function not implemented"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -30,12 +30,10 @@ func validate(arguments: Array):
|
|||||||
|
|
||||||
# We can't wait for 0 or fewer seconds, now, can we?
|
# We can't wait for 0 or fewer seconds, now, can we?
|
||||||
if arguments[0] <= 0.0:
|
if arguments[0] <= 0.0:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"wait: argument invalid",
|
self,
|
||||||
[
|
"[%s]: argument invalid. %s is an invalid amount of time to wait (must be positive)."
|
||||||
"%ss is an invalid amount of time to wait." % arguments[0],
|
% [get_command_name(), arguments[0]]
|
||||||
"Time to wait must be positive."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|||||||
@@ -38,19 +38,17 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"walk: invalid first object",
|
self,
|
||||||
[
|
"[%s]: invalid first object. The object with global id %s to make walk was not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not escoria.object_manager.has(arguments[1]):
|
if not escoria.object_manager.has(arguments[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"walk: invalid second object",
|
self,
|
||||||
[
|
": invalid second object. The object to walk to with global id %s was not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[1]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|||||||
@@ -38,19 +38,17 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"walk_block: invalid first object",
|
self,
|
||||||
[
|
"[%s]: invalid first object. The object to make walk with global id %s was not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if not escoria.object_manager.has(arguments[1]):
|
if not escoria.object_manager.has(arguments[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"walk_block: invalid second object",
|
self,
|
||||||
[
|
"[%s]: invalid second object. The object to walk to with global id %s was not found."
|
||||||
"Object with global id %s not found" % arguments[1]
|
% [get_command_name(), arguments[1]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"walk_to_pos: invalid first object",
|
self,
|
||||||
[
|
"[%s]: invalid first object. The object to make walk with global id %s was not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,10 @@ func validate(arguments: Array):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
if not escoria.object_manager.has(arguments[0]):
|
if not escoria.object_manager.has(arguments[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"walk_to_pos_block: invalid first object",
|
self,
|
||||||
[
|
"[%s]: invalid first object. The object to make walk with global id %s was not found."
|
||||||
"Object with global id %s not found" % arguments[0]
|
% [get_command_name(), arguments[0]]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Manages currently carried out actions
|
# Manages currently carried out actions
|
||||||
extends Object
|
extends Resource
|
||||||
class_name ESCActionManager
|
class_name ESCActionManager
|
||||||
|
|
||||||
|
|
||||||
@@ -90,12 +90,10 @@ func do(action: int, params: Array = [], can_interrupt: bool = false) -> void:
|
|||||||
|
|
||||||
# Check moving object.
|
# Check moving object.
|
||||||
if not escoria.object_manager.has(params[0]):
|
if not escoria.object_manager.has(params[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_action_manager.gd:do()",
|
self,
|
||||||
[
|
"Walk action requested for nonexisting object: %s."
|
||||||
"Walk action requested on nonexisting " + \
|
% params[0]
|
||||||
"object: %s " % params[0]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -104,12 +102,10 @@ func do(action: int, params: Array = [], can_interrupt: bool = false) -> void:
|
|||||||
|
|
||||||
if params[1] is String:
|
if params[1] is String:
|
||||||
if not escoria.object_manager.has(params[1]):
|
if not escoria.object_manager.has(params[1]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_action_manager.gd:do()",
|
self,
|
||||||
[
|
"Walk action requested to nonexisting destination object: %s."
|
||||||
"Walk action requested to nonexisting " + \
|
% params[1]
|
||||||
"object: %s " % params[1]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -122,8 +118,8 @@ func do(action: int, params: Array = [], can_interrupt: bool = false) -> void:
|
|||||||
ACTION.ITEM_LEFT_CLICK:
|
ACTION.ITEM_LEFT_CLICK:
|
||||||
if params[0] is String:
|
if params[0] is String:
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"esc_action_manager.do(): item_left_click on item ",
|
self,
|
||||||
[params[0]]
|
"item_left_click on item %s." % params[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if can_interrupt:
|
if can_interrupt:
|
||||||
@@ -135,8 +131,8 @@ func do(action: int, params: Array = [], can_interrupt: bool = false) -> void:
|
|||||||
ACTION.ITEM_RIGHT_CLICK:
|
ACTION.ITEM_RIGHT_CLICK:
|
||||||
if params[0] is String:
|
if params[0] is String:
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"esc_action_manager.do(): item_right_click on item ",
|
self,
|
||||||
[params[0]]
|
"item_right_click on item %s." % params[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if can_interrupt:
|
if can_interrupt:
|
||||||
@@ -149,10 +145,13 @@ func do(action: int, params: Array = [], can_interrupt: bool = false) -> void:
|
|||||||
var trigger_id = params[0]
|
var trigger_id = params[0]
|
||||||
var object_id = params[1]
|
var object_id = params[1]
|
||||||
var trigger_in_verb = params[2]
|
var trigger_in_verb = params[2]
|
||||||
escoria.logger.info("esc_action_manager.do(): trigger_in %s by %s" % [
|
escoria.logger.info(
|
||||||
trigger_id,
|
self,
|
||||||
object_id
|
"trigger_in on trigger %s activated by %s." % [
|
||||||
])
|
trigger_id,
|
||||||
|
object_id
|
||||||
|
]
|
||||||
|
)
|
||||||
escoria.event_manager.queue_event(
|
escoria.event_manager.queue_event(
|
||||||
escoria.object_manager.get_object(trigger_id).events[
|
escoria.object_manager.get_object(trigger_id).events[
|
||||||
trigger_in_verb
|
trigger_in_verb
|
||||||
@@ -163,10 +162,13 @@ func do(action: int, params: Array = [], can_interrupt: bool = false) -> void:
|
|||||||
var trigger_id = params[0]
|
var trigger_id = params[0]
|
||||||
var object_id = params[1]
|
var object_id = params[1]
|
||||||
var trigger_out_verb = params[2]
|
var trigger_out_verb = params[2]
|
||||||
escoria.logger.info("esc_action_manager.do(): trigger_out %s by %s" % [
|
escoria.logger.info(
|
||||||
trigger_id,
|
self,
|
||||||
object_id
|
"trigger_out on trigger %s activated by %s." % [
|
||||||
])
|
trigger_id,
|
||||||
|
object_id
|
||||||
|
]
|
||||||
|
)
|
||||||
escoria.event_manager.queue_event(
|
escoria.event_manager.queue_event(
|
||||||
escoria.object_manager.get_object(trigger_id).events[
|
escoria.object_manager.get_object(trigger_id).events[
|
||||||
trigger_out_verb
|
trigger_out_verb
|
||||||
@@ -174,8 +176,10 @@ func do(action: int, params: Array = [], can_interrupt: bool = false) -> void:
|
|||||||
)
|
)
|
||||||
|
|
||||||
_:
|
_:
|
||||||
escoria.logger.report_warnings("esc_action_manager.gd:do()",
|
escoria.logger.warn(
|
||||||
["Action received:", action, "with params ", params])
|
self,
|
||||||
|
"Action received: %s with params %s.", [action, params]
|
||||||
|
)
|
||||||
elif escoria.current_state == escoria.GAME_STATE.WAIT:
|
elif escoria.current_state == escoria.GAME_STATE.WAIT:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -237,7 +241,10 @@ func _activate(
|
|||||||
target: ESCObject,
|
target: ESCObject,
|
||||||
combine_with: ESCObject = null
|
combine_with: ESCObject = null
|
||||||
) -> int:
|
) -> int:
|
||||||
escoria.logger.info("Activated action %s on %s" % [action, target])
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Activated action %s on %s." % [action, target]
|
||||||
|
)
|
||||||
|
|
||||||
# If we're using an action which item requires to combine
|
# If we're using an action which item requires to combine
|
||||||
if target.node is ESCItem\
|
if target.node is ESCItem\
|
||||||
@@ -314,16 +321,16 @@ func _activate(
|
|||||||
("Reason: %s's item interaction " +\
|
("Reason: %s's item interaction " +\
|
||||||
"is one-way.") % combine_with.global_id
|
"is one-way.") % combine_with.global_id
|
||||||
)
|
)
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCActionManager.activate: Invalid action",
|
self,
|
||||||
errors
|
"Invalid action" + str(errors)
|
||||||
)
|
)
|
||||||
emit_signal("action_finished")
|
emit_signal("action_finished")
|
||||||
return ESCExecution.RC_ERROR
|
return ESCExecution.RC_ERROR
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCActionManager.activate: Invalid action on item",
|
self,
|
||||||
[
|
"Invalid action on item: " +
|
||||||
(
|
(
|
||||||
"Trying to combine object %s with %s, "+
|
"Trying to combine object %s with %s, "+
|
||||||
"but %s is not in inventory."
|
"but %s is not in inventory."
|
||||||
@@ -332,7 +339,6 @@ func _activate(
|
|||||||
combine_with.global_id,
|
combine_with.global_id,
|
||||||
combine_with.global_id
|
combine_with.global_id
|
||||||
]
|
]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
emit_signal("action_finished")
|
emit_signal("action_finished")
|
||||||
return ESCExecution.RC_ERROR
|
return ESCExecution.RC_ERROR
|
||||||
@@ -344,16 +350,15 @@ func _activate(
|
|||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCActionManager.activate: Invalid action on item",
|
self,
|
||||||
|
"Invalid action on item" +
|
||||||
|
"Trying to run action %s on object %s, " %
|
||||||
[
|
[
|
||||||
"Trying to run %s on object %s, " %
|
action,
|
||||||
[
|
target.node.global_id
|
||||||
action,
|
|
||||||
target.node.global_id
|
|
||||||
]
|
|
||||||
+ "but item must be in inventory."
|
|
||||||
]
|
]
|
||||||
|
+ "but item must be in inventory."
|
||||||
)
|
)
|
||||||
|
|
||||||
if target.events.has(action):
|
if target.events.has(action):
|
||||||
@@ -372,14 +377,13 @@ func _activate(
|
|||||||
emit_signal("action_finished")
|
emit_signal("action_finished")
|
||||||
return event_returned[0]
|
return event_returned[0]
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCActionManager.activate: Invalid action",
|
self,
|
||||||
[
|
"Invalid action: " +
|
||||||
"Event for action %s on object %s not found." % [
|
"Event for action %s on object %s not found." % [
|
||||||
action,
|
action,
|
||||||
target.global_id
|
target.global_id
|
||||||
]
|
]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
emit_signal("action_finished")
|
emit_signal("action_finished")
|
||||||
return ESCExecution.RC_ERROR
|
return ESCExecution.RC_ERROR
|
||||||
@@ -428,12 +432,10 @@ func perform_walk(
|
|||||||
moving_obj.node.walk_to(target_position, walk_context)
|
moving_obj.node.walk_to(target_position, walk_context)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_controller.gd:perform_walk()",
|
self,
|
||||||
[
|
"Function expected either a Vector2 or ESCObject type " + \
|
||||||
"Function expected either a Vector2 or ESCObject type " + \
|
"for destination parameter. Destination provided was: %s." % destination
|
||||||
"for destination parameter. Actual was: %s " % destination
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -472,7 +474,10 @@ func perform_inputevent_on_object(
|
|||||||
In this case, perform the default_action on the item.
|
In this case, perform the default_action on the item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
escoria.logger.info("%s left-clicked with event " % obj.global_id, [event])
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"%s left-clicked with event %s." % [obj.global_id, event]
|
||||||
|
)
|
||||||
|
|
||||||
var event_flags = 0
|
var event_flags = 0
|
||||||
var has_current_action: bool = false
|
var has_current_action: bool = false
|
||||||
@@ -620,8 +625,10 @@ func _walk_towards_object(
|
|||||||
var dont_interact: bool = false
|
var dont_interact: bool = false
|
||||||
|
|
||||||
if obj == null || obj.node == null:
|
if obj == null || obj.node == null:
|
||||||
escoria.logger.report_errors("esc_action_manager.gd:_walk_towards_object",
|
escoria.logger.error(
|
||||||
["obj or obj.node not populated."])
|
self,
|
||||||
|
"walk_towards_object error. obj or obj.node not populated."
|
||||||
|
)
|
||||||
var interact_position = obj.node.get_interact_position()
|
var interact_position = obj.node.get_interact_position()
|
||||||
# If clicked object is interactive, get destination position from it.
|
# If clicked object is interactive, get destination position from it.
|
||||||
if escoria.object_manager.get_object(obj.global_id).interactive:
|
if escoria.object_manager.get_object(obj.global_id).interactive:
|
||||||
@@ -645,7 +652,10 @@ func _walk_towards_object(
|
|||||||
escoria.main.current_scene.player.walk_to(destination_position,
|
escoria.main.current_scene.player.walk_to(destination_position,
|
||||||
walk_context)
|
walk_context)
|
||||||
|
|
||||||
escoria.logger.debug("Player walking to destination. Yielding.")
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Player walking to destination. Yielding."
|
||||||
|
)
|
||||||
|
|
||||||
# Wait for the player to arrive before continuing with action.
|
# Wait for the player to arrive before continuing with action.
|
||||||
var context: ESCWalkContext = yield(
|
var context: ESCWalkContext = yield(
|
||||||
@@ -654,11 +664,16 @@ func _walk_towards_object(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if context.target_object != obj:
|
if context.target_object != obj:
|
||||||
escoria.logger.debug("Original walk context target does not match " \
|
escoria.logger.debug(
|
||||||
+ "yielded walk context. Likely interrutped walk.")
|
self,
|
||||||
|
"Original walk context target does not match " \
|
||||||
|
+ "yielded walk context. Likely interrutped walk.")
|
||||||
return
|
return
|
||||||
|
|
||||||
escoria.logger.info("Context arrived: %s" % context)
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Context arrived: %s." % context
|
||||||
|
)
|
||||||
|
|
||||||
# Confirm that reached item was the one user clicked in the first place.
|
# Confirm that reached item was the one user clicked in the first place.
|
||||||
# Don't interact if that is not the case.
|
# Don't interact if that is not the case.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# A registry of ESC command objects
|
# A registry of ESC command objects
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCCommandRegistry
|
class_name ESCCommandRegistry
|
||||||
|
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ var registry: Dictionary = {}
|
|||||||
# - command_name: Name of command to load
|
# - command_name: Name of command to load
|
||||||
# **Returns** The command object
|
# **Returns** The command object
|
||||||
func load_command(command_name: String) -> ESCBaseCommand:
|
func load_command(command_name: String) -> ESCBaseCommand:
|
||||||
for command_directory in escoria.project_settings_manager.get_setting(
|
for command_directory in ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.COMMAND_DIRECTORIES
|
ESCProjectSettingsManager.COMMAND_DIRECTORIES
|
||||||
):
|
):
|
||||||
if ResourceLoader.exists("%s/%s.gd" % [command_directory, command_name]):
|
if ResourceLoader.exists("%s/%s.gd" % [command_directory, command_name]):
|
||||||
registry[command_name] = load(
|
registry[command_name] = load(
|
||||||
@@ -26,12 +26,10 @@ func load_command(command_name: String) -> ESCBaseCommand:
|
|||||||
).new()
|
).new()
|
||||||
return registry[command_name]
|
return registry[command_name]
|
||||||
|
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCCommandRegistry.load_command: Command not found",
|
self,
|
||||||
[
|
"No command class could be found for command %s."
|
||||||
"No command class could be found for command %s" %
|
% command_name
|
||||||
command_name
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Compiler of the ESC language
|
# Compiler of the ESC language
|
||||||
extends Object
|
extends Resource
|
||||||
class_name ESCCompiler
|
class_name ESCCompiler
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ var _current_indent = 0
|
|||||||
|
|
||||||
func _init():
|
func _init():
|
||||||
# Assure command list preference
|
# Assure command list preference
|
||||||
# (we use ProjectSettings instead of escoria.project_settings_manager
|
# (we use ProjectSettings instead of ESCProjectSettingsManager
|
||||||
# here because this is called from escoria._init())
|
# here because this is called from escoria._init())
|
||||||
if not ProjectSettings.has_setting(COMMAND_DIRECTORIES):
|
if not ProjectSettings.has_setting(COMMAND_DIRECTORIES):
|
||||||
ProjectSettings.set_setting(COMMAND_DIRECTORIES, [
|
ProjectSettings.set_setting(COMMAND_DIRECTORIES, [
|
||||||
@@ -90,7 +90,7 @@ func _init():
|
|||||||
|
|
||||||
# Load an ESC file from a file resource
|
# Load an ESC file from a file resource
|
||||||
func load_esc_file(path: String) -> ESCScript:
|
func load_esc_file(path: String) -> ESCScript:
|
||||||
escoria.logger.debug("Parsing file %s" % path)
|
escoria.logger.debug(self, "Parsing file %s." % path)
|
||||||
if File.new().file_exists(path):
|
if File.new().file_exists(path):
|
||||||
var file = File.new()
|
var file = File.new()
|
||||||
file.open(path, File.READ)
|
file.open(path, File.READ)
|
||||||
@@ -99,12 +99,9 @@ func load_esc_file(path: String) -> ESCScript:
|
|||||||
lines.append(file.get_line())
|
lines.append(file.get_line())
|
||||||
return self.compile(lines, path)
|
return self.compile(lines, path)
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
path,
|
self,
|
||||||
[
|
"Can not find ESC file: file %s could not be found." % path
|
||||||
"Can not find ESC file",
|
|
||||||
"File %s could not be found" % path
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
@@ -128,20 +125,29 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
|
|
||||||
while lines.size() > 0:
|
while lines.size() > 0:
|
||||||
var line = lines.pop_front().strip_edges(false, true)
|
var line = lines.pop_front().strip_edges(false, true)
|
||||||
escoria.logger.trace("Parsing line %s" % line)
|
escoria.logger.trace(
|
||||||
|
self,
|
||||||
|
"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.trace("Line is empty or a comment. Skipping.")
|
escoria.logger.trace(
|
||||||
|
self,
|
||||||
|
"Line is empty or a comment. Skipping."
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
var indent = \
|
var indent = \
|
||||||
escoria.utils.get_re_group(
|
ESCUtils.get_re_group(
|
||||||
_indent_regex.search(line),
|
_indent_regex.search(line),
|
||||||
INDENT_REGEX_GROUP
|
INDENT_REGEX_GROUP
|
||||||
).length()
|
).length()
|
||||||
|
|
||||||
if _event_regex.search(line):
|
if _event_regex.search(line):
|
||||||
var event = ESCEvent.new(line)
|
var event = ESCEvent.new(line)
|
||||||
escoria.logger.trace("Line is the event %s" % event.name)
|
escoria.logger.trace(
|
||||||
|
self,
|
||||||
|
"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()
|
||||||
@@ -152,14 +158,18 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
break
|
break
|
||||||
if event_lines.size() > 0:
|
if event_lines.size() > 0:
|
||||||
escoria.logger.trace(
|
escoria.logger.trace(
|
||||||
"Compiling the next %d lines into the event" % \
|
self,
|
||||||
|
"Compiling the next %d lines into the event." % \
|
||||||
event_lines.size()
|
event_lines.size()
|
||||||
)
|
)
|
||||||
event.statements = self._compile(event_lines, path)
|
event.statements = self._compile(event_lines, path)
|
||||||
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.trace("Line is a group")
|
escoria.logger.trace(
|
||||||
|
self,
|
||||||
|
"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()
|
||||||
@@ -167,7 +177,7 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
_empty_regex.search(next_line):
|
_empty_regex.search(next_line):
|
||||||
continue
|
continue
|
||||||
var next_line_indent = \
|
var next_line_indent = \
|
||||||
escoria.utils.get_re_group(
|
ESCUtils.get_re_group(
|
||||||
_indent_regex.search(next_line),
|
_indent_regex.search(next_line),
|
||||||
INDENT_REGEX_GROUP
|
INDENT_REGEX_GROUP
|
||||||
).length()
|
).length()
|
||||||
@@ -178,7 +188,8 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
break
|
break
|
||||||
if group_lines.size() > 0:
|
if group_lines.size() > 0:
|
||||||
escoria.logger.trace(
|
escoria.logger.trace(
|
||||||
"Compiling the next %d lines into the group" % \
|
self,
|
||||||
|
"Compiling the next %d lines into the group." % \
|
||||||
group_lines.size()
|
group_lines.size()
|
||||||
)
|
)
|
||||||
group.statements = self._compile(group_lines, path)
|
group.statements = self._compile(group_lines, path)
|
||||||
@@ -186,7 +197,10 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
elif _dialog_regex.search(line):
|
elif _dialog_regex.search(line):
|
||||||
var dialog = ESCDialog.new()
|
var dialog = ESCDialog.new()
|
||||||
dialog.load_string(line)
|
dialog.load_string(line)
|
||||||
escoria.logger.trace("Line is a dialog")
|
escoria.logger.trace(
|
||||||
|
self,
|
||||||
|
"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()
|
||||||
@@ -195,7 +209,7 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
continue
|
continue
|
||||||
var end_line = _dialog_end_regex.search(next_line)
|
var end_line = _dialog_end_regex.search(next_line)
|
||||||
if end_line and \
|
if end_line and \
|
||||||
escoria.utils.get_re_group(
|
ESCUtils.get_re_group(
|
||||||
end_line,
|
end_line,
|
||||||
INDENT_REGEX_GROUP
|
INDENT_REGEX_GROUP
|
||||||
).length() == indent:
|
).length() == indent:
|
||||||
@@ -204,7 +218,8 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
dialog_lines.append(next_line)
|
dialog_lines.append(next_line)
|
||||||
if dialog_lines.size() > 0:
|
if dialog_lines.size() > 0:
|
||||||
escoria.logger.trace(
|
escoria.logger.trace(
|
||||||
"Compiling the next %d lines into the dialog" % \
|
self,
|
||||||
|
"Compiling the next %d lines into the dialog." % \
|
||||||
dialog_lines.size()
|
dialog_lines.size()
|
||||||
)
|
)
|
||||||
dialog.options = self._compile(dialog_lines, path)
|
dialog.options = self._compile(dialog_lines, path)
|
||||||
@@ -215,7 +230,8 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
var dialog_option = ESCDialogOption.new()
|
var dialog_option = ESCDialogOption.new()
|
||||||
dialog_option.load_string(line)
|
dialog_option.load_string(line)
|
||||||
escoria.logger.trace(
|
escoria.logger.trace(
|
||||||
"Line is the dialog option %s" % \
|
self,
|
||||||
|
"Line is the dialog option %s." % \
|
||||||
dialog_option.option
|
dialog_option.option
|
||||||
)
|
)
|
||||||
var dialog_option_lines = []
|
var dialog_option_lines = []
|
||||||
@@ -225,7 +241,7 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
_empty_regex.search(next_line):
|
_empty_regex.search(next_line):
|
||||||
continue
|
continue
|
||||||
var next_line_indent = \
|
var next_line_indent = \
|
||||||
escoria.utils.get_re_group(
|
ESCUtils.get_re_group(
|
||||||
_indent_regex.search(next_line),
|
_indent_regex.search(next_line),
|
||||||
INDENT_REGEX_GROUP
|
INDENT_REGEX_GROUP
|
||||||
).length()
|
).length()
|
||||||
@@ -236,8 +252,9 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
break
|
break
|
||||||
if dialog_option_lines.size() > 0:
|
if dialog_option_lines.size() > 0:
|
||||||
escoria.logger.trace(
|
escoria.logger.trace(
|
||||||
"Compiling the next %d lines into the event" % \
|
self,
|
||||||
dialog_option_lines.size()
|
"Compiling the next %d lines into the event."
|
||||||
|
% dialog_option_lines.size()
|
||||||
)
|
)
|
||||||
dialog_option.statements = self._compile(dialog_option_lines, path)
|
dialog_option.statements = self._compile(dialog_option_lines, path)
|
||||||
returned.append(dialog_option)
|
returned.append(dialog_option)
|
||||||
@@ -246,34 +263,19 @@ func _compile(lines: Array, path: String = "") -> Array:
|
|||||||
if command.command_exists():
|
if command.command_exists():
|
||||||
returned.append(command)
|
returned.append(command)
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
path,
|
self,
|
||||||
[
|
"Command \"%s\" cannot be found under folder %s.\nPlease confirm setting \"%s\" is set to the folder where ESC commands are stored."
|
||||||
"Invalid command detected: %s" % command.name,
|
% [
|
||||||
"Command implementation not found in any command directory"
|
command.name,
|
||||||
]
|
ProjectSettings.get_setting(COMMAND_DIRECTORIES),
|
||||||
|
ESCProjectSettingsManager.COMMAND_DIRECTORIES
|
||||||
|
]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
path,
|
self,
|
||||||
[
|
"Invalid ESC line detected.\nLine couldn't be compiled: %s."
|
||||||
"Invalid ESC line detected",
|
% line
|
||||||
"Line couldn't be compiled: %s" % line
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return returned
|
return returned
|
||||||
|
|
||||||
# Look to see if any globals (names in braces) should be interpreted
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * string: Text to log
|
|
||||||
func replace_globals(string: String) -> String:
|
|
||||||
for result in _globals_regex.search_all(string):
|
|
||||||
var globresult = escoria.globals_manager.get_global(
|
|
||||||
str(result.get_string())
|
|
||||||
)
|
|
||||||
string = string.replace(
|
|
||||||
"{" + result.get_string() + "}", str(globresult)
|
|
||||||
)
|
|
||||||
return string
|
|
||||||
|
|||||||
@@ -88,16 +88,14 @@ func _process(delta: float) -> void:
|
|||||||
_running_events[channel_name] = \
|
_running_events[channel_name] = \
|
||||||
events_queue[channel_name].pop_front()
|
events_queue[channel_name].pop_front()
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"esc_event_manager",
|
self,
|
||||||
[
|
"Popping event '%s' from background queue %s " % [
|
||||||
"Popping event '%s' from background queue %s" % [
|
_running_events[channel_name].name,
|
||||||
_running_events[channel_name].name,
|
channel_name,
|
||||||
channel_name,
|
] +
|
||||||
],
|
"to source %s." % _running_events[channel_name].source \
|
||||||
"from source %s" % _running_events[channel_name].source \
|
if not _running_events[channel_name].source.empty()
|
||||||
if not _running_events[channel_name].source.empty()
|
else "(unknown)"
|
||||||
else "(unknown)",
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
if not _running_events[channel_name].is_connected(
|
if not _running_events[channel_name].is_connected(
|
||||||
"finished", self, "_on_event_finished"
|
"finished", self, "_on_event_finished"
|
||||||
@@ -174,28 +172,22 @@ func queue_event_from_esc(script_object: ESCScript, event: String,
|
|||||||
return ESCExecution.RC_WONT_QUEUE
|
return ESCExecution.RC_WONT_QUEUE
|
||||||
|
|
||||||
if channel == CHANNEL_FRONT:
|
if channel == CHANNEL_FRONT:
|
||||||
escoria.event_manager.queue_event(script_object.events[event])
|
queue_event(script_object.events[event])
|
||||||
else:
|
else:
|
||||||
escoria.event_manager.queue_background_event(
|
queue_background_event(
|
||||||
channel,
|
channel,
|
||||||
script_object.events[event]
|
script_object.events[event]
|
||||||
)
|
)
|
||||||
if block:
|
if block:
|
||||||
if channel == CHANNEL_FRONT:
|
if channel == CHANNEL_FRONT:
|
||||||
var rc = yield(escoria.event_manager, "event_finished")
|
var rc = yield(self, "event_finished")
|
||||||
while rc[1] != event:
|
while rc[1] != event:
|
||||||
rc = yield(escoria.event_manager, "event_finished")
|
rc = yield(self, "event_finished")
|
||||||
return rc
|
return rc
|
||||||
else:
|
else:
|
||||||
var rc = yield(
|
var rc = yield(self, "background_event_finished")
|
||||||
escoria.event_manager,
|
|
||||||
"background_event_finished"
|
|
||||||
)
|
|
||||||
while rc[1] != event and rc[2] != channel:
|
while rc[1] != event and rc[2] != channel:
|
||||||
rc = yield(
|
rc = yield(self, "background_event_finished")
|
||||||
escoria.event_manager,
|
|
||||||
"background_event_finished"
|
|
||||||
)
|
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
@@ -208,6 +200,7 @@ func queue_event_from_esc(script_object: ESCScript, event: String,
|
|||||||
func queue_event(event: ESCEvent, force: bool = false) -> void:
|
func queue_event(event: ESCEvent, force: bool = false) -> void:
|
||||||
if _changing_scene and not force:
|
if _changing_scene and not force:
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
"Changing scenes. Won't queue event '%s'." % event.name
|
"Changing scenes. Won't queue event '%s'." % event.name
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@@ -222,18 +215,22 @@ func queue_event(event: ESCEvent, force: bool = false) -> void:
|
|||||||
var message = "Event '%s' is already the most-recently queued event in channel '%s'." + \
|
var message = "Event '%s' is already the most-recently queued event in channel '%s'." + \
|
||||||
" Won't be queued again."
|
" Won't be queued again."
|
||||||
|
|
||||||
escoria.logger.debug(message % [event.name, CHANNEL_FRONT])
|
escoria.logger.debug(self, message % [event.name, CHANNEL_FRONT])
|
||||||
return
|
return
|
||||||
elif _is_event_running(event, CHANNEL_FRONT):
|
elif _is_event_running(event, CHANNEL_FRONT):
|
||||||
# Don't queue the same event if it's already running.
|
# Don't queue the same event if it's already running.
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
"Event %s already running in channel '%s'. Won't be queued."
|
"Event %s already running in channel '%s'. Won't be queued."
|
||||||
% [event.name, CHANNEL_FRONT]
|
% [event.name, CHANNEL_FRONT]
|
||||||
)
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
escoria.logger.debug("Queueing %s in channel %s." % [event.name, CHANNEL_FRONT])
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Queueing event %s in channel %s." % [event.name, CHANNEL_FRONT]
|
||||||
|
)
|
||||||
self.events_queue[CHANNEL_FRONT].append(event)
|
self.events_queue[CHANNEL_FRONT].append(event)
|
||||||
|
|
||||||
|
|
||||||
@@ -266,11 +263,12 @@ func queue_background_event(channel_name: String, event: ESCEvent) -> void:
|
|||||||
var message = "Event '%s' is already the most-recently queued event in channel '%s'." + \
|
var message = "Event '%s' is already the most-recently queued event in channel '%s'." + \
|
||||||
" Won't be queued again."
|
" Won't be queued again."
|
||||||
|
|
||||||
escoria.logger.debug(message % [event.name, channel_name])
|
escoria.logger.debug(self, message % [event.name, channel_name])
|
||||||
return
|
return
|
||||||
elif _is_event_running(event, CHANNEL_FRONT):
|
elif _is_event_running(event, CHANNEL_FRONT):
|
||||||
# Don't queue the same event if it's already running.
|
# Don't queue the same event if it's already running.
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
"Event %s already running in channel '%s'. Won't be queued."
|
"Event %s already running in channel '%s'. Won't be queued."
|
||||||
% [event.name, channel_name]
|
% [event.name, channel_name]
|
||||||
)
|
)
|
||||||
@@ -287,8 +285,10 @@ func queue_background_event(channel_name: String, event: ESCEvent) -> void:
|
|||||||
func interrupt(exceptions: PoolStringArray = []) -> void:
|
func interrupt(exceptions: PoolStringArray = []) -> void:
|
||||||
for channel_name in _running_events.keys():
|
for channel_name in _running_events.keys():
|
||||||
if _running_events[channel_name] != null and not _running_events[channel_name].name in exceptions:
|
if _running_events[channel_name] != null and not _running_events[channel_name].name in exceptions:
|
||||||
escoria.logger.debug("Interrupting running event %s in channel %s..."
|
escoria.logger.debug(
|
||||||
% [_running_events[channel_name].name, channel_name])
|
self,
|
||||||
|
"Interrupting running event %s in channel %s..."
|
||||||
|
% [_running_events[channel_name].name, channel_name])
|
||||||
_running_events[channel_name].interrupt()
|
_running_events[channel_name].interrupt()
|
||||||
_channels_state[channel_name] = true
|
_channels_state[channel_name] = true
|
||||||
|
|
||||||
@@ -298,8 +298,10 @@ func interrupt(exceptions: PoolStringArray = []) -> void:
|
|||||||
if event.name in exceptions:
|
if event.name in exceptions:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
escoria.logger.debug("Interrupting queued event %s in channel %s..."
|
escoria.logger.debug(
|
||||||
% [event.name, channel_name])
|
self,
|
||||||
|
"Interrupting queued event %s in channel %s..."
|
||||||
|
% [event.name, channel_name])
|
||||||
event.interrupt()
|
event.interrupt()
|
||||||
|
|
||||||
events_queue[channel_name].clear()
|
events_queue[channel_name].clear()
|
||||||
@@ -334,7 +336,10 @@ func get_running_event(name: String) -> ESCEvent:
|
|||||||
# #### Parameterse
|
# #### Parameterse
|
||||||
# - value: boolean value to set _changing_scene to
|
# - value: boolean value to set _changing_scene to
|
||||||
func set_changing_scene(p_is_changing_scene: bool) -> void:
|
func set_changing_scene(p_is_changing_scene: bool) -> void:
|
||||||
escoria.logger.trace("Setting _changing_scene to %s." % p_is_changing_scene)
|
escoria.logger.trace(
|
||||||
|
self,
|
||||||
|
"Setting _changing_scene to %s." % p_is_changing_scene
|
||||||
|
)
|
||||||
|
|
||||||
_changing_scene = p_is_changing_scene
|
_changing_scene = p_is_changing_scene
|
||||||
|
|
||||||
@@ -353,17 +358,16 @@ func set_changing_scene(p_is_changing_scene: bool) -> void:
|
|||||||
func _on_event_finished(finished_statement: ESCStatement, return_code: int, channel_name: String) -> void:
|
func _on_event_finished(finished_statement: ESCStatement, return_code: int, channel_name: String) -> void:
|
||||||
var event = _running_events[channel_name]
|
var event = _running_events[channel_name]
|
||||||
if not event:
|
if not event:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_event_manager.gd:_on_event_finished()",
|
self,
|
||||||
[
|
"Event %s finished without being in _running_events[%s]."
|
||||||
"Event %s finished without being in _running_events[%s]"
|
% [finished_statement.name, channel_name]
|
||||||
% [finished_statement.name, channel_name]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"Event %s ended with return code %d" % [event.name, return_code]
|
self,
|
||||||
|
"Event %s ended with return code %d." % [event.name, return_code]
|
||||||
)
|
)
|
||||||
|
|
||||||
var event_flags = event.flags
|
var event_flags = event.flags
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ export(Dictionary) var _globals = {}
|
|||||||
# Registry of globals that are to be reserved for internal use only.
|
# Registry of globals that are to be reserved for internal use only.
|
||||||
var _reserved_globals: Dictionary = {}
|
var _reserved_globals: Dictionary = {}
|
||||||
|
|
||||||
|
# Use look-ahead/behind to capture the term in braces
|
||||||
|
var globals_regex: RegEx = RegEx.new()
|
||||||
|
|
||||||
|
# Constructor
|
||||||
|
func _init():
|
||||||
|
globals_regex.compile("(?<=\\{)(.*)(?=\\})")
|
||||||
|
|
||||||
|
|
||||||
# Check if a global was registered
|
# Check if a global was registered
|
||||||
#
|
#
|
||||||
@@ -35,11 +42,11 @@ func has(key: String) -> bool:
|
|||||||
# - value: The initial value (optional)
|
# - value: The initial value (optional)
|
||||||
func register_reserved_global(key: String, value = null) -> void:
|
func register_reserved_global(key: String, value = null) -> void:
|
||||||
if key in _reserved_globals:
|
if key in _reserved_globals:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCGlobalsManager.register_reserved_global: Can not override reserved global",
|
self,
|
||||||
[
|
"Can not override reserved global: Global key %s is already " +
|
||||||
"Global key %s is already registered as reserved" % key
|
"registered as reserved."
|
||||||
]
|
% key
|
||||||
)
|
)
|
||||||
var old_value = _globals[key] if _globals.has(key) else ""
|
var old_value = _globals[key] if _globals.has(key) else ""
|
||||||
_reserved_globals[key] = value
|
_reserved_globals[key] = value
|
||||||
@@ -86,11 +93,9 @@ func filter(pattern: String) -> Dictionary:
|
|||||||
# - value: The new value
|
# - value: The new value
|
||||||
func set_global(key: String, value, ignore_reserved: bool = false) -> void:
|
func set_global(key: String, value, ignore_reserved: bool = false) -> void:
|
||||||
if key in _reserved_globals and not ignore_reserved:
|
if key in _reserved_globals and not ignore_reserved:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCGlobalsManager.set_global: Can not override reserved global",
|
self,
|
||||||
[
|
"Global key %s is reserved and can not be overridden." % key
|
||||||
"Global key %s is reserved and can not be overridden" % key
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
emit_signal(
|
emit_signal(
|
||||||
@@ -102,7 +107,6 @@ func set_global(key: String, value, ignore_reserved: bool = false) -> void:
|
|||||||
_globals[key] = value
|
_globals[key] = value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Set all globals that match the pattern to the value
|
# Set all globals that match the pattern to the value
|
||||||
# Check out [the Godot docs](https://docs.godotengine.org/en/stable/classes/class_string.html#class-string-method-match)
|
# Check out [the Godot docs](https://docs.godotengine.org/en/stable/classes/class_string.html#class-string-method-match)
|
||||||
# for the pattern format
|
# for the pattern format
|
||||||
@@ -117,6 +121,24 @@ func set_global_wildcard(pattern: String, value) -> void:
|
|||||||
self.set_global(global_key, value)
|
self.set_global(global_key, value)
|
||||||
|
|
||||||
|
|
||||||
|
# Look to see if any globals (names in braces) should be interpreted
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
#
|
||||||
|
# * string: Text in which to replace globals
|
||||||
|
#
|
||||||
|
# *Returns* the provided string with globals variables replaced with their values
|
||||||
|
func replace_globals(string: String) -> String:
|
||||||
|
for result in globals_regex.search_all(string):
|
||||||
|
var globresult = escoria.globals_manager.get_global(
|
||||||
|
str(result.get_string())
|
||||||
|
)
|
||||||
|
string = string.replace(
|
||||||
|
"{" + result.get_string() + "}", str(globresult)
|
||||||
|
)
|
||||||
|
return string
|
||||||
|
|
||||||
|
|
||||||
# Save the state of globals in the savegame.
|
# Save the state of globals in the savegame.
|
||||||
#
|
#
|
||||||
# #### Parameters
|
# #### Parameters
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# A manager for inventory objects
|
# A manager for inventory objects
|
||||||
extends Object
|
extends Resource
|
||||||
class_name ESCInventoryManager
|
class_name ESCInventoryManager
|
||||||
|
|
||||||
|
|
||||||
@@ -31,11 +31,10 @@ func items_in_inventory() -> Array:
|
|||||||
# - item: Inventory item id
|
# - item: Inventory item id
|
||||||
func remove_item(item: String):
|
func remove_item(item: String):
|
||||||
if not inventory_has(item):
|
if not inventory_has(item):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCInventoryManager.remove_item: Error removing inventory item",
|
self,
|
||||||
[
|
"Error removing inventory item: " +
|
||||||
"Trying to remove non-existent item %s" % item
|
"Trying to remove non-existent item %s." % item
|
||||||
]
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
escoria.globals_manager.set_global("i/%s" % item, false)
|
escoria.globals_manager.set_global("i/%s" % item, false)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# A manager for ESC objects
|
# A manager for ESC objects
|
||||||
extends Node
|
extends Resource
|
||||||
class_name ESCObjectManager
|
class_name ESCObjectManager
|
||||||
|
|
||||||
|
|
||||||
@@ -69,15 +69,6 @@ func _init() -> void:
|
|||||||
current_room_key = ESCRoomObjectsKey.new()
|
current_room_key = ESCRoomObjectsKey.new()
|
||||||
|
|
||||||
|
|
||||||
# Make active objects in current room visible
|
|
||||||
func _process(_delta):
|
|
||||||
for room in room_objects:
|
|
||||||
if room.is_reserved or _is_current_room(room):
|
|
||||||
for object in room.objects:
|
|
||||||
if (object as ESCObject).node:
|
|
||||||
(object as ESCObject).node.visible = (object as ESCObject).active
|
|
||||||
|
|
||||||
|
|
||||||
# Updates which object manager room is to be treated as the currently active one.
|
# Updates which object manager room is to be treated as the currently active one.
|
||||||
#
|
#
|
||||||
# #### Parameters
|
# #### Parameters
|
||||||
@@ -85,12 +76,10 @@ func _process(_delta):
|
|||||||
# - room: Room to register the object with in the object manager
|
# - room: Room to register the object with in the object manager
|
||||||
func set_current_room(room: ESCRoom) -> void:
|
func set_current_room(room: ESCRoom) -> void:
|
||||||
if room == null:
|
if room == null:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCObjectManager:set_current_room()",
|
self,
|
||||||
[
|
"Unable to set current room: No room was specified.\n" +
|
||||||
"Unable to set current room: No valid room specified.",
|
"Please pass in a valid ESCRoom as an argument to the method."
|
||||||
"Please pass in a valid ESCRoom as an argument to the method."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
current_room_key.room_global_id = room.global_id
|
current_room_key.room_global_id = room.global_id
|
||||||
@@ -111,13 +100,11 @@ func register_object(object: ESCObject, room: ESCRoom = null, force: bool = fals
|
|||||||
if object.global_id.empty():
|
if object.global_id.empty():
|
||||||
object.global_id = str(object.node.get_path()).split("/root/", false)[0]
|
object.global_id = str(object.node.get_path()).split("/root/", false)[0]
|
||||||
object.node.global_id = object.global_id
|
object.node.global_id = object.global_id
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCObjectManager:register_object()",
|
self,
|
||||||
[
|
"Registering ESCObject %s with empty global_id." % object.name +
|
||||||
"Registering ESCObject %s with empty global_id." % object.name,
|
"Using node's full path as global_id: %s"
|
||||||
"Using node's full path as global_id: %s"
|
% object.node.global_id
|
||||||
% object.node.global_id
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# If this is a reserved object, let's make sure it's in the right place.
|
# If this is a reserved object, let's make sure it's in the right place.
|
||||||
@@ -139,28 +126,25 @@ func register_object(object: ESCObject, room: ESCRoom = null, force: bool = fals
|
|||||||
|
|
||||||
if not room_key.is_valid():
|
if not room_key.is_valid():
|
||||||
# This condition should very likely never happen.
|
# This condition should very likely never happen.
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCObjectManager:register_object()",
|
self,
|
||||||
[
|
"No room was specified to register object with, and no current room is properly set.\n" +
|
||||||
"No room was specified to register object with, and no current room is properly set.",
|
"Please either pass in a valid ESCRoom to this method, or " + \
|
||||||
"Please either pass in a valid ESCRoom to this method, or " + \
|
"call set_current_room() with a valid ESCRoom first."
|
||||||
"call set_current_room() with a valid ESCRoom first."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
room_key.room_global_id = room.global_id
|
room_key.room_global_id = room.global_id
|
||||||
room_key.room_instance_id = room.get_instance_id()
|
room_key.room_instance_id = room.get_instance_id()
|
||||||
|
|
||||||
if not force and _object_exists_in_room(object, room_key):
|
if not force and _object_exists_in_room(object, room_key) \
|
||||||
escoria.logger.report_errors(
|
and _object_state_in_room_is_default(object, room_key):
|
||||||
"ESCObjectManager:register_object()",
|
escoria.logger.error(
|
||||||
[
|
self,
|
||||||
"Object with global id %s in room (%s, %s) already registered" %
|
"Object with global id '%s' in room %s already registered from node path %s."
|
||||||
[
|
% [
|
||||||
object.global_id,
|
object.global_id,
|
||||||
room_key.room_global_id,
|
room_key.room_global_id,
|
||||||
room_key.room_instance_id
|
get_object(object.global_id, room).node.get_path()
|
||||||
]
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@@ -213,17 +197,15 @@ func register_object(object: ESCObject, room: ESCRoom = null, force: bool = fals
|
|||||||
# If object state is not STATE_DEFAULT, save it in manager's object states
|
# If object state is not STATE_DEFAULT, save it in manager's object states
|
||||||
if object.state != ESCObject.STATE_DEFAULT:
|
if object.state != ESCObject.STATE_DEFAULT:
|
||||||
if get_object(object.global_id) == null:
|
if get_object(object.global_id) == null:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCObjectManager:register_object()",
|
self,
|
||||||
[
|
"Object with global id %s in room (%s, %s) not found in Object Manager."
|
||||||
"Object with global id %s in room (%s, %s) not found in Object Manager" %
|
% [
|
||||||
[
|
object.global_id,
|
||||||
object.global_id,
|
room_key.room_global_id,
|
||||||
room_key.room_global_id,
|
room_key.room_instance_id
|
||||||
room_key.room_instance_id
|
]
|
||||||
]
|
)
|
||||||
]
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
get_object(object.global_id).state = object.state
|
get_object(object.global_id).state = object.state
|
||||||
|
|
||||||
@@ -235,7 +217,6 @@ func register_object(object: ESCObject, room: ESCRoom = null, force: bool = fals
|
|||||||
room_container.room_instance_id = room_key.room_instance_id
|
room_container.room_instance_id = room_key.room_instance_id
|
||||||
room_container.is_reserved = false
|
room_container.is_reserved = false
|
||||||
room_container.objects = objects
|
room_container.objects = objects
|
||||||
|
|
||||||
room_objects.push_back(room_container)
|
room_objects.push_back(room_container)
|
||||||
|
|
||||||
|
|
||||||
@@ -256,8 +237,9 @@ func has(global_id: String, room: ESCRoom = null) -> bool:
|
|||||||
var room_key: ESCRoomObjectsKey
|
var room_key: ESCRoomObjectsKey
|
||||||
|
|
||||||
if room == null:
|
if room == null:
|
||||||
escoria.logger.trace("ESCObjectManager.has(): No room specified." \
|
escoria.logger.trace(
|
||||||
+ " Defaulting to current room."
|
self,
|
||||||
|
"No room specified. Defaulting to current room."
|
||||||
)
|
)
|
||||||
|
|
||||||
room_key = current_room_key
|
room_key = current_room_key
|
||||||
@@ -284,20 +266,19 @@ func get_object(global_id: String, room: ESCRoom = null) -> ESCObject:
|
|||||||
if reserved_objects_container.objects.has(global_id):
|
if reserved_objects_container.objects.has(global_id):
|
||||||
return reserved_objects_container.objects[global_id]
|
return reserved_objects_container.objects[global_id]
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCObjectManager:get_object()",
|
self,
|
||||||
[
|
"Reserved object with global id %s not found in object manager!"
|
||||||
"Reserved object with global id %s not found in object manager!"
|
% global_id
|
||||||
% global_id
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
var room_key: ESCRoomObjectsKey
|
var room_key: ESCRoomObjectsKey
|
||||||
|
|
||||||
if room == null:
|
if room == null:
|
||||||
escoria.logger.trace("ESCObjectManager.has(): No room specified." \
|
escoria.logger.trace(
|
||||||
+ " Defaulting to current room."
|
self,
|
||||||
|
"No room specified. Defaulting to current room."
|
||||||
)
|
)
|
||||||
|
|
||||||
room_key = current_room_key
|
room_key = current_room_key
|
||||||
@@ -307,13 +288,11 @@ func get_object(global_id: String, room: ESCRoom = null) -> ESCObject:
|
|||||||
room_key.room_instance_id = room.get_instance_id()
|
room_key.room_instance_id = room.get_instance_id()
|
||||||
|
|
||||||
if not _room_exists(room_key):
|
if not _room_exists(room_key):
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCObjectManager:get_object()",
|
self,
|
||||||
[
|
"Specified room is empty/not found.\n" +
|
||||||
"Specified room is empty/not found.",
|
"Object with global id %s in room instance (%s, %s) not found."
|
||||||
"Object with global id %s in room instance (%s, %s) not found"
|
% [global_id, room_key.room_global_id, room_key.room_instance_id]
|
||||||
% [global_id, room_key.room_global_id, room_key.room_instance_id]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
@@ -322,12 +301,10 @@ func get_object(global_id: String, room: ESCRoom = null) -> ESCObject:
|
|||||||
if objects.has(global_id):
|
if objects.has(global_id):
|
||||||
return objects[global_id]
|
return objects[global_id]
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCObjectManager:get_object()",
|
self,
|
||||||
[
|
"Object with global id %s in room instance (%s, %s) not found."
|
||||||
"Object with global id %s in room instance (%s, %s) not found"
|
% [global_id, room_key.room_global_id, room_key.room_instance_id]
|
||||||
% [global_id, room_key.room_global_id, room_key.room_instance_id]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
@@ -344,23 +321,22 @@ func unregister_object(object: ESCObject, room_key: ESCRoomObjectsKey) -> void:
|
|||||||
# called as part of an objectd's forced registration and the object not
|
# called as part of an objectd's forced registration and the object not
|
||||||
# yet being managed.
|
# yet being managed.
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"ESCObjectManager:unregister_object(): Unable to unregister object.",
|
self,
|
||||||
[
|
"Unable to unregister object.\n" +
|
||||||
"Object with global ID %s room (%s, %s) not found. If this was" %
|
"Object with global ID %s room (%s, %s) not found. If this was "
|
||||||
[
|
% [
|
||||||
"?" if object == null else object.global_id,
|
"?" if object == null else object.global_id,
|
||||||
room_key.room_global_id,
|
room_key.room_global_id,
|
||||||
room_key.room_instance_id
|
room_key.room_instance_id
|
||||||
],
|
] +
|
||||||
"part of a 'forced' registration, ignore this warning."
|
"part of a 'forced' registration, ignore this warning."
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
var room_objects = _get_room_objects_objects(room_key)
|
var room_objects = _get_room_objects_objects(room_key)
|
||||||
|
|
||||||
if escoria.inventory_manager.inventory_has(object.global_id):
|
if not escoria.is_quitting and escoria.inventory_manager.inventory_has(object.global_id):
|
||||||
# Re-instance the node if it is an item present in inventory; that is,
|
# Re-instance the node if it is an item present in inventory; that is,
|
||||||
# re-register it with the new current room.
|
# re-register it with the new current room.
|
||||||
if object.node != null:
|
if object.node != null:
|
||||||
@@ -393,11 +369,9 @@ func unregister_object_by_global_id(global_id: String, room_key: ESCRoomObjectsK
|
|||||||
# - p_savegame: The savegame resource
|
# - p_savegame: The savegame resource
|
||||||
func save_game(p_savegame: ESCSaveGame) -> void:
|
func save_game(p_savegame: ESCSaveGame) -> void:
|
||||||
if not current_room_key.is_valid() or not _room_exists(current_room_key):
|
if not current_room_key.is_valid() or not _room_exists(current_room_key):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCObjectManager:save_game()",
|
self,
|
||||||
[
|
"No current room specified or found."
|
||||||
"No current room specified or found."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var objects: Dictionary = _get_room_objects_objects(current_room_key)
|
var objects: Dictionary = _get_room_objects_objects(current_room_key)
|
||||||
@@ -430,13 +404,11 @@ func get_start_location() -> ESCLocation:
|
|||||||
and object.node.is_start_location:
|
and object.node.is_start_location:
|
||||||
return object
|
return object
|
||||||
|
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCObjectManager:get_start_location()",
|
self,
|
||||||
[
|
"Room has no ESCLocation node with 'is_start_location' enabled. " +
|
||||||
"Room has no ESCLocation node with 'is_start_location' enabled.",
|
"Player will be set at position (0,0)."
|
||||||
"Player will be set at position (0,0) by default."
|
)
|
||||||
]
|
|
||||||
)
|
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
|
||||||
@@ -486,11 +458,9 @@ func _room_exists(room_key: ESCRoomObjectsKey) -> bool:
|
|||||||
# **Returns** True iff object exists in the object manager entry specified by room_key.
|
# **Returns** True iff object exists in the object manager entry specified by room_key.
|
||||||
func _object_exists_in_room(object: ESCObject, room_key: ESCRoomObjectsKey) -> bool:
|
func _object_exists_in_room(object: ESCObject, room_key: ESCRoomObjectsKey) -> bool:
|
||||||
if object == null:
|
if object == null:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCObjectManager:_object_exists_in_room()",
|
self,
|
||||||
[
|
"Cannot check room for \"null\" objects."
|
||||||
"Cannot check for null objects."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -503,6 +473,30 @@ func _object_exists_in_room(object: ESCObject, room_key: ESCRoomObjectsKey) -> b
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
# Checks whether the specified object's state is "default" in the specified object manager entry.
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
#
|
||||||
|
# - object: The object to check for existence.
|
||||||
|
# - room_key: The key representing the desired room in the object manager array.
|
||||||
|
# **Returns** True if object's state is "default" in the object manager entry specified by room_key.
|
||||||
|
func _object_state_in_room_is_default(object: ESCObject, room_key: ESCRoomObjectsKey) -> bool:
|
||||||
|
if object == null:
|
||||||
|
escoria.logger.warn(
|
||||||
|
self,
|
||||||
|
"Cannot check room for \"null\" objects."
|
||||||
|
)
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
for room_container in room_objects:
|
||||||
|
if _compare_container_to_key(room_container, room_key) \
|
||||||
|
and room_container.objects.get(object.global_id).state == ESCObject.STATE_DEFAULT:
|
||||||
|
return true
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
|
||||||
# Returns the objects currently being managed in the object manager entry specified
|
# Returns the objects currently being managed in the object manager entry specified
|
||||||
# by the specified room key.
|
# by the specified room key.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
extends Object
|
extends Resource
|
||||||
class_name ESCRoomManager
|
class_name ESCRoomManager
|
||||||
|
|
||||||
|
|
||||||
@@ -86,14 +86,12 @@ func change_scene(room_path: String, enable_automatic_transitions: bool) -> void
|
|||||||
|
|
||||||
# Check if game scene was loaded
|
# Check if game scene was loaded
|
||||||
if not escoria.game_scene:
|
if not escoria.game_scene:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCRoomManager.change_scene: Failed loading game scene",
|
self,
|
||||||
[
|
"Failed loading game scene %s." % \
|
||||||
"Failed loading scene %s" % \
|
ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.get_setting(
|
ESCProjectSettingsManager.GAME_SCENE
|
||||||
escoria.project_settings_manager.GAME_SCENE
|
)
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if escoria.main.current_scene \
|
if escoria.main.current_scene \
|
||||||
@@ -106,9 +104,12 @@ func change_scene(room_path: String, enable_automatic_transitions: bool) -> void
|
|||||||
var room_scene = res_room.instance()
|
var room_scene = res_room.instance()
|
||||||
if room_scene:
|
if room_scene:
|
||||||
if enable_automatic_transitions \
|
if enable_automatic_transitions \
|
||||||
and escoria.event_manager.get_running_event(escoria.event_manager.CHANNEL_FRONT) != null \
|
and escoria.event_manager.get_running_event(
|
||||||
and escoria.event_manager.get_running_event(escoria.event_manager.CHANNEL_FRONT).name \
|
escoria.event_manager.CHANNEL_FRONT
|
||||||
== escoria.event_manager.EVENT_ROOM_SELECTOR:
|
) != null \
|
||||||
|
and escoria.event_manager.get_running_event(
|
||||||
|
escoria.event_manager.CHANNEL_FRONT
|
||||||
|
).name == escoria.event_manager.EVENT_ROOM_SELECTOR:
|
||||||
room_scene.enabled_automatic_transitions = true
|
room_scene.enabled_automatic_transitions = true
|
||||||
else:
|
else:
|
||||||
room_scene.enabled_automatic_transitions = enable_automatic_transitions
|
room_scene.enabled_automatic_transitions = enable_automatic_transitions
|
||||||
@@ -138,11 +139,9 @@ func change_scene(room_path: String, enable_automatic_transitions: bool) -> void
|
|||||||
|
|
||||||
escoria.inputs_manager.hotspot_focused = ""
|
escoria.inputs_manager.hotspot_focused = ""
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCRoomManager.change_scene: Failed loading room scene",
|
self,
|
||||||
[
|
"Failed loading room scene %s." % room_path
|
||||||
"Failed loading scene %s" % room_path
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -154,11 +153,9 @@ func change_scene(room_path: String, enable_automatic_transitions: bool) -> void
|
|||||||
# - room: The ESCRoom to be initialized for use.
|
# - room: The ESCRoom to be initialized for use.
|
||||||
func init_room(room: ESCRoom) -> void:
|
func init_room(room: ESCRoom) -> void:
|
||||||
if not is_instance_valid(room) || room == null:
|
if not is_instance_valid(room) || room == null:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCRoomManager.init_room: No valid room specified",
|
self,
|
||||||
[
|
"No valid room was specified for initialization."
|
||||||
"No valid room was specified for initialization."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if room.camera_limits.empty():
|
if room.camera_limits.empty():
|
||||||
@@ -189,12 +186,11 @@ func init_room(room: ESCRoom) -> void:
|
|||||||
# player by the same number of pixels when they're at the terrain edge and
|
# player by the same number of pixels when they're at the terrain edge and
|
||||||
# move them when it shouldn't.
|
# move them when it shouldn't.
|
||||||
if room.position != Vector2(0,0):
|
if room.position != Vector2(0,0):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCRoomManager.init_room: Room node not at (0,0)",
|
self,
|
||||||
[
|
"The room node's coordinates must be (0,0) instead of %s."
|
||||||
"The room node's coordinates must be (0,0) instead of %s." % room.position
|
% room.position
|
||||||
]
|
)
|
||||||
)
|
|
||||||
|
|
||||||
_perform_script_events(room)
|
_perform_script_events(room)
|
||||||
|
|
||||||
@@ -217,8 +213,8 @@ func _perform_script_events(room: ESCRoom) -> void:
|
|||||||
"%s %s out" %
|
"%s %s out" %
|
||||||
[
|
[
|
||||||
_transition.get_command_name(),
|
_transition.get_command_name(),
|
||||||
escoria.project_settings_manager.get_setting(
|
ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.DEFAULT_TRANSITION
|
ESCProjectSettingsManager.DEFAULT_TRANSITION
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
"%s 0.1" % _wait.get_command_name()
|
"%s 0.1" % _wait.get_command_name()
|
||||||
@@ -286,7 +282,9 @@ func _perform_script_events(room: ESCRoom) -> void:
|
|||||||
escoria.main.finish_current_scene_init(room)
|
escoria.main.finish_current_scene_init(room)
|
||||||
|
|
||||||
# Add new camera to scene being prepared.
|
# Add new camera to scene being prepared.
|
||||||
var new_player_camera: ESCCamera = escoria.resource_cache.get_resource(escoria.CAMERA_SCENE_PATH).instance()
|
var new_player_camera: ESCCamera = escoria.resource_cache.get_resource(
|
||||||
|
escoria.CAMERA_SCENE_PATH
|
||||||
|
).instance()
|
||||||
new_player_camera.register()
|
new_player_camera.register()
|
||||||
room.player_camera = new_player_camera
|
room.player_camera = new_player_camera
|
||||||
|
|
||||||
@@ -360,8 +358,8 @@ func _perform_script_events(room: ESCRoom) -> void:
|
|||||||
command_strings.append("%s %s in" %
|
command_strings.append("%s %s in" %
|
||||||
[
|
[
|
||||||
_transition.get_command_name(),
|
_transition.get_command_name(),
|
||||||
escoria.project_settings_manager.get_setting(
|
ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.DEFAULT_TRANSITION
|
ESCProjectSettingsManager.DEFAULT_TRANSITION
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -432,12 +430,10 @@ func _run_script_event(event_name: String, room: ESCRoom):
|
|||||||
|
|
||||||
if room.compiled_script.events.has(event_name):
|
if room.compiled_script.events.has(event_name):
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"esc_room:_run_script_event",
|
self,
|
||||||
[
|
"Queuing room script event %s " % event_name +
|
||||||
"Queuing room script event %s" % event_name,
|
"composed of %s statements."
|
||||||
"Composed of %s statements" %
|
% room.compiled_script.events[event_name].statements.size()
|
||||||
room.compiled_script.events[event_name].statements.size()
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
escoria.event_manager.queue_event(room.compiled_script.events[event_name], true)
|
escoria.event_manager.queue_event(room.compiled_script.events[event_name], true)
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# A base class for every ESC command.
|
# A base class for every ESC command.
|
||||||
# Extending classes have to override the configure and run function
|
# Extending classes have to override the configure and run function
|
||||||
extends Node
|
extends Resource
|
||||||
class_name ESCBaseCommand
|
class_name ESCBaseCommand
|
||||||
|
|
||||||
|
|
||||||
@@ -22,7 +22,10 @@ func _init() -> void:
|
|||||||
|
|
||||||
# Return the descriptor of the arguments of this command
|
# Return the descriptor of the arguments of this command
|
||||||
func configure() -> ESCCommandArgumentDescriptor:
|
func configure() -> ESCCommandArgumentDescriptor:
|
||||||
escoria.logger.error("Command %s did not override configure." % get_command_name())
|
escoria.logger.error(
|
||||||
|
self,
|
||||||
|
"Command %s did not override configure. Please implement a configure() function." % get_command_name()
|
||||||
|
)
|
||||||
return ESCCommandArgumentDescriptor.new()
|
return ESCCommandArgumentDescriptor.new()
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +36,10 @@ 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.error("Command %s did not override run." % get_command_name())
|
escoria.logger.error(
|
||||||
|
self,
|
||||||
|
"Command %s did not override run. Please implement a run() function." % get_command_name()
|
||||||
|
)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@@ -44,4 +50,7 @@ func get_command_name() -> String:
|
|||||||
|
|
||||||
# Function called when the command is interrupted.
|
# Function called when the command is interrupted.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.trace("Command %s did not override interrupt." % get_command_name())
|
escoria.logger.trace(
|
||||||
|
self,
|
||||||
|
"Command %s did not override interrupt. Please implement an interrupt() function." % get_command_name()
|
||||||
|
)
|
||||||
|
|||||||
@@ -28,15 +28,15 @@ func _init(command_string):
|
|||||||
if command_regex.search(command_string):
|
if command_regex.search(command_string):
|
||||||
for result in command_regex.search_all(command_string):
|
for result in command_regex.search_all(command_string):
|
||||||
if "name" in result.names:
|
if "name" in result.names:
|
||||||
self.name = escoria.utils.get_re_group(result, "name")
|
self.name = ESCUtils.get_re_group(result, "name")
|
||||||
if "parameters" in result.names:
|
if "parameters" in result.names:
|
||||||
# Split parameters by whitespace but allow quoted
|
# Split parameters by whitespace but allow quoted
|
||||||
# parameters
|
# parameters
|
||||||
var quote_open = false
|
var quote_open = false
|
||||||
var parameter_values = PoolStringArray([])
|
var parameter_values = PoolStringArray([])
|
||||||
var parsed_parameters = \
|
var parsed_parameters = \
|
||||||
escoria.utils.sanitize_whitespace(
|
ESCUtils.sanitize_whitespace(
|
||||||
escoria.utils.get_re_group(
|
ESCUtils.get_re_group(
|
||||||
result,
|
result,
|
||||||
"parameters"
|
"parameters"
|
||||||
).strip_edges()
|
).strip_edges()
|
||||||
@@ -66,7 +66,7 @@ func _init(command_string):
|
|||||||
else:
|
else:
|
||||||
parameters.append(parameter)
|
parameters.append(parameter)
|
||||||
if "conditions" in result.names:
|
if "conditions" in result.names:
|
||||||
for condition in escoria.utils.get_re_group(
|
for condition in ESCUtils.get_re_group(
|
||||||
result,
|
result,
|
||||||
"conditions"
|
"conditions"
|
||||||
).split(","):
|
).split(","):
|
||||||
@@ -74,22 +74,20 @@ func _init(command_string):
|
|||||||
ESCCondition.new(condition.strip_edges())
|
ESCCondition.new(condition.strip_edges())
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Invalid command detected: %s" % command_string,
|
self,
|
||||||
[
|
"Invalid command detected: %s\nCommand regexp didn't match."
|
||||||
"Command regexp didn't match"
|
% command_string
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Check, if conditions match
|
# Check, if conditions match
|
||||||
func is_valid() -> bool:
|
func is_valid() -> bool:
|
||||||
if not command_exists():
|
if not command_exists():
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Invalid command detected: %s" % self.name,
|
self,
|
||||||
[
|
"Invalid command detected: %s" % self.name +
|
||||||
"Command implementation not found in any command directory"
|
"Command implementation not found in any command directory."
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@@ -100,8 +98,8 @@ func is_valid() -> bool:
|
|||||||
#
|
#
|
||||||
# *Returns* True if the command exists, else false.
|
# *Returns* True if the command exists, else false.
|
||||||
func command_exists() -> bool:
|
func command_exists() -> bool:
|
||||||
for base_path in escoria.project_settings_manager.get_setting(
|
for base_path in ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.COMMAND_DIRECTORIES
|
ESCProjectSettingsManager.COMMAND_DIRECTORIES
|
||||||
):
|
):
|
||||||
var command_path = "%s/%s.gd" % [
|
var command_path = "%s/%s.gd" % [
|
||||||
base_path.trim_suffix("/"),
|
base_path.trim_suffix("/"),
|
||||||
@@ -124,14 +122,18 @@ func run() -> int:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if command_object.validate(prepared_arguments):
|
if command_object.validate(prepared_arguments):
|
||||||
escoria.logger.debug("Running command %s with parameters %s" % [
|
escoria.logger.debug(
|
||||||
self.name,
|
self,
|
||||||
prepared_arguments
|
"Running command %s with parameters %s."
|
||||||
])
|
% [self.name, prepared_arguments]
|
||||||
|
)
|
||||||
var rc = command_object.run(prepared_arguments)
|
var rc = command_object.run(prepared_arguments)
|
||||||
if rc is GDScriptFunctionState:
|
if rc is GDScriptFunctionState:
|
||||||
rc = yield(rc, "completed")
|
rc = yield(rc, "completed")
|
||||||
escoria.logger.debug("[%s] Return code: %d" % [self.name, rc])
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"[%s] Return code: %d." % [self.name, rc]
|
||||||
|
)
|
||||||
return rc
|
return rc
|
||||||
else:
|
else:
|
||||||
return ESCExecution.RC_ERROR
|
return ESCExecution.RC_ERROR
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# The descriptor of the arguments of an ESC command
|
# The descriptor of the arguments of an ESC command
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCCommandArgumentDescriptor
|
class_name ESCCommandArgumentDescriptor
|
||||||
|
|
||||||
# As the get_type command was deprecated with Godot 2.x w we need a way to determine
|
# As the get_type command was deprecated with Godot 2.x w we need a way to determine
|
||||||
@@ -71,7 +71,7 @@ func prepare_arguments(arguments: Array) -> Array:
|
|||||||
# appear at the very end of a command's argument list.
|
# appear at the very end of a command's argument list.
|
||||||
varargs.append(arguments[index])
|
varargs.append(arguments[index])
|
||||||
else:
|
else:
|
||||||
complete_arguments[index] = escoria.utils.get_typed_value(
|
complete_arguments[index] = ESCUtils.get_typed_value(
|
||||||
arguments[index],
|
arguments[index],
|
||||||
types[index]
|
types[index]
|
||||||
)
|
)
|
||||||
@@ -98,22 +98,20 @@ func validate(command: String, arguments: Array) -> bool:
|
|||||||
if required_args_count < min_args:
|
if required_args_count < min_args:
|
||||||
var verb = "was" if required_args_count == 1 else "were"
|
var verb = "was" if required_args_count == 1 else "were"
|
||||||
|
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCCommandArgumentDescriptor:validate()",
|
self,
|
||||||
[
|
"Invalid arguments for command %s. " % command +
|
||||||
"Invalid arguments for command %s" % command,
|
"Arguments didn't match minimum size {num}: Only {args} {verb} found." \
|
||||||
"Arguments didn't match minimum size {num}: Only {args} {verb} found" \
|
.format({"num":self.min_args,"args":required_args_count,"verb":verb})
|
||||||
.format({"num":self.min_args,"args":required_args_count,"verb":verb})
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if arguments.size() > self.max_args and not has_varargs:
|
if arguments.size() > self.max_args and not has_varargs:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCCommandArgumentDescriptor:validate()",
|
self,
|
||||||
[
|
"Invalid arguments for command %s" % command +
|
||||||
"Invalid arguments for command %s" % command,
|
"Maximum number of arguments ({num}) exceeded: {args}.".format(
|
||||||
"Maximum number of arguments ({num}) exceeded: {args}".format({"num":self.max_args,"args":arguments})
|
{"num":self.max_args,"args":arguments}
|
||||||
]
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
for index in range(arguments.size()):
|
for index in range(arguments.size()):
|
||||||
@@ -140,17 +138,17 @@ func validate(command: String, arguments: Array) -> bool:
|
|||||||
for type in self.types[types_index]:
|
for type in self.types[types_index]:
|
||||||
allowed_types += GODOT_TYPE_LIST[type] + " or "
|
allowed_types += GODOT_TYPE_LIST[type] + " or "
|
||||||
allowed_types = allowed_types.substr(0, allowed_types.length() - 3) + "]"
|
allowed_types = allowed_types.substr(0, allowed_types.length() - 3) + "]"
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Argument type did not match descriptor for command \"%s\"" %
|
self,
|
||||||
command,
|
"Argument type did not match descriptor for command \"%s\"\n"
|
||||||
[
|
% command +
|
||||||
"Argument %d (\"%s\") is of type %s. Expected %s" % [
|
"Argument %d (\"%s\") is of type %s. Expected %s."
|
||||||
index,
|
% [
|
||||||
arguments[index],
|
index,
|
||||||
GODOT_TYPE_LIST[typeof(arguments[index])],
|
arguments[index],
|
||||||
allowed_types
|
GODOT_TYPE_LIST[typeof(arguments[index])],
|
||||||
]
|
allowed_types
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# A condition to run a command
|
# A condition to run a command
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCCondition
|
class_name ESCCondition
|
||||||
|
|
||||||
|
|
||||||
@@ -56,24 +56,24 @@ func _init(comparison_string: String):
|
|||||||
if "is_negated" in result.names:
|
if "is_negated" in result.names:
|
||||||
self.negated = true
|
self.negated = true
|
||||||
if "comparison" in result.names:
|
if "comparison" in result.names:
|
||||||
match escoria.utils.get_re_group(result, "comparison"):
|
match ESCUtils.get_re_group(result, "comparison"):
|
||||||
"eq": self.comparison = COMPARISON_EQ
|
"eq": self.comparison = COMPARISON_EQ
|
||||||
"gt": self.comparison = COMPARISON_GT
|
"gt": self.comparison = COMPARISON_GT
|
||||||
"lt": self.comparison = COMPARISON_LT
|
"lt": self.comparison = COMPARISON_LT
|
||||||
_: escoria.logger.report_errors(
|
_:
|
||||||
"Invalid comparison type detected: %s" %
|
escoria.logger.error(
|
||||||
comparison_string,
|
self,
|
||||||
[
|
"Invalid comparison type detected: %s" %
|
||||||
|
comparison_string +
|
||||||
"Comparison type %s unknown" %
|
"Comparison type %s unknown" %
|
||||||
escoria.utils.get_re_group(
|
ESCUtils.get_re_group(
|
||||||
result,
|
result,
|
||||||
"comparison"
|
"comparison"
|
||||||
)
|
)
|
||||||
]
|
)
|
||||||
)
|
|
||||||
if "comparison_value" in result.names:
|
if "comparison_value" in result.names:
|
||||||
self.comparison_value = escoria.utils.get_typed_value(
|
self.comparison_value = ESCUtils.get_typed_value(
|
||||||
escoria.utils.get_re_group(
|
ESCUtils.get_re_group(
|
||||||
result,
|
result,
|
||||||
"comparison_value"
|
"comparison_value"
|
||||||
)
|
)
|
||||||
@@ -83,13 +83,12 @@ func _init(comparison_string: String):
|
|||||||
if "is_activity" in result.names:
|
if "is_activity" in result.names:
|
||||||
self.comparison = COMPARISON_ACTIVITY
|
self.comparison = COMPARISON_ACTIVITY
|
||||||
if "flag" in result.names:
|
if "flag" in result.names:
|
||||||
self.flag = escoria.utils.get_re_group(result, "flag")
|
self.flag = ESCUtils.get_re_group(result, "flag")
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Invalid comparison detected: %s" % comparison_string,
|
self,
|
||||||
[
|
"Invalid comparison detected: %s\nComparison regexp didn't match."
|
||||||
"Comparison regexp didn't match"
|
% comparison_string
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -98,6 +97,7 @@ func run() -> bool:
|
|||||||
var global_name = self.flag
|
var global_name = self.flag
|
||||||
|
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
COMPARISON_DESCRIPTION[self.comparison] % [
|
COMPARISON_DESCRIPTION[self.comparison] % [
|
||||||
"inventory item" if self.inventory else "global value",
|
"inventory item" if self.inventory else "global value",
|
||||||
self.flag,
|
self.flag,
|
||||||
@@ -138,6 +138,7 @@ func run() -> bool:
|
|||||||
return_value = not return_value
|
return_value = not return_value
|
||||||
|
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
"It is" if return_value else "It isn't"
|
"It is" if return_value else "It isn't"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -38,37 +38,36 @@ func load_string(dialog_string: String):
|
|||||||
if dialog_regex.search(dialog_string):
|
if dialog_regex.search(dialog_string):
|
||||||
for result in dialog_regex.search_all(dialog_string):
|
for result in dialog_regex.search_all(dialog_string):
|
||||||
if "avatar" in result.names:
|
if "avatar" in result.names:
|
||||||
self.avatar = escoria.utils.get_re_group(result, "avatar")
|
self.avatar = ESCUtils.get_re_group(result, "avatar")
|
||||||
if "timeout" in result.names:
|
if "timeout" in result.names:
|
||||||
self.timeout = int(
|
self.timeout = int(
|
||||||
escoria.utils.get_re_group(result, "timeout")
|
ESCUtils.get_re_group(result, "timeout")
|
||||||
)
|
)
|
||||||
if "timeout_option" in result.names:
|
if "timeout_option" in result.names:
|
||||||
self.timeout_option = int(
|
self.timeout_option = int(
|
||||||
escoria.utils.get_re_group(result, "timeout_option")
|
ESCUtils.get_re_group(result, "timeout_option")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Invalid dialog detected: %s" % dialog_string,
|
self,
|
||||||
[
|
"Invalid dialog detected: %s\nDialog regexp didn't match."
|
||||||
"Dialog regexp didn't match"
|
% dialog_string
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Check if dialog is valid
|
# Check if dialog is valid
|
||||||
func is_valid() -> bool:
|
func is_valid() -> bool:
|
||||||
if self.avatar != "-" and not ResourceLoader.exists(self.avatar):
|
if self.avatar != "-" and not ResourceLoader.exists(self.avatar):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Avatar scene not found: %s" % self.avatar,
|
self,
|
||||||
[]
|
"Avatar scene not found: %s." % self.avatar
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
if self.timeout_option > self.options.size() \
|
if self.timeout_option > self.options.size() \
|
||||||
or self.timeout_option < 0:
|
or self.timeout_option < 0:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Invalid timeout_option parameter given: %d" % self.timeout_option,
|
self,
|
||||||
[]
|
"Invalid timeout_option parameter given: %d." % self.timeout_option
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@@ -77,7 +76,10 @@ func is_valid() -> bool:
|
|||||||
|
|
||||||
# Run this dialog
|
# Run this dialog
|
||||||
func run():
|
func run():
|
||||||
escoria.logger.debug("Starting dialog")
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Starting dialog."
|
||||||
|
)
|
||||||
escoria.current_state = escoria.GAME_STATE.DIALOG
|
escoria.current_state = escoria.GAME_STATE.DIALOG
|
||||||
if !escoria.dialog_player:
|
if !escoria.dialog_player:
|
||||||
escoria.dialog_player = escoria.main.current_scene.get_node(
|
escoria.dialog_player = escoria.main.current_scene.get_node(
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ func load_string(option_string: String):
|
|||||||
var _trans_key = ""
|
var _trans_key = ""
|
||||||
if "trans_key" in result.names:
|
if "trans_key" in result.names:
|
||||||
_trans_key = "%s:" % \
|
_trans_key = "%s:" % \
|
||||||
escoria.utils.get_re_group(result, "trans_key")
|
ESCUtils.get_re_group(result, "trans_key")
|
||||||
self.option = "%s%s" % [
|
self.option = "%s%s" % [
|
||||||
_trans_key,
|
_trans_key,
|
||||||
escoria.utils.get_re_group(result, "option")
|
ESCUtils.get_re_group(result, "option")
|
||||||
]
|
]
|
||||||
if "conditions" in result.names:
|
if "conditions" in result.names:
|
||||||
for condition_text in escoria.utils.get_re_group(
|
for condition_text in ESCUtils.get_re_group(
|
||||||
result,
|
result,
|
||||||
"conditions"
|
"conditions"
|
||||||
).split(","):
|
).split(","):
|
||||||
@@ -44,11 +44,10 @@ func load_string(option_string: String):
|
|||||||
ESCCondition.new(condition_text.strip_edges())
|
ESCCondition.new(condition_text.strip_edges())
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Invalid dialog option detected: %s" % option_string,
|
self,
|
||||||
[
|
"Invalid dialog option detected: %s." % option_string,
|
||||||
"Dialog option regexp didn't match"
|
"Dialog option regexp didn't match"
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ func _init(event_string: String):
|
|||||||
if event_regex.search(event_string):
|
if event_regex.search(event_string):
|
||||||
for result in event_regex.search_all(event_string):
|
for result in event_regex.search_all(event_string):
|
||||||
if "name" in result.names:
|
if "name" in result.names:
|
||||||
self.name = escoria.utils.get_re_group(result, "name") \
|
self.name = ESCUtils.get_re_group(result, "name") \
|
||||||
.strip_edges()
|
.strip_edges()
|
||||||
if "flags" in result.names:
|
if "flags" in result.names:
|
||||||
var _flags = escoria.utils.get_re_group(
|
var _flags = ESCUtils.get_re_group(
|
||||||
result,
|
result,
|
||||||
"flags"
|
"flags"
|
||||||
).strip_edges().split(" ")
|
).strip_edges().split(" ")
|
||||||
@@ -76,17 +76,19 @@ func _init(event_string: String):
|
|||||||
if "NO_SAVE" in _flags:
|
if "NO_SAVE" in _flags:
|
||||||
self.flags |= FLAG_NO_SAVE
|
self.flags |= FLAG_NO_SAVE
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Invalid event detected: %s" % event_string,
|
self,
|
||||||
[
|
"Invalid event detected: %s\nEvent regexp didn't match."
|
||||||
"Event regexp didn't match"
|
% event_string
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Execute this statement and return its return code
|
# Execute this statement and return its return code
|
||||||
func run() -> int:
|
func run() -> int:
|
||||||
reset_interrupt()
|
reset_interrupt()
|
||||||
escoria.logger.debug("Event %s started" % name)
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Event %s started." % name
|
||||||
|
)
|
||||||
return .run()
|
return .run()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Basic features and informations about ESC executions
|
# Basic features and informations about ESC executions
|
||||||
extends Object
|
extends Resource
|
||||||
class_name ESCExecution
|
class_name ESCExecution
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func _init(group_string: String):
|
|||||||
if group_regex.search(group_string):
|
if group_regex.search(group_string):
|
||||||
for result in group_regex.search_all(group_string):
|
for result in group_regex.search_all(group_string):
|
||||||
if "conditions" in result.names:
|
if "conditions" in result.names:
|
||||||
for condition in escoria.utils.get_re_group(
|
for condition in ESCUtils.get_re_group(
|
||||||
result,
|
result,
|
||||||
"conditions"
|
"conditions"
|
||||||
).split(","):
|
).split(","):
|
||||||
@@ -28,9 +28,8 @@ func _init(group_string: String):
|
|||||||
ESCCondition.new(condition.strip_edges())
|
ESCCondition.new(condition.strip_edges())
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Invalid group detected: %s" % group_string,
|
self,
|
||||||
[
|
"Invalid group detected: %s\nGroup regexp didn't match."
|
||||||
"Group regexp didn't match"
|
% group_string
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
extends Reference
|
||||||
# An object handled in Escoria
|
# An object handled in Escoria
|
||||||
extends Node
|
|
||||||
class_name ESCObject
|
class_name ESCObject
|
||||||
|
|
||||||
|
|
||||||
@@ -50,23 +50,23 @@ func set_state(p_state: String, immediate: bool = false):
|
|||||||
if animation_node.has_animation(p_state):
|
if animation_node.has_animation(p_state):
|
||||||
if immediate:
|
if immediate:
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"State \"%s\" set. Matching immediate animation executing." % [
|
self,
|
||||||
p_state
|
"State \"%s\" set. Matching immediate animation executing."
|
||||||
]
|
% p_state
|
||||||
)
|
)
|
||||||
animation_node.seek_end(p_state)
|
animation_node.seek_end(p_state)
|
||||||
else:
|
else:
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"State \"%s\" set. Matching non-immediate animation executing." % [
|
self,
|
||||||
p_state
|
"State \"%s\" set. Matching non-immediate animation executing."
|
||||||
]
|
% p_state
|
||||||
)
|
)
|
||||||
animation_node.play(p_state)
|
animation_node.play(p_state)
|
||||||
else:
|
else:
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"State \"%s\" set. No matching animation found." % [
|
self,
|
||||||
p_state
|
"State \"%s\" set. No matching animation found."
|
||||||
]
|
% p_state
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# An event that is scheduled to run later
|
# An event that is scheduled to run later
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCScheduledEvent
|
class_name ESCScheduledEvent
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# A compiled ESC script
|
# A compiled ESC script
|
||||||
extends Object
|
extends Resource
|
||||||
class_name ESCScript
|
class_name ESCScript
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# A statement in an ESC file
|
# A statement in an ESC file
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCStatement
|
class_name ESCStatement
|
||||||
|
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ class_name ESCStatement
|
|||||||
signal finished(event, return_code)
|
signal finished(event, return_code)
|
||||||
|
|
||||||
# Emitted when the event was interrupted
|
# Emitted when the event was interrupted
|
||||||
signal interrupted(return_code)
|
signal interrupted(event, return_code)
|
||||||
|
|
||||||
|
|
||||||
# The list of ESC commands
|
# The list of ESC commands
|
||||||
@@ -35,7 +35,7 @@ func run() -> int:
|
|||||||
if _is_interrupted:
|
if _is_interrupted:
|
||||||
final_rc = ESCExecution.RC_INTERRUPTED
|
final_rc = ESCExecution.RC_INTERRUPTED
|
||||||
statement.interrupt()
|
statement.interrupt()
|
||||||
emit_signal("interrupted", final_rc)
|
emit_signal("interrupted", self, final_rc)
|
||||||
return final_rc
|
return final_rc
|
||||||
|
|
||||||
if statement.is_valid():
|
if statement.is_valid():
|
||||||
@@ -43,9 +43,8 @@ func run() -> int:
|
|||||||
if rc is GDScriptFunctionState:
|
if rc is GDScriptFunctionState:
|
||||||
rc = yield(rc, "completed")
|
rc = yield(rc, "completed")
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"esc_statement",
|
self,
|
||||||
["Statement (%s) was completed."
|
"Statement (%s) was completed." % statement
|
||||||
% statement]
|
|
||||||
)
|
)
|
||||||
if rc == ESCExecution.RC_REPEAT:
|
if rc == ESCExecution.RC_REPEAT:
|
||||||
return self.run()
|
return self.run()
|
||||||
@@ -59,11 +58,10 @@ func run() -> int:
|
|||||||
|
|
||||||
# Interrupt the statement in the middle of its execution.
|
# Interrupt the statement in the middle of its execution.
|
||||||
func interrupt():
|
func interrupt():
|
||||||
escoria.logger.info("Interrupting event %s (%s)" % \
|
escoria.logger.info(
|
||||||
[
|
self,
|
||||||
self.name if "name" in self else "group",
|
"Interrupting event %s (%s)."
|
||||||
str(self)
|
% [self.name if "name" in self else "group", str(self)]
|
||||||
]
|
|
||||||
)
|
)
|
||||||
_is_interrupted = true
|
_is_interrupted = true
|
||||||
for statement in statements:
|
for statement in statements:
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func _ready():
|
|||||||
|
|
||||||
# Handle debugging visualizations
|
# Handle debugging visualizations
|
||||||
func _draw():
|
func _draw():
|
||||||
if !Engine.is_editor_hint():
|
if not Engine.is_editor_hint():
|
||||||
return
|
return
|
||||||
if editor_debug_mode == EDITOR_GAME_DEBUG_DISPLAY.NONE:
|
if editor_debug_mode == EDITOR_GAME_DEBUG_DISPLAY.NONE:
|
||||||
return
|
return
|
||||||
@@ -131,12 +131,9 @@ func do_walk(destination, params: Array = [], can_interrupt: bool = false) -> vo
|
|||||||
|
|
||||||
# Check moving object.
|
# Check moving object.
|
||||||
if not escoria.object_manager.has(params[0]):
|
if not escoria.object_manager.has(params[0]):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_game.gd:do_walk()",
|
self,
|
||||||
[
|
"Walk action requested on nonexisting object: %s." % params[0]
|
||||||
"Walk action requested on nonexisting " + \
|
|
||||||
"object: %s " % params[0]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -145,12 +142,9 @@ func do_walk(destination, params: Array = [], can_interrupt: bool = false) -> vo
|
|||||||
|
|
||||||
if destination is String:
|
if destination is String:
|
||||||
if not escoria.object_manager.has(destination):
|
if not escoria.object_manager.has(destination):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_game.gd:do_walk()",
|
self,
|
||||||
[
|
"Walk action requested to nonexisting object: %s." % destination
|
||||||
"Walk action requested to nonexisting " + \
|
|
||||||
"object: %s " % destination
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -436,8 +430,8 @@ func show_crash_popup(files: Array = []) -> void:
|
|||||||
var files_to_send: String = ""
|
var files_to_send: String = ""
|
||||||
for file in files:
|
for file in files:
|
||||||
files_to_send += "- %s\n" % file
|
files_to_send += "- %s\n" % file
|
||||||
crash_popup.dialog_text = tr(escoria.project_settings_manager.get_setting(
|
crash_popup.dialog_text = tr(ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.CRASH_MESSAGE)
|
ESCProjectSettingsManager.CRASH_MESSAGE)
|
||||||
) % files_to_send
|
) % files_to_send
|
||||||
crash_popup.popup_centered()
|
crash_popup.popup_centered()
|
||||||
escoria.set_game_paused(true)
|
escoria.set_game_paused(true)
|
||||||
@@ -451,9 +445,9 @@ func escoria_hide_ui():
|
|||||||
if ui_parent_control_node != null and not ui_parent_control_node.is_empty():
|
if ui_parent_control_node != null and not ui_parent_control_node.is_empty():
|
||||||
(get_node(ui_parent_control_node) as Control).visible = false
|
(get_node(ui_parent_control_node) as Control).visible = false
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_game.gd#escoria_hide_ui",
|
self,
|
||||||
["UI parent Control node not defined!"]
|
"UI parent Control node not defined!"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -463,9 +457,9 @@ func escoria_show_ui():
|
|||||||
if ui_parent_control_node != null and not ui_parent_control_node.is_empty():
|
if ui_parent_control_node != null and not ui_parent_control_node.is_empty():
|
||||||
(get_node(ui_parent_control_node) as Control).visible = true
|
(get_node(ui_parent_control_node) as Control).visible = true
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_game.gd#escoria_show_ui",
|
self,
|
||||||
["UI parent Control node not defined!"]
|
"UI parent Control node not defined!"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -323,7 +323,10 @@ func _unhandled_input(input_event: InputEvent) -> void:
|
|||||||
|
|
||||||
if event is InputEventMouseButton and event.is_pressed():
|
if event is InputEventMouseButton and event.is_pressed():
|
||||||
if not escoria.current_state == escoria.GAME_STATE.DEFAULT:
|
if not escoria.current_state == escoria.GAME_STATE.DEFAULT:
|
||||||
escoria.logger.info("Game state doesn't accept interactions")
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Current game state doesn't accept interactions."
|
||||||
|
)
|
||||||
return
|
return
|
||||||
var p = get_global_mouse_position()
|
var p = get_global_mouse_position()
|
||||||
if _is_in_shape(p):
|
if _is_in_shape(p):
|
||||||
@@ -367,8 +370,9 @@ func get_animation_player() -> Node:
|
|||||||
child is AnimationPlayer:
|
child is AnimationPlayer:
|
||||||
player_node_path = child.get_path()
|
player_node_path = child.get_path()
|
||||||
if not has_node(player_node_path):
|
if not has_node(player_node_path):
|
||||||
escoria.logger.warning(
|
escoria.logger.warn(
|
||||||
"Can not find node at path %s" % player_node_path
|
self,
|
||||||
|
"Can not find animation_player node at path %s for %s." % [player_node_path, global_id]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
_animation_player = ESCAnimationPlayer.new(
|
_animation_player = ESCAnimationPlayer.new(
|
||||||
@@ -394,7 +398,9 @@ func get_interact_position() -> Vector2:
|
|||||||
interact_position = collision.global_position
|
interact_position = collision.global_position
|
||||||
|
|
||||||
if multiple_positions_found:
|
if multiple_positions_found:
|
||||||
escoria.logger.warning("Multiple ESClocations found to walk to for object " +
|
escoria.logger.warn(
|
||||||
|
self,
|
||||||
|
"Multiple ESClocations found to walk to for object " +
|
||||||
"%s. Last one will be used." % global_id)
|
"%s. Last one will be used." % global_id)
|
||||||
return interact_position
|
return interact_position
|
||||||
|
|
||||||
@@ -500,7 +506,8 @@ func get_sprite() -> Node:
|
|||||||
_sprite_node = child
|
_sprite_node = child
|
||||||
if _sprite_node == null:
|
if _sprite_node == null:
|
||||||
escoria.logger.error(
|
escoria.logger.error(
|
||||||
"No sprite node found in the scene %s" % get_path()
|
self,
|
||||||
|
"No sprite node found in the scene %s." % get_path()
|
||||||
)
|
)
|
||||||
return _sprite_node
|
return _sprite_node
|
||||||
|
|
||||||
@@ -579,7 +586,11 @@ func update_idle():
|
|||||||
# global position of the player
|
# global position of the player
|
||||||
func get_camera_node():
|
func get_camera_node():
|
||||||
if has_node(camera_node):
|
if has_node(camera_node):
|
||||||
escoria.logger.debug("Camera node found - directing camera to the camera_node on " + global_id)
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Camera node found - directing camera to the camera_node on %s."
|
||||||
|
% global_id
|
||||||
|
)
|
||||||
return get_node(camera_node)
|
return get_node(camera_node)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# A cache for resources
|
# A cache for resources
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCResourceCache
|
class_name ESCResourceCache
|
||||||
|
|
||||||
var thread: Thread
|
var thread: Thread
|
||||||
@@ -138,7 +138,7 @@ func get_resource(path):
|
|||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
_unlock("return")
|
_unlock("return")
|
||||||
# We can't use escoria.project_settings_manager here since this method
|
# We can't use ESCProjectSettingsManager here since this method
|
||||||
# can be called from escoria._init()
|
# can be called from escoria._init()
|
||||||
if not ProjectSettings.get_setting("escoria/platform/skip_cache"):
|
if not ProjectSettings.get_setting("escoria/platform/skip_cache"):
|
||||||
var res = ResourceLoader.load(path)
|
var res = ResourceLoader.load(path)
|
||||||
|
|||||||
@@ -60,7 +60,10 @@ func _enter_tree():
|
|||||||
# name of this node if it's not set manually
|
# name of this node if it's not set manually
|
||||||
func _ready():
|
func _ready():
|
||||||
# Might as well just check here.
|
# Might as well just check here.
|
||||||
if get_parent() == get_tree().root and ProjectSettings.get_setting("application/run/main_scene") != self.filename:
|
if get_parent() == get_tree().root \
|
||||||
|
and ESCProjectSettingsManager.get_setting(
|
||||||
|
"application/run/main_scene"
|
||||||
|
) != self.filename:
|
||||||
is_run_directly = true
|
is_run_directly = true
|
||||||
|
|
||||||
escoria.room_manager.init_room(self)
|
escoria.room_manager.init_room(self)
|
||||||
@@ -85,7 +88,9 @@ func _draw():
|
|||||||
# Draw lines for camera limits
|
# Draw lines for camera limits
|
||||||
for i in camera_limits.size():
|
for i in camera_limits.size():
|
||||||
draw_rect(camera_limits[i], camera_limits_colors[i], false, 10.0)
|
draw_rect(camera_limits[i], camera_limits_colors[i], false, 10.0)
|
||||||
var default_font = Control.new().get_font("font")
|
var temp_control = Control.new()
|
||||||
|
var default_font = temp_control.get_font("font")
|
||||||
|
temp_control.queue_free()
|
||||||
|
|
||||||
draw_string(default_font, Vector2(camera_limits[i].position.x + 30,
|
draw_string(default_font, Vector2(camera_limits[i].position.x + 30,
|
||||||
camera_limits[i].position.y + 30), str(i), camera_limits_colors[i])
|
camera_limits[i].position.y + 30), str(i), camera_limits_colors[i])
|
||||||
|
|||||||
@@ -64,20 +64,16 @@ func _ready():
|
|||||||
if n is NavigationPolygonInstance:
|
if n is NavigationPolygonInstance:
|
||||||
if n.enabled:
|
if n.enabled:
|
||||||
if !Engine.is_editor_hint() and navigation_enabled_found:
|
if !Engine.is_editor_hint() and navigation_enabled_found:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"ESCTerrain:_ready()",
|
self,
|
||||||
[
|
"Multiple NavigationPolygonInstances enabled " + \
|
||||||
"Multiple NavigationPolygonInstances enabled " + \
|
"at the same time."
|
||||||
"at the same time."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
elif Engine.is_editor_hint():
|
elif Engine.is_editor_hint():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"ESCTerrain:_ready()",
|
self,
|
||||||
[
|
"Multiple NavigationPolygonInstances enabled " + \
|
||||||
"Multiple NavigationPolygonInstances enabled " + \
|
"at the same time."
|
||||||
"at the same time."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
navigation_enabled_found = true
|
navigation_enabled_found = true
|
||||||
current_active_navigation_instance = n
|
current_active_navigation_instance = n
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ func set_debug_mode(p_debug_mode: bool):
|
|||||||
else:
|
else:
|
||||||
if debug_texturerect_node:
|
if debug_texturerect_node:
|
||||||
remove_child(debug_texturerect_node)
|
remove_child(debug_texturerect_node)
|
||||||
|
debug_texturerect_node.queue_free()
|
||||||
|
|
||||||
|
|
||||||
# Set the first target of the label.
|
# Set the first target of the label.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# The walk context describes the target of a walk command and if that command
|
# The walk context describes the target of a walk command and if that command
|
||||||
# should be executed fast
|
# should be executed fast
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCWalkContext
|
class_name ESCWalkContext
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,325 +0,0 @@
|
|||||||
# Logging framework for Escoria
|
|
||||||
extends Object
|
|
||||||
class_name ESCLogger
|
|
||||||
|
|
||||||
# Log file format
|
|
||||||
const LOG_FILE_FORMAT: String = "log_%s_%s.log"
|
|
||||||
|
|
||||||
|
|
||||||
# The path of the ESC file that was reported last (used for removing
|
|
||||||
# duplicate warnings
|
|
||||||
var warning_path: String
|
|
||||||
|
|
||||||
# Log file handler
|
|
||||||
var log_file: File
|
|
||||||
|
|
||||||
# Crash save filename
|
|
||||||
var crash_savegame_filename
|
|
||||||
|
|
||||||
# Did we crash already?
|
|
||||||
onready var crashed = false
|
|
||||||
|
|
||||||
# Valid log levels
|
|
||||||
enum { LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG, LOG_TRACE }
|
|
||||||
|
|
||||||
|
|
||||||
# A map of log level names to log level ints
|
|
||||||
var _level_map: Dictionary = {
|
|
||||||
"ERROR": LOG_ERROR,
|
|
||||||
"WARNING": LOG_WARNING,
|
|
||||||
"INFO": LOG_INFO,
|
|
||||||
"DEBUG": LOG_DEBUG,
|
|
||||||
"TRACE": LOG_TRACE,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Logger constructor
|
|
||||||
func _init():
|
|
||||||
# Open logfile in write mode
|
|
||||||
log_file = File.new()
|
|
||||||
|
|
||||||
# this is left alone as this constructor is called from escoria.gd's own
|
|
||||||
# constructor
|
|
||||||
var log_file_path = ProjectSettings.get_setting(
|
|
||||||
"escoria/debug/log_file_path"
|
|
||||||
)
|
|
||||||
var date = OS.get_datetime()
|
|
||||||
log_file_path = log_file_path.plus_file(LOG_FILE_FORMAT % [
|
|
||||||
str(date["year"]) + str(date["month"]) + str(date["day"]),
|
|
||||||
str(date["hour"]) + str(date["minute"]) + str(date["second"])
|
|
||||||
])
|
|
||||||
log_file.open(
|
|
||||||
log_file_path,
|
|
||||||
File.WRITE
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Log a trace message
|
|
||||||
#
|
|
||||||
# Global variables can be substituted into the text by wrapping the global
|
|
||||||
# name in braces.
|
|
||||||
# e.g. trace "There are {coin_count} coins remaining".
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * string: Text to log
|
|
||||||
# * args: Additional information
|
|
||||||
func trace(string: String, args = []):
|
|
||||||
if _get_log_level() >= LOG_TRACE and !crashed:
|
|
||||||
var argsstr = str(args) if !args.empty() else ""
|
|
||||||
string = escoria.esc_compiler.replace_globals(string)
|
|
||||||
_log("(T)\t" + string + " \t" + argsstr)
|
|
||||||
|
|
||||||
|
|
||||||
# Log a debug message
|
|
||||||
#
|
|
||||||
# Global variables can be substituted into the text by wrapping the global
|
|
||||||
# name in braces.
|
|
||||||
# e.g. debug "There are {coin_count} coins remaining".
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * string: Text to log
|
|
||||||
# * args: Additional information
|
|
||||||
func debug(string: String, args = []):
|
|
||||||
if _get_log_level() >= LOG_DEBUG and !crashed:
|
|
||||||
string = escoria.esc_compiler.replace_globals(string)
|
|
||||||
var argsstr = str(args) if !args.empty() else ""
|
|
||||||
_log("(D)\t" + string + " \t" + argsstr)
|
|
||||||
|
|
||||||
# Log an info message
|
|
||||||
#
|
|
||||||
# Global variables can be substituted into the text by wrapping the global
|
|
||||||
# name in braces.
|
|
||||||
# e.g. info "There are {coin_count} coins remaining".
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * string: Text to log
|
|
||||||
# * args: Additional information
|
|
||||||
func info(string: String, args = []):
|
|
||||||
if _get_log_level() >= LOG_INFO and !crashed:
|
|
||||||
var argsstr = []
|
|
||||||
if !args.empty():
|
|
||||||
for arg in args:
|
|
||||||
if arg is Array:
|
|
||||||
for p in arg:
|
|
||||||
argsstr.append(p.global_id)
|
|
||||||
else:
|
|
||||||
argsstr.append(str(arg))
|
|
||||||
string = escoria.esc_compiler.replace_globals(string)
|
|
||||||
_log("(I)\t" + string + " \t" + str(argsstr))
|
|
||||||
|
|
||||||
|
|
||||||
# Log a warning message
|
|
||||||
#
|
|
||||||
# Global variables can be substituted into the text by wrapping the global
|
|
||||||
# name in braces.
|
|
||||||
# e.g. warning "There are {coin_count} coins remaining".
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * string: Text to log
|
|
||||||
# * args: Additional information
|
|
||||||
func warning(string: String, args = []):
|
|
||||||
if _get_log_level() >= LOG_WARNING and !crashed:
|
|
||||||
var argsstr = str(args) if !args.empty() else ""
|
|
||||||
string = escoria.esc_compiler.replace_globals(string)
|
|
||||||
_log("(W)\t" + string + " \t" + argsstr, true)
|
|
||||||
|
|
||||||
if escoria.project_settings_manager.get_setting(
|
|
||||||
escoria.project_settings_manager.TERMINATE_ON_WARNINGS
|
|
||||||
):
|
|
||||||
_perform_stack_trace_log()
|
|
||||||
crashed = true
|
|
||||||
|
|
||||||
var files = "- %s" % log_file.get_path_absolute()
|
|
||||||
var message = escoria.project_settings_manager.get_setting(
|
|
||||||
escoria.project_settings_manager.CRASH_MESSAGE
|
|
||||||
) % files
|
|
||||||
|
|
||||||
_log(message, true)
|
|
||||||
escoria.set_game_paused(true)
|
|
||||||
escoria.main.current_scene.game.show_crash_popup(
|
|
||||||
[log_file.get_path_absolute()]
|
|
||||||
)
|
|
||||||
assert(false)
|
|
||||||
|
|
||||||
|
|
||||||
# Log an error message
|
|
||||||
#
|
|
||||||
# Global variables can be substituted into the text by wrapping the global
|
|
||||||
# name in braces.
|
|
||||||
# e.g. error "There are {coin_count} coins remaining".
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * string: Text to log
|
|
||||||
# * args: Additional information
|
|
||||||
func error(string: String, args = [], do_savegame: bool = true):
|
|
||||||
if _get_log_level() >= LOG_ERROR and !crashed:
|
|
||||||
var argsstr = str(args) if !args.empty() else ""
|
|
||||||
string = escoria.esc_compiler.replace_globals(string)
|
|
||||||
_log("(E)\t" + string + " \t" + argsstr, true)
|
|
||||||
|
|
||||||
if escoria.project_settings_manager.get_setting(
|
|
||||||
escoria.project_settings_manager.TERMINATE_ON_ERRORS
|
|
||||||
):
|
|
||||||
_perform_stack_trace_log()
|
|
||||||
crashed = true
|
|
||||||
if do_savegame:
|
|
||||||
_perform_save_game_log()
|
|
||||||
|
|
||||||
var files_to_send: Array = [
|
|
||||||
log_file.get_path_absolute().get_base_dir().plus_file(
|
|
||||||
escoria.save_manager.crash_savegame_filename.get_file()
|
|
||||||
),
|
|
||||||
log_file.get_path_absolute()
|
|
||||||
]
|
|
||||||
|
|
||||||
var files = "- %s\n- %s" % files_to_send
|
|
||||||
var message = escoria.project_settings_manager.get_setting(
|
|
||||||
escoria.project_settings_manager.CRASH_MESSAGE
|
|
||||||
) % files
|
|
||||||
|
|
||||||
_log(message, true)
|
|
||||||
escoria.set_game_paused(true)
|
|
||||||
|
|
||||||
if is_instance_valid(escoria.main.current_scene):
|
|
||||||
escoria.main.current_scene.game.show_crash_popup(files_to_send)
|
|
||||||
|
|
||||||
assert(false)
|
|
||||||
|
|
||||||
|
|
||||||
# Log a warning message about an ESC file
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * p_path: Path to the file
|
|
||||||
# * warnings: Array of warnings to put out
|
|
||||||
# * report_once: Additional messages about the same file will be ignored
|
|
||||||
func report_warnings(p_path: String, warnings: Array, report_once = false) -> void:
|
|
||||||
var warning_is_reported = false
|
|
||||||
if p_path == warning_path:
|
|
||||||
warning_is_reported = true
|
|
||||||
|
|
||||||
if !warning_is_reported:
|
|
||||||
var text = "Warnings in file "+p_path+"\n"
|
|
||||||
for w in warnings:
|
|
||||||
if w is Array:
|
|
||||||
text += str(w)+"\n"
|
|
||||||
else:
|
|
||||||
text += w+"\n"
|
|
||||||
warning(text)
|
|
||||||
|
|
||||||
if report_once:
|
|
||||||
warning_is_reported = true
|
|
||||||
|
|
||||||
|
|
||||||
# Log an error message about an ESC file
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * p_path: Path to the file
|
|
||||||
# * errors: Array of errors to put out
|
|
||||||
func report_errors(p_path: String, errors: Array) -> void:
|
|
||||||
var text = "Errors in file "+p_path+"\n"
|
|
||||||
for e in errors:
|
|
||||||
if e is Array:
|
|
||||||
text += str(e)+"\n"
|
|
||||||
else:
|
|
||||||
text += e+"\n"
|
|
||||||
error(text)
|
|
||||||
|
|
||||||
|
|
||||||
# Write message:
|
|
||||||
# - in logfile
|
|
||||||
# - in stdout, or stderr if err is true.
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * message: Message to log
|
|
||||||
# * err: if true, write in stderr
|
|
||||||
func _log(message:String, err: bool = false):
|
|
||||||
message = "ESC {0} {1}".format([_formatted_date(), message])
|
|
||||||
|
|
||||||
if err:
|
|
||||||
printerr(message)
|
|
||||||
else:
|
|
||||||
print(message)
|
|
||||||
_write_logfile(message)
|
|
||||||
|
|
||||||
|
|
||||||
# Returns the current date/time, as a string
|
|
||||||
# formatted for logging. E.g. 2022-04-19T16:10:39
|
|
||||||
func _formatted_date() -> String:
|
|
||||||
var info = OS.get_datetime()
|
|
||||||
info["year"] = "%04d" % info["year"]
|
|
||||||
info["month"] = "%02d" % info["month"]
|
|
||||||
info["day"] = "%02d" % info["day"]
|
|
||||||
info["hour"] = "%02d" % info["hour"]
|
|
||||||
info["minute"] = "%02d" % info["minute"]
|
|
||||||
info["second"] = "%02d" % info["second"]
|
|
||||||
|
|
||||||
return "{year}-{month}-{day}T{hour}:{minute}:{second}".format(info)
|
|
||||||
|
|
||||||
|
|
||||||
# Returns the currently set log level
|
|
||||||
# **Returns** Log level as set in the configuration
|
|
||||||
func _get_log_level() -> int:
|
|
||||||
return _level_map[escoria.project_settings_manager.get_setting(
|
|
||||||
escoria.project_settings_manager.LOG_LEVEL
|
|
||||||
)]
|
|
||||||
|
|
||||||
|
|
||||||
# Creates a savegame file and save it in output log location
|
|
||||||
func _perform_save_game_log():
|
|
||||||
_log("Performing emergency savegame.")
|
|
||||||
var error = escoria.save_manager.save_game_crash()
|
|
||||||
if error == OK:
|
|
||||||
_log(
|
|
||||||
"Emergency savegame created successfully in folder: %s" %
|
|
||||||
escoria.project_settings_manager.get_setting(
|
|
||||||
escoria.project_settings_manager.LOG_FILE_PATH
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
_log("Emergency savegame creation failed!", false)
|
|
||||||
|
|
||||||
|
|
||||||
# Logs and writes the stack trace into stdout and log file.
|
|
||||||
func _perform_stack_trace_log():
|
|
||||||
_log("Stack trace:")
|
|
||||||
print_stack()
|
|
||||||
_write_stack_logfile()
|
|
||||||
|
|
||||||
|
|
||||||
# Write a message in the output logfile
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * message: Message to write
|
|
||||||
func _write_logfile(message: String) -> void:
|
|
||||||
if log_file.is_open():
|
|
||||||
log_file.store_string(message + "\n")
|
|
||||||
|
|
||||||
|
|
||||||
# Write the stacktrace in the output logfile
|
|
||||||
func _write_stack_logfile():
|
|
||||||
var frame_number = 0
|
|
||||||
for stack in get_stack().slice(2, get_stack().size()):
|
|
||||||
_write_logfile(
|
|
||||||
"Frame %s - %s:%s in function '%s'" % [
|
|
||||||
str(frame_number),
|
|
||||||
stack["source"],
|
|
||||||
stack["line"],
|
|
||||||
stack["function"],
|
|
||||||
]
|
|
||||||
)
|
|
||||||
frame_number += 1
|
|
||||||
|
|
||||||
|
|
||||||
# Close the log file cleanly
|
|
||||||
func close_logs():
|
|
||||||
_log("Closing logs peacefully.")
|
|
||||||
log_file.close()
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Base class for all migration version scripts. Extending scripts should be
|
# Base class for all migration version scripts. Extending scripts should be
|
||||||
# named like the version they migrate the savegame to. (e.g. 1.0.0.gd, 1.0.1.gd)
|
# named like the version they migrate the savegame to. (e.g. 1.0.0.gd, 1.0.1.gd)
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCMigration
|
class_name ESCMigration
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Class that handles migrations between different game or escoria versions
|
# Class that handles migrations between different game or escoria versions
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCMigrationManager
|
class_name ESCMigrationManager
|
||||||
|
|
||||||
|
|
||||||
@@ -29,10 +29,11 @@ func migrate(
|
|||||||
to: String,
|
to: String,
|
||||||
versions_directory: String
|
versions_directory: String
|
||||||
) -> ESCSaveGame:
|
) -> ESCSaveGame:
|
||||||
escoria.logger.info("Migrating from version %s to %s" % [
|
escoria.logger.info(
|
||||||
from,
|
self,
|
||||||
to
|
"Migrating savegame from version %s to version %s."
|
||||||
])
|
% [from, to]
|
||||||
|
)
|
||||||
|
|
||||||
var from_info = version_regex.search(from)
|
var from_info = version_regex.search(from)
|
||||||
var to_info = version_regex.search(to)
|
var to_info = version_regex.search(to)
|
||||||
@@ -49,14 +50,11 @@ func migrate(
|
|||||||
wrong_version = true
|
wrong_version = true
|
||||||
|
|
||||||
if wrong_version:
|
if wrong_version:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_migration_manager:migrate",
|
self,
|
||||||
[
|
"Can not migrate savegame from version %s to version %s." +
|
||||||
"Can not migrate savegame from version %s to version %s" % [
|
" \"To\" version must be later than \"from\" version."
|
||||||
from,
|
% [from, to]
|
||||||
to
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var versions = _find_versions(versions_directory, from, to)
|
var versions = _find_versions(versions_directory, from, to)
|
||||||
@@ -67,13 +65,14 @@ func migrate(
|
|||||||
for version in versions:
|
for version in versions:
|
||||||
var migration_script = load(version).new()
|
var migration_script = load(version).new()
|
||||||
if not migration_script is ESCMigration:
|
if not migration_script is ESCMigration:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_migration_manager:migrate",
|
self,
|
||||||
[
|
"File %s is not a valid migration script." % version
|
||||||
"File %s is not a valid migration script" % version
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
escoria.logger.debug("Migrating using %s" % version)
|
escoria.logger.debug(
|
||||||
|
self,
|
||||||
|
"Migrating savegame to version %s." % version
|
||||||
|
)
|
||||||
(migration_script as ESCMigration).set_savegame(savegame)
|
(migration_script as ESCMigration).set_savegame(savegame)
|
||||||
(migration_script as ESCMigration).migrate()
|
(migration_script as ESCMigration).migrate()
|
||||||
savegame = (migration_script as ESCMigration).get_savegame()
|
savegame = (migration_script as ESCMigration).get_savegame()
|
||||||
@@ -90,7 +89,10 @@ func migrate(
|
|||||||
# - to: End version to check
|
# - to: End version to check
|
||||||
# **Returns** A list of version scripts
|
# **Returns** A list of version scripts
|
||||||
func _find_versions(directory: String, from: String, to: String) -> Array:
|
func _find_versions(directory: String, from: String, to: String) -> Array:
|
||||||
escoria.logger.trace("Searching directory %s" % directory)
|
escoria.logger.trace(
|
||||||
|
self,
|
||||||
|
"Searching directory %s." % directory
|
||||||
|
)
|
||||||
var versions = []
|
var versions = []
|
||||||
var dir = Directory.new()
|
var dir = Directory.new()
|
||||||
dir.open(directory)
|
dir.open(directory)
|
||||||
@@ -106,7 +108,10 @@ func _find_versions(directory: String, from: String, to: String) -> Array:
|
|||||||
to
|
to
|
||||||
)
|
)
|
||||||
elif regex_result and _version_between(version, from, to):
|
elif regex_result and _version_between(version, from, to):
|
||||||
escoria.logger.trace("Found fitting migration script %s" % version)
|
escoria.logger.trace(
|
||||||
|
self,
|
||||||
|
"Found compatible savegame migration script for version %s." % version
|
||||||
|
)
|
||||||
versions.append(
|
versions.append(
|
||||||
directory.plus_file(file_name)
|
directory.plus_file(file_name)
|
||||||
)
|
)
|
||||||
|
|||||||
102
addons/escoria-core/game/core-scripts/plugins/escoria_plugin.gd
Normal file
102
addons/escoria-core/game/core-scripts/plugins/escoria_plugin.gd
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
class_name EscoriaPlugin
|
||||||
|
|
||||||
|
# Register a user interface. This should be called in a deferred way
|
||||||
|
# from the addon's _enter_tree.
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - plugin: the plugin that registers
|
||||||
|
# - game_scene: Path to the game scene extending ESCGame
|
||||||
|
#
|
||||||
|
# *Returns* a boolean indicating whether the ui could be successfully registered
|
||||||
|
static func register_ui(plugin: EditorPlugin, game_scene: String) -> bool:
|
||||||
|
if not plugin.get_editor_interface().is_plugin_enabled(
|
||||||
|
Escoria.ESCORIA_CORE_PLUGIN_NAME
|
||||||
|
):
|
||||||
|
push_error("Escoria Core must be enabled.")
|
||||||
|
return false
|
||||||
|
|
||||||
|
var game_scene_setting_value = ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.GAME_SCENE
|
||||||
|
)
|
||||||
|
|
||||||
|
if not game_scene_setting_value in [
|
||||||
|
"",
|
||||||
|
game_scene
|
||||||
|
]:
|
||||||
|
push_error("Can't register user interface because user interface %s is registered."
|
||||||
|
% game_scene_setting_value
|
||||||
|
)
|
||||||
|
return false
|
||||||
|
ESCProjectSettingsManager.set_setting(
|
||||||
|
ESCProjectSettingsManager.GAME_SCENE,
|
||||||
|
game_scene
|
||||||
|
)
|
||||||
|
return true
|
||||||
|
|
||||||
|
# Deregister a user interface
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - game_scene: Path to the game scene extending ESCGame
|
||||||
|
static func deregister_ui(game_scene: String):
|
||||||
|
# If the currently configured game scene is not the one we're disabling, exit now.
|
||||||
|
if ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.GAME_SCENE
|
||||||
|
) != game_scene:
|
||||||
|
return
|
||||||
|
|
||||||
|
ESCProjectSettingsManager.set_setting(
|
||||||
|
ESCProjectSettingsManager.GAME_SCENE,
|
||||||
|
""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Register a dialog manager addon. This should be called in a deferred way
|
||||||
|
# from the addon's _enter_tree.
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - plugin: the plugin that registers
|
||||||
|
# - manager_class: Path to the manager class script
|
||||||
|
#
|
||||||
|
# *Returns* a boolean value indicating whether the dialog manager was registered
|
||||||
|
static func register_dialog_manager(plugin: EditorPlugin, manager_class: String) -> bool:
|
||||||
|
if not plugin.get_editor_interface().is_plugin_enabled(
|
||||||
|
Escoria.ESCORIA_CORE_PLUGIN_NAME
|
||||||
|
):
|
||||||
|
push_error("Escoria Core must be enabled.")
|
||||||
|
return false
|
||||||
|
|
||||||
|
var dialog_managers: Array = ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.DIALOG_MANAGERS
|
||||||
|
)
|
||||||
|
|
||||||
|
if manager_class in dialog_managers:
|
||||||
|
return true
|
||||||
|
|
||||||
|
dialog_managers.push_back(manager_class)
|
||||||
|
|
||||||
|
ESCProjectSettingsManager.set_setting(
|
||||||
|
ESCProjectSettingsManager.DIALOG_MANAGERS,
|
||||||
|
dialog_managers
|
||||||
|
)
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
# Deregister a dialog manager addon
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - manager_class: Path to the manager class script
|
||||||
|
static func deregister_dialog_manager(manager_class: String):
|
||||||
|
var dialog_managers: Array = ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.DIALOG_MANAGERS
|
||||||
|
)
|
||||||
|
|
||||||
|
# If the dialog manager we're removing in not in the registered list, return quietly.
|
||||||
|
if not manager_class in dialog_managers:
|
||||||
|
return
|
||||||
|
|
||||||
|
dialog_managers.erase(manager_class)
|
||||||
|
|
||||||
|
ESCProjectSettingsManager.set_setting(
|
||||||
|
ESCProjectSettingsManager.DIALOG_MANAGERS,
|
||||||
|
dialog_managers
|
||||||
|
)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Describes a resource for use in the resource cache
|
# Describes a resource for use in the resource cache
|
||||||
extends Object
|
extends Resource
|
||||||
class_name ESCResourceDescriptor
|
class_name ESCResourceDescriptor
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ func get_saves_list() -> Dictionary:
|
|||||||
var save_game_res: Resource = load(save_path)
|
var save_game_res: Resource = load(save_path)
|
||||||
|
|
||||||
if save_game_res == null:
|
if save_game_res == null:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_save_manager.gd",
|
self,
|
||||||
["Savegame file %s is corrupted. Skipping." % save_path]
|
"Savegame file %s is corrupted. Skipping." % save_path
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
var save_game_data = {
|
var save_game_data = {
|
||||||
@@ -91,12 +91,10 @@ func get_saves_list() -> Dictionary:
|
|||||||
if matches != null and matches.get_string("slotnumber") != null:
|
if matches != null and matches.get_string("slotnumber") != null:
|
||||||
saves[int(matches.get_string("slotnumber"))] = save_game_data
|
saves[int(matches.get_string("slotnumber"))] = save_game_data
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_save_manager.gd",
|
self,
|
||||||
[
|
"Savegame file %s contains valid data but doesn't match filename format %s. Skipping."
|
||||||
"Savegame file %s contains valid data but doesn't match filename format %s. Skipping."
|
% [save_path, regex.get_pattern()]
|
||||||
% [save_path, regex.get_pattern()]
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
nextfile = dirsave.get_next()
|
nextfile = dirsave.get_next()
|
||||||
return saves
|
return saves
|
||||||
@@ -121,8 +119,9 @@ func save_game_exists(id: int) -> bool:
|
|||||||
func save_game(id: int, p_savename: String):
|
func save_game(id: int, p_savename: String):
|
||||||
if not save_enabled:
|
if not save_enabled:
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(
|
||||||
"esc_save_manager.gd",
|
self,
|
||||||
["Save requested while saving is not possible. Save canceled."])
|
"Save requested while saving is not possible. Save cancelled."
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
var save_game := _do_save_game(p_savename)
|
var save_game := _do_save_game(p_savename)
|
||||||
@@ -134,9 +133,9 @@ func save_game(id: int, p_savename: String):
|
|||||||
var save_path = save_folder.plus_file(SAVE_NAME_TEMPLATE % id)
|
var save_path = save_folder.plus_file(SAVE_NAME_TEMPLATE % id)
|
||||||
var error: int = ResourceSaver.save(save_path, save_game)
|
var error: int = ResourceSaver.save(save_path, save_game)
|
||||||
if error != OK:
|
if error != OK:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_save_manager.gd",
|
self,
|
||||||
["There was an issue writing the save %s to %s" % [id, save_path]]
|
"There was an issue writing savegame number %s to %s." % [id, save_path]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -153,8 +152,8 @@ func save_game_crash():
|
|||||||
|
|
||||||
var save_game := _do_save_game("Crash %s" % datetime_string)
|
var save_game := _do_save_game("Crash %s" % datetime_string)
|
||||||
|
|
||||||
var save_file_path: String = escoria.project_settings_manager.get_setting(
|
var save_file_path: String = ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.LOG_FILE_PATH
|
ESCProjectSettingsManager.LOG_FILE_PATH
|
||||||
)
|
)
|
||||||
crash_savegame_filename = save_file_path.plus_file(
|
crash_savegame_filename = save_file_path.plus_file(
|
||||||
CRASH_SAVE_NAME_TEMPLATE % [
|
CRASH_SAVE_NAME_TEMPLATE % [
|
||||||
@@ -167,10 +166,11 @@ func save_game_crash():
|
|||||||
|
|
||||||
var error: int = ResourceSaver.save(crash_savegame_filename, save_game)
|
var error: int = ResourceSaver.save(crash_savegame_filename, save_game)
|
||||||
if error != OK:
|
if error != OK:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_save_manager.gd",
|
self,
|
||||||
["There was an issue writing the crash save to %s"
|
"There was an issue writing the crash save to %s."
|
||||||
% crash_savegame_filename])
|
% crash_savegame_filename
|
||||||
|
)
|
||||||
return error
|
return error
|
||||||
|
|
||||||
|
|
||||||
@@ -185,8 +185,8 @@ func _do_save_game(p_savename: String) -> ESCSaveGame:
|
|||||||
plugin_config.load("res://addons/escoria-core/plugin.cfg")
|
plugin_config.load("res://addons/escoria-core/plugin.cfg")
|
||||||
save_game.escoria_version = plugin_config.get_value("plugin", "version")
|
save_game.escoria_version = plugin_config.get_value("plugin", "version")
|
||||||
|
|
||||||
save_game.game_version = escoria.project_settings_manager.get_setting(
|
save_game.game_version = ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.GAME_VERSION
|
ESCProjectSettingsManager.GAME_VERSION
|
||||||
)
|
)
|
||||||
save_game.name = p_savename
|
save_game.name = p_savename
|
||||||
|
|
||||||
@@ -216,14 +216,16 @@ func load_game(id: int):
|
|||||||
var save_file_path: String = save_folder.plus_file(SAVE_NAME_TEMPLATE % id)
|
var save_file_path: String = save_folder.plus_file(SAVE_NAME_TEMPLATE % id)
|
||||||
var file: File = File.new()
|
var file: File = File.new()
|
||||||
if not file.file_exists(save_file_path):
|
if not file.file_exists(save_file_path):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_save_manager.gd:load_game()",
|
self,
|
||||||
["Save file %s doesn't exist" % save_file_path])
|
"Save file %s doesn't exist." % save_file_path
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"esc_save_manager.gd:load_game()",
|
self,
|
||||||
["Loading savegame %s" % str(id)])
|
"Loading savegame %s." % str(id)
|
||||||
|
)
|
||||||
|
|
||||||
var save_game: ESCSaveGame = ResourceLoader.load(save_file_path)
|
var save_game: ESCSaveGame = ResourceLoader.load(save_file_path)
|
||||||
|
|
||||||
@@ -243,21 +245,21 @@ func load_game(id: int):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Migrate savegame through game versions
|
# Migrate savegame through game versions
|
||||||
if escoria.project_settings_manager.get_setting(
|
if ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.GAME_VERSION
|
ESCProjectSettingsManager.GAME_VERSION
|
||||||
) != save_game.game_version \
|
) != save_game.game_version \
|
||||||
and escoria.project_settings_manager.get_setting(
|
and ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.GAME_MIGRATION_PATH
|
ESCProjectSettingsManager.GAME_MIGRATION_PATH
|
||||||
) != "":
|
) != "":
|
||||||
var migration_manager: ESCMigrationManager = ESCMigrationManager.new()
|
var migration_manager: ESCMigrationManager = ESCMigrationManager.new()
|
||||||
save_game = migration_manager.migrate(
|
save_game = migration_manager.migrate(
|
||||||
save_game,
|
save_game,
|
||||||
save_game.game_version,
|
save_game.game_version,
|
||||||
escoria.project_settings_manager.get_setting(
|
ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.GAME_VERSION
|
ESCProjectSettingsManager.GAME_VERSION
|
||||||
),
|
),
|
||||||
escoria.project_settings_manager.get_setting(
|
ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.GAME_MIGRATION_PATH
|
ESCProjectSettingsManager.GAME_MIGRATION_PATH
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -271,8 +273,8 @@ func load_game(id: int):
|
|||||||
"%s %s out" %
|
"%s %s out" %
|
||||||
[
|
[
|
||||||
_transition.get_command_name(),
|
_transition.get_command_name(),
|
||||||
escoria.project_settings_manager.get_setting(
|
ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.DEFAULT_TRANSITION
|
ESCProjectSettingsManager.DEFAULT_TRANSITION
|
||||||
)]
|
)]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -391,8 +393,8 @@ func load_game(id: int):
|
|||||||
"%s %s in" %
|
"%s %s in" %
|
||||||
[
|
[
|
||||||
_transition.get_command_name(),
|
_transition.get_command_name(),
|
||||||
escoria.project_settings_manager.get_setting(
|
ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.DEFAULT_TRANSITION
|
ESCProjectSettingsManager.DEFAULT_TRANSITION
|
||||||
)]
|
)]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -402,9 +404,7 @@ func load_game(id: int):
|
|||||||
escoria.set_game_paused(false)
|
escoria.set_game_paused(false)
|
||||||
|
|
||||||
escoria.event_manager.queue_event(load_event)
|
escoria.event_manager.queue_event(load_event)
|
||||||
escoria.logger.debug(
|
escoria.logger.debug(self, "Load event queued.")
|
||||||
"esc_save_manager.gd:load_game()",
|
|
||||||
["Load event queued."])
|
|
||||||
|
|
||||||
|
|
||||||
# Save the game settings in the settings file.
|
# Save the game settings in the settings file.
|
||||||
@@ -432,9 +432,9 @@ func save_settings():
|
|||||||
var save_path = settings_folder.plus_file(SETTINGS_TEMPLATE)
|
var save_path = settings_folder.plus_file(SETTINGS_TEMPLATE)
|
||||||
var error: int = ResourceSaver.save(save_path, settings_res)
|
var error: int = ResourceSaver.save(save_path, settings_res)
|
||||||
if error != OK:
|
if error != OK:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_save_manager.gd:save_settings()",
|
"esc_save_manager.gd:save_settings()",
|
||||||
["There was an issue writing settings %s" % save_path])
|
["There was an issue writing settings file %s." % save_path])
|
||||||
|
|
||||||
|
|
||||||
# Load the game settings from the settings file
|
# Load the game settings from the settings file
|
||||||
@@ -444,10 +444,11 @@ func load_settings() -> Resource:
|
|||||||
settings_folder.plus_file(SETTINGS_TEMPLATE)
|
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.warn(
|
||||||
"esc_save_manager.gd:load_settings()",
|
self,
|
||||||
["Settings file %s doesn't exist" % save_settings_path,
|
"Settings file %s doesn't exist. Using default settings."
|
||||||
"Setting default settings."])
|
% save_settings_path
|
||||||
|
)
|
||||||
save_settings()
|
save_settings()
|
||||||
|
|
||||||
return load(save_settings_path)
|
return load(save_settings_path)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# A set of common utilities
|
# A set of common utilities
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCUtils
|
class_name ESCUtils
|
||||||
|
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ class_name ESCUtils
|
|||||||
#
|
#
|
||||||
# - rad_angle: Angle in radians
|
# - rad_angle: Angle in radians
|
||||||
# **Returns** Degrees
|
# **Returns** Degrees
|
||||||
func get_deg_from_rad(rad_angle: float):
|
static func get_deg_from_rad(rad_angle: float):
|
||||||
var deg = rad2deg(rad_angle)
|
var deg = rad2deg(rad_angle)
|
||||||
if deg >= 360.0:
|
if deg >= 360.0:
|
||||||
deg = clamp(deg, 0.0, 360.0)
|
deg = clamp(deg, 0.0, 360.0)
|
||||||
@@ -25,7 +25,7 @@ func get_deg_from_rad(rad_angle: float):
|
|||||||
# - re_match: The RegExMatch object
|
# - re_match: The RegExMatch object
|
||||||
# - group: The name of the group
|
# - group: The name of the group
|
||||||
# **Returns** The value of the named regex group in the match
|
# **Returns** The value of the named regex group in the match
|
||||||
func get_re_group(re_match: RegExMatch, group: String) -> String:
|
static func get_re_group(re_match: RegExMatch, group: String) -> String:
|
||||||
if group in re_match.names:
|
if group in re_match.names:
|
||||||
return re_match.strings[re_match.names[group]]
|
return re_match.strings[re_match.names[group]]
|
||||||
else:
|
else:
|
||||||
@@ -39,7 +39,7 @@ func get_re_group(re_match: RegExMatch, group: String) -> String:
|
|||||||
# - value: The original value
|
# - value: The original value
|
||||||
# - type_hint: The type it should be
|
# - type_hint: The type it should be
|
||||||
# **Returns** The typed value according to the type inference
|
# **Returns** The typed value according to the type inference
|
||||||
func get_typed_value(value: String, type_hint = []):
|
static func get_typed_value(value: String, type_hint = []):
|
||||||
var regex_bool = RegEx.new()
|
var regex_bool = RegEx.new()
|
||||||
regex_bool.compile("^true|false$")
|
regex_bool.compile("^true|false$")
|
||||||
var regex_float = RegEx.new()
|
var regex_float = RegEx.new()
|
||||||
@@ -68,7 +68,7 @@ func get_typed_value(value: String, type_hint = []):
|
|||||||
#
|
#
|
||||||
# - value: String to work on
|
# - value: String to work on
|
||||||
# **Returns** the string with sanitized whitespaces
|
# **Returns** the string with sanitized whitespaces
|
||||||
func sanitize_whitespace(value: String) -> String:
|
static func sanitize_whitespace(value: String) -> String:
|
||||||
var tab_regex = RegEx.new()
|
var tab_regex = RegEx.new()
|
||||||
tab_regex.compile("\\t")
|
tab_regex.compile("\\t")
|
||||||
var double_regex = RegEx.new()
|
var double_regex = RegEx.new()
|
||||||
|
|||||||
195
addons/escoria-core/game/esc_autoload.gd
Normal file
195
addons/escoria-core/game/esc_autoload.gd
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
# This is Escoria's singleton script.
|
||||||
|
# It holds accessors to some utils, such as Escoria's logger.
|
||||||
|
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
# Signal sent when Escoria is paused
|
||||||
|
signal paused
|
||||||
|
|
||||||
|
# Signal sent when Escoria is resumed from pause
|
||||||
|
signal resumed
|
||||||
|
|
||||||
|
|
||||||
|
# Current game state
|
||||||
|
# * DEFAULT: Common game function
|
||||||
|
# * DIALOG: Game is playing a dialog
|
||||||
|
# * WAIT: Game is waiting
|
||||||
|
enum GAME_STATE {
|
||||||
|
DEFAULT,
|
||||||
|
DIALOG,
|
||||||
|
WAIT
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Audio bus indices.
|
||||||
|
const BUS_MASTER = "Master"
|
||||||
|
const BUS_SFX = "SFX"
|
||||||
|
const BUS_MUSIC = "Music"
|
||||||
|
const BUS_SPEECH = "Speech"
|
||||||
|
|
||||||
|
# Path to camera scene
|
||||||
|
const CAMERA_SCENE_PATH = "res://addons/escoria-core/game/scenes/camera_player/camera.tscn"
|
||||||
|
|
||||||
|
|
||||||
|
# Logger class
|
||||||
|
const Logger = preload("res://addons/escoria-core/game/esc_logger.gd")
|
||||||
|
|
||||||
|
|
||||||
|
# Logger instance
|
||||||
|
var logger = Logger.ESCLoggerFile.new()
|
||||||
|
|
||||||
|
# ESC Compiler
|
||||||
|
var esc_compiler = ESCCompiler.new()
|
||||||
|
|
||||||
|
# ESC Object Manager
|
||||||
|
var object_manager = ESCObjectManager.new()
|
||||||
|
|
||||||
|
# ESC Room Manager
|
||||||
|
var room_manager = ESCRoomManager.new()
|
||||||
|
|
||||||
|
# Terrain of the current room
|
||||||
|
var room_terrain
|
||||||
|
|
||||||
|
# The inventory manager instance
|
||||||
|
var inventory_manager: ESCInventoryManager
|
||||||
|
|
||||||
|
# The action manager instance
|
||||||
|
var action_manager: ESCActionManager
|
||||||
|
|
||||||
|
# ESC Event manager instance
|
||||||
|
var event_manager: ESCEventManager
|
||||||
|
|
||||||
|
# ESC globals registry instance
|
||||||
|
var globals_manager: ESCGlobalsManager
|
||||||
|
|
||||||
|
# ESC command registry instance
|
||||||
|
var command_registry: ESCCommandRegistry
|
||||||
|
|
||||||
|
# Resource cache handler
|
||||||
|
var resource_cache: ESCResourceCache
|
||||||
|
|
||||||
|
# Dialog player instantiator. This instance is called directly for dialogs.
|
||||||
|
var dialog_player: ESCDialogPlayer
|
||||||
|
|
||||||
|
# Inventory scene
|
||||||
|
var inventory
|
||||||
|
|
||||||
|
# These are settings that the player can affect and save/load later
|
||||||
|
var settings: ESCSaveSettings
|
||||||
|
|
||||||
|
# The main scene
|
||||||
|
var main
|
||||||
|
|
||||||
|
# The escoria inputs manager
|
||||||
|
var inputs_manager: ESCInputsManager
|
||||||
|
|
||||||
|
# Savegames and settings manager
|
||||||
|
var save_manager: ESCSaveManager
|
||||||
|
|
||||||
|
# The game scene loaded
|
||||||
|
var game_scene: ESCGame
|
||||||
|
|
||||||
|
# The main player camera
|
||||||
|
var player_camera: ESCCamera
|
||||||
|
|
||||||
|
# The compiled start script loaded from ProjectSettings
|
||||||
|
# escoria/main/game_start_script
|
||||||
|
var start_script: ESCScript
|
||||||
|
|
||||||
|
# Whether we ran a room directly from editor, not a full game
|
||||||
|
var is_direct_room_run: bool = false
|
||||||
|
|
||||||
|
# Whether we're quitting the game
|
||||||
|
var is_quitting: bool = false
|
||||||
|
|
||||||
|
|
||||||
|
# The game resolution
|
||||||
|
onready var game_size = get_viewport().size
|
||||||
|
|
||||||
|
# The current state of the game
|
||||||
|
onready var current_state = GAME_STATE.DEFAULT
|
||||||
|
|
||||||
|
|
||||||
|
# Ready function
|
||||||
|
func _ready():
|
||||||
|
# We check if we run the full game or a room scene directly
|
||||||
|
if not get_tree().current_scene is ESCMain:
|
||||||
|
# Running a room scene. We need to instantiate the main scene ourselves
|
||||||
|
# so that the Escoria scene is created and managers are instanced as well.
|
||||||
|
is_direct_room_run = true
|
||||||
|
var main_scene = preload("res://addons/escoria-core/game/main_scene.tscn").instance()
|
||||||
|
add_child(main_scene)
|
||||||
|
|
||||||
|
|
||||||
|
# Get the Escoria node. That node gives access to the Escoria scene that's
|
||||||
|
# instanced by the main_scene (if full game is run) or by this autoload if
|
||||||
|
# room is run directly.
|
||||||
|
func get_escoria():
|
||||||
|
# We check if we run the full game or a room scene directly
|
||||||
|
if get_tree().current_scene is ESCMain:
|
||||||
|
return get_node("/root/main_scene").escoria_node
|
||||||
|
else:
|
||||||
|
return get_node("main_scene").escoria_node
|
||||||
|
|
||||||
|
|
||||||
|
# Pauses or unpause the game
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - p_paused: if true, pauses the game. If false, unpauses the game.
|
||||||
|
func set_game_paused(p_paused: bool):
|
||||||
|
if p_paused:
|
||||||
|
emit_signal("paused")
|
||||||
|
else:
|
||||||
|
emit_signal("resumed")
|
||||||
|
|
||||||
|
var scene_tree = get_tree()
|
||||||
|
|
||||||
|
if is_instance_valid(scene_tree):
|
||||||
|
scene_tree.paused = p_paused
|
||||||
|
|
||||||
|
|
||||||
|
# Apply the loaded settings
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
#
|
||||||
|
# * p_settings: Loaded settings
|
||||||
|
func apply_settings(p_settings: ESCSaveSettings) -> void:
|
||||||
|
if not Engine.is_editor_hint():
|
||||||
|
escoria.logger.info(self, "******* settings loaded")
|
||||||
|
if p_settings != null:
|
||||||
|
settings = p_settings
|
||||||
|
else:
|
||||||
|
settings = ESCSaveSettings.new()
|
||||||
|
|
||||||
|
AudioServer.set_bus_volume_db(
|
||||||
|
AudioServer.get_bus_index(BUS_MASTER),
|
||||||
|
linear2db(settings.master_volume)
|
||||||
|
)
|
||||||
|
AudioServer.set_bus_volume_db(
|
||||||
|
AudioServer.get_bus_index(BUS_SFX),
|
||||||
|
linear2db(settings.sfx_volume)
|
||||||
|
)
|
||||||
|
AudioServer.set_bus_volume_db(
|
||||||
|
AudioServer.get_bus_index(BUS_MUSIC),
|
||||||
|
linear2db(settings.music_volume)
|
||||||
|
)
|
||||||
|
AudioServer.set_bus_volume_db(
|
||||||
|
AudioServer.get_bus_index(BUS_SPEECH),
|
||||||
|
linear2db(settings.speech_volume)
|
||||||
|
)
|
||||||
|
TranslationServer.set_locale(settings.text_lang)
|
||||||
|
|
||||||
|
game_scene.apply_custom_settings(settings.custom_settings)
|
||||||
|
|
||||||
|
|
||||||
|
# Called from main menu's "new game" button
|
||||||
|
func new_game():
|
||||||
|
get_escoria().new_game()
|
||||||
|
|
||||||
|
|
||||||
|
# Called from main menu's "quit" button
|
||||||
|
func quit():
|
||||||
|
is_quitting = true
|
||||||
|
get_escoria().quit()
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Escoria inputs manager
|
# Escoria inputs manager
|
||||||
# Catches, handles and distributes input events for the game
|
# Catches, handles and distributes input events for the game
|
||||||
extends Node
|
extends Resource
|
||||||
class_name ESCInputsManager
|
class_name ESCInputsManager
|
||||||
|
|
||||||
|
|
||||||
@@ -166,7 +166,10 @@ func clear_stack():
|
|||||||
# - position: Position of the click
|
# - position: Position of the click
|
||||||
func _on_left_click_on_bg(position: Vector2) -> void:
|
func _on_left_click_on_bg(position: Vector2) -> void:
|
||||||
if input_mode == INPUT_ALL and hotspot_focused.empty():
|
if input_mode == INPUT_ALL and hotspot_focused.empty():
|
||||||
escoria.logger.info("Left click on background at ", [str(position)])
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Left click on background at %s." % str(position)
|
||||||
|
)
|
||||||
escoria.main.current_scene.game.left_click_on_bg(position)
|
escoria.main.current_scene.game.left_click_on_bg(position)
|
||||||
|
|
||||||
|
|
||||||
@@ -178,7 +181,8 @@ func _on_left_click_on_bg(position: Vector2) -> void:
|
|||||||
func _on_double_left_click_on_bg(position: Vector2) -> void:
|
func _on_double_left_click_on_bg(position: Vector2) -> void:
|
||||||
if input_mode == INPUT_ALL and hotspot_focused.empty():
|
if input_mode == INPUT_ALL and hotspot_focused.empty():
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"Double left click on background at %s" % str(position)
|
self,
|
||||||
|
"Double left click on background at %s." % str(position)
|
||||||
)
|
)
|
||||||
escoria.main.current_scene.game.left_double_click_on_bg(position)
|
escoria.main.current_scene.game.left_double_click_on_bg(position)
|
||||||
|
|
||||||
@@ -190,7 +194,10 @@ func _on_double_left_click_on_bg(position: Vector2) -> void:
|
|||||||
# - position: Position of the click
|
# - position: Position of the click
|
||||||
func _on_right_click_on_bg(position: Vector2) -> void:
|
func _on_right_click_on_bg(position: Vector2) -> void:
|
||||||
if input_mode == INPUT_ALL and hotspot_focused.empty():
|
if input_mode == INPUT_ALL and hotspot_focused.empty():
|
||||||
escoria.logger.info("Right click on background at ", [str(position)])
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Right click on background at %s." % str(position)
|
||||||
|
)
|
||||||
escoria.main.current_scene.game.right_click_on_bg(position)
|
escoria.main.current_scene.game.right_click_on_bg(position)
|
||||||
|
|
||||||
|
|
||||||
@@ -205,7 +212,8 @@ func _on_mouse_left_click_inventory_item(
|
|||||||
event: InputEvent
|
event: InputEvent
|
||||||
) -> void:
|
) -> void:
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"Inventory item left clicked %s " % inventory_item_global_id
|
self,
|
||||||
|
"Inventory item %s left clicked." % inventory_item_global_id
|
||||||
)
|
)
|
||||||
escoria.main.current_scene.game.left_click_on_inventory_item(
|
escoria.main.current_scene.game.left_click_on_inventory_item(
|
||||||
inventory_item_global_id,
|
inventory_item_global_id,
|
||||||
@@ -225,7 +233,8 @@ func _on_mouse_right_click_inventory_item(
|
|||||||
) -> void:
|
) -> void:
|
||||||
if input_mode == INPUT_ALL:
|
if input_mode == INPUT_ALL:
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"Inventory item right clicked %s" % inventory_item_global_id
|
self,
|
||||||
|
"Inventory item %s right clicked." % inventory_item_global_id
|
||||||
)
|
)
|
||||||
escoria.main.current_scene.game.right_click_on_inventory_item(
|
escoria.main.current_scene.game.right_click_on_inventory_item(
|
||||||
inventory_item_global_id,
|
inventory_item_global_id,
|
||||||
@@ -245,7 +254,8 @@ func _on_mouse_double_left_click_inventory_item(
|
|||||||
) -> void:
|
) -> void:
|
||||||
if input_mode == INPUT_ALL:
|
if input_mode == INPUT_ALL:
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"Inventory item double left clicked %s" % inventory_item_global_id
|
self,
|
||||||
|
"Inventory item %s double left clicked." % inventory_item_global_id
|
||||||
)
|
)
|
||||||
escoria.main.current_scene.game.left_double_click_on_inventory_item(
|
escoria.main.current_scene.game.left_double_click_on_inventory_item(
|
||||||
inventory_item_global_id,
|
inventory_item_global_id,
|
||||||
@@ -261,7 +271,8 @@ func _on_mouse_double_left_click_inventory_item(
|
|||||||
# that is hovered
|
# that is hovered
|
||||||
func _on_mouse_entered_inventory_item(inventory_item_global_id: String) -> void:
|
func _on_mouse_entered_inventory_item(inventory_item_global_id: String) -> void:
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"Inventory item focused %s" % inventory_item_global_id
|
self,
|
||||||
|
"Inventory item %s focused." % inventory_item_global_id
|
||||||
)
|
)
|
||||||
escoria.main.current_scene.game.inventory_item_focused(
|
escoria.main.current_scene.game.inventory_item_focused(
|
||||||
inventory_item_global_id
|
inventory_item_global_id
|
||||||
@@ -270,7 +281,10 @@ func _on_mouse_entered_inventory_item(inventory_item_global_id: String) -> void:
|
|||||||
|
|
||||||
# The mouse exited an inventory item
|
# The mouse exited an inventory item
|
||||||
func _on_mouse_exited_inventory_item() -> void:
|
func _on_mouse_exited_inventory_item() -> void:
|
||||||
escoria.logger.info("Inventory item unfocused")
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Inventory item unfocused."
|
||||||
|
)
|
||||||
escoria.main.current_scene.game.inventory_item_unfocused()
|
escoria.main.current_scene.game.inventory_item_unfocused()
|
||||||
|
|
||||||
|
|
||||||
@@ -280,7 +294,10 @@ func _on_mouse_exited_inventory_item() -> void:
|
|||||||
#
|
#
|
||||||
# - item: The Escoria item hovered
|
# - item: The Escoria item hovered
|
||||||
func _on_mouse_entered_item(item: ESCItem) -> void:
|
func _on_mouse_entered_item(item: ESCItem) -> void:
|
||||||
escoria.logger.info("Item focused: ", [item.global_id])
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Item focused: %s" % item.global_id
|
||||||
|
)
|
||||||
_clean_hover_stack()
|
_clean_hover_stack()
|
||||||
|
|
||||||
if not hover_stack.empty():
|
if not hover_stack.empty():
|
||||||
@@ -301,7 +318,10 @@ func _on_mouse_entered_item(item: ESCItem) -> void:
|
|||||||
#
|
#
|
||||||
# - item: The Escoria item hovered
|
# - item: The Escoria item hovered
|
||||||
func _on_mouse_exited_item(item: ESCItem) -> void:
|
func _on_mouse_exited_item(item: ESCItem) -> void:
|
||||||
escoria.logger.info("Item unfocused: ", [item.global_id])
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Item unfocused: %s" % item.global_id
|
||||||
|
)
|
||||||
_hover_stack_erase_item(item)
|
_hover_stack_erase_item(item)
|
||||||
if hover_stack.empty():
|
if hover_stack.empty():
|
||||||
hotspot_focused = ""
|
hotspot_focused = ""
|
||||||
@@ -320,7 +340,10 @@ func _on_mouse_exited_item(item: ESCItem) -> void:
|
|||||||
func _on_mouse_left_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
func _on_mouse_left_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||||
if input_mode == INPUT_ALL:
|
if input_mode == INPUT_ALL:
|
||||||
if hover_stack.empty() or hover_stack.back() == item:
|
if hover_stack.empty() or hover_stack.back() == item:
|
||||||
escoria.logger.info("Item left clicked", [item.global_id, event])
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Item %s left clicked with event %s." % [item.global_id, event]
|
||||||
|
)
|
||||||
hotspot_focused = item.global_id
|
hotspot_focused = item.global_id
|
||||||
escoria.main.current_scene.game.left_click_on_item(
|
escoria.main.current_scene.game.left_click_on_item(
|
||||||
item.global_id,
|
item.global_id,
|
||||||
@@ -339,7 +362,10 @@ func _on_mouse_left_double_clicked_item(
|
|||||||
event: InputEvent
|
event: InputEvent
|
||||||
) -> void:
|
) -> void:
|
||||||
if input_mode == INPUT_ALL:
|
if input_mode == INPUT_ALL:
|
||||||
escoria.logger.info("Item left double clicked", [item.global_id, event])
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Item %s left double clicked with event %s." % [item.global_id, event]
|
||||||
|
)
|
||||||
hotspot_focused = item.global_id
|
hotspot_focused = item.global_id
|
||||||
escoria.main.current_scene.game.left_double_click_on_item(
|
escoria.main.current_scene.game.left_double_click_on_item(
|
||||||
item.global_id,
|
item.global_id,
|
||||||
@@ -355,7 +381,10 @@ func _on_mouse_left_double_clicked_item(
|
|||||||
# - event: The input event from the click
|
# - event: The input event from the click
|
||||||
func _on_mouse_right_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
func _on_mouse_right_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||||
if input_mode == INPUT_ALL:
|
if input_mode == INPUT_ALL:
|
||||||
escoria.logger.info("Item right clicked", [item.global_id, event])
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Item %s right clicked with event %s." % [item.global_id, event]
|
||||||
|
)
|
||||||
hotspot_focused = item.global_id
|
hotspot_focused = item.global_id
|
||||||
escoria.main.current_scene.game.right_click_on_item(
|
escoria.main.current_scene.game.right_click_on_item(
|
||||||
item.global_id,
|
item.global_id,
|
||||||
195
addons/escoria-core/game/esc_logger.gd
Normal file
195
addons/escoria-core/game/esc_logger.gd
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
class ESCLoggerBase:
|
||||||
|
# Perform emergency savegame
|
||||||
|
signal perform_emergency_savegame
|
||||||
|
|
||||||
|
# Valid log levels
|
||||||
|
enum { LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG, LOG_TRACE }
|
||||||
|
|
||||||
|
# Log file format
|
||||||
|
const LOG_FILE_FORMAT: String = "log_%s_%s.log"
|
||||||
|
|
||||||
|
# A map of log level names to log level ints
|
||||||
|
var _level_map: Dictionary = {
|
||||||
|
"ERROR": LOG_ERROR,
|
||||||
|
"WARNING": LOG_WARNING,
|
||||||
|
"INFO": LOG_INFO,
|
||||||
|
"DEBUG": LOG_DEBUG,
|
||||||
|
"TRACE": LOG_TRACE,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configured log level
|
||||||
|
var _log_level: int
|
||||||
|
|
||||||
|
|
||||||
|
# Constructor
|
||||||
|
func _init():
|
||||||
|
_log_level = _level_map[ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.LOG_LEVEL
|
||||||
|
).to_upper()]
|
||||||
|
|
||||||
|
|
||||||
|
func formatted_message(context: String, msg: String, letter: String) -> String:
|
||||||
|
return "ESC ({0}) {1} {2}: {3}".format([_formatted_date(), letter, context, msg])
|
||||||
|
|
||||||
|
|
||||||
|
func trace(owner: Object, msg: String):
|
||||||
|
var context = owner.get_script().resource_path.get_file()
|
||||||
|
print(formatted_message(context, msg, "T"))
|
||||||
|
|
||||||
|
|
||||||
|
# Debug log
|
||||||
|
func debug(owner: Object, msg: String):
|
||||||
|
var context = owner.get_script().resource_path.get_file()
|
||||||
|
print(formatted_message(context, msg, "D"))
|
||||||
|
|
||||||
|
|
||||||
|
func info(owner: Object, msg: String):
|
||||||
|
var context = owner.get_script().resource_path.get_file()
|
||||||
|
print(formatted_message(context, msg, "I"))
|
||||||
|
|
||||||
|
|
||||||
|
# Warning log
|
||||||
|
func warn(owner: Object, msg: String):
|
||||||
|
var context = owner.get_script().resource_path.get_file()
|
||||||
|
print(formatted_message(context, msg, "W"))
|
||||||
|
push_warning(formatted_message(context, msg, "W"))
|
||||||
|
if ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.TERMINATE_ON_WARNINGS
|
||||||
|
):
|
||||||
|
assert(false)
|
||||||
|
escoria.get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
|
# Error log
|
||||||
|
func error(owner: Object, msg: String):
|
||||||
|
var context = owner.get_script().resource_path.get_file()
|
||||||
|
printerr(formatted_message(context, msg, "E"))
|
||||||
|
push_error(formatted_message(context, msg, "E"))
|
||||||
|
if ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.TERMINATE_ON_ERRORS
|
||||||
|
):
|
||||||
|
assert(false)
|
||||||
|
escoria.get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
|
func get_log_level() -> int:
|
||||||
|
return _log_level
|
||||||
|
|
||||||
|
func _formatted_date():
|
||||||
|
var info = OS.get_datetime()
|
||||||
|
info["year"] = "%04d" % info["year"]
|
||||||
|
info["month"] = "%02d" % info["month"]
|
||||||
|
info["day"] = "%02d" % info["day"]
|
||||||
|
info["hour"] = "%02d" % info["hour"]
|
||||||
|
info["minute"] = "%02d" % info["minute"]
|
||||||
|
info["second"] = "%02d" % info["second"]
|
||||||
|
return "{year}-{month}-{day}T{hour}:{minute}:{second}".format(info)
|
||||||
|
|
||||||
|
|
||||||
|
# A logger that logs to the terminal and to a log file.
|
||||||
|
class ESCLoggerFile extends ESCLoggerBase:
|
||||||
|
# Log file handler
|
||||||
|
var log_file: File
|
||||||
|
|
||||||
|
# Constructor
|
||||||
|
func _init():
|
||||||
|
# Open logfile in write mode
|
||||||
|
log_file = File.new()
|
||||||
|
|
||||||
|
# This is left alone as this constructor is called from escoria.gd's own
|
||||||
|
# constructor
|
||||||
|
var log_file_path = ProjectSettings.get_setting(
|
||||||
|
ESCProjectSettingsManager.LOG_FILE_PATH
|
||||||
|
)
|
||||||
|
var date = OS.get_datetime()
|
||||||
|
log_file_path = log_file_path.plus_file(LOG_FILE_FORMAT % [
|
||||||
|
str(date["year"]) + str(date["month"]) + str(date["day"]),
|
||||||
|
str(date["hour"]) + str(date["minute"]) + str(date["second"])
|
||||||
|
])
|
||||||
|
log_file.open(
|
||||||
|
log_file_path,
|
||||||
|
File.WRITE
|
||||||
|
)
|
||||||
|
|
||||||
|
func trace(owner: Object, msg: String):
|
||||||
|
if _log_level >= LOG_TRACE:
|
||||||
|
_log_to_file(owner, msg, "T")
|
||||||
|
.trace(owner, msg)
|
||||||
|
|
||||||
|
# Debug log
|
||||||
|
func debug(owner: Object, msg: String):
|
||||||
|
if _log_level >= LOG_DEBUG:
|
||||||
|
_log_to_file(owner, msg, "D")
|
||||||
|
.debug(owner, msg)
|
||||||
|
|
||||||
|
func info(owner: Object, msg: String):
|
||||||
|
if _log_level >= LOG_INFO:
|
||||||
|
_log_to_file(owner, msg, "I")
|
||||||
|
.info(owner, msg)
|
||||||
|
|
||||||
|
# Warning log
|
||||||
|
func warn(owner: Object, msg: String):
|
||||||
|
if _log_level >= LOG_WARNING:
|
||||||
|
_log_to_file(owner, msg, "W")
|
||||||
|
if ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.TERMINATE_ON_WARNINGS
|
||||||
|
):
|
||||||
|
_log_stack_trace_to_file(owner)
|
||||||
|
print_stack()
|
||||||
|
close_logs()
|
||||||
|
.warn(owner, msg)
|
||||||
|
|
||||||
|
# Error log
|
||||||
|
func error(owner: Object, msg: String):
|
||||||
|
if _log_level >= LOG_ERROR:
|
||||||
|
_log_to_file(owner, msg, "E")
|
||||||
|
if ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.TERMINATE_ON_ERRORS
|
||||||
|
):
|
||||||
|
_log_stack_trace_to_file(owner)
|
||||||
|
print_stack()
|
||||||
|
close_logs()
|
||||||
|
.error(owner, msg)
|
||||||
|
|
||||||
|
|
||||||
|
# Close the log file cleanly
|
||||||
|
func close_logs():
|
||||||
|
print("Closing logs peacefully.")
|
||||||
|
_log_line_to_file("Closing logs peacefully.")
|
||||||
|
log_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
func _log_to_file(owner: Object, msg: String, letter: String):
|
||||||
|
if log_file.is_open():
|
||||||
|
var context = ""
|
||||||
|
if owner != null:
|
||||||
|
context = owner.get_script().resource_path.get_file()
|
||||||
|
log_file.store_string(formatted_message(context, msg, letter) + "\n")
|
||||||
|
|
||||||
|
func _log_line_to_file(msg: String):
|
||||||
|
if log_file.is_open():
|
||||||
|
log_file.store_string(msg + "\n")
|
||||||
|
|
||||||
|
func _log_stack_trace_to_file(owner: Object):
|
||||||
|
var frame_number = 0
|
||||||
|
for stack in get_stack().slice(2, get_stack().size()):
|
||||||
|
_log_line_to_file(
|
||||||
|
"Frame %s - %s:%s in function '%s'" % [
|
||||||
|
str(frame_number),
|
||||||
|
stack["source"],
|
||||||
|
stack["line"],
|
||||||
|
stack["function"],
|
||||||
|
]
|
||||||
|
)
|
||||||
|
frame_number += 1
|
||||||
|
|
||||||
|
|
||||||
|
# A simple logger that logs to terminal using debug() function
|
||||||
|
class ESCLoggerVerbose extends ESCLoggerBase:
|
||||||
|
func _init():
|
||||||
|
pass
|
||||||
|
|
||||||
|
func debug(owner: Object, msg: String):
|
||||||
|
var context = owner.get_script().resource_path.get_file()
|
||||||
|
print(context, ": ", msg)
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Registers and allows access to Escoria-specific project settings.
|
# Registers and allows access to Escoria-specific project settings.
|
||||||
extends Node
|
extends Resource
|
||||||
class_name ESCProjectSettingsManager
|
class_name ESCProjectSettingsManager
|
||||||
|
|
||||||
|
|
||||||
@@ -75,14 +75,13 @@ const MAX_TIME_TO_DISAPPEAR = "%s/%s/max_time_to_disappear" % [_ESCORIA_SETTINGS
|
|||||||
# - name: Name of the project setting
|
# - name: Name of the project setting
|
||||||
# - default: Default value
|
# - default: Default value
|
||||||
# - info: Property info for the setting
|
# - info: Property info for the setting
|
||||||
func register_setting(name: String, default, info: Dictionary) -> void:
|
static func register_setting(name: String, default, info: Dictionary) -> void:
|
||||||
if not ProjectSettings.has_setting(name):
|
ProjectSettings.set_setting(
|
||||||
ProjectSettings.set_setting(
|
name,
|
||||||
name,
|
default
|
||||||
default
|
)
|
||||||
)
|
info.name = name
|
||||||
info.name = name
|
ProjectSettings.add_property_info(info)
|
||||||
ProjectSettings.add_property_info(info)
|
|
||||||
|
|
||||||
|
|
||||||
# Retrieves the specified project setting.
|
# Retrieves the specified project setting.
|
||||||
@@ -92,11 +91,10 @@ func register_setting(name: String, default, info: Dictionary) -> void:
|
|||||||
# - key: Project setting name.
|
# - key: Project setting name.
|
||||||
#
|
#
|
||||||
# *Returns* the value of the project setting located with key.
|
# *Returns* the value of the project setting located with key.
|
||||||
func get_setting(key: String):
|
static func get_setting(key: String):
|
||||||
if not ProjectSettings.has_setting(key):
|
if not ProjectSettings.has_setting(key):
|
||||||
escoria.logger.report_errors("project_settings_manager.gd",
|
push_error("Parameter %s is not set!" % key)
|
||||||
["Parameter %s is not set!" % key]
|
assert(false)
|
||||||
)
|
|
||||||
|
|
||||||
return ProjectSettings.get_setting(key)
|
return ProjectSettings.get_setting(key)
|
||||||
|
|
||||||
@@ -107,7 +105,7 @@ func get_setting(key: String):
|
|||||||
#
|
#
|
||||||
# - key: Project setting name.
|
# - key: Project setting name.
|
||||||
# - value: Project setting value.
|
# - value: Project setting value.
|
||||||
func set_setting(key: String, value) -> void:
|
static func set_setting(key: String, value) -> void:
|
||||||
ProjectSettings.set_setting(key, value)
|
ProjectSettings.set_setting(key, value)
|
||||||
|
|
||||||
|
|
||||||
@@ -118,5 +116,5 @@ func set_setting(key: String, value) -> void:
|
|||||||
# - key: Project setting name.
|
# - key: Project setting name.
|
||||||
#
|
#
|
||||||
# *Returns* true iff the project setting exists.
|
# *Returns* true iff the project setting exists.
|
||||||
func has_setting(key: String) -> bool:
|
static func has_setting(key: String) -> bool:
|
||||||
return ProjectSettings.has_setting(key)
|
return ProjectSettings.has_setting(key)
|
||||||
@@ -3,166 +3,98 @@ tool
|
|||||||
extends Node
|
extends Node
|
||||||
class_name Escoria
|
class_name Escoria
|
||||||
|
|
||||||
|
# Signal sent when pause menu has to be displayed
|
||||||
# Signal sent when Escoria is paused
|
signal request_pause_menu
|
||||||
signal paused
|
|
||||||
|
|
||||||
# Signal sent when Escoria is resumed from pause
|
|
||||||
signal resumed
|
|
||||||
|
|
||||||
|
|
||||||
# Current game state
|
# Name of the Escoria core plugin
|
||||||
# * DEFAULT: Common game function
|
const ESCORIA_CORE_PLUGIN_NAME: String = "escoria-core"
|
||||||
# * DIALOG: Game is playing a dialog
|
|
||||||
# * WAIT: Game is waiting
|
|
||||||
enum GAME_STATE {
|
|
||||||
DEFAULT,
|
|
||||||
DIALOG,
|
|
||||||
WAIT
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Audio bus indices.
|
|
||||||
const BUS_MASTER = "Master"
|
|
||||||
const BUS_SFX = "SFX"
|
|
||||||
const BUS_MUSIC = "Music"
|
|
||||||
const BUS_SPEECH = "Speech"
|
|
||||||
|
|
||||||
const CAMERA_SCENE_PATH = "res://addons/escoria-core/game/scenes/camera_player/camera.tscn"
|
|
||||||
|
|
||||||
|
|
||||||
# Logger used
|
|
||||||
var logger: ESCLogger
|
|
||||||
|
|
||||||
# Several utilities
|
|
||||||
var utils: ESCUtils
|
|
||||||
|
|
||||||
# The inventory manager instance
|
|
||||||
var inventory_manager: ESCInventoryManager
|
|
||||||
|
|
||||||
# The action manager instance
|
|
||||||
var action_manager: ESCActionManager
|
|
||||||
|
|
||||||
# ESC compiler instance
|
|
||||||
var esc_compiler: ESCCompiler
|
|
||||||
|
|
||||||
# ESC Event manager instance
|
|
||||||
var event_manager: ESCEventManager
|
|
||||||
|
|
||||||
# ESC globals registry instance
|
|
||||||
var globals_manager: ESCGlobalsManager
|
|
||||||
|
|
||||||
# ESC room manager instance
|
|
||||||
var room_manager: ESCRoomManager
|
|
||||||
|
|
||||||
# ESC object manager instance
|
|
||||||
var object_manager: ESCObjectManager
|
|
||||||
|
|
||||||
# ESC project settings manager instance
|
|
||||||
var project_settings_manager: ESCProjectSettingsManager
|
|
||||||
|
|
||||||
# ESC command registry instance
|
|
||||||
var command_registry: ESCCommandRegistry
|
|
||||||
|
|
||||||
# Resource cache handler
|
|
||||||
var resource_cache: ESCResourceCache
|
|
||||||
|
|
||||||
# Terrain of the current room
|
|
||||||
var room_terrain
|
|
||||||
|
|
||||||
# Dialog player instantiator. This instance is called directly for dialogs.
|
|
||||||
var dialog_player: ESCDialogPlayer
|
|
||||||
|
|
||||||
# Inventory scene
|
|
||||||
var inventory
|
|
||||||
|
|
||||||
# These are settings that the player can affect and save/load later
|
|
||||||
var settings: ESCSaveSettings
|
|
||||||
|
|
||||||
# The game resolution
|
|
||||||
onready var game_size = get_viewport().size
|
|
||||||
|
|
||||||
# The main scene
|
# The main scene
|
||||||
onready var main = $main
|
onready var main = $main
|
||||||
|
|
||||||
# The current state of the game
|
|
||||||
onready var current_state = GAME_STATE.DEFAULT
|
|
||||||
|
|
||||||
# The escoria inputs manager
|
|
||||||
var inputs_manager: ESCInputsManager
|
|
||||||
|
|
||||||
# Savegames and settings manager
|
|
||||||
var save_manager: ESCSaveManager
|
|
||||||
|
|
||||||
# The game scene loaded
|
|
||||||
var game_scene: ESCGame
|
|
||||||
|
|
||||||
# The main player camera
|
|
||||||
var player_camera: ESCCamera
|
|
||||||
|
|
||||||
# The compiled start script loaded from ProjectSettings
|
|
||||||
# escoria/main/game_start_script
|
|
||||||
var start_script: ESCScript
|
|
||||||
|
|
||||||
|
|
||||||
# Initialize various objects
|
|
||||||
func _init():
|
func _init():
|
||||||
self.logger = ESCLogger.new()
|
escoria.inventory_manager = ESCInventoryManager.new()
|
||||||
self.utils = ESCUtils.new()
|
escoria.action_manager = ESCActionManager.new()
|
||||||
self.inventory_manager = ESCInventoryManager.new()
|
escoria.event_manager = ESCEventManager.new()
|
||||||
self.action_manager = ESCActionManager.new()
|
escoria.globals_manager = ESCGlobalsManager.new()
|
||||||
self.event_manager = ESCEventManager.new()
|
add_child(escoria.event_manager)
|
||||||
self.globals_manager = ESCGlobalsManager.new()
|
escoria.object_manager = ESCObjectManager.new()
|
||||||
self.add_child(self.event_manager)
|
escoria.command_registry = ESCCommandRegistry.new()
|
||||||
self.object_manager = ESCObjectManager.new()
|
escoria.resource_cache = ESCResourceCache.new()
|
||||||
self.command_registry = ESCCommandRegistry.new()
|
escoria.resource_cache.start()
|
||||||
self.esc_compiler = ESCCompiler.new()
|
escoria.save_manager = ESCSaveManager.new()
|
||||||
self.resource_cache = ESCResourceCache.new()
|
escoria.inputs_manager = ESCInputsManager.new()
|
||||||
self.resource_cache.start()
|
escoria.settings = ESCSaveSettings.new()
|
||||||
self.save_manager = ESCSaveManager.new()
|
|
||||||
self.inputs_manager = ESCInputsManager.new()
|
|
||||||
self.room_manager = ESCRoomManager.new()
|
|
||||||
self.project_settings_manager = ESCProjectSettingsManager.new()
|
|
||||||
|
|
||||||
settings = ESCSaveSettings.new()
|
if ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.GAME_SCENE
|
||||||
if self.project_settings_manager.get_setting(self.project_settings_manager.GAME_SCENE) == "":
|
).empty():
|
||||||
logger.report_errors("escoria.gd",
|
escoria.logger.error(
|
||||||
["Project setting '%s' is not set!" % self.project_settings_manager.GAME_SCENE]
|
self,
|
||||||
|
"Project setting '%s' is not set!" % ESCProjectSettingsManager.GAME_SCENE
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
game_scene = resource_cache.get_resource(
|
escoria.game_scene = escoria.resource_cache.get_resource(
|
||||||
self.project_settings_manager.get_setting(self.project_settings_manager.GAME_SCENE)
|
ESCProjectSettingsManager.get_setting(ESCProjectSettingsManager.GAME_SCENE)
|
||||||
).instance()
|
).instance()
|
||||||
|
|
||||||
print("ESC {0}".format([get_script().get_path()]))
|
|
||||||
|
|
||||||
|
|
||||||
# Load settings
|
# Load settings
|
||||||
func _ready():
|
func _ready():
|
||||||
_handle_direct_scene_run()
|
_handle_direct_scene_run()
|
||||||
|
|
||||||
settings = save_manager.load_settings()
|
escoria.settings = escoria.save_manager.load_settings()
|
||||||
apply_settings(settings)
|
escoria.apply_settings(escoria.settings)
|
||||||
room_manager.register_reserved_globals()
|
escoria.room_manager.register_reserved_globals()
|
||||||
inputs_manager.register_core()
|
escoria.inputs_manager.register_core()
|
||||||
if self.project_settings_manager.get_setting(self.project_settings_manager.GAME_START_SCRIPT).empty():
|
if ESCProjectSettingsManager.get_setting(
|
||||||
logger.report_errors("escoria.gd",
|
ESCProjectSettingsManager.GAME_START_SCRIPT
|
||||||
[
|
).empty():
|
||||||
"Project setting '%s' is not set!" % self.project_settings_manager.GAME_START_SCRIPT
|
escoria.logger.error(
|
||||||
])
|
self,
|
||||||
start_script = self.esc_compiler.load_esc_file(
|
"Project setting '%s' is not set!"
|
||||||
self.project_settings_manager.get_setting(self.project_settings_manager.GAME_START_SCRIPT)
|
% ESCProjectSettingsManager.GAME_START_SCRIPT
|
||||||
|
)
|
||||||
|
escoria.start_script = escoria.esc_compiler.load_esc_file(
|
||||||
|
ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.GAME_START_SCRIPT
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
escoria.main = main
|
||||||
|
|
||||||
|
_perform_plugins_checks()
|
||||||
|
|
||||||
|
|
||||||
func _notification(what):
|
# Verifies that the game is configured with required plugin(s).
|
||||||
|
# If a required plugin is missing (or disabled) we stop immediately.
|
||||||
|
func _perform_plugins_checks():
|
||||||
|
if ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.DIALOG_MANAGERS
|
||||||
|
).empty():
|
||||||
|
escoria.logger.error(
|
||||||
|
self,
|
||||||
|
"No dialog manager configured. Please add a dialog manager plugin."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Manage notifications received from OS
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - what: the notification constant received (usually defined in MainLoop)
|
||||||
|
func _notification(what: int):
|
||||||
match what:
|
match what:
|
||||||
MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
|
MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
|
||||||
escoria.logger.close_logs()
|
escoria.logger.close_logs()
|
||||||
|
escoria.is_quitting = true
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST:
|
MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST:
|
||||||
escoria.logger.close_logs()
|
escoria.logger.close_logs()
|
||||||
|
escoria.is_quitting = true
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
@@ -173,69 +105,22 @@ func init():
|
|||||||
# Don't show the UI until we're ready in order to avoid a sometimes-noticeable
|
# Don't show the UI until we're ready in order to avoid a sometimes-noticeable
|
||||||
# blink. The UI will be "shown" later via a visibility update to the first room.
|
# blink. The UI will be "shown" later via a visibility update to the first room.
|
||||||
escoria.game_scene.escoria_hide_ui()
|
escoria.game_scene.escoria_hide_ui()
|
||||||
run_event_from_script(start_script, self.event_manager.EVENT_INIT)
|
run_event_from_script(escoria.start_script, escoria.event_manager.EVENT_INIT)
|
||||||
|
pass
|
||||||
|
|
||||||
# Called by Main menu "start new game"
|
|
||||||
func new_game():
|
|
||||||
run_event_from_script(start_script, self.event_manager.EVENT_NEW_GAME)
|
|
||||||
|
|
||||||
|
|
||||||
# Apply the loaded settings
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# * p_settings: Loaded settings
|
|
||||||
func apply_settings(p_settings: ESCSaveSettings) -> void:
|
|
||||||
if not Engine.is_editor_hint():
|
|
||||||
logger.info("******* settings loaded")
|
|
||||||
if p_settings != null:
|
|
||||||
settings = p_settings
|
|
||||||
else:
|
|
||||||
settings = ESCSaveSettings.new()
|
|
||||||
|
|
||||||
AudioServer.set_bus_volume_db(
|
|
||||||
AudioServer.get_bus_index(BUS_MASTER),
|
|
||||||
linear2db(settings.master_volume)
|
|
||||||
)
|
|
||||||
AudioServer.set_bus_volume_db(
|
|
||||||
AudioServer.get_bus_index(BUS_SFX),
|
|
||||||
linear2db(settings.sfx_volume)
|
|
||||||
)
|
|
||||||
AudioServer.set_bus_volume_db(
|
|
||||||
AudioServer.get_bus_index(BUS_MUSIC),
|
|
||||||
linear2db(settings.music_volume)
|
|
||||||
)
|
|
||||||
AudioServer.set_bus_volume_db(
|
|
||||||
AudioServer.get_bus_index(BUS_SPEECH),
|
|
||||||
linear2db(settings.speech_volume)
|
|
||||||
)
|
|
||||||
TranslationServer.set_locale(settings.text_lang)
|
|
||||||
|
|
||||||
game_scene.apply_custom_settings(settings.custom_settings)
|
|
||||||
|
|
||||||
|
|
||||||
# Input function to manage specific input keys
|
# Input function to manage specific input keys
|
||||||
func _input(event):
|
|
||||||
if InputMap.has_action(ESCInputsManager.ESC_SHOW_DEBUG_PROMPT) \
|
|
||||||
and event.is_action_pressed(ESCInputsManager.ESC_SHOW_DEBUG_PROMPT):
|
|
||||||
escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup()
|
|
||||||
|
|
||||||
|
|
||||||
# Pauses or unpause the game
|
|
||||||
#
|
#
|
||||||
# #### Parameters
|
# #### Parameters
|
||||||
# - p_paused: if true, pauses the game. If false, unpauses the game.
|
# - event: the input event to manage.
|
||||||
func set_game_paused(p_paused: bool):
|
func _input(event: InputEvent):
|
||||||
if p_paused:
|
if InputMap.has_action(ESCInputsManager.ESC_SHOW_DEBUG_PROMPT) \
|
||||||
emit_signal("paused")
|
and event.is_action_pressed(ESCInputsManager.ESC_SHOW_DEBUG_PROMPT):
|
||||||
else:
|
main.get_node("layers/debug_layer/esc_prompt_popup").popup()
|
||||||
emit_signal("resumed")
|
|
||||||
|
|
||||||
var scene_tree = get_tree()
|
if event.is_action_pressed("ui_cancel"):
|
||||||
|
emit_signal("request_pause_menu")
|
||||||
if is_instance_valid(scene_tree):
|
pass
|
||||||
scene_tree.paused = p_paused
|
|
||||||
|
|
||||||
|
|
||||||
# Runs the event "event_name" from the "script" ESC script.
|
# Runs the event "event_name" from the "script" ESC script.
|
||||||
@@ -246,121 +131,27 @@ func set_game_paused(p_paused: bool):
|
|||||||
# - event_name: Name of the event to run
|
# - event_name: Name of the event to run
|
||||||
func run_event_from_script(script: ESCScript, event_name: String):
|
func run_event_from_script(script: ESCScript, event_name: String):
|
||||||
if script == null:
|
if script == null:
|
||||||
logger.report_errors(
|
escoria.logger.error(
|
||||||
"escoria.gd:run_event_from_script()",
|
self,
|
||||||
["Requested action %s on unloaded script %s" % [event_name, script],
|
"Requested action %s on unloaded script %s." % [event_name, script] +
|
||||||
"Please load the ESC script using esc_compiler.load_esc_file()."]
|
"Please load the ESC script using esc_compiler.load_esc_file()."
|
||||||
)
|
)
|
||||||
event_manager.queue_event(script.events[event_name])
|
escoria.event_manager.queue_event(script.events[event_name])
|
||||||
var rc = yield(event_manager, "event_finished")
|
var rc = yield(escoria.event_manager, "event_finished")
|
||||||
while rc[1] != event_name:
|
while rc[1] != event_name:
|
||||||
rc = yield(event_manager, "event_finished")
|
rc = yield(escoria.event_manager, "event_finished")
|
||||||
|
|
||||||
if rc[0] != ESCExecution.RC_OK:
|
if rc[0] != ESCExecution.RC_OK:
|
||||||
self.logger.report_errors(
|
escoria.logger.error(
|
||||||
"Start event of the start script returned unsuccessful: %d" % rc[0],
|
self,
|
||||||
[]
|
"Start event of the start script returned unsuccessful: %d." % rc[0]
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# Register a user interface. This should be called in a deferred way
|
# Called from escoria autoload to start a new game.
|
||||||
# from the addon's _enter_tree.
|
func new_game():
|
||||||
#
|
run_event_from_script(escoria.start_script, escoria.event_manager.EVENT_NEW_GAME)
|
||||||
# #### Parameters
|
|
||||||
# - game_scene: Path to the game scene extending ESCGame
|
|
||||||
func register_ui(game_scene: String):
|
|
||||||
var game_scene_setting_value = escoria.project_settings_manager.get_setting(
|
|
||||||
escoria.project_settings_manager.GAME_SCENE
|
|
||||||
)
|
|
||||||
|
|
||||||
if not game_scene_setting_value in [
|
|
||||||
"",
|
|
||||||
game_scene
|
|
||||||
]:
|
|
||||||
logger.report_errors(
|
|
||||||
"escoria.gd:register_ui()",
|
|
||||||
[
|
|
||||||
"Can't register user interface because %s is registered" % \
|
|
||||||
game_scene_setting_value
|
|
||||||
]
|
|
||||||
)
|
|
||||||
escoria.project_settings_manager.set_setting(
|
|
||||||
escoria.project_settings_manager.GAME_SCENE,
|
|
||||||
game_scene
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Deregister a user interface
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
# - game_scene: Path to the game scene extending ESCGame
|
|
||||||
func deregister_ui(game_scene: String):
|
|
||||||
var game_scene_setting_value = escoria.project_settings_manager.get_setting(
|
|
||||||
escoria.project_settings_manager.GAME_SCENE
|
|
||||||
)
|
|
||||||
|
|
||||||
if game_scene_setting_value != game_scene:
|
|
||||||
logger.report_errors(
|
|
||||||
"escoria.gd:deregister_ui()",
|
|
||||||
[
|
|
||||||
(
|
|
||||||
"Can't deregister user interface %s because it " +
|
|
||||||
"is not registered."
|
|
||||||
) % game_scene_setting_value
|
|
||||||
]
|
|
||||||
)
|
|
||||||
escoria.project_settings_manager.set_setting(
|
|
||||||
escoria.project_settings_manager.GAME_SCENE,
|
|
||||||
""
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Register a dialog manager addon. This should be called in a deferred way
|
|
||||||
# from the addon's _enter_tree.
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
# - manager_class: Path to the manager class script
|
|
||||||
func register_dialog_manager(manager_class: String):
|
|
||||||
var dialog_managers: Array = escoria.project_settings_manager.get_setting(
|
|
||||||
escoria.project_settings_manager.DIALOG_MANAGERS
|
|
||||||
)
|
|
||||||
|
|
||||||
if manager_class in dialog_managers:
|
|
||||||
return
|
|
||||||
|
|
||||||
dialog_managers.push_back(manager_class)
|
|
||||||
|
|
||||||
escoria.project_settings_manager.set_setting(
|
|
||||||
escoria.project_settings_manager.DIALOG_MANAGERS,
|
|
||||||
dialog_managers
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Deregister a dialog manager addon
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
# - manager_class: Path to the manager class script
|
|
||||||
func deregister_dialog_manager(manager_class: String):
|
|
||||||
var dialog_managers: Array = escoria.project_settings_manager.get_setting(
|
|
||||||
escoria.project_settings_manager.DIALOG_MANAGERS
|
|
||||||
)
|
|
||||||
|
|
||||||
if not manager_class in dialog_managers:
|
|
||||||
logger.report_warnings(
|
|
||||||
"escoria.gd:deregister_dialog_manager()",
|
|
||||||
[
|
|
||||||
"Dialog manager %s is not registered" % manager_class
|
|
||||||
]
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
dialog_managers.erase(manager_class)
|
|
||||||
|
|
||||||
escoria.project_settings_manager.set_setting(
|
|
||||||
escoria.project_settings_manager.DIALOG_MANAGERS,
|
|
||||||
dialog_managers
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Function called to quit the game.
|
# Function called to quit the game.
|
||||||
@@ -370,19 +161,8 @@ func quit():
|
|||||||
|
|
||||||
# Handle anything necessary if the game started a scene directly.
|
# Handle anything necessary if the game started a scene directly.
|
||||||
func _handle_direct_scene_run() -> void:
|
func _handle_direct_scene_run() -> void:
|
||||||
var current_scene_root: Node = get_tree().get_current_scene()
|
if escoria.is_direct_room_run:
|
||||||
|
escoria.object_manager.set_current_room(get_tree().get_current_scene())
|
||||||
if current_scene_root == null:
|
|
||||||
# there's no 'current scene'
|
|
||||||
# e.g. you're opening escoria.tscn from the editor
|
|
||||||
return
|
|
||||||
|
|
||||||
if current_scene_root.filename == ProjectSettings.get_setting('application/run/main_scene'):
|
|
||||||
# This is a normal, full-game run, so there's nothing to do.
|
|
||||||
return
|
|
||||||
|
|
||||||
if current_scene_root is ESCRoom:
|
|
||||||
escoria.object_manager.set_current_room(current_scene_root)
|
|
||||||
|
|
||||||
|
|
||||||
# Used by game.gd to determine whether the game scene is ready to take inputs
|
# Used by game.gd to determine whether the game scene is ready to take inputs
|
||||||
@@ -393,5 +173,5 @@ func _handle_direct_scene_run() -> void:
|
|||||||
# *Returns*
|
# *Returns*
|
||||||
# true if game scene is ready for inputs
|
# true if game scene is ready for inputs
|
||||||
func is_ready_for_inputs() -> bool:
|
func is_ready_for_inputs() -> bool:
|
||||||
return escoria.main.current_scene and escoria.main.current_scene.game \
|
return main.current_scene and main.current_scene.game \
|
||||||
and escoria.main.current_scene.game.room_ready_for_inputs
|
and main.current_scene.game.room_ready_for_inputs
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
[ext_resource path="res://addons/escoria-core/game/main.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://addons/escoria-core/game/main.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://addons/escoria-core/game/escoria.gd" type="Script" id=3]
|
[ext_resource path="res://addons/escoria-core/game/escoria.gd" type="Script" id=3]
|
||||||
|
|
||||||
[node name="escoria" type="Node"]
|
[node name="escoria_scene" type="Node"]
|
||||||
pause_mode = 2
|
pause_mode = 2
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ func _ready() -> void:
|
|||||||
$layers/wait_timer.connect("timeout", self, "_on_wait_finished")
|
$layers/wait_timer.connect("timeout", self, "_on_wait_finished")
|
||||||
|
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
$layers/curtain.remove_child(scene_transition)
|
||||||
|
scene_transition.queue_free()
|
||||||
|
|
||||||
# Set current scene
|
# Set current scene
|
||||||
#
|
#
|
||||||
# #### Parameters
|
# #### Parameters
|
||||||
@@ -38,7 +42,10 @@ func _ready() -> void:
|
|||||||
# - p_scene: Scene to set
|
# - p_scene: Scene to set
|
||||||
func set_scene(p_scene: Node) -> void:
|
func set_scene(p_scene: Node) -> void:
|
||||||
if !p_scene:
|
if !p_scene:
|
||||||
escoria.logger.report_errors("main", ["Trying to set empty scene"])
|
escoria.logger.error(
|
||||||
|
self,
|
||||||
|
"Can't change to an empty scene. Please specify the scene name."
|
||||||
|
)
|
||||||
|
|
||||||
previous_scene = current_scene
|
previous_scene = current_scene
|
||||||
|
|
||||||
@@ -130,13 +137,11 @@ func set_camera_limits(camera_limit_id: int = 0, scene: Node = current_scene) ->
|
|||||||
var limits = {}
|
var limits = {}
|
||||||
var last_available_camera_limit = scene.camera_limits.size() - 1
|
var last_available_camera_limit = scene.camera_limits.size() - 1
|
||||||
if camera_limit_id > last_available_camera_limit:
|
if camera_limit_id > last_available_camera_limit:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"main.gd:set_camera_limits()",
|
self,
|
||||||
[
|
"Camera limit %d requested. Last available camera limit is %d." % [
|
||||||
"Camera limit %d requested. Last available camera limit is %d." % [
|
camera_limit_id,
|
||||||
camera_limit_id,
|
last_available_camera_limit
|
||||||
last_available_camera_limit
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
var scene_camera_limits = scene.camera_limits[camera_limit_id]
|
var scene_camera_limits = scene.camera_limits[camera_limit_id]
|
||||||
@@ -151,15 +156,16 @@ func set_camera_limits(camera_limit_id: int = 0, scene: Node = current_scene) ->
|
|||||||
# to stick centered on the background
|
# to stick centered on the background
|
||||||
if area.size.x == 0 or area.size.y == 0 \
|
if area.size.x == 0 or area.size.y == 0 \
|
||||||
or area.size < get_viewport().size:
|
or area.size < get_viewport().size:
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"main.gd:set_camera_limits()",
|
self,
|
||||||
[
|
"Defined camera is smaller than the viewport. Using viewport size."
|
||||||
"No limit area! Using viewport."
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
area.size = get_viewport().size
|
area.size = get_viewport().size
|
||||||
|
|
||||||
escoria.logger.info("Setting camera limits from scene ", [area])
|
escoria.logger.info(
|
||||||
|
self,
|
||||||
|
"Setting camera limits from scene " + area
|
||||||
|
)
|
||||||
limits = ESCCameraLimits.new(
|
limits = ESCCameraLimits.new(
|
||||||
area.position.x,
|
area.position.x,
|
||||||
area.position.x + area.size.x,
|
area.position.x + area.size.x,
|
||||||
@@ -176,8 +182,8 @@ func set_camera_limits(camera_limit_id: int = 0, scene: Node = current_scene) ->
|
|||||||
scene_camera_limits.size.y
|
scene_camera_limits.size.y
|
||||||
)
|
)
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"Setting camera limits from parameter ",
|
self,
|
||||||
[scene_camera_limits]
|
"Setting camera limits using configured parameters " + str(scene_camera_limits)
|
||||||
)
|
)
|
||||||
|
|
||||||
escoria.object_manager.get_object(
|
escoria.object_manager.get_object(
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ script = ExtResource( 1 )
|
|||||||
[node name="curtain" type="CanvasLayer" parent="layers"]
|
[node name="curtain" type="CanvasLayer" parent="layers"]
|
||||||
layer = 20
|
layer = 20
|
||||||
|
|
||||||
[node name="menu" type="CanvasLayer" parent="layers"]
|
|
||||||
|
|
||||||
[node name="wait_timer" type="Timer" parent="layers"]
|
[node name="wait_timer" type="Timer" parent="layers"]
|
||||||
|
|
||||||
[node name="debug_layer" type="CanvasLayer" parent="layers"]
|
[node name="debug_layer" type="CanvasLayer" parent="layers"]
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
# Main_scene is the entry point for Godot Engine.
|
# Main_scene is the entry point for Godot Engine.
|
||||||
# This scene sets up the main menu scene to load.
|
# This scene sets up the main menu scene to load.
|
||||||
extends Node
|
extends Node
|
||||||
|
class_name ESCMain
|
||||||
|
|
||||||
|
var escoria_node: Escoria
|
||||||
|
|
||||||
|
|
||||||
# Start the main menu
|
# Start the main menu
|
||||||
func _ready():
|
func _ready():
|
||||||
escoria.init()
|
escoria.logger.info(self, "Escoria starts...")
|
||||||
|
|
||||||
|
escoria_node = preload("res://addons/escoria-core/game/escoria.tscn").instance()
|
||||||
|
add_child(escoria_node)
|
||||||
|
|
||||||
|
if not escoria.is_direct_room_run:
|
||||||
|
escoria_node.init()
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ func _ready():
|
|||||||
_tween.connect("tween_all_completed", self, "_target_reached")
|
_tween.connect("tween_all_completed", self, "_target_reached")
|
||||||
|
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
remove_child(_tween)
|
||||||
|
if is_instance_valid(_tween):
|
||||||
|
_tween.queue_free()
|
||||||
|
|
||||||
|
|
||||||
# Update the position if the followed target is moving
|
# Update the position if the followed target is moving
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if is_instance_valid(_follow_target) and not _tween.is_active() and _follow_target.has_moved():
|
if is_instance_valid(_follow_target) and not _tween.is_active() and _follow_target.has_moved():
|
||||||
@@ -103,20 +109,19 @@ func set_target(p_target, p_time : float = 0.0):
|
|||||||
_resolve_target_and_zoom(p_target)
|
_resolve_target_and_zoom(p_target)
|
||||||
|
|
||||||
escoria.logger.info(
|
escoria.logger.info(
|
||||||
"Current camera position = %s " % str(self.global_position)
|
self,
|
||||||
|
"Current camera position = %s." % str(self.global_position)
|
||||||
)
|
)
|
||||||
|
|
||||||
if p_time == 0.0:
|
if p_time == 0.0:
|
||||||
self.global_position = _target
|
self.global_position = _target
|
||||||
else:
|
else:
|
||||||
if _tween.is_active():
|
if _tween.is_active():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_camera.gd:set_target()",
|
self,
|
||||||
[
|
"Tween is still active: %f seconds of %f completed." % [
|
||||||
"Tween is still active: %f/%f" % [
|
_tween.tell(),
|
||||||
_tween.tell(),
|
_tween.get_runtime()
|
||||||
_tween.get_runtime()
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
_tween.emit_signal("tween_completed")
|
_tween.emit_signal("tween_completed")
|
||||||
@@ -140,9 +145,9 @@ func set_target(p_target, p_time : float = 0.0):
|
|||||||
# - p_time: Number of seconds for the camera to reach the zoom level
|
# - p_time: Number of seconds for the camera to reach the zoom level
|
||||||
func set_camera_zoom(p_zoom_level: float, p_time: float):
|
func set_camera_zoom(p_zoom_level: float, p_time: float):
|
||||||
if p_zoom_level <= 0.0:
|
if p_zoom_level <= 0.0:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_camera.gd:set_camera_zoom()",
|
self,
|
||||||
["Tried to set negative or zero zoom level"]
|
"Tried to set negative or zero zoom level."
|
||||||
)
|
)
|
||||||
|
|
||||||
_zoom_target = Vector2(1, 1) * p_zoom_level
|
_zoom_target = Vector2(1, 1) * p_zoom_level
|
||||||
@@ -151,13 +156,11 @@ func set_camera_zoom(p_zoom_level: float, p_time: float):
|
|||||||
self.zoom = _zoom_target
|
self.zoom = _zoom_target
|
||||||
else:
|
else:
|
||||||
if _tween.is_active():
|
if _tween.is_active():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_camera.gd:set_camera_zoom()",
|
self,
|
||||||
[
|
"Tween is still active: %f/%f" % [
|
||||||
"Tween is still active: %f/%f" % [
|
_tween.tell(),
|
||||||
_tween.tell(),
|
_tween.get_runtime()
|
||||||
_tween.get_runtime()
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
_tween.emit_signal("tween_completed")
|
_tween.emit_signal("tween_completed")
|
||||||
@@ -199,13 +202,11 @@ func push(p_target, p_time: float = 0.0, p_type: int = 0):
|
|||||||
self.zoom = _zoom_target
|
self.zoom = _zoom_target
|
||||||
else:
|
else:
|
||||||
if _tween.is_active():
|
if _tween.is_active():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_camera.gd:push()",
|
self,
|
||||||
[
|
"Tween is still active: %f seconds of %f completed." % [
|
||||||
"Tween is still active: %f/%f" % [
|
_tween.tell(),
|
||||||
_tween.tell(),
|
_tween.get_runtime()
|
||||||
_tween.get_runtime()
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
_tween.emit_signal("tween_completed", null, null)
|
_tween.emit_signal("tween_completed", null, null)
|
||||||
@@ -251,15 +252,13 @@ func shift(p_target: Vector2, p_time: float, p_type: int):
|
|||||||
_target = new_pos
|
_target = new_pos
|
||||||
|
|
||||||
if _tween.is_active():
|
if _tween.is_active():
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_camera.gd:set_camera_zoom()",
|
self,
|
||||||
[
|
"Tween is still active: %f seconds of %f completed." % [
|
||||||
"Tween is still active: %f/%f" % [
|
_tween.tell(),
|
||||||
_tween.tell(),
|
_tween.get_runtime()
|
||||||
_tween.get_runtime()
|
]
|
||||||
]
|
)
|
||||||
]
|
|
||||||
)
|
|
||||||
_tween.emit_signal("tween_completed")
|
_tween.emit_signal("tween_completed")
|
||||||
|
|
||||||
_tween.interpolate_property(
|
_tween.interpolate_property(
|
||||||
@@ -276,6 +275,3 @@ func shift(p_target: Vector2, p_time: float, p_type: int):
|
|||||||
|
|
||||||
func _target_reached():
|
func _target_reached():
|
||||||
_tween.stop_all()
|
_tween.stop_all()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Describes a bounding box that limits the camera movement in the scene
|
# Describes a bounding box that limits the camera movement in the scene
|
||||||
extends Object
|
extends Reference
|
||||||
class_name ESCCameraLimits
|
class_name ESCCameraLimits
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,15 @@ func set_dialog(new_dialog: ESCDialog) -> void:
|
|||||||
|
|
||||||
# Show the dialog chooser UI
|
# Show the dialog chooser UI
|
||||||
func show_chooser() -> void:
|
func show_chooser() -> void:
|
||||||
escoria.logger.error("Dialog chooser did not implement the show method.")
|
escoria.logger.error(
|
||||||
|
self,
|
||||||
|
"Dialog chooser does not implement the show method."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Hide the dialog chooser UI
|
# Hide the dialog chooser UI
|
||||||
func hide_chooser() -> void:
|
func hide_chooser() -> void:
|
||||||
escoria.logger.error("Dialog chooser did not implement the hide method.")
|
escoria.logger.error(
|
||||||
|
self,
|
||||||
|
"Dialog chooser does not implement the hide method."
|
||||||
|
)
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ func _input(event):
|
|||||||
# *Returns* The path to the matching voice file
|
# *Returns* The path to the matching voice file
|
||||||
func _get_voice_file(key: String, start: String = "") -> String:
|
func _get_voice_file(key: String, start: String = "") -> String:
|
||||||
if start == "":
|
if start == "":
|
||||||
start = escoria.project_settings_manager.get_setting(
|
start = ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.SPEECH_FOLDER
|
ESCProjectSettingsManager.SPEECH_FOLDER
|
||||||
)
|
)
|
||||||
var _dir = Directory.new()
|
var _dir = Directory.new()
|
||||||
if _dir.open(start) == OK:
|
if _dir.open(start) == OK:
|
||||||
@@ -80,8 +80,8 @@ func _get_voice_file(key: String, start: String = "") -> String:
|
|||||||
else:
|
else:
|
||||||
if file_name == "%s.%s.import" % [
|
if file_name == "%s.%s.import" % [
|
||||||
key,
|
key,
|
||||||
escoria.project_settings_manager.get_setting(
|
ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.SPEECH_EXTENSION
|
ESCProjectSettingsManager.SPEECH_EXTENSION
|
||||||
)
|
)
|
||||||
]:
|
]:
|
||||||
return start.plus_file(file_name.trim_suffix(".import"))
|
return start.plus_file(file_name.trim_suffix(".import"))
|
||||||
@@ -98,12 +98,12 @@ func _get_voice_file(key: String, start: String = "") -> String:
|
|||||||
# - text: Text to say
|
# - text: Text to say
|
||||||
func say(character: String, type: String, text: String) -> void:
|
func say(character: String, type: String, text: String) -> void:
|
||||||
if type == "":
|
if type == "":
|
||||||
type = escoria.project_settings_manager.get_setting(
|
type = ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.DEFAULT_DIALOG_TYPE
|
ESCProjectSettingsManager.DEFAULT_DIALOG_TYPE
|
||||||
)
|
)
|
||||||
is_speaking = true
|
is_speaking = true
|
||||||
for _manager_class in escoria.project_settings_manager.get_setting(
|
for _manager_class in ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.DIALOG_MANAGERS
|
ESCProjectSettingsManager.DIALOG_MANAGERS
|
||||||
):
|
):
|
||||||
if ResourceLoader.exists(_manager_class):
|
if ResourceLoader.exists(_manager_class):
|
||||||
var _manager: ESCDialogManager = load(_manager_class).new()
|
var _manager: ESCDialogManager = load(_manager_class).new()
|
||||||
@@ -113,22 +113,18 @@ func say(character: String, type: String, text: String) -> void:
|
|||||||
_dialog_manager = null
|
_dialog_manager = null
|
||||||
|
|
||||||
if _dialog_manager == null:
|
if _dialog_manager == null:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_dialog_player.gd:say",
|
self,
|
||||||
[
|
"No dialog manager called %s configured." % type
|
||||||
"No dialog manager supports the type %s" % type
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
_dialog_manager.connect("say_finished", self, "_on_say_finished", [], CONNECT_ONESHOT)
|
_dialog_manager.connect("say_finished", self, "_on_say_finished", [], CONNECT_ONESHOT)
|
||||||
|
|
||||||
var matches = _keytext_regex.search(text)
|
var matches = _keytext_regex.search(text)
|
||||||
if not matches:
|
if not matches:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_dialog_player.gd:say",
|
self,
|
||||||
[
|
"Unexpected text encountered : %s." % text
|
||||||
"Unexpected text encountered %s" % text
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
var key = matches.get_string("key")
|
var key = matches.get_string("key")
|
||||||
if matches.get_string("key") != "":
|
if matches.get_string("key") != "":
|
||||||
@@ -136,11 +132,9 @@ func say(character: String, type: String, text: String) -> void:
|
|||||||
matches.get_string("key")
|
matches.get_string("key")
|
||||||
)
|
)
|
||||||
if _speech_resource == "":
|
if _speech_resource == "":
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_dialog_player.gd:say",
|
self,
|
||||||
[
|
"Unable to find voice file with key '%s'." % matches.get_string("key")
|
||||||
"Unable to find voice file with key '%s'." % matches.get_string("key")
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
(
|
(
|
||||||
@@ -153,11 +147,9 @@ func say(character: String, type: String, text: String) -> void:
|
|||||||
# Only update the text if the translated text was found; otherwise, raise
|
# Only update the text if the translated text was found; otherwise, raise
|
||||||
# a warning and use the original, untranslated text.
|
# a warning and use the original, untranslated text.
|
||||||
if translated_text == matches.get_string("key"):
|
if translated_text == matches.get_string("key"):
|
||||||
escoria.logger.report_warnings(
|
escoria.logger.warn(
|
||||||
"esc_dialog_player.gd:say",
|
self,
|
||||||
[
|
"Unable to find translation key '%s'. Using untranslated text." % matches.get_string("key")
|
||||||
"Unable to find translation key '%s'. Using untranslated text." % matches.get_string("key")
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
text = matches.get_string("text")
|
text = matches.get_string("text")
|
||||||
else:
|
else:
|
||||||
@@ -165,8 +157,8 @@ func say(character: String, type: String, text: String) -> void:
|
|||||||
else:
|
else:
|
||||||
text = matches.get_string("text")
|
text = matches.get_string("text")
|
||||||
|
|
||||||
_dialog_manager.say(self, character, text, type)
|
|
||||||
|
|
||||||
|
_dialog_manager.say(self, character, text, type)
|
||||||
|
|
||||||
# Handles the end of a say function after it has emitted say_finished.
|
# Handles the end of a say function after it has emitted say_finished.
|
||||||
func _on_say_finished():
|
func _on_say_finished():
|
||||||
@@ -189,15 +181,15 @@ func speedup() -> void:
|
|||||||
# - dialog: The dialog to start
|
# - dialog: The dialog to start
|
||||||
func start_dialog_choices(dialog: ESCDialog, type: String = "simple"):
|
func start_dialog_choices(dialog: ESCDialog, type: String = "simple"):
|
||||||
if dialog.options.empty():
|
if dialog.options.empty():
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_dialog_player.gd:start_dialog_choices()",
|
self,
|
||||||
["Received answers array was empty."]
|
"Received dialog options array was empty."
|
||||||
)
|
)
|
||||||
|
|
||||||
var _dialog_chooser_ui: ESCDialogManager = null
|
var _dialog_chooser_ui: ESCDialogManager = null
|
||||||
|
|
||||||
for _manager_class in escoria.project_settings_manager.get_setting(
|
for _manager_class in ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.DIALOG_MANAGERS
|
ESCProjectSettingsManager.DIALOG_MANAGERS
|
||||||
):
|
):
|
||||||
if ResourceLoader.exists(_manager_class):
|
if ResourceLoader.exists(_manager_class):
|
||||||
var _manager: ESCDialogManager = load(_manager_class).new()
|
var _manager: ESCDialogManager = load(_manager_class).new()
|
||||||
@@ -205,11 +197,9 @@ func start_dialog_choices(dialog: ESCDialog, type: String = "simple"):
|
|||||||
_dialog_chooser_ui = _manager
|
_dialog_chooser_ui = _manager
|
||||||
|
|
||||||
if _dialog_chooser_ui == null:
|
if _dialog_chooser_ui == null:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"esc_dialog_player.gd: Unknown chooser type",
|
self,
|
||||||
[
|
"No dialog manager supports the chooser type %s." % type
|
||||||
"No dialog manager supports the chooser type %s" % type
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
_dialog_chooser_ui.choose(self, dialog)
|
_dialog_chooser_ui.choose(self, dialog)
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ var items_ids_in_inventory: Dictionary = {}
|
|||||||
# listen when a global has changed
|
# listen when a global has changed
|
||||||
func _ready():
|
func _ready():
|
||||||
if inventory_ui_container == null or inventory_ui_container.is_empty():
|
if inventory_ui_container == null or inventory_ui_container.is_empty():
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
self.get_path(),
|
self,
|
||||||
["Items container is empty."]
|
"Inventory items container is empty."
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -43,8 +43,8 @@ func add_new_item_by_id(item_id: String) -> void:
|
|||||||
if not escoria.object_manager.has(item_id) or not is_instance_valid( \
|
if not escoria.object_manager.has(item_id) or not is_instance_valid( \
|
||||||
escoria.object_manager.get_object(item_id).node):
|
escoria.object_manager.get_object(item_id).node):
|
||||||
var inventory_file = "%s/%s.tscn" % [
|
var inventory_file = "%s/%s.tscn" % [
|
||||||
escoria.project_settings_manager.get_setting(
|
ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.ITEMS_AUTOREGISTER_PATH
|
ESCProjectSettingsManager.ITEMS_AUTOREGISTER_PATH
|
||||||
).trim_suffix("/"),
|
).trim_suffix("/"),
|
||||||
item_id
|
item_id
|
||||||
]
|
]
|
||||||
@@ -58,11 +58,21 @@ func add_new_item_by_id(item_id: String) -> void:
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"inventory_ui.gd:add_new_item_by_id()",
|
self,
|
||||||
[
|
(
|
||||||
"Item global id '%s' does not exist." % item_id
|
"Item global id '%s' is not registered because the item's scene file was not found.\n"
|
||||||
]
|
+ "Attempted scene file path: %s.\n"
|
||||||
|
+ "Please ensure that the '%s' project setting points at **your inventory items folder** (current is: \"%s\")."
|
||||||
|
)
|
||||||
|
% [
|
||||||
|
item_id,
|
||||||
|
inventory_file,
|
||||||
|
ESCProjectSettingsManager.ITEMS_AUTOREGISTER_PATH,
|
||||||
|
ESCProjectSettingsManager.get_setting(
|
||||||
|
ESCProjectSettingsManager.ITEMS_AUTOREGISTER_PATH
|
||||||
|
)
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
var inventory_item = ESCInventoryItem.new(
|
var inventory_item = ESCInventoryItem.new(
|
||||||
@@ -90,7 +100,10 @@ func add_new_item_by_id(item_id: String) -> void:
|
|||||||
# remove item fromInventory UI using its id set in its scene
|
# remove item fromInventory UI using its id set in its scene
|
||||||
func remove_item_by_id(item_id: String) -> void:
|
func remove_item_by_id(item_id: String) -> void:
|
||||||
if items_ids_in_inventory.has(item_id):
|
if items_ids_in_inventory.has(item_id):
|
||||||
var item_inventory_button = items_ids_in_inventory[item_id]
|
var item_inventory = items_ids_in_inventory[item_id]
|
||||||
|
var item_inventory_button = get_node(
|
||||||
|
inventory_ui_container
|
||||||
|
).get_inventory_button(item_inventory)
|
||||||
|
|
||||||
if item_inventory_button.is_connected(
|
if item_inventory_button.is_connected(
|
||||||
"mouse_left_inventory_item",
|
"mouse_left_inventory_item",
|
||||||
@@ -143,7 +156,7 @@ func remove_item_by_id(item_id: String) -> void:
|
|||||||
"_on_mouse_exited_inventory_item"
|
"_on_mouse_exited_inventory_item"
|
||||||
)
|
)
|
||||||
|
|
||||||
get_node(inventory_ui_container).remove_item(item_inventory_button)
|
get_node(inventory_ui_container).remove_item(item_inventory)
|
||||||
items_ids_in_inventory.erase(item_id)
|
items_ids_in_inventory.erase(item_id)
|
||||||
|
|
||||||
|
|
||||||
@@ -158,10 +171,7 @@ func _on_escoria_global_changed(global: String, old_value, new_value) -> void:
|
|||||||
else:
|
else:
|
||||||
remove_item_by_id(item[0])
|
remove_item_by_id(item[0])
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"inventory_ui.gd:_on_escoria_global_changed()",
|
self,
|
||||||
[
|
"Global must contain only one item name (received: %s)." % global
|
||||||
"Global must contain only one item name.",
|
|
||||||
"(received: %s)" % global
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ func set_state(p_state: String, p_force: bool = false) -> void:
|
|||||||
resource.loop_end = resource.mix_rate * resource.get_length()
|
resource.loop_end = resource.mix_rate * resource.get_length()
|
||||||
elif "loop" in resource:
|
elif "loop" in resource:
|
||||||
resource.loop = true
|
resource.loop = true
|
||||||
if escoria.project_settings_manager.has_setting(escoria.project_settings_manager.MUSIC_VOLUME):
|
if ESCProjectSettingsManager.has_setting(ESCProjectSettingsManager.MUSIC_VOLUME):
|
||||||
stream.volume_db = escoria.project_settings_manager.get_setting(
|
stream.volume_db = ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.MUSIC_VOLUME
|
ESCProjectSettingsManager.MUSIC_VOLUME
|
||||||
)
|
)
|
||||||
stream.play()
|
stream.play()
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ func set_state(p_state: String, p_force: bool = false):
|
|||||||
resource.loop_mode = AudioStreamSample.LOOP_DISABLED
|
resource.loop_mode = AudioStreamSample.LOOP_DISABLED
|
||||||
elif "loop" in resource:
|
elif "loop" in resource:
|
||||||
resource.loop = false
|
resource.loop = false
|
||||||
if escoria.project_settings_manager.has_setting(escoria.project_settings_manager.SFX_VOLUME):
|
if ESCProjectSettingsManager.has_setting(ESCProjectSettingsManager.SFX_VOLUME):
|
||||||
stream.volume_db = escoria.project_settings_manager.get_setting(
|
stream.volume_db = ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.SFX_VOLUME
|
ESCProjectSettingsManager.SFX_VOLUME
|
||||||
)
|
)
|
||||||
stream.play()
|
stream.play()
|
||||||
|
|
||||||
|
|||||||
@@ -67,14 +67,14 @@ func transition(
|
|||||||
_tween.connect("tween_all_completed", self, "_on_tween_completed")
|
_tween.connect("tween_all_completed", self, "_on_tween_completed")
|
||||||
|
|
||||||
if transition_name.empty():
|
if transition_name.empty():
|
||||||
transition_name = escoria.project_settings_manager.get_setting(
|
transition_name = ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.DEFAULT_TRANSITION
|
ESCProjectSettingsManager.DEFAULT_TRANSITION
|
||||||
)
|
)
|
||||||
|
|
||||||
if not has_transition(transition_name):
|
if not has_transition(transition_name):
|
||||||
escoria.logger.report_errors(
|
escoria.logger.error(
|
||||||
"transition: Transition %s not found" % transition_name,
|
self,
|
||||||
[]
|
"transition: Transition %s not found" % transition_name
|
||||||
)
|
)
|
||||||
|
|
||||||
# If this is an "instant" transition, we need to set the alpha of the base
|
# If this is an "instant" transition, we need to set the alpha of the base
|
||||||
@@ -122,8 +122,8 @@ func transition(
|
|||||||
#
|
#
|
||||||
# *Returns* the full path to the shader or an empty string, if it can't be found
|
# *Returns* the full path to the shader or an empty string, if it can't be found
|
||||||
func get_transition(name: String) -> String:
|
func get_transition(name: String) -> String:
|
||||||
for directory in escoria.project_settings_manager.get_setting(
|
for directory in ESCProjectSettingsManager.get_setting(
|
||||||
escoria.project_settings_manager.TRANSITION_PATHS
|
ESCProjectSettingsManager.TRANSITION_PATHS
|
||||||
):
|
):
|
||||||
if ResourceLoader.exists(directory.plus_file("%s.material" % name)):
|
if ResourceLoader.exists(directory.plus_file("%s.material" % name)):
|
||||||
return directory.plus_file("%s.material" % name)
|
return directory.plus_file("%s.material" % name)
|
||||||
@@ -154,5 +154,5 @@ func _on_tween_completed():
|
|||||||
if not _was_canceled:
|
if not _was_canceled:
|
||||||
_tween.stop_all()
|
_tween.stop_all()
|
||||||
_tween.remove_all()
|
_tween.remove_all()
|
||||||
escoria.logger.debug("Transition %s done." % str(transition_id))
|
escoria.logger.debug(self, "Transition %s done." % str(transition_id))
|
||||||
emit_signal("transition_done", transition_id)
|
emit_signal("transition_done", transition_id)
|
||||||
|
|||||||
@@ -2,41 +2,28 @@
|
|||||||
tool
|
tool
|
||||||
extends EditorPlugin
|
extends EditorPlugin
|
||||||
|
|
||||||
|
# The warning popup displayed on escoria-core enabling.
|
||||||
# The path to node 'escoria'.
|
var popup_info: AcceptDialog
|
||||||
const ESCORIA: String = "/root/escoria"
|
|
||||||
|
|
||||||
|
|
||||||
# Reference to "escoria" singleton instance.
|
|
||||||
var escoria_instance: Node = null
|
|
||||||
|
|
||||||
|
|
||||||
# Returns the 'escoria' singleton/autoload.
|
|
||||||
#
|
|
||||||
# *Returns*
|
|
||||||
# The escoria singleton.
|
|
||||||
func _get_escoria():
|
|
||||||
if not is_instance_valid(escoria_instance):
|
|
||||||
escoria_instance = get_node(ESCORIA)
|
|
||||||
if not is_instance_valid(escoria_instance):
|
|
||||||
printerr(
|
|
||||||
"Escoria could not load the 'escoria' singleton/autoload.\n",
|
|
||||||
"Please try to disable and re-enable 'Escoria' plugin."
|
|
||||||
)
|
|
||||||
|
|
||||||
return escoria_instance
|
|
||||||
|
|
||||||
|
|
||||||
# Virtual function called when plugin is enabled.
|
# Virtual function called when plugin is enabled.
|
||||||
func _enable_plugin():
|
func enable_plugin():
|
||||||
add_autoload_singleton(
|
add_autoload_singleton(
|
||||||
"escoria",
|
"escoria",
|
||||||
"res://addons/escoria-core/game/escoria.tscn"
|
"res://addons/escoria-core/game/esc_autoload.gd"
|
||||||
)
|
)
|
||||||
|
# Prepare settings
|
||||||
|
set_escoria_main_settings()
|
||||||
|
set_escoria_debug_settings()
|
||||||
|
set_escoria_ui_settings()
|
||||||
|
set_escoria_sound_settings()
|
||||||
|
set_escoria_platform_settings()
|
||||||
|
|
||||||
# Add input actions in InputMap
|
# Add input actions in InputMap
|
||||||
InputMap.add_action(_get_escoria().inputs_manager.SWITCH_ACTION_VERB)
|
# if not InputMap.has_action(ESCInputsManager.SWITCH_ACTION_VERB):
|
||||||
InputMap.add_action(_get_escoria().inputs_manager.ESC_SHOW_DEBUG_PROMPT)
|
# InputMap.add_action(ESCInputsManager.SWITCH_ACTION_VERB)
|
||||||
|
# if not InputMap.has_action(ESCInputsManager.ESC_SHOW_DEBUG_PROMPT):
|
||||||
|
# InputMap.add_action(ESCInputsManager.ESC_SHOW_DEBUG_PROMPT)
|
||||||
|
|
||||||
# Define standard settings
|
# Define standard settings
|
||||||
ProjectSettings.set_setting(
|
ProjectSettings.set_setting(
|
||||||
@@ -49,92 +36,103 @@ func _enable_plugin():
|
|||||||
"res://addons/escoria-core/default_bus_layout.tres"
|
"res://addons/escoria-core/default_bus_layout.tres"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
popup_info = AcceptDialog.new()
|
||||||
|
popup_info.dialog_text = """You enabled escoria-core plugin.
|
||||||
|
|
||||||
|
Please ignore error messages in Output console and reload your project using
|
||||||
|
Godot editor's "Project / Reload Current Project" menu.
|
||||||
|
"""
|
||||||
|
popup_info.connect("confirmed", self, "_on_warning_popup_confirmed", [], CONNECT_ONESHOT)
|
||||||
|
add_child(popup_info)
|
||||||
|
popup_info.popup_centered()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_warning_popup_confirmed():
|
||||||
|
popup_info.queue_free()
|
||||||
|
|
||||||
|
|
||||||
# Virtual function called when plugin is disabled.
|
# Virtual function called when plugin is disabled.
|
||||||
func _disable_plugin():
|
func disable_plugin():
|
||||||
InputMap.erase_action(_get_escoria().inputs_manager.SWITCH_ACTION_VERB)
|
|
||||||
InputMap.erase_action(_get_escoria().inputs_manager.ESC_SHOW_DEBUG_PROMPT)
|
|
||||||
remove_autoload_singleton("escoria")
|
remove_autoload_singleton("escoria")
|
||||||
|
# if InputMap.has_action(ESCInputsManager.SWITCH_ACTION_VERB):
|
||||||
|
# InputMap.erase_action(ESCInputsManager.SWITCH_ACTION_VERB)
|
||||||
|
# if InputMap.has_action(ESCInputsManager.SWITCH_ACTION_VERB):
|
||||||
|
# InputMap.erase_action(ESCInputsManager.SWITCH_ACTION_VERB)
|
||||||
|
|
||||||
|
|
||||||
# Setup Escoria
|
# Setup Escoria
|
||||||
func _enter_tree():
|
func _enter_tree():
|
||||||
_enable_plugin()
|
pass
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
# Prepare settings
|
ProjectSettings.save_custom("escoria.godot")
|
||||||
set_escoria_main_settings()
|
|
||||||
set_escoria_debug_settings()
|
|
||||||
set_escoria_ui_settings()
|
|
||||||
set_escoria_sound_settings()
|
|
||||||
set_escoria_platform_settings()
|
|
||||||
ProjectSettings.save()
|
|
||||||
|
|
||||||
|
|
||||||
# Prepare the settings in the Escoria UI category
|
# Prepare the settings in the Escoria UI category
|
||||||
func set_escoria_ui_settings():
|
func set_escoria_ui_settings():
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.DEFAULT_DIALOG_TYPE,
|
ESCProjectSettingsManager.DEFAULT_DIALOG_TYPE,
|
||||||
"",
|
"",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING
|
"type": TYPE_STRING
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
print("DEFAULT DIALOG TYPE RESET !!!")
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.GAME_SCENE,
|
ESCProjectSettingsManager.GAME_SCENE,
|
||||||
"",
|
"",
|
||||||
{
|
{
|
||||||
"name": _get_escoria().project_settings_manager.GAME_SCENE,
|
"name": ESCProjectSettingsManager.GAME_SCENE,
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
"hint": PROPERTY_HINT_FILE,
|
"hint": PROPERTY_HINT_FILE,
|
||||||
"hint_string": "*.tscn, *.scn"
|
"hint_string": "*.tscn, *.scn"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.ITEMS_AUTOREGISTER_PATH,
|
ESCProjectSettingsManager.ITEMS_AUTOREGISTER_PATH,
|
||||||
"res://game/items/escitems/",
|
"res://game/items/inventory/",
|
||||||
{
|
{
|
||||||
"name": _get_escoria().project_settings_manager.ITEMS_AUTOREGISTER_PATH,
|
"name": ESCProjectSettingsManager.ITEMS_AUTOREGISTER_PATH,
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
"hint": PROPERTY_HINT_DIR
|
"hint": PROPERTY_HINT_DIR
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.DEFAULT_TRANSITION,
|
ESCProjectSettingsManager.DEFAULT_TRANSITION,
|
||||||
"curtain",
|
"curtain",
|
||||||
{
|
{
|
||||||
"name": _get_escoria().project_settings_manager.DEFAULT_TRANSITION,
|
"name": ESCProjectSettingsManager.DEFAULT_TRANSITION,
|
||||||
"type": TYPE_STRING
|
"type": TYPE_STRING
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.TRANSITION_PATHS,
|
ESCProjectSettingsManager.TRANSITION_PATHS,
|
||||||
[
|
[
|
||||||
"res://addons/escoria-core/game/scenes/transitions/shaders/"
|
"res://addons/escoria-core/game/scenes/transitions/shaders/"
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
"name": _get_escoria().project_settings_manager.TRANSITION_PATHS,
|
"name": ESCProjectSettingsManager.TRANSITION_PATHS,
|
||||||
"type": TYPE_STRING_ARRAY,
|
"type": TYPE_STRING_ARRAY,
|
||||||
"hint": PROPERTY_HINT_DIR
|
"hint": PROPERTY_HINT_DIR
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.INVENTORY_ITEM_SIZE,
|
ESCProjectSettingsManager.INVENTORY_ITEM_SIZE,
|
||||||
Vector2(72, 72),
|
Vector2(72, 72),
|
||||||
{
|
{
|
||||||
"name": _get_escoria().project_settings_manager.INVENTORY_ITEM_SIZE,
|
"name": ESCProjectSettingsManager.INVENTORY_ITEM_SIZE,
|
||||||
"type": TYPE_VECTOR2
|
"type": TYPE_VECTOR2
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.DIALOG_MANAGERS,
|
ESCProjectSettingsManager.DIALOG_MANAGERS,
|
||||||
[],
|
[],
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING_ARRAY
|
"type": TYPE_STRING_ARRAY
|
||||||
@@ -144,16 +142,16 @@ func set_escoria_ui_settings():
|
|||||||
|
|
||||||
# Prepare the settings in the Escoria main category
|
# Prepare the settings in the Escoria main category
|
||||||
func set_escoria_main_settings():
|
func set_escoria_main_settings():
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.GAME_VERSION,
|
ESCProjectSettingsManager.GAME_VERSION,
|
||||||
"",
|
"",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING
|
"type": TYPE_STRING
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.GAME_START_SCRIPT,
|
ESCProjectSettingsManager.GAME_START_SCRIPT,
|
||||||
"",
|
"",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
@@ -162,16 +160,16 @@ func set_escoria_main_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.FORCE_QUIT,
|
ESCProjectSettingsManager.FORCE_QUIT,
|
||||||
true,
|
true,
|
||||||
{
|
{
|
||||||
"type": TYPE_BOOL
|
"type": TYPE_BOOL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.COMMAND_DIRECTORIES,
|
ESCProjectSettingsManager.COMMAND_DIRECTORIES,
|
||||||
[
|
[
|
||||||
"res://addons/escoria-core/game/core-scripts/esc/commands"
|
"res://addons/escoria-core/game/core-scripts/esc/commands"
|
||||||
],
|
],
|
||||||
@@ -180,8 +178,8 @@ func set_escoria_main_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.TEXT_LANG,
|
ESCProjectSettingsManager.TEXT_LANG,
|
||||||
TranslationServer.get_locale(),
|
TranslationServer.get_locale(),
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
@@ -189,8 +187,8 @@ func set_escoria_main_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.VOICE_LANG,
|
ESCProjectSettingsManager.VOICE_LANG,
|
||||||
TranslationServer.get_locale(),
|
TranslationServer.get_locale(),
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
@@ -198,8 +196,8 @@ func set_escoria_main_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.SAVEGAMES_PATH,
|
ESCProjectSettingsManager.SAVEGAMES_PATH,
|
||||||
"user://saves/",
|
"user://saves/",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
@@ -207,8 +205,8 @@ func set_escoria_main_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.SETTINGS_PATH,
|
ESCProjectSettingsManager.SETTINGS_PATH,
|
||||||
"user://",
|
"user://",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
@@ -216,8 +214,8 @@ func set_escoria_main_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.GAME_MIGRATION_PATH,
|
ESCProjectSettingsManager.GAME_MIGRATION_PATH,
|
||||||
"",
|
"",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
@@ -228,42 +226,42 @@ func set_escoria_main_settings():
|
|||||||
|
|
||||||
# Prepare the settings in the Escoria debug category
|
# Prepare the settings in the Escoria debug category
|
||||||
func set_escoria_debug_settings():
|
func set_escoria_debug_settings():
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.TERMINATE_ON_WARNINGS,
|
ESCProjectSettingsManager.TERMINATE_ON_WARNINGS,
|
||||||
false,
|
false,
|
||||||
{
|
{
|
||||||
"type": TYPE_BOOL
|
"type": TYPE_BOOL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.TERMINATE_ON_ERRORS,
|
ESCProjectSettingsManager.TERMINATE_ON_ERRORS,
|
||||||
true,
|
true,
|
||||||
{
|
{
|
||||||
"type": TYPE_BOOL
|
"type": TYPE_BOOL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.DEVELOPMENT_LANG,
|
ESCProjectSettingsManager.DEVELOPMENT_LANG,
|
||||||
"en",
|
"en",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING
|
"type": TYPE_STRING
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.LOG_LEVEL,
|
ESCProjectSettingsManager.LOG_LEVEL,
|
||||||
"ERROR",
|
"ERROR",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
"hint": PROPERTY_HINT_ENUM,
|
"hint": PROPERTY_HINT_ENUM,
|
||||||
"hint_string": "ERROR,WARNING,INFO,DEBUG"
|
"hint_string": "ERROR,WARNING,INFO,DEBUG,TRACE"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.LOG_FILE_PATH,
|
ESCProjectSettingsManager.LOG_FILE_PATH,
|
||||||
"user://",
|
"user://",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
@@ -271,8 +269,8 @@ func set_escoria_debug_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.LOG_FILE_PATH,
|
ESCProjectSettingsManager.CRASH_MESSAGE,
|
||||||
"We're sorry, but the game crashed. Please send us the " +
|
"We're sorry, but the game crashed. Please send us the " +
|
||||||
"following files:\n\n%s",
|
"following files:\n\n%s",
|
||||||
{
|
{
|
||||||
@@ -281,28 +279,28 @@ func set_escoria_debug_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.ENABLE_ROOM_SELECTOR,
|
ESCProjectSettingsManager.ENABLE_ROOM_SELECTOR,
|
||||||
false,
|
false,
|
||||||
{
|
{
|
||||||
"type": TYPE_BOOL
|
"type": TYPE_BOOL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.ROOM_SELECTOR_ROOM_DIR,
|
ESCProjectSettingsManager.ROOM_SELECTOR_ROOM_DIR,
|
||||||
"",
|
"",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
"hint": PROPERTY_HINT_DIR
|
"hint": PROPERTY_HINT_DIR
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Prepare the settings in the Escoria sound settings
|
# Prepare the settings in the Escoria sound settings
|
||||||
func set_escoria_sound_settings():
|
func set_escoria_sound_settings():
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.MASTER_VOLUME,
|
ESCProjectSettingsManager.MASTER_VOLUME,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
"type": TYPE_REAL,
|
"type": TYPE_REAL,
|
||||||
@@ -311,8 +309,8 @@ func set_escoria_sound_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.MUSIC_VOLUME,
|
ESCProjectSettingsManager.MUSIC_VOLUME,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
"type": TYPE_REAL,
|
"type": TYPE_REAL,
|
||||||
@@ -321,8 +319,8 @@ func set_escoria_sound_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.SFX_VOLUME,
|
ESCProjectSettingsManager.SFX_VOLUME,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
"type": TYPE_REAL,
|
"type": TYPE_REAL,
|
||||||
@@ -331,8 +329,8 @@ func set_escoria_sound_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.SPEECH_VOLUME,
|
ESCProjectSettingsManager.SPEECH_VOLUME,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
"type": TYPE_REAL,
|
"type": TYPE_REAL,
|
||||||
@@ -341,16 +339,16 @@ func set_escoria_sound_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.SPEECH_ENABLED,
|
ESCProjectSettingsManager.SPEECH_ENABLED,
|
||||||
1,
|
true,
|
||||||
{
|
{
|
||||||
"type": TYPE_BOOL
|
"type": TYPE_BOOL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.SPEECH_FOLDER,
|
ESCProjectSettingsManager.SPEECH_FOLDER,
|
||||||
"res://speech",
|
"res://speech",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING,
|
"type": TYPE_STRING,
|
||||||
@@ -358,8 +356,8 @@ func set_escoria_sound_settings():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.SPEECH_EXTENSION,
|
ESCProjectSettingsManager.SPEECH_EXTENSION,
|
||||||
"ogg",
|
"ogg",
|
||||||
{
|
{
|
||||||
"type": TYPE_STRING
|
"type": TYPE_STRING
|
||||||
@@ -374,16 +372,16 @@ func set_escoria_platform_settings():
|
|||||||
# scenes.
|
# scenes.
|
||||||
# If set to true, all generic scenes (UI, inventory, etc) will be loaded
|
# If set to true, all generic scenes (UI, inventory, etc) will be loaded
|
||||||
# as any other scene.
|
# as any other scene.
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.SKIP_CACHE,
|
ESCProjectSettingsManager.SKIP_CACHE,
|
||||||
false,
|
false,
|
||||||
{
|
{
|
||||||
"type": TYPE_BOOL
|
"type": TYPE_BOOL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_get_escoria().project_settings_manager.register_setting(
|
register_setting(
|
||||||
_get_escoria().project_settings_manager.SKIP_CACHE_MOBILE,
|
ESCProjectSettingsManager.SKIP_CACHE_MOBILE,
|
||||||
true,
|
true,
|
||||||
{
|
{
|
||||||
"type": TYPE_BOOL
|
"type": TYPE_BOOL
|
||||||
@@ -391,7 +389,18 @@ func set_escoria_platform_settings():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Uninstall plugin
|
# Register a new project setting if it hasn't been defined already
|
||||||
func _exit_tree():
|
#
|
||||||
_disable_plugin()
|
# #### Parameters
|
||||||
|
#
|
||||||
|
# - name: Name of the project setting
|
||||||
|
# - default: Default value
|
||||||
|
# - info: Property info for the setting
|
||||||
|
static func register_setting(name: String, default, info: Dictionary) -> void:
|
||||||
|
if not ProjectSettings.has_setting(name):
|
||||||
|
ProjectSettings.set_setting(
|
||||||
|
name,
|
||||||
|
default
|
||||||
|
)
|
||||||
|
info.name = name
|
||||||
|
ProjectSettings.add_property_info(info)
|
||||||
|
|||||||
@@ -29,3 +29,16 @@ func remove_item(inventory_item: ESCInventoryItem):
|
|||||||
if c is ESCInventoryButton and c.global_id == inventory_item.global_id:
|
if c is ESCInventoryButton and c.global_id == inventory_item.global_id:
|
||||||
remove_child(c)
|
remove_child(c)
|
||||||
c.queue_free()
|
c.queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
# Return an Inventory button from the container, using an ESCInventoryItem
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - inventory_item: Inventory item to return the button node from
|
||||||
|
func get_inventory_button(inventory_item: ESCInventoryItem) -> ESCInventoryButton:
|
||||||
|
var inventory_button = null
|
||||||
|
for c in get_children():
|
||||||
|
if c.global_id == inventory_item.global_id:
|
||||||
|
inventory_button = c
|
||||||
|
break
|
||||||
|
return inventory_button
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ func _ready() -> void:
|
|||||||
$VBoxContainer/MarginContainer/options/flags
|
$VBoxContainer/MarginContainer/options/flags
|
||||||
for child in _flags_container.get_children():
|
for child in _flags_container.get_children():
|
||||||
_flags_container.remove_child(child)
|
_flags_container.remove_child(child)
|
||||||
|
child.queue_free()
|
||||||
|
|
||||||
_loaded_languages = []
|
_loaded_languages = []
|
||||||
|
|
||||||
@@ -38,7 +39,6 @@ func _ready() -> void:
|
|||||||
_flags_container.add_child(_lang)
|
_flags_container.add_child(_lang)
|
||||||
_lang.connect("gui_input", self, "_on_language_input", [lang])
|
_lang.connect("gui_input", self, "_on_language_input", [lang])
|
||||||
|
|
||||||
|
|
||||||
# Show the options
|
# Show the options
|
||||||
func show():
|
func show():
|
||||||
backup_settings = escoria.settings.duplicate()
|
backup_settings = escoria.settings.duplicate()
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ var _options_paths = []
|
|||||||
|
|
||||||
# Build up the list of rooms
|
# Build up the list of rooms
|
||||||
func _ready():
|
func _ready():
|
||||||
var rooms_folder = ProjectSettings.get_setting(
|
var rooms_folder = ESCProjectSettingsManager.get_setting(
|
||||||
"escoria/debug/room_selector_room_dir"
|
ESCProjectSettingsManager.ROOM_SELECTOR_ROOM_DIR
|
||||||
)
|
)
|
||||||
if rooms_folder == "" or \
|
if rooms_folder == "" or \
|
||||||
not ProjectSettings.get_setting(
|
not ESCProjectSettingsManager.get_setting(
|
||||||
"escoria/debug/enable_room_selector"
|
ESCProjectSettingsManager.ENABLE_ROOM_SELECTOR
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
var dir = Directory.new()
|
var dir = Directory.new()
|
||||||
@@ -44,8 +44,10 @@ func _ready():
|
|||||||
])
|
])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
escoria.logger.report_warnings("room_select.gd:_ready()",
|
escoria.logger.warn(
|
||||||
["A problem occurred while opening rooms folder."])
|
self,
|
||||||
|
"A problem occurred while opening rooms folder %s." % str(path)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Switch to the selected room
|
# Switch to the selected room
|
||||||
|
|||||||
@@ -2,59 +2,95 @@
|
|||||||
tool
|
tool
|
||||||
extends EditorPlugin
|
extends EditorPlugin
|
||||||
|
|
||||||
|
|
||||||
var _escoria
|
|
||||||
|
|
||||||
const MANAGER_CLASS="res://addons/escoria-dialog-simple/esc_dialog_simple.gd"
|
const MANAGER_CLASS="res://addons/escoria-dialog-simple/esc_dialog_simple.gd"
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
# Override function to return the plugin name.
|
||||||
_escoria = preload("res://addons/escoria-core/game/escoria.tscn")\
|
func get_plugin_name():
|
||||||
.instance()
|
return "escoria-dialog-simple"
|
||||||
|
|
||||||
|
|
||||||
# Register ourselves after setup
|
|
||||||
func _ready() -> void:
|
|
||||||
call_deferred("_register")
|
|
||||||
|
|
||||||
|
|
||||||
# Unregister ourselves
|
# Unregister ourselves
|
||||||
func _exit_tree() -> void:
|
func disable_plugin():
|
||||||
_escoria.deregister_dialog_manager(MANAGER_CLASS)
|
print("Disabling plugin Escoria Dialog Simple")
|
||||||
|
ESCProjectSettingsManager.register_setting(
|
||||||
|
ESCProjectSettingsManager.DEFAULT_DIALOG_TYPE,
|
||||||
|
"",
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
ESCProjectSettingsManager.register_setting(
|
||||||
|
ESCProjectSettingsManager.AVATARS_PATH,
|
||||||
|
null,
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
|
ESCProjectSettingsManager.register_setting(
|
||||||
|
ESCProjectSettingsManager.TEXT_SPEED_PER_CHARACTER,
|
||||||
|
null,
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
|
ESCProjectSettingsManager.register_setting(
|
||||||
|
ESCProjectSettingsManager.FAST_TEXT_SPEED_PER_CHARACTER,
|
||||||
|
null,
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
|
ESCProjectSettingsManager.register_setting(
|
||||||
|
ESCProjectSettingsManager.MAX_TIME_TO_DISAPPEAR,
|
||||||
|
null,
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
|
EscoriaPlugin.deregister_dialog_manager(MANAGER_CLASS)
|
||||||
|
|
||||||
|
|
||||||
# Add ourselves to the list of dialog managers
|
# Add ourselves to the list of dialog managers
|
||||||
func _register():
|
func enable_plugin():
|
||||||
_escoria.register_dialog_manager(MANAGER_CLASS)
|
print("Enabling plugin Escoria Dialog Simple")
|
||||||
_escoria.project_settings_manager.register_setting(
|
if EscoriaPlugin.register_dialog_manager(self, MANAGER_CLASS):
|
||||||
_escoria.project_settings_manager.AVATARS_PATH,
|
ESCProjectSettingsManager.register_setting(
|
||||||
"",
|
ESCProjectSettingsManager.DEFAULT_DIALOG_TYPE,
|
||||||
{
|
"floating",
|
||||||
"type": TYPE_STRING,
|
{
|
||||||
"hint": PROPERTY_HINT_DIR
|
"type": TYPE_STRING
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ESCProjectSettingsManager.register_setting(
|
||||||
|
ESCProjectSettingsManager.AVATARS_PATH,
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
"type": TYPE_STRING,
|
||||||
|
"hint": PROPERTY_HINT_DIR
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
_escoria.project_settings_manager.register_setting(
|
ESCProjectSettingsManager.register_setting(
|
||||||
_escoria.project_settings_manager.TEXT_SPEED_PER_CHARACTER,
|
ESCProjectSettingsManager.TEXT_SPEED_PER_CHARACTER,
|
||||||
0.1,
|
0.1,
|
||||||
{
|
{
|
||||||
"type": TYPE_REAL
|
"type": TYPE_REAL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_escoria.project_settings_manager.register_setting(
|
ESCProjectSettingsManager.register_setting(
|
||||||
_escoria.project_settings_manager.FAST_TEXT_SPEED_PER_CHARACTER,
|
ESCProjectSettingsManager.FAST_TEXT_SPEED_PER_CHARACTER,
|
||||||
0.25,
|
0.25,
|
||||||
{
|
{
|
||||||
"type": TYPE_REAL
|
"type": TYPE_REAL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_escoria.project_settings_manager.register_setting(
|
ESCProjectSettingsManager.register_setting(
|
||||||
_escoria.project_settings_manager.MAX_TIME_TO_DISAPPEAR,
|
ESCProjectSettingsManager.MAX_TIME_TO_DISAPPEAR,
|
||||||
1.0,
|
1.0,
|
||||||
{
|
{
|
||||||
"type": TYPE_REAL
|
"type": TYPE_REAL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
get_editor_interface().set_plugin_enabled(
|
||||||
|
get_plugin_name(),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user