fix NAT flixel cpp bug

This commit is contained in:
2022-09-08 20:46:45 +00:00
parent 74a7a41cae
commit 9ab8bdb96d

View File

@@ -19,24 +19,25 @@
// Also, remove text image files -- now that text sprites
// are generated on the fly.
(function :Bool upgradeToVersion2 [:nat.Archive archive :nat.Entry e]
(when (hasComponent e Images)
(let [images1 (readComponent e Images)
scale (readComponentOr e Scale 1.0)
pIdx images1.pinnedImageIndex
textImageFiles (filter images1.imageFiles ->[:String f] (f.startsWith "textImage"))]
(removeComponent archive e Images)
(removeFiles archive e textImageFiles)
(doFor f textImageFiles (images1.imageFiles.remove f))
// If all images were removed (the entry only had a text image), don't add Images2
(unless images1.imageFiles (return true))
(if (hasComponent e Images)
(let [images1 (readComponent e Images)
scale (readComponentOr e Scale 1.0)
pIdx images1.pinnedImageIndex
textImageFiles (filter images1.imageFiles ->[:String f] (f.startsWith "textImage"))]
(removeComponent archive e Images)
(removeFiles archive e textImageFiles)
(doFor f textImageFiles (images1.imageFiles.remove f))
// If all images were removed (the entry only had a text image), don't add Images2
(unless images1.imageFiles (return true))
(addComponent archive e Images2
(object
imageFiles images1.imageFiles
imageScales (cast (concat
(for _ (range pIdx) 1.0)
[scale]
(for _ (range (- images1.imageFiles.length 1 pIdx)) 1.0)))
pinnedImageIndex pIdx))
(removeComponent archive e Scale)
true)))
(addComponent archive e Images2
(object
imageFiles images1.imageFiles
imageScales (cast (concat
(for _ (range pIdx) 1.0)
[scale]
(for _ (range (- images1.imageFiles.length 1 pIdx)) 1.0)))
pinnedImageIndex pIdx))
(removeComponent archive e Scale)
true)
false))