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
|
|
@ -1,19 +1,19 @@
|
|||
export default class DhAppearance extends foundry.abstract.DataModel {
|
||||
static LOCALIZATION_PREFIXES = ['DAGGERHEART.SETTINGS.Appearance'];
|
||||
|
||||
static sfxSchema = () =>
|
||||
new foundry.data.fields.SchemaField({
|
||||
class: new foundry.data.fields.StringField({
|
||||
nullable: true,
|
||||
initial: null,
|
||||
blank: true,
|
||||
choices: CONFIG.DH.GENERAL.diceSoNiceSFXClasses
|
||||
})
|
||||
});
|
||||
|
||||
static defineSchema() {
|
||||
const { StringField, ColorField, BooleanField, SchemaField } = foundry.data.fields;
|
||||
|
||||
const sfxSchema = () =>
|
||||
new SchemaField({
|
||||
class: new StringField({
|
||||
nullable: true,
|
||||
initial: null,
|
||||
blank: true,
|
||||
choices: CONFIG.DH.GENERAL.diceSoNiceSFXClasses
|
||||
})
|
||||
});
|
||||
|
||||
// helper to create dice style schema
|
||||
const diceStyle = ({ fg, bg, outline, edge }) =>
|
||||
new SchemaField({
|
||||
|
|
@ -27,7 +27,7 @@ export default class DhAppearance extends foundry.abstract.DataModel {
|
|||
system: new StringField({ initial: 'standard', required: true, blank: false }),
|
||||
font: new StringField({ initial: 'auto', required: true, blank: false }),
|
||||
sfx: new SchemaField({
|
||||
higher: sfxSchema()
|
||||
higher: DhAppearance.sfxSchema()
|
||||
})
|
||||
});
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ export default class DhAppearance extends foundry.abstract.DataModel {
|
|||
advantage: diceStyle({ fg: '#ffffff', bg: '#008000', outline: '#000000', edge: '#ffffff' }),
|
||||
disadvantage: diceStyle({ fg: '#000000', bg: '#b30000', outline: '#ffffff', edge: '#000000' }),
|
||||
sfx: new SchemaField({
|
||||
critical: sfxSchema()
|
||||
critical: DhAppearance.sfxSchema()
|
||||
})
|
||||
}),
|
||||
extendCharacterDescriptions: new BooleanField(),
|
||||
|
|
@ -81,4 +81,48 @@ export default class DhAppearance extends foundry.abstract.DataModel {
|
|||
showGenericStatusEffects: new BooleanField({ initial: true })
|
||||
};
|
||||
}
|
||||
|
||||
get diceSoNiceData() {
|
||||
const globalOverrides = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.GlobalOverrides);
|
||||
const getSFX = (baseClientData, overrideKey) => {
|
||||
if (!globalOverrides.diceSoNice.sfx.overrideEnabled) return baseClientData;
|
||||
const overrideData = globalOverrides.diceSoNice.sfx[overrideKey];
|
||||
const clientData = foundry.utils.deepClone(baseClientData);
|
||||
return Object.keys(clientData).reduce((acc, key) => {
|
||||
const data = clientData[key];
|
||||
acc[key] = Object.keys(data).reduce((acc, dataKey) => {
|
||||
const value = data[dataKey];
|
||||
acc[dataKey] = value ? value : overrideData[key][dataKey];
|
||||
return acc;
|
||||
}, {});
|
||||
return acc;
|
||||
}, {});
|
||||
};
|
||||
|
||||
return {
|
||||
...this.diceSoNice,
|
||||
sfx: getSFX(this.diceSoNice.sfx, 'global'),
|
||||
hope: {
|
||||
...this.diceSoNice.hope,
|
||||
sfx: getSFX(this.diceSoNice.hope.sfx, 'hope')
|
||||
},
|
||||
fear: {
|
||||
...this.diceSoNice.fear,
|
||||
sfx: getSFX(this.diceSoNice.fear.sfx, 'fear')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** Invoked by the setting when data changes */
|
||||
handleChange() {
|
||||
if (this.displayFear) {
|
||||
if (ui.resources) {
|
||||
if (this.displayFear === 'hide') ui.resources.close({ allowed: true });
|
||||
else ui.resources.render({ force: true });
|
||||
}
|
||||
}
|
||||
|
||||
const globalOverrides = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.GlobalOverrides);
|
||||
globalOverrides.diceSoNiceSFXUpdate(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue