Update types

This commit is contained in:
Johannes Loher 2021-02-05 02:35:47 +01:00
parent cd86857b43
commit 2641b1ee74
5 changed files with 38 additions and 38 deletions

2
package-lock.json generated
View file

@ -3119,7 +3119,7 @@
} }
}, },
"foundry-vtt-types": { "foundry-vtt-types": {
"version": "github:League-of-Foundry-Developers/foundry-vtt-types#4890983e397a28026b0a38c4081fb284ff97020a", "version": "github:League-of-Foundry-Developers/foundry-vtt-types#dc5ff5a9c75cda3f4999603221275ed8d7d9212c",
"from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9",
"dev": true, "dev": true,
"requires": { "requires": {

View file

@ -1,3 +1,4 @@
import { DS4 } from "../../config";
import { DS4Item } from "../../item/item"; import { DS4Item } from "../../item/item";
import { DS4ItemData, ItemType } from "../../item/item-data"; import { DS4ItemData, ItemType } from "../../item/item-data";
import { DS4Actor } from "../actor"; import { DS4Actor } from "../actor";
@ -55,7 +56,7 @@ export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
const data = { const data = {
...super.getData(), ...super.getData(),
// Add the localization config to the data: // Add the localization config to the data:
config: CONFIG.DS4, config: DS4,
// Add the items explicitly sorted by type to the data: // Add the items explicitly sorted by type to the data:
itemsByType: this.actor.itemTypes, itemsByType: this.actor.itemTypes,
}; };

View file

@ -35,8 +35,7 @@ Hooks.once("init", async function () {
// Configure Dice // Configure Dice
CONFIG.Dice.types = [Die, DS4Check]; // TODO(types) fix upstream CONFIG.Dice.types = [Die, DS4Check]; // TODO(types) fix upstream
CONFIG.Dice.terms = { CONFIG.Dice.terms = {
c: Coin, ...CONFIG.Dice.terms,
d: Die,
s: DS4Check, s: DS4Check,
}; };
@ -88,12 +87,12 @@ Hooks.once("setup", function () {
const noSort = ["attributes", "traits", "combatValues", "creatureSizeCategories"]; const noSort = ["attributes", "traits", "combatValues", "creatureSizeCategories"];
// Localize and sort CONFIG objects // Localize and sort CONFIG objects
for (const o of Object.keys(CONFIG.DS4.i18n)) { for (const o of Object.keys(DS4.i18n)) {
const localized = Object.entries(CONFIG.DS4.i18n[o]).map((e) => { const localized = Object.entries(DS4.i18n[o]).map((e) => {
return [e[0], game.i18n.localize(e[1] as string)]; return [e[0], game.i18n.localize(e[1] as string)];
}); });
if (!noSort.includes(o)) localized.sort((a, b) => a[1].localeCompare(b[1])); if (!noSort.includes(o)) localized.sort((a, b) => a[1].localeCompare(b[1]));
CONFIG.DS4.i18n[o] = localized.reduce((obj, e) => { DS4.i18n[o] = localized.reduce((obj, e) => {
obj[e[0]] = e[1]; obj[e[0]] = e[1];
return obj; return obj;
}, {}); }, {});

View file

@ -1,3 +1,4 @@
import { DS4 } from "../config";
import { DS4Item } from "./item"; import { DS4Item } from "./item";
import { isDS4ItemDataTypePhysical } from "./item-data"; import { isDS4ItemDataTypePhysical } from "./item-data";
@ -47,7 +48,7 @@ export class DS4ItemSheet extends ItemSheet<unknown, DS4Item> {
getData(): ItemSheet.Data<DS4Item> { getData(): ItemSheet.Data<DS4Item> {
const data = { const data = {
...super.getData(), ...super.getData(),
config: CONFIG.DS4, config: DS4,
isOwned: this.item.isOwned, isOwned: this.item.isOwned,
actor: this.item.actor, actor: this.item.actor,
isPhysical: isDS4ItemDataTypePhysical(this.item.data.data), isPhysical: isDS4ItemDataTypePhysical(this.item.data.data),

View file

@ -34,7 +34,7 @@ class CheckFactory {
private checkOptions: DS4CheckFactoryOptions; private checkOptions: DS4CheckFactoryOptions;
async execute(): Promise<ChatMessage | unknown> { async execute(): Promise<ChatMessage | unknown> {
const rollCls: typeof Roll = CONFIG.Dice.rolls[0]; const rollCls = CONFIG.Dice.rolls[0];
const formula = [ const formula = [
"ds", "ds",
@ -131,16 +131,14 @@ async function askGmModifier(
const renderedHtml = await renderTemplate(usedTemplate, templateData); const renderedHtml = await renderTemplate(usedTemplate, templateData);
const dialogPromise = new Promise<HTMLFormElement>((resolve) => { const dialogPromise = new Promise<HTMLFormElement>((resolve) => {
new Dialog({ new Dialog(
{
title: usedTitle, title: usedTitle,
close: () => {
// Don't do anything
},
content: renderedHtml, content: renderedHtml,
buttons: { buttons: {
ok: { ok: {
label: game.i18n.localize("DS4.RollDialogOkButton"), label: game.i18n.localize("DS4.RollDialogOkButton"),
callback: (html: HTMLElement | JQuery) => { callback: (html) => {
if (!("jquery" in html)) { if (!("jquery" in html)) {
throw new Error( throw new Error(
game.i18n.format("DS4.ErrorUnexpectedHtmlType", { game.i18n.format("DS4.ErrorUnexpectedHtmlType", {
@ -153,16 +151,17 @@ async function askGmModifier(
resolve(innerForm); resolve(innerForm);
} }
}, },
icon: "", // TODO(types): Remove once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/266 is fixed
}, },
cancel: { cancel: {
label: game.i18n.localize("DS4.RollDialogCancelButton"), label: game.i18n.localize("DS4.RollDialogCancelButton"),
callback: () => { icon: "", // TODO(types): Remove once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/266 is fixed
// Don't do anything
},
}, },
}, },
default: "ok", default: "ok",
}).render(true); },
{}, // TODO(types): Remove once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/267 is resolved
).render(true);
}); });
const dialogForm = await dialogPromise; const dialogForm = await dialogPromise;
return parseDialogFormData(dialogForm); return parseDialogFormData(dialogForm);