Files
kiss-vscode/projects/nat-flixel-desktop-playground/source/EntrySpriteSystem.kiss

33 lines
1.2 KiB
Plaintext

(loadFrom "nat-archive-tool" "src/nat/Lib.kiss")
(prop :Map<String,EntrySprite> sprites (new Map))
// TODO this can also handle text sprites, and instead of saving out the text bitmap,
// just make the FlxText every time at runtime -- so PinNextImage won't be needed
// when the media tag is added
(defNew [:PlayState playState
&prop :ArchiveController controller]
(super
playState
->[archive e]
?(hasComponent e Images)
->[archive e pos &opt ui]
(unless (sprites.exists e.id)
(let [sprite (new EntrySprite this _playgroundKey pos archive e controller)]
(playState.entryGroup.add sprite)
(dictSet sprites e.id sprite))))
(set onRemoveEntry
->[archive e &opt ui]
{
(.kill (dictGet sprites e.id))
(sprites.remove e.id)
// When an Entry is hidden, we can bet the user doesn't want it selected anymore
(controller.DeSelectEntry e)
}))
// TODO override process to z-sort all sprites after making them
(method getSelectedSprites []
(filter (for e (controller.getSelectedEntries) (dictGet sprites e.id))))