v0.5.1 — fix scene-control button on Foundry v14 (tokens group + onChange)
Button registered on notes/onClick did not appear on v14. Now matches the Zero Engine system pattern: token group, visible+button, onChange. Open via the skull icon in the token toolbar or game.slaBlueprintNewsZero.open(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -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",
|
||||
|
||||
+24
-14
@@ -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; }
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user