bol/module/item/item-sheet.js

82 lines
2.4 KiB
JavaScript
Raw Normal View History

2021-11-01 00:28:42 +01:00
import { BoLUtility } from "../system/bol-utility.js";
2021-07-08 10:12:12 +02:00
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
*/
export class BoLItemSheet extends ItemSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["bol", "sheet", "item"],
template: "systems/bol/templates/item/item-sheet.hbs",
2021-07-08 10:12:12 +02:00
width: 520,
height: 480,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }]
});
}
// /** @override */
// get template() {
// const path = "systems/bol/templates/item";
// // Return a single sheet for all item types.
// //return `${path}/item-sheet.hbs`;
// // Alternatively, you could use the following return statement to do a
// // unique item sheet by type, like `weapon-sheet.html`.
// return `${path}/item-${this.item.data.type}-sheet.hbs`;
// }
2021-07-08 10:12:12 +02:00
/* -------------------------------------------- */
/** @override */
getData() {
2021-11-08 14:40:29 +01:00
const objectData = BoLUtility.data(this.item);
// const objectData = BoLUtility.data(this.object);
2021-11-01 00:28:42 +01:00
2021-11-08 14:40:29 +01:00
let itemData = foundry.utils.deepClone(BoLUtility.templateData(this.item));
2021-11-01 00:28:42 +01:00
let formData = {
title: this.title,
id: this.id,
2021-11-08 14:40:29 +01:00
config: game.bol.config,
2021-11-01 00:28:42 +01:00
type: objectData.type,
img: objectData.img,
name: objectData.name,
editable: this.isEditable,
cssClass: this.isEditable ? "editable" : "locked",
data: itemData,
limited: this.object.limited,
options: this.options,
owner: this.document.isOwner,
2021-11-08 14:40:29 +01:00
isGM: game.user.isGM,
itemProperties : this.item.itemProperties
2021-11-01 00:28:42 +01:00
}
console.log("ITEMDATA", formData);
this.options.editable = !(this.object.data.origin == "embeddedItem");
return formData;
2021-07-08 10:12:12 +02:00
}
/* -------------------------------------------- */
/** @override */
setPosition(options = {}) {
const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192;
sheetBody.css("height", bodyHeight);
return position;
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
super.activateListeners(html);
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
// Roll handlers, click handlers, etc. would go here.
}
2021-11-08 14:40:29 +01:00
2021-07-08 10:12:12 +02:00
}