NAT flixel playground multiple playground views
This commit is contained in:
@@ -3,8 +3,8 @@ package nat;
|
|||||||
import sys.FileSystem;
|
import sys.FileSystem;
|
||||||
import kiss.Prelude;
|
import kiss.Prelude;
|
||||||
import sys.io.File;
|
import sys.io.File;
|
||||||
import tink.Json;
|
|
||||||
import uuid.Uuid;
|
import uuid.Uuid;
|
||||||
|
import haxe.DynamicAccess;
|
||||||
|
|
||||||
using haxe.io.Path;
|
using haxe.io.Path;
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,27 @@
|
|||||||
(FileSystem.createDirectory entryDir)
|
(FileSystem.createDirectory entryDir)
|
||||||
(FileSystem.createDirectory componentDir)
|
(FileSystem.createDirectory componentDir)
|
||||||
(FileSystem.createDirectory filesDir)
|
(FileSystem.createDirectory filesDir)
|
||||||
|
|
||||||
(let [entryFiles (FileSystem.readDirectory entryDir)]
|
(let [entryFiles (FileSystem.readDirectory entryDir)]
|
||||||
(for file entryFiles
|
(for file entryFiles
|
||||||
=>(file.withoutExtension)
|
=>(file.withoutExtension)
|
||||||
(the Entry (Json.parse (File.getContent (joinPath archiveDir "entries" file)))))))])
|
(the Entry (tink.Json.parse (File.getContent (joinPath archiveDir "entries" file)))))))
|
||||||
|
:DynamicAccess<Dynamic> playgrounds
|
||||||
|
(let [playgroundsFile (joinPath archiveDir "playgrounds.json")]
|
||||||
|
(unless (FileSystem.exists playgroundsFile)
|
||||||
|
(File.saveContent playgroundsFile
|
||||||
|
#"{
|
||||||
|
"default": "Playground-MAIN",
|
||||||
|
"Playground-MAIN": {
|
||||||
|
"catsMatch": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#))
|
||||||
|
(haxe.Json.parse (File.getContent playgroundsFile)))])
|
||||||
|
|
||||||
|
(method changePlaygrounds [:Dynamic->Void change]
|
||||||
|
(change playgrounds)
|
||||||
|
(File.saveContent (joinPath archiveDir "playgrounds.json") (haxe.Json.stringify playgrounds "\t")))
|
||||||
|
|
||||||
(method addSystem [:System system]
|
(method addSystem [:System system]
|
||||||
// Assign entries to the Systems that care about them
|
// Assign entries to the Systems that care about them
|
||||||
@@ -47,7 +64,7 @@
|
|||||||
(method _saveEntry [:Entry e]
|
(method _saveEntry [:Entry e]
|
||||||
(File.saveContent
|
(File.saveContent
|
||||||
(joinPath archiveDir "entries" (e.id.withExtension "json"))
|
(joinPath archiveDir "entries" (e.id.withExtension "json"))
|
||||||
(Json.stringify e)))
|
(tink.Json.stringify e)))
|
||||||
|
|
||||||
(method fullString [:Entry e]
|
(method fullString [:Entry e]
|
||||||
(haxe.Json.stringify e null "\t"))
|
(haxe.Json.stringify e null "\t"))
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package nat;
|
|||||||
import kiss.Prelude;
|
import kiss.Prelude;
|
||||||
import kiss.List;
|
import kiss.List;
|
||||||
import haxe.Constraints;
|
import haxe.Constraints;
|
||||||
|
import haxe.DynamicAccess;
|
||||||
import uuid.Uuid;
|
import uuid.Uuid;
|
||||||
import nat.systems.*;
|
import nat.systems.*;
|
||||||
|
|
||||||
@@ -22,6 +23,8 @@ enum CommandArgType {
|
|||||||
Entries(min:Null<Int>, max:Null<Int>);
|
Entries(min:Null<Int>, max:Null<Int>);
|
||||||
// TODO Tag -- make sure a tag input is a valid haxe variable name for tagsMatch compatibility
|
// TODO Tag -- make sure a tag input is a valid haxe variable name for tagsMatch compatibility
|
||||||
// TODO VarTag
|
// TODO VarTag
|
||||||
|
|
||||||
|
// TODO playground name -- choose from archive.playgrounds
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef CommandArg = {
|
typedef CommandArg = {
|
||||||
|
|||||||
@@ -146,6 +146,8 @@
|
|||||||
(method getSelectedEntries []
|
(method getSelectedEntries []
|
||||||
(_selectedEntries.copy))
|
(_selectedEntries.copy))
|
||||||
|
|
||||||
|
(prop &mut :PlaygroundSystem playgroundSystem null)
|
||||||
|
|
||||||
(defNew [&prop :Archive archive
|
(defNew [&prop :Archive archive
|
||||||
&prop :ArchiveUI ui]
|
&prop :ArchiveUI ui]
|
||||||
[&mut :Array<Entry> _selectedEntries []
|
[&mut :Array<Entry> _selectedEntries []
|
||||||
@@ -163,14 +165,14 @@
|
|||||||
(archive.addSystem (new KeyShortcutSystem this))
|
(archive.addSystem (new KeyShortcutSystem this))
|
||||||
(archive.addSystem (new DLSystem))
|
(archive.addSystem (new DLSystem))
|
||||||
(whenLet [ps (ui.playgroundSystem)]
|
(whenLet [ps (ui.playgroundSystem)]
|
||||||
|
(set playgroundSystem ps)
|
||||||
(archive.addSystem ps)
|
(archive.addSystem ps)
|
||||||
// TODO allow saving a different default playground
|
(ps.switchPlaygroundKey (dictGet archive.playgrounds "default")))
|
||||||
(ps.switchPlaygroundKey "Playground-MAIN"))
|
|
||||||
|
|
||||||
// Just for testing:
|
// Just for testing:
|
||||||
// (archive.addSystem (new AttachmentSystem ["jpg" "jpeg" "png"] ->[archive e files] ~files))
|
// (archive.addSystem (new AttachmentSystem ["jpg" "jpeg" "png"] ->[archive e files] ~files))
|
||||||
|
|
||||||
(archive.processSystems)
|
(archive.processSystems ui)
|
||||||
|
|
||||||
(defCommand Help []
|
(defCommand Help []
|
||||||
(ui.displayMessage
|
(ui.displayMessage
|
||||||
@@ -261,4 +263,12 @@
|
|||||||
(withWritableComponents archive e [scaleComponent Scale]
|
(withWritableComponents archive e [scaleComponent Scale]
|
||||||
(set scaleComponent scale))
|
(set scaleComponent scale))
|
||||||
(addComponent archive e Scale scale)))
|
(addComponent archive e Scale scale)))
|
||||||
entries))
|
entries)
|
||||||
|
|
||||||
|
(defCommand CreatePlayground [name (Text null) catsMatchExp (Text null)]
|
||||||
|
(archive.changePlaygrounds ->:Void [:DynamicAccess<Dynamic> p]
|
||||||
|
(dictSet p name (object catsMatch catsMatchExp))))
|
||||||
|
|
||||||
|
(defCommand SwitchPlayground [name (Text null)]
|
||||||
|
(archive.changePlaygrounds ->:Void [:DynamicAccess<Dynamic> p] (dictSet p "default" name))
|
||||||
|
(when playgroundSystem (playgroundSystem.switchPlaygroundKey name))))
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
// Changes to the object returned by (readComponent) will not be saved! Use (withWritableComponents) for making changes
|
// Changes to the object returned by (readComponent) will not be saved! Use (withWritableComponents) for making changes
|
||||||
(defMacro readComponent [e componentType]
|
(defMacro readComponent [e componentType]
|
||||||
`(let [componentData (dictGet (the Map<String,String> .components ,e) ,(symbolName componentType))]
|
`(let [componentData (dictGet (the Map<String,String> .components ,e) ,(symbolName componentType))]
|
||||||
(log null (+ "reading " componentData " as " ,(symbolName componentType) " for " .id ,e))
|
// (log null (+ "reading " componentData " as " ,(symbolName componentType) " for " .id ,e))
|
||||||
(the nat.components ,componentType
|
(the nat.components ,componentType
|
||||||
// TODO add to the documentation a hint that macros should use fully qualified type paths so macro caller classes don't need to import everything
|
// TODO add to the documentation a hint that macros should use fully qualified type paths so macro caller classes don't need to import everything
|
||||||
(tink.Json.parse componentData))))
|
(tink.Json.parse componentData))))
|
||||||
|
|||||||
@@ -16,5 +16,3 @@
|
|||||||
(when (entries.exists e.id)
|
(when (entries.exists e.id)
|
||||||
(entries.remove e.id)
|
(entries.remove e.id)
|
||||||
(when onRemoveEntry (onRemoveEntry archive e)))))
|
(when onRemoveEntry (onRemoveEntry archive e)))))
|
||||||
|
|
||||||
// TODO systems may need access to an ArchiveController
|
|
||||||
|
|||||||
@@ -16,9 +16,10 @@
|
|||||||
(addComponent archive e Positions (new Map)))
|
(addComponent archive e Positions (new Map)))
|
||||||
(withWritableComponents archive e [positions Positions]
|
(withWritableComponents archive e [positions Positions]
|
||||||
(when !(positions.exists _playgroundKey)
|
(when !(positions.exists _playgroundKey)
|
||||||
// TODO do a playground check before giving a default position.
|
(if (catsMatch e .catsMatch (dictGet archive.playgrounds _playgroundKey))
|
||||||
(dictSet positions _playgroundKey (defaultPosition e))))
|
(dictSet positions _playgroundKey (defaultPosition e))
|
||||||
(let [pos (dictGet (readComponent e Positions) _playgroundKey)]
|
(return null))))
|
||||||
|
(whenLet [pos (dictGet (readComponent e Positions) _playgroundKey)]
|
||||||
(processor archive e pos ui))
|
(processor archive e pos ui))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
(set _playgroundKey key)
|
(set _playgroundKey key)
|
||||||
(process ui.controller.archive ui))
|
(process ui.controller.archive ui))
|
||||||
|
|
||||||
(method clear [])
|
(method :Void clear [])
|
||||||
|
|
||||||
(method &override :Void process [:Archive archive &opt :ArchiveUI ui]
|
(method &override :Void process [:Archive archive &opt :ArchiveUI ui]
|
||||||
(when _playgroundKey (super.process archive ui)))
|
(when _playgroundKey (super.process archive ui)))
|
||||||
|
|||||||
Reference in New Issue
Block a user