11import type { RENDER_SCALE_DEFAULTS } from 'src/settings/constants.ts' ;
22import { SETTINGS } from 'src/settings/constants.ts' ;
33import { getSetting } from 'src/settings/settings.ts' ;
4-
5- function CanvasBackgroundAlterationEffects__draw ( this : any , wrapped : ( ...args : any ) => void , ...args : any [ ] ) {
6- wrapped ( ...args ) ;
7- if ( ! getSetting < boolean > ( SETTINGS . ReduceLightingResolution ) ) {
8- return ;
9- }
10-
11- const customRenderScale = getSetting < typeof RENDER_SCALE_DEFAULTS > ( SETTINGS . CustomRenderScale ) ;
12- setReducedResolution ( this . lighting ?. filter , customRenderScale . background ) ;
13- }
14-
15- function CanvasColorationEffects__draw ( this : any , wrapped : ( ...args : any ) => void , ...args : any [ ] ) {
16- wrapped ( ...args ) ;
17- if ( ! getSetting < boolean > ( SETTINGS . ReduceLightingResolution ) ) {
18- return ;
19- }
20-
21- const customRenderScale = getSetting < typeof RENDER_SCALE_DEFAULTS > ( SETTINGS . CustomRenderScale ) ;
22- setReducedResolution ( this . filter , customRenderScale . coloration ) ;
23- }
24-
25- function CanvasIlluminationEffects__draw ( this : any , wrapped : ( ...args : any ) => void , ...args : any [ ] ) {
26- wrapped ( ...args ) ;
27- if ( ! getSetting < boolean > ( SETTINGS . ReduceLightingResolution ) ) {
28- return ;
29- }
30-
31- const customRenderScale = getSetting < typeof RENDER_SCALE_DEFAULTS > ( SETTINGS . CustomRenderScale ) ;
32- setReducedResolution ( this . filter , customRenderScale . illumination ) ;
33- }
34-
35- function CanvasDarknessEffects__draw ( this : any , wrapped : ( ...args : any ) => void , ...args : any [ ] ) {
36- wrapped ( ...args ) ;
37- if ( ! getSetting < boolean > ( SETTINGS . ReduceLightingResolution ) ) {
38- return ;
39- }
40-
41- const customRenderScale = getSetting < typeof RENDER_SCALE_DEFAULTS > ( SETTINGS . CustomRenderScale ) ;
42- setReducedResolution ( this . filter , customRenderScale . darkness ) ;
43- }
4+ import { FOUNDRY_API } from 'src/utils/foundryShim.ts' ;
445
456function setReducedResolution ( filter : PIXI . Filter , scale : number | undefined ) {
467 if ( ! filter ) {
@@ -55,6 +16,10 @@ function setReducedResolution(filter: PIXI.Filter, scale: number | undefined) {
5516}
5617
5718async function enableReducedLightingResolution ( ) {
19+ if ( ! FOUNDRY_API . hasCanvas ) {
20+ return ;
21+ }
22+
5823 Hooks . on ( 'canvasReady' , ( ) => {
5924 if ( ! getSetting < boolean > ( SETTINGS . ReduceLightingResolution ) ) {
6025 return ;
@@ -65,10 +30,14 @@ async function enableReducedLightingResolution() {
6530}
6631
6732function configureEffectsResolution ( customRenderScale : typeof RENDER_SCALE_DEFAULTS | null | undefined ) {
33+ if ( ! FOUNDRY_API . hasCanvas ) {
34+ return ;
35+ }
36+
6837 setReducedResolution ( canvas ?. effects ?. background ?. lighting ?. filter , customRenderScale ?. background ) ;
6938 setReducedResolution ( canvas ?. effects ?. illumination ?. filter , customRenderScale ?. illumination ) ;
7039 setReducedResolution ( canvas ?. effects ?. coloration ?. filter , customRenderScale ?. coloration ) ;
7140 setReducedResolution ( canvas ?. effects ?. darkness ?. filter , customRenderScale ?. darkness ) ;
7241}
7342
74- export { configureEffectsResolution , enableReducedLightingResolution , toggleReducedLightingResolution } ;
43+ export { configureEffectsResolution , enableReducedLightingResolution } ;
0 commit comments