From c9f99e78cec33e546188b251ac148b8dbac5ff72 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 30 Dec 2021 12:03:54 -0700 Subject: [PATCH] skip voice tracks when skipping dialogue --- .../hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx | 1 + .../src/hollywoo_flixel/FlxDirector.kiss | 9 ++++++++- projects/hollywoo/src/hollywoo/Director.hx | 1 + projects/hollywoo/src/hollywoo/Movie.kiss | 10 ++++++---- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx index d9701034..4f28756e 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx @@ -15,6 +15,7 @@ import flixel.util.FlxColor; import flixel.text.FlxText; import flixel.system.FlxSound; import flixel.util.FlxTimer; +import haxe.Constraints; @:build(kiss.Kiss.build()) class FlxDirector implements Director {} diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss index 24795dc0..3b7fcfef 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss @@ -126,13 +126,20 @@ (sound.play) (unless waitForEnd (cc))) +(var DELAY_BETWEEN_VOICE_TRACKS 0.1) +(prop :Map restoreOriginalVolumes (new Map)) (method :Void playVoiceTrack [:FlxSound track :Float volumeMod :Float start :Float end :Continuation cc] (let [originalVolume track.volume restoreOriginalVolume ->(set track.volume originalVolume)] + (dictSet restoreOriginalVolumes track restoreOriginalVolume) (*= track.volume volumeMod) - (set track.onComplete ->{(restoreOriginalVolume) (movie.delay 0.1 cc)})) + (set track.onComplete ->{(restoreOriginalVolume) (movie.delay DELAY_BETWEEN_VOICE_TRACKS cc)})) (track.play true (* 1000 start) (* 1000 end))) +(method :Void stopVoiceTrack [:FlxSound track] + (track.stop) + ((dictGet restoreOriginalVolumes track))) + (prop &mut :FlxSound music) (prop MUSIC_FADE_SEC 1) (prop MUSIC_FADE_STEPS 10) diff --git a/projects/hollywoo/src/hollywoo/Director.hx b/projects/hollywoo/src/hollywoo/Director.hx index 6628feca..586b0983 100644 --- a/projects/hollywoo/src/hollywoo/Director.hx +++ b/projects/hollywoo/src/hollywoo/Director.hx @@ -17,6 +17,7 @@ interface Director{}))) - (let [cc ->:Void {(director.hideDialog) (cc)}] - (director.showDialog actorName dialogType wryly text cc) + (let [cc ->:Void {(director.hideDialog) (cc)} + &mut skipCC cc] // When an actorName is given, check for a voiced line to play. // Otherwise, assume it is un-voiced super text (when (and actorName (< 0 (count voiceTracks))) (case (try (dictGet voiceLines "$actorName $text") (catch [e] (print e) null)) ((objectWith trackKey start end) - (director.playVoiceTrack (dictGet voiceTracks trackKey) 1 start end cc)) - (otherwise))))) + (director.playVoiceTrack (dictGet voiceTracks trackKey) 1 start end cc) + (set skipCC ->:Void {(director.stopVoiceTrack (dictGet voiceTracks trackKey)) (cc)})) + (otherwise))) + (director.showDialog actorName dialogType wryly text skipCC))) (method newVoiceTrack [actorName :VoiceTrack track :String lineJson] (let [actorNumVoiceTracks (or (dictGet voiceTracksPerActor actorName) 0)