fvtt-fria-ligan / vaesen-foundry-vtt

GNU General Public License v3.0
17 stars 16 forks source link

Foundryvtt v10 Unable to open scenes with a character token #38

Closed FinitelyFailed closed 2 years ago

FinitelyFailed commented 2 years ago

I'm running foundryvtt v10 284 and Vaesen 2.3.6. When I create a scene and drag a character token to it, I'm unable to see the token and when navigating to and from that scene I get some errors:

foundry.js:25740 Error: The requested texture  could not be loaded: Failed to load texture : Invalid URL
    at TextureLoader.fetchResource (foundry.js:25574:23)
    at TextureLoader.loadImageTexture (foundry.js:25495:38)
    at TextureLoader.loadTexture (foundry.js:25484:83)
    at loadTexture (foundry.js:25732:37)
    at Token._drawEffect (hooks.js:72:25)
    at Token._drawOverlay (foundry.js:45783:23)
    at Token.drawEffects (foundry.js:45719:39)
    at Token._draw (foundry.js:45384:16)
    at async Token.draw (foundry.js:24869:5)
    at async Promise.all (index 0)
loadTexture @ foundry.js:25740
await in loadTexture (async)
Token._drawEffect @ hooks.js:72
_drawOverlay @ foundry.js:45783
drawEffects @ foundry.js:45719
_draw @ foundry.js:45384
await in _draw (async)
draw @ foundry.js:24869
(anonymous) @ foundry.js:30447
map @ commons.js:2869
_draw @ foundry.js:30445
_draw @ foundry.js:36466
draw @ foundry.js:29972
await in draw (async)
draw @ foundry.js:28407
await in draw (async)
draw @ foundry.js:38649
draw @ foundry.js:23403
await in draw (async)
view @ foundry.js:20727
_onClickScene @ foundry.js:68027
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
foundry.js:711 TypeError: Canvas drawing failed: Cannot read properties of undefined (reading 'effects'). Cannot read properties of undefined (reading 'effects')
    at Token._drawEffect (hooks.js:74:29)
    at async Token.drawEffects (foundry.js:45719:28)
    at async Token._draw (foundry.js:45384:5)
    at async Token.draw (foundry.js:24869:5)
    at async Promise.all (index 0)
    at async TokenLayer._draw (foundry.js:30452:5)
    at async TokenLayer._draw (foundry.js:36466:5)
    at async TokenLayer.draw (foundry.js:29972:5)
    at async InterfaceCanvasGroup.draw (foundry.js:28407:9)
    at async InterfaceCanvasGroup.draw (foundry.js:38649:5)
onError @ foundry.js:711
draw @ foundry.js:23406
await in draw (async)
view @ foundry.js:20727
_onClickScene @ foundry.js:68027
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
foundry.js:58303 Canvas drawing failed: Cannot read properties of undefined (reading 'effects')
fetch @ foundry.js:58303
notify @ foundry.js:58230
error @ foundry.js:58266
onError @ foundry.js:712
draw @ foundry.js:23406
await in draw (async)
view @ foundry.js:20727
_onClickScene @ foundry.js:68027
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
foundry.js:30510 Uncaught (in promise) TypeError: Cannot set properties of null (setting 'visible')
    at SoundsLayer._deactivate (foundry.js:30510:26)
    at SoundsLayer.deactivate (foundry.js:30096:10)
    at TokenLayer.activate (foundry.js:30061:76)
    at #initializeCanvasLayer (foundry.js:23575:11)
    at #initialize (foundry.js:23525:32)
    at Canvas.draw (foundry.js:23419:29)
    at async Scene.view (foundry.js:20727:7)

image

The issue seems to be inside of hooks.js:

// render cutstom effect icons
if(game.data.version == '0.8.9' || game.data.version == '0.8.8' || game.data.version == '0.8.7' || game.data.version == '0.8.6') {
        Token.prototype._drawEffect = async function(src, i, bg, w, tint) {
          const multiplier = 3;
          const divisor = 3 * this.data.height;
          w = (w / 2) * multiplier;
          let tex = await loadTexture(src);

          let icon = this.effects.addChild(new PIXI.Sprite(tex));
          icon.width = icon.height = w;
          icon.y = Math.floor(i / divisor) * w;
          icon.x = (i % divisor) * w;
          if ( tint ) icon.tint = tint;
          this.effects.addChild(icon);
        };
    } else {
      Token.prototype._drawEffect = async function(src, i, bg, w, tint) {
        const multiplier = 3;
        const divisor = 3 * this.data.height;
        w = (w / 2) * multiplier;
        let tex = await loadTexture(src);

        let icon = this.hud.effects.addChild(new PIXI.Sprite(tex));
        icon.width = icon.height = w;
        icon.y = Math.floor(i / divisor) * w;
        icon.x = (i % divisor) * w;
        if ( tint ) icon.tint = tint;
        this.hud.effects.addChild(icon);
      };

I changed it to:

// render custom effect icons
    if (game.data.release.generation == 10) {
      Token.prototype._drawEffect = async function(src, i, bg, w, tint) {
        //   const multiplier = 3;
        //   const divisor = 3 * this.data.height;
        //   w = (w / 2) * multiplier;
          let tex = await loadTexture(src);

          let icon = this.effects.addChild(new PIXI.Sprite(tex));
        //   icon.width = icon.height = w;
        //   icon.y = Math.floor(i / divisor) * w;
        //   icon.x = (i % divisor) * w;
        //   if ( tint ) icon.tint = tint;
          this.effects.addChild(icon);
        }
    } else if(game.data.version == '0.8.9' || game.data.version == '0.8.8' || game.data.version == '0.8.7' || game.data.version == '0.8.6') {
        Token.prototype._drawEffect = async function(src, i, bg, w, tint) {
          const multiplier = 3;
          const divisor = 3 * this.data.height;
          w = (w / 2) * multiplier;
          let tex = await loadTexture(src);

          let icon = this.effects.addChild(new PIXI.Sprite(tex));
          icon.width = icon.height = w;
          icon.y = Math.floor(i / divisor) * w;
          icon.x = (i % divisor) * w;
          if ( tint ) icon.tint = tint;
          this.effects.addChild(icon);
        };
    } else {
      Token.prototype._drawEffect = async function(src, i, bg, w, tint) {
        const multiplier = 3;
        const divisor = 3 * this.data.height;
        w = (w / 2) * multiplier;
        let tex = await loadTexture(src);

        let icon = this.hud.effects.addChild(new PIXI.Sprite(tex));
        icon.width = icon.height = w;
        icon.y = Math.floor(i / divisor) * w;
        icon.x = (i % divisor) * w;
        if ( tint ) icon.tint = tint;
        this.hud.effects.addChild(icon);
      };
    }

And now I can run scenes as normal, without the effects on the token. As I didn't manage to figure out how to draw the effects for the token ... If I did, I would have created a pull request with the fix. Sorry.

DrOgres commented 2 years ago

vaesen is not v10 ready as of yet. the update will come shortly. for now please run foundry v9

DrOgres commented 2 years ago

3.0.1 release is v10 compatible

FinitelyFailed commented 2 years ago

Good to know, I'll try 3.0.1. :) I tested the v10-beta-2 branch before as well, and it had the same issue at the time. Just trying to be helpful.

DrOgres commented 2 years ago

it is appreciated :) sorry if I sounded short. been eyeball deep in code all day the release version did fix this though so give that a spin and see if it solves your issue!

Thanks again!