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