Skip to content

Commit

Permalink
Merge pull request #233 from sdenec/0.4.13
Browse files Browse the repository at this point in the history
0.4.13 compendium fix
  • Loading branch information
sdenec authored Jan 28, 2021
2 parents 4410e0b + 84233df commit b389503
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Additional Translations generously provided by:

Thank you very much!

*Version 0.4.13*
- fixed a problem with compendiums that would cause a render loop for actor sheets bogging down the game to a halt.

*Version 0.4.12*
- classic menu will no longer cause the headers to jump when rendering the sheet.
- various minor css fixes
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/tidy5e-npc.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ async function toggleItemMode(app, html, data){

// restore scroll position
async function resetTempHp(app, html, data){
if(data.editable){
let actor = app.actor,
temp = actor.data.data.attributes.hp.temp,
let actor = app.actor;
if(data.editable && !actor.compendium){
let temp = actor.data.data.attributes.hp.temp,
tempmax = actor.data.data.attributes.hp.tempmax;

if(temp == 0){
Expand Down
27 changes: 18 additions & 9 deletions src/scripts/tidy5e-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,10 @@ async function countInventoryItems(app, html, data){

// count attuned items
async function countAttunedItems(app, html, data){
if(data.editable){
let actor = game.actors.entities.find(a => a.data._id === data.actor._id),
count = actor.data.data.details.attunedItemsCount;
let actor = app.actor;
// let actor = game.actors.entities.find(a => a.data._id === data.actor._id),
if(data.editable && !actor.compendium){
let count = actor.data.data.details.attunedItemsCount;
// if no items are counted set default value to 3
if (!actor.data.data.details.attunedItemsMax) {
await actor.update({"data.details.attunedItemsMax": 3});
Expand Down Expand Up @@ -270,7 +271,8 @@ async function toggleTraitsList(app, html, data){
// Check Death Save Status
async function checkDeathSaveStatus(app, html, data){
if(data.editable){
var actor = game.actors.entities.find(a => a.data._id === data.actor._id);
// var actor = game.actors.entities.find(a => a.data._id === data.actor._id);
let actor = app.actor;
var data = actor.data.data;
var currentHealth = data.attributes.hp.value;
var deathSaveSuccess = data.attributes.death.success;
Expand Down Expand Up @@ -344,7 +346,8 @@ async function editProtection(app, html, data) {
async function addClassList(app, html, data) {
if(data.editable){
if (!game.settings.get("tidy5e-sheet", "hideClassList")) {
let actor = game.actors.entities.find(a => a.data._id === data.actor._id);
// let actor = game.actors.entities.find(a => a.data._id === data.actor._id);
let actor = app.actor;
let classList = [];
let items = data.actor.items;
for (let item of items) {
Expand All @@ -365,7 +368,8 @@ async function addClassList(app, html, data) {
// Calculate Spell Attack modifier
async function spellAttackMod(app,html,data){
if(data.editable){
let actor = game.actors.entities.find(a => a.data._id === data.actor._id),
// let actor = game.actors.entities.find(a => a.data._id === data.actor._id),
let actor = app.actor,
prof = actor.data.data.attributes.prof,
spellAbility = html.find('.spellcasting-attribute select option:selected').val(),
abilityMod = spellAbility != '' ? actor.data.data.abilities[spellAbility].mod : 0,
Expand Down Expand Up @@ -411,7 +415,8 @@ function tidyCustomEffect(actor, change) {

// Manage Sheet Options
async function setSheetClasses(app, html, data) {
let actor = game.actors.entities.find(a => a.data._id === data.actor._id);
// let actor = game.actors.entities.find(a => a.data._id === data.actor._id);
let actor = app.actor;
if (game.settings.get("tidy5e-sheet", "disableRightClick")) {
if(game.settings.get("tidy5e-sheet", "useClassicControls")){
html.find('.tidy5e-sheet .grid-layout .items-list').addClass('alt-context');
Expand Down Expand Up @@ -491,15 +496,19 @@ Hooks.on("renderTidy5eSheet", (app, html, data) => {
addClassList(app, html, data);
toggleTraitsList(app, html, data)
checkDeathSaveStatus(app, html, data);
countInventoryItems(app,html,data);
countAttunedItems(app, html, data);
abbreviateCurrency(app,html,data);
spellAttackMod(app,html,data);
addFavorites(app, html, data, position);
countAttunedItems(app, html, data);
countInventoryItems(app,html,data);
// console.log(data.actor);
// console.log("Tidy5e Sheet rendered!");
});

// Hooks.on("updateOwnedItem", (app, html, data) => {
// console.log(data);
// });

// broken at the moment
// Hooks.on("updateActor", (actorObject) => {
// activeEffectsExhaustion(actorObject);
Expand Down
4 changes: 2 additions & 2 deletions src/templates/actors/parts/tidy5e-inventory-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

{{#if isCharacter}}
<div class="attuned-items-counter" title="{{localize 'DND5E.Attunement'}}">
<i class="fas fa-sun"></i> <span class="attuned-items-current">{{data.details.attunedItemsCount}}</span>/<span class="attuned-items-max">{{data.details.attunedItemsMax}}</span>
<input type="text" class="attuned-items-max" name="data.details.attunedItemsMax" value="{{data.details.attunedItemsMax}}" placeholder="0" title="{{localize 'TIDY5E.AttunementMax'}}">
<i class="fas fa-sun"></i> <span class="attuned-items-current">{{#if data.details.attunedItemsCount}}{{data.details.attunedItemsCount}}{{else}}0{{/if}}</span>/<span class="attuned-items-max">{{data.details.attunedItemsMax}}</span>
<input type="text" class="attuned-items-max" name="data.details.attunedItemsMax" value="{{#if data.details.attunedItemsMax}}{{data.details.attunedItemsMax}}{{else}}3{{/if}}" placeholder="0" title="{{localize 'TIDY5E.AttunementMax'}}">
</div>
{{/if}}

Expand Down
4 changes: 2 additions & 2 deletions src/templates/actors/tidy5e-npc.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
{{!-- Temp Hit Points --}}
<div class="portrait-temp">
<input name="data.attributes.hp.temp" type="text" class="temphp" placeholder="+{{ localize 'DND5E.Temp' }}" title="+{{ localize 'DND5E.Temp' }}"
value="{{data.attributes.hp.temp}}" data-dtype="Number" maxlength="5">
value="{{#if (eq data.attributes.hp.temp 0)}}{{else}}{{data.attributes.hp.temp}}{{/if}}" data-dtype="Number" maxlength="5">
<input name="data.attributes.hp.tempmax" type="text" class="max-temphp" placeholder="+{{ localize 'DND5E.Max' }}" title="+{{ localize 'DND5E.Max' }}"
value="{{data.attributes.hp.tempmax}}" data-dtype="Number" maxlength="5">
value="{{#if (eq data.attributes.hp.tempmax 0)}}{{else}}{{data.attributes.hp.tempmax}}{{/if}}" data-dtype="Number" maxlength="5">
</div>

</section>
Expand Down

0 comments on commit b389503

Please sign in to comment.