Move shortcut labels and skip to shortcutHandler

This commit is contained in:
2023-04-03 07:58:26 -06:00
parent 78afdf94d7
commit b7d883479c
3 changed files with 34 additions and 26 deletions

View File

@@ -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<Dynamic>))
**(#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<Dynamic>)))
(defAlias &ident flxDirector (cast director FlxDirector))

View File

@@ -35,6 +35,8 @@ interface Director<Set:Cloneable<Set>, Actor, Sound, Song, Prop, VoiceTrack, Cam
function resume():Void;
function showPauseMenu(resume:Continuation):Void;
function chooseString(prompt:String, choices:Array<String>, 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;

View File

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