mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-07 21:34:16 +02:00
Add setting to hide party stats
This commit is contained in:
parent
85ca7efc6d
commit
cde1654f42
9 changed files with 212 additions and 142 deletions
|
|
@ -2822,6 +2822,15 @@
|
||||||
"hideObserverPermissionInChat": {
|
"hideObserverPermissionInChat": {
|
||||||
"label": "Hide Chat Info From Players",
|
"label": "Hide Chat Info From Players",
|
||||||
"hint": "Information such as hit/miss on attack rolls against adversaries will be hidden"
|
"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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,14 @@ export default class Party extends DHBaseActorSheet {
|
||||||
/* Prepare Context */
|
/* 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) {
|
async _preparePartContext(partId, context, options) {
|
||||||
context = await super._preparePartContext(partId, context, options);
|
context = await super._preparePartContext(partId, context, options);
|
||||||
switch (partId) {
|
switch (partId) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { defaultRestOptions } from '../../config/generalConfig.mjs';
|
import { defaultRestOptions } from '../../config/generalConfig.mjs';
|
||||||
|
import { resetAndRerenderActors } from '../../helpers/utils.mjs';
|
||||||
import { ActionsField } from '../fields/actionField.mjs';
|
import { ActionsField } from '../fields/actionField.mjs';
|
||||||
|
|
||||||
const currencyField = (initial, label, icon) =>
|
const currencyField = (initial, label, icon) =>
|
||||||
|
|
@ -209,7 +210,7 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.refreshConfig();
|
this.refreshConfig();
|
||||||
this.#resetActors();
|
resetAndRerenderActors();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update config values based on homebrew data. Make sure the references don't change */
|
/** 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 {
|
export class Resource extends foundry.abstract.DataModel {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { resetAndRerenderActors } from '../../helpers/utils.mjs';
|
||||||
|
|
||||||
export default class DhMetagaming extends foundry.abstract.DataModel {
|
export default class DhMetagaming extends foundry.abstract.DataModel {
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
@ -6,7 +8,24 @@ export default class DhMetagaming extends foundry.abstract.DataModel {
|
||||||
initial: false,
|
initial: false,
|
||||||
label: 'DAGGERHEART.SETTINGS.Metagaming.FIELDS.hideObserverPermissionInChat.label',
|
label: 'DAGGERHEART.SETTINGS.Metagaming.FIELDS.hideObserverPermissionInChat.label',
|
||||||
hint: 'DAGGERHEART.SETTINGS.Metagaming.FIELDS.hideObserverPermissionInChat.hint'
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
* 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.
|
* Similar to lodash's sortBy function.
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,10 @@ const registerMenuSettings = () => {
|
||||||
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Metagaming, {
|
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Metagaming, {
|
||||||
scope: 'world',
|
scope: 'world',
|
||||||
config: false,
|
config: false,
|
||||||
type: DhMetagaming
|
type: DhMetagaming,
|
||||||
|
onChange: value => {
|
||||||
|
value.handleChange();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew, {
|
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew, {
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
.actors-dragger {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<div>
|
<div>
|
||||||
{{formGroup settingFields.schema.fields.hideObserverPermissionInChat value=settingFields._source.hideObserverPermissionInChat localize=true}}
|
{{formGroup settingFields.schema.fields.hideObserverPermissionInChat value=settingFields._source.hideObserverPermissionInChat localize=true}}
|
||||||
|
{{formGroup settingFields.schema.fields.hidePartyStats value=settingFields._source.hidePartyStats localize=true}}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{#if @root.showStats}}
|
||||||
<ul class="actors-list">
|
<ul class="actors-list">
|
||||||
{{#each partyMembers as |member id|}}
|
{{#each partyMembers as |member id|}}
|
||||||
<li class="actor-resources">
|
<li class="actor-resources">
|
||||||
|
|
@ -160,6 +161,26 @@
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
{{else}}
|
||||||
|
<ul class="actors-list limited">
|
||||||
|
{{#each partyMembers as |member id|}}
|
||||||
|
<li class="actor-resources">
|
||||||
|
<div class="actor-img-frame">
|
||||||
|
<img class="actor-img" src="{{member.img}}">
|
||||||
|
</div>
|
||||||
|
<header>
|
||||||
|
<h2 class="actor-name">
|
||||||
|
<a data-action="openDocument" data-uuid="{{member.uuid}}">{{member.name}}</a>
|
||||||
|
<a class="delete-icon" data-action="deletePartyMember" data-uuid="{{member.uuid}}"><i class="fa-regular fa-times" inert></i></a>
|
||||||
|
</h2>
|
||||||
|
{{#if member.subtitle}}
|
||||||
|
<span class="subtitle">{{member.subtitle}}</span>
|
||||||
|
{{/if}}
|
||||||
|
</header>
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
{{/if}}
|
||||||
{{#unless document.system.partyMembers.length}}
|
{{#unless document.system.partyMembers.length}}
|
||||||
<div class="actors-dragger">
|
<div class="actors-dragger">
|
||||||
<span>{{localize "DAGGERHEART.GENERAL.dropActorsHere"}}</span>
|
<span>{{localize "DAGGERHEART.GENERAL.dropActorsHere"}}</span>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue