From 4db843897afde20c0586c2a0d6896c4249edbd13 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 27 Sep 2021 22:46:04 -0600 Subject: [PATCH] when refreshing sprite, keep it blue --- .../source/EntrySprite.kiss | 22 +++++++++++-------- .../source/PlayState.kiss | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss b/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss index dd20bfe4..1ceeba0a 100644 --- a/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss +++ b/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss @@ -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))))) \ No newline at end of file + (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) + })) \ No newline at end of file diff --git a/projects/nat-flixel-desktop-playground/source/PlayState.kiss b/projects/nat-flixel-desktop-playground/source/PlayState.kiss index 2d9f09d9..e477c059 100644 --- a/projects/nat-flixel-desktop-playground/source/PlayState.kiss +++ b/projects/nat-flixel-desktop-playground/source/PlayState.kiss @@ -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))))