2020-04-17 21:23:57 +00:00
|
|
|
/**
|
2020-04-21 16:06:33 +00:00
|
|
|
* Extend the basic ItemSheet
|
2020-04-17 21:23:57 +00:00
|
|
|
* @extends {ItemSheet}
|
|
|
|
*/
|
2021-06-10 22:57:01 +00:00
|
|
|
import {onManageActiveEffect, prepareActiveEffectCategories} from "./effects.js";
|
2021-09-20 22:39:57 +00:00
|
|
|
import { BladesActiveEffect } from "./blades-active-effect.js";
|
2021-06-10 22:57:01 +00:00
|
|
|
|
2020-04-21 16:06:33 +00:00
|
|
|
export class BladesItemSheet extends ItemSheet {
|
2020-04-17 21:23:57 +00:00
|
|
|
|
|
|
|
/** @override */
|
|
|
|
static get defaultOptions() {
|
2020-11-03 13:44:09 +00:00
|
|
|
|
2021-05-25 10:27:40 +00:00
|
|
|
return foundry.utils.mergeObject(super.defaultOptions, {
|
2023-11-28 22:06:09 +00:00
|
|
|
classes: ["beam-saber", "sheet", "item"],
|
2021-03-04 06:44:24 +00:00
|
|
|
width: 560,
|
2020-11-03 13:44:09 +00:00
|
|
|
height: 'auto',
|
2020-04-17 21:23:57 +00:00
|
|
|
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
2020-04-21 16:06:33 +00:00
|
|
|
/** @override */
|
|
|
|
get template() {
|
2023-11-28 22:06:09 +00:00
|
|
|
const path = "systems/beam-saber/templates/items";
|
2020-05-04 16:28:55 +00:00
|
|
|
let simple_item_types = ["background", "heritage", "vice", "crew_reputation"];
|
2022-09-03 15:44:26 +00:00
|
|
|
let template_name = `${this.item.type}`;
|
2020-04-23 16:11:04 +00:00
|
|
|
|
2022-09-03 15:44:26 +00:00
|
|
|
if (simple_item_types.indexOf(this.item.type) >= 0) {
|
2020-04-23 16:11:04 +00:00
|
|
|
template_name = "simple";
|
|
|
|
}
|
|
|
|
|
|
|
|
return `${path}/${template_name}.html`;
|
2020-04-21 16:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
2020-04-17 21:23:57 +00:00
|
|
|
/** @override */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
|
|
|
// Everything below here is only needed if the sheet is editable
|
|
|
|
if (!this.options.editable) return;
|
2021-06-10 22:57:01 +00:00
|
|
|
|
|
|
|
html.find(".effect-control").click(ev => {
|
|
|
|
if ( this.item.isOwned ) return ui.notifications.warn(game.i18n.localize("BITD.EffectWarning"))
|
2021-09-20 22:39:57 +00:00
|
|
|
BladesActiveEffect.onManageActiveEffect(ev, this.item)
|
2021-06-10 22:57:01 +00:00
|
|
|
});
|
2020-04-17 21:23:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2021-04-22 11:27:10 +00:00
|
|
|
|
|
|
|
/** @override */
|
2022-09-03 15:44:26 +00:00
|
|
|
async getData(options) {
|
|
|
|
const superData = super.getData( options );
|
|
|
|
const sheetData = superData.data;
|
|
|
|
|
|
|
|
sheetData.isGM = game.user.isGM;
|
|
|
|
sheetData.owner = superData.owner;
|
|
|
|
sheetData.editable = superData.editable;
|
2021-06-10 22:57:01 +00:00
|
|
|
|
|
|
|
// Prepare Active Effects
|
2022-09-03 15:44:26 +00:00
|
|
|
sheetData.effects = prepareActiveEffectCategories(this.document.effects);
|
|
|
|
|
|
|
|
sheetData.system.description = await TextEditor.enrichHTML(sheetData.system.description, {secrets: sheetData.owner, async: true});
|
2021-06-10 22:57:01 +00:00
|
|
|
|
2022-09-03 15:44:26 +00:00
|
|
|
return sheetData;
|
2021-04-22 11:27:10 +00:00
|
|
|
}
|
2020-04-17 21:23:57 +00:00
|
|
|
}
|