Skip to content

Commit

Permalink
pre 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
averrin committed Jul 31, 2022
1 parent 39cb131 commit e2c2f8c
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 51 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@ Added:
* You cannot add a duplicate modifier (there are some exceptions)
* Support of Sequencer 2.1.9
* A bunch of missed arguments for modifiers
* `fadeDuration` for toggle/show/hide sections
* `addSequence` section

Fixed:
* Wrong width of argument labels
* A couple of rare problems in the hooks' calling
* Sequencer's warning about reading db before it's populated
* Many problems with arguments' inputs (i suppose, i also added some more bugs)
* Fixed missing dependencies for v9
* Missed dependencies for v9
* Manual position picking reset controlled tokens to only the first one.

Known bugs:
* Color picker for stroke color in text modifier is bugged
* Alpha in color pickers do nothing
* Toggle/show/hide sections ignores `fadeDuration` in export as code
* Non-sequencer sections (hide, kill, so on) with `multiply` cannot be played separately

## [0.7.2](https://github.com/averrin/director/compare/0.7.1...0.7.2)

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Your actions are stored in the scene's data so that you can have many of them. T
Director sometimes looks too complex, so read [Documentation](https://github.com/averrin/director/wiki/How-to-use.-With-examples.). It contains a couple of easy to go examples.

## Hints
- [JB2A](https://foundryvtt.com/packages/JB2A_DnD5e/) is not required but HIGHLY recommended
- you can drag and drop tags
- right click on tag opens a color picker
- right click on action item opens a color picker for its accent
- if director fails to open, please try `Director.clearSceneData()` or `Director.clearGlobalData()` to clear data.
- click on "visible/hidden" tag in a selection card toggles visibility
- You can [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/averrin)
Expand All @@ -34,24 +34,28 @@ It's not going to be MATT's alternative, so actions are pretty basic
- Stop Sequencer's effects
- Manage Convenient Effects
- Manage TokenMagicFX filters
- Manage FxMaster weather effects

## Integrations
* Tagger [required]
* Sequencer [BETA, required]
* Monk's Active Tiles Triggers
* Token Magic FX [optional Virtual Sequencer's section]
* DFreds Convenient Effects [optional Virtual Sequencer's section]
* FxMaster

## Plans
- [ ] Documentation
- [X] Extension API
- [ ] Migrate to Active Effects Manager
- [ ] Token Attacher integration
- [ ] Warpgate mutations & summons integration
- [ ] Support for templates, lights, doors and so on
- [ ] Rolls support (variables, hooks)
- [X] v10 support
- [ ] Beginner / Expert UI mode
- [ ] Better import / export
- [ ] Better support of Sequencer's functions and types
- [X] Better support of Sequencer's functions and types
- [X] Better support for Token Magic FX
- [X] Support for Convenient Effects
- [ ] Hooks for ending effects of a sequence. E.g. to destroy DAE's effects.
Expand Down
6 changes: 4 additions & 2 deletions src/modules/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ export default class Action {
const spec = actionTypes.find(t => t.id == this.type.id);
const value = override || this.value;
let objects;
objects = await calculateValue(value, "selection");
if (!spec.ignoreTarget || value === "") {
objects = await calculateValue(value, "selection");
}
if (!Array.isArray(objects)) objects = [objects];
if (spec?.execute) {
if (spec.ignoreTarget) {
if (spec.ignoreTarget || value === "") {
spec.execute(null, this, event, seqVars);
} else {
objects.forEach((o) => spec.execute(o, this, event, seqVars));
Expand Down
15 changes: 9 additions & 6 deletions src/modules/Integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function initActiveTilesIntegration() {
label: 'Execute trigger',
group: 'Active Tiles',
execute: (object, action, event) => {
if (object.data.flags["monks-active-tiles"]) {
if (object && object.data.flags["monks-active-tiles"]) {
globalThis.game.MonksActiveTiles.object = { document: object };
globalThis.game.MonksActiveTiles.manuallyTrigger(event);
}
Expand Down Expand Up @@ -78,6 +78,7 @@ function initTokenMagicIntegration() {
label: 'Toggle Token Magic',
group: 'Token Magic',
execute: (object, action, event) => {
if (!object) return;
object.getFlag = object.document.getFlag.bind(object.document);
if (TokenMagic.hasFilterType(object, action.args[0])) {
TokenMagic.deleteFilters(object, action.args[0]);
Expand All @@ -94,6 +95,7 @@ function initTokenMagicIntegration() {
label: 'Add Token Magic',
group: 'Token Magic',
execute: (object, action, event) => {
if (!object) return;
const filter = TokenMagic.getPreset(action.args[0]);
TokenMagic.addUpdateFilters(object, filter);
}, args: [{ type: 'token-magic', label: 'filter' }]
Expand All @@ -105,6 +107,7 @@ function initTokenMagicIntegration() {
label: 'Remove Token Magic',
group: 'Token Magic',
execute: (object, action, event) => {
if (!object) return;
TokenMagic.deleteFilters(object, action.args[0]);
}, args: [{ type: 'token-magic', label: 'filter' }]
});
Expand All @@ -125,7 +128,7 @@ function initFxMasterIntegration() {
label: 'Set Weather',
group: 'FxMaster',
ignoreTarget: true,
execute: (object, action, event) => {
execute: (_, action, event) => {
Hooks.call("fxmaster.switchWeather", { type: action.args[0], id: "weather", options: {} });
}, args: [{ type: 'weather', label: 'weather' }]
});
Expand All @@ -136,7 +139,7 @@ function initFxMasterIntegration() {
label: 'Clear Weather',
group: 'FxMaster',
ignoreTarget: true,
execute: (object, action, event) => {
execute: (_, action, event) => {
canvas.scene.unsetFlag("fxmaster", "effects");
}, args: []
});
Expand Down Expand Up @@ -218,7 +221,7 @@ function initConvenientEffectsIntegration() {
label: 'Toggle Convenient Effect',
group: 'Convenient Effects',
execute: (object, action, event) => {
game.dfreds.effectInterface.toggleEffect(action.args[0], { uuids: [object.actor.uuid] });
object && game.dfreds.effectInterface.toggleEffect(action.args[0], { uuids: [object.actor.uuid] });
}, args: [{ type: 'ce-effect', label: 'effect' }]
});

Expand All @@ -228,7 +231,7 @@ function initConvenientEffectsIntegration() {
label: 'Add Convenient Effect',
group: 'Convenient Effects',
execute: (object, action, event) => {
game.dfreds.effectInterface.addEffect({ effectName: action.args[0], uuid: object.actor.uuid });
object && game.dfreds.effectInterface.addEffect({ effectName: action.args[0], uuid: object.actor.uuid });
},
args: [{ type: 'ce-effect', label: 'effect' }]
});
Expand All @@ -239,7 +242,7 @@ function initConvenientEffectsIntegration() {
label: 'Remove Convenient Effect',
group: 'Convenient Effects',
execute: (object, action, event) => {
game.dfreds.effectInterface.removeEffect({ effectName: action.args[0], uuid: object.actor.uuid });
object && game.dfreds.effectInterface.removeEffect({ effectName: action.args[0], uuid: object.actor.uuid });
}, args: [{ type: 'ce-effect', label: 'effect' }]
});

Expand Down
43 changes: 31 additions & 12 deletions src/modules/Sequencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ controlled.forEach(c => c.control({releaseOthers: false}));`;
let r = `// This macro was created by converting Director's sequence. Correctness of this code isn't guaranteed.\n`;
r += `// The code isn't indentical to how Director executes sequences, but it should be a good base for modifications.\n`;
if (this.variables.length > 0) {
r += `\n//==== Variables (all of them, not only used) ====\n`;
r += `\n//==== Variables (all of them, not only used) ====//\n`;
}
for (const v of this.variables) {
const [val, replace] = this.getCodeForVal(v.name, v.value, v.type);
Expand All @@ -132,7 +132,7 @@ controlled.forEach(c => c.control({releaseOthers: false}));`;
}
}

r += `\n//==== Sequence construction ====\n`;
r += `\n//==== Sequence construction ====//\n`;
r += `let sequence = new Sequence("${moduleId}")`;
let i = 0;

Expand All @@ -144,16 +144,20 @@ controlled.forEach(c => c.control({releaseOthers: false}));`;
for (const m of section.modifiers) {
if (m.type == "multiply") {
isMulti = true;
mode = m.args[1] || "on";
mode = m.args[1] || section._spec.multiplyMode;
targets = m.args[0];
}
}
if (isMulti) {
section.modifiers = section.modifiers.filter(m => m.type != "multiply");
const mod = new Modifier(uuidv4(), mode);
mod.setType(mode, section.type);
mod.args[0] = "@_target";
section.modifiers.push(mod);
if (mode) {
const mod = new Modifier(uuidv4(), mode);
mod.setType(mode, section.type);
mod.args[0] = "@_target";
section.modifiers.push(mod);
} else {
section.args[0] = "@_target";
}
if (stage == "normal") r += ";";
r += `\n\nfor (const _target of ${this.getCodeForVal("", targets, "selection")[0]}) {`;
stage = "in_multi";
Expand All @@ -178,6 +182,8 @@ controlled.forEach(c => c.control({releaseOthers: false}));`;
r += `.${section.type}()`;
r += `\n\t\t.origin("${this.id}")`;
r += `\n\t\t.name(${name})`;
} else if (section.type == "addSequence") {
r += `/* .${section.type}() */ // please combine sequences by yourself`;
} else {
if (section._spec && "toCode" in section._spec) {
r += section._spec.toCode(args);
Expand Down Expand Up @@ -261,6 +267,11 @@ controlled.forEach(c => c.control({releaseOthers: false}));`;
val = await v.getValue(this);
}
}
if (!obj._spec.args) {
n++;
result.push(undefined);
continue;
}
const spec = obj._spec.args[n];
if (val === undefined) {
val = await calculateValue(a, spec.type, this);
Expand Down Expand Up @@ -292,7 +303,7 @@ controlled.forEach(c => c.control({releaseOthers: false}));`;
if (m.type == "multiply") {
isMulti = true;
targets = await calculateValue(m.args[0], "selection");
mode = m.args[1] || "on";
mode = m.args[1] || section._spec.multiplyMode;
}
}
if (!isMulti) {
Expand All @@ -302,10 +313,14 @@ controlled.forEach(c => c.control({releaseOthers: false}));`;
const ns = Section.fromPlain(section);
ns.id = uuidv4();
ns.modifiers = ns.modifiers.filter(m => m.type != "multiply");
const mod = new Modifier(uuidv4(), mode);
mod.setType(mode, section.type);
mod.args[0] = target;
ns.modifiers.push(mod);
if (mode == "self") {
ns.args[0] = target;
} else {
const mod = new Modifier(uuidv4(), mode);
mod.setType(mode, section.type);
mod.args[0] = target;
ns.modifiers.push(mod);
}
seq.push(ns);
}
}
Expand All @@ -319,6 +334,9 @@ controlled.forEach(c => c.control({releaseOthers: false}));`;
if ("thenDo" in section._spec) {
sectionName = "thenDo";
args = [section._spec.thenDo(args)];
} else if ("addSequence" in section._spec) {
sectionName = "addSequence";
args = [section._spec.addSequence(args)];
}
let currentSection = s[sectionName](...args);
if (section.type == "effect") {
Expand Down Expand Up @@ -424,6 +442,7 @@ export class Section {
this.args = [];
this.type = type;
this._spec = sectionSpecs.find(s => s.id == this.type);
this.modifiers = [];
if (!this._spec || !this._spec.args) return;
for (const arg of this._spec?.args) {
const spec = argSpecs.find(s => s.id == arg.type);
Expand Down
Loading

0 comments on commit e2c2f8c

Please sign in to comment.