enhance card items (#75)

This commit is contained in:
Murilo Brito 2025-05-29 07:07:09 -03:00 committed by GitHub
parent 917bcd7056
commit c34c923406
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 727 additions and 534 deletions

View file

@ -3,9 +3,9 @@ export { default as DhpAdversarySheet } from './sheets/adversary.mjs';
export { default as DhpClassSheet } from './sheets/class.mjs';
export { default as DhpSubclass } from './sheets/subclass.mjs';
export { default as DhpFeatureSheet } from './sheets/items/feature.mjs';
export { default as DhpDomainCardSheet } from './sheets/domainCard.mjs';
export { default as DhpAncestry } from './sheets/ancestry.mjs';
export { default as DhpCommunity } from './sheets/community.mjs';
export { default as DhpDomainCardSheet } from './sheets/items/domainCard.mjs';
export { default as DhpAncestry } from './sheets/items/ancestry.mjs';
export { default as DhpCommunity } from './sheets/items/community.mjs';
export { default as DhpMiscellaneous } from './sheets/items/miscellaneous.mjs';
export { default as DhpConsumable } from './sheets/items/consumable.mjs';
export { default as DhpWeapon } from './sheets/items/weapon.mjs';

View file

@ -1,122 +0,0 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class AncestrySheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "ancestry";
// constructor(options){
// super(options);
// }
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "heritage"],
// width: 600,
// height: 'auto',
// dragDrop: [{ dragSelector: null, dropSelector: null }],
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// return context;
// }
// async _handleAction(action, event, button) {
// switch(action){
// case 'editAbility':
// this.editAbility(button);
// break;
// case 'deleteAbility':
// this.deleteAbility(event);
// break;
// }
// }
// async editAbility(button){
// const feature = await fromUuid(button.dataset.ability);
// feature.sheet.render(true);
// }
// async deleteAbility(event){
// event.preventDefault();
// event.stopPropagation();
// await this.item.update({ "system.abilities": this.item.system.abilities.filter(x => x.uuid !== event.currentTarget.dataset.ability) })
// }
// async _onDrop(event) {
// const data = TextEditor.getDragEventData(event);
// const item = await fromUuid(data.uuid);
// if(item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.ancestry.id) {
// await this.object.update({ "system.abilities": [...this.item.system.abilities, { img: item.img, name: item.name, uuid: item.uuid }] });
// }
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class AncestrySheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'sheet', 'heritage'],
position: { width: 600 },
actions: {
editAbility: this.editAbility,
deleteAbility: this.deleteAbility
},
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false
},
dragDrop: [{ dragSelector: null, dropSelector: null }]
};
static PARTS = {
form: {
id: 'feature',
template: 'systems/daggerheart/templates/sheets/ancestry.hbs'
}
};
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object);
this.render();
}
static async editAbility(_, button) {
const feature = await fromUuid(button.dataset.ability);
feature.sheet.render(true);
}
static async deleteAbility(event, button) {
event.preventDefault();
event.stopPropagation();
await this.item.update({
'system.abilities': this.item.system.abilities.filter(x => x.uuid !== button.dataset.ability)
});
}
async _onDrop(event) {
const data = TextEditor.getDragEventData(event);
const item = await fromUuid(data.uuid);
if (item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.ancestry.id) {
await this.document.update({
'system.abilities': [
...this.document.system.abilities,
{ img: item.img, name: item.name, uuid: item.uuid }
]
});
}
}
}

View file

@ -1,122 +0,0 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class CommunitySheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "community";
// constructor(options){
// super(options);
// }
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "heritage"],
// width: 600,
// height: 'auto',
// dragDrop: [{ dragSelector: null, dropSelector: null }],
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// return context;
// }
// async _handleAction(action, event, button) {
// switch(action){
// case 'editAbility':
// this.editAbility(button);
// break;
// case 'deleteAbility':
// this.deleteAbility(event);
// break;
// }
// }
// async editAbility(button){
// const feature = await fromUuid(button.dataset.ability);
// feature.sheet.render(true);
// }
// async deleteAbility(event){
// event.preventDefault();
// event.stopPropagation();
// await this.item.update({ "system.abilities": this.item.system.abilities.filter(x => x.uuid !== event.currentTarget.dataset.ability) })
// }
// async _onDrop(event) {
// const data = TextEditor.getDragEventData(event);
// const item = await fromUuid(data.uuid);
// if(item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.community.id) {
// await this.object.update({ "system.abilities": [...this.item.system.abilities, { img: item.img, name: item.name, uuid: item.uuid }] });
// }
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class CommunitySheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'sheet', 'heritage'],
position: { width: 600 },
actions: {
editAbility: this.editAbility,
deleteAbility: this.deleteAbility
},
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false
},
dragDrop: [{ dragSelector: null, dropSelector: null }]
};
static PARTS = {
form: {
id: 'feature',
template: 'systems/daggerheart/templates/sheets/community.hbs'
}
};
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object);
this.render();
}
static async editAbility(_, button) {
const feature = await fromUuid(button.dataset.ability);
feature.sheet.render(true);
}
static async deleteAbility(event, button) {
event.preventDefault();
event.stopPropagation();
await this.item.update({
'system.abilities': this.item.system.abilities.filter(x => x.uuid !== button.dataset.ability)
});
}
async _onDrop(event) {
const data = TextEditor.getDragEventData(event);
const item = await fromUuid(data.uuid);
if (item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.community.id) {
await this.document.update({
'system.abilities': [
...this.document.system.abilities,
{ img: item.img, name: item.name, uuid: item.uuid }
]
});
}
}
}

View file

@ -0,0 +1,88 @@
import DaggerheartSheet from '../daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class AncestrySheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'sheet', 'item', 'dh-style', 'ancestry'],
position: { width: 450, height: 700 },
actions: {
editFeature: this.editFeature,
deleteFeature: this.deleteFeature
},
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false
},
dragDrop: [{ dragSelector: null, dropSelector: null }]
};
static PARTS = {
header: { template: 'systems/daggerheart/templates/sheets/items/ancestry/header.hbs' },
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
features: {
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-feature-section.hbs',
scrollable: ['.features']
}
};
static TABS = {
description: {
active: true,
cssClass: '',
group: 'primary',
id: 'description',
icon: null,
label: 'DAGGERHEART.Sheets.Feature.Tabs.Description'
},
features: {
active: false,
cssClass: '',
group: 'primary',
id: 'features',
icon: null,
label: 'DAGGERHEART.Sheets.Feature.Tabs.Features'
}
};
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
context.tabs = super._getTabs(this.constructor.TABS);
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object);
this.render();
}
static async editFeature(_, target) {
const feature = await fromUuid(target.dataset.feature);
feature.sheet.render(true);
}
static async deleteFeature(event, target) {
event.preventDefault();
event.stopPropagation();
await this.item.update({
'system.abilities': this.item.system.abilities.filter(x => x.uuid !== target.dataset.feature)
});
}
async _onDrop(event) {
const data = TextEditor.getDragEventData(event);
const item = await fromUuid(data.uuid);
if (item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.ancestry.id) {
await this.document.update({
'system.abilities': [
...this.document.system.abilities,
{ img: item.img, name: item.name, uuid: item.uuid }
]
});
}
}
}

View file

@ -4,7 +4,7 @@ const { ItemSheetV2 } = foundry.applications.sheets;
export default class ArmorSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'sheet', 'dh-style', 'armor'],
classes: ['daggerheart', 'sheet', 'item', 'dh-style', 'armor'],
position: { width: 600 },
form: {
handler: this.updateForm,

View file

@ -0,0 +1,88 @@
import DaggerheartSheet from '../daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class CommunitySheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'sheet', 'item', 'dh-style', 'community'],
position: { width: 450, height: 700 },
actions: {
editFeature: this.editFeature,
deleteFeature: this.deleteFeature
},
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false
},
dragDrop: [{ dragSelector: null, dropSelector: null }]
};
static PARTS = {
header: { template: 'systems/daggerheart/templates/sheets/items/community/header.hbs' },
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
features: {
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-feature-section.hbs',
scrollable: ['.features']
}
};
static TABS = {
description: {
active: true,
cssClass: '',
group: 'primary',
id: 'description',
icon: null,
label: 'DAGGERHEART.Sheets.Feature.Tabs.Description'
},
features: {
active: false,
cssClass: '',
group: 'primary',
id: 'features',
icon: null,
label: 'DAGGERHEART.Sheets.Feature.Tabs.Features'
}
};
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
context.tabs = super._getTabs(this.constructor.TABS);
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object);
this.render();
}
static async editFeature(_, target) {
const feature = await fromUuid(target.dataset.feature);
feature.sheet.render(true);
}
static async deleteFeature(event, target) {
event.preventDefault();
event.stopPropagation();
await this.item.update({
'system.abilities': this.item.system.abilities.filter(x => x.uuid !== target.dataset.feature)
});
}
async _onDrop(event) {
const data = TextEditor.getDragEventData(event);
const item = await fromUuid(data.uuid);
if (item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.community.id) {
await this.document.update({
'system.abilities': [
...this.document.system.abilities,
{ img: item.img, name: item.name, uuid: item.uuid }
]
});
}
}
}

View file

@ -4,7 +4,7 @@ const { ItemSheetV2 } = foundry.applications.sheets;
export default class ConsumableSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'sheet', 'dh-style', 'consumable'],
classes: ['daggerheart', 'sheet', 'item', 'dh-style', 'consumable'],
position: { width: 550 },
form: {
handler: this.updateForm,

View file

@ -1,45 +1,13 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class DomainCardSheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "domainCard";
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "domain-card"],
// width: 600,
// height: 600,
// tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// context.config = CONFIG.daggerheart;
// return context;
// }
// async _handleAction(action, event, button) {
// switch(action){
// case 'attributeRoll':
// break;
// }
// }
// }
import DaggerheartAction from '../../data/action.mjs';
import DaggerheartActionConfig from '../config/Action.mjs';
import DaggerheartSheet from './daggerheart-sheet.mjs';
import DaggerheartAction from '../../../data/action.mjs';
import DaggerheartActionConfig from '../../config/Action.mjs';
import DaggerheartSheet from '../daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class DomainCardSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'sheet', 'domain-card'],
position: { width: 600, height: 600 },
classes: ['daggerheart', 'sheet', 'item', 'dh-style', 'domain-card'],
position: { width: 450, height: 700 },
actions: {
addAction: this.addAction,
editAction: this.editAction,
@ -53,29 +21,50 @@ export default class DomainCardSheet extends DaggerheartSheet(ItemSheetV2) {
};
static PARTS = {
form: {
id: 'feature',
template: 'systems/daggerheart/templates/sheets/domainCard.hbs'
header: { template: 'systems/daggerheart/templates/sheets/items/domainCard/header.hbs' },
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
actions: {
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-actions.hbs',
scrollable: ['.actions']
},
settings: {
template: 'systems/daggerheart/templates/sheets/items/domainCard/settings.hbs',
scrollable: ['.settings']
}
};
_getTabs() {
const tabs = {
general: { active: true, cssClass: '', group: 'primary', id: 'general', icon: null, label: 'General' },
actions: { active: false, cssClass: '', group: 'primary', id: 'actions', icon: null, label: 'Actions' }
};
for (const v of Object.values(tabs)) {
v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active;
v.cssClass = v.active ? 'active' : '';
static TABS = {
description: {
active: true,
cssClass: '',
group: 'primary',
id: 'description',
icon: null,
label: 'DAGGERHEART.Sheets.Feature.Tabs.Description'
},
actions: {
active: false,
cssClass: '',
group: 'primary',
id: 'actions',
icon: null,
label: 'DAGGERHEART.Sheets.Feature.Tabs.Actions'
},
settings: {
active: false,
cssClass: '',
group: 'primary',
id: 'settings',
icon: null,
label: 'DAGGERHEART.Sheets.Feature.Tabs.Settings'
}
return tabs;
}
};
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.config = CONFIG.daggerheart;
context.tabs = this._getTabs();
context.tabs = super._getTabs(this.constructor.TABS);
return context;
}

View file

@ -13,7 +13,7 @@ export default class FeatureSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
id: 'daggerheart-feature',
classes: ['daggerheart', 'sheet', 'dh-style', 'feature'],
classes: ['daggerheart', 'sheet', 'item', 'dh-style', 'feature'],
position: { width: 600, height: 600 },
window: { resizable: true },
actions: {
@ -35,7 +35,7 @@ export default class FeatureSheet extends DaggerheartSheet(ItemSheetV2) {
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
actions: {
template: 'systems/daggerheart/templates/sheets/items/feature/actions.hbs',
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-actions.hbs',
scrollable: ['.actions']
},
settings: {

View file

@ -1,32 +1,10 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class MiscellaneousSheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "miscellaneous";
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "miscellaneous"],
// width: 400,
// height: 'auto',
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// return context;
// }
// }
import DaggerheartSheet from '../daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class MiscellaneousSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'sheet', 'dh-style', 'miscellaneous'],
classes: ['daggerheart', 'sheet', 'item', 'dh-style', 'miscellaneous'],
position: { width: 550 },
form: {
handler: this.updateForm,

View file

@ -4,7 +4,7 @@ const { ItemSheetV2 } = foundry.applications.sheets;
export default class WeaponSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'sheet', 'dh-style', 'weapon'],
classes: ['daggerheart', 'sheet', 'item', 'dh-style', 'weapon'],
position: { width: 600 },
form: {
handler: this.updateForm,