v0.4.1 — fix scene-control button on Foundry v14 (tokens group + onChange)

The toolbar button was registered on the notes group with onClick, which v14
ignores, so no entry point appeared. Now mirrors the Zero Engine system's
working pattern: token group, visible+button, onChange (v14) / array (v13).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 19:32:39 +01:00
co-authored by Claude Opus 4.8
parent cd09c043b2
commit 1d8c9a0610
2 changed files with 19 additions and 14 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"id": "sla-blueprint-news",
"title": "SLA Blueprint News",
"description": "Generate SLA Industries BPN mission briefings as journal entries — a player-facing Brief and a separate GM-only Dossier, in the SLA house style with procedural artwork. Engine-agnostic core; this module is the Foundry wrapper.",
"version": "0.4.0",
"version": "0.4.1",
"compatibility": {
"minimum": "13",
"verified": "14.361",
+18 -13
View File
@@ -33,27 +33,32 @@ 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). 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: "slaBpnOpen",
title: game.i18n.localize("SLABPN.ToolbarOpen"),
icon: "fas fa-file-contract",
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);
if (controls && !Array.isArray(controls)) {
const grp = controls.tokens ?? controls.token ?? null;
if (grp) {
grp.tools ??= {};
grp.tools[tool.name] = tool;
}
return;
}
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; }
}
});