better (but still broken) removal from playgrounds

This commit is contained in:
2022-07-05 14:55:49 +00:00
parent 4a379e00ba
commit 81ae02a58d
4 changed files with 17 additions and 14 deletions

View File

@@ -328,4 +328,10 @@
(defCommand SwitchPlayground [name (Text null)]
(archive.changePlaygrounds ->:Void [:DynamicAccess<Dynamic> p] (dictSet p "default" name))
(when playgroundSystem (playgroundSystem.switchPlaygroundKey name))))
(when playgroundSystem (playgroundSystem.switchPlaygroundKey name)))
(defCommand RemoveFromPlayground [entries (SelectedEntries 1 null)]
(for e entries
(when (hasComponent e Positions)
(withWritableComponents archive e [positions Positions]
(positions.remove (dictGet archive.playgrounds "default")))) e)))

View File

@@ -5,7 +5,8 @@
(defNew [&prop :ArchiveUI ui
:EntryChecker canProcess
&prop :PlaygroundEntryProcessor processor]
&prop :PlaygroundEntryProcessor processor
:EntryProcessor onRemoveEntry]
(super
->[archive e]
@@ -21,7 +22,8 @@
(return null))))
(whenLet [pos (dictGet (readComponent e Positions) _playgroundKey)]
(processor archive e pos ui))
}))
})
(set this.onRemoveEntry onRemoveEntry))
(method switchPlaygroundKey [key]
(when _playgroundKey

View File

@@ -16,12 +16,11 @@
(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
(dictSet sprites e.id sprite)))
->[archive e &opt ui]
{
(.kill (dictGet sprites e.id))
(playState.entryGroup.remove (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)

View File

@@ -1,9 +1,5 @@
(loadFrom "nat-archive-tool" "src/nat/Lib.kiss")
// TODO handleChanges() will need to kill every changed Entry's sprite and make a new one
// make interactible sprites for entries that have images
(var TEXT_SIZE 16)
(prop &mut :EntrySpriteSystem spriteSystem)
@@ -251,9 +247,7 @@
// process the WikipediaImageSystem and run spriteSystem process on newly created entries that get one
(archive.processSystems this)
// Do a second loop through the systems, so Playground systems that trigger Core systems have their effects processed
(archive.processSystems this)
(FlxG.camera.calculateScrollBounds entryGroup SCROLL_BOUND_MARGIN))
(archive.processSystems this))
(doFor e changeSet
// Entries whose data changed to remove them from the sprite pool will already have been removed
@@ -262,7 +256,9 @@
// 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))))
(spriteSystem.processEntry archive e)))
(FlxG.camera.calculateScrollBounds entryGroup SCROLL_BOUND_MARGIN))
(prop &mut :Int uiY 0)