mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Added a Setting that controls if scroll texts should be shown on resource change (#578)
This commit is contained in:
parent
089657a896
commit
04fbf9db4f
7 changed files with 95 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import DHBaseActorSettings from '../../applications/sheets/api/actor-setting.mjs';
|
||||
import { createScrollText, getScrollTextData } from '../../helpers/utils.mjs';
|
||||
|
||||
const resistanceField = (resistanceLabel, immunityLabel, reductionLabel) =>
|
||||
new foundry.data.fields.SchemaField({
|
||||
|
|
@ -88,4 +89,28 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
|
|||
const data = { ...this };
|
||||
return data;
|
||||
}
|
||||
|
||||
async _preUpdate(changes, options, userId) {
|
||||
const allowed = await super._preUpdate(changes, options, userId);
|
||||
if (allowed === false) return;
|
||||
|
||||
const autoSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
|
||||
if (changes.system?.resources && autoSettings.resourceScrollTexts) {
|
||||
const textData = Object.keys(changes.system.resources).reduce((acc, key) => {
|
||||
const resource = changes.system.resources[key];
|
||||
if (resource.value !== undefined && resource.value !== this.resources[key].value) {
|
||||
acc.push(getScrollTextData(this.resources, resource, key));
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
options.scrollingTextData = textData;
|
||||
}
|
||||
}
|
||||
|
||||
_onUpdate(changes, options, userId) {
|
||||
super._onUpdate(changes, options, userId);
|
||||
|
||||
createScrollText(this.parent, options.scrollingTextData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue