From e723598a6cd022014df4297ec6f0e65320786453 Mon Sep 17 00:00:00 2001 From: Lich Date: Wed, 5 Jan 2022 18:42:52 +0000 Subject: [PATCH] 37: Fix custom attribute token bars being marked as not editable in token HUD --- module/simple.js | 4 ++++ module/simpletokendocument.js | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 module/simpletokendocument.js diff --git a/module/simple.js b/module/simple.js index d42b182..059bea6 100644 --- a/module/simple.js +++ b/module/simple.js @@ -10,6 +10,7 @@ import { SimpleItemSheet } from "./item-sheet.js"; import { SimpleActorSheet } from "./actor-sheet.js"; import { preloadHandlebarsTemplates } from "./templates.js"; import { createWorldbuildingMacro } from "./macro.js"; +import { SimpleTokenDocument } from "./simpletokendocument.js"; /* -------------------------------------------- */ /* Foundry VTT Initialization */ @@ -39,6 +40,9 @@ Hooks.once("init", async function() { // Define custom Document classes CONFIG.Actor.documentClass = SimpleActor; CONFIG.Item.documentClass = SimpleItem; + + // Update TokenDocument with overrided getBarAttribute method + CONFIG.Token.documentClass = SimpleTokenDocument; // Register sheet application classes Actors.unregisterSheet("core", ActorSheet); diff --git a/module/simpletokendocument.js b/module/simpletokendocument.js new file mode 100644 index 0000000..dd63f65 --- /dev/null +++ b/module/simpletokendocument.js @@ -0,0 +1,11 @@ +export class SimpleTokenDocument extends TokenDocument { + + /** @inheritdoc */ + getBarAttribute(barName, {alternative}={}) { + const attr = super.getBarAttribute(barName, {alternative}); + if ( attr === null ) return null; + attr.editable = true; // Attribute always editable, super requires attr to exist in actor template + return attr; + } + +} \ No newline at end of file