Add subtitle UI for voice playback
This commit is contained in:
@@ -45,7 +45,8 @@ namespace BriarQueen.Framework.Managers.Audio
|
||||
private AudioSource _musicSourceB;
|
||||
private AudioSource _voiceSource;
|
||||
|
||||
private string _activeVoiceSubtitleId;
|
||||
private VoiceKey _activeVoiceKey = VoiceKey.None;
|
||||
private SubtitleKey _activeSubtitleKey = SubtitleKey.None;
|
||||
private AudioFileSo _currentMusicTrack;
|
||||
|
||||
private CancellationTokenSource _musicDuckCts;
|
||||
@@ -140,7 +141,8 @@ namespace BriarQueen.Framework.Managers.Audio
|
||||
_musicSourceB = null;
|
||||
_voiceSource = null;
|
||||
_currentMusicTrack = null;
|
||||
_activeVoiceSubtitleId = null;
|
||||
_activeVoiceKey = VoiceKey.None;
|
||||
_activeSubtitleKey = SubtitleKey.None;
|
||||
_voiceFinishedPublished = false;
|
||||
Initialized = false;
|
||||
}
|
||||
@@ -205,8 +207,7 @@ namespace BriarQueen.Framework.Managers.Audio
|
||||
if (_audioMixer == null || string.IsNullOrWhiteSpace(parameter))
|
||||
return;
|
||||
|
||||
if (!_baseDb.TryGetValue(parameter, out var baseDb))
|
||||
baseDb = 0f;
|
||||
var baseDb = _baseDb.GetValueOrDefault(parameter, 0f);
|
||||
|
||||
var effective = baseDb;
|
||||
|
||||
@@ -340,10 +341,14 @@ namespace BriarQueen.Framework.Managers.Audio
|
||||
_voiceCts = new CancellationTokenSource();
|
||||
var token = _voiceCts.Token;
|
||||
|
||||
_activeVoiceSubtitleId = SubtitleIdentifiers.Get(audioData.MatchingSubtitleID);
|
||||
_activeVoiceKey = audioData.VoiceKey;
|
||||
_activeSubtitleKey = audioData.MatchingSubtitleID;
|
||||
_voiceFinishedPublished = false;
|
||||
|
||||
_eventCoordinator.Publish(new VoiceLineStartedEvent(_activeVoiceSubtitleId));
|
||||
_eventCoordinator.Publish(new VoicePlaybackStartedEvent(
|
||||
_activeVoiceKey,
|
||||
_activeSubtitleKey,
|
||||
audioData.Clip.length));
|
||||
|
||||
_voiceSource.clip = audioData.Clip;
|
||||
_voiceSource.pitch = audioData.Pitch;
|
||||
@@ -369,11 +374,16 @@ namespace BriarQueen.Framework.Managers.Audio
|
||||
{
|
||||
if (_voiceFinishedPublished) return;
|
||||
|
||||
if (!string.IsNullOrEmpty(_activeVoiceSubtitleId))
|
||||
_eventCoordinator.Publish(new VoiceLineFinishedEvent(_activeVoiceSubtitleId));
|
||||
if (_activeVoiceKey != VoiceKey.None || _activeSubtitleKey != SubtitleKey.None)
|
||||
{
|
||||
_eventCoordinator.Publish(new VoicePlaybackFinishedEvent(
|
||||
_activeVoiceKey,
|
||||
_activeSubtitleKey));
|
||||
}
|
||||
|
||||
_voiceFinishedPublished = true;
|
||||
_activeVoiceSubtitleId = null;
|
||||
_activeVoiceKey = VoiceKey.None;
|
||||
_activeSubtitleKey = SubtitleKey.None;
|
||||
}
|
||||
|
||||
public void StopVoice()
|
||||
@@ -666,4 +676,4 @@ namespace BriarQueen.Framework.Managers.Audio
|
||||
public float StartedAtUnscaled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user