DRY special dialogue tags + voiceover

This commit is contained in:
2021-12-14 19:00:38 -07:00
parent 9fc66840c6
commit 2f3066f1f6
3 changed files with 30 additions and 18 deletions

View File

@@ -3,27 +3,35 @@
(function isUpperCase [s]
(= s (s.toUpperCase)))
(registerConversion
(new ktxt2.StreamConversion "On Phone Speech" "fountain" "hollywoo"
->stream
?(whenLet [(Some name) (stream.takeUntilAndDrop " (O.P.")]
(and (isUpperCase name) {(stream.dropWhitespace) !(stream.isEmpty)}))
->stream
(let [name (whenLet [(Some name) (stream.takeUntilAndDrop " (O.P.")] name)
&mut output ""]
(stream.takeLine)
(loop
(let [wryly (ifLet [(Some w) (stream.takeBetween "(" ")\n")] w "")
line (ifLet [(Some l) (stream.takeLine)] (l.trim) (break))]
(when line
(+= output "ONPHONESPEECH \"${name}\" \"${wryly}\" ##\"${line}\"##\n"))))
output)))
(var :Array<String> specialSpeechTags [])
(function specialSpeech [name parenTag hmethod]
(specialSpeechTags.push parenTag)
(registerConversion
(new ktxt2.StreamConversion name "fountain" "hollywoo"
->stream
?(whenLet [(Some name) (stream.takeUntilAndDrop " (${parenTag}")]
(and (isUpperCase name) {(stream.dropWhitespace) !(stream.isEmpty)}))
->stream
(let [name (whenLet [(Some name) (stream.takeUntilAndDrop " (${parenTag}")] name)
&mut output ""]
(stream.takeLine)
(loop
(let [wryly (ifLet [(Some w) (stream.takeBetween "(" ")\n")] w "")
line (ifLet [(Some l) (stream.takeLine)] (l.trim) (break))]
(when line
(+= output "$hmethod \"${name}\" \"${wryly}\" ##\"${line}\"##\n"))))
output))))
(specialSpeech "On Phone Speech" "O.P." "ONPHONESPEECH")
(specialSpeech "VoiceOver Speech" "V.O." "VOICEOVER")
(registerConversion
(new ktxt2.StreamConversion "Normal Speech" "fountain" "hollywoo"
->stream ?(whenLet [(Some name) (stream.takeLine)
None (indexOf name "(O.P.")
None (indexOf name "(V.O.")] (and (isUpperCase name) {(stream.dropWhitespace) !(stream.isEmpty)}))
->stream ?(whenLet [(Some name) (stream.takeLine)]
(doFor tag specialSpeechTags
(whenLet [(Some _) (indexOf name "(${tag}")] (return false)))
(and (isUpperCase name) {(stream.dropWhitespace) !(stream.isEmpty)}))
->stream
(let [name (whenLet [(Some name) (stream.takeLine)] name)
&mut output ""]

View File

@@ -207,6 +207,9 @@
(hollywooMethod normalSpeech [actorName wryly text :Continuation cc]
(showDialog actorName (OnScreen (dictGet .characters (_currentScene) actorName)) wryly text cc))
(hollywooMethod voiceOver [actorName wryly text :Continuation cc]
(showDialog actorName (VoiceOver (dictGet actors actorName)) wryly text cc))
(hollywooMethod onPhoneSpeech [actorName wryly text :Continuation cc]
(showDialog actorName (ifLet [charOnScreen (dictGet .characters (_currentScene) actorName)]
(OnScreen charOnScreen)

View File

@@ -22,6 +22,7 @@ typedef Character<StagePosition, StageFacing, Actor> = {
enum SpeechType<StagePosition, StageFacing, Actor> {
Super;
OffScreen(actor:Actor);
VoiceOver(actor:Actor);
TextMessage(actor:Actor);
FromPhone(actor:Actor);
OnScreen(character:Character<StagePosition, StageFacing, Actor>);