Skip to content

Commit

Permalink
Merge pull request #685 from p4535992/master
Browse files Browse the repository at this point in the history
Bugs fix
  • Loading branch information
p4535992 authored Feb 6, 2023
2 parents d6c24bd + 0733e07 commit cdad3c9
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 17 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Thank you very much!

## Version History

### Version 0.8.5-6-7-8-9-10-1-12-13-14-15-16-17

- Bug fixing and improvements

### Version 0.8.0-1-2-3-4

- Compatibility with dnd5e 2.1.X
Expand Down
1 change: 1 addition & 0 deletions src/_scss/_items.scss
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
list-style: none;
margin: 0;
padding: 0;
width: 100%;

li {
border-left: 1px solid var(--t5e-faint-color);
Expand Down
4 changes: 2 additions & 2 deletions src/_scss/partials/_character-details.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
}

.current-xp {
width: calc(7.5ch + 0.3rem);
width: calc(10.5ch + 0.3rem);
height: 16px;
text-align: right;
padding: 0 4px;
}

.max-xp {
width: calc(8.5ch + 0.3rem);
width: calc(10.5ch + 0.3rem);
height: 16px;
text-align: left;
padding: 0 4px;
Expand Down
5 changes: 3 additions & 2 deletions src/css/tidy5e.css
Original file line number Diff line number Diff line change
Expand Up @@ -1311,13 +1311,13 @@
align-items: center;
}
.tidy5e.sheet.actor .current-xp {
width: calc(7.5ch + 0.3rem);
width: calc(10.5ch + 0.3rem);
height: 16px;
text-align: right;
padding: 0 4px;
}
.tidy5e.sheet.actor .max-xp {
width: calc(8.5ch + 0.3rem);
width: calc(10.5ch + 0.3rem);
height: 16px;
text-align: left;
padding: 0 4px;
Expand Down Expand Up @@ -3133,6 +3133,7 @@
padding: 0.5rem;
border-top: 1px solid var(--t5e-faint-color);
font-size: 12px;
width: 100%;
}
.tidy5e.sheet.actor .items-list .item .item-summary p:not(:first-child) {
margin-top: 0.5em;
Expand Down
6 changes: 3 additions & 3 deletions src/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "tidy5e-sheet",
"title": "Tidy5e Sheet",
"description": "Replaces the default D&D 5e character and NPC sheet with an alternate layout focused on a cleaner UI",
"version": "0.8.14",
"version": "0.8.17",
"authors": [
{
"name": "sednec#3813"
Expand Down Expand Up @@ -85,8 +85,8 @@
}
],
"url": "https://github.com/sdenec/tidy5e-sheet",
"manifest": "https://github.com/sdenec/tidy5e-sheet/releases/download/v0.8.14/module.json",
"download": "https://github.com/sdenec/tidy5e-sheet/releases/download/v0.8.14/module.zip",
"manifest": "https://github.com/sdenec/tidy5e-sheet/releases/download/v0.8.17/module.json",
"download": "https://github.com/sdenec/tidy5e-sheet/releases/download/v0.8.17/module.zip",
"relationships": {
"systems": [
{
Expand Down
3 changes: 3 additions & 0 deletions src/scripts/app/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function is_real_number(inNumber) {
return !isNaN(inNumber) && typeof inNumber === "number" && isFinite(inNumber);
}
5 changes: 1 addition & 4 deletions src/scripts/app/tidy5e-favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { applyColorPickerCustomization } from "./color-picker.js";
import CONSTANTS from "./constants.js";
import { tidy5eContextMenu } from "./context-menu.js";
import { is_real_number } from "./helpers.js";

export const isItemFavorite = function (item) {
if (!item) {
Expand All @@ -42,10 +43,6 @@ export const isItemFavorite = function (item) {
return isFav;
};

function is_real_number(inNumber) {
return !isNaN(inNumber) && typeof inNumber === "number" && isFinite(inNumber);
}

export const addFavorites = async function (app, html, data, position) {
let favs = app.actor.items.filter((i) => {
return isItemFavorite(i);
Expand Down
15 changes: 15 additions & 0 deletions src/scripts/tidy5e-npc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { applyLocksNpcSheet } from "./app/lockers.js";
import { applyColorPickerCustomization } from "./app/color-picker.js";
import { addFavorites } from "./app/tidy5e-favorites.js";
import CONSTANTS from "./app/constants.js";
import { is_real_number } from "./app/helpers.js";

/**
* An Actor sheet for NPC type characters in the D&D5E system.
Expand Down Expand Up @@ -242,6 +243,20 @@ export default class Tidy5eNPC extends dnd5e.applications.actor.ActorSheet5eNPC
context.rightClickDisabled = game.settings.get(CONSTANTS.MODULE_ID, "rightClickDisabled");
context.classicControlsEnabled = game.settings.get(CONSTANTS.MODULE_ID, "classicControlsEnabled");
context.classicControlsDisabled = !game.settings.get(CONSTANTS.MODULE_ID, "classicControlsEnabled");

context.hpOverlayCalculationCurrent =
(
100 /
(
(is_real_number(this.actor.system?.attributes?.hp?.max) ? this.actor.system.attributes.hp.max : 1)
+ (is_real_number(this.actor.system?.attributes?.hp?.tempmax) ? this.actor.system.attributes.hp.tempmax : 0)
)
)
* (is_real_number(this.actor.system?.attributes?.hp?.value) ? this.actor.system.attributes.hp.value : 0)
+ (is_real_number(this.actor.system?.attributes?.hp?.temp) ? this.actor.system.attributes.hp.temp : 0);

context.hpOverlayCalculationCurrent = context.hpOverlayCalculationCurrent + "%"

return context;
}

Expand Down
14 changes: 14 additions & 0 deletions src/scripts/tidy5e-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { applySpellClassFilterActorSheet } from "./app/spellClassFilter.js";
import { updateExhaustion } from "./app/exhaustion.js";
import { HexToRGBA, colorPicker, mapDefaultColorsRGBA, mapDefaultColorsDarkRGBA, mapDefaultColorsDarkRGB, mapDefaultColorsRGB, applyColorPickerCustomization } from "./app/color-picker.js";
import CONSTANTS from "./app/constants.js";
import { is_real_number } from "./app/helpers.js";

let position = 0;

Expand Down Expand Up @@ -100,6 +101,19 @@ export class Tidy5eSheet extends dnd5e.applications.actor.ActorSheet5eCharacter
context.classicControlsEnabled = game.settings.get(CONSTANTS.MODULE_ID, "classicControlsEnabled");
context.classicControlsDisabled = !game.settings.get(CONSTANTS.MODULE_ID, "classicControlsEnabled");

context.hpOverlayCalculationCurrent =
(
100 /
(
(is_real_number(this.actor.system?.attributes?.hp?.max) ? this.actor.system.attributes.hp.max : 1)
+ (is_real_number(this.actor.system?.attributes?.hp?.tempmax) ? this.actor.system.attributes.hp.tempmax : 0)
)
)
* (is_real_number(this.actor.system?.attributes?.hp?.value) ? this.actor.system.attributes.hp.value : 0)
+ (is_real_number(this.actor.system?.attributes?.hp?.temp) ? this.actor.system.attributes.hp.temp : 0);

context.hpOverlayCalculationCurrent = context.hpOverlayCalculationCurrent + "%"

const exhaustionTooltipPrefix = `${game.i18n.localize("DND5E.Exhaustion")} ${game.i18n.localize("DND5E.AbbreviationLevel")} ${this.actor.system.attributes.exhaustion}`;
if (this.actor.system.attributes.exhaustion === 0) {
context.exhaustionTooltip = exhaustionTooltipPrefix + `, ${game.i18n.localize("TIDY5E.Exhaustion0")}`;
Expand Down
15 changes: 15 additions & 0 deletions src/scripts/tidy5e-vehicle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { applyLazyExp, applyLazyHp } from "./app/lazyExpAndHp.js";
import { applyLocksVehicleSheet } from "./app/lockers.js";
import { applyColorPickerCustomization } from "./app/color-picker.js";
import CONSTANTS from "./app/constants.js";
import { is_real_number } from "./app/helpers.js";

export class Tidy5eVehicle extends dnd5e.applications.actor.ActorSheet5eVehicle {
static get defaultOptions() {
Expand Down Expand Up @@ -50,6 +51,20 @@ export class Tidy5eVehicle extends dnd5e.applications.actor.ActorSheet5eVehicle
context.rightClickDisabled = game.settings.get(CONSTANTS.MODULE_ID, "rightClickDisabled");
context.classicControlsEnabled = game.settings.get(CONSTANTS.MODULE_ID, "classicControlsEnabled");
context.classicControlsDisabled = !game.settings.get(CONSTANTS.MODULE_ID, "classicControlsEnabled");

context.hpOverlayCalculationCurrent =
(
100 /
(
(is_real_number(this.actor.system?.attributes?.hp?.max) ? this.actor.system.attributes.hp.max : 1)
+ (is_real_number(this.actor.system?.attributes?.hp?.tempmax) ? this.actor.system.attributes.hp.tempmax : 0)
)
)
* (is_real_number(this.actor.system?.attributes?.hp?.value) ? this.actor.system.attributes.hp.value : 0)
+ (is_real_number(this.actor.system?.attributes?.hp?.temp) ? this.actor.system.attributes.hp.temp : 0);

context.hpOverlayCalculationCurrent = context.hpOverlayCalculationCurrent + "%"

return context;
}

Expand Down
9 changes: 7 additions & 2 deletions src/templates/actors/tidy5e-npc.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@

{{!-- HP Overlay --}}
<div class="hp-overlay-wrapper">
<div class="hp-overlay" style="background: linear-gradient(0deg, rgba(255, 0, 0, 1) 0%, rgba(255, 0, 0, 1) calc(100% - ((100% / ({{system.attributes.hp.max}} + {{#if system.attributes.hp.tempmax}}{{system.attributes.hp.tempmax}}{{else}}0{{/if}} )) * ({{system.attributes.hp.value}} + {{#if system.attributes.hp.temp}}{{system.attributes.hp.temp}}{{else}}0{{/if}})) ), rgba(255, 255, 255, 1) calc(100% - ((100% / ({{system.attributes.hp.max}} + {{#if system.attributes.hp.tempmax}}{{system.attributes.hp.tempmax}}{{else}}0{{/if}} )) * ({{system.attributes.hp.value}} + {{#if system.attributes.hp.temp}}{{system.attributes.hp.temp}}{{else}}0{{/if}})) ), rgba(255, 255, 255, 1) 100%);">
<div class="hp-overlay" style="background: linear-gradient(
0deg,
rgba(255, 0, 0, 1) 0%,
rgba(255, 0, 0, 1) calc(100% - {{hpOverlayCalculationCurrent}}),
rgba(255, 255, 255, 1) calc(100% - {{hpOverlayCalculationCurrent}}),
rgba(255, 255, 255, 1) 100%);">
</div>
</div>

Expand Down Expand Up @@ -262,7 +267,7 @@ <h4 class="ability-name box-title rollable" title="{{ability.label}}">{{ability.
<input type="hidden" name="system.skills.{{s}}.value" value="{{skill.baseValue}}" data-dtype="Number">
<a class="proficiency-toggle skill-proficiency" title="{{skill.hover}}">{{{skill.icon}}}</a>
<h4 class="skill-name rollable">{{skill.label}}</h4>
<span class="skill-ability">{{skill.ability}}</span>
<span class="skill-ability">{{skill.abbreviation}}</span>
<span class="skill-mod">{{numberFormat skill.total decimals=0 sign=true}}</span>
<span class="skill-passive" title="{{skill.label}} ({{ localize 'DND5E.Passive' }})">({{skill.passive}})</span>
</li>
Expand Down
6 changes: 3 additions & 3 deletions src/templates/actors/tidy5e-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
<div class="hp-overlay" style="background: linear-gradient(
0deg,
rgba(255, 0, 0, 1) 0%,
rgba(255, 0, 0, 1) calc(100% - ((100% / ({{#if (eq system.attributes.hp.max 0)}} 1 {{else}} {{system.attributes.hp.max}} {{/if}} + {{#if system.attributes.hp.tempmax}}{{system.attributes.hp.tempmax}}{{else}}0{{/if}} )) * ({{system.attributes.hp.value}} + {{#if system.attributes.hp.temp}}{{system.attributes.hp.temp}}{{else}}0{{/if}})) ),
rgba(255, 255, 255, 1) calc(100% - ((100% / ({{#if (eq system.attributes.hp.max 0)}} 1 {{else}} {{system.attributes.hp.max}} {{/if}} + {{#if system.attributes.hp.tempmax}}{{system.attributes.hp.tempmax}}{{else}}0{{/if}} )) * ({{system.attributes.hp.value}} + {{#if system.attributes.hp.temp}}{{system.attributes.hp.temp}}{{else}}0{{/if}})) ),
rgba(255, 0, 0, 1) calc(100% - {{hpOverlayCalculationCurrent}}),
rgba(255, 255, 255, 1) calc(100% - {{hpOverlayCalculationCurrent}}),
rgba(255, 255, 255, 1) 100%);">
</div>
</div>
Expand Down Expand Up @@ -340,7 +340,7 @@ <h4 class="ability-name box-title rollable" title="{{ability.label}}">{{ability.
<input type="hidden" name="system.skills.{{s}}.value" value="{{skill.value}}" data-dtype="Number">
<a class="proficiency-toggle skill-proficiency" title="{{skill.hover}}">{{{skill.icon}}}</a>
<h4 class="skill-name rollable">{{skill.label}}</h4>
<span class="skill-ability">{{skill.ability}}</span>
<span class="skill-ability">{{skill.abbreviation}}</span>
<span class="skill-mod">{{numberFormat skill.total decimals=0 sign=true}}</span>
<span class="skill-passive" title="{{skill.label}} ({{ localize 'DND5E.Passive' }})">({{skill.passive}})</span>
</li>
Expand Down
7 changes: 6 additions & 1 deletion src/templates/actors/tidy5e-vehicle.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
<div class="hp-overlay-wrapper">
<div
class="hp-overlay"
style="background: linear-gradient(0deg, rgba(255, 0, 0, 1) 0%, rgba(255, 0, 0, 1) calc(100% - ((100% / ({{system.attributes.hp.max}} + {{#if system.attributes.hp.tempmax}}{{system.attributes.hp.tempmax}}{{else}}0{{/if}} )) * ({{system.attributes.hp.value}} + {{#if system.attributes.hp.temp}}{{system.attributes.hp.temp}}{{else}}0{{/if}})) ), rgba(255, 255, 255, 1) calc(100% - ((100% / ({{system.attributes.hp.max}} + {{#if system.attributes.hp.tempmax}}{{system.attributes.hp.tempmax}}{{else}}0{{/if}} )) * ({{system.attributes.hp.value}} + {{#if system.attributes.hp.temp}}{{system.attributes.hp.temp}}{{else}}0{{/if}})) ), rgba(255, 255, 255, 1) 100%);"
style="background: linear-gradient(
0deg,
rgba(255, 0, 0, 1) 0%,
rgba(255, 0, 0, 1) calc(100% - {{hpOverlayCalculationCurrent}}),
rgba(255, 255, 255, 1) calc(100% - {{hpOverlayCalculationCurrent}}),
rgba(255, 255, 255, 1) 100%);"
></div>
</div>

Expand Down

0 comments on commit cdad3c9

Please sign in to comment.