Skip to content

Commit

Permalink
Added a module setting to show creature Level as a toggleable field f…
Browse files Browse the repository at this point in the history
…or the gm.
  • Loading branch information
WBHarry committed Aug 17, 2024
1 parent 605c4ef commit a2af49f
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 18 deletions.
5 changes: 5 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"PF2EBestiary": {
"Miscellaneous": {
"Name": "Name",
"Level": "Level",
"AC": "AC",
"HP": "HP",
"Immunities": "Immunities",
Expand Down Expand Up @@ -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": {
Expand Down
5 changes: 3 additions & 2 deletions module/bestiary.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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),
Expand Down
8 changes: 8 additions & 0 deletions scripts/migrationHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
9 changes: 9 additions & 0 deletions scripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
15 changes: 9 additions & 6 deletions styles/pf2e-bestiary-tracking.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 11 additions & 7 deletions styles/stylesheets/bestiary.less
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@
border-bottom: 1px solid;
border-color: #7a7971;
margin-bottom: 4px;

.health-icon {
margin-left: 2px;
}
}

.speeds-container {
Expand Down Expand Up @@ -354,6 +358,12 @@
}
}

.data-icon {
width: 16px;
border: 0;
filter: drop-shadow(0 0 3px black);
}

.right-monster-container {
flex: 1;
display: flex;
Expand Down Expand Up @@ -396,7 +406,7 @@
.monster-return-icon {
cursor: pointer;
position: absolute;
right: 9px;
left: 9px;
top: 40px;
font-size: 30px;

Expand Down Expand Up @@ -555,12 +565,6 @@
}
}

.data-icon {
width: 16px;
border: 0;
filter: drop-shadow(0 0 3px black);
}

.attack-container {
display: flex;
align-items: center;
Expand Down
2 changes: 1 addition & 1 deletion templates/bestiary.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
<div class="type-overview-container">
Expand Down
13 changes: 11 additions & 2 deletions templates/partials/monsterView.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<div class="monster-container flex-col">
<div class="left-monster-container">
<img class="monster-image {{#if this.useTokenArt}}token{{/if}}" src="{{this.img}}" data-action="imagePopout" />

{{#if this.showMonsterLevel}}
<div class="monster-left-data {{PF2EBTToggleContainer this.user this.level}}" data-action="toggleRevealed" data-path="level" data-name="{{localize "PF2EBestiary.Miscellaneous.Level"}}" data-vague-property="level">
<div class="flex-data">
<i class="fa-solid fa-dragon"></i>
<div>{{localize "PF2EBestiary.Miscellaneous.Level"}}</div>
</div>
<div class="flex-value">{{#if (or this.level.revealed this.user.isGM)}}{{PF2EBTMonsterValue this.level}}{{else}}?{{/if}}</div>
</div>
{{/if}}

<div class="monster-left-data {{PF2EBTToggleContainer this.user this.ac}}" data-action="toggleRevealed" data-path="ac" data-name="{{localize "PF2EBestiary.Miscellaneous.AC"}}" data-vague-property="ac">
<div class="flex-data">
Expand All @@ -12,7 +22,7 @@

<div class="monster-left-data {{PF2EBTToggleContainer this.user this.hp}}" data-action="toggleRevealed" data-path="hp" data-name="{{localize "PF2EBestiary.Miscellaneous.HP"}}" data-vague-property="hp">
<div class="flex-data">
<i class="fa-solid fa-fw fa-shield-halved"></i>
<i class="fa-solid fa-heart health-icon"></i>
<div>{{localize "PF2EBestiary.Miscellaneous.HP"}}</div>
</div>
<div class="flex-value">{{#if (or this.hp.revealed this.user.isGM)}}{{PF2EBTMonsterValue this.hp this.vagueDescriptions.properties.hp}}{{else}}?{{/if}}</div>
Expand Down Expand Up @@ -198,7 +208,6 @@
</a>
{{/each}}
</nav>

<i class="fa-solid fa-reply monster-return-icon" data-action="returnButton" title="{{localize "PF2EBestiary.Bestiary.ReturnMessages.ReturnToCategory" type=(PF2EBTCaptialize this.selected.type)}}"></i>
</div>
<div class="monster-traits-row">
Expand Down

0 comments on commit a2af49f

Please sign in to comment.