mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
[PR] [Feature] Refresh actors when a homebrew setting is changed (#1382)
* Refresh actors when a homebrew setting is changed * Newline at end of file * Close open prosemirror documents during reset
This commit is contained in:
parent
99d0eab5bd
commit
e8dd38fbfa
1 changed files with 25 additions and 0 deletions
|
|
@ -46,6 +46,9 @@ const registerMenuSettings = () => {
|
||||||
if (value.maxFear) {
|
if (value.maxFear) {
|
||||||
if (ui.resources) ui.resources.render({ force: true });
|
if (ui.resources) ui.resources.render({ force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some homebrew settings may change sheets in various ways, so trigger a re-render
|
||||||
|
resetActors();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -140,3 +143,25 @@ const registerNonConfigSettings = () => {
|
||||||
type: DhTagTeamRoll
|
type: DhTagTeamRoll
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers a reset and non-forced re-render on all given actors (if given)
|
||||||
|
* or all world actors and actors in all scenes to show immediate results for a changed setting.
|
||||||
|
*/
|
||||||
|
function resetActors(actors) {
|
||||||
|
actors ??= [
|
||||||
|
game.actors.contents,
|
||||||
|
game.scenes.contents.flatMap(s => s.tokens.contents).flatMap(t => t.actor ?? [])
|
||||||
|
].flat();
|
||||||
|
actors = new Set(actors);
|
||||||
|
for (const actor of actors) {
|
||||||
|
for (const app of Object.values(actor.apps)) {
|
||||||
|
for (const element of app.element?.querySelectorAll('prose-mirror.active')) {
|
||||||
|
element.open = false; // This triggers a save
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actor.reset();
|
||||||
|
actor.render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue