generalize EntrySpriteSystem into PlaygroundSystem which all ui will provide
This commit is contained in:
@@ -162,6 +162,10 @@
|
|||||||
(archive.addSystem (new ImageAttachmentSystem))
|
(archive.addSystem (new ImageAttachmentSystem))
|
||||||
(archive.addSystem (new KeyShortcutSystem this))
|
(archive.addSystem (new KeyShortcutSystem this))
|
||||||
(archive.addSystem (new DLSystem))
|
(archive.addSystem (new DLSystem))
|
||||||
|
(whenLet [ps (ui.playgroundSystem)]
|
||||||
|
(archive.addSystem ps)
|
||||||
|
// TODO allow saving a different default playground
|
||||||
|
(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))
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package nat;
|
|||||||
import nat.Entry;
|
import nat.Entry;
|
||||||
import nat.ArchiveController;
|
import nat.ArchiveController;
|
||||||
import kiss_tools.KeyShortcutHandler;
|
import kiss_tools.KeyShortcutHandler;
|
||||||
|
import nat.systems.PlaygroundSystem;
|
||||||
|
|
||||||
interface ArchiveUI {
|
interface ArchiveUI {
|
||||||
/**
|
/**
|
||||||
@@ -15,6 +16,11 @@ interface ArchiveUI {
|
|||||||
*/
|
*/
|
||||||
var shortcutHandler(default, null):Null<KeyShortcutHandler<Entry>>;
|
var shortcutHandler(default, null):Null<KeyShortcutHandler<Entry>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A PlaygroundSystem that will display interactible entry representations
|
||||||
|
*/
|
||||||
|
function playgroundSystem():Null<PlaygroundSystem>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompt the user to enter text
|
* Prompt the user to enter text
|
||||||
*/
|
*/
|
||||||
|
|||||||
3
src/nat/components/Position.hx
Normal file
3
src/nat/components/Position.hx
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
package nat.components;
|
||||||
|
|
||||||
|
typedef Position = {x:Float, y:Float, z:Float};
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package nat.components;
|
package nat.components;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entries can have multiple positions in different UIs/folders/whatever.
|
* Entries can have multiple positions in different UIs/folders/whatever.
|
||||||
*/
|
*/
|
||||||
typedef Positions = Map<String, {x:Float, y:Float, z:Float}>;
|
typedef Positions = Map<String, Position>;
|
||||||
|
|||||||
15
src/nat/systems/PlaygroundSystem.hx
Normal file
15
src/nat/systems/PlaygroundSystem.hx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package nat.systems;
|
||||||
|
|
||||||
|
import kiss.Prelude;
|
||||||
|
import kiss.List;
|
||||||
|
import nat.System;
|
||||||
|
import nat.components.Position;
|
||||||
|
|
||||||
|
typedef PlaygroundEntryProcessor = (Archive, Entry, Position, ?ArchiveUI) -> Dynamic; // Whatever value is returned will be dropped, but this is easier than requiring ->:Void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for Systems that process Entries in a playground view and displays them in an interactive form
|
||||||
|
* (EntrySpriteSystem, for example)
|
||||||
|
*/
|
||||||
|
@:build(kiss.Kiss.build())
|
||||||
|
class PlaygroundSystem extends System {}
|
||||||
37
src/nat/systems/PlaygroundSystem.kiss
Normal file
37
src/nat/systems/PlaygroundSystem.kiss
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
(load "../Lib.kiss")
|
||||||
|
|
||||||
|
(prop &mut :String _playgroundKey "")
|
||||||
|
(method :String getPlaygroundKey [] _playgroundKey)
|
||||||
|
|
||||||
|
(defNew [&prop :ArchiveUI ui
|
||||||
|
:EntryChecker canProcess
|
||||||
|
&prop :PlaygroundEntryProcessor processor]
|
||||||
|
|
||||||
|
(super
|
||||||
|
->[archive e]
|
||||||
|
(and (tagsMatch e "!(or done hidden)") (canProcess archive e))
|
||||||
|
->[archive e &opt ui]
|
||||||
|
{
|
||||||
|
(when !(hasComponent e Positions)
|
||||||
|
(addComponent archive e Positions (new Map)))
|
||||||
|
(withWritableComponents archive e [positions Positions]
|
||||||
|
(when !(positions.exists _playgroundKey)
|
||||||
|
// TODO do a playground check before giving a default position.
|
||||||
|
(dictSet positions _playgroundKey (defaultPosition e))))
|
||||||
|
(let [pos (dictGet (readComponent e Positions) _playgroundKey)]
|
||||||
|
(processor archive e pos ui))
|
||||||
|
}))
|
||||||
|
|
||||||
|
(method switchPlaygroundKey [key]
|
||||||
|
(when _playgroundKey
|
||||||
|
(clear))
|
||||||
|
(set _playgroundKey key)
|
||||||
|
(process ui.controller.archive ui))
|
||||||
|
|
||||||
|
(method clear [])
|
||||||
|
|
||||||
|
(method &override :Void process [:Archive archive &opt :ArchiveUI ui]
|
||||||
|
(when _playgroundKey (super.process archive ui)))
|
||||||
|
|
||||||
|
(method defaultPosition [:Entry e]
|
||||||
|
(object x 0.0 y 0.0 z 0.0))
|
||||||
Reference in New Issue
Block a user