Skip to content

Commit

Permalink
12.01 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ironmonk88 committed Jun 10, 2024
1 parent 8214cc1 commit 9457aa7
Show file tree
Hide file tree
Showing 15 changed files with 574 additions and 269 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## Version 12.01

v12 compatibility

Added the option for the GM to see imageless tiles in v12.

Updated the game time action to handle hous and minutes better, and to not break when advancing time.

Fixed issue with Stop Within Tile and Movement Within Tile causing a tile to trigger even if no movement has happened.

Fixed issue with tokens within Tile when triggering another tile.

Added the name property to Tiles so you can give them a name, this helps when triggering them from a Region.

Added Tile Triggering as a behavior in regions.

## Version 11.27

Increased the precision of the playlist volume slider
Expand Down
220 changes: 124 additions & 96 deletions actions.js

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions apps/action-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class ActionConfig extends FormApplication {
return result;
}, {});*/

return mergeObject(super.getData(options), {
return foundry.utils.mergeObject(super.getData(options), {
availableActions: availableActions
});
}
Expand Down Expand Up @@ -255,7 +255,7 @@ export class ActionConfig extends FormApplication {
} else if (data.type == "button") {
// Call the drop handler
if (target && target.dataset.id) {
let items = duplicate(this.buttonlist);
let items = foundry.utils.duplicate(this.buttonlist);

if (data.id === target.dataset.id) return; // Don't drop on yourself

Expand Down Expand Up @@ -508,7 +508,7 @@ export class ActionConfig extends FormApplication {
}

static async addTag(event) {
let data = expandObject(this._getSubmitData());
let data = foundry.utils.expandObject(this._getSubmitData());
let prop = event.currentTarget.dataset["target"]
let entity = $(`input[name="${prop}"]`).data("value") || {};
entity["tag-name"] = entity?.id?.substring(7);
Expand Down Expand Up @@ -563,7 +563,7 @@ export class ActionConfig extends FormApplication {
if (!temporaryIds?.[tag]) {
temporaryIds[tag] = []
}
id = randomID();
id = foundry.utils.randomID();
temporaryIds[tag].push(id);
}
return tag.replace(regx, id);
Expand Down Expand Up @@ -626,7 +626,7 @@ export class ActionConfig extends FormApplication {
}

async editEntityId(event) {
let data = expandObject(super._getSubmitData());
let data = foundry.utils.expandObject(super._getSubmitData());
let entity = JSON.parse(data?.data?.entity || "{}");

const html = await renderTemplate(`modules/monks-active-tiles/templates/entity-dialog.html`, {
Expand Down Expand Up @@ -663,7 +663,7 @@ export class ActionConfig extends FormApplication {
sceneList[scene.id] = scene.name;
}

let data = expandObject(super._getSubmitData());
let data = foundry.utils.expandObject(super._getSubmitData());
let location = JSON.parse(data?.data?.location || "{}");

const html = await renderTemplate(`modules/monks-active-tiles/templates/location-dialog.html`, {
Expand Down Expand Up @@ -706,7 +706,7 @@ export class ActionConfig extends FormApplication {

/*
async editEntityId(event) {
let data = expandObject(super._getSubmitData());
let data = foundry.utils.expandObject(super._getSubmitData());
new EntityEdit($(event.currentTarget).prev(), { action: data.action }).render(true);
}
Expand Down Expand Up @@ -749,7 +749,7 @@ export class ActionConfig extends FormApplication {

let buttons = JSON.parse($('input[name="data.buttons"', this.element).val() || "[]");
if (!data.id) {
data.id = randomID();
data.id = foundry.utils.randomID();
buttons.push(data);
} else {
let button = buttons.find(b => b.id == data.id);
Expand Down Expand Up @@ -819,7 +819,7 @@ export class ActionConfig extends FormApplication {
}

_getSubmitData(updateData = {}) {
let data = expandObject(super._getSubmitData(updateData));
let data = foundry.utils.expandObject(super._getSubmitData(updateData));

let files = null;
if (data.files) {
Expand All @@ -844,10 +844,10 @@ export class ActionConfig extends FormApplication {
*/

$('input.range-value', this.element).each(function () {
if ($(this).val() == "") setProperty(data, $(this).prev().attr("name"), "");
if ($(this).val() == "") foundry.utils.setProperty(data, $(this).prev().attr("name"), "");
});

return flattenObject(data);
return foundry.utils.flattenObject(data);
}

async _updateObject(event, formData) {
Expand All @@ -872,15 +872,15 @@ export class ActionConfig extends FormApplication {
formData['data.attack'] = { id: formData['data.attack'], name: $('select[name="data.attack"] option:selected', this.element).text()};

if (this.object.id == undefined) {
mergeObject(this.object, formData);
foundry.utils.mergeObject(this.object, formData);
this.object.id = makeid();
let actions = duplicate(this.options.parent.object.getFlag("monks-active-tiles", "actions") || []);
let actions = foundry.utils.duplicate(this.options.parent.object.getFlag("monks-active-tiles", "actions") || []);
let append = this.options.index === -1 || this.options.index === actions.length;
if (append)
actions.push(this.object);
else
actions.splice(this.options.index, 0, this.object);
mergeObject(this.options.parent.object.flags, {
foundry.utils.mergeObject(this.options.parent.object.flags, {
"monks-active-tiles": { actions: actions }
});
//add this row to the parent
Expand All @@ -905,7 +905,7 @@ export class ActionConfig extends FormApplication {

this.options.parent.setPosition({height: 'auto'});
} else {
let actions = duplicate(this.options.parent.object.getFlag("monks-active-tiles", "actions") || []);
let actions = foundry.utils.duplicate(this.options.parent.object.getFlag("monks-active-tiles", "actions") || []);
let action = actions.find(a => a.id == this.object.id);
if (action) {
//clear out these before saving the new information so we don't get data bleed through
Expand All @@ -918,7 +918,7 @@ export class ActionConfig extends FormApplication {
if (this.options.parent.object._sounds) {
this.options.parent.object._sounds[this.object.id] = [];
}
mergeObject(action, formData);
foundry.utils.mergeObject(action, formData);
this.options.parent.object.flags["monks-active-tiles"].actions = actions;
//update the text for this row
let trigger = MonksActiveTiles.triggerActions[action.action];
Expand Down Expand Up @@ -965,7 +965,7 @@ export class ActionConfig extends FormApplication {
//$('.gmonly', this.element).toggle(action.requiresGM);

for (let ctrl of (action?.ctrls || [])) {
let options = mergeObject({ hide: [], show: [] }, ctrl.options);
let options = foundry.utils.mergeObject({ hide: [], show: [] }, ctrl.options);
let field = $('<div>').addClass('form-fields').data('ctrl', ctrl);
if (ctrl["class"]) field.addClass(ctrl["class"]);
let id = 'data.' + ctrl.id + (ctrl.variation ? '.value' : '');
Expand Down
44 changes: 22 additions & 22 deletions apps/active-tile-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export const WithActiveTileConfig = (TileConfig) => {
constructor(...args) {
super(...args);

if (getProperty(this.object, "flags.monks-active-tiles") == undefined) {
this.object.flags = mergeObject(this.object.flags, {
if (foundry.utils.getProperty(this.object, "flags.monks-active-tiles") == undefined) {
this.object.flags = foundry.utils.mergeObject(this.object.flags, {
'monks-active-tiles': {
active: true,
trigger: setting('default-trigger'),
Expand Down Expand Up @@ -112,7 +112,7 @@ export const WithActiveTileConfig = (TileConfig) => {
let tab = $('<div>').addClass('tab').attr('data-tab', "triggers").css({ "position": "relative" }).insertAfter($('div[data-tab="animation"]', html));

let template = "modules/monks-active-tiles/templates/tile-config.html";
const tiledata = mergeObject({ 'data.flags.monks-active-tiles.minrequired': 0 }, data);
const tiledata = foundry.utils.mergeObject({ 'data.flags.monks-active-tiles.minrequired': 0 }, data);

tiledata.triggerModes = MonksActiveTiles.triggerModes;
tiledata.triggerRestriction = { 'all': i18n("MonksActiveTiles.restrict.all"), 'player': i18n("MonksActiveTiles.restrict.player"), 'gm': i18n("MonksActiveTiles.restrict.gm") };
Expand Down Expand Up @@ -161,7 +161,7 @@ export const WithActiveTileConfig = (TileConfig) => {
a.marker = currentLanding;
a.landingStop = a.data.stop;
}
a.landings = duplicate(landings);
a.landings = foundry.utils.duplicate(landings);
}
}

Expand Down Expand Up @@ -241,12 +241,12 @@ export const WithActiveTileConfig = (TileConfig) => {
if (data.tileId != this.object.id) {
if (data.collection == list.dataset.collection) {
let src = canvas.scene.tiles.get(data.tileId);
let action = getProperty(src, "flags.monks-active-tiles.actions")?.find(a => a.id == data.id);
let action = foundry.utils.getProperty(src, "flags.monks-active-tiles.actions")?.find(a => a.id == data.id);

if (action) {
let newAction = duplicate(action);
let newAction = foundry.utils.duplicate(action);
newAction.id = makeid();
let items = duplicate(this[list.dataset.collection]);
let items = foundry.utils.duplicate(this[list.dataset.collection]);
if (items.length && !target)
target = $(`li[data-id="${items[0].id}"]`, this.element).get(0);
let to = items.findIndex(a => a.id == target?.dataset.id) || 0;
Expand All @@ -267,7 +267,7 @@ export const WithActiveTileConfig = (TileConfig) => {
} else {
// Call the drop handler
if (target && target.dataset.id) {
let items = duplicate(this[list.dataset.collection]);
let items = foundry.utils.duplicate(this[list.dataset.collection]);

if (data.id === target.dataset.id) return; // Don't drop on yourself

Expand Down Expand Up @@ -324,7 +324,7 @@ export const WithActiveTileConfig = (TileConfig) => {
this.object._images = await MonksActiveTiles.getTileFiles(this.object.flags["monks-active-tiles"].files || []);

if (!this.object.id && this.object._images.length) {
let fileindex = Math.clamped(this.object.flags["monks-active-tiles"].fileindex, 0, this.object._images.length - 1);
let fileindex = Math.clamp(this.object.flags["monks-active-tiles"].fileindex, 0, this.object._images.length - 1);
if (this.object._images[fileindex] != this.object.texture.src) {
formData["texture.src"] = this.object._images[fileindex];
}
Expand All @@ -336,7 +336,7 @@ export const WithActiveTileConfig = (TileConfig) => {
await super._updateObject(event, formData);

if (this.object.id && this.object._images.length) {
let fileindex = Math.clamped(this.object.flags["monks-active-tiles"].fileindex, 0, this.object._images.length - 1);
let fileindex = Math.clamp(this.object.flags["monks-active-tiles"].fileindex, 0, this.object._images.length - 1);
if (this.object._images[fileindex] != this.object.texture.src) {
await this.object.update({ texture: { src: this.object._images[fileindex] } });
}
Expand Down Expand Up @@ -469,9 +469,9 @@ export const WithActiveTileConfig = (TileConfig) => {
let result = this.addFile(id, filename);
$(event.currentTarget).val('');
if (result) {
let files = duplicate(this.files);
let files = foundry.utils.duplicate(this.files);
files.push(result);
mergeObject(this.object.flags, {
foundry.utils.mergeObject(this.object.flags, {
"monks-active-tiles": { files: files }
});
}
Expand Down Expand Up @@ -502,7 +502,7 @@ export const WithActiveTileConfig = (TileConfig) => {
// Retrieve wildcard content
try {
const content = await FilePicker.browse(source, pattern, browseOptions);
let files = duplicate(this.files);
let files = foundry.utils.duplicate(this.files);
for (let file of content.files) {
let ext = file.substr(file.lastIndexOf('.') + 1);
if (CONST.IMAGE_FILE_EXTENSIONS[ext] != undefined) {
Expand All @@ -511,7 +511,7 @@ export const WithActiveTileConfig = (TileConfig) => {
files.push(result);
}
}
mergeObject(this.object.flags, {
foundry.utils.mergeObject(this.object.flags, {
"monks-active-tiles": { files: files }
});
this.setPosition({ height: 'auto' });
Expand Down Expand Up @@ -546,16 +546,16 @@ export const WithActiveTileConfig = (TileConfig) => {

$(`input[name="flags.monks-active-tiles.fileindex"]`, this.element).val(idx);

mergeObject(this.object.flags, {
foundry.utils.mergeObject(this.object.flags, {
"monks-active-tiles": { fileindex: idx }
});
}

removeFile(event) {
let id = event.currentTarget.closest('.file-row').dataset["id"];
let files = duplicate(this.files);
let files = foundry.utils.duplicate(this.files);
files.findSplice(i => i.id == id);
mergeObject(this.object.flags, {
foundry.utils.mergeObject(this.object.flags, {
"monks-active-tiles": { files: files }
});

Expand Down Expand Up @@ -583,9 +583,9 @@ export const WithActiveTileConfig = (TileConfig) => {
}

deleteAction(id) {
let actions = duplicate(this.actions);
let actions = foundry.utils.duplicate(this.actions);
actions.findSplice(i => i.id == id);
mergeObject(this.object.flags, {
foundry.utils.mergeObject(this.object.flags, {
"monks-active-tiles": { actions: actions }
});
//this.object.setFlag("monks-active-tiles", "actions", actions);
Expand All @@ -609,7 +609,7 @@ export const WithActiveTileConfig = (TileConfig) => {
}

cloneAction(id) {
let actions = duplicate(this.actions);
let actions = foundry.utils.duplicate(this.actions);
let idx = actions.findIndex(obj => obj.id == id);
if (idx == -1)
return;
Expand All @@ -618,13 +618,13 @@ export const WithActiveTileConfig = (TileConfig) => {
if (!action)
return;

let clone = duplicate(action);
let clone = foundry.utils.duplicate(action);
clone.id = makeid();
actions.splice(idx + 1, 0, clone);
//if (this.object.id) {
// this.object.setFlag("monks-active-tiles", "actions", actions);
//} else {
setProperty(this.object, "flags.monks-active-tiles.actions", actions);
foundry.utils.setProperty(this.object, "flags.monks-active-tiles.actions", actions);
this.render();
//}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/entity-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class EntityEdit extends FormApplication {
}

getData(options) {
return mergeObject(super.getData(options), {
return foundry.utils.mergeObject(super.getData(options), {
action: this.options.action,
entities: this.entityList
});
Expand Down
2 changes: 1 addition & 1 deletion apps/location-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class LocationEdit extends FormApplication {
sceneList[scene.id] = scene.name;
}

return mergeObject(super.getData(options), {
return foundry.utils.mergeObject(super.getData(options), {
action: this.options.action,
locations: this.locationList,
sceneList
Expand Down
4 changes: 2 additions & 2 deletions apps/template-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export class TemplateConfig extends FormApplication {

getData(options) {
let data = super.getData(options)
let tileData = duplicate(this.object);
let tileData = foundry.utils.duplicate(this.object);
delete tileData._id;
delete tileData.id;
delete tileData.x;
delete tileData.y;

return mergeObject(data, {
return foundry.utils.mergeObject(data, {
tileData: JSON.stringify(tileData, null, 4),
allowEditing: setting("tile-edit")
});
Expand Down
2 changes: 1 addition & 1 deletion apps/tile-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class TileHistory extends FormApplication {

getData(options) {
let history = this.object.getHistory();
return mergeObject(super.getData(options), {
return foundry.utils.mergeObject(super.getData(options), {
history: history
});
}
Expand Down
Loading

0 comments on commit 9457aa7

Please sign in to comment.