buggy label/skip system for hollywooFlixel
This commit is contained in:
@@ -22,6 +22,7 @@ class AsyncEmbeddedScript {
|
|||||||
private var instructions:Array<AsyncCommand> = null;
|
private var instructions:Array<AsyncCommand> = null;
|
||||||
private var breakPoints:Map<Int, () -> Bool> = [];
|
private var breakPoints:Map<Int, () -> Bool> = [];
|
||||||
private var onBreak:AsyncCommand = null;
|
private var onBreak:AsyncCommand = null;
|
||||||
|
public var lastInstructionPointer = 0;
|
||||||
|
|
||||||
public function setBreakHandler(handler:AsyncCommand) {
|
public function setBreakHandler(handler:AsyncCommand) {
|
||||||
onBreak = handler;
|
onBreak = handler;
|
||||||
@@ -136,6 +137,7 @@ class AsyncEmbeddedScript {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
expr: macro {
|
expr: macro {
|
||||||
|
lastInstructionPointer = instructionPointer;
|
||||||
if (instructions == null)
|
if (instructions == null)
|
||||||
resetInstructions();
|
resetInstructions();
|
||||||
if (withBreakPoints && breakPoints.exists(instructionPointer) && breakPoints[instructionPointer]()) {
|
if (withBreakPoints && breakPoints.exists(instructionPointer) && breakPoints[instructionPointer]()) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
(currentState.close))
|
(currentState.close))
|
||||||
// TODO on the first appearance, give a super (for some scenes but probably not others... hm....)
|
// TODO on the first appearance, give a super (for some scenes but probably not others... hm....)
|
||||||
(set currentState (cast scene SceneFlxState))
|
(set currentState (cast scene SceneFlxState))
|
||||||
|
(set currentState.parent FlxG.state)
|
||||||
(FlxG.state.openSubState currentState)
|
(FlxG.state.openSubState currentState)
|
||||||
(cc))
|
(cc))
|
||||||
|
|
||||||
|
|||||||
@@ -21,3 +21,14 @@
|
|||||||
(let [propSprite (new FlxSprite 0 0)]
|
(let [propSprite (new FlxSprite 0 0)]
|
||||||
(propSprite.loadGraphic path)
|
(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))))))
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package hollywoo_flixel;
|
package hollywoo_flixel;
|
||||||
|
|
||||||
import flixel.FlxState;
|
import flixel.FlxState;
|
||||||
|
import kiss.Prelude;
|
||||||
|
|
||||||
@:build(kiss.Kiss.build())
|
@:build(kiss.Kiss.build())
|
||||||
class MovieFlxState extends FlxState {}
|
class MovieFlxState extends FlxState {}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package hollywoo_flixel;
|
|||||||
import kiss.Prelude;
|
import kiss.Prelude;
|
||||||
import kiss.List;
|
import kiss.List;
|
||||||
import flixel.FlxSubState;
|
import flixel.FlxSubState;
|
||||||
|
import flixel.FlxState;
|
||||||
import flixel.FlxSprite;
|
import flixel.FlxSprite;
|
||||||
import flixel.FlxG;
|
import flixel.FlxG;
|
||||||
import hollywoo.Scene;
|
import hollywoo.Scene;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
(defNew [&prop :FlxSprite setSprite &prop :SceneTime time &prop :ScenePerspective perspective]
|
(defNew [&prop :FlxSprite setSprite &prop :SceneTime time &prop :ScenePerspective perspective]
|
||||||
[
|
[
|
||||||
|
&mut :FlxState parent null
|
||||||
:Map<String,Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite>> characters (new Map)
|
:Map<String,Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite>> characters (new Map)
|
||||||
:Map<FlxSprite,FlxScreenPosition> propsOnScreen (new Map)
|
:Map<FlxSprite,FlxScreenPosition> propsOnScreen (new Map)
|
||||||
]
|
]
|
||||||
@@ -15,4 +16,6 @@
|
|||||||
(setSprite.screenCenter))
|
(setSprite.screenCenter))
|
||||||
|
|
||||||
(method &override :Void update [:Float elapsed]
|
(method &override :Void update [:Float elapsed]
|
||||||
|
(when parent
|
||||||
|
(parent.update elapsed))
|
||||||
(super.update elapsed))
|
(super.update elapsed))
|
||||||
@@ -3,11 +3,28 @@
|
|||||||
// This allows assets to be declared in Hollywoo files where they first appear, but still loaded before execution starts.
|
// This allows assets to be declared in Hollywoo files where they first appear, but still loaded before execution starts.
|
||||||
(collectBlocks preload (cc))
|
(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.
|
// TODO could make an &eof style of reader macro, and have (end) read automatically at the end of any Hollywoo file.
|
||||||
(defMacro end []
|
(defMacro end []
|
||||||
`(method doPreload [:Void->Void cc]
|
(let [labelSetters
|
||||||
(set isLoading true)
|
(for [label idx] (zipThrow _labelNames _labelLines)
|
||||||
(collectedBlocks preload)
|
`{
|
||||||
(set isLoading false)
|
(dictSet labelsByName ,label ,idx)
|
||||||
(cc)))
|
(labels.push ,idx)
|
||||||
|
})]
|
||||||
|
`(method doPreload [:Void->Void cc]
|
||||||
|
(set isLoading true)
|
||||||
|
(collectedBlocks preload)
|
||||||
|
(set isLoading false)
|
||||||
|
,@labelSetters
|
||||||
|
(cc))))
|
||||||
// TODO also &bof could call (doPreload)
|
// TODO also &bof could call (doPreload)
|
||||||
|
|||||||
Reference in New Issue
Block a user