From 52466b2803adefea7e8579bb11f780e9cac89fe2 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 17 Aug 2025 15:12:39 +0200 Subject: [PATCH] Added a setting to hide attribution --- lang/en.json | 5 +++-- module/applications/sheets/actors/environment.mjs | 3 --- module/applications/sheets/api/application-mixin.mjs | 12 ++++++++++-- module/applications/sheets/api/base-actor.mjs | 3 +++ module/applications/sheets/api/base-item.mjs | 9 +++++++++ module/data/actor/base.mjs | 7 +++++++ module/data/settings/Appearance.mjs | 5 +++++ templates/settings/appearance-settings.hbs | 2 ++ templates/sheets/actors/adversary/notes.hbs | 2 +- templates/sheets/actors/environment/header.hbs | 4 ++-- templates/sheets/actors/environment/notes.hbs | 2 +- templates/sheets/global/tabs/tab-description.hbs | 2 +- templates/sheets/items/ancestry/header.hbs | 2 +- templates/sheets/items/community/header.hbs | 2 +- templates/sheets/items/domainCard/header.hbs | 2 +- 15 files changed, 47 insertions(+), 15 deletions(-) diff --git a/lang/en.json b/lang/en.json index a05d6da0..ee6ac23b 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2111,7 +2111,7 @@ "FIELDS": { "displayFear": { "label": "Fear Display" }, "dualityColorScheme": { "label": "Chat Style" }, - "showGenericStatusEffects": { "label": "Show Foundry Status Effects" }, + "hideAttribution": { "label": "Hide Attribution" }, "expandedTitle": "Auto-expand Descriptions", "extendCharacterDescriptions": { "label": "Characters" }, "extendAdversaryDescriptions": { "label": "Adversaries" }, @@ -2121,7 +2121,8 @@ "expandRollMessageDesc": { "label": "Description" }, "expandRollMessageRoll": { "label": "Formula" }, "expandRollMessageDamage": { "label": "Damage/Healing" }, - "expandRollMessageTarget": { "label": "Target" } + "expandRollMessageTarget": { "label": "Target" }, + "showGenericStatusEffects": { "label": "Show Foundry Status Effects" } }, "fearDisplay": { "token": "Tokens", diff --git a/module/applications/sheets/actors/environment.mjs b/module/applications/sheets/actors/environment.mjs index c2748a58..9fd003c6 100644 --- a/module/applications/sheets/actors/environment.mjs +++ b/module/applications/sheets/actors/environment.mjs @@ -50,9 +50,6 @@ export default class DhpEnvironment extends DHBaseActorSheet { case 'header': await this._prepareHeaderContext(context, options); - const { source, page } = this.document.system.attribution; - const attribution = [source, page ? `pg ${page}.` : null].filter(x => x).join('. '); - context.attributionLabel = attribution; break; case 'notes': await this._prepareNotesContext(context, options); diff --git a/module/applications/sheets/api/application-mixin.mjs b/module/applications/sheets/api/application-mixin.mjs index b03eb92d..15b84cff 100644 --- a/module/applications/sheets/api/application-mixin.mjs +++ b/module/applications/sheets/api/application-mixin.mjs @@ -132,8 +132,12 @@ export default function DHApplicationMixin(Base) { async _renderFrame(options) { const frame = await super._renderFrame(options); + const hideAttribution = game.settings.get( + CONFIG.DH.id, + CONFIG.DH.SETTINGS.gameSettings.appearance + ).hideAttribution; const headerAttribution = !this.#nonHeaderAttribution.includes(this.document.type); - if (this.document.system.metadata.hasAttribution && headerAttribution) { + if (!hideAttribution && this.document.system.metadata.hasAttribution && headerAttribution) { const { source, page } = this.document.system.attribution; const attribution = [source, page ? `pg ${page}.` : null].filter(x => x).join('. '); const element = ``; @@ -147,8 +151,12 @@ export default function DHApplicationMixin(Base) { * Refresh the custom parts of the application frame */ refreshFrame() { + const hideAttribution = game.settings.get( + CONFIG.DH.id, + CONFIG.DH.SETTINGS.gameSettings.appearance + ).hideAttribution; const headerAttribution = !this.#nonHeaderAttribution.includes(this.document.type); - if (this.document.system.metadata.hasAttribution && headerAttribution) { + if (!hideAttribution && this.document.system.metadata.hasAttribution && headerAttribution) { const { source, page } = this.document.system.attribution; const attribution = [source, page ? `pg ${page}.` : null].filter(x => x).join('. '); diff --git a/module/applications/sheets/api/base-actor.mjs b/module/applications/sheets/api/base-actor.mjs index 67cec44f..33c5a0e2 100644 --- a/module/applications/sheets/api/base-actor.mjs +++ b/module/applications/sheets/api/base-actor.mjs @@ -55,6 +55,9 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) { async _prepareContext(_options) { const context = await super._prepareContext(_options); context.isNPC = this.document.isNPC; + context.showAttribution = !game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance) + .hideAttribution; + return context; } diff --git a/module/applications/sheets/api/base-item.mjs b/module/applications/sheets/api/base-item.mjs index 6b548d2a..b4af283b 100644 --- a/module/applications/sheets/api/base-item.mjs +++ b/module/applications/sheets/api/base-item.mjs @@ -64,6 +64,15 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) { /* Prepare Context */ /* -------------------------------------------- */ + /**@inheritdoc */ + async _prepareContext(options) { + const context = super._prepareContext(options); + context.showAttribution = !game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance) + .hideAttribution; + + return context; + } + /**@inheritdoc */ async _preparePartContext(partId, context, options) { await super._preparePartContext(partId, context, options); diff --git a/module/data/actor/base.mjs b/module/data/actor/base.mjs index 36573325..bdb810dd 100644 --- a/module/data/actor/base.mjs +++ b/module/data/actor/base.mjs @@ -86,6 +86,13 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel { */ static DEFAULT_ICON = null; + get attributionLabel() { + if (!this.attribution) return; + + const { source, page } = this.attribution; + return [source, page ? `pg ${page}.` : null].filter(x => x).join('. '); + } + /* -------------------------------------------- */ /** diff --git a/module/data/settings/Appearance.mjs b/module/data/settings/Appearance.mjs index e493b187..36f6bb5a 100644 --- a/module/data/settings/Appearance.mjs +++ b/module/data/settings/Appearance.mjs @@ -89,6 +89,11 @@ export default class DhAppearance extends foundry.abstract.DataModel { initial: false, label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.expandRollMessageTarget.label' }) + }), + hideAttribution: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.hideAttribution.label' }) }; } diff --git a/templates/settings/appearance-settings.hbs b/templates/settings/appearance-settings.hbs index cd0fab3e..aa094d69 100644 --- a/templates/settings/appearance-settings.hbs +++ b/templates/settings/appearance-settings.hbs @@ -3,6 +3,8 @@

{{localize 'DAGGERHEART.SETTINGS.Menu.appearance.name'}}

+ {{formGroup settingFields.schema.fields.hideAttribution value=settingFields._source.hideAttribution localize=true}} +
{{localize 'DAGGERHEART.GENERAL.fear'}} {{formGroup settingFields.schema.fields.displayFear value=settingFields._source.displayFear localize=true}} diff --git a/templates/sheets/actors/adversary/notes.hbs b/templates/sheets/actors/adversary/notes.hbs index ef8ccf9d..a5c3f706 100644 --- a/templates/sheets/actors/adversary/notes.hbs +++ b/templates/sheets/actors/adversary/notes.hbs @@ -8,7 +8,7 @@ {{formInput notes.field value=notes.value enriched=notes.enriched toggled=true}}
- {{#if document.system.attribution.artist}} + {{#if (and showAttribution document.system.attribution.artist)}} {{/if}} \ No newline at end of file diff --git a/templates/sheets/actors/environment/header.hbs b/templates/sheets/actors/environment/header.hbs index c49b612b..b7eab3db 100644 --- a/templates/sheets/actors/environment/header.hbs +++ b/templates/sheets/actors/environment/header.hbs @@ -18,8 +18,8 @@ {{/if}} - {{#if document.system.attribution.source}} - + {{#if (and showAttribution document.system.attributionLabel)}} + {{/if}} diff --git a/templates/sheets/actors/environment/notes.hbs b/templates/sheets/actors/environment/notes.hbs index 352be465..4f6b131e 100644 --- a/templates/sheets/actors/environment/notes.hbs +++ b/templates/sheets/actors/environment/notes.hbs @@ -8,7 +8,7 @@ {{formInput notes.field value=notes.value enriched=notes.value toggled=true}} - {{#if document.system.attribution.artist}} + {{#if (and showAttribution document.system.attribution.artist)}} {{/if}} \ No newline at end of file diff --git a/templates/sheets/global/tabs/tab-description.hbs b/templates/sheets/global/tabs/tab-description.hbs index 64997bd4..6d0669e0 100755 --- a/templates/sheets/global/tabs/tab-description.hbs +++ b/templates/sheets/global/tabs/tab-description.hbs @@ -8,7 +8,7 @@ {{formInput systemFields.description value=document.system.description enriched=enrichedDescription toggled=true}} - {{#if document.system.attribution.artist}} + {{#if (and showAttribution document.system.attribution.artist)}} {{/if}} \ No newline at end of file diff --git a/templates/sheets/items/ancestry/header.hbs b/templates/sheets/items/ancestry/header.hbs index 25513dcb..60eaa363 100644 --- a/templates/sheets/items/ancestry/header.hbs +++ b/templates/sheets/items/ancestry/header.hbs @@ -4,7 +4,7 @@

{{localize 'TYPES.Item.ancestry'}}

- {{#if source.system.attributionLabel}}
{{source.system.attributionLabel}}
{{/if}} + {{#if (and showAttribution source.system.attributionLabel)}}
{{source.system.attributionLabel}}
{{/if}}
\ No newline at end of file diff --git a/templates/sheets/items/community/header.hbs b/templates/sheets/items/community/header.hbs index 5ff9f3b2..63267f44 100644 --- a/templates/sheets/items/community/header.hbs +++ b/templates/sheets/items/community/header.hbs @@ -4,7 +4,7 @@

{{localize 'TYPES.Item.community'}}

- {{#if source.system.attributionLabel}}
{{source.system.attributionLabel}}
{{/if}} + {{#if (and showAttribution source.system.attributionLabel)}}
{{source.system.attributionLabel}}
{{/if}}
\ No newline at end of file diff --git a/templates/sheets/items/domainCard/header.hbs b/templates/sheets/items/domainCard/header.hbs index caa1a9a4..935dca6f 100644 --- a/templates/sheets/items/domainCard/header.hbs +++ b/templates/sheets/items/domainCard/header.hbs @@ -24,6 +24,6 @@ {{source.system.level}} - {{#if source.system.attributionLabel}}
{{source.system.attributionLabel}}
{{/if}} + {{#if (and showAttribution source.system.attributionLabel)}}
{{source.system.attributionLabel}}
{{/if}} \ No newline at end of file