Position arg type in NAT
This commit is contained in:
@@ -3,6 +3,7 @@ package nat;
|
|||||||
import kiss.Prelude;
|
import kiss.Prelude;
|
||||||
import kiss.List;
|
import kiss.List;
|
||||||
import kiss.Stream;
|
import kiss.Stream;
|
||||||
|
import nat.components.Position;
|
||||||
import haxe.Constraints;
|
import haxe.Constraints;
|
||||||
import haxe.DynamicAccess;
|
import haxe.DynamicAccess;
|
||||||
import uuid.Uuid;
|
import uuid.Uuid;
|
||||||
@@ -27,6 +28,8 @@ enum CommandArgType {
|
|||||||
|
|
||||||
// TODO playground name -- choose from archive.playgrounds
|
// TODO playground name -- choose from archive.playgrounds
|
||||||
|
|
||||||
|
Position;
|
||||||
|
|
||||||
// Then again the more of these I add the more convoluted CollectAndValidateArgs gets,
|
// Then again the more of these I add the more convoluted CollectAndValidateArgs gets,
|
||||||
// and the more stream reader methods I need to write
|
// and the more stream reader methods I need to write
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,9 @@
|
|||||||
(continuation entries)))
|
(continuation entries)))
|
||||||
min
|
min
|
||||||
max))
|
max))
|
||||||
(null)))
|
(Position
|
||||||
|
(ui.choosePosition "${arg.name}:" continuation))
|
||||||
|
(never null)))
|
||||||
|
|
||||||
// TODO try catch and ui.reportError
|
// TODO try catch and ui.reportError
|
||||||
// TODO maaaybe support escape sequences?
|
// TODO maaaybe support escape sequences?
|
||||||
@@ -176,7 +178,8 @@
|
|||||||
((exprOr (SelectedEntries _ _) (Entries _ _)) `:Array<nat.Entry> ,name)
|
((exprOr (SelectedEntries _ _) (Entries _ _)) `:Array<nat.Entry> ,name)
|
||||||
((Text _) `:String ,name)
|
((Text _) `:String ,name)
|
||||||
((VarText _) `:Array<String> ,name)
|
((VarText _) `:Array<String> ,name)
|
||||||
((Number _ _ _) `:Float ,name)))
|
((Number _ _ _) `:Float ,name)
|
||||||
|
(Position `:Position ,name)))
|
||||||
commandArgs
|
commandArgs
|
||||||
(for [name type] argPairs
|
(for [name type] argPairs
|
||||||
`(object name ,(symbolName name) type ,type))]
|
`(object name ,(symbolName name) type ,type))]
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ interface ArchiveUI {
|
|||||||
*/
|
*/
|
||||||
function onSelectionChanged(selectedEntries:Array<Entry>, lastSelectedEntries:Array<Entry>):Void;
|
function onSelectionChanged(selectedEntries:Array<Entry>, lastSelectedEntries:Array<Entry>):Void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompt the user to choose a position
|
||||||
|
*/
|
||||||
|
function choosePosition(prompt:String, resolve:Position->Void):Void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A way to tell NAT where the cursor is
|
* A way to tell NAT where the cursor is
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -80,7 +80,12 @@
|
|||||||
(when (and textInput !textInput.alive)
|
(when (and textInput !textInput.alive)
|
||||||
(set textInput null))
|
(set textInput null))
|
||||||
|
|
||||||
|
(when resolvePosition
|
||||||
|
(when FlxG.mouse.justPressed
|
||||||
|
(whenLet [rp resolvePosition
|
||||||
|
(Some pos) (cursorPosition)]
|
||||||
|
(set resolvePosition null)
|
||||||
|
(rp pos))))
|
||||||
|
|
||||||
// Control the UI camera with WASD, and the playground camera with arrow keys:
|
// Control the UI camera with WASD, and the playground camera with arrow keys:
|
||||||
(var KEYBOARD_SCROLL_SPEED 800)
|
(var KEYBOARD_SCROLL_SPEED 800)
|
||||||
@@ -214,6 +219,11 @@
|
|||||||
(whenLet [sprite (dictGet spriteSystem.sprites e.id)]
|
(whenLet [sprite (dictGet spriteSystem.sprites e.id)]
|
||||||
(sprite.updateColor))))
|
(sprite.updateColor))))
|
||||||
|
|
||||||
|
(prop &mut :Position->Void resolvePosition)
|
||||||
|
(method :Void choosePosition [prompt resolve]
|
||||||
|
(displayMessage prompt)
|
||||||
|
(set resolvePosition resolve))
|
||||||
|
|
||||||
(method :Option<Position> cursorPosition []
|
(method :Option<Position> cursorPosition []
|
||||||
(let [pos (FlxG.mouse.getWorldPosition FlxG.camera)]
|
(let [pos (FlxG.mouse.getWorldPosition FlxG.camera)]
|
||||||
(Some (object x pos.x y pos.y z 0.0))))
|
(Some (object x pos.x y pos.y z 0.0))))
|
||||||
Reference in New Issue
Block a user