-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joe A. Spandrusyszyn
committed
Aug 23, 2020
1 parent
c8257fd
commit b5564ed
Showing
4 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
# FoundryVTT-token-hud-scale | ||
# Illandril's Token HUD Scaler | ||
This is a module for Foundry Virtual Tabletop that adjusts the scale of the Token HUD and status effect icons. | ||
|
||
The Token HUD scale is increased by 50%. The Status Effect icons are scaled so that they can fit 3 across for the token. It also increases the opacity of the background behind the Token HUD and Status Effect icons. | ||
|
||
# Installation | ||
1. Open the Configuration and Setup for your FoundryVTT server | ||
1. Open the Add-on Modules Tab | ||
1. Click the Install Module button | ||
1. In the Manifest URL input, specify https://github.com/illandril/FoundryVTT-token-hud-scale/releases/latest/download/module.json | ||
1. Click Install | ||
1. Launch your world | ||
1. Log in as the GM | ||
1. Open the Settings tab | ||
1. Click Manage Modules | ||
1. Check the checkbox for Illandril's Token HUD scaler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Hooks.on("canvasReady", canvas => { | ||
canvas.tokens.placeables.forEach(token => { | ||
token.effects.addListener("childAdded", child => { | ||
fixEffectScale(token, child); | ||
}); | ||
updateEffectScales(token); | ||
}); | ||
}); | ||
|
||
Hooks.on("createToken", (parent, tokenData, options, userId) => { | ||
setTimeout(() => { | ||
const token = canvas.tokens.get(tokenData._id); | ||
token.effects.addListener("childAdded", child => { | ||
fixEffectScale(token, child); | ||
}); | ||
updateEffectScales(token); | ||
}, 1000); | ||
}); | ||
|
||
let pendingUpdates = {}; | ||
|
||
function fixEffectScale(token, child) { | ||
clearTimeout(pendingUpdates[token.id]); | ||
pendingUpdates[token.id] = setTimeout(() => { | ||
updateEffectScales(token); | ||
}, 10); | ||
} | ||
|
||
function updateEffectScales(token) { | ||
const numEffects = token.data.effects.length; | ||
if (numEffects > 0) { | ||
const w = Math.floor(token.width / 3)-1; | ||
const bg = token.effects.children[0]; | ||
bg.clear(); | ||
bg.beginFill(0x000000, 0.60).lineStyle(1.0, 0x000000); | ||
token.effects.children.forEach((effectIcon, i) => { | ||
if ( i === 0 ) { | ||
// BG | ||
} else if ( i <= numEffects ) { | ||
// Effect icon | ||
const ei = i-1; | ||
const x = (ei % 3) * w; | ||
const y = Math.floor(ei / 3) * w; | ||
effectIcon.width = effectIcon.height = w; | ||
effectIcon.position.x = x; | ||
effectIcon.position.y = y; | ||
bg.drawRoundedRect(effectIcon.position.x, effectIcon.position.y, effectIcon.width, effectIcon.width, 2); | ||
} else { | ||
// Overlay icon | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"type": "module", | ||
"name": "illandril-token-hud-scale", | ||
"version": "1.0.0", | ||
"title": "Illandril's Token HUD scaler", | ||
"description": "Adjusts the scale of the Token HUD and status effects for improved usability when zoomed out.", | ||
"author": "Joe Spandrusyszyn", | ||
"minimumCoreVersion": "0.6.5", | ||
"compatibleCoreVersion": "0.6.5", | ||
"styles": ["./styles.css"], | ||
"esmodules": ["./init.js"], | ||
"license": "./LICENSE", | ||
"url": "https://github.com/illandril/FoundryVTT-token-hud-scale", | ||
"bugs": "https://github.com/illandril/FoundryVTT-token-hud-scale/issues", | ||
"manifest": "https://github.com/illandril/FoundryVTT-token-hud-scale/releases/latest/download/module.json", | ||
"download": "https://github.com/illandril/FoundryVTT-token-hud-scale/releases/download/v1.0.0/illandril-sheet5e-lockdown.zip" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#token-hud .control-icon { | ||
background: rgba(0,0,0,0.8); | ||
} | ||
|
||
#token-hud .status-effects { | ||
width: 152px; | ||
grid-template-columns: 38px 38px 38px 38px; | ||
background: rgba(0,0,0,0.8); | ||
} | ||
|
||
#token-hud .status-effects .effect-control { | ||
width: 36px; | ||
height: 36px; | ||
} | ||
|
||
#token-hud .col.right { | ||
transform: scale(1.5); | ||
right: -80px; | ||
} | ||
|
||
#token-hud .col.left { | ||
transform: scale(1.5); | ||
left: -80px; | ||
} |