Add ability to toggle between list and card views (#188)

* Add ability to toggle between list and card views

* set the list display as a user flag

* Fixed domainCard cardlist rendering

---------

Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
IrkTheImp 2025-06-28 10:53:40 -05:00 committed by GitHub
parent 1f5b5f9915
commit 1135669d0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 122 additions and 60 deletions

View file

@ -26,6 +26,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
toggleHope: this.toggleHope,
toggleGold: this.toggleGold,
toggleLoadoutView: this.toggleLoadoutView,
attackRoll: this.attackRoll,
useDomainCard: this.useDomainCard,
removeCard: this.removeDomainCard,
selectClass: this.selectClass,
@ -391,7 +392,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: game.user.getFlag(SYSTEM.id, SYSTEM.FLAGS.displayDomainCardsAsList)
},
vault: vault.map(x => ({
...x,
@ -553,6 +555,22 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
this.render();
}
static async toggleLoadoutView(_, button) {
const newAbilityView = !(button.dataset.value === 'true');
await game.user.setFlag(SYSTEM.id, SYSTEM.FLAGS.displayDomainCardsAsList, newAbilityView);
this.render();
}
static async attackRoll(event, button) {
const weapon = await fromUuid(button.dataset.weapon);
if (!weapon) return;
const wasUsed = await weapon.use(event);
if (wasUsed) {
Hooks.callAll(SYSTEM.HOOKS.characterAttack, {});
}
}
static levelManagement() {
if (this.document.system.needsCharacterSetup) {
this.characterSetup();
@ -753,7 +771,9 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
const cls = getDocumentClass('ChatMessage');
const systemData = {
name: game.i18n.localize('DAGGERHEART.General.Experience.Single'),
description: `${experience.description} ${experience.total < 0 ? experience.total : `+${experience.total}`}`
description: `${experience.description} ${
experience.total < 0 ? experience.total : `+${experience.total}`
}`
};
const msg = new cls({
type: 'abilityUse',
@ -778,7 +798,9 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
? this.document.system.multiclass.subclass
: this.document.system.class.subclass;
const ability = item.system[`${button.dataset.key}Feature`];
const title = `${item.name} - ${game.i18n.localize(`DAGGERHEART.Sheets.PC.DomainCard.${capitalize(button.dataset.key)}Title`)}`;
const title = `${item.name} - ${game.i18n.localize(
`DAGGERHEART.Sheets.PC.DomainCard.${capitalize(button.dataset.key)}Title`
)}`;
const cls = getDocumentClass('ChatMessage');
const systemData = {