From 9c76eebe28beb19a6ecdeb78008a83f1dbcc159b Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sun, 9 Oct 2022 00:33:58 +0000 Subject: [PATCH] run multiple NATCommands --- .../src/nat/ArchiveController.kiss | 19 +++++++++++++++---- .../src/nat/systems/KeyShortcutSystem.kiss | 3 +-- .../source/PlayState.kiss | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/projects/nat-archive-tool/src/nat/ArchiveController.kiss b/projects/nat-archive-tool/src/nat/ArchiveController.kiss index 8e91dc59..93e184df 100644 --- a/projects/nat-archive-tool/src/nat/ArchiveController.kiss +++ b/projects/nat-archive-tool/src/nat/ArchiveController.kiss @@ -128,16 +128,20 @@ (lambda :Void [] (_collectAndValidateArg arg stream ->:Void [:Dynamic argValue] {(collectedArgs.push argValue) (lastCollector)}))) -(method :Void tryRunCommand [:String command] +(method :Void tryRunCommand [:String command &opt :Void->Void doAfter] (let [parts (command.split " ") commandName (parts.shift) stream (Stream.fromString (parts.join " ")) lowerCommandName (commandName.toLowerCase)] (if (commands.exists lowerCommandName) - (_runCommand (dictGet commands lowerCommandName) stream) + (_runCommand (dictGet commands lowerCommandName) stream doAfter) (ui.reportError "$commandName is not a valid command")))) -(method :Void _runCommand [:Command command :Stream stream] +(method :Void tryRunCommands [:Array commands] + (when commands + (tryRunCommand (commands.shift) ->:Void (tryRunCommands commands)))) + +(method :Void _runCommand [:Command command :Stream stream &opt :Void->Void doAfter] (let [collectedArgs [] &mut lastCollector @@ -149,7 +153,8 @@ (when lastChangeSet (doFor e lastChangeSet (assert (and e (isEntry e)) "Lib function forgot to return the Entry that was modified")) - (ui.handleChanges archive lastChangeSet))))] + (ui.handleChanges archive lastChangeSet) + (when doAfter (doAfter)))))] // To facilitate asynchronous arg input via UI, we need to construct an insanely complicated nested callback to give the UI (doFor arg (reverse command.args) (set lastCollector (_composeArgCollector collectedArgs arg stream lastCollector))) @@ -321,6 +326,12 @@ (AddKeyShortcut e description) (AddNATCommand [e] command)})]) + (defCommand CreateMultiCommandShortcut [description (Text null) commands (VarText null)] + [(archive.createEntry ->e { + (addComponent archive e Name description) + (AddKeyShortcut e description) + (AddNATCommands [e] commands)})]) + (defCommand AddFiles [entries (SelectedEntries 1 null) // TODO add File and Files as an argument type for commands, ArchiveUI // TODO make tkinter file browser externs and use tkinter as the file picking mechanism for CLI diff --git a/projects/nat-archive-tool/src/nat/systems/KeyShortcutSystem.kiss b/projects/nat-archive-tool/src/nat/systems/KeyShortcutSystem.kiss index 4ddc7daa..6496efe8 100644 --- a/projects/nat-archive-tool/src/nat/systems/KeyShortcutSystem.kiss +++ b/projects/nat-archive-tool/src/nat/systems/KeyShortcutSystem.kiss @@ -32,6 +32,5 @@ ((hasComponent e NATCommand) (controller.tryRunCommand (readComponent e NATCommand)) 0) ((hasComponent e NATCommands) - // TODO chain them together asynchronously (they may be partial) - 0) + (controller.tryRunCommands (readComponent e NATCommands)) 0) (true (ui.displayMessage "tried to invoke ${e.id} but it has no available actions"))) 0) \ No newline at end of file diff --git a/projects/nat-flixel-desktop-playground/source/PlayState.kiss b/projects/nat-flixel-desktop-playground/source/PlayState.kiss index d2196d57..a3208a58 100644 --- a/projects/nat-flixel-desktop-playground/source/PlayState.kiss +++ b/projects/nat-flixel-desktop-playground/source/PlayState.kiss @@ -134,6 +134,8 @@ (case [text action] ([text FlxInputText.ENTER_ACTION] (clearUI) + (set textInput.callback null) + (set textInput null) (resolve text)) //([_ FlxInputText.]) (otherwise {}))))