Skip to content

Commit feda9da

Browse files
committed
Fix issue with control icons in foundry v12
1 parent 61b0706 commit feda9da

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.11.4
2+
3+
- Fix issue with control icons in Foundry v12
4+
15
## 0.11.3
26

37
- Fix an issue with control icons not being optimized in certain cases

module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "fvtt-perf-optim",
33
"title": "Prime Performance",
4-
"version": "0.11.3",
4+
"version": "0.11.4",
55
"description": "Provides a collection of unofficial performance optimizations and hacks for foundry vtt.",
66
"esmodules": ["dist/fvtt-perf-optim.js"],
77
"languages": [

src/hacks/spritesheetSubstitution.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,18 @@ function drawOptimizedControlIcon({
151151
return icon;
152152
}
153153

154+
function getControlIconSize(): number {
155+
if (FOUNDRY_API.generation < 13) {
156+
return Math.max(Math.round((canvas.dimensions.size * 0.5) / 20) * 20, 40);
157+
}
158+
return 60 * canvas.dimensions.uiScale;
159+
}
160+
154161
function AmbientLight__draw(this: AmbientLight, wrapped: (...args: any[]) => void, ...args: any[]) {
155162
const result = wrapped(...args);
156163
removeOldControlIcon(this);
157164

158-
const size = 60 * canvas.dimensions.uiScale;
165+
const size = getControlIconSize();
159166
this.controlIcon = this.addChild(drawOptimizedControlIcon({ size, texture: CONFIG.controlIcons.light }));
160167

161168
return result;
@@ -165,7 +172,7 @@ function AmbientSound__draw(this: AmbientSound, wrapped: (...args: any[]) => voi
165172
const result = wrapped(...args);
166173
removeOldControlIcon(this);
167174

168-
const size = 60 * canvas.dimensions.uiScale;
175+
const size = getControlIconSize();
169176
this.controlIcon = this.addChild(drawOptimizedControlIcon({ size, texture: CONFIG.controlIcons.sound }));
170177

171178
return result;
@@ -175,7 +182,7 @@ function MeasuredTemplate__draw(this: MeasuredTemplate, wrapped: (...args: any[]
175182
const result = wrapped(...args);
176183
removeOldControlIcon(this);
177184

178-
const size = 60 * canvas.dimensions.uiScale;
185+
const size = getControlIconSize();
179186
this.controlIcon = this.addChild(drawOptimizedControlIcon({ size, texture: CONFIG.controlIcons.template }));
180187

181188
return result;

0 commit comments

Comments
 (0)