diff --git a/module.json b/module.json index 37d0c02..bf66efd 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "id": "dh-hotbar-cardview", "title": "Daggerheart Hotbar Card View", "description": "Replaces the hover-tooltips on the hotbar icons with a full card view of the item for Daggerheart.", - "version": "1.0.0", + "version": "1.1.0", "compatibility": { "minimum": "14", "verified": "14" @@ -34,5 +34,5 @@ ], "url": "https://git.geeks.gay/cosmo/dh-hotbar-cardview", "manifest": "https://git.geeks.gay/cosmo/dh-hotbar-cardview/raw/branch/main/module.json", - "download": "https://git.geeks.gay/cosmo/dh-hotbar-cardview/releases/latest/download/dh-hotbar-cardview.zip" + "download": "https://git.geeks.gay/cosmo/dh-hotbar-cardview/releases/download/1.1.0/dh-hotbar-cardview.zip" } \ No newline at end of file diff --git a/scripts/main.js b/scripts/main.js index 02339db..9e1ca4c 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -1,4 +1,87 @@ Hooks.once('init', () => { + // Register Module Settings + game.settings.register('dh-hotbar-cardview', 'showTagsAll', { + name: 'Show Tags on Tooltips', + hint: 'Master toggle to display item tags (damage, properties, etc.) on hotbar card tooltips.', + scope: 'client', + config: true, + type: Boolean, + default: true + }); + game.settings.register('dh-hotbar-cardview', 'showTagsWeapons', { + name: 'Show Tags: Weapons', + scope: 'client', + config: true, + type: Boolean, + default: true + }); + game.settings.register('dh-hotbar-cardview', 'showTagsArmor', { + name: 'Show Tags: Armor', + scope: 'client', + config: true, + type: Boolean, + default: true + }); + game.settings.register('dh-hotbar-cardview', 'showTagsConsumables', { + name: 'Show Tags: Consumables', + scope: 'client', + config: true, + type: Boolean, + default: true + }); + game.settings.register('dh-hotbar-cardview', 'showTagsFeatures', { + name: 'Show Tags: Features', + scope: 'client', + config: true, + type: Boolean, + default: true + }); + game.settings.register('dh-hotbar-cardview', 'showTagsDomains', { + name: 'Show Tags: Domain Cards', + scope: 'client', + config: true, + type: Boolean, + default: false + }); + + // Hook to dynamically hide/show sub-settings based on the master toggle + Hooks.on('renderSettingsConfig', (app, html) => { + // Use a timeout to ensure the DOM is fully rendered and attached, + // and to run after Foundry's own initial display/search logic. + setTimeout(() => { + // Find the master checkbox + const showTagsAllCheckbox = document.querySelector('input[name="dh-hotbar-cardview.showTagsAll"]'); + if (!showTagsAllCheckbox) return; + + const subSettings = ['Weapons', 'Armor', 'Consumables', 'Features', 'Domains']; + + function toggleSubSettings() { + const isChecked = showTagsAllCheckbox.checked; + subSettings.forEach(setting => { + const input = document.querySelector(`input[name="dh-hotbar-cardview.showTags${setting}"]`); + if (input) { + const row = input.closest('.form-group'); + if (row) { + if (isChecked) { + // Remove inline display style to let CSS handle it (usually flex) + row.style.display = ''; + } else { + // Use !important to prevent Foundry's search or tab logic from overriding it + row.style.setProperty('display', 'none', 'important'); + } + } + } + }); + } + + // Run once to set initial state + toggleSubSettings(); + + // Listen for changes + showTagsAllCheckbox.addEventListener('change', toggleSubSettings); + }, 100); + }); + const originalActivate = CONFIG.ux.TooltipManager.prototype.activate; CONFIG.ux.TooltipManager.prototype.activate = async function(element, options = {}) { @@ -11,11 +94,44 @@ Hooks.once('init', () => { await this.enrichText(item); } + // Calculate Feature Source Category + let featureSource = null; + if (item.type === 'feature' && item.system?.originItemType) { + const originType = item.system.originItemType; + // Attempt to get the localized string for the origin type (e.g., "Ancestry") + let originTypeString = game.i18n.localize(`TYPES.Item.${originType}`); + // Fallback just in case + if (originTypeString === `TYPES.Item.${originType}`) { + originTypeString = originType.charAt(0).toUpperCase() + originType.slice(1); + } + + if (item.parent && item.parent.items) { + const sourceItem = item.parent.items.find(i => i.type === originType); + if (sourceItem) { + featureSource = `${originTypeString} - ${sourceItem.name}`; + } else { + featureSource = originTypeString; + } + } else { + featureSource = originTypeString; + } + } + + const showTagsAll = game.settings.get('dh-hotbar-cardview', 'showTagsAll'); + options.html = await renderTemplate('modules/dh-hotbar-cardview/templates/cardview.hbs', { item: item, description: item.system?.enrichedDescription ?? item.enrichedDescription ?? item.system?.description, config: CONFIG.DH, - allDomains: CONFIG.DH.DOMAIN?.allDomains ? CONFIG.DH.DOMAIN.allDomains() : {} + allDomains: CONFIG.DH.DOMAIN?.allDomains ? CONFIG.DH.DOMAIN.allDomains() : {}, + featureSource: featureSource, + settings: { + weapon: showTagsAll && game.settings.get('dh-hotbar-cardview', 'showTagsWeapons'), + armor: showTagsAll && game.settings.get('dh-hotbar-cardview', 'showTagsArmor'), + consumable: showTagsAll && game.settings.get('dh-hotbar-cardview', 'showTagsConsumables'), + feature: showTagsAll && game.settings.get('dh-hotbar-cardview', 'showTagsFeatures'), + domain: showTagsAll && game.settings.get('dh-hotbar-cardview', 'showTagsDomains') + } }); options.direction = this.constructor.TOOLTIP_DIRECTIONS.UP; diff --git a/styles/cardview.css b/styles/cardview.css index c021ba9..96b146c 100644 --- a/styles/cardview.css +++ b/styles/cardview.css @@ -49,7 +49,7 @@ .dh-hotbar-card .card-art-container { position: relative; width: 100%; - height: 180px; + height: 260px; border-bottom: 4px solid #f2cf5b; /* Gold line */ background: #333; display: flex; @@ -126,24 +126,43 @@ bottom: -14px; left: 50%; transform: translateX(-50%); - background: #1a1a1a; + background: #f2cf5b; color: white; font-weight: 800; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; - padding: 4px 24px; + padding: 6px 26px; clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 10px 100%, 0 50%); z-index: 10; + display: flex; + justify-content: center; + align-items: center; +} + +.dh-hotbar-card .card-type-banner::before { + content: ''; + position: absolute; + top: 2px; + left: 2px; + right: 2px; + bottom: 2px; + background: #1a1a1a; + clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%); + z-index: -1; } .dh-hotbar-card .card-type-banner.ancestry { left: auto; right: 20px; transform: none; - background: #f2cf5b; + background: var(--dh-card-banner-border); color: #000; - border: 2px solid var(--dh-card-banner-border); + border: none; +} + +.dh-hotbar-card .card-type-banner.ancestry::before { + background: #f2cf5b; } /* Adjust layout so content doesn't collide with the banner */ @@ -170,6 +189,35 @@ color: var(--dh-card-text); } +.dh-hotbar-card .card-tags { + display: flex; + flex-wrap: wrap; + gap: 8px; + margin-bottom: 16px; +} + +.dh-hotbar-card .card-tags .tag { + background: #1a1a1a; + border: 1px solid var(--dh-card-border); + border-radius: 4px; + padding: 2px 8px; + font-size: 12px; + font-weight: 600; + color: #ddd; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.dh-hotbar-card .card-tags .tag.damage-tag { + background: #441a1a; + border-color: #f2cf5b; + color: #f2cf5b; +} + +.dh-hotbar-card .card-tags .tag i { + margin-right: 4px; +} + .dh-hotbar-card .card-description p { margin: 0 0 8px 0; } diff --git a/templates/cardview.hbs b/templates/cardview.hbs index 2243e75..3d9a05e 100644 --- a/templates/cardview.hbs +++ b/templates/cardview.hbs @@ -29,6 +29,78 @@

{{item.name}}

+ + {{#if (and (eq item.type "weapon") settings.weapon)}} +
+
+ {{#if item.system.secondary}}{{localize "DAGGERHEART.ITEMS.Weapon.secondaryWeapon.full"}}{{else}}{{localize "DAGGERHEART.ITEMS.Weapon.primaryWeapon.full"}}{{/if}} +
+
+ {{#with (lookup config.GENERAL.burden item.system.burden) as | burden |}} + {{localize burden.label}} + {{/with}} +
+ {{#if item.system.attack.roll.trait}} +
+ {{#with (lookup config.ACTOR.abilities item.system.attack.roll.trait) as | trait |}} + {{localize trait.label}} + {{/with}} +
+ {{/if}} +
+ {{#with (lookup config.GENERAL.range item.system.attack.range) as | range |}} + {{localize range.label}} + {{/with}} +
+
+ {{{damageFormula item.system.attack}}} {{{damageSymbols item.system.attack.damage.parts}}} +
+
+ {{/if}} + + {{#if (and (eq item.type "armor") settings.armor)}} +
+
+ {{localize "DAGGERHEART.ITEMS.Armor.baseScore"}} {{item.system.baseScore}} +
+
+ {{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.major"}} {{item.system.baseThresholds.major}} +
+
+ {{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.severe"}} {{item.system.baseThresholds.severe}} +
+
+ {{/if}} + + {{#if (and (eq item.type "consumable") settings.consumable)}} +
+
+ {{localize "DAGGERHEART.GENERAL.quantity"}} {{item.system.quantity}} +
+
+ {{/if}} + + {{#if (and (eq item.type "feature") settings.feature)}} +
+
+ {{#if featureSource}}{{featureSource}}{{else}}{{localize "TYPES.Item.feature"}}{{/if}} +
+
+ {{/if}} + + {{#if (and (eq item.type "domainCard") settings.domain)}} +
+
+ {{#with (lookup config.DOMAIN.cardTypes item.system.type) as | type |}} + {{localize type.label}} + {{/with}} +
+
+ {{localize 'DAGGERHEART.GENERAL.levelShort'}} {{ item.system.level }} +
+
+ {{/if}} +
{{{description}}}