[Feature] Compedium Browser (#707)

* Create files

* Item Browser v0.5

* dialog with (temporary)

* Css

* initial style in compedium browser

* config

* fixes

* Replace compendium calls

* Level Up

* style compedium item list

* removing css files

---------

Co-authored-by: Dapoolp <elcatnet@gmail.com>
Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
Murilo Brito 2025-08-07 20:08:52 -03:00 committed by GitHub
parent a19c77ae4a
commit a25007b994
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 1650 additions and 123 deletions

View file

@ -1,5 +1,6 @@
import { abilities, subclassFeatureLabels } from '../../config/actorConfig.mjs';
import { getDeleteKeys, tagifyElement } from '../../helpers/utils.mjs';
import { ItemBrowser } from '../ui/itemBrowser.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
@ -11,6 +12,8 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
this._dragDrop = this._createDragDropHandlers();
this.tabGroups.primary = 'advancements';
this.itemBrowser = null;
}
get title() {
@ -533,8 +536,30 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
this.render();
}
static async viewCompendium(_, button) {
(await game.packs.get(`daggerheart.${button.dataset.compendium}`))?.render(true);
static async viewCompendium(event, target) {
const type = target.dataset.compendium ?? target.dataset.type;
const presets = {
compendium: 'daggerheart',
folder: type,
render: {
noFolder: true
}
};
if (type == 'domains') {
const domains = this.actor.system.domains,
multiclassDomain = this.levelup.classUpgradeChoices?.multiclass?.domain;
if (multiclassDomain) {
if (!domains.includes(x => x === multiclassDomain)) domains.push(multiclassDomain);
}
presets.filter = {
'level.max': { key: 'level.max', value: this.levelup.currentLevel },
'system.domain': { key: 'system.domain', value: domains }
};
}
return (this.itemBrowser = await new ItemBrowser({ presets }).render({ force: true }));
}
static async selectPreview(_, button) {
@ -635,6 +660,7 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
}, {});
await this.actor.levelUp(levelupData);
if (this.itemBrowser) this.itemBrowser.close();
this.close();
}
}