From 1a27fa7e9752bcf388978286490f67d1821d49e8 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sat, 12 Feb 2022 04:01:38 +0100 Subject: [PATCH 1/2] feat: allow selecting all resources in the combat tracker config and the default token config --- src/hooks/init.ts | 2 ++ src/token-document.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/token-document.ts diff --git a/src/hooks/init.ts b/src/hooks/init.ts index 75353d2e..45264fe4 100644 --- a/src/hooks/init.ts +++ b/src/hooks/init.ts @@ -24,6 +24,7 @@ import { createCheckRoll } from "../rolls/check-factory"; import { DS4Roll } from "../rolls/roll"; import registerSlayingDiceModifier from "../rolls/slaying-dice-modifier"; import { registerSystemSettings } from "../settings"; +import { DS4TokenDocument } from "../token-document"; export default function registerForInitHook(): void { Hooks.once("init", init); @@ -47,6 +48,7 @@ async function init() { CONFIG.Item.documentClass = DS4Item; CONFIG.ActiveEffect.documentClass = DS4ActiveEffect; CONFIG.ChatMessage.documentClass = DS4ChatMessage; + CONFIG.Token.documentClass = DS4TokenDocument; CONFIG.Actor.typeLabels = DS4.i18n.actorTypes; CONFIG.Item.typeLabels = DS4.i18n.itemTypes; diff --git a/src/token-document.ts b/src/token-document.ts new file mode 100644 index 00000000..0491f13e --- /dev/null +++ b/src/token-document.ts @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: 2021 Johannes Loher +// +// SPDX-License-Identifier: MIT + +import { DS4Actor } from "./actor/actor"; +import { getGame } from "./helpers"; + +let fallbackData: foundry.data.ActorData["data"] | undefined = undefined; + +function getFallbackData() { + if (!fallbackData) { + fallbackData = {} as foundry.data.ActorData["data"]; + for (const type of getGame().system.template.Actor?.types ?? []) { + foundry.utils.mergeObject( + fallbackData, + new DS4Actor({ type: type as foundry.data.ActorData["type"], name: "temporary" }).data.data, + ); + } + } + return fallbackData; +} + +export class DS4TokenDocument extends TokenDocument { + static getTrackedAttributes(data?: foundry.data.ActorData["data"], _path: string[] = []) { + if (!data) { + data = getFallbackData(); + } + return super.getTrackedAttributes(data, _path); + } +} From ad1fd150b731e9b159171fda49a232ab0305be70 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sat, 12 Feb 2022 04:18:49 +0100 Subject: [PATCH 2/2] build: don't fail watching on compile error --- rollup.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollup.config.js b/rollup.config.js index 7a6a8c4a..98331152 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -38,7 +38,7 @@ const config = { assetFileNames: "[name].[ext]", }, plugins: [ - typescript({ noEmitOnError: true }), + typescript(), styles({ mode: ["extract", `css/${name}.css`], url: false,