From 22c44a39725db3863c64e38e3e72a0c04bb2e2c4 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 10 Mar 2019 16:31:50 +0100 Subject: [PATCH] Building action.cmd[] and editing of command, arg. Order of commands can't be edited yet --- .../add-edit-action-popup.vue | 36 +++++++-- .../command-builder/command-add-edit.vue | 50 ++++++++---- .../command-builder/command-block.vue | 81 ++++++++++++------- .../command-builder/command-chain.vue | 28 ++++--- .../set-shortcut-button.vue | 2 +- 5 files changed, 136 insertions(+), 61 deletions(-) diff --git a/src/options/controls-settings/add-edit-action-popup.vue b/src/options/controls-settings/add-edit-action-popup.vue index 4f2a1a3..88a1c89 100644 --- a/src/options/controls-settings/add-edit-action-popup.vue +++ b/src/options/controls-settings/add-edit-action-popup.vue @@ -8,23 +8,27 @@ -
-        Action:
-        {{action}}
-        ----
-      
+
+        ----- [ raw action data ] -----
+        Action:
+        {{action}}
+        --- [ end raw action data ] ---
+      
+
@@ -138,6 +142,11 @@ export default { } } }, + watch: { + action: { + deep: true, + } + }, methods: { parseActionShortcut(action) { return KeyboardShortcutParser.parseShortcut(action.shortcut[0]); @@ -166,9 +175,19 @@ export default { }, addNewCommand() { this.currentCmdIndex = -1; + this.currentCmd = undefined; this.addEditCommand = true; console.log("adding command") }, + editCommand(index) { + this.currentCmdIndex = index; + this.currentCmd = this.action.cmd[index]; + this.addEditCommand = true; + console.log("EDITING COMMAND") + }, + deleteCommand(index) { + this.action.cmd.splice(index,1); + }, updateCommand(action, arg) { this.addEditCommand = false; if (this.currentCmdIndex < 0) { @@ -182,6 +201,9 @@ export default { arg: arg, }; } + this.action = JSON.parse(JSON.stringify(this.action)); + + // this.$nextTick(function() {this.$forceUpdate()}); } } } diff --git a/src/options/controls-settings/command-builder/command-add-edit.vue b/src/options/controls-settings/command-builder/command-add-edit.vue index 22848f3..2c2628a 100644 --- a/src/options/controls-settings/command-builder/command-add-edit.vue +++ b/src/options/controls-settings/command-builder/command-add-edit.vue @@ -1,11 +1,6 @@ @@ -91,19 +104,28 @@ export default { return { Stretch: Stretch, ActionList: ActionList, - selectedAction: this.action ? action.action : undefined, - selectedArgument: this.action ? { - name: ActionList[action.action].args.find(x => x.arg === action.arg) || ActionList[action.action].args.find(x => x.customArg), - arg: action.arg - } : undefined, - customArgumentValue: this.action ? action.arg : undefined + selectedAction: undefined, + selectedArgument: undefined, + customArgumentValue: undefined } }, created () { - console.log("this.actionList", ActionList, this.ActionList) - for(const a in ActionList) { - console.log(a); + if (this.action) { + this.selectedAction = this.action.cmd; + this.selectedArgument = { + name: ActionList[this.action.cmd].args.find(x => x.arg === this.action.arg) || ActionList[this.action.cmd].args.find(x => x.customArg), + arg: this.action.arg + } + this.customArgumentValue = this.action.arg; } + + // console.log("this.actionList", ActionList, this.ActionList) + // for(const a in ActionList) { + // console.log(a); + // } + }, + mounted() { + }, props: { action: Object, diff --git a/src/options/controls-settings/command-builder/command-block.vue b/src/options/controls-settings/command-builder/command-block.vue index 62b80af..b5e2820 100644 --- a/src/options/controls-settings/command-builder/command-block.vue +++ b/src/options/controls-settings/command-builder/command-block.vue @@ -1,40 +1,38 @@ @@ -57,7 +55,9 @@ export default { }, methods: { parseActionShortcut(action) { - return KeyboardShortcutParser.parseShortcut(action.shortcut[0]); + if (action.shortcut) { + return KeyboardShortcutParser.parseShortcut(action.shortcut[0]); + } }, setAction(cmd) { console.log("SETTING ACTION", cmd); @@ -70,13 +70,36 @@ export default { this.selectedArgument = arg; this.customArgumentValue = undefined; }, - emitCommand() { - this.$emit( - 'set-command', - this.selectedAction, - this.customArgumentValue ? this.customArgumentValue : this.selectedArgument.arg - ); - } + // emitCommand() { + // this.$emit( + // 'set-command', + // this.selectedAction, + // this.customArgumentValue ? this.customArgumentValue : this.selectedArgument.arg + // ); + // } } } - \ No newline at end of file + + + diff --git a/src/options/controls-settings/command-builder/command-chain.vue b/src/options/controls-settings/command-builder/command-chain.vue index f96d515..5ebcb00 100644 --- a/src/options/controls-settings/command-builder/command-chain.vue +++ b/src/options/controls-settings/command-builder/command-chain.vue @@ -1,22 +1,20 @@