From 01ddc4f9e783d652614a7f3b48fe950d564e0650 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Thu, 17 Jul 2025 17:47:13 +0200 Subject: [PATCH] Fixed styling for downtime tooltip --- module/applications/dialogs/downtime.mjs | 4 +- module/config/generalConfig.mjs | 19 +++---- module/data/settings/Homebrew.mjs | 2 + module/documents/tooltipManager.mjs | 51 ++++++++++++++++++- .../dialog/downtime/downtime-container.less | 38 ++++++++++---- styles/less/ux/tooltip/tooltip.less | 14 +++++ templates/dialogs/downtime/activities.hbs | 10 ++-- templates/dialogs/downtime/downtime.hbs | 7 ++- templates/settings/automation-settings.hbs | 2 +- templates/ui/tooltip/downtime.hbs | 7 +++ 10 files changed, 122 insertions(+), 32 deletions(-) create mode 100644 templates/ui/tooltip/downtime.hbs diff --git a/module/applications/dialogs/downtime.mjs b/module/applications/dialogs/downtime.mjs index 20faa428..8da8137d 100644 --- a/module/applications/dialogs/downtime.mjs +++ b/module/applications/dialogs/downtime.mjs @@ -25,8 +25,8 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV static DEFAULT_OPTIONS = { tag: 'form', - classes: ['daggerheart', 'views', 'dh-style', 'downtime'], - position: { width: 680, height: 'auto' }, + classes: ['daggerheart', 'views', 'dh-style', 'dialog', 'downtime'], + position: { width: 600, height: 'auto' }, actions: { selectMove: this.selectMove, takeDowntime: this.takeDowntime diff --git a/module/config/generalConfig.mjs b/module/config/generalConfig.mjs index 704a5401..632e5448 100644 --- a/module/config/generalConfig.mjs +++ b/module/config/generalConfig.mjs @@ -130,6 +130,7 @@ export const defaultRestOptions = { tendToWounds: { id: 'tendToWounds', name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.tendToWounds.name'), + icon: 'fa-solid fa-bandage', img: 'icons/magic/life/cross-worn-green.webp', description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.tendToWounds.description'), actions: [ @@ -153,6 +154,7 @@ export const defaultRestOptions = { clearStress: { id: 'clearStress', name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.clearStress.name'), + icon: 'fa-regular fa-face-surprise', img: 'icons/magic/perception/eye-ringed-green.webp', description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.clearStress.description'), actions: [ @@ -176,6 +178,7 @@ export const defaultRestOptions = { repairArmor: { id: 'repairArmor', name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.name'), + icon: 'fa-solid fa-hammer', img: 'icons/skills/trades/smithing-anvil-silver-red.webp', description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.description'), actions: [] @@ -183,6 +186,7 @@ export const defaultRestOptions = { prepare: { id: 'prepare', name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.prepare.name'), + icon: 'fa-solid fa-dumbbell', img: 'icons/skills/trades/academics-merchant-scribe.webp', description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.prepare.description'), actions: [] @@ -192,6 +196,7 @@ export const defaultRestOptions = { tendToWounds: { id: 'tendToWounds', name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.tendToWounds.name'), + icon: 'fa-solid fa-bandage', img: 'icons/magic/life/cross-worn-green.webp', description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.tendToWounds.description'), actions: [] @@ -199,6 +204,7 @@ export const defaultRestOptions = { clearStress: { id: 'clearStress', name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.clearStress.name'), + icon: 'fa-regular fa-face-surprise', img: 'icons/magic/perception/eye-ringed-green.webp', description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.clearStress.description'), actions: [] @@ -206,6 +212,7 @@ export const defaultRestOptions = { repairArmor: { id: 'repairArmor', name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.repairArmor.name'), + icon: 'fa-solid fa-hammer', img: 'icons/skills/trades/smithing-anvil-silver-red.webp', description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.repairArmor.description'), actions: [] @@ -213,6 +220,7 @@ export const defaultRestOptions = { prepare: { id: 'prepare', name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.prepare.name'), + icon: 'fa-solid fa-dumbbell', img: 'icons/skills/trades/academics-merchant-scribe.webp', description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.prepare.description'), actions: [] @@ -220,19 +228,12 @@ export const defaultRestOptions = { workOnAProject: { id: 'workOnAProject', name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.workOnAProject.name'), + icon: 'fa-solid fa-diagram-project', img: 'icons/skills/social/thumbsup-approval-like.webp', description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.workOnAProject.description'), actions: [] } - }), - custom: { - id: 'customActivity', - name: '', - img: 'icons/skills/trades/academics-investigation-puzzles.webp', - description: '', - namePlaceholder: 'DAGGERHEART.APPLICATIONS.Downtime.custom.namePlaceholder', - placeholder: 'DAGGERHEART.APPLICATIONS.Downtime.custom.placeholder' - } + }) }; export const deathMoves = { diff --git a/module/data/settings/Homebrew.mjs b/module/data/settings/Homebrew.mjs index ead5a09f..008cd73c 100644 --- a/module/data/settings/Homebrew.mjs +++ b/module/data/settings/Homebrew.mjs @@ -54,6 +54,7 @@ export default class DhHomebrew extends foundry.abstract.DataModel { moves: new fields.TypedObjectField( new fields.SchemaField({ name: new fields.StringField({ required: true }), + icon: new fields.StringField({ required: true }), img: new fields.FilePathField({ initial: 'icons/magic/life/cross-worn-green.webp', categories: ['IMAGE'], @@ -70,6 +71,7 @@ export default class DhHomebrew extends foundry.abstract.DataModel { moves: new fields.TypedObjectField( new fields.SchemaField({ name: new fields.StringField({ required: true }), + icon: new fields.StringField({ required: true }), img: new fields.FilePathField({ initial: 'icons/magic/life/cross-worn-green.webp', categories: ['IMAGE'], diff --git a/module/documents/tooltipManager.mjs b/module/documents/tooltipManager.mjs index d9444207..ab1eefd6 100644 --- a/module/documents/tooltipManager.mjs +++ b/module/documents/tooltipManager.mjs @@ -21,14 +21,61 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti this.tooltip.innerHTML = html; options.direction = this._determineItemTooltipDirection(element); } + } else { + const shortRest = element.dataset.tooltip?.startsWith('#shortRest#'); + const longRest = element.dataset.tooltip?.startsWith('#longRest#'); + if (shortRest || longRest) { + const key = element.dataset.tooltip.slice(shortRest ? 11 : 10); + const downtimeOptions = shortRest + ? CONFIG.DH.GENERAL.defaultRestOptions.shortRest() + : CONFIG.DH.GENERAL.defaultRestOptions.longRest(); + const move = downtimeOptions[key]; + html = await foundry.applications.handlebars.renderTemplate( + `systems/daggerheart/templates/ui/tooltip/downtime.hbs`, + { + move: move + } + ); + + this.tooltip.innerHTML = html; + options.direction = this._determineItemTooltipDirection( + element, + this.constructor.TOOLTIP_DIRECTIONS.UP + ); + } } super.activate(element, { ...options, html: html }); } - _determineItemTooltipDirection(element) { + _determineItemTooltipDirection(element, prefered = this.constructor.TOOLTIP_DIRECTIONS.LEFT) { const pos = element.getBoundingClientRect(); const dirs = this.constructor.TOOLTIP_DIRECTIONS; - return dirs[pos.x - this.tooltip.offsetWidth < 0 ? 'DOWN' : 'LEFT']; + switch (prefered) { + case this.constructor.TOOLTIP_DIRECTIONS.LEFT: + return dirs[ + pos.x - this.tooltip.offsetWidth < 0 + ? this.constructor.TOOLTIP_DIRECTIONS.DOWN + : this.constructor.TOOLTIP_DIRECTIONS.LEFT + ]; + case this.constructor.TOOLTIP_DIRECTIONS.UP: + return dirs[ + pos.y - this.tooltip.offsetHeight < 0 + ? this.constructor.TOOLTIP_DIRECTIONS.RIGHT + : this.constructor.TOOLTIP_DIRECTIONS.UP + ]; + case this.constructor.TOOLTIP_DIRECTIONS.RIGHT: + return dirs[ + pos.x + this.tooltip.offsetWidth > document.body.clientWidth + ? this.constructor.TOOLTIP_DIRECTIONS.DOWN + : this.constructor.TOOLTIP_DIRECTIONS.RIGHT + ]; + case this.constructor.TOOLTIP_DIRECTIONS.DOWN: + return dirs[ + pos.y + this.tooltip.offsetHeight > document.body.clientHeight + ? this.constructor.TOOLTIP_DIRECTIONS.LEFT + : this.constructor.TOOLTIP_DIRECTIONS.DOWN + ]; + } } } diff --git a/styles/less/dialog/downtime/downtime-container.less b/styles/less/dialog/downtime/downtime-container.less index d97b3d24..1188a50b 100644 --- a/styles/less/dialog/downtime/downtime-container.less +++ b/styles/less/dialog/downtime/downtime-container.less @@ -1,13 +1,14 @@ @import '../../utils/spacing.less'; @import '../../utils/colors.less'; -.daggerheart.views { - .downtime-header { - margin: 0; - color: light-dark(@dark-blue, @golden); - text-align: center; - width: 100%; +.theme-light .daggerheart.dh-style.views.downtime { + .downtime-container .activity-container .activity-selected-marker { + background-image: url(../assets/parchments/dh-parchment-dark.png); } +} + +.daggerheart.dh-style.views.downtime { + font-family: @font-body; .downtime-container { .activities-container { @@ -28,15 +29,31 @@ font-size: 8px; flex: none; color: light-dark(#18162e, #f3c267); - margin-right: 8px; + margin-right: 4px; } .activity-select-section { display: flex; align-items: center; gap: 4px; + + .activity-icon { + min-width: 24px; + text-align: center; + } } } + + .activity-selected-marker { + font-size: 14px; + border: 1px solid light-dark(@dark-blue, @golden); + border-radius: 6px; + color: light-dark(@beige, @dark); + background-image: url(../assets/parchments/dh-parchment-light.png); + padding: 0 8px; + line-height: 1; + font-weight: bold; + } } } } @@ -45,11 +62,10 @@ margin-top: 8px; display: flex; gap: 8px; - } - &.downtime { - .activity-text-area { - resize: none; + button { + flex: 1; + font-family: 'Montserrat', sans-serif; } } } diff --git a/styles/less/ux/tooltip/tooltip.less b/styles/less/ux/tooltip/tooltip.less index 38502d09..0060f74b 100644 --- a/styles/less/ux/tooltip/tooltip.less +++ b/styles/less/ux/tooltip/tooltip.less @@ -4,6 +4,20 @@ align-items: center; gap: 4px; + .tooltip-title-container { + width: 100%; + display: flex; + align-items: center; + gap: 16px; + + .tooltip-image { + height: 40px; + width: 40px; + border-radius: 6px; + border: 1px solid @golden; + } + } + .tooltip-title { margin: 0; text-align: center; diff --git a/templates/dialogs/downtime/activities.hbs b/templates/dialogs/downtime/activities.hbs index ccfcbc81..4b56572c 100644 --- a/templates/dialogs/downtime/activities.hbs +++ b/templates/dialogs/downtime/activities.hbs @@ -5,13 +5,13 @@ {{#each moves as |move key|}}
- + {{#if move.selected}}
{{move.selected}}
{{/if}}
{{/each}} diff --git a/templates/dialogs/downtime/downtime.hbs b/templates/dialogs/downtime/downtime.hbs index 26ac21cc..3f7f06f5 100644 --- a/templates/dialogs/downtime/downtime.hbs +++ b/templates/dialogs/downtime/downtime.hbs @@ -1,10 +1,13 @@
-

{{localize "DAGGERHEART.APPLICATIONS.Downtime.downtimeHeader"}}

+
+

{{localize "DAGGERHEART.APPLICATIONS.Downtime.downtimeHeader"}}

+
+
{{#if shortRestMoves.moves}}{{> "systems/daggerheart/templates/dialogs/downtime/activities.hbs" moves=shortRestMoves.moves category='shortRest' nrChoices=nrChoices.shortRest}}{{/if}} {{#if longRestMoves.moves}}{{> "systems/daggerheart/templates/dialogs/downtime/activities.hbs" moves=longRestMoves.moves category='longRest' nrChoices=nrChoices.longRest}}{{/if}}
-
+
diff --git a/templates/settings/automation-settings.hbs b/templates/settings/automation-settings.hbs index 0e158ab6..910ace56 100644 --- a/templates/settings/automation-settings.hbs +++ b/templates/settings/automation-settings.hbs @@ -6,7 +6,7 @@
{{formGroup settingFields.schema.fields.actionPoints value=settingFields._source.actionPoints localize=true}} -s {{formGroup settingFields.schema.fields.hordeDamage value=settingFields._source.hordeDamage localize=true}} + {{formGroup settingFields.schema.fields.hordeDamage value=settingFields._source.hordeDamage localize=true}}