fix: scene controls PC Status button for Foundry v14 API (v1.6.4)
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"id": "zero-engine",
|
"id": "zero-engine",
|
||||||
"title": "Zero Engine (SLA Industries)",
|
"title": "Zero Engine (SLA Industries)",
|
||||||
"description": "A basic game system for SLA Industries using the Zero Engine rules.",
|
"description": "A basic game system for SLA Industries using the Zero Engine rules.",
|
||||||
"version": "1.6.3",
|
"version": "1.6.4",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": 13,
|
"minimum": 13,
|
||||||
"verified": "14.359"
|
"verified": "14.359"
|
||||||
|
|||||||
+37
-11
@@ -3742,19 +3742,45 @@ Hooks.once("setup", () => {
|
|||||||
* Ready hook
|
* Ready hook
|
||||||
*/
|
*/
|
||||||
// ── GM SCENE CONTROLS: PC STATUS BUTTON ──────────────────────────────────────
|
// ── GM SCENE CONTROLS: PC STATUS BUTTON ──────────────────────────────────────
|
||||||
// Adds a clipboard-list icon to the Token layer toolbar (GM only).
|
// Adds a standalone clipboard icon to the scene controls toolbar (GM only).
|
||||||
// Click it any time to whisper yourself a full PC conditions report.
|
// Foundry v14 uses an object-keyed API; v13 uses an array — handle both.
|
||||||
Hooks.on("getSceneControlButtons", (controls) => {
|
Hooks.on("getSceneControlButtons", (controls) => {
|
||||||
if (!game.user?.isGM) return;
|
if (!game.user?.isGM) return;
|
||||||
const tokenGroup = controls.find(c => c.name === "token");
|
|
||||||
if (!tokenGroup) return;
|
const tool = {
|
||||||
tokenGroup.tools.push({
|
name: "sla-pc-status",
|
||||||
name: "sla-pc-status",
|
title: "PC Status Report",
|
||||||
title: "PC Status Report",
|
icon: "fas fa-clipboard-list",
|
||||||
icon: "fas fa-clipboard-list",
|
visible: true,
|
||||||
button: 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() {
|
Hooks.once('ready', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user