Merge branch '002-fix-default-token-config' into 'master'
fix: make the DDV Config work with the Default Token Config Closes #2 See merge request ghost/darkness-dependent-vision!14
This commit is contained in:
commit
5fb8e8ddc5
3 changed files with 21 additions and 2 deletions
|
@ -19,6 +19,7 @@ module.exports = {
|
||||||
plugins: [],
|
plugins: [],
|
||||||
|
|
||||||
globals: {
|
globals: {
|
||||||
|
DefaultTokenConfig: false,
|
||||||
PrototypeTokenDocument: false,
|
PrototypeTokenDocument: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,10 @@ export class DarknessDependentVisionConfig extends FormApplication {
|
||||||
return `${name}: ${game.i18n.localize('DarknessDependentVision.Title')}`;
|
return `${name}: ${game.i18n.localize('DarknessDependentVision.Title')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isDefault() {
|
||||||
|
return this.options.tokenConfig instanceof DefaultTokenConfig;
|
||||||
|
}
|
||||||
|
|
||||||
async getData() {
|
async getData() {
|
||||||
const data = this.isPrototype ? this.actor.data.token : this.token.data;
|
const data = this.isPrototype ? this.actor.data.token : this.token.data;
|
||||||
return {
|
return {
|
||||||
|
@ -69,9 +73,23 @@ export class DarknessDependentVisionConfig extends FormApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _updateObject(event, formData) {
|
async _updateObject(event, formData) {
|
||||||
|
// Configure the Default Token Configuration
|
||||||
|
if (this.isDefault) {
|
||||||
|
const current = game.settings.get('core', DefaultTokenConfig.SETTING);
|
||||||
|
const update = foundry.utils.mergeObject(current, formData, { inplace: false });
|
||||||
|
const result = await game.settings.set('core', DefaultTokenConfig.SETTING, update);
|
||||||
|
const tokenConfig = this.options.tokenConfig;
|
||||||
|
tokenConfig.data = new foundry.data.TokenData(result);
|
||||||
|
tokenConfig.object = new TokenDocument(tokenConfig.data, { actor: null });
|
||||||
|
tokenConfig.token = tokenConfig.object;
|
||||||
|
tokenConfig.render();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Configure the Prototype Token data of an Actor
|
// Configure the Prototype Token data of an Actor
|
||||||
if (this.isPrototype) return this.actor.update({ token: formData });
|
if (this.isPrototype) return this.actor.update({ token: formData });
|
||||||
|
|
||||||
// Update an embedded Token document
|
// Update an embedded Token document
|
||||||
else return this.token.update(formData);
|
return this.token.update(formData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ function onGetTokenConfigHeaderButtons(tokenConfig, buttons) {
|
||||||
class: 'configure-darkness-dependent-vision',
|
class: 'configure-darkness-dependent-vision',
|
||||||
icon: 'fas fa-eye',
|
icon: 'fas fa-eye',
|
||||||
onclick: async () => {
|
onclick: async () => {
|
||||||
return new DarknessDependentVisionConfig(tokenConfig.object).render(true);
|
return new DarknessDependentVisionConfig(tokenConfig.object, { tokenConfig }).render(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue