Implement audio management system with effects and music players; add settings for sound and music volume
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
extends SceneTree
|
||||
|
||||
var checks: int = 0
|
||||
var failures: int = 0
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("run")
|
||||
|
||||
|
||||
func check(condition: bool, message: String) -> void:
|
||||
checks += 1
|
||||
if not condition:
|
||||
failures += 1
|
||||
push_error(message)
|
||||
|
||||
|
||||
func run() -> void:
|
||||
var player := OwniverseMusicPlayer.new()
|
||||
root.add_child(player)
|
||||
await process_frame
|
||||
|
||||
check(player.last_track == "", "Music player starts with silence")
|
||||
check(player._pause_timer.time_left >= player.MIN_PAUSE_SECONDS and player._pause_timer.time_left <= player.MAX_PAUSE_SECONDS, "Initial pause is between two and five minutes")
|
||||
player._pause_timer.stop()
|
||||
player._play_next()
|
||||
check(player.last_track != "", "Music player selects an initial track")
|
||||
check(player.last_track != player.EXCLUDED_TRACK, "Normal playlist excludes apocalypse")
|
||||
var previous: String = player.last_track
|
||||
player._play_next()
|
||||
check(player.last_track != previous, "Consecutive tracks do not repeat")
|
||||
check(player.last_track != player.EXCLUDED_TRACK, "Subsequent tracks exclude apocalypse")
|
||||
|
||||
var last_normal_track: String = player.last_track
|
||||
player.play_apocalypse()
|
||||
check(player.stream == player._music[player.EXCLUDED_TRACK] and player.playing, "Apocalypse music starts immediately")
|
||||
check(player.last_track == last_normal_track, "Apocalypse does not replace the last normal track")
|
||||
|
||||
player._schedule_pause()
|
||||
check(player._pause_timer.time_left >= player.MIN_PAUSE_SECONDS and player._pause_timer.time_left <= player.MAX_PAUSE_SECONDS, "Pause is between two and five minutes")
|
||||
player.set_enabled(false)
|
||||
check(player.stream_paused and player._pause_timer.paused, "Disabling music pauses playback and scheduling")
|
||||
var disabled_stream: AudioStream = player.stream
|
||||
player.play_apocalypse()
|
||||
check(player.stream == disabled_stream, "Apocalypse does not start while music is disabled")
|
||||
player.set_enabled(true)
|
||||
check(not player.stream_paused and not player._pause_timer.paused, "Enabling music resumes playback and scheduling")
|
||||
|
||||
player.stop()
|
||||
player.stream = null
|
||||
player.free()
|
||||
await process_frame
|
||||
print("Music player: %d checks, %d failures" % [checks, failures])
|
||||
quit(0 if failures == 0 else 1)
|
||||
Reference in New Issue
Block a user