37: Fix custom attribute token bars being marked as not editable in token HUD

This commit is contained in:
Lich 2022-01-05 18:42:52 +00:00 committed by Andrew
parent 93d86fc459
commit e723598a6c
2 changed files with 15 additions and 0 deletions

View file

@ -10,6 +10,7 @@ import { SimpleItemSheet } from "./item-sheet.js";
import { SimpleActorSheet } from "./actor-sheet.js"; import { SimpleActorSheet } from "./actor-sheet.js";
import { preloadHandlebarsTemplates } from "./templates.js"; import { preloadHandlebarsTemplates } from "./templates.js";
import { createWorldbuildingMacro } from "./macro.js"; import { createWorldbuildingMacro } from "./macro.js";
import { SimpleTokenDocument } from "./simpletokendocument.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Foundry VTT Initialization */ /* Foundry VTT Initialization */
@ -40,6 +41,9 @@ Hooks.once("init", async function() {
CONFIG.Actor.documentClass = SimpleActor; CONFIG.Actor.documentClass = SimpleActor;
CONFIG.Item.documentClass = SimpleItem; CONFIG.Item.documentClass = SimpleItem;
// Update TokenDocument with overrided getBarAttribute method
CONFIG.Token.documentClass = SimpleTokenDocument;
// Register sheet application classes // Register sheet application classes
Actors.unregisterSheet("core", ActorSheet); Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("worldbuilding", SimpleActorSheet, { makeDefault: true }); Actors.registerSheet("worldbuilding", SimpleActorSheet, { makeDefault: true });

View file

@ -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;
}
}