Issue 377 (#383)
* feat: Implements speech fixes #377 * docs: Automatic update of API docs * chore: Updated speech translation. Co-authored-by: Dennis Ploeger <develop@dieploegers.de> Co-authored-by: dploeger <dploeger@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
44
addons/escoria-core/game/scenes/sound/esc_speech_player.gd
Normal file
44
addons/escoria-core/game/scenes/sound/esc_speech_player.gd
Normal file
@@ -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")
|
||||
17
addons/escoria-core/game/scenes/sound/esc_speech_player.tscn
Normal file
17
addons/escoria-core/game/scenes/sound/esc_speech_player.tscn
Normal file
@@ -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"]
|
||||
Reference in New Issue
Block a user