Skip to content

Commit

Permalink
2.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorako committed Apr 12, 2023
1 parent 44bfa88 commit 939d535
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 22 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# 2.1.4

- (Refinement) Adjusted token effect icons are now larger.
- (Fix) Skull overlay should be more reasonably sized when the adjusted token effect setting is enabled.

# 2.1.3

- (Module) Add support for Item Piles. The current implementation should also add support for other Svelte-based modules, but if that turns out to be too breaky I'll have to adjust.

# 2.1.2

- (Fix) Fixed an issue that messed up the token effects HUD when the new experimental setting was _not_ enabled
- (Fix) Fixed an issue that messed up the token effects HUD when the new experimental setting was _not_ enabled.

# 2.1.1

- (Fix) Adjust token effects HUD setting now accounts for the scene's gridsize
- (Refinement) Adjust token effects HUD setting now looks nicer
- (Fix) Adjust token effects HUD setting now accounts for the scene's gridsize.
- (Refinement) Adjust token effects HUD setting now looks nicer.

# 2.1.0

Expand Down
73 changes: 54 additions & 19 deletions modules/pixi.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ Token.prototype._refreshEffects = function (...args) {
}
};

const origDrawOverlay = Token.prototype._drawOverlay;
Token.prototype._drawOverlay = async function (src, tint) {
const enabled = game.settings.get("pf2e-dorako-ui", "ux.adjust-token-effects-hud");
if (!enabled) {
origDrawOverlay.apply(this, args);
return;
}
const icon = await this._drawEffect(src, tint);
if (icon) {
const gridSize = this.scene?.grid?.size ?? 100;
const gridScale = gridSize / 100;
const tile = this.document.width;
icon.alpha = 0.8;
icon.x = 24 * gridScale * tile;
icon.y = 24 * gridScale * tile;
icon.width = 48 * gridScale * tile;
icon.height = 48 * gridScale * tile;
}
// icon.anchor.set(0.5);
// debugger;
return icon;
};

// const origDrawEffect = Token.prototype._drawEffect;
// Token.prototype._drawEffect = async function (...args) {
// // origDrawEffect.apply(this, args);
Expand Down Expand Up @@ -64,28 +87,30 @@ Token.prototype._refreshEffects = function (...args) {
// }

// const isSmall = this.document.actor.size === "sm";
// const gridSize = this.scene?.grid?.size ?? 100;
// const gridScale = gridSize / 100;
// const scale = isSmall ? 0.8 : 1;
// const h = Math.round(t / 2);
// const o = Math.round(h / 2);

// this.border
// .lineStyle(t, 0x956d58, 1)
// .drawCircle((this.document.width * gridSize) / 2, (this.document.height * gridSize) / 2, gridScale * 104 * scale);
// this.border
// .lineStyle(t, 0xe9d7a1, 1)
// .drawCircle((this.document.width * gridSize) / 2, (this.document.height * gridSize) / 2, gridScale * 100 * scale);
// this.border
// .lineStyle(t, 0x956d58, 1)
// .drawCircle((this.document.width * gridSize) / 2, (this.document.height * gridSize) / 2, gridScale * 94 * scale);
// // this.border
// // .lineStyle(t, 0x956d58, 1)
// // .lineStyle(t, 0x23261a, 1)
// // .drawCircle((this.document.width * 200) / 2, (this.document.height * 200) / 2, 104 * scale);
// // this.border
// // .lineStyle(t, 0xe9d7a1, 1)
// // .lineStyle(t, 0xeceec5, 1)
// // .drawCircle((this.document.width * 200) / 2, (this.document.height * 200) / 2, 100 * scale);
// // this.border
// // .lineStyle(t, 0x956d58, 1)
// // .lineStyle(t, 0x3e4031, 1)
// // .drawCircle((this.document.width * 200) / 2, (this.document.height * 200) / 2, 94 * scale);
// this.border
// .lineStyle(t, 0x23261a, 1)
// .drawCircle((this.document.width * 200) / 2, (this.document.height * 200) / 2, 104 * scale);
// this.border
// .lineStyle(t, 0xeceec5, 1)
// .drawCircle((this.document.width * 200) / 2, (this.document.height * 200) / 2, 100 * scale);
// this.border
// .lineStyle(t, 0x3e4031, 1)
// .drawCircle((this.document.width * 200) / 2, (this.document.height * 200) / 2, 94 * scale);
// };

const countEffects = (token) => {
Expand Down Expand Up @@ -124,7 +149,8 @@ const updateIconPosition = (effectIcon, i, effectIcons, token) => {
const actorSize = token?.actor?.size;
let max = 20;
if (actorSize == "tiny") max = 10;
if (actorSize == "sm") max = 16;
if (actorSize == "sm") max = 14;
if (actorSize == "med") max = 16;
const ratio = i / max;
// const angularOffset = i < max ? 0 : ratio / 2;
const gridSize = token?.scene?.grid?.size ?? 100;
Expand All @@ -142,11 +168,11 @@ const updateIconPosition = (effectIcon, i, effectIcons, token) => {
// Nudge icons to be on the token ring or slightly outside
function sizeToOffset(size) {
if (size == "tiny") {
return 1.3;
return 1.4;
} else if (size == "sm") {
return 0.95;
return 1.0;
} else if (size == "med") {
return 1.15;
return 1.2;
} else if (size == "lg") {
return 0.925;
} else if (size == "huge") {
Expand All @@ -159,11 +185,11 @@ function sizeToOffset(size) {

function sizeToIconScale(size) {
if (size == "tiny") {
return 1.0;
return 1.4;
} else if (size == "sm") {
return 1.0;
return 1.4;
} else if (size == "med") {
return 1.0;
return 1.4;
} else if (size == "lg") {
return 1.25;
} else if (size == "huge") {
Expand Down Expand Up @@ -206,6 +232,15 @@ const updateEffectScales = (token) => {
if (!(effectIcon instanceof PIXI.Sprite)) {
return;
}
// debugger;

// Overlay effect
if (effectIcon === token.effects.overlay) {
const size = Math.min(token.w * 0.1, token.h * 0.1);
effectIcon.width = effectIcon.height = size;
effectIcon.position.set((token.w - size) / 2, (token.h - size) / 2);
}

effectIcon.anchor.set(0.5);

const iconScale = sizeToIconScale(tokenSize);
Expand Down

0 comments on commit 939d535

Please sign in to comment.