Skip to content

Commit

Permalink
Merge pull request #60 from etiquettestartshere/1.1.11
Browse files Browse the repository at this point in the history
dont close on apply fix(?)
  • Loading branch information
etiquettestartshere authored Apr 12, 2024
2 parents 41ae4c3 + d0774c0 commit e8eb5c5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "effectivetray",
"title": "Effective Tray",
"version": "1.1.10",
"version": "1.1.11",
"compatibility": {
"minimum": "11",
"verified": "11"
Expand Down
47 changes: 33 additions & 14 deletions scripts/effective-tray.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class effectiveTray {
Hooks.on("dnd5e.renderChatMessage", effectiveTray._scrollEffectsTray);
Hooks.on("preCreateItem", effectiveTray._removeTransfer);
if (!game.settings.get(MODULE, "systemDefault")) {
Hooks.on("dnd5e.renderChatMessage", effectiveTray._effectButton);
Hooks.on("dnd5e.renderChatMessage", effectiveTray._effectTray);
};
if (game.settings.get(MODULE, "dontCloseOnPress") && game.settings.get(MODULE, "systemDefault")) {
Hooks.on("dnd5e.renderChatMessage", effectiveTray._effectCollapse);
Expand Down Expand Up @@ -40,7 +40,7 @@ export class effectiveTray {
};

// Make the tray effective
static async _effectButton(message, html) {
static async _effectTray(message, html) {
const tray = html.querySelector('.effects-tray');
if (!tray) return;
const uuid = message.flags?.dnd5e?.use?.itemUuid;
Expand Down Expand Up @@ -101,7 +101,10 @@ export class effectiveTray {
for (const token of canvas.tokens.controlled) if (token.actor) actors.add(token.actor);
for (const actor of actors) {
await _applyEffects(actor, effect, lvl, concentration);
tray.classList.add("collapsed");
if (!game.settings.get(MODULE, "dontCloseOnPress")) {
tray.classList.add("collapsed");
tray.classList.remove("et-uncollapsed");
};
};
} else {

Expand All @@ -112,13 +115,19 @@ export class effectiveTray {
const actors = new Set();
for (const token of game.user.targets) if (token.actor) actors.add(token.actor);
for (const actor of actors) {
await _applyEffects(actor, effect, lvl, concentration);
tray.classList.add("collapsed");
await _applyEffects(actor, effect, lvl, concentration);
if (!game.settings.get(MODULE, "dontCloseOnPress")) {
tray.classList.add("collapsed");
tray.classList.remove("et-uncollapsed");
};
}
} else {
const origin = effect.uuid;
await game.socket.emit(socketID, { type: "firstCase", data: { origin, targets, lvl, con, caster } });
tray.classList.add("collapsed");
if (!game.settings.get(MODULE, "dontCloseOnPress")) {
tray.classList.add("collapsed");
tray.classList.remove("et-uncollapsed");
};
};
};
});
Expand All @@ -135,12 +144,18 @@ export class effectiveTray {
for (const token of game.user.targets) if (token.actor) actors.add(token.actor);
for (const actor of actors) {
await _applyEffects(actor, effect, lvl, concentration);
tray.classList.add("collapsed");
if (!game.settings.get(MODULE, "dontCloseOnPress")) {
tray.classList.add("collapsed");
tray.classList.remove("et-uncollapsed");
};
}
} else {
const origin = effect.uuid;
await game.socket.emit(socketID, { type: "firstCase", data: { origin, targets, lvl, con, caster } });
tray.classList.add("collapsed");
if (!game.settings.get(MODULE, "dontCloseOnPress")) {
tray.classList.add("collapsed");
tray.classList.remove("et-uncollapsed");
};
};
});
};
Expand All @@ -157,7 +172,9 @@ export class effectiveTray {
upper.addEventListener('click', function (event) {
event.stopPropagation();
event.preventDefault();
if (html.querySelector(".et-uncollapsed")) tray.classList.remove("et-uncollapsed");
if (html.querySelector(".et-uncollapsed")) {
tray.classList.remove("et-uncollapsed");
};
if (!html.querySelector(".effects-tray.collapsed")) {
tray.classList.add("collapsed");
} else if (html.querySelector(".effects-tray.collapsed")) tray.classList.remove("collapsed");
Expand Down Expand Up @@ -193,10 +210,11 @@ export class effectiveTray {
if (game.settings.get(MODULE, "dontCloseOnPress")) {
const buttons = tray.querySelectorAll("button");
for (const button of buttons) {
button.addEventListener('click', function () {
button.addEventListener('click', async function () {
if (!tray.querySelector(".et-uncollapsed")) {
tray.classList.add("et-uncollapsed");
tray.classList.remove("collapsed");
await tray.classList.add("et-uncollapsed");
await new Promise(r => setTimeout(r, 108));
await tray.classList.remove("collapsed");
}
});
};
Expand Down Expand Up @@ -226,8 +244,9 @@ export class effectiveTray {
const tray = html.querySelector('.effects-tray');
if (!tray) return;
const mid = message.id;
await new Promise(r => setTimeout(r, 100));
tray.classList.remove("collapsed");
await tray.classList.add("et-uncollapsed");
await new Promise(r => setTimeout(r, 108));
await tray.classList.remove("collapsed");
if (game.settings.get(MODULE, "scrollOnExpand")) _scroll(mid);
};

Expand Down

0 comments on commit e8eb5c5

Please sign in to comment.