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
-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

View File

@@ -1,12 +1,12 @@
# @install: lix --silent download "gh://github.com/kiss-lang/kiss#8843ac539a9468e59b432532025ac9a8773db5bf" into kiss/0.0.1/github/8843ac539a9468e59b432532025ac9a8773db5bf
# @run: haxelib run-dir kiss "${HAXE_LIBCACHE}/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/01801cdf5008f535ca1f871320d69b217fb95477"
-lib haxe-strings
-lib hscript
-lib tink_json
-lib tink_macro
-lib tink_syntaxhub
-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
-w -WUnusedPattern
--macro kiss.KissFrontend.use()

View File

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

View File

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