Finished ESC camera commands reimplementation.
Some cleaning done, and all logging commands put in escoria.logger script.
This commit is contained in:
@@ -88,7 +88,7 @@ func _process(time):
|
||||
else:
|
||||
bypass_missing_animation = true
|
||||
current_animation = animation_to_play
|
||||
escoria.report_warnings("movable.gd:_process()",
|
||||
escoria.logger.report_warnings("movable.gd:_process()",
|
||||
["Character " + parent.global_id + " has no animation " + animation_to_play,
|
||||
"Bypassing missing animation and proceed movement."], true)
|
||||
|
||||
@@ -106,16 +106,18 @@ func teleport(target, angle : Object = null) -> void:
|
||||
target can be Vector2 or Object
|
||||
"""
|
||||
if typeof(target) == TYPE_VECTOR2:
|
||||
printt("Item teleported at position", target, "with angle", angle)
|
||||
escoria.logger.info("Object " + target + " teleported at position" +
|
||||
str(target) + "with angle", [angle])
|
||||
parent.position = target
|
||||
elif typeof(target) == TYPE_OBJECT:
|
||||
if target.get("interact_positions") != null:
|
||||
parent.position = target.interact_positions.default #.global_position
|
||||
else:
|
||||
parent.position = target.position
|
||||
printt("Item teleported at", target.name, "position", parent.position, "with angle", angle)
|
||||
escoria.logger.info("Object " + target.name + " teleported at position "
|
||||
+ str(parent.position) + " with angle ", str(angle))
|
||||
else:
|
||||
escoria.report_errors("escitem.gd:teleport()", ["Target to teleport to is null or unusable (" + target + ")"])
|
||||
escoria.logger.report_errors("escitem.gd:teleport()", ["Target to teleport to is null or unusable (" + target + ")"])
|
||||
|
||||
# PUBLIC FUNCTION
|
||||
func walk_to(pos : Vector2, p_walk_context = null):
|
||||
@@ -208,7 +210,7 @@ func walk_stop(pos):
|
||||
# walk_context = null
|
||||
|
||||
yield(parent.animation_sprite, "animation_finished")
|
||||
printt(parent.global_id + " arrived at ", walk_context)
|
||||
escoria.logger.info(parent.global_id + " arrived at " + str(walk_context))
|
||||
parent.emit_signal("arrived", walk_context)
|
||||
|
||||
|
||||
@@ -271,7 +273,7 @@ func _get_dir_deg(deg : int, animations) -> int:
|
||||
|
||||
# It's an error to have the animations misconfigured
|
||||
if dir == -1:
|
||||
escoria.report_errors("escitem.gd:_get_dir_deg()", ["No direction found for " + str(deg)])
|
||||
escoria.logger.report_errors("escitem.gd:_get_dir_deg()", ["No direction found for " + str(deg)])
|
||||
|
||||
return dir
|
||||
|
||||
@@ -315,7 +317,7 @@ Whatever the implementation, this should be activated using "parameter "immediat
|
||||
"""
|
||||
func set_angle(deg : int, immediate = true):
|
||||
if deg < 0 or deg > 360:
|
||||
escoria.report_errors("movable.gd:set_angle()", ["Invalid degree to turn to " + str(deg)])
|
||||
escoria.logger.report_errors("movable.gd:set_angle()", ["Invalid degree to turn to " + str(deg)])
|
||||
moved = true
|
||||
last_deg = deg
|
||||
last_dir = _get_dir_deg(deg, parent.animations)
|
||||
|
||||
@@ -49,7 +49,7 @@ var commands = {
|
||||
"inc_global": { "min_args": 2, "types": [TYPE_STRING, TYPE_INT] },
|
||||
"inventory_add": { "min_args": 1 },
|
||||
"inventory_remove": { "min_args": 1 },
|
||||
"inventory_open": { "min_args": 1, "types": [TYPE_BOOL] },
|
||||
"inventory_display": { "min_args": 1, "types": [TYPE_BOOL] },
|
||||
"jump": { "min_args": 1 },
|
||||
"play_snd": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
|
||||
"queue_animation": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
|
||||
@@ -76,6 +76,7 @@ var commands = {
|
||||
"wait": true,
|
||||
"walk": { "min_args": 2 },
|
||||
"walk_to_pos": { "min_args": 3},
|
||||
"walk_to_pos_block": { "min_args": 3},
|
||||
"walk_block": { "min_args": 2 },
|
||||
|
||||
"%": { "alias": "label", "min_args": 1},
|
||||
@@ -96,7 +97,7 @@ var debug_commands = {
|
||||
func load_esc_file(esc_file_path : String) -> Dictionary:
|
||||
var f = File.new()
|
||||
if !f.file_exists(esc_file_path):
|
||||
escoria.report_errors("esc_compiler.gd:load_esc_file()", ["File " + esc_file_path + " not found."])
|
||||
escoria.logger.report_errors("esc_compiler.gd:load_esc_file()", ["File " + esc_file_path + " not found."])
|
||||
return {}
|
||||
return compile_script(esc_file_path)
|
||||
|
||||
@@ -114,7 +115,7 @@ func compile_script(p_path : String) -> Dictionary:
|
||||
var errors = []
|
||||
ev_table = compile(p_path, errors)
|
||||
if errors.size() > 0:
|
||||
escoria.call_deferred("report_errors", p_path, errors)
|
||||
escoria.logger.call_deferred("report_errors", p_path, errors)
|
||||
return ev_table
|
||||
|
||||
func check_command(commands_list : Dictionary, cmd : esctypes.ESCCommand, state : esctypes.ESCState, errors : Array):
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
extends Node
|
||||
|
||||
# This is the script that runs in background, checking for events in the events stack
|
||||
# and executing them.
|
||||
# Events are managed using 2 structures:
|
||||
# - event_queue: a queue for scheduled events. On each iteration, every event in the queue is updated
|
||||
# according time delta. If an event time occurs, it is run (see check_event_queue()).
|
||||
# - levels_stack: stack of events to be run immediately (from an event in ESC file usually)
|
||||
"""
|
||||
This is the script that runs in background, checking for events in the events
|
||||
stack and executing them.
|
||||
Events are managed using 2 structures:
|
||||
- event_queue: a queue for scheduled events. On each iteration, every event
|
||||
in the queue is updated according time delta. If an event time occurs, it is run
|
||||
(see check_event_queue()).
|
||||
- levels_stack: stack of events to be run immediately (from an event in ESC file
|
||||
usually)
|
||||
"""
|
||||
|
||||
signal global_changed(global_name)
|
||||
signal inventory_changed
|
||||
@@ -18,7 +22,6 @@ signal action_changed
|
||||
signal paused(p_paused)
|
||||
|
||||
onready var resource_cache = load("res://addons/escoria-core/game/core-scripts/resource_queue.gd").new()
|
||||
#save_data = load(ProjectSettings.get_setting("escoria/internals/save_data")).new()
|
||||
onready var save_data = load("res://addons/escoria-core/game/core-scripts/save_data/save_data.gd").new()
|
||||
|
||||
# Cached scenes
|
||||
@@ -80,14 +83,14 @@ func _ready():
|
||||
randomize()
|
||||
save_data.load_settings([self, "settings_loaded"])
|
||||
|
||||
printt("calling res cache start")
|
||||
printt("Calling resource cache start")
|
||||
resource_cache.start()
|
||||
|
||||
if !ProjectSettings.get_setting("escoria/platform/skip_cache"):
|
||||
scenes_cache_list.push_back(ProjectSettings.get_setting("escoria/main/curtain"))
|
||||
scenes_cache_list.push_back(ProjectSettings.get_setting("escoria/main/hud"))
|
||||
|
||||
printt("cache list ", scenes_cache_list)
|
||||
printt("Cache list ", [scenes_cache_list])
|
||||
for s in scenes_cache_list:
|
||||
if s != null:
|
||||
resource_cache.queue_resource(s, false, true)
|
||||
@@ -265,7 +268,7 @@ func get_global(name):
|
||||
#
|
||||
func set_global(name, val, force_change_reserved : bool = false):
|
||||
if name in reserved_globals and !force_change_reserved:
|
||||
escoria.report_warnings("esc_runner.gd:set_global()",
|
||||
escoria.logger.report_warnings("esc_runner.gd:set_global()",
|
||||
["Global " + name + " is reserved. Value not modified."])
|
||||
return
|
||||
globals[name] = val
|
||||
@@ -304,12 +307,28 @@ func is_global_less_than(name, val):
|
||||
if global and val and int(global) < int(val):
|
||||
return true
|
||||
|
||||
func jump(p_label):
|
||||
while levels_stack.size() > 0:
|
||||
var top = levels_stack[levels_stack.size()-1]
|
||||
printt("top labels: ", top.labels, p_label)
|
||||
if p_label in top.labels:
|
||||
top.ip = top.labels[p_label]
|
||||
return
|
||||
else:
|
||||
if top.break_stop || levels_stack.size() == 1:
|
||||
escoria.logger.report_errors("esc_runner.gd:jump()",
|
||||
["ESC: Jump to inexisting label: " + p_label])
|
||||
levels_stack.remove(levels_stack.size()-1)
|
||||
break
|
||||
else:
|
||||
levels_stack.remove(levels_stack.size()-1)
|
||||
|
||||
func check_autosave():
|
||||
pass
|
||||
|
||||
func set_current_action(action : String):
|
||||
if ! action is String:
|
||||
escoria.report_errors("esc_runner.gd",
|
||||
escoria.logger.report_errors("esc_runner.gd",
|
||||
["Trying to set_current_action: " + str(typeof(action))])
|
||||
|
||||
if action != current_action:
|
||||
@@ -325,7 +344,7 @@ func clear_current_tool():
|
||||
current_tool = null
|
||||
|
||||
func change_scene(params, context, run_events=true):
|
||||
printt("change scene to ", params[0], " with run_events ", run_events)
|
||||
escoria.logger.info("Change scene to " + params[0] + " with run_events " + str(run_events))
|
||||
# check_cache()
|
||||
# main.clear_scene()
|
||||
# camera = null
|
||||
@@ -341,10 +360,10 @@ func change_scene(params, context, run_events=true):
|
||||
var res_room = resource_cache.get_resource(params[0])
|
||||
var res_game = resource_cache.get_resource(ProjectSettings.get_setting("escoria/ui/game_scene"))
|
||||
if !res_room:
|
||||
escoria.report_errors("esc_runner.gd:change_scene()",
|
||||
escoria.logger.report_errors("esc_runner.gd:change_scene()",
|
||||
["Resource not found: " + params[0]])
|
||||
if !res_game:
|
||||
escoria.report_errors("esc_runner.gd:change_scene()",
|
||||
escoria.logger.report_errors("esc_runner.gd:change_scene()",
|
||||
["Resource not found: " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
||||
|
||||
resource_cache.clear()
|
||||
@@ -352,7 +371,7 @@ func change_scene(params, context, run_events=true):
|
||||
# Load game scene
|
||||
var game_scene = res_game.instance()
|
||||
if !game_scene:
|
||||
escoria.report_errors("esc_runner.gd:change_scene()",
|
||||
escoria.logger.report_errors("esc_runner.gd:change_scene()",
|
||||
["Failed loading scene " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
||||
|
||||
# Load room scene
|
||||
@@ -380,7 +399,7 @@ func change_scene(params, context, run_events=true):
|
||||
scenes_cache_list.push_back(params[0])
|
||||
scenes_cache[room_scene.global_id] = params[0]
|
||||
else:
|
||||
escoria.report_errors("esc_runner.gd:change_scene()",
|
||||
escoria.logger.report_errors("esc_runner.gd:change_scene()",
|
||||
["Failed loading scene " + params[0]])
|
||||
|
||||
if context != null:
|
||||
@@ -411,10 +430,10 @@ func superpose_scene(params, context, run_events=true):
|
||||
var res_room = resource_cache.get_resource(params[0])
|
||||
var res_game = resource_cache.get_resource(ProjectSettings.get_setting("escoria/ui/game_scene"))
|
||||
if !res_room:
|
||||
escoria.report_errors("esc_runner.gd:superpose_scene()",
|
||||
escoria.logger.report_errors("esc_runner.gd:superpose_scene()",
|
||||
["Resource not found: " + params[0]])
|
||||
if !res_game:
|
||||
escoria.report_errors("esc_runner.gd:superpose_scene()",
|
||||
escoria.logger.report_errors("esc_runner.gd:superpose_scene()",
|
||||
["Resource not found: " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
||||
|
||||
resource_cache.clear()
|
||||
@@ -422,14 +441,21 @@ func superpose_scene(params, context, run_events=true):
|
||||
# Load game scene
|
||||
var game_scene = res_game.instance()
|
||||
if !game_scene:
|
||||
escoria.report_errors("esc_runner.gd:superpose_scene()",
|
||||
escoria.logger.report_errors("esc_runner.gd:superpose_scene()",
|
||||
["Failed loading scene " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
||||
|
||||
# Load room scene
|
||||
var room_scene = res_room.instance()
|
||||
if room_scene:
|
||||
get_node("/root").add_child(room_scene)
|
||||
|
||||
|
||||
var target = context.get("set_position")
|
||||
if target:
|
||||
if target is Vector2:
|
||||
room_scene.set_position(target)
|
||||
if target is String:
|
||||
var obj = get_object(target)
|
||||
room_scene.set_position(obj.get_global_position())
|
||||
|
||||
escoria.inputs_manager.hotspot_focused = false
|
||||
if !scenes_cache_list.has(params[0]):
|
||||
@@ -439,7 +465,7 @@ func superpose_scene(params, context, run_events=true):
|
||||
else:
|
||||
scenes_cache[room_scene.name] = params[0]
|
||||
else:
|
||||
escoria.report_errors("esc_runner.gd:superpose_scene()",
|
||||
escoria.logger.report_errors("esc_runner.gd:superpose_scene()",
|
||||
["Failed loading scene " + params[0]])
|
||||
|
||||
if context != null:
|
||||
@@ -448,13 +474,11 @@ func superpose_scene(params, context, run_events=true):
|
||||
# Re-apply actives
|
||||
for active in actives:
|
||||
set_active(active, actives[active])
|
||||
|
||||
|
||||
# cam_target = null
|
||||
# autosave_pending = true
|
||||
|
||||
|
||||
|
||||
|
||||
func run_game(actions : Dictionary):
|
||||
set_process(true)
|
||||
# `load` and `ready` are exclusive because you probably don't want to
|
||||
@@ -487,11 +511,11 @@ func clear():
|
||||
|
||||
func register_object(name : String, val : Object, force : bool = false):
|
||||
if !name:
|
||||
escoria.report_errors("esc_runner.gd:register_object()",
|
||||
escoria.logger.report_errors("esc_runner.gd:register_object()",
|
||||
["global_id not given for " + val.get_class() + " " + val.name])
|
||||
|
||||
if name in objects and not force:
|
||||
escoria.report_errors("esc_runner.gd:register_object()",
|
||||
escoria.logger.report_errors("esc_runner.gd:register_object()",
|
||||
["Trying to register already registered object " + name + ": " \
|
||||
+ val.get_class() + " (" + val.name + ")"])
|
||||
|
||||
@@ -528,7 +552,7 @@ func get_object(name):
|
||||
# p_params Array
|
||||
# - 0 Object Target object
|
||||
func activate(p_action : String, p_param : Array):
|
||||
printt("Action", p_action, "with params", p_param)
|
||||
escoria.logger.info("Action " + p_action + " with params ", [p_param])
|
||||
# if p_param[0].global_id:
|
||||
# printt("("+p_param[0].global_id+")")
|
||||
var what = p_param[0]
|
||||
@@ -539,8 +563,8 @@ func activate(p_action : String, p_param : Array):
|
||||
if what is ESCItem and what.use_from_inventory_only:
|
||||
if !inventory_has(what.global_id):
|
||||
# TODO Either use fallback here, or run pickup action before use
|
||||
escoria.report_warnings("esc_runner.gd:activate()", ["Trying to "
|
||||
+ p_action + " on object " + what.global_id
|
||||
escoria.logger.report_warnings("esc_runner.gd:activate()",
|
||||
["Trying to " + p_action + " on object " + what.global_id
|
||||
+ " but item must be in inventory."])
|
||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||
else:
|
||||
@@ -570,7 +594,7 @@ func activate(p_action : String, p_param : Array):
|
||||
if combine_with.get("combine_is_one_way") != null \
|
||||
and combine_with.combine_is_one_way:
|
||||
errors.append("Reason: " + combine_with.global_id + "'s item interaction is one-way.")
|
||||
escoria.report_warnings("esc_runner.gd:activate()", errors)
|
||||
escoria.logger.report_warnings("esc_runner.gd:activate()", errors)
|
||||
|
||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||
else:
|
||||
@@ -588,13 +612,13 @@ func activate(p_action : String, p_param : Array):
|
||||
if p_action in objects_events_table[what.global_id]:
|
||||
run_event(objects_events_table[what.global_id][p_action])
|
||||
else:
|
||||
escoria.report_warnings("esc_runner.gd:activate()",
|
||||
escoria.logger.report_warnings("esc_runner.gd:activate()",
|
||||
["Action '" + p_action + "' requested on object '" \
|
||||
+ what.global_id + "' but action doesn't exist in attached ESC file.",
|
||||
"TODO: manage fallbacks."])
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
else:
|
||||
escoria.report_warnings("esc_runner.gd:activate()",
|
||||
escoria.logger.report_warnings("esc_runner.gd:activate()",
|
||||
["Action '" + p_action + "' requested on object '" + what.global_id \
|
||||
+ "' but object does not exist in objects_events_table.", \
|
||||
"Does object " + what.global_id + " have an attached ESC file?"])
|
||||
@@ -662,7 +686,7 @@ func set_state(global_id : String, p_params : Array):
|
||||
var animation = actual_animator.get_animation(p_params[0])
|
||||
var animation_length = animation.length
|
||||
animation_node.seek(animation_length)
|
||||
print_debug("Item " + obj.global_id + " changed state to: " + p_params[0])
|
||||
escoria.logger.info("Item " + obj.global_id + " changed state to: " + p_params[0])
|
||||
|
||||
"""
|
||||
When object is active, it is VISIBLE.
|
||||
@@ -698,7 +722,7 @@ func object_exit_scene(name : String):
|
||||
if inventory_has(name):
|
||||
objects[name] = objects[name].duplicate()
|
||||
else:
|
||||
printt("Object " + name + " removed from scene.")
|
||||
escoria.logger.info("Object " + name + " removed from scene.")
|
||||
objects.erase(name)
|
||||
|
||||
#func jump(p_label):
|
||||
@@ -710,7 +734,7 @@ func object_exit_scene(name : String):
|
||||
# return
|
||||
# else:
|
||||
# if top.break_stop || stack.size() == 1:
|
||||
# report_errors("", ["Label not found: "+p_label+", can't jump"])
|
||||
# escoria.logger.report_errors("", ["Label not found: "+p_label+", can't jump"])
|
||||
# stack.remove(stack.size()-1)
|
||||
# break
|
||||
# else:
|
||||
@@ -720,6 +744,6 @@ func object_exit_scene(name : String):
|
||||
func check_obj(name, cmd):
|
||||
var obj = escoria.esc_runner.get_object(name)
|
||||
if obj == null:
|
||||
escoria.report_errors("", ["Global id "+name+" not found for " + cmd])
|
||||
escoria.logger.report_errors("", ["Global id "+name+" not found for " + cmd])
|
||||
return false
|
||||
return true
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
extends Node
|
||||
|
||||
# This script runs the ESCCommands contained in the ESCEvent.
|
||||
# This script implements the ESCCommands contained in the ESCEvent.
|
||||
# TODO : this script should use "Command" pattern.
|
||||
|
||||
var current_context
|
||||
onready var esc_runner = get_parent()
|
||||
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
func finished(context = null):
|
||||
@@ -26,10 +22,10 @@ func resume(context):
|
||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||
var count = context.instructions.size()
|
||||
while context.ip < count:
|
||||
var top = esc_runner.levels_stack.size()
|
||||
var top = escoria.esc_runner.levels_stack.size()
|
||||
var ret = run(context)
|
||||
context.ip += 1
|
||||
if top < esc_runner.levels_stack.size():
|
||||
if top < escoria.esc_runner.levels_stack.size():
|
||||
return esctypes.EVENT_LEVEL_STATE.CALL
|
||||
if ret == esctypes.EVENT_LEVEL_STATE.YIELD:
|
||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||
@@ -52,11 +48,11 @@ func run(context):
|
||||
var cmd = context.instructions[context.ip]
|
||||
if cmd.name == "label":
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
if !esc_runner.test(cmd):
|
||||
if !escoria.esc_runner.test(cmd):
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
#print("name is ", cmd.name)
|
||||
#if !(cmd.name in self):
|
||||
# esc_runner.report_errors("", ["Unexisting command "+cmd.name])
|
||||
# escoria.logger.report_errors("", ["Unexisting command "+cmd.name])
|
||||
return call(cmd.name, cmd.params)
|
||||
|
||||
|
||||
@@ -137,18 +133,28 @@ func camera_push(command_params : Array):
|
||||
escoria.esc_runner.get_object("camera").push(target, time, type)
|
||||
|
||||
|
||||
"""
|
||||
camera_set_limits camlimits_id
|
||||
Sets the camera limits to the one defined under "camlimits_id" in ESCRoom's
|
||||
camera_limits array.
|
||||
- camlimits_id : int : id of the camera limits to apply (defined in ESCRoom's
|
||||
camera_limits array)
|
||||
"""
|
||||
func camera_set_limits(command_params : Array):
|
||||
escoria.main.set_camera_limits(command_params[0])
|
||||
|
||||
|
||||
"""
|
||||
camera_set_drag_margin_enabled h v
|
||||
- "h" and "v" are booleans for whether or not horizontal and vertical drag
|
||||
camera_set_drag_margin_enabled horizontal_enabled vertical_enabled
|
||||
- horizontal_enabled : bool
|
||||
- vertical_enabled : bool are booleans for whether or not horizontal and vertical drag
|
||||
margins are enabled. You will likely want to set them false for advanced camera
|
||||
motions and true for regular gameplay and/or tracking NPCs.
|
||||
"""
|
||||
func camera_set_drag_margin_enabled():
|
||||
pass
|
||||
func camera_set_drag_margin_enabled(command_params : Array):
|
||||
var horizontal_enabled = command_params[0]
|
||||
var vertical_enabled = command_params[1]
|
||||
escoria.esc_runner.get_object("camera").set_drag_margin_enabled(horizontal_enabled, vertical_enabled)
|
||||
|
||||
|
||||
"""
|
||||
@@ -157,11 +163,10 @@ Moves the camera to a position defined by "x" and "y", at the speed defined by
|
||||
"speed" in pixels per second. If speed is 0, camera is teleported to the position.
|
||||
"""
|
||||
func camera_set_pos(command_params : Array):
|
||||
# var speed = command_params[0]
|
||||
# var x = command_params[1]
|
||||
# var y = command_params[2]
|
||||
# escoria.esc_runner.get_object("camera").set_pos(speed, x, y)
|
||||
pass
|
||||
var speed = command_params[0]
|
||||
var pos = Vector2(command_params[1], command_params[2])
|
||||
escoria.esc_runner.get_object("camera").set_target(pos, speed)
|
||||
|
||||
|
||||
"""
|
||||
camera_set_target speed object [object2 object3 ...]
|
||||
@@ -193,8 +198,10 @@ func camera_set_zoom(command_params : Array):
|
||||
camera_set_zoom_height pixels [time]
|
||||
Similar to the command above, but uses pixel height instead of magnitude to zoom.
|
||||
"""
|
||||
func camera_set_zoom_height():
|
||||
pass
|
||||
func camera_set_zoom_height(command_params : Array):
|
||||
var magnitude = command_params[0] / escoria.game_size.y
|
||||
var time = command_params[1] if command_params.size() > 1 else 0
|
||||
escoria.esc_runner.get_object("camera").set_camera_zoom(magnitude, float(time))
|
||||
|
||||
|
||||
"""
|
||||
@@ -369,18 +376,25 @@ func inventory_remove(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
TODO: This is dependant to the user UI. It must remain flexible enough.
|
||||
inventory_open true/false
|
||||
Shows or hides inventory. Uses code in game.tscn scene, thus developed outside of Escoria.
|
||||
"""
|
||||
func inventory_open(command_params : Array):
|
||||
pass
|
||||
func inventory_display(command_params : Array):
|
||||
var display : bool = bool(command_params[0])
|
||||
if display:
|
||||
escoria.main.current_scene.game.open_inventory()
|
||||
else:
|
||||
escoria.main.current_scene.game.close_inventory()
|
||||
|
||||
|
||||
"""
|
||||
jump label_name
|
||||
Jump to label_name block. Labels are blocks defined the same way as action_verbs:
|
||||
:label
|
||||
"""
|
||||
func jump(command_params : Array):
|
||||
# escoria.esc_runner.jump(command_params[0])
|
||||
# return esctypes.EVENT_LEVEL_STATE.JUMP
|
||||
pass
|
||||
escoria.esc_runner.jump(command_params[0])
|
||||
return esctypes.EVENT_LEVEL_STATE.JUMP
|
||||
|
||||
"""
|
||||
"""
|
||||
@@ -389,21 +403,34 @@ func play_snd(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
queue_animation object animation
|
||||
"""
|
||||
func queue_animation(command_params : Array):
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
queue_resource path [front_of_queue]
|
||||
Queues the load of a resource in a background thread. The path must be a full
|
||||
path inside your game, for example "res://scenes/next_scene.tscn".
|
||||
The "front_of_queue" parameter is optional (default value false), to put the
|
||||
resource in the front of the queue. Queued resources are cleared when a change
|
||||
scene happens (but after the scene is loaded, meaning you can queue resources
|
||||
that belong to the next scene).
|
||||
"""
|
||||
func queue_resource(command_params : Array):
|
||||
pass
|
||||
var path : String = command_params[0]
|
||||
var in_front : bool = command_params[1] if command_params.size() > 1 else false
|
||||
escoria.esc_runner.resource_cache.queue_resource(path, in_front)
|
||||
|
||||
|
||||
"""
|
||||
repeat
|
||||
Restarts the execution of the current scope at the start. A scope can be a group
|
||||
or an event.
|
||||
"""
|
||||
func repeat(command_params : Array):
|
||||
pass
|
||||
return esctypes.EVENT_LEVEL_STATE.REPEAT
|
||||
|
||||
|
||||
"""
|
||||
@@ -419,7 +446,9 @@ func say(command_params : Array) -> esctypes:
|
||||
var dialog_scene_name = ProjectSettings.get_setting("escoria/ui/default_dialog_scene")
|
||||
|
||||
if dialog_scene_name.empty():
|
||||
escoria.report_errors("level_esc_runners.gd:say()", ["Project setting 'escoria/ui/default_dialog_scene' is not set. Please set a default dialog scene."])
|
||||
escoria.logger.report_errors("level_esc_runners.gd:say()",
|
||||
["Project setting 'escoria/ui/default_dialog_scene' is not set.",
|
||||
"Please set a default dialog scene."])
|
||||
var file = dialog_scene_name.get_file()
|
||||
var extension = dialog_scene_name.get_extension()
|
||||
dialog_scene_name = file.rstrip("." + extension)
|
||||
@@ -442,8 +471,9 @@ func say(command_params : Array) -> esctypes:
|
||||
|
||||
|
||||
"""
|
||||
Sets object as active or inactive. Active objects are displayed in scene and respond
|
||||
to inputs. Inactives are hidden.
|
||||
set_active global_id true/false
|
||||
Sets object as active or inactive. Active objects are displayed in scene and
|
||||
respond to inputs. Inactives are hidden.
|
||||
"""
|
||||
func set_active(command_params : Array):
|
||||
if !escoria.esc_runner.check_obj(command_params[0], "set_active"):
|
||||
@@ -453,8 +483,8 @@ func set_active(command_params : Array):
|
||||
escoria.esc_runner.set_active(name, value)
|
||||
|
||||
"""
|
||||
set_angle object_id angle_degrees
|
||||
Set the angle of an object.
|
||||
Usage: set_angle object_id angle_degrees
|
||||
"""
|
||||
func set_angle(command_params : Array):
|
||||
if !escoria.esc_runner.check_obj(command_params[0], "set_angle"):
|
||||
@@ -468,6 +498,9 @@ func set_angle(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
set_state object_id state_name
|
||||
Set object state to state_name. States are recorded in escoria.states[].
|
||||
If the object has an animation named 'state_name', Escoria plays it.
|
||||
"""
|
||||
func set_state(command_params : Array):
|
||||
var global_id : String = command_params[0]
|
||||
@@ -476,9 +509,14 @@ func set_state(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
set_hud_visible true/false
|
||||
Hides the UI. Uses code in game.tscn scene, thus developed outside of Escoria.
|
||||
"""
|
||||
func set_hud_visible(command_params : Array):
|
||||
pass
|
||||
if command_params[0]:
|
||||
escoria.main.current_scene.game.show_ui()
|
||||
else:
|
||||
escoria.main.current_scene.game.hide_ui()
|
||||
|
||||
|
||||
"""
|
||||
@@ -488,6 +526,8 @@ func sched_event(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
set_global global_variable value
|
||||
Sets a global variable value. Value can be string, integer or boolean.
|
||||
"""
|
||||
func set_global(command_params : Array):
|
||||
var name : String = command_params[0]
|
||||
@@ -509,17 +549,27 @@ func set_globals(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
set_interactive global_id true/false
|
||||
Sets object as interactive or not. Interactive objects can be pointed and
|
||||
interacted with.
|
||||
"""
|
||||
func set_interactive(command_params : Array):
|
||||
var name : String = command_params[0]
|
||||
var global_id : String = command_params[0]
|
||||
var value = command_params[1]
|
||||
escoria.esc_runner.set_interactive(name, value)
|
||||
escoria.esc_runner.set_interactive(global_id, value)
|
||||
|
||||
|
||||
"""
|
||||
set_speed global_id speed_value
|
||||
Sets the speed of object defined by 'global_id' to 'speed_value'
|
||||
"""
|
||||
func set_speed(command_params : Array):
|
||||
pass
|
||||
if !escoria.esc_runner.check_obj(command_params[0], "set_speed"):
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
var global_id : String = command_params[0]
|
||||
var speed_value = command_params[1]
|
||||
escoria.get_object(global_id).set_speed(speed_value)
|
||||
|
||||
|
||||
"""
|
||||
@@ -528,6 +578,12 @@ func slide(command_params : Array):
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
"""
|
||||
func slide_to_pos(command_params : Array):
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
"""
|
||||
func slide_block(command_params : Array):
|
||||
@@ -536,11 +592,22 @@ func slide_block(command_params : Array):
|
||||
|
||||
"""
|
||||
"""
|
||||
func spawn(command_params : Array):
|
||||
func slide_to_pos_block(command_params : Array):
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
spawn path [object2]
|
||||
Instances a scene determined by "path", and places in the position of object2
|
||||
(object2 is optional)
|
||||
"""
|
||||
func spawn(command_params : Array):
|
||||
superpose_scene(command_params)
|
||||
|
||||
"""
|
||||
stop
|
||||
Stops the execution of the current script when it reaches the 'stop' instruction.
|
||||
Usually used in the end of commands blocks.
|
||||
"""
|
||||
func stop(command_params : Array):
|
||||
return esctypes.EVENT_LEVEL_STATE.BREAK
|
||||
@@ -560,7 +627,10 @@ func superpose_scene(command_params : Array):
|
||||
# Savegames must have events disabled, so saving the game adds a false to params
|
||||
var run_events = true
|
||||
if command_params.size() == 2:
|
||||
run_events = bool(command_params[1])
|
||||
if command_params[1] in ["true", "false"]:
|
||||
run_events = true if command_params[1] == "true" else false
|
||||
else:
|
||||
current_context["set_position"] = command_params[1]
|
||||
|
||||
# looking for localized string format in scene. this should be somewhere else
|
||||
var sep = command_params[0].find(":\"")
|
||||
@@ -575,9 +645,9 @@ func superpose_scene(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
teleport obj1 obj2 [angle_degrees]
|
||||
Teleports obj1 at obj2's position. If angle_degrees is set (int), sets obj1's
|
||||
angle to angle_degrees.
|
||||
Usage: teleport obj1 obj2 [angle_degrees]
|
||||
"""
|
||||
func teleport(command_params : Array):
|
||||
if !escoria.esc_runner.check_obj(command_params[0], "teleport"):
|
||||
@@ -595,9 +665,22 @@ func teleport(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
teleport obj1 x y [angle_degrees]
|
||||
Teleports obj1 at (x,y). If angle_degrees is set (int), sets obj1's
|
||||
angle to angle_degrees.
|
||||
"""
|
||||
func teleport_pos(command_params : Array):
|
||||
pass
|
||||
if !escoria.esc_runner.check_obj(command_params[0], "teleport"):
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
var x = command_params[1]
|
||||
var y = command_params[2]
|
||||
|
||||
var angle
|
||||
if command_params.size() > 2:
|
||||
angle = int(command_params[3])
|
||||
|
||||
escoria.esc_runner.get_object(command_params[0]).teleport(Vector2(x,y), angle)
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
|
||||
"""
|
||||
@@ -622,29 +705,48 @@ func wait(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
walk object_id1 object_id2
|
||||
Make object1 walk towards object2. This command is not blocking (user input not disabled)
|
||||
Usage: walk object_id1 object_id2
|
||||
"""
|
||||
func walk(command_params : Array):
|
||||
current_context.waiting = false
|
||||
escoria.do("walk", command_params)
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
|
||||
"""
|
||||
walk_block object_id1 object_id2
|
||||
Make object1 walk towards object2. This command is blocking (user input disabled)
|
||||
"""
|
||||
func walk_block(command_params : Array):
|
||||
current_context.waiting = true
|
||||
escoria.do("walk", command_params)
|
||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||
|
||||
|
||||
"""
|
||||
walk_to_pos object_id1 pos_x pos_y
|
||||
Make object1 walk towards object2. This command is not blocking (user input not disabled)
|
||||
Usage: walk_to_pos object_id1 pos_x pos_y
|
||||
"""
|
||||
func walk_to_pos(command_params : Array):
|
||||
current_context.waiting = false
|
||||
var destination_pos = Vector2(command_params[1], command_params[2])
|
||||
escoria.do("walk", [command_params[0], destination_pos])
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
"""
|
||||
walk_to_pos_block object_id1 pos_x pos_y
|
||||
Make object1 walk towards object2. This command is blocking (user input disabled)
|
||||
"""
|
||||
func walk_to_pos_block(command_params : Array):
|
||||
current_context.waiting = true
|
||||
var destination_pos = Vector2(command_params[1], command_params[2])
|
||||
escoria.do("walk", [command_params[0], destination_pos])
|
||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||
|
||||
|
||||
"""
|
||||
"""
|
||||
func walk_block(command_params : Array):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -94,7 +94,6 @@ var last_dir : int
|
||||
|
||||
|
||||
func _ready():
|
||||
assert(!global_id.empty())
|
||||
|
||||
# Adds movable behavior
|
||||
Movable = Node.new()
|
||||
@@ -210,9 +209,12 @@ func element_exited(body):
|
||||
func teleport(target, angle : Object = null) -> void:
|
||||
Movable.teleport(target, angle)
|
||||
|
||||
func walk_to(pos : Vector2, p_walk_context = null):
|
||||
func walk_to(pos : Vector2, p_walk_context = null) -> void:
|
||||
Movable.walk_to(pos, p_walk_context)
|
||||
|
||||
func set_speed(speed_value : int) -> void:
|
||||
speed = speed_value
|
||||
|
||||
################################################################################
|
||||
|
||||
# TALKATIVE object functions
|
||||
|
||||
@@ -129,18 +129,20 @@ func _process(time):
|
||||
$debug.text = str(z_index)
|
||||
|
||||
|
||||
|
||||
func anim_finished():
|
||||
pass
|
||||
|
||||
|
||||
func get_camera_pos():
|
||||
if camera_position_node and get_node(camera_position_node):
|
||||
return get_node(camera_position_node).global_position
|
||||
return global_position
|
||||
|
||||
|
||||
func get_animations_list() -> PoolStringArray:
|
||||
return animation_sprite.get_sprite_frames().get_animation_names()
|
||||
|
||||
|
||||
func start_talking():
|
||||
if animation_sprite.is_playing():
|
||||
animation_sprite.stop()
|
||||
@@ -162,3 +164,8 @@ func walk_to(pos : Vector2, p_walk_context = null):
|
||||
|
||||
func set_angle(deg : int, immediate = true):
|
||||
Movable.set_angle(deg, immediate)
|
||||
|
||||
|
||||
func set_speed(speed_value : int) -> void:
|
||||
speed = speed_value
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ func _ready():
|
||||
if n is NavigationPolygonInstance:
|
||||
if n.enabled:
|
||||
if navigation_enabled_found:
|
||||
escoria.report_errors("escterrain.gd:_ready()", ["Multiple NavigationPolygonInstances enabled at the same time."])
|
||||
escoria.logger.report_errors("escterrain.gd:_ready()", ["Multiple NavigationPolygonInstances enabled at the same time."])
|
||||
navigation_enabled_found = true
|
||||
current_active_navigation_instance = n
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
tool
|
||||
extends Area2D
|
||||
class_name ESCTriggerZone
|
||||
|
||||
func get_class():
|
||||
return "ESCTriggerZone"
|
||||
|
||||
|
||||
export(String) var global_id
|
||||
export(String, FILE, "*.esc") var esc_script
|
||||
|
||||
func _ready():
|
||||
assert(!global_id.empty())
|
||||
escoria.register_object(self)
|
||||
connect("area_entered", self, "element_entered")
|
||||
connect("area_exited", self, "element_exited")
|
||||
connect("body_entered", self, "element_entered")
|
||||
connect("body_exited", self, "element_exited")
|
||||
|
||||
|
||||
func element_entered(body):
|
||||
if body is ESCBackground or body.get_parent() is ESCBackground:
|
||||
return
|
||||
escoria.do("trigger_in", [global_id, body.global_id])
|
||||
|
||||
|
||||
func element_exited(body):
|
||||
escoria.do("trigger_out", [global_id, body.global_id])
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,49 @@
|
||||
# Logging
|
||||
onready var warning_is_reported : bool = false
|
||||
var warning_path : String
|
||||
|
||||
func warning(string : String):
|
||||
printerr("(W)\t" + string)
|
||||
func warning(string : String, args = []):
|
||||
var argsstr = str(args) if !args.empty() else ""
|
||||
printerr("(W)\t" + string + " \t" + argsstr)
|
||||
|
||||
func info(string : String):
|
||||
print("(I)\t" + string)
|
||||
|
||||
func info(string : String, args = []):
|
||||
var argsstr = str(args) if !args.empty() else ""
|
||||
print("(I)\t" + string + " \t" + argsstr)
|
||||
|
||||
func error(string : String):
|
||||
printerr("(E)\t" + string)
|
||||
|
||||
func error(string : String, args = []):
|
||||
var argsstr = str(args) if !args.empty() else ""
|
||||
printerr("(E)\t" + string + " \t" + argsstr)
|
||||
|
||||
|
||||
func report_warnings(p_path : String, warnings : Array, report_once = false) -> void:
|
||||
if p_path != warning_path:
|
||||
warning_is_reported = false
|
||||
|
||||
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
|
||||
|
||||
|
||||
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)
|
||||
if ProjectSettings.get_setting("escoria/debug/terminate_on_errors"):
|
||||
print_stack()
|
||||
assert(false)
|
||||
# If your game stopped here, you may want to look at the Output tab and
|
||||
# check for the error that caused the game to stop.
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
extends Sprite
|
||||
|
||||
signal left_click_on_bg
|
||||
signal right_click_on_bg # Connect this in your game/signal_script
|
||||
|
||||
export var action = "walk"
|
||||
var area
|
||||
|
||||
# Godot doesn't do doubleclicks so we must
|
||||
var last_lmb_dt = 0
|
||||
var waiting_dblclick = null # null or [pos, event]
|
||||
|
||||
func input(_viewport, event, _shape_idx):
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
# If we are hovering items, do not allow background to receive a click
|
||||
# and let the items sort out who's on top and gets to be `clicked`
|
||||
if vm.hover_stack:
|
||||
return
|
||||
|
||||
if event.is_action("game_general"):
|
||||
last_lmb_dt = 0
|
||||
waiting_dblclick = [get_global_mouse_position(), event]
|
||||
elif event.is_action("game_rmb"):
|
||||
emit_signal("right_click_on_bg", self, get_global_mouse_position(), event)
|
||||
|
||||
func get_action():
|
||||
return action
|
||||
|
||||
func _physics_process(dt):
|
||||
last_lmb_dt += dt
|
||||
|
||||
if waiting_dblclick and last_lmb_dt > vm.DOUBLECLICK_TIMEOUT:
|
||||
emit_signal("left_click_on_bg", self, waiting_dblclick[0], waiting_dblclick[1])
|
||||
last_lmb_dt = 0
|
||||
waiting_dblclick = null
|
||||
|
||||
func _enter_tree():
|
||||
# Use size of background texture to calculate collision shape
|
||||
var size = get_texture().get_size()
|
||||
|
||||
area = Area2D.new()
|
||||
var shape = RectangleShape2D.new()
|
||||
|
||||
var sid = area.create_shape_owner(area)
|
||||
|
||||
# Move origin of Area2D to center of Sprite
|
||||
var transform = area.shape_owner_get_transform(sid)
|
||||
transform.origin = size / 2
|
||||
area.shape_owner_set_transform(sid, transform)
|
||||
|
||||
# Set extents of RectangleShape2D to cover entire Sprite
|
||||
shape.set_extents(size / 2)
|
||||
area.shape_owner_add_shape(sid, shape)
|
||||
|
||||
add_child(area)
|
||||
|
||||
func _ready():
|
||||
var conn_err
|
||||
|
||||
conn_err = area.connect("input_event", self, "input")
|
||||
if conn_err:
|
||||
vm.report_errors("item", ["area.input_event -> input error: " + String(conn_err)])
|
||||
|
||||
conn_err = connect("left_click_on_bg", $"/root/scene/game", "ev_left_click_on_bg")
|
||||
if conn_err:
|
||||
vm.report_errors("item", ["left_click_on_bg -> ev_left_click_on_bg error: " + String(conn_err)])
|
||||
|
||||
add_to_group("background")
|
||||
|
||||
@@ -132,7 +132,6 @@ func load_autosave(p_callback):
|
||||
|
||||
|
||||
func _do_load(fname):
|
||||
|
||||
var f = File.new()
|
||||
if !f.file_exists(fname):
|
||||
return null
|
||||
|
||||
@@ -26,9 +26,8 @@ enum GAME_STATE {
|
||||
}
|
||||
onready var current_state = GAME_STATE.DEFAULT
|
||||
|
||||
onready var game_size = get_viewport().size
|
||||
|
||||
# Logging
|
||||
onready var is_reported : bool = false
|
||||
|
||||
##################################################################################
|
||||
func _ready():
|
||||
@@ -41,42 +40,9 @@ func new_game():
|
||||
$esc_runner.run_game(actions)
|
||||
|
||||
|
||||
func change_scene_path(scene_path):
|
||||
var scene = load(scene_path).instance()
|
||||
get_tree().get_root().call_deferred("add_child", scene)
|
||||
return scene
|
||||
|
||||
|
||||
func set_main_menu(scene):
|
||||
main_menu_instance = scene
|
||||
|
||||
func report_warnings(p_path : String, warnings : Array, report_once = false) -> void:
|
||||
if !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"
|
||||
printerr("warning is: ", text)
|
||||
|
||||
if report_once:
|
||||
is_reported = true
|
||||
|
||||
|
||||
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"
|
||||
printerr("error is: ", text)
|
||||
if ProjectSettings.get_setting("escoria/debug/terminate_on_errors"):
|
||||
print_stack()
|
||||
assert(false)
|
||||
# If your game stopped here, you may want to look at the Output tab and check for
|
||||
# the error that caused the game to stop.
|
||||
|
||||
|
||||
"""
|
||||
@@ -113,8 +79,6 @@ func register_object(object : Object):
|
||||
if object is ESCInventory:
|
||||
inventory = object
|
||||
|
||||
if object is ESCTriggerZone:
|
||||
$esc_runner.register_object(object_id, object, true)
|
||||
|
||||
|
||||
"""
|
||||
@@ -130,7 +94,7 @@ func do(action : String, params : Array = []) -> void:
|
||||
|
||||
# Check moving object.
|
||||
if !escoria.esc_runner.check_obj(params[0], "escoria.do(walk)"):
|
||||
report_errors("escoria.gd:do()",
|
||||
escoria.logger.report_errors("escoria.gd:do()",
|
||||
["Walk action requested on inexisting object: " + params[0]])
|
||||
return
|
||||
|
||||
@@ -148,7 +112,7 @@ func do(action : String, params : Array = []) -> void:
|
||||
# Walk to object from its id
|
||||
elif params[1] is String:
|
||||
if !escoria.esc_runner.check_obj(params[1], "escoria.do(walk)"):
|
||||
report_errors("escoria.gd:do()",
|
||||
escoria.logger.report_errors("escoria.gd:do()",
|
||||
["Walk action requested TOWARDS inexisting object: " + params[1]])
|
||||
return
|
||||
|
||||
@@ -164,34 +128,32 @@ func do(action : String, params : Array = []) -> void:
|
||||
|
||||
"item_left_click":
|
||||
if params[0] is String:
|
||||
printt("escoria.do : item_left_click on item ", params[0])
|
||||
escoria.logger.info("escoria.do() : item_left_click on item ", [params[0]])
|
||||
var item = $esc_runner.get_object(params[0])
|
||||
ev_left_click_on_item(item, params[1])
|
||||
|
||||
"item_right_click":
|
||||
if params[0] is String:
|
||||
printt("escoria.do : item_right_click on item ", params[0])
|
||||
escoria.logger.info("escoria.do() : item_right_click on item ", [params[0]])
|
||||
ev_left_click_on_item($esc_runner.get_object(params[0]), params[1], true)
|
||||
|
||||
"trigger_in":
|
||||
var trigger_id = params[0]
|
||||
var object_id = params[1]
|
||||
var trigger_in_verb = params[2]
|
||||
printt("escoria.do() : trigger_in ", trigger_id, " by ", object_id)
|
||||
escoria.logger.info("escoria.do() : trigger_in " + trigger_id + " by " + object_id)
|
||||
esc_runner.run_event(esc_runner.objects_events_table[trigger_id][trigger_in_verb])
|
||||
|
||||
"trigger_out":
|
||||
var trigger_id = params[0]
|
||||
var object_id = params[1]
|
||||
var trigger_out_verb = params[2]
|
||||
printt("escoria.do() : trigger_out ", trigger_id, " by ", object_id)
|
||||
escoria.logger.info("escoria.do() : trigger_out " + trigger_id + " by " + object_id)
|
||||
esc_runner.run_event(esc_runner.objects_events_table[trigger_id][trigger_out_verb])
|
||||
|
||||
_:
|
||||
# $esc_runner.activate(action, params[0])
|
||||
report_warnings("escoria.gd:do()", ["Action received:", action, "with params ", params])
|
||||
# elif current_state == GAME_STATE.DIALOG:
|
||||
# dialog_player.finish_fast()
|
||||
escoria.logger.report_warnings("escoria.gd:do()",
|
||||
["Action received:", action, "with params ", params])
|
||||
elif current_state == GAME_STATE.WAIT:
|
||||
pass
|
||||
|
||||
@@ -206,7 +168,7 @@ func ev_left_click_on_item(obj, event, default_action = false):
|
||||
"""
|
||||
if obj is String:
|
||||
obj = esc_runner.objects[obj]
|
||||
printt(obj.global_id, "left-clicked with", event)
|
||||
escoria.logger.info(obj.global_id + " left-clicked with event ", [event])
|
||||
|
||||
var need_combine = false
|
||||
# Check if current_action and current_tool are already set
|
||||
@@ -250,7 +212,7 @@ func ev_left_click_on_item(obj, event, default_action = false):
|
||||
|
||||
# Wait for the player to arrive before continuing with action.
|
||||
var context = yield(main.current_scene.player, "arrived")
|
||||
printt("context arrived: ", context)
|
||||
escoria.logger.info("Context arrived: ", [context])
|
||||
if context.has("target_object") and walk_context.has("target_object"):
|
||||
if (context.target_object.global_id != walk_context.target_object.global_id) \
|
||||
or (context.target_object.global_id == walk_context.target_object.global_id and is_already_walking):
|
||||
|
||||
@@ -8,6 +8,7 @@ onready var hotspot_focused : String = ""
|
||||
func _ready():
|
||||
set_process_input(true)
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("esc_show_debug_prompt"):
|
||||
escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup()
|
||||
@@ -16,48 +17,53 @@ func _input(event):
|
||||
|
||||
func _on_left_click_on_bg(position : Vector2):
|
||||
if hotspot_focused.empty():
|
||||
printt("Left click on background at ", str(position))
|
||||
escoria.logger.info("Left click on background at ", [str(position)])
|
||||
escoria.main.current_scene.game.left_click_on_bg(position)
|
||||
|
||||
|
||||
func _on_double_left_click_on_bg(position : Vector2):
|
||||
if hotspot_focused.empty():
|
||||
printt("Double left click on background at ", str(position))
|
||||
escoria.logger.info("Double left click on background at ", [str(position)])
|
||||
escoria.main.current_scene.game.left_double_click_on_bg(position)
|
||||
|
||||
|
||||
func _on_right_click_on_bg(position : Vector2):
|
||||
if hotspot_focused.empty():
|
||||
printt("Right click on background at ", str(position))
|
||||
escoria.logger.info("Right click on background at ", [str(position)])
|
||||
escoria.main.current_scene.game.right_click_on_bg(position)
|
||||
|
||||
##################################################################################
|
||||
|
||||
func _on_mouse_left_click_inventory_item(inventory_item_global_id, event : InputEvent) -> void:
|
||||
printt("Inventory item left clicked ", inventory_item_global_id)
|
||||
escoria.logger.info("Inventory item left clicked ", [inventory_item_global_id])
|
||||
escoria.main.current_scene.game.left_click_on_inventory_item(inventory_item_global_id, event)
|
||||
|
||||
|
||||
func _on_mouse_right_click_inventory_item(inventory_item_global_id, event : InputEvent) -> void:
|
||||
printt("Inventory item right clicked ", inventory_item_global_id)
|
||||
escoria.logger.info("Inventory item right clicked ", [inventory_item_global_id])
|
||||
escoria.main.current_scene.game.right_click_on_inventory_item(inventory_item_global_id, event)
|
||||
|
||||
|
||||
func _on_mouse_double_left_click_inventory_item(inventory_item_global_id, event : InputEvent) -> void:
|
||||
printt("Inventory item double left clicked ", inventory_item_global_id)
|
||||
escoria.logger.info("Inventory item double left clicked ", [inventory_item_global_id])
|
||||
escoria.main.current_scene.game.left_double_click_on_inventory_item(inventory_item_global_id, event)
|
||||
|
||||
|
||||
func _on_mouse_entered_inventory_item(inventory_item_global_id) -> void:
|
||||
printt("Inventory item focused ", inventory_item_global_id)
|
||||
escoria.logger.info("Inventory item focused ", [inventory_item_global_id])
|
||||
escoria.main.current_scene.game.inventory_item_focused(inventory_item_global_id)
|
||||
|
||||
|
||||
func _on_mouse_exited_inventory_item() -> void:
|
||||
printt("Inventory item unfocused")
|
||||
escoria.logger.info("Inventory item unfocused")
|
||||
escoria.main.current_scene.game.inventory_item_unfocused()
|
||||
|
||||
|
||||
##################################################################################
|
||||
|
||||
func _on_mouse_entered_item(item : ESCItem) -> void:
|
||||
printt("Item focused : ", item.global_id)
|
||||
escoria.logger.info("Item focused : ", [item.global_id])
|
||||
clean_hover_stack()
|
||||
|
||||
if !hover_stack.empty():
|
||||
if item.z_index > hover_stack.back().z_index:
|
||||
@@ -72,7 +78,7 @@ func _on_mouse_entered_item(item : ESCItem) -> void:
|
||||
|
||||
|
||||
func _on_mouse_exited_item(item : ESCItem) -> void:
|
||||
printt("Item unfocused : ", item.global_id)
|
||||
escoria.logger.info("Item unfocused : ", [item.global_id])
|
||||
hover_stack.erase(item)
|
||||
if hover_stack.empty():
|
||||
hotspot_focused = ""
|
||||
@@ -84,15 +90,17 @@ func _on_mouse_exited_item(item : ESCItem) -> void:
|
||||
|
||||
func _on_mouse_left_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
||||
if hover_stack.empty() or hover_stack.back() == item:
|
||||
printt("Item left clicked", item.global_id, event)
|
||||
escoria.logger.info("Item left clicked", [item.global_id, event])
|
||||
escoria.main.current_scene.game.left_click_on_item(item.global_id, event)
|
||||
|
||||
|
||||
func _on_mouse_left_double_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
||||
printt("Item left double clicked", item.global_id, event)
|
||||
escoria.logger.info("Item left double clicked", [item.global_id, event])
|
||||
escoria.main.current_scene.game.left_double_click_on_item(item.global_id, event)
|
||||
|
||||
|
||||
|
||||
func _on_mouse_right_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
||||
printt("Item right clicked", item.global_id, event)
|
||||
escoria.logger.info("Item right clicked", [item.global_id, event])
|
||||
escoria.main.current_scene.game.right_click_on_item(item.global_id, event)
|
||||
|
||||
|
||||
@@ -100,3 +108,11 @@ func _on_mouse_right_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
||||
|
||||
func _on_mousewheel_action(direction : int):
|
||||
escoria.main.current_scene.game.mousewheel_action(direction)
|
||||
|
||||
|
||||
##################################################################################
|
||||
|
||||
func clean_hover_stack():
|
||||
for e in hover_stack:
|
||||
if e == null or !is_instance_valid(e):
|
||||
hover_stack.erase(e)
|
||||
|
||||
@@ -20,7 +20,7 @@ func set_scene(p_scene, run_events=true):
|
||||
If run_events=true, plays the events defined in :setup event
|
||||
"""
|
||||
if !p_scene:
|
||||
escoria.report_errors("main", ["Trying to set empty scene"])
|
||||
escoria.logger.report_errors("main", ["Trying to set empty scene"])
|
||||
|
||||
if current_scene != null:
|
||||
clear_scene()
|
||||
@@ -69,10 +69,10 @@ func set_current_scene(p_scene, run_events=true):
|
||||
# Having a game with `:setup` means we must wait for it to finish
|
||||
if "setup" in escoria.esc_runner.game:
|
||||
if not escoria.esc_runner.running_event:
|
||||
escoria.report_errors("main.gd:set_current_scene()", ["escoria.esc_runner.game has setup but no running_event"])
|
||||
escoria.logger.report_errors("main.gd:set_current_scene()", ["escoria.esc_runner.game has setup but no running_event"])
|
||||
|
||||
if escoria.esc_runner.running_event.ev_name != "setup":
|
||||
escoria.report_errors("main.gd:set_current_scene()", ["escoria.esc_runner.game has setup but it is not running: " + escoria.esc_runner.running_event.ev_name])
|
||||
escoria.logger.report_errors("main.gd:set_current_scene()", ["escoria.esc_runner.game has setup but it is not running: " + escoria.esc_runner.running_event.ev_name])
|
||||
|
||||
yield(escoria.esc_runner, "event_done")
|
||||
else:
|
||||
@@ -127,10 +127,11 @@ func set_camera_limits(camera_limit_id : int = 0):
|
||||
|
||||
# if the background is smaller than the viewport, we want the camera to stick centered on the background
|
||||
if area.size.x == 0 or area.size.y == 0 or area.size < get_viewport().size:
|
||||
printt("No limit area! Using viewport")
|
||||
escoria.logger.report_warning("main.gd:set_camera_limits()",
|
||||
"No limit area! Using viewport.")
|
||||
area.size = get_viewport().size
|
||||
|
||||
printt("setting camera limits from scene ", area)
|
||||
escoria.logger.info("Setting camera limits from scene ", [area])
|
||||
limits = {
|
||||
"limit_left": area.position.x,
|
||||
"limit_right": area.position.x + area.size.x,
|
||||
@@ -146,7 +147,7 @@ func set_camera_limits(camera_limit_id : int = 0):
|
||||
"limit_bottom": scene_camera_limits.position.y + scene_camera_limits.size.y + screen_ofs.y * 2,
|
||||
"set_default": true,
|
||||
}
|
||||
printt("setting camera limits from parameter ", scene_camera_limits)
|
||||
escoria.logger.info("Setting camera limits from parameter ", [scene_camera_limits])
|
||||
|
||||
current_scene.game.get_node("camera").set_limits(limits)
|
||||
current_scene.game.get_node("camera").set_offset(screen_ofs * 2)
|
||||
|
||||
@@ -5,6 +5,8 @@ extends Node
|
||||
|
||||
func _ready():
|
||||
var main_menu_path = ProjectSettings.get_setting("escoria/main/main_menu_scene")
|
||||
var main_menu = escoria.change_scene_path(main_menu_path)
|
||||
escoria.set_main_menu(main_menu)
|
||||
var main_menu_scene = load(main_menu_path).instance()
|
||||
get_tree().get_root().call_deferred("add_child", main_menu_scene)
|
||||
escoria.set_main_menu(main_menu_scene)
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@ onready var tween = $"tween"
|
||||
var default_limits = {} # This does not change once set
|
||||
|
||||
var speed = 0.0
|
||||
# Target can be object or Vector2. See resove_target_pos()
|
||||
var target
|
||||
var target_pos
|
||||
var target_pos : Vector2
|
||||
|
||||
var zoom_time
|
||||
var zoom_target
|
||||
@@ -72,6 +73,7 @@ func set_target(p_target, p_speed : float = 0.0):
|
||||
target = p_target
|
||||
|
||||
resolve_target_pos()
|
||||
escoria.logger.info("Current camera position = " + str(self.global_position))
|
||||
|
||||
if speed == 0.0:
|
||||
self.global_position = target_pos
|
||||
@@ -80,7 +82,7 @@ func set_target(p_target, p_speed : float = 0.0):
|
||||
|
||||
if tween.is_active():
|
||||
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
||||
escoria.report_warnings("camera.gd:set_target()",
|
||||
escoria.logger.report_warnings("camera.gd:set_target()",
|
||||
["Tween still active running camera_set_target: " + tweenstat])
|
||||
tween.emit_signal("tween_completed")
|
||||
|
||||
@@ -90,7 +92,7 @@ func set_target(p_target, p_speed : float = 0.0):
|
||||
|
||||
func set_camera_zoom(p_zoom_level, p_time):
|
||||
if p_zoom_level <= 0.0:
|
||||
escoria.report_errors("camera.gd:set_camera_zoom()",
|
||||
escoria.logger.report_errors("camera.gd:set_camera_zoom()",
|
||||
["Tried to set negative or zero zoom level"])
|
||||
|
||||
zoom_time = p_time
|
||||
@@ -101,7 +103,7 @@ func set_camera_zoom(p_zoom_level, p_time):
|
||||
else:
|
||||
if tween.is_active():
|
||||
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
||||
escoria.report_warnings("camera",
|
||||
escoria.logger.report_warnings("camera",
|
||||
["Tween still active running camera_set_zoom: " + tweenstat])
|
||||
tween.emit_signal("tween_completed")
|
||||
|
||||
@@ -132,7 +134,7 @@ func push(p_target, p_time, p_type):
|
||||
else:
|
||||
if tween.is_active():
|
||||
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
||||
escoria.report_warnings("camera",
|
||||
escoria.logger.report_warnings("camera",
|
||||
["Tween still active running camera_push: " + tweenstat])
|
||||
tween.emit_signal("tween_completed")
|
||||
|
||||
@@ -156,7 +158,7 @@ func shift(p_x, p_y, p_time, p_type):
|
||||
|
||||
if tween.is_active():
|
||||
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
||||
escoria.report_warnings("camera",
|
||||
escoria.logger.report_warnings("camera",
|
||||
["Tween still active running camera_shift: " + tweenstat])
|
||||
tween.emit_signal("tween_completed")
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func preload_resources(path : String):
|
||||
add_resource(basename, dialog_scene)
|
||||
file_name = dialog_folder.get_next()
|
||||
else:
|
||||
escoria.report_errors("dialog_player.gd:preload_resources()", ["An error occurred when trying to access the path: {_}.".format(path)])
|
||||
escoria.logger.report_errors("dialog_player.gd:preload_resources()", ["An error occurred when trying to access the path: {_}.".format(path)])
|
||||
|
||||
|
||||
func say(character : String, params : Dictionary):
|
||||
@@ -60,7 +60,7 @@ func finish_fast():
|
||||
# timeout_option: (default value 0) option selected when timeout is reached.
|
||||
func start_dialog_choices(answers : Array, options : Array):
|
||||
if answers.empty():
|
||||
escoria.report_errors("dialog_player.gd:start_dialog_choices()", ["Received answers array was empty."])
|
||||
escoria.logger.report_errors("dialog_player.gd:start_dialog_choices()", ["Received answers array was empty."])
|
||||
dialog_chooser_ui = get_resource("text_dialog_choice").instance()
|
||||
get_parent().add_child(dialog_chooser_ui)
|
||||
dialog_chooser_ui.set_answers(answers)
|
||||
|
||||
@@ -31,7 +31,7 @@ func _ready():
|
||||
escoria.register_object(self)
|
||||
|
||||
if items_container == null or items_container.is_empty():
|
||||
escoria.report_errors(self.get_path(), ["Items container is empty."])
|
||||
escoria.logger.report_errors(self.get_path(), ["Items container is empty."])
|
||||
return
|
||||
for c in get_node(items_container).get_items():
|
||||
items_ids_in_inventory[c.item_id] = c
|
||||
@@ -46,11 +46,11 @@ func add_new_item_by_id(item_id : String) -> void:
|
||||
item_id = item_id.rsplit("i/", false)[0]
|
||||
if !items_ids_in_inventory.has(item_id):
|
||||
if !escoria.esc_runner.check_obj(item_id, "add_new_item_by_id"):
|
||||
escoria.report_errors("inventory_ui.gd:add_new_item_by_id()",
|
||||
escoria.logger.report_errors("inventory_ui.gd:add_new_item_by_id()",
|
||||
["Item global id '"+ item_id + "' does not exist.",
|
||||
"Check item's id in ESCORIA_ALL_ITEMS scene."])
|
||||
if !all_items.get_inventory_item(item_id):
|
||||
escoria.report_errors("inventory_ui.gd:add_new_item_by_id()",
|
||||
escoria.logger.report_errors("inventory_ui.gd:add_new_item_by_id()",
|
||||
["Item global id '"+ item_id + "' doesn't have corresponding inventory item.",
|
||||
"Check item's id in ESCORIA_ALL_ITEMS scene."])
|
||||
var item_inventory_button = all_items.get_inventory_item(item_id).duplicate()
|
||||
@@ -104,7 +104,7 @@ func _on_escoria_global_changed(global : String) -> void:
|
||||
elif escoria.esc_runner.globals[global] == "false":
|
||||
remove_item_by_id(item[0])
|
||||
else:
|
||||
escoria.report_warnings("inventory_ui.gd:_on_escoria_global_changed()", \
|
||||
escoria.logger.report_warnings("inventory_ui.gd:_on_escoria_global_changed()", \
|
||||
["Inventory global " + global + " is neither 'true' nor 'false' (was " + escoria.esc_runner.globals[global] + "). "])
|
||||
else:
|
||||
escoria.report_errors("inventory_ui.gd:_on_escoria_global_changed()", ["Global must contain 1 item name.", "(received: " + global + ")"])
|
||||
escoria.logger.report_errors("inventory_ui.gd:_on_escoria_global_changed()", ["Global must contain 1 item name.", "(received: " + global + ")"])
|
||||
|
||||
@@ -43,7 +43,7 @@ func say(character : String, params : Dictionary) :
|
||||
set_current_character(character)
|
||||
|
||||
if !params["line"]:
|
||||
escoria.report_errors("dialog_box_inset.gd:say()", ["No line field in params!"])
|
||||
escoria.logger.report_errors("dialog_box_inset.gd:say()", ["No line field in params!"])
|
||||
return
|
||||
|
||||
text_node.bbcode_text = params["line"]
|
||||
|
||||
@@ -29,7 +29,7 @@ func say(character : String, params : Dictionary) :
|
||||
show()
|
||||
|
||||
if !params["line"]:
|
||||
escoria.report_errors("dialog_box_inset.gd:say()", ["No line field in params!"])
|
||||
escoria.logger.report_errors("dialog_box_inset.gd:say()", ["No line field in params!"])
|
||||
return
|
||||
|
||||
# Position the RichTextLabel on the character's dialog position, if any.
|
||||
|
||||
@@ -19,32 +19,6 @@ func on_action_selected() -> void:
|
||||
current_action = escoria.esc_runner.current_action
|
||||
update_tooltip_text()
|
||||
|
||||
#func element_focused(element_id : String) -> void:
|
||||
# printt("action_target_tooltip.gd:on_element_focused()", "Element focused: ", element_id)
|
||||
#
|
||||
# if element_id == "":
|
||||
# set_target("")
|
||||
# return
|
||||
#
|
||||
# var object = escoria.esc_runner.get_object(element_id)
|
||||
#
|
||||
# if object == null or !is_instance_valid(object):
|
||||
# escoria.report_warnings("action_target_tooltip.gd:on_element_focused()",
|
||||
# ["Object exists but is not loaded for id " + element_id])
|
||||
# set_target(element_id)
|
||||
# return
|
||||
#
|
||||
# if !escoria.esc_runner.get_interactive(element_id) and !object is ESCInventoryItem:
|
||||
# set_target("")
|
||||
# return
|
||||
#
|
||||
# var wait_for_target = false
|
||||
# if object is ESCItem or object is ESCInventoryItem:
|
||||
# if current_action in object.combine_if_action_used_among:
|
||||
# wait_for_target = true
|
||||
#
|
||||
# set_target(object.tooltip_name, wait_for_target)
|
||||
|
||||
|
||||
func set_target(target : String, needs_second_target : bool = false) -> void:
|
||||
current_target = target
|
||||
|
||||
Reference in New Issue
Block a user