From 28c9c9fa787c7954ad585ca05de18663e607bdb0 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sat, 4 Dec 2021 00:12:13 -0700 Subject: [PATCH] fixes for Hollywoo --- kiss/src/kiss/Prelude.hx | 1 + .../src/hollywoo_flixel/FlxDirector.kiss | 3 +- projects/hollywoo/src/hollywoo/Movie.kiss | 43 ++++++++++--------- projects/kiss-vscode/src/ktxt2/KTxt2.kiss | 15 +++---- .../src/ktxt2/KTxt2EditorProvider.kiss | 2 +- 5 files changed, 31 insertions(+), 33 deletions(-) diff --git a/kiss/src/kiss/Prelude.hx b/kiss/src/kiss/Prelude.hx index de58227b..c3cd7d76 100644 --- a/kiss/src/kiss/Prelude.hx +++ b/kiss/src/kiss/Prelude.hx @@ -653,4 +653,5 @@ class Prelude { public static var newLine = "\n"; public static var backSlash = "\\"; + public static var doubleQuote = "\""; } diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss index 26968183..95d35ee1 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss @@ -36,7 +36,8 @@ (Left STAGE_LEFT_X) (Right - STAGE_RIGHT_X)) + STAGE_RIGHT_X) + (otherwise (throw "unsupported stage position"))) (/ character.actor.width 2))) (set character.actor.y ACTOR_Y) (currentState.add character.actor) diff --git a/projects/hollywoo/src/hollywoo/Movie.kiss b/projects/hollywoo/src/hollywoo/Movie.kiss index 84a2a90c..0d1a76ff 100644 --- a/projects/hollywoo/src/hollywoo/Movie.kiss +++ b/projects/hollywoo/src/hollywoo/Movie.kiss @@ -30,6 +30,13 @@ (prop &mut :String sceneKey "") (method _currentScene [] (dictGet scenes sceneKey)) + (prop &mut :Map intercutMap) + (method showDialog [actorName dialogType wryly text cc] + (when intercutMap + (whenLet [sceneForActor (dictGet intercutMap actorName)] + (setScene sceneForActor ->{}))) + (director.showDialog actorName dialogType wryly text cc)) + (defNew [ // "View" in the Model-View-Controller architecture: @@ -90,7 +97,8 @@ ->{ (director.stopWaitForInput) (cc) - })))) + })) + (otherwise (throw "Unsupported delay type $delayHandling")))) (hollywooMethod newSet [name :Set set] (assert isLoading) @@ -148,8 +156,9 @@ (hollywooMethod loopSong [name :Continuation cc &opt :Float volumeMod] (playSong name cc volumeMod true false)) -(hollywooMethod stopSong [] - (director.stopSong)) +(hollywooMethod stopSong [cc] + (director.stopSong) + (cc)) (hollywooMethod newActor [name :Actor actor] (assert isLoading) @@ -161,8 +170,7 @@ (director.showCharacter character (appearanceFlag shownCharacters actorName) - cc) - )) + cc))) (hollywooMethod removeCharacter [actorName :Continuation cc] (let [c (dictGet .characters (_currentScene) actorName)] @@ -183,30 +191,23 @@ (hollywooMethod removeProp [name :Continuation cc] (director.hideProp (dictGet props name) cc)) -// TODO removeProp - // Dialogue: -(prop &mut :Map intercutMap) -(hollywooMethod intercut [:Map actorNamesToSceneNames cc] - (set intercutMap actorNamesToSceneNames)) +(hollywooMethod intercut [:Map actorNamesToSceneNames :Continuation cc] + (set intercutMap actorNamesToSceneNames) + (cc)) -(hollywooMethod endIntercut [cc] - (set intercutMap null)) +(hollywooMethod endIntercut [:Continuation cc] + (set intercutMap null) + (cc)) -(method showDialog [actorName dialogType wryly text cc] - (when intercutMap - (whenLet [sceneForActor (dictGet intercutMap actorName)] - (setScene sceneForActor ->{}))) - (director.showDialog actorName dialogType text cc)) - -(hollywooMethod superText [text cc] +(hollywooMethod superText [text :Continuation cc] (showDialog "" Super "" text cc)) -(hollywooMethod normalSpeech [actorName wryly text cc] +(hollywooMethod normalSpeech [actorName wryly text :Continuation cc] (showDialog actorName (OnScreen (dictGet .characters (_currentScene) actorName)) wryly text cc)) -(hollywooMethod onPhoneSpeech [actorName wryly text cc] +(hollywooMethod onPhoneSpeech [actorName wryly text :Continuation cc] (showDialog actorName (ifLet [charOnScreen (dictGet .characters (_currentScene) actorName)] (OnScreen charOnScreen) (FromPhone (dictGet actors actorName))) wryly text cc)) \ No newline at end of file diff --git a/projects/kiss-vscode/src/ktxt2/KTxt2.kiss b/projects/kiss-vscode/src/ktxt2/KTxt2.kiss index 180f4d71..369f9c9b 100644 --- a/projects/kiss-vscode/src/ktxt2/KTxt2.kiss +++ b/projects/kiss-vscode/src/ktxt2/KTxt2.kiss @@ -82,8 +82,9 @@ (doFor ktxtElement (splitFileElements fileStream) (case ktxtElement ((Block (objectWith source output)) + (set source (applySpecialChars source)) (+= sourceText source) - (dictSet interp.variables "source" (removeSpecialChars source)) + (dictSet interp.variables "source" source) (dictSet interp.variables "sourceLine" ->line (nth (source.split "\n") line)) (dictSet interp.variables "R" re_flex.R) (+= outputText @@ -102,7 +103,7 @@ ((when (and (= sourceType (sourceFile.extension)) (= outputType (outputFile.extension)) - (canConvert (removeSpecialChars source))) + (canConvert (applySpecialChars source))) (objectWith sourceType outputType canConvert name)) (dictSet validMap name c)) (otherwise {}))) @@ -118,7 +119,7 @@ (let [conversions (validConversions conversions "${base}.${sourceExt}" "${base}.${outputExt}" element.source)] (when (= 1 (count conversions)) (let [onlyConversion (first (collect (conversions.iterator)))] - (set element.output (onlyConversion.convert (removeSpecialChars element.source))))))))) + (set element.output (onlyConversion.convert (applySpecialChars element.source))))))))) (toString elements)))) (function :String insertSpecialChars [:String text] @@ -129,10 +130,4 @@ ((text.endsWith "\n") (+ (substr text 0 -1) "↵")) (true - text)))) - -(function :String removeSpecialChars [:String text] - (let [text (text.replace "\r" "")] - (.replace - (.replace text "¶" "\n\n") - "↵" "\n"))) \ No newline at end of file + text)))) \ No newline at end of file diff --git a/projects/kiss-vscode/src/ktxt2/KTxt2EditorProvider.kiss b/projects/kiss-vscode/src/ktxt2/KTxt2EditorProvider.kiss index 77c7756b..b0df54cf 100644 --- a/projects/kiss-vscode/src/ktxt2/KTxt2EditorProvider.kiss +++ b/projects/kiss-vscode/src/ktxt2/KTxt2EditorProvider.kiss @@ -67,7 +67,7 @@ (when (= "Overwrite" overwrite) (withValueOrQuickPickMap chosenConversion conversions (whenLet [converted - (try (chosenConversion.convert (KTxt2.removeSpecialChars source)) + (try (chosenConversion.convert (KTxt2.applySpecialChars source)) (catch [e] (errorMessage "Conversion error: $e") null))] (makeEdit ->edit (edit.replace document.uri (rangeFromStartEnd outputStart outputEnd) converted)))))))