fix C++ type error for playground

This commit is contained in:
2021-09-18 18:33:44 -06:00
parent 65323a3d96
commit 1e44f1db11
4 changed files with 32 additions and 12 deletions

View File

@@ -29,8 +29,10 @@
(refreshEntry e) (refreshEntry e)
e)) e))
// After modifying an entry, this must be called. If you are writing in a createEntry initializer or a system's processEntry function, this will happen automatically. // After modifying an entry, this must be called. If you are writing in a createEntry
// Otherwise, you can guarantee it happens automatically by using the (withWritableEntry) macro in Lib.kiss // initializer or a system's processEntry function, this will happen automatically.
// Otherwise, you can guarantee it happens automatically by using the (withWritableEntry)
// and (withWritableComponents) macros in Lib.kiss
(method refreshEntry [:Entry e] (method refreshEntry [:Entry e]
(_saveEntry e) (_saveEntry e)
(doFor system systems (doFor system systems

View File

@@ -9,9 +9,13 @@
&prop :EntryProcessor processEntry] &prop :EntryProcessor processEntry]
[]) [])
(prop &mut :Null<EntryProcessor> onRemoveEntry)
(method :Void checkEntryInOrOut [:Archive archive :Entry e] (method :Void checkEntryInOrOut [:Archive archive :Entry e]
(if (canProcessEntry archive e) (if (canProcessEntry archive e)
(dictSet entries e.id e) (dictSet entries e.id e)
(entries.remove e.id))) (when (entries.exists e.id)
(entries.remove e.id)
(when onRemoveEntry (onRemoveEntry archive e)))))
// TODO systems may need access to a UI // TODO systems may need access to a UI

View File

@@ -1,9 +1,11 @@
(loadFrom "nat-archive-tool" "src/nat/Lib.kiss") (loadFrom "nat-archive-tool" "src/nat/Lib.kiss")
(prop :Map<String,EntrySprite> sprites (new Map))
(defNew [:String tagFilterString :String positionKey :PlayState playState] (defNew [:String tagFilterString :String positionKey :PlayState playState]
(super (super
->[archive e] ->[archive e]
(and (tagsMatch archive e tagFilterString) (hasComponent e Images)) ?(and (tagsMatch archive e tagFilterString) (hasComponent e Images))
->[archive e] ->[archive e]
{ {
(when !(hasComponent e Positions) (when !(hasComponent e Positions)
@@ -12,5 +14,14 @@
(withWritableComponents archive e [positions Positions] (withWritableComponents archive e [positions Positions]
(when !(positions.exists positionKey) (when !(positions.exists positionKey)
(dictSet positions positionKey (object x 0.0 y 0.0 z 0.0)))) (dictSet positions positionKey (object x 0.0 y 0.0 z 0.0))))
(playState.entryGroup.add (new EntrySprite positionKey archive e)) (let [sprite (new EntrySprite positionKey archive e)]
(playState.entryGroup.add sprite)
(dictSet sprites e.id sprite))
})
(set onRemoveEntry
->[archive e]
{
(.kill (dictGet sprites e.id))
(sprites.remove e.id)
})) }))

View File

@@ -38,11 +38,10 @@
// TODO allow configuring the tags at runtime and erasing/re-creating sprites later // TODO allow configuring the tags at runtime and erasing/re-creating sprites later
// TODO allow using other position keys and erasing/re-creating sprites later // TODO allow using other position keys and erasing/re-creating sprites later
(let [entrySpriteSystem (new EntrySpriteSystem "!done" "Playground-MAIN" this)] (prop &mut :EntrySpriteSystem spriteSystem)
(archive.addSystem entrySpriteSystem) (set spriteSystem (new EntrySpriteSystem "!done" "Playground-MAIN" this))
(entrySpriteSystem.process archive)) (archive.addSystem spriteSystem)
(spriteSystem.process archive))
)
(method &override :Void update [:Float elapsed] (method &override :Void update [:Float elapsed]
(super.update elapsed) (super.update elapsed)
@@ -153,9 +152,13 @@
(method handleChanges [:Archive archive :ChangeSet changeSet] (method handleChanges [:Archive archive :ChangeSet changeSet]
// TODO refresh the sprites/other UI elements for entries that changed data
(doFor e changeSet (doFor e changeSet
(print (archive.fullString e)))) // 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)
(spriteSystem.onRemoveEntry e)
(spriteSystem.processEntry e))))
(prop &mut :Int uiY 0) (prop &mut :Int uiY 0)