From e890f384d1b17a7d2ba3b7d0f954c2e5578185cf Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sat, 8 Oct 2022 23:02:44 +0000 Subject: [PATCH] color tag systems. Close #152 --- .../src/nat/ArchiveController.kiss | 19 +++++++++++++++++++ .../src/nat/systems/TagSystem.hx | 1 + 2 files changed, 20 insertions(+) diff --git a/projects/nat-archive-tool/src/nat/ArchiveController.kiss b/projects/nat-archive-tool/src/nat/ArchiveController.kiss index 36eee16d..44d3e016 100644 --- a/projects/nat-archive-tool/src/nat/ArchiveController.kiss +++ b/projects/nat-archive-tool/src/nat/ArchiveController.kiss @@ -206,6 +206,25 @@ (archive.addSystem (new KeyShortcutSystem this)) (archive.addSystem (new DLSystem)) (archive.addSystem (new AutoStepperSystem)) + + (localFunction colorEqual [:nat.components.Color c1 :nat.components.Color c2] + (and (= c1.r c2.r) (= c1.g c2.g) (= c1.b c2.b) (= c1.a c2.a))) + (localFunction colorsContain [:Array cs :nat.components.Color c1] + (doFor c2 cs + (when (colorEqual c2 c1) + (return true))) + (return false)) + (localFunction addColorTagSystems [:Map info] + (let [colors (collect (info.iterator))] + (doFor =>tagExp color info + (archive.addSystem (new TagSystem tagExp ->[archive e &opt ui] + (when (or !(hasComponent e Color) (colorsContain colors (readComponent e Color))) + (addComponent archive e Color color))))))) + (addColorTagSystems [ + =>"(or active enabled)" (object r 0 g 1 b 0 a 1) + =>"(or inactive disabled)" (object r 0.5 g 0.5 b 0.5 a 1) + =>"todo" (object r 1 g (/ 165.0 255) b 0 a 1)]) + (whenLet [ps (ui.playgroundSystem)] (set playgroundSystem ps) (archive.addSystem ps) diff --git a/projects/nat-archive-tool/src/nat/systems/TagSystem.hx b/projects/nat-archive-tool/src/nat/systems/TagSystem.hx index 1172233b..4a899339 100644 --- a/projects/nat-archive-tool/src/nat/systems/TagSystem.hx +++ b/projects/nat-archive-tool/src/nat/systems/TagSystem.hx @@ -1,6 +1,7 @@ package nat.systems; import kiss.Prelude; +import nat.System; @:build(kiss.Kiss.build()) class TagSystem extends System {}