fix: scene controls PC Status button for Foundry v14 API (v1.6.4)

This commit is contained in:
2026-06-10 18:02:25 +01:00
parent c09de0b476
commit d47871ea38
2 changed files with 38 additions and 12 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"id": "zero-engine",
"title": "Zero Engine (SLA Industries)",
"description": "A basic game system for SLA Industries using the Zero Engine rules.",
"version": "1.6.3",
"version": "1.6.4",
"compatibility": {
"minimum": 13,
"verified": "14.359"
+33 -7
View File
@@ -3742,19 +3742,45 @@ Hooks.once("setup", () => {
* Ready hook
*/
// ── GM SCENE CONTROLS: PC STATUS BUTTON ──────────────────────────────────────
// Adds a clipboard-list icon to the Token layer toolbar (GM only).
// Click it any time to whisper yourself a full PC conditions report.
// Adds a standalone clipboard icon to the scene controls toolbar (GM only).
// Foundry v14 uses an object-keyed API; v13 uses an array — handle both.
Hooks.on("getSceneControlButtons", (controls) => {
if (!game.user?.isGM) return;
const tokenGroup = controls.find(c => c.name === "token");
if (!tokenGroup) return;
tokenGroup.tools.push({
const tool = {
name: "sla-pc-status",
title: "PC Status Report",
icon: "fas fa-clipboard-list",
visible: true,
button: true,
onClick: () => _broadcastPCConditions()
});
onChange: () => _broadcastPCConditions(), // v14
onClick: () => _broadcastPCConditions() // v13 compat
};
// Foundry v14: controls is a plain object keyed by group name
if (controls && !Array.isArray(controls)) {
// Add as a standalone top-level button (no sub-tools; fires on click)
controls["sla-gm-tools"] = {
name: "sla-gm-tools",
title: "SLA GM Tools",
icon: "fas fa-clipboard-list",
visible: true,
button: true,
onChange: () => _broadcastPCConditions()
};
return;
}
// Foundry v13 fallback: controls is an array
const tokenGroup = controls.find(c => c.name === "token" || c.name === "tokens");
if (tokenGroup) {
tokenGroup.tools ??= [];
if (Array.isArray(tokenGroup.tools)) {
tokenGroup.tools.push(tool);
} else {
tokenGroup.tools["sla-pc-status"] = tool;
}
}
});
Hooks.once('ready', function() {