Unified settings management and sound fixes
- fix: speech was not paused during pause menu - fix: allow sound levels to reach min value 0.0 (=muted) - fix: crash was happening when switch language during the game
This commit is contained in:
committed by
Duncan Brown
parent
4ef86c6cc3
commit
04348147b9
@@ -44,10 +44,6 @@ func set_state(p_state: String, p_force: bool = false) -> void:
|
||||
resource.loop_end = resource.mix_rate * resource.get_length()
|
||||
elif "loop" in resource:
|
||||
resource.loop = true
|
||||
if ESCProjectSettingsManager.has_setting(ESCProjectSettingsManager.MUSIC_VOLUME):
|
||||
stream.volume_db = ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.MUSIC_VOLUME
|
||||
)
|
||||
stream.play()
|
||||
|
||||
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_music_player.gd" type="Script" id=1]
|
||||
|
||||
[node name="bg_music" type="Control"]
|
||||
pause_mode = 2
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = -1680.0
|
||||
margin_bottom = -1050.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
bus = "Music"
|
||||
|
||||
@@ -43,10 +43,6 @@ func set_state(p_state: String, p_force: bool = false):
|
||||
resource.loop_mode = AudioStreamSample.LOOP_DISABLED
|
||||
elif "loop" in resource:
|
||||
resource.loop = false
|
||||
if ESCProjectSettingsManager.has_setting(ESCProjectSettingsManager.SFX_VOLUME):
|
||||
stream.volume_db = ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.SFX_VOLUME
|
||||
)
|
||||
stream.play()
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_sound_player.gd" type="Script" id=1]
|
||||
|
||||
[node name="bg_sound" type="Control"]
|
||||
pause_mode = 2
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = -1680.0
|
||||
|
||||
@@ -6,6 +6,9 @@ class_name ESCSpeechPlayer
|
||||
# Global id of the background music player
|
||||
export var global_id: String = "_speech"
|
||||
|
||||
# Reference to the audio player
|
||||
onready var stream: AudioStreamPlayer = $AudioStreamPlayer
|
||||
|
||||
|
||||
# Set the state of this player
|
||||
#
|
||||
@@ -15,20 +18,21 @@ export var global_id: String = "_speech"
|
||||
# - 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:
|
||||
if not ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.SPEECH_ENABLED
|
||||
):
|
||||
return
|
||||
|
||||
# If state is "off"/"default", turn off speech
|
||||
if p_state in ["off", "default"]:
|
||||
$AudioStreamPlayer.stream = null
|
||||
stream.stream = null
|
||||
return
|
||||
|
||||
var resource = load(p_state)
|
||||
stream.stream = resource
|
||||
|
||||
$AudioStreamPlayer.stream = resource
|
||||
|
||||
if $AudioStreamPlayer.stream:
|
||||
resource.set_loop(false)
|
||||
if stream.stream:
|
||||
stream.stream.set_loop(false)
|
||||
$AudioStreamPlayer.play()
|
||||
|
||||
|
||||
@@ -42,5 +46,16 @@ func _ready():
|
||||
)
|
||||
|
||||
|
||||
# Callback called when the audio stream player finished playing.
|
||||
func _on_AudioStreamPlayer_finished() -> void:
|
||||
set_state("off")
|
||||
|
||||
|
||||
# Pause the speech player
|
||||
func pause():
|
||||
stream.stream_paused = true
|
||||
|
||||
|
||||
# Unpause the speech player
|
||||
func resume():
|
||||
stream.stream_paused = false
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_speech_player.gd" type="Script" id=1]
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
pause_mode = 2
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
|
||||
Reference in New Issue
Block a user