From 24ec7673b589b50fcb711a7157bcf9dd4192c984 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Tue, 25 Nov 2025 06:45:13 -0500 Subject: [PATCH] Show adversary and environment type --- lang/en.json | 5 ++-- .../sidebar/tabs/actorDirectory.mjs | 24 ++++++++++++------- .../ui/sidebar/actor-document-partial.hbs | 6 ++--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lang/en.json b/lang/en.json index 13d451f8..44e1950c 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2703,10 +2703,9 @@ }, "Sidebar": { "actorDirectory": { - "adversary": "Tier {tier} Adversary", + "tier": "Tier {tier} {type}", "character": "Level {level} Character", - "companion": "{partner}'s Companion", - "environment": "Tier {tier} Environment" + "companion": "{partner}'s Companion" }, "daggerheartMenu": { "title": "Daggerheart Menu", diff --git a/module/applications/sidebar/tabs/actorDirectory.mjs b/module/applications/sidebar/tabs/actorDirectory.mjs index c8cc5134..bf0d5eb3 100644 --- a/module/applications/sidebar/tabs/actorDirectory.mjs +++ b/module/applications/sidebar/tabs/actorDirectory.mjs @@ -1,11 +1,19 @@ export default class DhActorDirectory extends foundry.applications.sidebar.tabs.ActorDirectory { static DEFAULT_OPTIONS = { - renderUpdateKeys: [ - "system.levelData.level.current", - "system.partner", - "system.tier" - ] - } + renderUpdateKeys: ['system.levelData.level.current', 'system.partner', 'system.tier'] + }; - static _entryPartial = "systems/daggerheart/templates/ui/sidebar/actor-document-partial.hbs"; -} \ No newline at end of file + static _entryPartial = 'systems/daggerheart/templates/ui/sidebar/actor-document-partial.hbs'; + + async _prepareDirectoryContext(context, options) { + await super._prepareDirectoryContext(context, options); + const adversaryTypes = CONFIG.DH.ACTOR.allAdversaryTypes(); + context.getTypeLabel = document => { + return document.type === 'adversary' + ? game.i18n.localize(adversaryTypes[document.system.type].label) + : document.type === 'environment' + ? game.i18n.localize(CONFIG.DH.ACTOR.environmentTypes[document.system.type].label) + : null; + }; + } +} diff --git a/templates/ui/sidebar/actor-document-partial.hbs b/templates/ui/sidebar/actor-document-partial.hbs index 850c4507..3321bc1d 100644 --- a/templates/ui/sidebar/actor-document-partial.hbs +++ b/templates/ui/sidebar/actor-document-partial.hbs @@ -4,8 +4,8 @@ {{/if}} {{name}} - {{#if (eq type "adversary")}} - {{localize "DAGGERHEART.UI.Sidebar.actorDirectory.adversary" tier=system.tier}} + {{#if (or (eq type "adversary") (eq type "environment"))}} + {{localize "DAGGERHEART.UI.Sidebar.actorDirectory.tier" tier=system.tier type=(@root.getTypeLabel this)}} {{else if (eq type "character")}} {{localize "DAGGERHEART.UI.Sidebar.actorDirectory.character" level=system.levelData.level.current}} {{else if (eq type "companion")}} @@ -14,8 +14,6 @@ {{else}} {{localize "TYPES.Actor.companion"}} {{/if}} - {{else if (eq type "environment")}} - {{localize "DAGGERHEART.UI.Sidebar.actorDirectory.environment" tier=system.tier}} {{/if}}