onSkipEnd, start sound loops and current music

This commit is contained in:
2023-08-31 18:49:39 -06:00
parent ae77c427c2
commit 9a96fbf429
4 changed files with 65 additions and 45 deletions

View File

@@ -1,4 +1,4 @@
# @install: lix --silent download "gh://github.com/kiss-lang/kiss-tools#483e858ab91e148f030a2e2fcfedee29f3f4fc76" into kiss-tools/0.0.0/github/483e858ab91e148f030a2e2fcfedee29f3f4fc76 # @install: lix --silent download "gh://github.com/kiss-lang/kiss-tools#aa2b792118f223d75fb0ce926826ad2b00fd07e0" into kiss-tools/0.0.0/github/aa2b792118f223d75fb0ce926826ad2b00fd07e0
-lib kiss -lib kiss
-cp ${HAXE_LIBCACHE}/kiss-tools/0.0.0/github/483e858ab91e148f030a2e2fcfedee29f3f4fc76/src/ -cp ${HAXE_LIBCACHE}/kiss-tools/0.0.0/github/aa2b792118f223d75fb0ce926826ad2b00fd07e0/src/
-D kiss-tools=0.0.0 -D kiss-tools=0.0.0

View File

@@ -1,12 +1,12 @@
# @install: lix --silent download "gh://github.com/kiss-lang/kiss#8843ac539a9468e59b432532025ac9a8773db5bf" into kiss/0.0.1/github/8843ac539a9468e59b432532025ac9a8773db5bf # @install: lix --silent download "gh://github.com/kiss-lang/kiss#01801cdf5008f535ca1f871320d69b217fb95477" into kiss/0.0.1/github/01801cdf5008f535ca1f871320d69b217fb95477
# @run: haxelib run-dir kiss "${HAXE_LIBCACHE}/kiss/0.0.1/github/8843ac539a9468e59b432532025ac9a8773db5bf" # @run: haxelib run-dir kiss "${HAXE_LIBCACHE}/kiss/0.0.1/github/01801cdf5008f535ca1f871320d69b217fb95477"
-lib haxe-strings -lib haxe-strings
-lib hscript -lib hscript
-lib tink_json -lib tink_json
-lib tink_macro -lib tink_macro
-lib tink_syntaxhub -lib tink_syntaxhub
-lib uuid -lib uuid
-cp ${HAXE_LIBCACHE}/kiss/0.0.1/github/8843ac539a9468e59b432532025ac9a8773db5bf/src -cp ${HAXE_LIBCACHE}/kiss/0.0.1/github/01801cdf5008f535ca1f871320d69b217fb95477/src
-D kiss=0.0.1 -D kiss=0.0.1
-w -WUnusedPattern -w -WUnusedPattern
--macro kiss.KissFrontend.use() --macro kiss.KissFrontend.use()

View File

@@ -105,6 +105,7 @@
(method doCleanup [] (method doCleanup []
(director.cleanup) (director.cleanup)
(set lastInstructionPointer -2) (set lastInstructionPointer -2)
(set instructions null)
(collectedBlocks cleanup) (collectedBlocks cleanup)
(stagePositions.m.clear) (stagePositions.m.clear)
(lightSources.m.clear) (lightSources.m.clear)

View File

@@ -16,6 +16,9 @@
(prop :Array<HistoryElement<Actor>> dialogHistory []) (prop :Array<HistoryElement<Actor>> dialogHistory [])
(var MAX_DIALOG_HISTORY 50) (var MAX_DIALOG_HISTORY 50)
(prop &mut :String currentSong "")
(prop &mut :Float currentSongVolumeMod 0)
(prop &mut :Bool currentSongLooping false)
// Mostly immutable, reusable resources: // Mostly immutable, reusable resources:
(prop :FuzzyMap<Set> sets (new FuzzyMap<Set>)) (prop :FuzzyMap<Set> sets (new FuzzyMap<Set>))
@@ -98,11 +101,11 @@
(prop &mut :FuzzyMap<String> intercutMap) (prop &mut :FuzzyMap<String> intercutMap)
(prop &mut :Map<String,Int> altIdx (new Map)) (prop &mut :Map<String,Int> altIdx (new Map))
(method :Void processIntercut [actorName :Continuation cc] (method :Void processIntercut [:Bool skipping :String actorName :Continuation cc]
(when intercutMap (when intercutMap
(whenLet [sceneForActor (try (dictGet intercutMap actorName) (catch [e] null))] (whenLet [sceneForActor (try (dictGet intercutMap actorName) (catch [e] null))]
(unless (= sceneForActor sceneKey) (unless (= sceneForActor sceneKey)
(setScene sceneForActor cc) (setScene skipping sceneForActor cc)
(return)))) (return))))
(cc)) (cc))
@@ -123,7 +126,7 @@
(when skipping (when skipping
(cc) (cc)
(return)) (return))
(processIntercut actorName (processIntercut skipping actorName
(makeCC (makeCC
(let [isSilentType (let [isSilentType
?(whenLet [(Custom type _ _) dialogType] ?(whenLet [(Custom type _ _) dialogType]
@@ -510,8 +513,15 @@
:Map<String,Float> sceneMusicVolume (new Map) :Map<String,Float> sceneMusicVolume (new Map)
&mut :String playingSceneMusic null &mut :String playingSceneMusic null
] ]
(super)
(set director.movie this) (set director.movie this)
(set onSkipEnd
->:Void {
(doFor play loopingSoundPlays
(play))
(when currentSong
(playSong false currentSong ->:Void {} currentSongVolumeMod currentSongLooping false))
})
(let [shortcutHandler (director.shortcutHandler) (let [shortcutHandler (director.shortcutHandler)
cc ->(resume)] cc ->(resume)]
@@ -595,9 +605,7 @@
->label { ->label {
(resume) (resume)
((dictGet runners label)) ((dictGet runners label))
}))))) }))))))
(super))
@:keep @:keep
(method :Void _strobe [:Bool skipping :Bool prop :String actorOrPropKey :Float strobeSec :Int times &opt :Continuation cc] (method :Void _strobe [:Bool skipping :Bool prop :String actorOrPropKey :Float strobeSec :Int times &opt :Continuation cc]
@@ -731,19 +739,19 @@
(dictSet sceneMusicVolume scene volumeMod) (dictSet sceneMusicVolume scene volumeMod)
(when cc (cc))) (when cc (cc)))
(hollywooMethod setCurrentSceneSong [:String songKey :Continuation cc &opt :Float volumeMod] (hollywooMethod setCurrentSceneSong [:Bool skipping :String songKey :Continuation cc &opt :Float volumeMod]
(dictSet sceneMusic sceneKey songKey) (dictSet sceneMusic sceneKey songKey)
(dictSet sceneMusicVolume sceneKey volumeMod) (dictSet sceneMusicVolume sceneKey volumeMod)
(cond (cond
((= playingSceneMusic songKey) ((= playingSceneMusic songKey)
(changeSongVolume volumeMod cc)) (changeSongVolume skipping volumeMod cc))
(true (true
(set playingSceneMusic songKey) (set playingSceneMusic songKey)
(stopSong (makeCC null)) (stopSong skipping (makeCC null))
(loopSong songKey (makeCC null) volumeMod) (loopSong skipping songKey (makeCC null) volumeMod)
(cc)))) (cc))))
(hollywooMethod setScene [name :Continuation cc] (hollywooMethod setScene [:Bool skipping :String name :Continuation cc]
(_hideCurrentScene (_hideCurrentScene
(makeCC (makeCC
(let [name (FuzzyMapTools.bestMatch scenes name)] (let [name (FuzzyMapTools.bestMatch scenes name)]
@@ -752,11 +760,11 @@
// Keep the song going if it's the same as current. Otherwise, take over! // Keep the song going if it's the same as current. Otherwise, take over!
(unless (= playingSceneMusic songKey) (unless (= playingSceneMusic songKey)
(set playingSceneMusic songKey) (set playingSceneMusic songKey)
(stopSong (makeCC null)) (stopSong skipping (makeCC null))
(loopSong songKey (makeCC null) (dictGet sceneMusicVolume name))) (loopSong skipping songKey (makeCC null) (dictGet sceneMusicVolume name)))
(when playingSceneMusic (when playingSceneMusic
(set playingSceneMusic null) (set playingSceneMusic null)
(stopSong (makeCC null)))) (stopSong skipping (makeCC null))))
(unless (positionsInScene.exists sceneKey) (unless (positionsInScene.exists sceneKey)
(dictSet positionsInScene sceneKey [])) (dictSet positionsInScene sceneKey []))
(_showScene (_showScene
@@ -765,7 +773,7 @@
.camera (dictGet scenes name) .camera (dictGet scenes name)
cc))))) cc)))))
(hollywooMethod playSound [:Bool skipping name :Continuation cc &opt :Float volumeMod :Bool waitForEnd] (hollywooMethod playSound [:Bool skipping :String name :Continuation cc &opt :Float volumeMod :Bool waitForEnd]
(when skipping (when skipping
(cc) (cc)
(return)) (return))
@@ -787,18 +795,19 @@
(unless waitForEnd (unless waitForEnd
(cc))) (cc)))
(hollywooMethod awaitPlaySound [:Bool skipping name :Continuation cc &opt :Float volumeMod] (hollywooMethod awaitPlaySound [:Bool skipping :String name :Continuation cc &opt :Float volumeMod]
(director.startWaitForInput cc)
(playSound skipping name cc volumeMod true)) (playSound skipping name cc volumeMod true))
(hollywooMethod stopSound [:Bool skipping name :Continuation cc] (hollywooMethod stopSound [:Bool skipping :String name :Continuation cc]
(let [name (FuzzyMapTools.bestMatch sounds name)] (let [name (FuzzyMapTools.bestMatch sounds name)]
(loopingSoundPlays.remove name) (loopingSoundPlays.remove name)
(unless skipping (unless skipping
(director.stopSound (dictGet sounds name)))) (director.stopSound (dictGet sounds name))))
(cc)) (cc))
(hollywooMethod loopSound [:Bool skipping name :Continuation cc &opt :Float volumeMod] (hollywooMethod loopSound [:Bool skipping :String name :Continuation cc &opt :Float volumeMod]
// Even when skipping, create a lambda that plays an iteration of the sound, // Even when skipping, create a lambda that plays an iteration of the sound,
// so if skipping ends and the sound is still supposed to be looping, // so if skipping ends and the sound is still supposed to be looping,
// we can start it! // we can start it!
@@ -806,7 +815,7 @@
(withFunctions (withFunctions
[ [
(:Void playAgain [] (:Void playAgain []
(playSound skipping name (playSound false name
(makeCC (makeCC
(when (loopingSoundPlays.exists name) (when (loopingSoundPlays.exists name)
(playAgain))) (playAgain)))
@@ -818,27 +827,37 @@
(playAgain)))) (playAgain))))
(cc)) (cc))
// This is never skipped because the music might be expected to continue on to the place (hollywooMethod playSong [:Bool skipping :String name :Continuation cc &opt :Float volumeMod :Bool loop :Bool waitForEnd]
// we skip to:
(hollywooMethod playSong [name :Continuation cc &opt :Float volumeMod :Bool loop :Bool waitForEnd]
(set volumeMod (or volumeMod 1)) (set volumeMod (or volumeMod 1))
(assert (<= 0 volumeMod 1)) (assert (<= 0 volumeMod 1))
(director.playSong (dictGet songs name) volumeMod ?loop ?waitForEnd cc)) (set currentSong (FuzzyMapTools.bestMatch songs name))
(set currentSongVolumeMod volumeMod)
(hollywooMethod changeSongVolume [:Float volumeMod :Continuation cc] (set currentSongLooping ?loop)
(director.changeSongVolume volumeMod cc))
(hollywooMethod awaitPlaySong [:Bool skipping name :Continuation cc &opt :Float volumeMod]
(when skipping (when skipping
(cc) (cc)
(return)) (return))
(playSong name cc volumeMod false true)) (director.playSong (dictGet songs currentSong) volumeMod ?loop ?waitForEnd cc))
(hollywooMethod loopSong [name :Continuation cc &opt :Float volumeMod] (hollywooMethod changeSongVolume [:Bool skipping :Float volumeMod :Continuation cc]
(playSong name cc volumeMod true false)) (set currentSongVolumeMod volumeMod)
(when skipping
(cc)
(return))
(director.changeSongVolume volumeMod cc))
(hollywooMethod stopSong [cc] (hollywooMethod awaitPlaySong [:Bool skipping :String name :Continuation cc &opt :Float volumeMod]
(director.stopSong) (when skipping
(cc)
(return))
(playSong skipping name cc volumeMod false true))
(hollywooMethod loopSong [:Bool skipping :String name :Continuation cc &opt :Float volumeMod]
(playSong skipping name cc volumeMod true false))
(hollywooMethod stopSong [:Bool skipping cc]
(set currentSong "")
(unless skipping
(director.stopSong))
(cc)) (cc))
(hollywooMethod autoZProcess [:StagePosition position :Continuation cc] (hollywooMethod autoZProcess [:StagePosition position :Continuation cc]
@@ -977,7 +996,7 @@
// TODO themed superText // TODO themed superText
(hollywooMethod normalSpeech [:Bool skipping actorName wryly text :Continuation cc] (hollywooMethod normalSpeech [:Bool skipping actorName wryly text :Continuation cc]
(processIntercut actorName (processIntercut skipping actorName
(makeCC (makeCC
(showDialog skipping actorName (OnScreen (dictGet .characters (_currentScene) actorName)) wryly text cc)))) (showDialog skipping actorName (OnScreen (dictGet .characters (_currentScene) actorName)) wryly text cc))))
@@ -988,14 +1007,14 @@
(showDialog skipping actorName (VoiceOver (dictGet actors actorName)) wryly text cc)) (showDialog skipping actorName (VoiceOver (dictGet actors actorName)) wryly text cc))
(hollywooMethod onPhoneSpeech [:Bool skipping actorName wryly text :Continuation cc] (hollywooMethod onPhoneSpeech [:Bool skipping actorName wryly text :Continuation cc]
(processIntercut actorName (processIntercut skipping actorName
(makeCC (makeCC
(showDialog skipping actorName (ifLet [charOnScreen (try (dictGet .characters (_currentScene) actorName) (catch [e] null))] (showDialog skipping actorName (ifLet [charOnScreen (try (dictGet .characters (_currentScene) actorName) (catch [e] null))]
(OnScreen charOnScreen) (OnScreen charOnScreen)
(FromPhone (dictGet actors actorName))) wryly text cc)))) (FromPhone (dictGet actors actorName))) wryly text cc))))
(hollywooMethod customSpeech [:Bool skipping type actorName wryly args text :Continuation cc] (hollywooMethod customSpeech [:Bool skipping type actorName wryly args text :Continuation cc]
(processIntercut actorName (processIntercut skipping actorName
(makeCC (makeCC
(showDialog skipping actorName (Custom type (dictGet .characters (_currentScene) actorName) args) wryly text cc)))) (showDialog skipping actorName (Custom type (dictGet .characters (_currentScene) actorName) args) wryly text cc))))
@@ -1103,10 +1122,10 @@
(when skipping (when skipping
(cc) (cc)
(return)) (return))
(playSong songKey (makeCC null) volumeMod) (playSong skipping songKey (makeCC null) volumeMod)
(rollCredits (rollCredits
skipping skipping
creditsTSV creditsTSV
(makeCC (makeCC
(stopSong cc)) (stopSong skipping cc))
(director.getSongLength (dictGet songs songKey)))) (director.getSongLength (dictGet songs songKey))))