diff --git a/lang/en.json b/lang/en.json index 817fc355..aff0d60a 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2822,6 +2822,15 @@ "hideObserverPermissionInChat": { "label": "Hide Chat Info From Players", "hint": "Information such as hit/miss on attack rolls against adversaries will be hidden" + }, + "hidePartyStats": { + "label": "Hide Party Stats", + "hint": "Resources and stats in the party sheet's member list will be hidden to the following users, even if the user is part of the same party", + "choices": { + "never": "Never, always show", + "players": "Hide From Players", + "always": "Hide from Everyone" + } } } }, diff --git a/module/applications/sheets/actors/party.mjs b/module/applications/sheets/actors/party.mjs index a7eeccdf..403960c0 100644 --- a/module/applications/sheets/actors/party.mjs +++ b/module/applications/sheets/actors/party.mjs @@ -85,6 +85,14 @@ export default class Party extends DHBaseActorSheet { /* Prepare Context */ /* -------------------------------------------- */ + async _prepareContext(options) { + const context = await super._prepareContext(options); + const settings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Metagaming); + context.showStats = + settings.hidePartyStats === 'never' || (settings.hidePartyStats === 'players' && game.user.isGM); + return context; + } + async _preparePartContext(partId, context, options) { context = await super._preparePartContext(partId, context, options); switch (partId) { diff --git a/module/data/settings/Homebrew.mjs b/module/data/settings/Homebrew.mjs index b5e02675..31247458 100644 --- a/module/data/settings/Homebrew.mjs +++ b/module/data/settings/Homebrew.mjs @@ -1,4 +1,5 @@ import { defaultRestOptions } from '../../config/generalConfig.mjs'; +import { resetAndRerenderActors } from '../../helpers/utils.mjs'; import { ActionsField } from '../fields/actionField.mjs'; const currencyField = (initial, label, icon) => @@ -209,7 +210,7 @@ export default class DhHomebrew extends foundry.abstract.DataModel { } this.refreshConfig(); - this.#resetActors(); + resetAndRerenderActors(); } /** Update config values based on homebrew data. Make sure the references don't change */ @@ -230,29 +231,6 @@ export default class DhHomebrew extends foundry.abstract.DataModel { }); } } - - /** - * 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. - */ - #resetActors() { - const actors = new Set( - [ - game.actors.contents, - game.scenes.contents.flatMap(s => s.tokens.contents).flatMap(t => t.actor ?? []) - ].flat() - ); - 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(); - } - } } export class Resource extends foundry.abstract.DataModel { diff --git a/module/data/settings/Metagaming.mjs b/module/data/settings/Metagaming.mjs index 2bb5afdf..3694e09e 100644 --- a/module/data/settings/Metagaming.mjs +++ b/module/data/settings/Metagaming.mjs @@ -1,3 +1,5 @@ +import { resetAndRerenderActors } from '../../helpers/utils.mjs'; + export default class DhMetagaming extends foundry.abstract.DataModel { static defineSchema() { const fields = foundry.data.fields; @@ -6,7 +8,24 @@ export default class DhMetagaming extends foundry.abstract.DataModel { initial: false, label: 'DAGGERHEART.SETTINGS.Metagaming.FIELDS.hideObserverPermissionInChat.label', hint: 'DAGGERHEART.SETTINGS.Metagaming.FIELDS.hideObserverPermissionInChat.hint' + }), + hidePartyStats: new fields.StringField({ + initial: 'never', + label: 'DAGGERHEART.SETTINGS.Metagaming.FIELDS.hidePartyStats.label', + hint: 'DAGGERHEART.SETTINGS.Metagaming.FIELDS.hidePartyStats.hint', + required: true, + nullable: false, + choices: { + never: 'DAGGERHEART.SETTINGS.Metagaming.FIELDS.hidePartyStats.choices.never', + players: 'DAGGERHEART.SETTINGS.Metagaming.FIELDS.hidePartyStats.choices.players', + always: 'DAGGERHEART.SETTINGS.Metagaming.FIELDS.hidePartyStats.choices.always' + } }) }; } + + /** Invoked by the setting when data changes */ + handleChange() { + resetAndRerenderActors(); + } } diff --git a/module/helpers/utils.mjs b/module/helpers/utils.mjs index faa046ff..cec493b4 100644 --- a/module/helpers/utils.mjs +++ b/module/helpers/utils.mjs @@ -793,6 +793,26 @@ export function getArmorSources(actor) { }); } +/** + * 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. + */ +export function resetAndRerenderActors() { + const actors = new Set( + [game.actors.contents, game.scenes.contents.flatMap(s => s.tokens.contents).flatMap(t => t.actor ?? [])].flat() + ); + 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(); + } +} + /** * Returns an array sorted by a function that returns a thing to compare, or an array to compare in order * Similar to lodash's sortBy function. diff --git a/module/systemRegistration/settings.mjs b/module/systemRegistration/settings.mjs index 41cab011..a66323c7 100644 --- a/module/systemRegistration/settings.mjs +++ b/module/systemRegistration/settings.mjs @@ -91,7 +91,10 @@ const registerMenuSettings = () => { game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Metagaming, { scope: 'world', config: false, - type: DhMetagaming + type: DhMetagaming, + onChange: value => { + value.handleChange(); + } }); game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew, { diff --git a/styles/less/sheets/actors/party/party-members.less b/styles/less/sheets/actors/party/party-members.less index 2e2f4cf8..a29f7c88 100644 --- a/styles/less/sheets/actors/party/party-members.less +++ b/styles/less/sheets/actors/party/party-members.less @@ -280,6 +280,17 @@ body.game:is(.performance-low, .noblur) { } } + .actors-list.limited { + .actor-resources { + display: flex; + align-items: center; + } + .actor-img-frame { + width: 3rem; + height: 3rem; + } + } + .actors-dragger { display: flex; align-items: center; diff --git a/templates/settings/metagaming-settings/general.hbs b/templates/settings/metagaming-settings/general.hbs index 7f36715e..775ff016 100644 --- a/templates/settings/metagaming-settings/general.hbs +++ b/templates/settings/metagaming-settings/general.hbs @@ -1,3 +1,4 @@
{{formGroup settingFields.schema.fields.hideObserverPermissionInChat value=settingFields._source.hideObserverPermissionInChat localize=true}} + {{formGroup settingFields.schema.fields.hidePartyStats value=settingFields._source.hidePartyStats localize=true}}
\ No newline at end of file diff --git a/templates/sheets/actors/party/party-members.hbs b/templates/sheets/actors/party/party-members.hbs index aa41aeaa..c7870bc6 100644 --- a/templates/sheets/actors/party/party-members.hbs +++ b/templates/sheets/actors/party/party-members.hbs @@ -23,143 +23,164 @@ - + + {{/each}} + + {{else}} + + {{/if}} {{#unless document.system.partyMembers.length}}
{{localize "DAGGERHEART.GENERAL.dropActorsHere"}}