diff --git a/default_bus_layout.tres b/addons/escoria-core/default_bus_layout.tres similarity index 94% rename from default_bus_layout.tres rename to addons/escoria-core/default_bus_layout.tres index 2bd8efbd..196e4fec 100644 --- a/default_bus_layout.tres +++ b/addons/escoria-core/default_bus_layout.tres @@ -13,7 +13,7 @@ bus/2/mute = false bus/2/bypass_fx = false bus/2/volume_db = 0.0 bus/2/send = "Master" -bus/3/name = "Dialogs" +bus/3/name = "Speech" bus/3/solo = false bus/3/mute = false bus/3/bypass_fx = false diff --git a/addons/escoria-core/game/core-scripts/esc/commands/play_snd.gd b/addons/escoria-core/game/core-scripts/esc/commands/play_snd.gd index 2555231e..3a442c50 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/play_snd.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/play_snd.gd @@ -1,7 +1,7 @@ # `play_snd file [player]` # # Plays the sound specificed with the "file" parameter on the sound player -# `player`, without blocking. (player defaults to bg_sound) +# `player`, without blocking. (player defaults to _sound) # # @ESC extends ESCBaseCommand @@ -13,7 +13,7 @@ func configure() -> ESCCommandArgumentDescriptor: return ESCCommandArgumentDescriptor.new( 2, [TYPE_STRING, TYPE_STRING], - [null, "bg_sound"] + [null, "_sound"] ) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/say.gd b/addons/escoria-core/game/core-scripts/esc/commands/say.gd index 6f8fe4c0..834d6494 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/say.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/say.gd @@ -72,14 +72,10 @@ func run(command_params: Array) -> int: ) return ESCExecution.RC_ERROR - var _line = command_params[1] - if ":" in _line: - _line = tr(_line.split(":")[0]) - escoria.dialog_player.say( command_params[0], dialog_scene_name, - _line + command_params[1] ) yield(escoria.dialog_player, "dialog_line_finished") return ESCExecution.RC_OK diff --git a/addons/escoria-core/game/core-scripts/esc/commands/set_sound_state.gd b/addons/escoria-core/game/core-scripts/esc/commands/set_sound_state.gd index 89e07fdd..b9675306 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/set_sound_state.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/set_sound_state.gd @@ -2,7 +2,7 @@ # # Change the sound playing on `player` to `sound` with optional looping if # `loop` is true. -# Valid players are "bg_music" and "bg_sound". +# Valid players are "_music" and "_sound". # Aside from paths to sound or music files, the values *off* and *default*. # *default* is the default value. # are also valid for `sound` @@ -23,7 +23,7 @@ func configure() -> ESCCommandArgumentDescriptor: # Validate wether the given arguments match the command descriptor func validate(arguments: Array): - if not arguments[0] in ["bg_music", "bg_sound"]: + if not arguments[0] in ["_music", "_sound", "_speech"]: escoria.logger.report_errors( "SetSoundStateCommand.validate: invalid player", [ @@ -45,6 +45,6 @@ func validate(arguments: Array): # Run the command func run(command_params: Array) -> int: - escoria.main.get_node(command_params[0])\ + escoria.object_manager.get_object(command_params[0]).node\ .set_state(command_params[1], command_params[2]) return ESCExecution.RC_OK diff --git a/addons/escoria-core/game/core-scripts/esc/esc_object_manager.gd b/addons/escoria-core/game/core-scripts/esc/esc_object_manager.gd index 538033c8..d2c8ac98 100644 --- a/addons/escoria-core/game/core-scripts/esc/esc_object_manager.gd +++ b/addons/escoria-core/game/core-scripts/esc/esc_object_manager.gd @@ -4,8 +4,9 @@ class_name ESCObjectManager const RESERVED_OBJECTS = [ - "bg_music", - "bg_sound" + "_music", + "_sound", + "_speech" ] diff --git a/addons/escoria-core/game/core-scripts/esc/types/esc_object.gd b/addons/escoria-core/game/core-scripts/esc/types/esc_object.gd index cf90970c..6ed2f4c8 100644 --- a/addons/escoria-core/game/core-scripts/esc/types/esc_object.gd +++ b/addons/escoria-core/game/core-scripts/esc/types/esc_object.gd @@ -75,7 +75,7 @@ func get_save_data() -> Dictionary: save_data["last_deg"] = wrapi(self.node._movable._get_angle() + 1, 0, 360) save_data["last_dir"] = self.node._movable.last_dir - if (self.global_id == "bg_music" or self.global_id == "bg_sound") \ + if (self.global_id == "_music" or self.global_id == "_sound") \ and self.node.get("state"): save_data["state"] = self.node.get("state") diff --git a/addons/escoria-core/game/core-scripts/save_data/esc_save_manager.gd b/addons/escoria-core/game/core-scripts/save_data/esc_save_manager.gd index ecfae3f0..84276b51 100644 --- a/addons/escoria-core/game/core-scripts/save_data/esc_save_manager.gd +++ b/addons/escoria-core/game/core-scripts/save_data/esc_save_manager.gd @@ -162,7 +162,7 @@ func load_game(id: int): save_game.objects[object_global_id]["last_deg"]]) ) - if object_global_id == "bg_music" or object_global_id == "bg_sound": + if object_global_id == "_music" or object_global_id == "_sound": load_statements.append(ESCCommand.new("set_sound_state %s %s true" \ % [object_global_id, save_game.objects[object_global_id]["state"]]) @@ -185,7 +185,7 @@ func save_settings(): settings_res.master_volume = escoria.settings.master_volume settings_res.music_volume = escoria.settings.music_volume settings_res.sfx_volume = escoria.settings.sfx_volume - settings_res.voice_volume = escoria.settings.voice_volume + settings_res.speech_volume = escoria.settings.speech_volume settings_res.fullscreen = escoria.settings.fullscreen settings_res.skip_dialog = escoria.settings.skip_dialog diff --git a/addons/escoria-core/game/core-scripts/save_data/esc_savesettings.gd b/addons/escoria-core/game/core-scripts/save_data/esc_savesettings.gd index 048caeb5..db7eccff 100644 --- a/addons/escoria-core/game/core-scripts/save_data/esc_savesettings.gd +++ b/addons/escoria-core/game/core-scripts/save_data/esc_savesettings.gd @@ -6,10 +6,14 @@ class_name ESCSaveSettings export var escoria_version: String # Language of displayed text -export var text_lang: String = ProjectSettings.get_setting("escoria/main/text_lang") +export var text_lang: String = ProjectSettings.get_setting( + "escoria/main/text_lang" +) # Language of voice speech -export var voice_lang: String = ProjectSettings.get_setting("escoria/main/voice_lang") +export var voice_lang: String = ProjectSettings.get_setting( + "escoria/main/voice_lang" +) # Whether speech is enabled export var speech_enabled: bool = ProjectSettings.get_setting( @@ -24,10 +28,12 @@ export var music_volume: float = ProjectSettings.get_setting( "escoria/sound/music_volume") # Volume of SFX only -export var sfx_volume: float = ProjectSettings.get_setting("escoria/sound/sfx_volume") +export var sfx_volume: float = ProjectSettings.get_setting( + "escoria/sound/sfx_volume" +) -# Voice volume only -export var voice_volume: float = ProjectSettings.get_setting( +# Speech volume only +export var speech_volume: float = ProjectSettings.get_setting( "escoria/sound/speech_volume") # True if game has to be fullscreen diff --git a/addons/escoria-core/game/escoria.gd b/addons/escoria-core/game/escoria.gd index 2ed6e1a4..f3f44aeb 100644 --- a/addons/escoria-core/game/escoria.gd +++ b/addons/escoria-core/game/escoria.gd @@ -267,6 +267,10 @@ func _on_settings_loaded(p_settings: ESCSaveSettings) -> void: AudioServer.set_bus_volume_db( AudioServer.get_bus_index("Music"), linear2db(settings.music_volume) + ) + AudioServer.set_bus_volume_db( + AudioServer.get_bus_index("Speech"), + linear2db(settings.speech_volume) ) TranslationServer.set_locale(settings.text_lang) diff --git a/addons/escoria-core/game/main.gd b/addons/escoria-core/game/main.gd index 3dd897e3..ede56dc8 100644 --- a/addons/escoria-core/game/main.gd +++ b/addons/escoria-core/game/main.gd @@ -17,10 +17,6 @@ var current_scene: Node # The Escoria context currently in wait state var wait_level - -# Reference to the ESCBackgroundMusic node -onready var bg_music = $bg_music - # Reference to the scene transition node onready var scene_transition = $layers/curtain/scene_transition diff --git a/addons/escoria-core/game/main.tscn b/addons/escoria-core/game/main.tscn index a7fcf0b8..af90f8f9 100644 --- a/addons/escoria-core/game/main.tscn +++ b/addons/escoria-core/game/main.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://addons/escoria-core/game/main.gd" type="Script" id=1] [ext_resource path="res://addons/escoria-core/game/scenes/esc_prompt/esc_prompt_popup.tscn" type="PackedScene" id=2] -[ext_resource path="res://addons/escoria-core/game/scenes/sound/bg_music.tscn" type="PackedScene" id=3] +[ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_music_player.tscn" type="PackedScene" id=3] [ext_resource path="res://addons/escoria-core/game/scenes/transitions/transition.tscn" type="PackedScene" id=4] -[ext_resource path="res://addons/escoria-core/game/scenes/sound/bg_sound.tscn" type="PackedScene" id=5] +[ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_sound_player.tscn" type="PackedScene" id=5] +[ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_speech_player.tscn" type="PackedScene" id=6] [node name="main" type="Node"] script = ExtResource( 1 ) @@ -27,3 +28,5 @@ layer = 20 [node name="bg_music" parent="." instance=ExtResource( 3 )] [node name="bg_sound" parent="." instance=ExtResource( 5 )] + +[node name="speech" parent="." instance=ExtResource( 6 )] diff --git a/addons/escoria-core/game/scenes/dialogs/dialog_player.gd b/addons/escoria-core/game/scenes/dialogs/esc_dialog_player.gd similarity index 71% rename from addons/escoria-core/game/scenes/dialogs/dialog_player.gd rename to addons/escoria-core/game/scenes/dialogs/esc_dialog_player.gd index 63eb1206..c6189ec9 100644 --- a/addons/escoria-core/game/scenes/dialogs/dialog_player.gd +++ b/addons/escoria-core/game/scenes/dialogs/esc_dialog_player.gd @@ -50,6 +50,31 @@ func _input(event): if event is InputEventMouseButton and \ event.pressed: finish_fast() + + +func _get_voice_file(key: String, start: String = "") -> String: + if start == "": + start = ProjectSettings.get("escoria/sound/speech_folder") + var _dir = Directory.new() + if _dir.open(start) == OK: + _dir.list_dir_begin(true, true) + var file_name = _dir.get_next() + while file_name != "": + if _dir.current_is_dir(): + var _voice_file = _get_voice_file( + key, + start.plus_file(file_name) + ) + if _voice_file != "": + return _voice_file + else: + if file_name == "%s.%s" % [ + key, + ProjectSettings.get("escoria/sound/speech_extension") + ]: + return start.plus_file(file_name) + file_name = _dir.get_next() + return "" # A short one line dialog @@ -63,7 +88,15 @@ func say(character: String, ui: String, line: String) -> void: is_speaking = true _dialog_ui = get_resource(ui).instance() get_parent().add_child(_dialog_ui) - _dialog_ui.say(character, line) + var _key_line = line.split(":") + if _key_line.size() == 2: + var _speech_resource = _get_voice_file(_key_line[0]) + if _speech_resource != "": + ( + escoria.object_manager.get_object("_speech").node\ + as ESCSpeechPlayer + ).set_state(_speech_resource) + _dialog_ui.say(character, _key_line[1]) yield(_dialog_ui, "dialog_line_finished") is_speaking = false emit_signal("dialog_line_finished") diff --git a/addons/escoria-core/game/scenes/dialogs/dialog_player.tscn b/addons/escoria-core/game/scenes/dialogs/esc_dialog_player.tscn similarity index 93% rename from addons/escoria-core/game/scenes/dialogs/dialog_player.tscn rename to addons/escoria-core/game/scenes/dialogs/esc_dialog_player.tscn index 8ce9b455..05782d3f 100644 --- a/addons/escoria-core/game/scenes/dialogs/dialog_player.tscn +++ b/addons/escoria-core/game/scenes/dialogs/esc_dialog_player.tscn @@ -2,7 +2,7 @@ [ext_resource path="res://game/ui/commons/dialogs/dialog_label.tscn" type="PackedScene" id=1] [ext_resource path="res://game/ui/commons/dialogs/text_dialog_choice.tscn" type="PackedScene" id=2] -[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/dialog_player.gd" type="Script" id=3] +[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/esc_dialog_player.gd" type="Script" id=3] [ext_resource path="res://game/ui/commons/dialogs/dialog_box_inset.tscn" type="PackedScene" id=4] [node name="dialog_player" type="ResourcePreloader"] diff --git a/addons/escoria-core/game/scenes/sound/bg_music.gd b/addons/escoria-core/game/scenes/sound/esc_music_player.gd similarity index 94% rename from addons/escoria-core/game/scenes/sound/bg_music.gd rename to addons/escoria-core/game/scenes/sound/esc_music_player.gd index c1398857..89257abc 100644 --- a/addons/escoria-core/game/scenes/sound/bg_music.gd +++ b/addons/escoria-core/game/scenes/sound/esc_music_player.gd @@ -1,10 +1,10 @@ # Background music player extends Control -class_name ESCBackgroundMusic +class_name ESCMusicPlayer # Global id of the background music player -export var global_id: String = "bg_music" +export var global_id: String = "_music" # The state of the music player. "default" or "off" disable music diff --git a/addons/escoria-core/game/scenes/sound/bg_music.tscn b/addons/escoria-core/game/scenes/sound/esc_music_player.tscn similarity index 90% rename from addons/escoria-core/game/scenes/sound/bg_music.tscn rename to addons/escoria-core/game/scenes/sound/esc_music_player.tscn index aa496f80..1b690767 100644 --- a/addons/escoria-core/game/scenes/sound/bg_music.tscn +++ b/addons/escoria-core/game/scenes/sound/esc_music_player.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://addons/escoria-core/game/scenes/sound/bg_music.gd" type="Script" id=1] +[ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_music_player.gd" type="Script" id=1] [node name="bg_music" type="Control"] anchor_right = 1.0 diff --git a/addons/escoria-core/game/scenes/sound/bg_sound.gd b/addons/escoria-core/game/scenes/sound/esc_sound_player.gd similarity index 94% rename from addons/escoria-core/game/scenes/sound/bg_sound.gd rename to addons/escoria-core/game/scenes/sound/esc_sound_player.gd index c827a5a1..16905da7 100644 --- a/addons/escoria-core/game/scenes/sound/bg_sound.gd +++ b/addons/escoria-core/game/scenes/sound/esc_sound_player.gd @@ -1,10 +1,10 @@ # Background sound player extends Control -class_name ESCBackgroundSound +class_name ESCSoundPlayer # Global id of the background sound player -export var global_id: String = "bg_sound" +export var global_id: String = "_sound" # The state of the sound player. "default" or "off" disable sound diff --git a/addons/escoria-core/game/scenes/sound/bg_sound.tscn b/addons/escoria-core/game/scenes/sound/esc_sound_player.tscn similarity index 92% rename from addons/escoria-core/game/scenes/sound/bg_sound.tscn rename to addons/escoria-core/game/scenes/sound/esc_sound_player.tscn index fcde5b60..2e1a4ce4 100644 --- a/addons/escoria-core/game/scenes/sound/bg_sound.tscn +++ b/addons/escoria-core/game/scenes/sound/esc_sound_player.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://addons/escoria-core/game/scenes/sound/bg_sound.gd" type="Script" id=1] +[ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_sound_player.gd" type="Script" id=1] [node name="bg_sound" type="Control"] anchor_right = 1.0 diff --git a/addons/escoria-core/game/scenes/sound/esc_speech_player.gd b/addons/escoria-core/game/scenes/sound/esc_speech_player.gd new file mode 100644 index 00000000..9f5f6e45 --- /dev/null +++ b/addons/escoria-core/game/scenes/sound/esc_speech_player.gd @@ -0,0 +1,44 @@ +# Speech player +extends Control +class_name ESCSpeechPlayer + + +# Global id of the background music player +export var global_id: String = "_speech" + + +# Set the state of this player +# +# #### Parameters +# +# - p_state: New state to use +# - p_force: Override the existing state even if the stream is still playing +func set_state(p_state: String, p_force: bool = false) -> void: + # If speech is disabled, return + if not escoria.settings.speech_enabled: + return + + # If state is "off"/"default", turn off speech + if p_state in ["off", "default"]: + $AudioStreamPlayer.stream = null + return + + var resource = load(p_state) + + $AudioStreamPlayer.stream = resource + + if $AudioStreamPlayer.stream: + resource.set_loop(false) + $AudioStreamPlayer.play() + + +# Register to the object registry +func _ready(): + escoria.object_manager.register_object( + ESCObject.new(global_id, self), + true + ) + + +func _on_AudioStreamPlayer_finished() -> void: + set_state("off") diff --git a/addons/escoria-core/game/scenes/sound/esc_speech_player.tscn b/addons/escoria-core/game/scenes/sound/esc_speech_player.tscn new file mode 100644 index 00000000..c0ff6cf9 --- /dev/null +++ b/addons/escoria-core/game/scenes/sound/esc_speech_player.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_speech_player.gd" type="Script" id=1] + +[node name="Control" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] +bus = "Speech" + +[connection signal="finished" from="AudioStreamPlayer" to="." method="_on_AudioStreamPlayer_finished"] diff --git a/addons/escoria-core/plugin.gd b/addons/escoria-core/plugin.gd index 7ca624d0..db92b3af 100644 --- a/addons/escoria-core/plugin.gd +++ b/addons/escoria-core/plugin.gd @@ -23,6 +23,10 @@ func _enter_tree(): # Prepare the settings in the Escoria UI category func set_escoria_ui_settings(): + ProjectSettings.set_setting( + "audio/default_bus_layout", + "res://addons/escoria-core/default_bus_layout.tres" + ) if !ProjectSettings.has_setting("escoria/ui/tooltip_follows_mouse"): ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", true) @@ -245,6 +249,25 @@ func set_escoria_sound_settings(): "type": TYPE_BOOL } ProjectSettings.add_property_info(speech_enabled_property_info) + if !ProjectSettings.has_setting("escoria/sound/speech_folder"): + ProjectSettings.set_setting( + "escoria/sound/speech_folder", + "res://speech" + ) + ProjectSettings.add_property_info({ + "name": "escoria/sound/speech_folder", + "type": TYPE_STRING, + "hint": PROPERTY_HINT_DIR + }) + if !ProjectSettings.has_setting("escoria/sound/speech_extension"): + ProjectSettings.set_setting( + "escoria/sound/speech_extension", + "ogg" + ) + ProjectSettings.add_property_info({ + "name": "escoria/sound/speech_extension", + "type": TYPE_STRING + }) # Prepare the settings in the Escoria platform category and may need special diff --git a/addons/escoria-ui-9verbs/game.tscn b/addons/escoria-ui-9verbs/game.tscn index 70c2139b..6bfbc647 100644 --- a/addons/escoria-ui-9verbs/game.tscn +++ b/addons/escoria-ui-9verbs/game.tscn @@ -3,7 +3,7 @@ [ext_resource path="res://addons/escoria-ui-9verbs/tooltip/action_target_tooltip.tscn" type="PackedScene" id=1] [ext_resource path="res://addons/escoria-ui-9verbs/inventory/inventory_ui.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/escoria-ui-9verbs/verbs_menu.tscn" type="PackedScene" id=3] -[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/dialog_player.tscn" type="PackedScene" id=4] +[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/esc_dialog_player.tscn" type="PackedScene" id=4] [ext_resource path="res://addons/escoria-ui-9verbs/game.gd" type="Script" id=5] [ext_resource path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" type="PackedScene" id=6] [ext_resource path="res://game/ui/commons/room_select.tscn" type="PackedScene" id=7] diff --git a/addons/escoria-ui-simplemouse/game.tscn b/addons/escoria-ui-simplemouse/game.tscn index 52b8e1ba..62208532 100644 --- a/addons/escoria-ui-simplemouse/game.tscn +++ b/addons/escoria-ui-simplemouse/game.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=9 format=2] [ext_resource path="res://addons/escoria-ui-simplemouse/inventory/inventory_ui.tscn" type="PackedScene" id=1] -[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/dialog_player.tscn" type="PackedScene" id=2] +[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/esc_dialog_player.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" type="PackedScene" id=3] [ext_resource path="res://addons/escoria-ui-simplemouse/verbs_mouseicons.tscn" type="PackedScene" id=4] [ext_resource path="res://addons/escoria-ui-simplemouse/game.gd" type="Script" id=5] diff --git a/docs/api/ESCBackgroundMusic.md b/docs/api/ESCMusicPlayer.md similarity index 92% rename from docs/api/ESCBackgroundMusic.md rename to docs/api/ESCMusicPlayer.md index 4259c986..ed52c79f 100644 --- a/docs/api/ESCBackgroundMusic.md +++ b/docs/api/ESCMusicPlayer.md @@ -1,6 +1,6 @@ -# ESCBackgroundMusic +# ESCMusicPlayer **Extends:** [Control](../Control) @@ -13,7 +13,7 @@ Background music player ### global\_id ```gdscript -export var global_id: String = "bg_music" +export var global_id: String = "_music" ``` Global id of the background music player diff --git a/docs/api/ESCObjectManager.md b/docs/api/ESCObjectManager.md index d9727412..be77517d 100644 --- a/docs/api/ESCObjectManager.md +++ b/docs/api/ESCObjectManager.md @@ -13,7 +13,7 @@ A manager for ESC objects ### RESERVED\_OBJECTS ```gdscript -const RESERVED_OBJECTS: Array = ["bg_music","bg_sound"] +const RESERVED_OBJECTS: Array = ["_music","_sound","_speech"] ``` ## Property Descriptions diff --git a/docs/api/ESCSaveSettings.md b/docs/api/ESCSaveSettings.md index 8a6e46da..4d179c54 100644 --- a/docs/api/ESCSaveSettings.md +++ b/docs/api/ESCSaveSettings.md @@ -66,13 +66,13 @@ export var sfx_volume: float = 0  Volume of SFX only -### voice\_volume +### speech\_volume ```gdscript -export var voice_volume: float = 0 +export var speech_volume: float = 0 ``` -Voice volume only +Speech volume only ### fullscreen diff --git a/docs/api/ESCBackgroundSound.md b/docs/api/ESCSoundPlayer.md similarity index 92% rename from docs/api/ESCBackgroundSound.md rename to docs/api/ESCSoundPlayer.md index ce678862..47b2396d 100644 --- a/docs/api/ESCBackgroundSound.md +++ b/docs/api/ESCSoundPlayer.md @@ -1,6 +1,6 @@ -# ESCBackgroundSound +# ESCSoundPlayer **Extends:** [Control](../Control) @@ -13,7 +13,7 @@ Background sound player ### global\_id ```gdscript -export var global_id: String = "bg_sound" +export var global_id: String = "_sound" ``` Global id of the background sound player diff --git a/docs/api/ESCSpeechPlayer.md b/docs/api/ESCSpeechPlayer.md new file mode 100644 index 00000000..a3491974 --- /dev/null +++ b/docs/api/ESCSpeechPlayer.md @@ -0,0 +1,34 @@ + + +# ESCSpeechPlayer + +**Extends:** [Control](../Control) + +## Description + +Speech player + +## Property Descriptions + +### global\_id + +```gdscript +export var global_id: String = "_speech" +``` + +Global id of the background music player + +## Method Descriptions + +### set\_state + +```gdscript +func set_state(p_state: String, p_force: bool = false) -> void +``` + +Set the state of this player + +#### Parameters + +- p_state: New state to use +- p_force: Override the existing state even if the stream is still playing \ No newline at end of file diff --git a/docs/api/PlaySndCommand.md b/docs/api/PlaySndCommand.md index 97fc631e..50bd011f 100644 --- a/docs/api/PlaySndCommand.md +++ b/docs/api/PlaySndCommand.md @@ -9,7 +9,7 @@ `play_snd file [player]` Plays the sound specificed with the "file" parameter on the sound player -`player`, without blocking. (player defaults to bg_sound) +`player`, without blocking. (player defaults to _sound) @ESC diff --git a/docs/api/SetSoundStateCommand.md b/docs/api/SetSoundStateCommand.md index a8233e93..ba81ff9c 100644 --- a/docs/api/SetSoundStateCommand.md +++ b/docs/api/SetSoundStateCommand.md @@ -10,7 +10,7 @@ Change the sound playing on `player` to `sound` with optional looping if `loop` is true. -Valid players are "bg_music" and "bg_sound". +Valid players are "_music" and "_sound". Aside from paths to sound or music files, the values *off* and *default*. *default* is the default value. are also valid for `sound` diff --git a/docs/api/main.gd.md b/docs/api/main.gd.md index 422699fe..fb0efc89 100644 --- a/docs/api/main.gd.md +++ b/docs/api/main.gd.md @@ -34,14 +34,6 @@ var wait_level The Escoria context currently in wait state -### bg\_music - -```gdscript -var bg_music -``` - -Reference to the ESCBackgroundMusic node - ### scene\_transition ```gdscript diff --git a/docs/esc.md b/docs/esc.md index e88f7556..eceee58e 100644 --- a/docs/esc.md +++ b/docs/esc.md @@ -233,7 +233,7 @@ Remove an item from the inventory. #### `play_snd file [player]` [API-Doc](api/PlaySndCommand.md) Plays the sound specificed with the "file" parameter on the sound player -`player`, without blocking. (player defaults to bg_sound) +`player`, without blocking. (player defaults to _sound) #### `queue_resource path [front_of_queue]` [API-Doc](api/QueueResourceCommand.md) Queues the load of a resource in a background thread. The `path` must be a @@ -303,7 +303,7 @@ Sets whether or not an object should be interactive. Change the sound playing on `player` to `sound` with optional looping if `loop` is true. -Valid players are "bg_music" and "bg_sound". +Valid players are "_music" and "_sound". Aside from paths to sound or music files, the values *off* and *default*. *default* is the default value. are also valid for `sound` diff --git a/game/rooms/room01/esc/right_exit.esc b/game/rooms/room01/esc/right_exit.esc old mode 100755 new mode 100644 index 348f08bd..4128b8bc --- a/game/rooms/room01/esc/right_exit.esc +++ b/game/rooms/room01/esc/right_exit.esc @@ -1,3 +1,3 @@ :exit_scene -set_sound_state bg_sound res://game/sfx/sounds/doorOpen_2.ogg false +set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false change_scene "res://game/rooms/room02/room02.tscn" diff --git a/game/rooms/room01/esc/room01.esc b/game/rooms/room01/esc/room01.esc old mode 100755 new mode 100644 index 12d83678..da073089 --- a/game/rooms/room01/esc/room01.esc +++ b/game/rooms/room01/esc/room01.esc @@ -11,7 +11,7 @@ :ready -set_sound_state bg_music res://game/sfx/contemplation.ogg true +set_sound_state _music res://game/sfx/contemplation.ogg true > [!room1_visited] set_global room1_visited true diff --git a/game/rooms/room02/esc/left_exit.esc b/game/rooms/room02/esc/left_exit.esc old mode 100755 new mode 100644 index c624a5f2..feabc671 --- a/game/rooms/room02/esc/left_exit.esc +++ b/game/rooms/room02/esc/left_exit.esc @@ -1,3 +1,3 @@ :exit_scene -set_sound_state bg_sound res://game/sfx/sounds/doorOpen_2.ogg false +set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false change_scene "res://game/rooms/room01/room01.tscn" diff --git a/game/rooms/room02/esc/right_exit.esc b/game/rooms/room02/esc/right_exit.esc old mode 100755 new mode 100644 index 8c80d364..b5ff0423 --- a/game/rooms/room02/esc/right_exit.esc +++ b/game/rooms/room02/esc/right_exit.esc @@ -1,3 +1,3 @@ :exit_scene -set_sound_state bg_sound res://game/sfx/sounds/doorOpen_2.ogg false +set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false change_scene "res://game/rooms/room03/room03.tscn" diff --git a/game/rooms/room10/esc/button_play_bg_music.esc b/game/rooms/room10/esc/button_play_bg_music.esc index 90e1b7e9..4559c7cb 100644 --- a/game/rooms/room10/esc/button_play_bg_music.esc +++ b/game/rooms/room10/esc/button_play_bg_music.esc @@ -1,2 +1,2 @@ :use -set_sound_state bg_music res://game/sfx/contemplation.ogg true +set_sound_state _music res://game/sfx/contemplation.ogg true diff --git a/game/rooms/room10/esc/button_stop_bg_music.esc b/game/rooms/room10/esc/button_stop_bg_music.esc index 20768e9f..c57ffecc 100644 --- a/game/rooms/room10/esc/button_stop_bg_music.esc +++ b/game/rooms/room10/esc/button_stop_bg_music.esc @@ -1,2 +1,2 @@ :use -set_sound_state bg_music off true +set_sound_state _music off true diff --git a/game/rooms/room10/esc/left_exit.esc b/game/rooms/room10/esc/left_exit.esc old mode 100755 new mode 100644 index 29eea379..339599ea --- a/game/rooms/room10/esc/left_exit.esc +++ b/game/rooms/room10/esc/left_exit.esc @@ -1,5 +1,5 @@ :exit_scene -set_sound_state bg_sound res://game/sfx/sounds/doorOpen_2.ogg false +set_sound_state _sound res://game/sfx/sounds/doorOpen_2.ogg false change_scene "res://game/rooms/room09/room09.tscn" diff --git a/game/speech/room01/ROOM1_look_wall_item_1.ogg b/game/speech/room01/ROOM1_look_wall_item_1.ogg new file mode 100644 index 00000000..007dd9bd Binary files /dev/null and b/game/speech/room01/ROOM1_look_wall_item_1.ogg differ diff --git a/game/speech/room01/ROOM1_look_wall_item_1_de.ogg b/game/speech/room01/ROOM1_look_wall_item_1_de.ogg new file mode 100644 index 00000000..f8e4d5fa Binary files /dev/null and b/game/speech/room01/ROOM1_look_wall_item_1_de.ogg differ diff --git a/game/speech/room01/ROOM1_look_wall_item_2.ogg b/game/speech/room01/ROOM1_look_wall_item_2.ogg new file mode 100644 index 00000000..efcf1d9a Binary files /dev/null and b/game/speech/room01/ROOM1_look_wall_item_2.ogg differ diff --git a/game/speech/room01/ROOM1_look_wall_item_2_de.ogg b/game/speech/room01/ROOM1_look_wall_item_2_de.ogg new file mode 100644 index 00000000..6dc98f87 Binary files /dev/null and b/game/speech/room01/ROOM1_look_wall_item_2_de.ogg differ diff --git a/game/speech/room01/ROOM1_look_wall_item_3.ogg b/game/speech/room01/ROOM1_look_wall_item_3.ogg new file mode 100644 index 00000000..9d994027 Binary files /dev/null and b/game/speech/room01/ROOM1_look_wall_item_3.ogg differ diff --git a/game/speech/room01/ROOM1_look_wall_item_3_de.ogg b/game/speech/room01/ROOM1_look_wall_item_3_de.ogg new file mode 100644 index 00000000..96914bf9 Binary files /dev/null and b/game/speech/room01/ROOM1_look_wall_item_3_de.ogg differ diff --git a/game/speech/room01/ROOM1_look_wall_item_4.ogg b/game/speech/room01/ROOM1_look_wall_item_4.ogg new file mode 100644 index 00000000..a2bfbe70 Binary files /dev/null and b/game/speech/room01/ROOM1_look_wall_item_4.ogg differ diff --git a/game/speech/room01/ROOM1_look_wall_item_4_de.ogg b/game/speech/room01/ROOM1_look_wall_item_4_de.ogg new file mode 100644 index 00000000..f54617f5 Binary files /dev/null and b/game/speech/room01/ROOM1_look_wall_item_4_de.ogg differ diff --git a/game/translations/main_menu.csv b/game/translations/main_menu.csv index b4c25e09..cf480652 100644 --- a/game/translations/main_menu.csv +++ b/game/translations/main_menu.csv @@ -10,6 +10,7 @@ OPTIONS_LANGUAGE,Language,Langue,Sprache GENERAL_VOLUME,General,Général,Allgemein MUSIC_VOLUME,Music,Musique,Musik SOUND_VOLUME,Sound effects,Effets sonores,Soundeffekte +SPEECH_VOLUME,Speech,Voix,Sprachausgabe CANCEL,Cancel,Annuler,Abbrechen OK,OK,Ok,Ok ENTER_SAVE_NAME,Enter the save name:,Entrez un nom de sauvegarde,Bitte gib einen Namen für das Spiel ein: diff --git a/game/translations/main_menu.de.translation b/game/translations/main_menu.de.translation index 987ec021..7e71580a 100644 Binary files a/game/translations/main_menu.de.translation and b/game/translations/main_menu.de.translation differ diff --git a/game/translations/main_menu.en.translation b/game/translations/main_menu.en.translation index 9edeb798..0a45fd1b 100644 Binary files a/game/translations/main_menu.en.translation and b/game/translations/main_menu.en.translation differ diff --git a/game/translations/main_menu.fr.translation b/game/translations/main_menu.fr.translation index ea0ff883..9985abc1 100644 Binary files a/game/translations/main_menu.fr.translation and b/game/translations/main_menu.fr.translation differ diff --git a/game/ui/commons/main_menu/main_menu.gd b/game/ui/commons/main_menu/main_menu.gd index 4e4bc5e8..02937b47 100644 --- a/game/ui/commons/main_menu/main_menu.gd +++ b/game/ui/commons/main_menu/main_menu.gd @@ -5,7 +5,7 @@ func _ready(): var event = ESCEvent.new(":music") event.statements.append( ESCCommand.new( - "set_sound_state bg_music res://game/sfx/Game-Menu_Looping.mp3 true" + "set_sound_state _music res://game/sfx/Game-Menu_Looping.mp3 true" ) ) escoria.event_manager.queue_event(event) diff --git a/game/ui/commons/options/options.gd b/game/ui/commons/options/options.gd index 9ee8b654..4a7fa82e 100644 --- a/game/ui/commons/options/options.gd +++ b/game/ui/commons/options/options.gd @@ -40,6 +40,7 @@ func initialize_options(p_settings): _options.get_node("general_volume").value = p_settings["master_volume"] _options.get_node("sound_volume").value = p_settings["sfx_volume"] _options.get_node("music_volume").value = p_settings["music_volume"] + _options.get_node("speech_volume").value = p_settings["speech_volume"] func _on_language_input(event: InputEvent, language: String): @@ -77,3 +78,9 @@ func _on_back_pressed(): escoria.settings = backup_settings escoria._on_settings_loaded(escoria.settings) emit_signal("back_button_pressed") + + +func _on_speech_volume_value_changed(value: float) -> void: + escoria.settings["speech_volume"] = value + escoria._on_settings_loaded(escoria.settings) + settings_changed = true diff --git a/game/ui/commons/options/options.tscn b/game/ui/commons/options/options.tscn index 6e9432f8..f75317aa 100644 --- a/game/ui/commons/options/options.tscn +++ b/game/ui/commons/options/options.tscn @@ -19,16 +19,16 @@ size_flags_vertical = 3 [node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] margin_left = 482.0 -margin_top = 366.0 +margin_top = 354.0 margin_right = 798.0 -margin_bottom = 533.0 +margin_bottom = 546.0 __meta__ = { "_edit_use_anchors_": false } [node name="MarginContainer" type="MarginContainer" parent="CenterContainer/VBoxContainer"] margin_right = 316.0 -margin_bottom = 136.0 +margin_bottom = 161.0 size_flags_vertical = 6 custom_constants/margin_right = 20 custom_constants/margin_top = 20 @@ -39,7 +39,7 @@ custom_constants/margin_bottom = 20 margin_left = 20.0 margin_top = 20.0 margin_right = 296.0 -margin_bottom = 116.0 +margin_bottom = 141.0 size_flags_vertical = 6 custom_constants/hseparation = 40 columns = 2 @@ -115,10 +115,28 @@ max_value = 1.0 step = 0.001 value = 0.001 +[node name="label5" type="Label" parent="CenterContainer/VBoxContainer/MarginContainer/options"] +margin_top = 100.0 +margin_right = 220.0 +margin_bottom = 121.0 +custom_fonts/font = ExtResource( 1 ) +text = "SPEECH_VOLUME" + +[node name="speech_volume" type="HSlider" parent="CenterContainer/VBoxContainer/MarginContainer/options"] +margin_left = 260.0 +margin_top = 100.0 +margin_right = 276.0 +margin_bottom = 116.0 +size_flags_horizontal = 3 +min_value = 0.001 +max_value = 1.0 +step = 0.001 +value = 0.001 + [node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer"] -margin_top = 140.0 +margin_top = 165.0 margin_right = 316.0 -margin_bottom = 167.0 +margin_bottom = 192.0 custom_constants/separation = 20 alignment = 1 @@ -145,5 +163,6 @@ __meta__ = { [connection signal="value_changed" from="CenterContainer/VBoxContainer/MarginContainer/options/general_volume" to="." method="_on_general_volume_changed"] [connection signal="value_changed" from="CenterContainer/VBoxContainer/MarginContainer/options/sound_volume" to="." method="_on_sound_volume_changed"] [connection signal="value_changed" from="CenterContainer/VBoxContainer/MarginContainer/options/music_volume" to="." method="_on_music_volume_changed"] +[connection signal="value_changed" from="CenterContainer/VBoxContainer/MarginContainer/options/speech_volume" to="." method="_on_speech_volume_value_changed"] [connection signal="pressed" from="CenterContainer/VBoxContainer/HBoxContainer/back" to="." method="_on_back_pressed"] [connection signal="pressed" from="CenterContainer/VBoxContainer/HBoxContainer/apply" to="." method="_on_apply_pressed"] diff --git a/project.godot b/project.godot index 4de6c9ce..130d3a25 100644 --- a/project.godot +++ b/project.godot @@ -104,16 +104,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://addons/escoria-core/game/core-scripts/esc_background.gd" }, { -"base": "Control", -"class": "ESCBackgroundMusic", -"language": "GDScript", -"path": "res://addons/escoria-core/game/scenes/sound/bg_music.gd" -}, { -"base": "Control", -"class": "ESCBackgroundSound", -"language": "GDScript", -"path": "res://addons/escoria-core/game/scenes/sound/bg_sound.gd" -}, { "base": "Node", "class": "ESCBaseCommand", "language": "GDScript", @@ -177,7 +167,7 @@ _global_script_classes=[ { "base": "ResourcePreloader", "class": "ESCDialogsPlayer", "language": "GDScript", -"path": "res://addons/escoria-core/game/scenes/dialogs/dialog_player.gd" +"path": "res://addons/escoria-core/game/scenes/dialogs/esc_dialog_player.gd" }, { "base": "Resource", "class": "ESCDirectionAngle", @@ -254,6 +244,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://addons/escoria-core/game/core-scripts/behaviors/esc_movable.gd" }, { +"base": "Control", +"class": "ESCMusicPlayer", +"language": "GDScript", +"path": "res://addons/escoria-core/game/scenes/sound/esc_music_player.gd" +}, { "base": "Node", "class": "ESCObject", "language": "GDScript", @@ -304,6 +299,16 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://addons/escoria-core/game/core-scripts/esc/types/esc_script.gd" }, { +"base": "Control", +"class": "ESCSoundPlayer", +"language": "GDScript", +"path": "res://addons/escoria-core/game/scenes/sound/esc_sound_player.gd" +}, { +"base": "Control", +"class": "ESCSpeechPlayer", +"language": "GDScript", +"path": "res://addons/escoria-core/game/scenes/sound/esc_speech_player.gd" +}, { "base": "Object", "class": "ESCStatement", "language": "GDScript", @@ -504,8 +509,6 @@ _global_script_class_icons={ "ESCAnimationPlayer": "", "ESCAnimationResource": "", "ESCBackground": "res://addons/escoria-core/design/esc_background.svg", -"ESCBackgroundMusic": "", -"ESCBackgroundSound": "", "ESCBaseCommand": "", "ESCCamera": "", "ESCCameraLimits": "", @@ -534,6 +537,7 @@ _global_script_class_icons={ "ESCLocation": "res://addons/escoria-core/design/esc_location.svg", "ESCLogger": "", "ESCMovable": "", +"ESCMusicPlayer": "", "ESCObject": "", "ESCObjectManager": "", "ESCPlayer": "res://addons/escoria-core/design/esc_player.svg", @@ -544,6 +548,8 @@ _global_script_class_icons={ "ESCSaveSettings": "", "ESCScheduledEvent": "", "ESCScript": "", +"ESCSoundPlayer": "", +"ESCSpeechPlayer": "", "ESCStatement": "", "ESCTerrain": "res://addons/escoria-core/design/esc_terrain.svg", "ESCTooltip": "", @@ -592,6 +598,10 @@ boot_splash/use_filter=false boot_splash/bg_color=Color( 0.960784, 0.384314, 0, 1 ) config/icon="res://icon.png" +[audio] + +default_bus_layout="res://addons/escoria-core/default_bus_layout.tres" + [autoload] escoria="*res://addons/escoria-core/game/escoria.tscn" @@ -642,6 +652,8 @@ main/escoria_version="" sound/speech_enabled=1 ui/game_scene="res://addons/escoria-ui-9verbs/game.tscn" ui/dialogs_chooser="res://game/ui/commons/dialogs/text_dialog_choice.tscn" +sound/speech_folder="res://game/speech" +sound/speech_extension="ogg" [input] @@ -661,6 +673,12 @@ switch_action_verb={ translations=PoolStringArray( "res://game/translations/game.en.translation", "res://game/translations/game.fr.translation", "res://game/translations/main_menu.en.translation", "res://game/translations/main_menu.fr.translation", "res://game/translations/game.de.translation", "res://game/translations/main_menu.de.translation" ) locale_filter=[ 0, [ ] ] +translation_remaps={ +"res://game/speech/room01/ROOM1_look_wall_item_1.ogg": PoolStringArray( "res://game/speech/room01/ROOM1_look_wall_item_1_de.ogg:de" ), +"res://game/speech/room01/ROOM1_look_wall_item_2.ogg": PoolStringArray( "res://game/speech/room01/ROOM1_look_wall_item_2_de.ogg:de" ), +"res://game/speech/room01/ROOM1_look_wall_item_3.ogg": PoolStringArray( "res://game/speech/room01/ROOM1_look_wall_item_3_de.ogg:de" ), +"res://game/speech/room01/ROOM1_look_wall_item_4.ogg": PoolStringArray( "res://game/speech/room01/ROOM1_look_wall_item_4_de.ogg:de" ) +} [network]