mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
DiceSoNice Animation Overrides (#1726)
* . * . * Fixed hope/fear animation input
This commit is contained in:
parent
dd376705a9
commit
308a04e6c5
12 changed files with 242 additions and 95 deletions
|
|
@ -50,7 +50,8 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
{ id: 'hope', label: 'DAGGERHEART.GENERAL.hope' },
|
||||
{ id: 'fear', label: 'DAGGERHEART.GENERAL.fear' },
|
||||
{ id: 'advantage', label: 'DAGGERHEART.GENERAL.Advantage.full' },
|
||||
{ id: 'disadvantage', label: 'DAGGERHEART.GENERAL.Disadvantage.full' }
|
||||
{ id: 'disadvantage', label: 'DAGGERHEART.GENERAL.Disadvantage.full' },
|
||||
{ id: 'general', label: 'DAGGERHEART.GENERAL.general' }
|
||||
],
|
||||
initial: 'hope'
|
||||
}
|
||||
|
|
@ -70,6 +71,14 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
}
|
||||
}
|
||||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
htmlElement
|
||||
.querySelector('.default-animations-input')
|
||||
?.addEventListener('change', this.toggleSFXOverride.bind(this));
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
_configureRenderParts(options) {
|
||||
const parts = super._configureRenderParts(options);
|
||||
|
|
@ -83,15 +92,20 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
/**@inheritdoc */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
if (options.isFirstRender)
|
||||
if (options.isFirstRender) {
|
||||
this.setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance);
|
||||
this.globalOverrides = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.GlobalOverrides);
|
||||
}
|
||||
|
||||
context.setting = this.setting;
|
||||
context.globalOverrides = this.globalOverrides;
|
||||
context.fields = this.setting.schema.fields;
|
||||
|
||||
context.tabs = this._prepareTabs('general');
|
||||
context.dsnTabs = this._prepareTabs('diceSoNice');
|
||||
|
||||
context.isGM = game.user.isGM;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
|
|
@ -162,6 +176,7 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
(acc, key) => ({
|
||||
...acc,
|
||||
[key]: {
|
||||
diceTab: key !== 'general',
|
||||
values: this.setting.diceSoNice[key],
|
||||
fields: this.setting.schema.getField(`diceSoNice.${key}`).fields,
|
||||
animations: ['hope', 'fear'].includes(key) ? getAnimationsOptions(key) : {}
|
||||
|
|
@ -188,6 +203,12 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
async toggleSFXOverride(event) {
|
||||
await this.globalOverrides.diceSoNiceSFXUpdate(this.setting, event.target.checked);
|
||||
this.globalOverrides = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.GlobalOverrides);
|
||||
this.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the configuration form.
|
||||
* @this {DHAppearanceSettings}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue