Merge branch 'make-all-resources-available-in-default-token-config' into 'master'
feat: allow selecting all resources in the combat tracker config and the default token config See merge request dungeonslayers/ds4!169
This commit is contained in:
commit
6d6322a845
3 changed files with 33 additions and 1 deletions
|
@ -38,7 +38,7 @@ const config = {
|
||||||
assetFileNames: "[name].[ext]",
|
assetFileNames: "[name].[ext]",
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
typescript({ noEmitOnError: true }),
|
typescript(),
|
||||||
styles({
|
styles({
|
||||||
mode: ["extract", `css/${name}.css`],
|
mode: ["extract", `css/${name}.css`],
|
||||||
url: false,
|
url: false,
|
||||||
|
|
|
@ -24,6 +24,7 @@ import { createCheckRoll } from "../rolls/check-factory";
|
||||||
import { DS4Roll } from "../rolls/roll";
|
import { DS4Roll } from "../rolls/roll";
|
||||||
import registerSlayingDiceModifier from "../rolls/slaying-dice-modifier";
|
import registerSlayingDiceModifier from "../rolls/slaying-dice-modifier";
|
||||||
import { registerSystemSettings } from "../settings";
|
import { registerSystemSettings } from "../settings";
|
||||||
|
import { DS4TokenDocument } from "../token-document";
|
||||||
|
|
||||||
export default function registerForInitHook(): void {
|
export default function registerForInitHook(): void {
|
||||||
Hooks.once("init", init);
|
Hooks.once("init", init);
|
||||||
|
@ -47,6 +48,7 @@ async function init() {
|
||||||
CONFIG.Item.documentClass = DS4Item;
|
CONFIG.Item.documentClass = DS4Item;
|
||||||
CONFIG.ActiveEffect.documentClass = DS4ActiveEffect;
|
CONFIG.ActiveEffect.documentClass = DS4ActiveEffect;
|
||||||
CONFIG.ChatMessage.documentClass = DS4ChatMessage;
|
CONFIG.ChatMessage.documentClass = DS4ChatMessage;
|
||||||
|
CONFIG.Token.documentClass = DS4TokenDocument;
|
||||||
|
|
||||||
CONFIG.Actor.typeLabels = DS4.i18n.actorTypes;
|
CONFIG.Actor.typeLabels = DS4.i18n.actorTypes;
|
||||||
CONFIG.Item.typeLabels = DS4.i18n.itemTypes;
|
CONFIG.Item.typeLabels = DS4.i18n.itemTypes;
|
||||||
|
|
30
src/token-document.ts
Normal file
30
src/token-document.ts
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue