Added bg_sound manager and according ESC command.

Started transitions scene.
This commit is contained in:
Julian Murgia
2021-03-24 14:12:40 +01:00
parent 4acb971d54
commit 40dd4a6718
79 changed files with 1240 additions and 456 deletions

View File

@@ -52,7 +52,7 @@ var commands = {
"inventory_display": { "min_args": 1, "types": [TYPE_BOOL] },
"jump": { "min_args": 1 },
"label": { "min_args": 1 },
"play_snd": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
"set_sound_state": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
"queue_animation": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
"queue_resource": { "min_args": 1, "types": [TYPE_STRING, TYPE_BOOL] },
"repeat": true,

View File

@@ -349,7 +349,10 @@ func change_scene(params, context, run_events=true):
# main.clear_scene()
# camera = null
event_queue = []
escoria.main.scene_transition.fade_out()
yield(escoria.main.scene_transition, "transition_done")
# Regular events need to be reset immediately, so we don't
# accidentally `yield()` on them, for performance reasons.
# This does not affect `stack` so execution is fine anyway.
@@ -381,6 +384,9 @@ func change_scene(params, context, run_events=true):
room_scene.move_child(game_scene, 0)
var events = escoria.main.set_scene(room_scene, run_events)
escoria.main.scene_transition.fade_in()
yield(escoria.main.scene_transition, "transition_done")
# If scene was never visited, add "ready" event to the events stack
if !scenes_cache.has(room_scene.global_id) \
and "ready" in events:
@@ -526,7 +532,7 @@ func register_object(name : String, val : Object, force : bool = false):
# Most objects have states/animations, but don't count on it
# if val.has_method("set_state"):
if val is ESCItem or val is ESCPlayer or val is ESCCharacter:
if val is ESCItem or val is ESCPlayer:
if name in states:
set_state(name, [states[name], true])
else:
@@ -722,23 +728,9 @@ func object_exit_scene(name : String):
if inventory_has(name):
objects[name] = objects[name].duplicate()
else:
escoria.logger.info("Object " + name + " removed from scene.")
objects.erase(name)
#func jump(p_label):
# while stack.size() > 0:
# var top = stack[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 || stack.size() == 1:
# escoria.logger.report_errors("", ["Label not found: "+p_label+", can't jump"])
# stack.remove(stack.size()-1)
# break
# else:
# stack.remove(stack.size()-1)
if name != "bg_music":
escoria.logger.info("Object " + name + " removed from scene.")
objects.erase(name)
func check_obj(name, cmd):
@@ -747,3 +739,4 @@ func check_obj(name, cmd):
escoria.logger.report_errors("", ["Global id "+name+" not found for " + cmd])
return false
return true

View File

@@ -399,9 +399,16 @@ func jump(command_params : Array):
"""
set_sound_state bg_music|bg_sound off|default|<path/to/music.file> true|false
"""
func play_snd(command_params : Array):
pass
func set_sound_state(command_params : Array):
var snd_player = command_params[0]
var snd_id = command_params[1]
var loop = false
if command_params.size() == 3 and command_params[2]:
loop = true
escoria.main.get_node(snd_player).set_state(snd_id, loop)
return esctypes.EVENT_LEVEL_STATE.RETURN
"""

View File

@@ -1,9 +0,0 @@
tool
extends Node
class_name ESCCharacter
export(String) var character_id
export(String, FILE, ".esc") var esc_script = ""
func _ready():
pass

View File

@@ -4,7 +4,6 @@ const OBJ_DEFAULT_STATE = "default"
## Custom nodes:
#var ESCBackground = preload("res://addons/escoria-core/game/core-scripts/escbackground.gd")
#var ESCCharacter = preload("res://addons/escoria-core/game/core-scripts/esccharacter.gd")
#var ESCItem = preload("res://addons/escoria-core/game/core-scripts/escitem.gd")
#var ESCItemsInventory = preload("res://addons/escoria-core/game/core-scripts/items_inventory.gd")
#var ESCInventoryItem = preload("res://addons/escoria-core/game/core-scripts/inventory_item.gd")

View File

@@ -57,7 +57,8 @@ func set_debug_mode(p_debug_mode : bool):
debug_texturerect_node.mouse_filter = Control.MOUSE_FILTER_IGNORE
move_child(debug_texturerect_node, 2)
else:
remove_child(debug_texturerect_node)
if debug_texturerect_node:
remove_child(debug_texturerect_node)
func on_action_selected() -> void: