diff --git a/projects/nat-archive-tool/src/nat/ArchiveController.kiss b/projects/nat-archive-tool/src/nat/ArchiveController.kiss index 86e4bcdb..864175a2 100644 --- a/projects/nat-archive-tool/src/nat/ArchiveController.kiss +++ b/projects/nat-archive-tool/src/nat/ArchiveController.kiss @@ -336,8 +336,11 @@ (archive.changePlaygrounds ->:Void [:DynamicAccess p] (dictSet p "default" name)) (when playgroundSystem (playgroundSystem.switchPlaygroundKey name))) - (defCommand RemoveFromPlayground [entries (SelectedEntries 1 null)] + (defCommand AddConnections [entries (SelectedEntries 1 null) entriesToConnect (Entries 1 null)] (for e entries - (when (hasComponent e Positions) - (withWritableComponents archive e [positions Positions] - (positions.remove (dictGet archive.playgrounds "default")))) e))) + (addConnections archive e entriesToConnect))) + + (defCommand RemoveConnections [entries (SelectedEntries 1 null) entriesToRemove (Entries 1 null)] + (for e entries + (addConnections archive e entriesToRemove))) + ) diff --git a/projects/nat-archive-tool/src/nat/Lib.kiss b/projects/nat-archive-tool/src/nat/Lib.kiss index 8755969c..6a892b97 100644 --- a/projects/nat-archive-tool/src/nat/Lib.kiss +++ b/projects/nat-archive-tool/src/nat/Lib.kiss @@ -130,4 +130,15 @@ (nth i2.imageScales i2.pinnedImageIndex)) (if (hasComponent e Scale) (readComponent e Scale) - 1.0))) \ No newline at end of file + 1.0))) + +(function addConnections [:nat.Archive archive :nat.Entry e :Array entriesToConnect] + (if (hasComponent e Connections) + (withWritableComponents archive e [conn Connections] + (doFor e2 entriesToConnect (dictSet conn e2.id 1))) + (addComponent archive e Connections (for e2 entriesToConnect =>e2.id 1)))) + +(function removeConnections [:nat.Archive archive :nat.Entry e :Array entriesToRemove] + (when (hasComponent e Connections) + (withWritableComponents archive e [conn Connections] + (doFor e2 entriesToRemove (conn.remove e2.id))))) diff --git a/projects/nat-archive-tool/src/nat/components/Connections.hx b/projects/nat-archive-tool/src/nat/components/Connections.hx new file mode 100644 index 00000000..7490a8bf --- /dev/null +++ b/projects/nat-archive-tool/src/nat/components/Connections.hx @@ -0,0 +1,3 @@ +package nat.components; + +typedef Connections = Map; diff --git a/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss b/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss index 168228a9..d5bdc27c 100644 --- a/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss +++ b/projects/nat-flixel-desktop-playground/source/EntrySprite.kiss @@ -9,6 +9,8 @@ [&mut :Bool selected false &mut :Bool isCircle false] (super position.x position.y) + (enableMouseClicks false) + (set mousePressedCallback ->:Void [_ _ _] null) (cond ((hasComponent e Images2) (let [images (readComponent e Images2)] diff --git a/projects/nat-flixel-desktop-playground/source/PlayState.kiss b/projects/nat-flixel-desktop-playground/source/PlayState.kiss index b7cec32a..12eb8b61 100644 --- a/projects/nat-flixel-desktop-playground/source/PlayState.kiss +++ b/projects/nat-flixel-desktop-playground/source/PlayState.kiss @@ -240,12 +240,19 @@ Math.POSITIVE_INFINITY)) (method :Void chooseEntry [prompt :Archive archive resolve] - (resolve null)) + (entryGroup.forEach ->s + (set s.mousePressedCallback ->:Void [s _ _] { + (entryGroup.forEach ->s + (set s.mousePressedCallback ->:Void [_ _ _] null)) + (resolve .e (cast s EntrySprite)) + }))) (method :Void chooseEntries [prompt archive resolve min max] (_chooseEntries prompt archive resolve min max [])) // TODO is it possible to resolve with less than max? +// TODO this version that just delegates to (chooseEntry) should be reusable, which is tricky because ArchiveUI is an interface + // It also needs a way to resolve with less than the maximum, which may be infinity (method :Void _chooseEntries [prompt archive resolve min max :Array collectedEntries] (let [&mut :Void->Void chooseNextEntry null