Various fixes for official release

This commit is contained in:
2026-06-08 22:20:44 +02:00
parent 7623123bb5
commit 3851a38c9f
108 changed files with 1011 additions and 538 deletions
+22 -3
View File
@@ -73,10 +73,25 @@ Hooks.once("init", () => {
Hooks.once("setup", () => {
localizeSystemConfig()
})
// Strip phantom null-_id entries from all compendium indices.
// Foundry V14 LevelDatabase creates !items!null entries on open under Node24.
if (typeof CompendiumCollection !== "undefined") {
const orig = CompendiumCollection.prototype.getIndex;
CompendiumCollection.prototype.getIndex = async function(opts) {
const r = await orig.call(this, opts);
for (const k of [...this.index.keys()]) { if (!k) this.index.delete(k); }
return r;
};
}
});
Hooks.once("ready", async () => {
console.info(`${SYSTEM_ID} | Ready`)
// Clean anything already in the index before we patched
for (const pack of game.packs) {
for (const k of [...pack.index.keys()]) { if (!k) pack.index.delete(k); }
}
if (!game.user.isGM) return
@@ -117,7 +132,7 @@ Hooks.on("deleteCombat", (combat) => {
if (!cores.length) return
const lines = cores.map(c => `<li><strong>${c.parent.name}</strong> — ${c.name} (${c.system.usageDie})</li>`).join("")
ChatMessage.create({
content: `<article class="mgne-chat-card mode-check"><div class="chat-card-body"><p class="chat-special">⚙️ ${game.i18n.localize("MGNE.Notification.RollUsageDiceReminder")}</p><ul style="margin:.3rem 0 0 1rem;padding:0">${lines}</ul></div></article>`,
content: `<article class="mgne-chat-card"><div class="chat-card-body" style="color:#ccb292;font-size:0.72rem;line-height:1.4"><p style="margin:0">⚙️ ${game.i18n.localize("MGNE.Notification.RollUsageDiceReminder")}</p><ul style="margin:.3rem 0 0 1rem;padding:0;color:#ccb292;font-size:0.72rem">${lines}</ul></div></article>`,
})
})
@@ -242,6 +257,7 @@ Hooks.on("renderChatMessageHTML", (message, element) => {
const card = select.closest(".mgne-chat-card")
const damageTotal = parseInt(card?.dataset.damageTotal ?? "0", 10) || 0
const damageCritical = card?.dataset.damageCritical === "true"
const targetActorId = card?.dataset.targetActorId ?? null
const tokens = canvas.scene?.tokens.contents ?? []
for (const token of tokens) {
@@ -249,6 +265,9 @@ Hooks.on("renderChatMessageHTML", (message, element) => {
const opt = document.createElement("option")
opt.value = token.id
opt.textContent = token.name
if (targetActorId && token.actor.id === targetActorId) {
opt.selected = true
}
select.appendChild(opt)
}
@@ -292,7 +311,7 @@ Hooks.on("renderChatMessageHTML", (message, element) => {
await ChatMessage.create({
speaker: ChatMessage.getSpeaker({ actor: targetActor }),
rolls: [reduceRoll],
content: `<article class="mgne-chat-card mode-check"><div class="chat-card-body"><p class="chat-special">${reduceMsg}</p></div></article>`,
content: `<article class="mgne-chat-card"><div class="chat-card-body"><p style="margin:0;color:#ccb292;font-size:0.72rem;line-height:1.4">${reduceMsg}</p></div></article>`,
})
}
}