diff --git a/module.json b/module.json index 814fd15..65715a6 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "id": "sla-blueprint-news-zero", "title": "Blueprint News 0 Engine", "description": "Blueprint News for the Zero Engine (SLA Industries): generates BPN briefings as journal packages AND spawns Zero Engine NPC actors — gangs, Carrien and more — with attributes, weapons, hit points, armour and initiative.", - "version": "0.5.0", + "version": "0.5.1", "compatibility": { "minimum": "13", "verified": "14.361", diff --git a/module/blueprint-news.mjs b/module/blueprint-news.mjs index 08fdbe8..93f7a1a 100644 --- a/module/blueprint-news.mjs +++ b/module/blueprint-news.mjs @@ -33,27 +33,37 @@ Hooks.on("renderJournalDirectory", (_app, html) => { header.appendChild(btn); }); -/* Notes-layer toolbar button as a second entry point (v13/v14 control shape). */ +/* Token-group toolbar button (GM only). Mirrors the Zero Engine system's own + scene-control registration, which is the pattern verified on Foundry v14.361: + v14 controls is a keyed object and tools fire via onChange; v13 is an array. */ Hooks.on("getSceneControlButtons", (controls) => { if (!game.user?.isGM) return; + const open = () => BlueprintNewsApp.open(); const tool = { name: "slaBpnZeroOpen", - title: "Open Blueprint News 0 Engine", + title: "Blueprint News 0 Engine", icon: "fas fa-skull", + visible: true, button: true, - onClick: () => BlueprintNewsApp.open() + toggle: false, + onChange: open, + onClick: open }; - if (controls && typeof controls === "object" && !Array.isArray(controls)) { - const notes = controls.notes; - if (notes) { - notes.tools ??= {}; - notes.tools[tool.name] ??= tool; - } - } else if (Array.isArray(controls)) { - const notes = controls.find((c) => c.name === "notes"); - if (notes) { - notes.tools ??= []; - if (!notes.tools.some((t) => t.name === tool.name)) notes.tools.push(tool); + + // Foundry v14: controls is a plain object keyed by group name. + if (controls && !Array.isArray(controls)) { + const grp = controls.tokens ?? controls.token ?? null; + if (grp) { + grp.tools ??= {}; + grp.tools[tool.name] = tool; } + return; + } + + // Foundry v13 fallback: controls is an array. + const grp = controls.find((c) => c.name === "token" || c.name === "tokens"); + if (grp) { + if (Array.isArray(grp.tools)) grp.tools.push(tool); + else { grp.tools ??= {}; grp.tools[tool.name] = tool; } } });