custom handlers need a separate skipCC and cc

This commit is contained in:
2023-07-04 11:03:27 -06:00
parent 3c47446b7a
commit c49801726d
2 changed files with 7 additions and 3 deletions

View File

@@ -45,8 +45,8 @@ enum HistoryElement<Actor> {
// I don't want to manually define scene changes though.
}
// (speakerName, character, wryly, args, text, cc) -> cleanup function
typedef CustomDialogTypeHandler<Actor> = (String, Character<Actor>, String, Array<Dynamic>, String, Continuation) -> (Void->Void);
// (speakerName, character, wryly, args, text, skipCC, cc) -> cleanup function
typedef CustomDialogTypeHandler<Actor> = (String, Character<Actor>, String, Array<Dynamic>, String, Continuation, Continuation) -> (Void->Void);
enum CreditsLine {
OneColumn(s:String);

View File

@@ -74,6 +74,7 @@
(processIntercut actorName
(makeCC
(let [cc ->:Void {(director.hideDialog) (cc)}
&mut customCC cc
&mut skipCC cc]
// When an actorName is given, check for a voiced line to play.
// Otherwise, assume it is un-voiced super text
@@ -94,15 +95,18 @@
(case (dictGet altIdx "$actorName $text")
(null
(dictSet altIdx "$actorName $text" 0)
(set customCC ->:Void {})
(director.playVoiceTrack (dictGet voiceTracks trackKey) 1 start end cc))
((when (>= idx alts.length) idx)
(dictSet altIdx "$actorName $text" 0)
(set customCC ->:Void {})
(director.playVoiceTrack (dictGet voiceTracks trackKey) 1 start end cc))
(idx
(let [alt (nth alts idx)
start alt.start
end alt.end]
(+= (dictGet altIdx "$actorName $text") 1)
(set customCC ->:Void {})
(director.playVoiceTrack (dictGet voiceTracks trackKey) 1 start end cc))))
(set skipCC ->:Void {(director.stopVoiceTrack (dictGet voiceTracks trackKey)) (cc)}))
@@ -113,7 +117,7 @@
(case dialogType
((Custom type character args)
(ifLet [handler (dictGet customDialogTypeHandlers type)]
(let [cleanupFunc (handler actorName character wryly args text skipCC)]
(let [cleanupFunc (handler actorName character wryly args text skipCC customCC)]
(set _hideCustomDialog cleanupFunc))
(throw "No handler for custom dialog type $type")))
(otherwise (director.showDialog actorName dialogType wryly text skipCC)))))))