From cce86c70328a7a720e0de08f1ed8a1055638cf91 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 9 Mar 2026 20:10:31 +0100 Subject: [PATCH] Inverted from isImage to isIcon. Should be more logical for users --- daggerheart.mjs | 14 ++++++++------ lang/en.json | 2 +- .../applications/settings/homebrewSettings.mjs | 6 +++--- module/applications/sheets/actors/character.mjs | 4 ++-- module/config/resourceConfig.mjs | 4 ++-- module/data/settings/Homebrew.mjs | 10 +++++----- .../settings/homebrew-settings/resources.hbs | 16 ++++++++-------- templates/ui/tooltip/resourceManagement.hbs | 8 ++++---- 8 files changed, 33 insertions(+), 31 deletions(-) diff --git a/daggerheart.mjs b/daggerheart.mjs index 8c3e0cc1..71120a20 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -114,11 +114,11 @@ Hooks.once('init', () => { images: { full: { value: 'systems/daggerheart/assets/icons/domains/sage.svg', - isPath: true + isIcon: false }, empty: { value: 'systems/daggerheart/assets/icons/domains/sage.svg', - isPath: true + isIcon: false } } }; @@ -132,12 +132,12 @@ Hooks.once('init', () => { images: { full: { value: 'icons/magic/fire/barrier-wall-explosion-orange.webp', - isPath: true, + isIcon: false, noColorFilter: true }, empty: { value: 'icons/magic/fire/barrier-wall-flame-ring-blue.webp', - isPath: true, + isIcon: false, noColorFilter: true } } @@ -151,10 +151,12 @@ Hooks.once('init', () => { label: 'Hunger', images: { full: { - value: 'fa-solid fa-burger' + value: 'fa-solid fa-burger', + isIcon: true }, empty: { - value: 'fa-regular fa-burger' + value: 'fa-regular fa-burger', + isIcon: true } } }; diff --git a/lang/en.json b/lang/en.json index b74bfcc6..4e15c362 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2657,7 +2657,7 @@ "resources": { "resources": { "value": { "label": "Icon" }, - "isPath": { "label": "Is Image" }, + "isIcon": { "label": "Font Awesome Icon" }, "noColorFilter": { "label": "Disable Color Filter" } } }, diff --git a/module/applications/settings/homebrewSettings.mjs b/module/applications/settings/homebrewSettings.mjs index 3293c76f..9cc0ecb1 100644 --- a/module/applications/settings/homebrewSettings.mjs +++ b/module/applications/settings/homebrewSettings.mjs @@ -96,7 +96,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli super._attachPartListeners(partId, htmlElement, options); for (const element of htmlElement.querySelectorAll('.path-field input')) - element.addEventListener('change', this.toggleResourceIsPath.bind(this)); + element.addEventListener('change', this.toggleResourceIsIcon.bind(this)); } async _prepareContext(_options) { @@ -149,14 +149,14 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli this.render(); } - async toggleResourceIsPath(event) { + async toggleResourceIsIcon(event) { const element = event.target.closest('.resource-icon-container'); const { actorType, resourceKey, imageKey } = element.dataset; const current = this.settings.resources[actorType].resources[resourceKey].images[imageKey]; await this.settings.updateSource({ [`resources.${actorType}.resources.${resourceKey}.images.${imageKey}`]: { - isPath: !current.isPath, + isIcon: !current.isIcon, value: '' } }); diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index b0aecbac..71f2fc94 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -969,8 +969,8 @@ export default class CharacterSheet extends DHBaseActorSheet { label: game.i18n.localize(resource.label), value: resourceData.value, max: resourceData.max, - fullIcon: resource.images?.full ?? { value: 'fa-solid fa-circle' }, - emptyIcon: resource.images?.empty ?? { value: 'fa-regular fa-circle' } + fullIcon: resource.images?.full ?? { value: 'fa-solid fa-circle', isIcon: true }, + emptyIcon: resource.images?.empty ?? { value: 'fa-regular fa-circle', isIcon: true } }; return acc; diff --git a/module/config/resourceConfig.mjs b/module/config/resourceConfig.mjs index 4428e20d..1f594b39 100644 --- a/module/config/resourceConfig.mjs +++ b/module/config/resourceConfig.mjs @@ -6,8 +6,8 @@ * reverse * label * images { - * full { value, isPath, noColorFilter } - * empty { value, isPath noColorFilter } + * full { value, isIcon, noColorFilter } + * empty { value, isIcon noColorFilter } * } */ diff --git a/module/data/settings/Homebrew.mjs b/module/data/settings/Homebrew.mjs index fee2b8ca..c525cabd 100644 --- a/module/data/settings/Homebrew.mjs +++ b/module/data/settings/Homebrew.mjs @@ -223,7 +223,7 @@ export class Resource extends foundry.abstract.DataModel { } static getDefaultResourceData = label => { - const images = Resource._schema.fields.images.getInitialValue(); + const images = Resource.schema.fields.images.getInitialValue(); return { initial: 0, max: 0, @@ -233,7 +233,7 @@ export class Resource extends foundry.abstract.DataModel { }; static getDefaultImageData = imageKey => { - return Resource._schema.fields.images.fields[imageKey].getInitialValue(); + return Resource.schema.fields.images.fields[imageKey].getInitialValue(); }; } @@ -244,10 +244,10 @@ const imageIconField = defaultValue => initial: defaultValue, label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.resources.resources.value.label' }), - isPath: new foundry.data.fields.BooleanField({ + isIcon: new foundry.data.fields.BooleanField({ required: true, - initial: false, - label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.resources.resources.isPath.label' + initial: true, + label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.resources.resources.isIcon.label' }), noColorFilter: new foundry.data.fields.BooleanField({ required: true, diff --git a/templates/settings/homebrew-settings/resources.hbs b/templates/settings/homebrew-settings/resources.hbs index 480478bf..7f3dee3e 100644 --- a/templates/settings/homebrew-settings/resources.hbs +++ b/templates/settings/homebrew-settings/resources.hbs @@ -34,14 +34,14 @@
- {{#if ../images.full.isPath}} + {{#if ../images.full.isIcon}} + {{formGroup this.value value=../images.full.value name=(concat "resources." @../key ".resources." key ".images.full.value") localize=true }} + {{else}}
- {{else}} - {{formGroup this.value value=../images.full.value name=(concat "resources." @../key ".resources." key ".images.full.value") localize=true }} {{/if}} - {{formGroup this.isPath value=../images.full.isPath name="" classes="path-field" localize=true }} + {{formGroup this.isIcon value=../images.full.isIcon name="" classes="path-field" localize=true }} {{formGroup this.noColorFilter value=../images.full.noColorFilter name=(concat "resources." @../key ".resources." key ".images.full.noColorFilter") localize=true }}
{{/with}} @@ -55,14 +55,14 @@
- {{#if ../images.empty.isPath}} + {{#if ../images.empty.isIcon}} + {{formGroup this.value value=../images.empty.value name=(concat "resources." @../key ".resources." key ".images.empty.value") localize=true }} + {{else}}
- {{else}} - {{formGroup this.value value=../images.empty.value name=(concat "resources." @../key ".resources." key ".images.empty.value") localize=true }} {{/if}} - {{formGroup this.isPath value=resource.images.empty.isPath name="" classes="path-field" localize=true }} + {{formGroup this.isIcon value=resource.images.empty.isIcon name="" classes="path-field" localize=true }} {{formGroup this.noColorFilter value=resource.images.empty.noColorFilter name=(concat "resources." @../key ".resources." key ".images.empty.noColorFilter") localize=true }}
{{/with}} diff --git a/templates/ui/tooltip/resourceManagement.hbs b/templates/ui/tooltip/resourceManagement.hbs index d43c7a99..b9817e6e 100644 --- a/templates/ui/tooltip/resourceManagement.hbs +++ b/templates/ui/tooltip/resourceManagement.hbs @@ -4,16 +4,16 @@

{{resource.label}}

{{#times resource.max}} - {{#unless resource.fullIcon.isPath}} + {{#if resource.fullIcon.isIcon}} {{else}} - {{/unless}} - {{#unless resource.emptyIcon.isPath}} + {{/if}} + {{#if resource.emptyIcon.isIcon}} {{else}} - {{/unless}} + {{/if}} {{/times}}