switch to foundry-vtt-types
This commit is contained in:
parent
6e10d4b093
commit
62cc5a0e7c
13 changed files with 713 additions and 84 deletions
|
@ -3,7 +3,9 @@ import { DS4 } from "../config";
|
|||
|
||||
export type ItemType = keyof typeof DS4.itemTypes;
|
||||
|
||||
export type DS4ItemDataType =
|
||||
export type DS4ItemData = Item.Data<DS4ItemDataType>;
|
||||
|
||||
type DS4ItemDataType =
|
||||
| DS4Weapon
|
||||
| DS4Armor
|
||||
| DS4Shield
|
||||
|
|
|
@ -1,19 +1,37 @@
|
|||
import { DS4Item } from "./item";
|
||||
import { DS4ItemDataType, isDS4ItemDataTypePhysical } from "./item-data";
|
||||
import { isDS4ItemDataTypePhysical } from "./item-data";
|
||||
|
||||
/**
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
* @extends {ItemSheet}
|
||||
*/
|
||||
export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
|
||||
// TODO(types): provide proper types for all generic parameters
|
||||
export class DS4ItemSheet extends ItemSheet<unknown, DS4Item> {
|
||||
/** @override */
|
||||
static get defaultOptions(): FormApplicationOptions {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
static get defaultOptions(): BaseEntitySheet.Options {
|
||||
const superDefaultOptions = super.defaultOptions;
|
||||
return mergeObject(superDefaultOptions, {
|
||||
width: 530,
|
||||
height: 400,
|
||||
classes: ["ds4", "sheet", "item"],
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }],
|
||||
scrollY: [".sheet-body"],
|
||||
template: superDefaultOptions.template,
|
||||
viewPermission: superDefaultOptions.viewPermission,
|
||||
closeOnSubmit: superDefaultOptions.closeOnSubmit,
|
||||
submitOnChange: superDefaultOptions.submitOnChange,
|
||||
submitOnClose: superDefaultOptions.submitOnClose,
|
||||
editable: superDefaultOptions.editable,
|
||||
baseApplication: superDefaultOptions.baseApplication,
|
||||
top: superDefaultOptions.top,
|
||||
left: superDefaultOptions.left,
|
||||
popOut: superDefaultOptions.popOut,
|
||||
minimizable: superDefaultOptions.minimizable,
|
||||
resizable: superDefaultOptions.resizable,
|
||||
id: superDefaultOptions.id,
|
||||
dragDrop: superDefaultOptions.dragDrop,
|
||||
filters: superDefaultOptions.filters,
|
||||
title: superDefaultOptions.title,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -26,7 +44,7 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
|
|||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
getData(): ItemSheetData<DS4ItemDataType, DS4Item> {
|
||||
getData(): ItemSheet.Data<DS4Item> {
|
||||
const data = {
|
||||
...super.getData(),
|
||||
config: CONFIG.DS4,
|
||||
|
@ -41,11 +59,11 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
|
|||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
setPosition(options: ApplicationPosition = {}): ApplicationPosition {
|
||||
setPosition(options: Partial<Application.Position> = {}): Application.Position {
|
||||
const position = super.setPosition(options);
|
||||
if ("find" in this.element) {
|
||||
const sheetBody = this.element.find(".sheet-body");
|
||||
const bodyHeight = position.height - 192;
|
||||
const bodyHeight = (position.height as number) - 192; // TODO: remove type cast once https://github.com/kmoschcau/foundry-vtt-types/pull/214 is merged
|
||||
sheetBody.css("height", bodyHeight);
|
||||
} else {
|
||||
console.log("Failure setting position.");
|
||||
|
@ -81,7 +99,7 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
|
|||
case "create":
|
||||
return this._createActiveEffect();
|
||||
case "edit":
|
||||
const effect = this.item.effects.get(li.data("effectId"));
|
||||
const effect = this.item["effects"].get(li.data("effectId")); // TODO replace with item.effect once https://github.com/kmoschcau/foundry-vtt-types/pull/216 is merged
|
||||
return effect.sheet.render(true);
|
||||
case "delete": {
|
||||
return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId"));
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import { DS4Actor } from "../actor/actor";
|
||||
import { DS4ActorDataType } from "../actor/actor-data";
|
||||
import { DS4ItemDataType, DS4Talent } from "./item-data";
|
||||
import { DS4ItemData, DS4Talent } from "./item-data";
|
||||
|
||||
/**
|
||||
* Extend the basic Item with some very simple modifications.
|
||||
* @extends {Item}
|
||||
*/
|
||||
export class DS4Item extends Item<DS4ItemDataType, DS4ActorDataType, DS4Actor> {
|
||||
export class DS4Item extends Item<DS4ItemData> {
|
||||
/**
|
||||
* Augment the basic Item data model with additional dynamic data.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue