when refreshing sprite, keep it blue

This commit is contained in:
2021-09-27 22:46:04 -06:00
parent 26a6be35b9
commit 4db843897a
2 changed files with 14 additions and 10 deletions

View File

@@ -13,6 +13,7 @@
(.onComplete (BitmapData.loadFromFile (joinPath archive.archiveDir "files" (nth images.imageFiles images.pinnedImageIndex)))
->bitmapData {
(loadGraphic bitmapData)
(updateColor)
(when (hasComponent e Scale)
(let [:Float scale (readComponent archive e Scale)]
(this.scale.set scale scale)
@@ -21,20 +22,23 @@
(enableMouseDrag)
}))
// TODO add onEntrySelected(), onEntryDeselected() callback to ArchiveUI and use these to change color if SelectByName or SelectByTags are used on an Entry that has a sprite in the entryspritesystem's dictionary
(set mousePressedCallback
->[self _x _y]
{
(controller.ToggleEntrySelection e)
(set selected !selected)
(if selected
{
(set color FlxColor.BLUE)
}
{
(set color FlxColor.WHITE)
})
(updateColor)
})
(set mouseStopDragCallback
->[self _dx _dy]
(withWritableComponents archive e [positions Positions]
(dictSet positions positionKey (object x (cast this.x Float) y (cast this.y Float) z 0.0)))))
(dictSet positions positionKey (object x (cast this.x Float) y (cast this.y Float) z 0.0)))))
(method updateColor []
(if !(= -1 (controller.selectedEntries.indexOf e))
{
(set color FlxColor.BLUE)
}
{
(set color FlxColor.WHITE)
}))

View File

@@ -167,10 +167,10 @@
(method handleChanges [:Archive archive :ChangeSet changeSet]
(doFor e changeSet
// refresh the sprites for entries that changed data.
// Entries whose data changed to remove them from the sprite pool will already have been removed
// by refreshEntry()
(when (spriteSystem.entries.exists e.id)
// refresh the sprites for entries that changed data but still should have sprites
(when (spriteSystem.sprites.exists e.id)
(spriteSystem.onRemoveEntry archive e))
(spriteSystem.processEntry archive e))))