Begin playing around with the weapon sheet
This commit is contained in:
parent
d1cb412e5a
commit
91c95da639
8 changed files with 256 additions and 4 deletions
|
|
@ -15,6 +15,7 @@ import { ItemProxy } from "./documents/Item/_proxy.mjs";
|
|||
|
||||
// Item Sheets
|
||||
import { UntypedItemSheet } from "./sheets/Items/UntypedItemSheet.mjs";
|
||||
import { WeaponSheet } from "./sheets/Items/WeaponSheet.mjs";
|
||||
import { AspectSheet } from "./sheets/Items/AspectSheet.mjs";
|
||||
import { SpellSheet } from "./sheets/Items/SpellSheet.mjs";
|
||||
import { PetSheet } from "./sheets/Items/PetSheet.mjs";
|
||||
|
|
@ -95,6 +96,11 @@ Hooks.once(`init`, async () => {
|
|||
types: ["aspect"],
|
||||
label: "dotdungeon.sheet-names.AspectSheet"
|
||||
});
|
||||
Items.registerSheet("dotdungeon", WeaponSheet, {
|
||||
makeDefault: true,
|
||||
types: ["weapon"],
|
||||
label: "dotdungeon.sheet-names.WeaponSheet"
|
||||
});
|
||||
Items.registerSheet("dotdungeon", SpellSheet, {
|
||||
makeDefault: true,
|
||||
types: ["spell"],
|
||||
|
|
|
|||
|
|
@ -32,11 +32,15 @@ export const partials = [
|
|||
`actors/char-sheet/v2/partials/inventory/items/weapon.v2.pc.hbs`,
|
||||
`actors/char-sheet/v2/partials/inventory/items/pet.v2.pc.hbs`,
|
||||
|
||||
// The v2 Untyped sheet partials
|
||||
// The partials used for Untyped v2 and other item sheets that don't have a
|
||||
// unique design for the other tabs
|
||||
`items/untyped/v2/tabs/general.v2.untyped.hbs`,
|
||||
`items/untyped/v2/tabs/details.v2.untyped.hbs`,
|
||||
`items/untyped/v2/tabs/effects.v2.untyped.hbs`,
|
||||
`items/untyped/v2/tabs/settings.v2.untyped.hbs`,
|
||||
|
||||
// The weapon sheet partials
|
||||
`items/weapon/v1/tabs/details.v1.weapon.hbs`,
|
||||
];
|
||||
|
||||
export const preAliasedPartials = {
|
||||
|
|
|
|||
116
module/sheets/Items/WeaponSheet.mjs
Normal file
116
module/sheets/Items/WeaponSheet.mjs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
import { GenericContextMenu } from "../../utils/GenericContextMenu.mjs";
|
||||
import { DialogManager } from "../../utils/DialogManager.mjs";
|
||||
import { GenericItemSheet } from "./GenericItemSheet.mjs";
|
||||
import { localizer } from "../../utils/localizer.mjs";
|
||||
|
||||
export class WeaponSheet extends GenericItemSheet {
|
||||
static get defaultOptions() {
|
||||
let opts = foundry.utils.mergeObject(
|
||||
super.defaultOptions,
|
||||
{
|
||||
template: `systems/dotdungeon/templates/items/weapon/v1/index.hbs`,
|
||||
width: 300,
|
||||
height: 340,
|
||||
tabs: [
|
||||
{
|
||||
group: `page`,
|
||||
navSelector: `nav.page`,
|
||||
contentSelector: `.page-content`,
|
||||
initial: `general`,
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
opts.classes.push(`dotdungeon`, `style-v3`);
|
||||
return opts;
|
||||
};
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
new GenericContextMenu(html, `.photo.panel`, [
|
||||
{
|
||||
name: localizer(`dotdungeon.common.view-larger`),
|
||||
callback: () => {
|
||||
(new ImagePopout(this.item.img)).render(true);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: localizer(`dotdungeon.common.edit`),
|
||||
condition: () => this.isEditable,
|
||||
callback: () => {
|
||||
const fp = new FilePicker({
|
||||
callback: (path) => {
|
||||
this.item.update({"img": path});
|
||||
},
|
||||
});
|
||||
fp.render(true);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: localizer(`dotdungeon.common.reset`),
|
||||
condition: () => this.isEditable,
|
||||
callback: () => {
|
||||
console.log(`.dungeon | Reset Item Image`)
|
||||
},
|
||||
}
|
||||
]);
|
||||
|
||||
if (!this.isEditable) return;
|
||||
console.debug(`.dungeon | Adding event listeners for Weapon Item: ${this.item.id}`);
|
||||
|
||||
html.find(`.create-ae`).on(`click`, async () => {
|
||||
await this.item.createEmbeddedDocuments(
|
||||
`ActiveEffect`,
|
||||
[{name: localizer(`dotdungeon.default.name`, { document: `ActiveEffect`, type: `base` })}],
|
||||
{ renderSheet: true }
|
||||
);
|
||||
});
|
||||
|
||||
new GenericContextMenu(html, `.effect.panel`, [
|
||||
{
|
||||
name: localizer(`dotdungeon.common.edit`),
|
||||
callback: async (html) => {
|
||||
(await fromUuid(html.closest(`.effect`)[0].dataset.embeddedId))?.sheet.render(true);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: localizer(`dotdungeon.common.delete`),
|
||||
callback: async (html) => {
|
||||
const target = html.closest(`.effect`)[0];
|
||||
const data = target.dataset;
|
||||
const id = data.embeddedId;
|
||||
const doc = await fromUuid(id);
|
||||
DialogManager.createOrFocus(
|
||||
`${doc.uuid}-delete`,
|
||||
{
|
||||
title: localizer(`dotdungeon.delete.ActiveEffect.title`, doc),
|
||||
content: localizer(`dotdungeon.delete.ActiveEffect.content`, doc),
|
||||
buttons: {
|
||||
yes: {
|
||||
label: localizer(`Yes`),
|
||||
callback() {
|
||||
doc.delete();
|
||||
},
|
||||
},
|
||||
no: {
|
||||
label: localizer(`No`),
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
async getData() {
|
||||
const ctx = await super.getData();
|
||||
|
||||
ctx.meta.showSettingsTab = ctx.isGM || this.item.isOwned;
|
||||
ctx.meta.isEmbedded = this.item.isOwned;
|
||||
ctx.meta.isEditable = this.isEditable;
|
||||
|
||||
return ctx;
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue