buggy label/skip system for hollywooFlixel

This commit is contained in:
2021-12-14 20:48:53 -07:00
parent 8f86feaffe
commit 796e69cf45
7 changed files with 42 additions and 6 deletions

View File

@@ -22,6 +22,7 @@ class AsyncEmbeddedScript {
private var instructions:Array<AsyncCommand> = null;
private var breakPoints:Map<Int, () -> Bool> = [];
private var onBreak:AsyncCommand = null;
public var lastInstructionPointer = 0;
public function setBreakHandler(handler:AsyncCommand) {
onBreak = handler;
@@ -136,6 +137,7 @@ class AsyncEmbeddedScript {
}
],
expr: macro {
lastInstructionPointer = instructionPointer;
if (instructions == null)
resetInstructions();
if (withBreakPoints && breakPoints.exists(instructionPointer) && breakPoints[instructionPointer]()) {

View File

@@ -18,6 +18,7 @@
(currentState.close))
// TODO on the first appearance, give a super (for some scenes but probably not others... hm....)
(set currentState (cast scene SceneFlxState))
(set currentState.parent FlxG.state)
(FlxG.state.openSubState currentState)
(cc))

View File

@@ -20,4 +20,15 @@
(method newFlxProp [name path]
(let [propSprite (new FlxSprite 0 0)]
(propSprite.loadGraphic path)
(newProp name propSprite)))
(newProp name propSprite)))
(method :Void update [:Float elapsed]
// TODO CCs queued to timers will still be called
(#when debug
(when FlxG.keys.justPressed.N
(doFor [idx label] (enumerate labels)
(when (> label lastInstructionPointer)
(doFor =>labelName labelIdx labelsByName
(when (= labelIdx label) (trace "SKIPPING TO $labelName")))
(runInstruction label)
(break))))))

View File

@@ -1,6 +1,7 @@
package hollywoo_flixel;
import flixel.FlxState;
import kiss.Prelude;
@:build(kiss.Kiss.build())
class MovieFlxState extends FlxState {}

View File

@@ -3,6 +3,7 @@ package hollywoo_flixel;
import kiss.Prelude;
import kiss.List;
import flixel.FlxSubState;
import flixel.FlxState;
import flixel.FlxSprite;
import flixel.FlxG;
import hollywoo.Scene;

View File

@@ -1,5 +1,6 @@
(defNew [&prop :FlxSprite setSprite &prop :SceneTime time &prop :ScenePerspective perspective]
[
&mut :FlxState parent null
:Map<String,Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite>> characters (new Map)
:Map<FlxSprite,FlxScreenPosition> propsOnScreen (new Map)
]
@@ -15,4 +16,6 @@
(setSprite.screenCenter))
(method &override :Void update [:Float elapsed]
(when parent
(parent.update elapsed))
(super.update elapsed))

View File

@@ -3,11 +3,28 @@
// This allows assets to be declared in Hollywoo files where they first appear, but still loaded before execution starts.
(collectBlocks preload (cc))
(prop :Map<String,Int> labelsByName (new Map))
(prop :Array<Int> labels [])
(defMacroVar _labelNames [])
(defMacroVar _labelLines [])
(defReaderMacro "LABEL " [stream]
(_labelNames.push (stream.expect "label name" ->(stream.takeLine)))
(_labelLines.push (- .line (stream.position) 1))
`(cc))
// TODO could make an &eof style of reader macro, and have (end) read automatically at the end of any Hollywoo file.
(defMacro end []
`(method doPreload [:Void->Void cc]
(set isLoading true)
(collectedBlocks preload)
(set isLoading false)
(cc)))
(let [labelSetters
(for [label idx] (zipThrow _labelNames _labelLines)
`{
(dictSet labelsByName ,label ,idx)
(labels.push ,idx)
})]
`(method doPreload [:Void->Void cc]
(set isLoading true)
(collectedBlocks preload)
(set isLoading false)
,@labelSetters
(cc))))
// TODO also &bof could call (doPreload)