Add ability to toggle between list and card views

This commit is contained in:
IrkTheImp 2025-06-27 18:50:55 -05:00
parent c6cede40b2
commit 798c07dffe
6 changed files with 66 additions and 43 deletions

View file

@ -25,6 +25,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
toggleStress: this.toggleStress,
toggleHope: this.toggleHope,
toggleGold: this.toggleGold,
toggleLoadoutView: this.toggleLoadoutView,
attackRoll: this.attackRoll,
useDomainCard: this.useDomainCard,
removeCard: this.removeDomainCard,
@ -291,7 +292,8 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
loadout: {
top: loadout.slice(0, Math.min(2, nrLoadoutCards)),
bottom: nrLoadoutCards > 2 ? loadout.slice(2, Math.min(5, nrLoadoutCards)) : [],
nrTotal: nrLoadoutCards
nrTotal: nrLoadoutCards,
listView: this.document.system.layout.listView
},
vault: vault.map(x => ({
...x,
@ -447,6 +449,11 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
await this.document.update({ [update]: newValue });
}
static async toggleLoadoutView(_, button) {
const listView = !(button.dataset.value === 'true');
await this.document.update({ 'system.layout.listView': listView });
}
static async attackRoll(event, button) {
const weapon = await fromUuid(button.dataset.weapon);
if (!weapon) return;

View file

@ -90,6 +90,9 @@ export default class DhCharacter extends BaseDataActor {
attack: new fields.NumberField({ integer: true, initial: 0 }),
spellcast: new fields.NumberField({ integer: true, initial: 0 }),
armorScore: new fields.NumberField({ integer: true, initial: 0 })
}),
layout: new fields.SchemaField({
listView: new fields.BooleanField({ initial: true })
})
};
}