Add files via upload
fixed a bug that prevented proper load order if `renderCompendiumDirectory` gets called during `init`v0.1.11
parent
d4b2b2e0ea
commit
af1f4d6298
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* @author Felix Müller aka syl3r86
|
* @author Felix Müller aka syl3r86
|
||||||
* @version 0.1.5
|
* @version 0.1.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SpellBrowser extends Application {
|
class SpellBrowser extends Application {
|
||||||
|
@ -10,7 +10,9 @@ class SpellBrowser extends Application {
|
||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
Hooks.on('ready', e => {
|
Hooks.on('ready', e => {
|
||||||
this.initSettings();
|
if (this.settings === undefined) {
|
||||||
|
this.initSettings();
|
||||||
|
}
|
||||||
|
|
||||||
this.loadSpells().then(obj => {
|
this.loadSpells().then(obj => {
|
||||||
this.spells = obj
|
this.spells = obj
|
||||||
|
@ -53,6 +55,9 @@ class SpellBrowser extends Application {
|
||||||
|
|
||||||
hookCompendiumList() {
|
hookCompendiumList() {
|
||||||
Hooks.on('renderCompendiumDirectory', (app, html, data) => {
|
Hooks.on('renderCompendiumDirectory', (app, html, data) => {
|
||||||
|
if (this.settings === undefined) {
|
||||||
|
this.initSettings();
|
||||||
|
}
|
||||||
if (game.user.isGM || this.settings.allowSpellBrowser || this.settings.allowNpcBrowser) {
|
if (game.user.isGM || this.settings.allowSpellBrowser || this.settings.allowNpcBrowser) {
|
||||||
const importButton = $(`<button class="compendium-browser-btn"><i class="fas fa-fire"></i> ${game.i18n.localize("CMPBrowser.compendiumBrowser")}</button>`);
|
const importButton = $(`<button class="compendium-browser-btn"><i class="fas fa-fire"></i> ${game.i18n.localize("CMPBrowser.compendiumBrowser")}</button>`);
|
||||||
html.find('.compendium-browser-btn').remove();
|
html.find('.compendium-browser-btn').remove();
|
||||||
|
@ -646,7 +651,7 @@ class SpellBrowser extends Application {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// load settings from container and apply to default settings (available compendie might have changed)
|
// load settings from container and apply to default settings (available compendie might have changed)
|
||||||
let settings = game.settings.get('compendiumBrowser', 'settings');
|
let settings = game.settings.get('compendiumBrowser', 'settings');
|
||||||
for (let compKey in defaultSettings.loadedSpellCompendium) {
|
for (let compKey in defaultSettings.loadedSpellCompendium) {
|
||||||
|
@ -661,7 +666,7 @@ class SpellBrowser extends Application {
|
||||||
}
|
}
|
||||||
defaultSettings.allowSpellBrowser = settings.allowSpellBrowser;
|
defaultSettings.allowSpellBrowser = settings.allowSpellBrowser;
|
||||||
defaultSettings.allowNpcBrowser = settings.allowNpcBrowser;
|
defaultSettings.allowNpcBrowser = settings.allowNpcBrowser;
|
||||||
|
|
||||||
game.settings.set('compendiumBrowser', 'settings', defaultSettings);
|
game.settings.set('compendiumBrowser', 'settings', defaultSettings);
|
||||||
this.settings = defaultSettings;
|
this.settings = defaultSettings;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "compendium-browser",
|
"name": "compendium-browser",
|
||||||
"title": "Compendium Browser",
|
"title": "Compendium Browser",
|
||||||
"description": "A module to easily browse and filter spells as well as npcs loaded from compendie.",
|
"description": "A module to easily browse and filter spells as well as npcs loaded from compendie.",
|
||||||
"version": "0.1.8",
|
"version": "0.1.9",
|
||||||
"author": "Felix#6196",
|
"author": "Felix#6196",
|
||||||
"systems": ["dnd5e"],
|
"systems": ["dnd5e"],
|
||||||
"scripts": ["./compendium-browser.js"],
|
"scripts": ["./compendium-browser.js"],
|
||||||
|
|
Loading…
Reference in New Issue