Update compendium-browser.js

pull/1/head
Matheus Clemente 2023-11-12 03:11:53 -03:00
parent ef6fa264e3
commit e335544bf6
1 changed files with 22 additions and 15 deletions

View File

@ -631,7 +631,12 @@ class CompendiumBrowser extends Application {
} }
hookCompendiumList(html) { hookCompendiumList(html) {
if (game.user.isGM || this.settings.allowSpellBrowser || this.settings.allowNpcBrowser) { if (game.user.isGM
|| this.settings.allowSpellBrowser
|| this.settings.allowNpcBrowser
|| this.settings.allowFeatBrowser
|| this.settings.allowItemBrowser) {
const cbButton = $( const cbButton = $(
`<button class="compendium-browser-btn"><i class="fas fa-fire"></i> ${game.i18n.localize( `<button class="compendium-browser-btn"><i class="fas fa-fire"></i> ${game.i18n.localize(
"CMPBrowser.compendiumBrowser" "CMPBrowser.compendiumBrowser"
@ -1304,14 +1309,20 @@ class CompendiumBrowser extends Application {
async addItemFilters() { async addItemFilters() {
this.addItemFilter("CMPBrowser.general", "DND5E.Source", "system.source", "text"); this.addItemFilter("CMPBrowser.general", "DND5E.Source", "system.source", "text");
this.addItemFilter("CMPBrowser.general", "Item Type", "type", "select", { this.addItemFilter(
consumable: "ITEM.TypeConsumable", "CMPBrowser.general",
backpack: "ITEM.TypeContainer", "Item Type",
equipment: "ITEM.TypeEquipment", "type",
loot: "ITEM.TypeLoot", "select",
tool: "ITEM.TypeTool", this._sortPackValues({
weapon: "ITEM.TypeWeapon", consumable: "ITEM.TypeConsumable",
}); backpack: "ITEM.TypeContainer",
equipment: "ITEM.TypeEquipment",
loot: "ITEM.TypeLoot",
tool: "ITEM.TypeTool",
weapon: "ITEM.TypeWeapon",
})
);
this.addItemFilter( this.addItemFilter(
"CMPBrowser.general", "CMPBrowser.general",
@ -1842,12 +1853,8 @@ Hooks.once("init", async () => {
}); });
Hooks.on("ready", () => { Hooks.on("ready", () => {
if (game.compendiumBrowser === undefined) { game.compendiumBrowser = new CompendiumBrowser();
game.compendiumBrowser = new CompendiumBrowser(); game.compendiumBrowser.initialize();
// 0.4.0 Defer loading content until we actually use the Compendium Browser
// A compromise approach would be better (periodic loading) except would still create the memory use problem
game.compendiumBrowser.initialize();
}
game.compendiumBrowser.addSpellFilters(); game.compendiumBrowser.addSpellFilters();
game.compendiumBrowser.addFeatFilters(); game.compendiumBrowser.addFeatFilters();