Skip to content

Commit

Permalink
v2.5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mclemente committed Mar 31, 2021
1 parent f1206f2 commit ca02e17
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 160 deletions.
30 changes: 2 additions & 28 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "healthEstimate2",
"name": "healthEstimate",
"title": "Health Estimate 2",
"description": "Gives players ability to see approximate health status of a token",
"version": "1.0.0.3",
"version": "2.5.0.0",
"author": "MClemente, Shylight",
"scripts": [
"./lib/chroma.min.js",
Expand Down Expand Up @@ -58,32 +58,6 @@
"path": "./lang/pt-BR.json"
}
],
"systems": [
"archmage",
"D35E",
"dungeonworld",
"fate",
"lancer",
"numenera",
"ose",
"pf1",
"pf2e",
"ryuutama",
"shadowrun5e",
"swade",
"symbaroum",
"tormenta20",
"twodsix",
"wfrp4e",
"worldbuilding",
"starfinder",
"dnd5e",
"sw5e",
"blades-in-the-dark",
"foundryvtt-reve-de-dragon",
"tormenta20",
"uesrpg-d100"
],
"minimumCoreVersion": "0.5.0",
"compatibleCoreVersion": "0.7.9",
"url": "https://github.com/mclemente/healthEstimate",
Expand Down
57 changes: 29 additions & 28 deletions module/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import {breakOverlayRender, descriptionToShow, fractionFormula, updateBreakSetti
import {sGet} from './utils.js'

let descriptions, deathStateName, showDead, useColor, smooth, isDead, NPCsJustDie, deathMarker,
colors, outline, deadColor, deadOutline, perfectionism
colors, outline, deadColor, deadOutline, perfectionism, outputChat, npcName

export function updateSettings () {
useColor = sGet('core.menuSettings.useColor')
descriptions = sGet('core.stateNames').split(/[,;]\s*/)
smooth = sGet('core.menuSettings.smoothGradient')
useColor = sGet('core.menuSettings.useColor')
descriptions = sGet('core.stateNames').split(/[,;]\s*/)
smooth = sGet('core.menuSettings.smoothGradient')
deathStateName = sGet('core.deathStateName')
showDead = sGet('core.deathState')
NPCsJustDie = sGet('core.NPCsJustDie')
deathMarker = sGet('core.deathMarker')
colors = sGet('core.variables.colors')[0]
outline = sGet('core.variables.outline')[0]
deadColor = sGet('core.variables.deadColor')
deadOutline = sGet('core.variables.deadOutline')
perfectionism = sGet('core.perfectionism')
showDead = sGet('core.deathState')
NPCsJustDie = sGet('core.NPCsJustDie')
deathMarker = sGet('core.deathMarker')
colors = sGet('core.variables.colors')[0]
outline = sGet('core.variables.outline')[0]
deadColor = sGet('core.variables.deadColor')
deadOutline = sGet('core.variables.deadOutline')
perfectionism = sGet('core.perfectionism')

const margin = `${sGet('core.menuSettings.positionAdjustment')}em`
const margin = `${sGet('core.menuSettings.positionAdjustment')}em`
const alignment = sGet('core.menuSettings.position')
document.documentElement.style.setProperty('--healthEstimate-margin', margin)
document.documentElement.style.setProperty('--healthEstimate-alignment', alignment)
Expand All @@ -29,22 +29,22 @@ export function updateSettings () {
`return (
${NPCsJustDie ? '(!token.actor.hasPlayerOwner && stage === 0) ||' : ''}
${showDead ? `token.actor.effects.entries.some(x => x.data.icon === '${deathMarker}') ||` : ''}
token.getFlag('healthEstimate2', 'dead')
token.getFlag('healthestimate', 'dead')
)`
)
}

class HealthEstimateOverlay extends BasePlaceableHUD {
static get defaultOptions () {
const options = super.defaultOptions
options.classes = options.classes.concat(['healthEstimate', 'healthEstimateColor'])
options.template = 'modules/healthEstimate2/templates/healthEstimate.hbs'
options.id = 'healthEstimate'
const options = super.defaultOptions
options.classes = options.classes.concat(['healthEstimate', 'healthEstimateColor'])
options.template = 'modules/healthestimate/templates/healthEstimate.hbs'
options.id = 'healthEstimate'
return options
}

getData () {
const data = super.getData()
const data = super.getData()
data.status = this.estimation
return data
}
Expand All @@ -58,7 +58,6 @@ export class HealthEstimate {
this.initHooks()
}


initHooks () {
Hooks.on('hoverToken', (token, hovered) => {
this._handleOverlay(token, hovered)
Expand All @@ -67,6 +66,7 @@ export class HealthEstimate {
Hooks.on('deleteToken', (...args) => {
canvas.hud.HealthEstimate.clear()
})

Hooks.on('updateToken', (scene, token, ...args) => {
if (canvas.hud.HealthEstimate !== undefined && canvas.hud.HealthEstimate.object !== null) {
if (token._id === canvas.hud.HealthEstimate.object.id) {
Expand All @@ -86,33 +86,34 @@ export class HealthEstimate {
if (hovered) {
this._getEstimation(token)
canvas.hud.HealthEstimate.bind(token)
} else {
}
else {
canvas.hud.HealthEstimate.clear()
}
}

_getEstimation (token) {
const fraction = Math.min(fractionFormula(token), 1)
const stage = Math.max(0,
const fraction = Math.min(fractionFormula(token), 1)
const stage = Math.max(0,
perfectionism ?
Math.ceil((descriptions.length - 2 + Math.floor(fraction)) * fraction) :
Math.ceil((descriptions.length - 1) * fraction),
)
const colorIndex = Math.max(0, Math.ceil((colors.length - 1) * fraction))
let desc, color, stroke

desc = descriptionToShow(descriptions, stage, token, {
desc = descriptionToShow(descriptions, stage, token, {
isDead: isDead(token, stage),
desc : deathStateName,
desc : deathStateName,
}, fraction)
color = colors[colorIndex]
color = colors[colorIndex]
stroke = outline[colorIndex]
if (isDead(token, stage)) {
color = deadColor
color = deadColor
stroke = deadOutline
}
document.documentElement.style.setProperty('--healthEstimate-stroke-color', stroke)
document.documentElement.style.setProperty('--healthEstimate-text-color', color)
canvas.hud.HealthEstimate.estimation = {desc}
}
}
}
4 changes: 2 additions & 2 deletions module/preloadTemplates.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const preloadTemplates = async function () {
const templatePaths = [
// Add paths to "modules/healthEstimate2/templates"
'modules/healthEstimate2/templates/healthEstimate.hbs'
// Add paths to "modules/healthestimate/templates"
'modules/healthestimate/templates/healthEstimate.hbs'
]

return loadTemplates(templatePaths)
Expand Down
2 changes: 1 addition & 1 deletion module/styleSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class HealthEstimateStyleSettings extends FormApplication {
return mergeObject(super.defaultOptions, {
id : 'healthestimate-style-form',
title : 'Health Estimate Style Settings',
template : './modules/healthEstimate2/templates/settings.hbs',
template : './modules/healthestimate/templates/settings.hbs',
classes : ['sheet'],
width : 640,
height : 480,
Expand Down
2 changes: 1 addition & 1 deletion packs/macros.db
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"_id":"FUnpsmyP2zPf79JL","name":"Mark Dead","permission":{"default":0,"Y2U0NDkzODdlOTk1":3},"type":"script","flags":{"combat-utility-belt":{"macroTrigger":""}},"scope":"global","command":"/**\r\n* This macro will mark the selected tokens as dead.\r\n* If all the selected tokens are dead, they will be marked\r\n as alive instead.\r\n*/\r\n\r\nlet hasAlive = false;\r\nfor (let e of canvas.tokens.controlled) {\r\n\tif (!e.getFlag(\"healthEstimate2\", \"dead\")) {\r\n\t\thasAlive = true;\r\n\t\tbreak\r\n\t}\r\n}\r\nfor (let e of canvas.tokens.controlled) {\r\n\te.setFlag(\"healthEstimate2\", \"dead\", hasAlive)\r\n}","author":"Y2U0NDkzODdlOTk1","img":"icons/svg/bones.svg","actorIds":[]}
{"_id":"FUnpsmyP2zPf79JL","name":"Mark Dead","permission":{"default":0,"Y2U0NDkzODdlOTk1":3},"type":"script","flags":{"combat-utility-belt":{"macroTrigger":""}},"scope":"global","command":"/**\r\n* This macro will mark the selected tokens as dead.\r\n* If all the selected tokens are dead, they will be marked\r\n as alive instead.\r\n*/\r\n\r\nlet hasAlive = false;\r\nfor (let e of canvas.tokens.controlled) {\r\n\tif (!e.getFlag(\"healthestimate\", \"dead\")) {\r\n\t\thasAlive = true;\r\n\t\tbreak\r\n\t}\r\n}\r\nfor (let e of canvas.tokens.controlled) {\r\n\te.setFlag(\"healthestimate\", \"dead\", hasAlive)\r\n}","author":"Y2U0NDkzODdlOTk1","img":"icons/svg/bones.svg","actorIds":[]}
6 changes: 3 additions & 3 deletions templates/healthEstimate.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="{{id}}" class="{{classes}}" data-appid="{{appId}}">
<span class="estimation">
{{status.desc}}
</span>
<span class="estimation">
{{status.desc}}
</span>
</div>
194 changes: 97 additions & 97 deletions templates/settings.hbs
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
<form autocomplete="off" style="padding: 0 2.5%" onsubmit="event.preventDefault()" style="display: flex;flex-direction: column;">
<div class="form-group" style="align-items: flex-end;">
<label for="useColor" style="flex:none;margin-right: 3px">{{useColor.name}}</label>
<input type="checkbox" name="useColor" id="useColor" {{#if useColor.value}}checked="checked"{{/if}}>
<p class="notes">{{useColor.hint}}</p>
</div>
<div class="form-group">
{{#with smoothGradient}}
<label for="smoothGradient">{{localize name}}</label>
<input type="checkbox" name="smoothGradient" id="smoothGradient" {{#if value}}checked="checked"{{/if}}>
<p class="notes">{{localize hint}}</p>
{{/with}}
</div>
<div class="form-group">
<span style="flex-direction: column">
<div id="gradientExampleHE"></div>
<div id="gradientControlsHE"></div>
</span>
<span class="gradient-settings">
<select name="mode" id="mode">
{{#each mode.select}}
<option value="{{this.key}}" {{#if this.selected}}selected="selected"{{/if}}>{{this.value}}</option>
{{/each}}
</select>
</span>
</div>
<div class="form-group">
{{#with deadColor}}
<label for="deadColor">{{localize name}}</label>
<input type="text" name="deadColor" id="deadColor">
{{/with}}
</div>
<div class="form-group">
<div>
<div class="form-group">
{{#with outline}}
<label for="outline">{{localize name}}</label>
<select name="outlineMode" class="form-fileds" id="outlineMode" style="flex:2.2">
{{#each select}}
<option value="{{this.key}}" {{#if this.selected}}selected="selected"{{/if}}>{{this.value}}</option>
{{/each}}
</select>
<span style="flex:0;margin-top:0.1em;font-size: 17px">&nbsp;×&nbsp;</span>
<input type="number" step="0.1" min="0" value="{{multiplier}}" name="outlineIntensity"
id="outlineIntensity"
class="numberHE"
style="flex: 0 0 4em">
{{/with}}
</div>
<div class="form-group">
{{#with fontSize}}
<label for="fontSize">{{localize name}}</label>
<input type="text" value="{{value}}" name="fontSize" id="fontSize">
<p class="notes">{{localize hint}}</p>
{{/with}}
</div>
<div class="form-group">
<label for="positionAdjustment">{{localize position.name}}</label>
<select name="position" class="form-fileds" id="position" style="flex:2.2">
{{#each position.select}}
<option value="{{this.key}}" {{#if this.selected}}selected="selected"{{/if}}>{{this.value}}</option>
{{/each}}
</select>
<span style="flex:0;margin-top:0.1em;font-size: 17px">&nbsp;×&nbsp;</span>
<input type="number" step="0.1" value="{{positionAdjustment.value}}" name="positionAdjustment" id="positionAdjustment"
class="numberHE"
style="flex: 0 0 4em">
<p class="notes">{{localize positionAdjustment.hint}}</p>
</div>
</div>
<div style="flex:0; margin: 20px 10px 0 30px;">
<span class="sampleFrameHE">
<img src="./modules/healthEstimate2/static/frame.png" alt="" style="margin-bottom: -106px">
<div id="healthEstimateSample" class="healthEstimate" style="height: 106px;width: 106px">
<span style="display:flex; justify-content: center">
<span class="healthEstimateColor">Text&nbsp;</span>
<span class="healthEstimateColor">S</span>
<span class="healthEstimateColor">a</span>
<span class="healthEstimateColor">m</span>
<span class="healthEstimateColor">p</span>
<span class="healthEstimateColor">l</span>
<span class="healthEstimateColor">e</span>
</span>
</div>
</span>
</div>
</div>
<div class="form-group">
<label for=""></label>
</div>
<footer class="sheet-footer flexrow" style="margin-top: auto">
<!-- <button type="button" name="reset">-->
<!-- <i class="fas fa-undo"></i> {{localize 'SETTINGS.Reset'}}-->
<!-- </button>-->
<button type="submit" name="submit">
<i class="far fa-save"></i> {{localize 'SETTINGS.Save'}}
</button>
</footer>
<div class="form-group" style="align-items: flex-end;">
<label for="useColor" style="flex:none;margin-right: 3px">{{useColor.name}}</label>
<input type="checkbox" name="useColor" id="useColor" {{#if useColor.value}}checked="checked"{{/if}}>
<p class="notes">{{useColor.hint}}</p>
</div>
<div class="form-group">
{{#with smoothGradient}}
<label for="smoothGradient">{{localize name}}</label>
<input type="checkbox" name="smoothGradient" id="smoothGradient" {{#if value}}checked="checked"{{/if}}>
<p class="notes">{{localize hint}}</p>
{{/with}}
</div>
<div class="form-group">
<span style="flex-direction: column">
<div id="gradientExampleHE"></div>
<div id="gradientControlsHE"></div>
</span>
<span class="gradient-settings">
<select name="mode" id="mode">
{{#each mode.select}}
<option value="{{this.key}}" {{#if this.selected}}selected="selected"{{/if}}>{{this.value}}</option>
{{/each}}
</select>
</span>
</div>
<div class="form-group">
{{#with deadColor}}
<label for="deadColor">{{localize name}}</label>
<input type="text" name="deadColor" id="deadColor">
{{/with}}
</div>
<div class="form-group">
<div>
<div class="form-group">
{{#with outline}}
<label for="outline">{{localize name}}</label>
<select name="outlineMode" class="form-fileds" id="outlineMode" style="flex:2.2">
{{#each select}}
<option value="{{this.key}}" {{#if this.selected}}selected="selected"{{/if}}>{{this.value}}</option>
{{/each}}
</select>
<span style="flex:0;margin-top:0.1em;font-size: 17px">&nbsp;×&nbsp;</span>
<input type="number" step="0.1" min="0" value="{{multiplier}}" name="outlineIntensity"
id="outlineIntensity"
class="numberHE"
style="flex: 0 0 4em">
{{/with}}
</div>
<div class="form-group">
{{#with fontSize}}
<label for="fontSize">{{localize name}}</label>
<input type="text" value="{{value}}" name="fontSize" id="fontSize">
<p class="notes">{{localize hint}}</p>
{{/with}}
</div>
<div class="form-group">
<label for="positionAdjustment">{{localize position.name}}</label>
<select name="position" class="form-fileds" id="position" style="flex:2.2">
{{#each position.select}}
<option value="{{this.key}}" {{#if this.selected}}selected="selected"{{/if}}>{{this.value}}</option>
{{/each}}
</select>
<span style="flex:0;margin-top:0.1em;font-size: 17px">&nbsp;×&nbsp;</span>
<input type="number" step="0.1" value="{{positionAdjustment.value}}" name="positionAdjustment" id="positionAdjustment"
class="numberHE"
style="flex: 0 0 4em">
<p class="notes">{{localize positionAdjustment.hint}}</p>
</div>
</div>
<div style="flex:0; margin: 20px 10px 0 30px;">
<span class="sampleFrameHE">
<img src="./modules/healthestimate/static/frame.png" alt="" style="margin-bottom: -106px">
<div id="healthEstimateSample" class="healthEstimate" style="height: 106px;width: 106px">
<span style="display:flex; justify-content: center">
<span class="healthEstimateColor">Text&nbsp;</span>
<span class="healthEstimateColor">S</span>
<span class="healthEstimateColor">a</span>
<span class="healthEstimateColor">m</span>
<span class="healthEstimateColor">p</span>
<span class="healthEstimateColor">l</span>
<span class="healthEstimateColor">e</span>
</span>
</div>
</span>
</div>
</div>
<div class="form-group">
<label for=""></label>
</div>
<footer class="sheet-footer flexrow" style="margin-top: auto">
<!-- <button type="button" name="reset">-->
<!-- <i class="fas fa-undo"></i> {{localize 'SETTINGS.Reset'}}-->
<!-- </button>-->
<button type="submit" name="submit">
<i class="far fa-save"></i> {{localize 'SETTINGS.Save'}}
</button>
</footer>
</form>

0 comments on commit ca02e17

Please sign in to comment.