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

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