From 4413114218660844423c6dfdf558539f62aca1e9 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 28 Jun 2022 17:09:34 +0000 Subject: [PATCH] nat playground buggy z sorting --- .../source/EntrySprite.kiss | 3 ++- .../source/EntrySpriteSystem.kiss | 2 +- .../source/PlayState.kiss | 23 +++++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss b/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss index 7f517bd7..7bbc10de 100644 --- a/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss +++ b/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss @@ -43,7 +43,8 @@ (method savePos [] (FlxG.camera.extendScrollBounds this PlayState.SCROLL_BOUND_MARGIN) (withWritableComponents archive e [positions Positions] - (dictSet positions positionKey (object x (cast this.x Float) y (cast this.y Float) z 0.0)))) + (let [pos (dictGet positions positionKey)] + (dictSet positions positionKey (object x (cast this.x Float) y (cast this.y Float) z pos.z))))) (method &override :Void update [:Float elapsed] (super.update elapsed) diff --git a/projects/nat-flixel-desktop-playground/source/EntrySpriteSystem.kiss b/projects/nat-flixel-desktop-playground/source/EntrySpriteSystem.kiss index 12ba1531..5393b46a 100644 --- a/projects/nat-flixel-desktop-playground/source/EntrySpriteSystem.kiss +++ b/projects/nat-flixel-desktop-playground/source/EntrySpriteSystem.kiss @@ -3,7 +3,7 @@ (prop :Map sprites (new Map)) (defNew [:String tagFilterString - :String positionKey + &prop :String positionKey :PlayState playState &prop :ArchiveController controller] (super diff --git a/projects/nat-flixel-desktop-playground/source/PlayState.kiss b/projects/nat-flixel-desktop-playground/source/PlayState.kiss index 67d7d08a..06b7038a 100644 --- a/projects/nat-flixel-desktop-playground/source/PlayState.kiss +++ b/projects/nat-flixel-desktop-playground/source/PlayState.kiss @@ -7,6 +7,8 @@ (FlxG.plugins.add (new FlxMouseControl)) (set FlxG.sound.muteKeys null) + (set FlxG.sound.volumeDownKeys null) + (set FlxG.sound.volumeUpKeys null) // TODO find a better way to pass the archiveDir to a HaxeFlixel game (let [archiveDir @@ -95,12 +97,19 @@ (prop &mut :EntrySpriteSystem spriteSystem) (set spriteSystem (new EntrySpriteSystem "!done" "Playground-MAIN" this controller)) (archive.addSystem spriteSystem) + + (prop &mut :EntrySpriteDepthSystem spriteDepthSystem) + (set spriteDepthSystem (new EntrySpriteDepthSystem this spriteSystem)) + (archive.addSystem spriteDepthSystem) + (archive.processSystems this) (FlxG.camera.calculateScrollBounds entryGroup SCROLL_BOUND_MARGIN)) (method &override :Void update [:Float elapsed] (super.update elapsed) + (spriteDepthSystem.process archive) + (when FlxG.keys.justPressed.ESCAPE (Sys.exit 0)) @@ -133,6 +142,15 @@ (FlxG.camera.updateScrollWheelZoom elapsed 1) + // +/- keys to change an entry's z + (doFor e (controller.getSelectedEntries) + (when FlxG.keys.justPressed.MINUS + (withWritableComponents archive e [positions Positions] + (-= .z (dictGet positions spriteSystem.positionKey) 1))) + (when FlxG.keys.justPressed.PLUS + (withWritableComponents archive e [positions Positions] + (+= .z (dictGet positions spriteSystem.positionKey) 1)))) + // don't move the ui camera before ui has been placed -- new UI elements could appear offscreen (when (> uiGroup.length 0) (unless (and textInput textInput.hasFocus) @@ -214,14 +232,15 @@ (var SCROLL_BOUND_MARGIN 200) (method handleChanges [:Archive archive :ChangeSet changeSet] - (doFor e changeSet + (when changeSet // 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) + (FlxG.camera.calculateScrollBounds entryGroup SCROLL_BOUND_MARGIN)) + (doFor e changeSet // Entries whose data changed to remove them from the sprite pool will already have been removed // by refreshEntry() (when (spriteSystem.entries.exists e.id)