From bc490507c48f3a48fcba37bce982ec31fd478feb Mon Sep 17 00:00:00 2001 From: averrin Date: Sun, 21 Aug 2022 11:39:28 +0200 Subject: [PATCH] 0.8.8 --- src/modules/API.js | 38 +----- src/modules/Specs.js | 14 ++ src/styles/main.scss | 16 ++- src/view/MainUI.svelte | 26 +--- src/view/components/ActionItem.svelte | 4 +- src/view/components/ArgInput.svelte | 2 +- src/view/components/ModifierItem.svelte | 2 +- src/view/components/Tag.svelte | 70 ++++++++++ src/view/components/Tags.svelte | 164 +++++++++++++----------- 9 files changed, 205 insertions(+), 131 deletions(-) create mode 100644 src/view/components/Tag.svelte diff --git a/src/modules/API.js b/src/modules/API.js index 8916b2e..36918a4 100644 --- a/src/modules/API.js +++ b/src/modules/API.js @@ -2,16 +2,14 @@ import { moduleId, SETTINGS } from '../constants.js'; import { addArgSpec, addModifier, addSection, addHook, addAction } from "./Specs.js"; import { sequences, actions } from "./stores.js"; import { DSequence } from "./Sequencer.js"; +import { get } from "svelte/store"; const API = { addArgSpec, addModifier, addSection, addHook, addAction, getSequence: async (name, overrides) => { let seq; - sequences.update(seqs => { - seq = seqs.find(s => s.title == name || s.id == name); - return seqs; - }); + seq = get(sequences).find(s => s.title == name || s.id == name); if (!seq) { logger.error(`Sequence ${name} not found`); return null; @@ -24,48 +22,26 @@ const API = { runAction: (id) => { let action; - actions.update(a => { - action = a.find(action => action.id == id || action.name == id); - return a; - }); + action = get(actions).find(action => action.id == id || action.name == id); if (action) { action.run(new MouseEvent("")) } }, listSequences: () => { - let seq; - sequences.update(seqs => { - seq = seqs; - return seqs; - }); - return seq; + return get(sequences); }, listActions: () => { - let acts; - actions.update(a => { - acts = a; - return a; - }); - return acts; + return get(actions); }, findSequence: (name) => { - let seq; - sequences.update(seqs => { - seq = seqs.find(s => s.title == name || s.id == name); - return seqs; - }); - return seq; + return get(sequences).find(s => s.title == name || s.id == name); }, playSequence: (name, overrides) => { - let seq; - sequences.update(seqs => { - seq = seqs.find(s => s.title == name || s.id == name); - return seqs; - }); + let seq = get(sequences).find(s => s.title == name || s.id == name); if (!seq) { logger.error(`Sequence ${name} not found`); } else { diff --git a/src/modules/Specs.js b/src/modules/Specs.js index 22054e9..f2f77a9 100644 --- a/src/modules/Specs.js +++ b/src/modules/Specs.js @@ -33,6 +33,14 @@ export const actionTypes = [ group: 'Tokens', execute: (object, action) => object && tools.revive(object?.document || object), }, + + { + id: 'another-action', + label: 'Another Action', + group: 'Macro', + args: [{ type: "action", label: "action" }], + execute: (object, action) => Director.runAction(action.args[0]), + }, { id: 'macro', label: 'Run Macro', @@ -736,6 +744,12 @@ export const argSpecs = [ } , control: "select" }, + { + id: "action", var_types: ["action"], options: (_) => { + return Director.listActions().filter(a => a.name != "").map(s => { return { value: s.id, label: s.name } }); + } + , control: "select" + }, { id: "animate-target", var_types: ["animate-target"], options: [ { value: "sprite", label: "sprite" }, diff --git a/src/styles/main.scss b/src/styles/main.scss index c61f5fb..e2f1cd8 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -36,7 +36,7 @@ max-width: 600px; border-radius: var(--rounded-btn, 0.5rem); background: #fff !important; - height: 3rem !important; + height: 2.5rem !important; input, .selection { font-size: 1rem !important; @@ -79,7 +79,7 @@ .ui-input-lg { border-color: #ddd !important; - height: 3rem !important; + height: 2.5rem !important; } .ui-text-base { @@ -101,6 +101,16 @@ button > i { margin: 0px !important; } + + .ui-btn { + height: 2.5rem !important; + min-height: 2.5rem !important; + } + .ui-btn-square { + width: 2.5rem !important; + height: 2.5rem !important; +} + .ui-tabs { justify-content: center; } @@ -112,7 +122,7 @@ .ui-toggle { flex-shrink: 0 !important; flex-basis: auto !important; - width: 3rem !important; + width: 2.5rem !important; height: 1.5rem !important; } diff --git a/src/view/MainUI.svelte b/src/view/MainUI.svelte index 67351e8..6416183 100644 --- a/src/view/MainUI.svelte +++ b/src/view/MainUI.svelte @@ -19,10 +19,13 @@ import FaCompressArrowsAlt from "svelte-icons/fa/FaCompressArrowsAlt.svelte"; import ArgInput from "./components/ArgInput.svelte"; + import { getContext, onDestroy, setContext } from "svelte"; import { tagsStore, actions } from "../modules/stores.js"; + setContext("tagsStore", tagsStore); + import Tag from "../modules/Tags.js"; + import TagComponent from "./components/Tag.svelte"; - import { getContext, onDestroy, setContext } from "svelte"; import Action from "../modules/Actions"; import { actionTypes } from "../modules/Specs"; const { application } = getContext("external"); @@ -49,7 +52,7 @@ }); pickerOpen = !pickerOpen; } - setContext("onTagClick", onTagClick); + setContext("tagRClick", onTagClick); function createAction(_, tags) { actions.update((actions) => { @@ -127,22 +130,7 @@
- - {#if editTag.icon} - - {/if} - - {editTag.text} - +
@@ -157,7 +145,7 @@
{#each availableTabs as t (t.title)} - selectMode(t)} class:ui-tab-active={t.mode == mode}> + selectMode(t)} class:ui-tab-active={t.mode == mode}> {t.title} {#if t.badge} {@html t.badge} diff --git a/src/view/components/ActionItem.svelte b/src/view/components/ActionItem.svelte index f76b435..49d85e4 100644 --- a/src/view/components/ActionItem.svelte +++ b/src/view/components/ActionItem.svelte @@ -92,11 +92,11 @@ {#if item.valueType == "hook" && hook} {#if !hook?.enabled} - + {:else} - + {/if} diff --git a/src/view/components/ArgInput.svelte b/src/view/components/ArgInput.svelte index b78d824..3eecc1e 100644 --- a/src/view/components/ArgInput.svelte +++ b/src/view/components/ArgInput.svelte @@ -167,7 +167,7 @@ {/if}