DiceSoNice Animation Overrides (#1726)

* .

* .

* Fixed hope/fear animation input
This commit is contained in:
WBHarry 2026-03-12 23:34:13 +01:00 committed by GitHub
parent dd376705a9
commit 308a04e6c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 242 additions and 95 deletions

View file

@ -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}