From a2af49ffb362856721b270e6bccbe6ba4991468b Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sat, 17 Aug 2024 14:54:07 +0200 Subject: [PATCH] Added a module setting to show creature Level as a toggleable field for the gm. --- lang/en.json | 5 +++++ module/bestiary.js | 5 +++-- scripts/migrationHandler.js | 8 ++++++++ scripts/setup.js | 9 +++++++++ styles/pf2e-bestiary-tracking.css | 15 +++++++++------ styles/stylesheets/bestiary.less | 18 +++++++++++------- templates/bestiary.hbs | 2 +- templates/partials/monsterView.hbs | 13 +++++++++++-- 8 files changed, 57 insertions(+), 18 deletions(-) diff --git a/lang/en.json b/lang/en.json index 2337b00..92855ae 100644 --- a/lang/en.json +++ b/lang/en.json @@ -2,6 +2,7 @@ "PF2EBestiary": { "Miscellaneous": { "Name": "Name", + "Level": "Level", "AC": "AC", "HP": "HP", "Immunities": "Immunities", @@ -182,6 +183,10 @@ "UseTokenArt": { "Name": "Use Token Art", "Hint": "Token art will be used in the Bestiary." + }, + "ShowMonsterLevel": { + "Name": "Show Monster Level", + "Hint": "Display the monster's level as a field the GM can toggle" } }, "Macros": { diff --git a/module/bestiary.js b/module/bestiary.js index f42b5bd..40a1ac8 100644 --- a/module/bestiary.js +++ b/module/bestiary.js @@ -167,7 +167,7 @@ export default class PF2EBestiary extends HandlebarsApplicationMixin(Application slug: monster.slug, id: monster.id, uuid: monster.uuid, - level: monster.value, + level: monster.level, inTypes: monster.inTypes, traits: monster.traits, size: monster.size, @@ -227,6 +227,7 @@ export default class PF2EBestiary extends HandlebarsApplicationMixin(Application context.tabs = this.getTabs(); context.layout = await game.settings.get('pf2e-bestiary-tracking', 'bestiary-layout'); + context.showMonsterLevel = await game.settings.get('pf2e-bestiary-tracking', 'show-monster-level'); context.bestiary = foundry.utils.deepClone(this.bestiary); context.selected = foundry.utils.deepClone(this.selected); @@ -809,7 +810,7 @@ export default class PF2EBestiary extends HandlebarsApplicationMixin(Application slug: slug, id: item.id, uuid: item.uuid, - level: item.system.details.level.value, + level: { revealed: false, value: item.system.details.level.value }, inTypes: types.map(x => x.key), traits: traits, size: getCreatureSize(item.system.traits.size.value), diff --git a/scripts/migrationHandler.js b/scripts/migrationHandler.js index affde9c..c714019 100644 --- a/scripts/migrationHandler.js +++ b/scripts/migrationHandler.js @@ -171,6 +171,14 @@ export const handleDataMigration = async () => { version = '0.8.7'; } + if(version === '0.8.7'){ + await migrateBestiary(async (bestiary, monster, type, monsterKey) => { + bestiary.monster[type][monsterKey].level = { revealed: false, value: bestiary.monster[type][monsterKey].level }; + }); + + version = '0.8.7.1'; + } + await game.settings.set('pf2e-bestiary-tracking', 'version', version); } diff --git a/scripts/setup.js b/scripts/setup.js index a5577d2..7cfb879 100644 --- a/scripts/setup.js +++ b/scripts/setup.js @@ -58,6 +58,15 @@ const configSettings = () => { type: Boolean, default: false, }); + + game.settings.register('pf2e-bestiary-tracking', 'show-monster-level', { + name: game.i18n.localize('PF2EBestiary.Settings.ShowMonsterLevel.Name'), + hint: game.i18n.localize('PF2EBestiary.Settings.ShowMonsterLevel.Hint'), + scope: 'world', + config: true, + type: Boolean, + default: false, + }); }; const generalNonConfigSettings = () => { diff --git a/styles/pf2e-bestiary-tracking.css b/styles/pf2e-bestiary-tracking.css index a8b06e8..9b26a9b 100644 --- a/styles/pf2e-bestiary-tracking.css +++ b/styles/pf2e-bestiary-tracking.css @@ -330,6 +330,9 @@ border-color: #7a7971; margin-bottom: 4px; } +.bestiary-tracking.bestiary .monster-container .left-monster-container .monster-left-data .health-icon { + margin-left: 2px; +} .bestiary-tracking.bestiary .monster-container .left-monster-container .speeds-container { display: flex; align-items: center; @@ -366,6 +369,11 @@ .bestiary-tracking.bestiary .monster-container .left-monster-container .saves-container .save-container .saves-value { font-size: 16px; } +.bestiary-tracking.bestiary .monster-container .data-icon { + width: 16px; + border: 0; + filter: drop-shadow(0 0 3px black); +} .bestiary-tracking.bestiary .monster-container .right-monster-container { flex: 1; display: flex; @@ -405,7 +413,7 @@ .bestiary-tracking.bestiary .monster-container .right-monster-container .monster-name-container .monster-return-icon { cursor: pointer; position: absolute; - right: 9px; + left: 9px; top: 40px; font-size: 30px; } @@ -540,11 +548,6 @@ .bestiary-tracking.bestiary .monster-container .right-monster-container .actions-container .action-description.expanded { max-height: 500px; } -.bestiary-tracking.bestiary .monster-container .right-monster-container .data-icon { - width: 16px; - border: 0; - filter: drop-shadow(0 0 3px black); -} .bestiary-tracking.bestiary .monster-container .right-monster-container .attack-container { display: flex; align-items: center; diff --git a/styles/stylesheets/bestiary.less b/styles/stylesheets/bestiary.less index c5db8e3..58d9afb 100644 --- a/styles/stylesheets/bestiary.less +++ b/styles/stylesheets/bestiary.less @@ -308,6 +308,10 @@ border-bottom: 1px solid; border-color: #7a7971; margin-bottom: 4px; + + .health-icon { + margin-left: 2px; + } } .speeds-container { @@ -354,6 +358,12 @@ } } + .data-icon { + width: 16px; + border: 0; + filter: drop-shadow(0 0 3px black); + } + .right-monster-container { flex: 1; display: flex; @@ -396,7 +406,7 @@ .monster-return-icon { cursor: pointer; position: absolute; - right: 9px; + left: 9px; top: 40px; font-size: 30px; @@ -555,12 +565,6 @@ } } - .data-icon { - width: 16px; - border: 0; - filter: drop-shadow(0 0 3px black); - } - .attack-container { display: flex; align-items: center; diff --git a/templates/bestiary.hbs b/templates/bestiary.hbs index 5881866..597c95f 100644 --- a/templates/bestiary.hbs +++ b/templates/bestiary.hbs @@ -42,7 +42,7 @@ {{else}} {{#if this.selected.monster}} {{#with this.selected.monster}} - {{> "modules/pf2e-bestiary-tracking/templates/partials/monsterView.hbs" selected=../selected user=../user vagueDescriptions=../vagueDescriptions tabs=../tabs useTokenArt=../useTokenArt }} + {{> "modules/pf2e-bestiary-tracking/templates/partials/monsterView.hbs" selected=../selected user=../user vagueDescriptions=../vagueDescriptions tabs=../tabs useTokenArt=../useTokenArt showMonsterLevel=../showMonsterLevel }} {{/with}} {{else}}
diff --git a/templates/partials/monsterView.hbs b/templates/partials/monsterView.hbs index 2c9b6e3..9f2b016 100644 --- a/templates/partials/monsterView.hbs +++ b/templates/partials/monsterView.hbs @@ -1,6 +1,16 @@
+ + {{#if this.showMonsterLevel}} +
+
+ +
{{localize "PF2EBestiary.Miscellaneous.Level"}}
+
+
{{#if (or this.level.revealed this.user.isGM)}}{{PF2EBTMonsterValue this.level}}{{else}}?{{/if}}
+
+ {{/if}}
@@ -12,7 +22,7 @@
- +
{{localize "PF2EBestiary.Miscellaneous.HP"}}
{{#if (or this.hp.revealed this.user.isGM)}}{{PF2EBTMonsterValue this.hp this.vagueDescriptions.properties.hp}}{{else}}?{{/if}}
@@ -198,7 +208,6 @@ {{/each}} -