From b7d883479c03873c021a0d9eea3bc5b8ccc188a0 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 3 Apr 2023 07:58:26 -0600 Subject: [PATCH] Move shortcut labels and skip to shortcutHandler --- .../hollywoo_flixel/HollywooFlixelDSL.kiss | 24 +------------ projects/hollywoo/src/hollywoo/Director.hx | 2 ++ projects/hollywoo/src/hollywoo/Movie.kiss | 34 +++++++++++++++++-- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/HollywooFlixelDSL.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/HollywooFlixelDSL.kiss index 489416de..93a6460c 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/HollywooFlixelDSL.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/HollywooFlixelDSL.kiss @@ -39,29 +39,7 @@ `(new FlxSprite 0 0 ,(b.field (symbolNameValue asset) (b.symbol "AssetPaths")))) (method :Void update [:Float elapsed] - (.update (cast (director.shortcutHandler) kiss_tools.FlxKeyShortcutHandler)) - **(#when debug - (when FlxG.keys.justPressed.N - (skipToNextLabel)) - (when FlxG.keys.justPressed.L - (showLabelSkipButtons)))) - -(method :Void showLabelSkipButtons [] - (let [runners (labelRunners)] - (localVar &mut buttonY 0) - (localVar buttonsPerColumn 25) - (kiss_flixel.SimpleWindow.promptForChoice - "Skip to scene?" - (sort (collect (runners.keys))) - ->label ((dictGet runners label)) - FlxColor.BLACK - FlxColor.WHITE - 0.8 - 0.8 - true - "escape" - "left" - "right"))) + (.update (cast (director.shortcutHandler) kiss_tools.FlxKeyShortcutHandler))) (defAlias &ident flxDirector (cast director FlxDirector)) diff --git a/projects/hollywoo/src/hollywoo/Director.hx b/projects/hollywoo/src/hollywoo/Director.hx index 7110b06d..fe9134c9 100644 --- a/projects/hollywoo/src/hollywoo/Director.hx +++ b/projects/hollywoo/src/hollywoo/Director.hx @@ -35,6 +35,8 @@ interface Director, Actor, Sound, Song, Prop, VoiceTrack, Cam function resume():Void; function showPauseMenu(resume:Continuation):Void; + function chooseString(prompt:String, choices:Array, submit:String->Void):Void; + function defineLightSource(submit:LightSource->Void):Void; function showSet(set:Set, time:SceneTime, perspective:ScenePerspective, appearance:Appearance, camera:Camera, cc:Continuation):Void; diff --git a/projects/hollywoo/src/hollywoo/Movie.kiss b/projects/hollywoo/src/hollywoo/Movie.kiss index 2690712e..b379fdbb 100644 --- a/projects/hollywoo/src/hollywoo/Movie.kiss +++ b/projects/hollywoo/src/hollywoo/Movie.kiss @@ -140,6 +140,19 @@ (director.showProp p.prop p.position cc) cc)))))) + (prop &mut :Bool paused false) + + (method pause [] + (unless paused + // TODO pause all delays (which will require ditching haxe.Timer!!!) + (set paused true) + (director.pause))) + + (method resume [] + (when paused + (set paused false) + (director.resume))) + (method resolvePosition [:Dynamic position] (typeCase [position] ([:String positionKey] @@ -173,11 +186,12 @@ (voiceLines.loadMatches voiceLinesJson)) (let [shortcutHandler (director.shortcutHandler) - cc ->(director.resume)] + cc ->(resume)] (set shortcutHandler.onSelectItem ->process { - // TODO pause all delays (which will require ditching haxe.Timer!!!) - (director.pause) + (pause) + // TODO this is dicey but it allows processes to use the handler: + (shortcutHandler.start) (process cc) }) (shortcutHandler.registerItem "{escape} Pause the movie" @@ -193,6 +207,20 @@ (director.showLighting .time (_currentScene) arr.elements .camera (_currentScene)) (cc)) })) + + (shortcutHandler.registerItem "[n]ext label" + ->cc + (skipToNextLabel)) + (shortcutHandler.registerItem "skip to [l]abel" + ->cc + (let [runners (labelRunners)] + (localVar &mut buttonY 0) + (localVar buttonsPerColumn 25) + (director.chooseString + "Skip to scene?" + (sort (collect (runners.keys))) + ->label ((dictGet runners label))))) + (shortcutHandler.start)) (super)))