Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foundry v9 incompatibility #27

Open
GambetTV opened this issue Dec 21, 2021 · 20 comments
Open

Foundry v9 incompatibility #27

GambetTV opened this issue Dec 21, 2021 · 20 comments

Comments

@GambetTV
Copy link

The module works for the most part in v9, but one critical aspect of it is no longer supported, which is you can no longer define a default token image. I suspect this is because of the updates done to the Token Configuration menu, as the layout now is significantly different.

@NorthernPlague
Copy link

I may have a conflict with another module, but the HUD is visible and working only when I'm GM. The button to access token selection is not present when I log in as the player/owner.

@smoothingplane
Copy link

same here

@SirTman
Copy link

SirTman commented Jan 8, 2022

I tried to make a pull request as the fix is quite trival but was unable.

const imageDataTab = html.find('.tab[data-tab="image"]')

Line 68 needs to changed to const imageDataTab = html.find('.tab[data-tab="appearance"]')
As that tab was renamed in v9

@NorthernPlague
Copy link

NorthernPlague commented Jan 8, 2022

Line 68 needs to changed to const imageDataTab = html.find('.tab[data-tab="appearance"]') As that tab was renamed in v9

I tried that change manually and cleared cache but the GM vs Player views still differ - maybe I've misconfigured something.
image
image

@GrumpyVader
Copy link

I don't even get the Randomize Wildcard Images check box in Foundry v9.

image

When I try to use the wild card, I get the following error in the console.
image

@cs96and
Copy link

cs96and commented Jan 20, 2022

@GrumpyVader it looks like some other module is also fiddling with the token config dialog. Try disabling all modules apart from Token HUD Wildcard to see if it works.

@cs96and
Copy link

cs96and commented Jan 20, 2022

It seems that the players need the "Use File Browser" permission in order for the extra button to appear on the token HUD. This is due to a change in core Foundry. I raised a bug report for it here...
https://gitlab.com/foundrynet/foundryvtt/-/issues/6575

@shirkie
Copy link

shirkie commented Jan 22, 2022

Updating the code manually to enable the default image options still gives me an issue to where it doesn't respect the selection. It will still be random even with a default set.

@cs96and
Copy link

cs96and commented Jan 22, 2022

@shirkie I noticed that too, it's actually a problem in v0.8 too. I actually have a fix for it, but I'm not at my PC right now to post it.

@shirkie
Copy link

shirkie commented Jan 22, 2022

@cs96and That's great news! I would LOVE to get that from you whenever you have time! Glad i wasn't the only one experiencing it. Thank you in advance.

@cs96and
Copy link

cs96and commented Jan 24, 2022

Here's the fix for the default token. On line 52 of main.js, replace this...

    _hookPreTokenCreate () {
        Hooks.on('createToken', (parent, options, userId) => {
            const defaultValue = parent?.actor?.data?.token?.flags['token-hud-wildcard'] ? parent.actor.data.token.flags['token-hud-wildcard'].default : ''
        
            if (defaultValue !== '' && parent?.actor?.data?.token?.randomImg) {
                const dimensions = getTokenDimensions(parent, defaultValue)
                let updateInfo = { img: defaultValue, ...dimensions }
                parent.object.document.update(updateInfo)
            }
        })
    },

With this...

    _hookPreTokenCreate () {
        Hooks.on('preCreateToken', (parent, data, options, userId) => {
            const defaultValue = parent?.actor?.data?.token?.flags['token-hud-wildcard'] ? parent.actor.data.token.flags['token-hud-wildcard'].default : ''

            if (defaultValue !== '' && parent?.actor?.data?.token?.randomImg) {
                const dimensions = getTokenDimensions(parent, defaultValue);
                let updateInfo = { img: defaultValue , ...dimensions };
                mergeObject(data, updateInfo);
                parent.data.update(updateInfo);
            }
        })
    },

@shirkie
Copy link

shirkie commented Jan 24, 2022

That works wonderfully! Thank you for posting it!

@javieros105
Copy link
Owner

javieros105 commented Jan 31, 2022

I'm so sorry, i missed all these notifications.

oh damn that's awesome. Gonna try to include it in a new version soon, I haven't updated to foundry v9

Gonna update foundry today and check the fix during the week to make a new version.

@cs96and
Copy link

cs96and commented Feb 1, 2022

Note there are two separate fixes above. @SirTman's fix is the fix to make it work with v9.

My fix actually fixes #24.

Also, you can improve on @SirTman's fix, to make it compatible with both v0.8 and v9...

const imageDataTab = html.find('.tab[data-tab="appearance"],.tab[data-tab="image"]')

@GambetTV
Copy link
Author

GambetTV commented Feb 1, 2022

Also, if there's a way to fix the current v9 requirement of having to give players File Browser permissions for them to be able to change their own tokens that would be ideal.

@cs96and
Copy link

cs96and commented Feb 1, 2022

@GambetTV that relies on fixing core foundry...
https://gitlab.com/foundrynet/foundryvtt/-/issues/6575

@javieros105
Copy link
Owner

Gonna try to add the fixes during this week, probably before friday. Regarding the issue with file picker, that definitely gonna have to wait unti there is a solution on the core side

@javieros105
Copy link
Owner

Here's the fix for the default token. On line 52 of main.js, replace this...

    _hookPreTokenCreate () {
        Hooks.on('createToken', (parent, options, userId) => {
            const defaultValue = parent?.actor?.data?.token?.flags['token-hud-wildcard'] ? parent.actor.data.token.flags['token-hud-wildcard'].default : ''
        
            if (defaultValue !== '' && parent?.actor?.data?.token?.randomImg) {
                const dimensions = getTokenDimensions(parent, defaultValue)
                let updateInfo = { img: defaultValue, ...dimensions }
                parent.object.document.update(updateInfo)
            }
        })
    },

With this...

    _hookPreTokenCreate () {
        Hooks.on('preCreateToken', (parent, data, options, userId) => {
            const defaultValue = parent?.actor?.data?.token?.flags['token-hud-wildcard'] ? parent.actor.data.token.flags['token-hud-wildcard'].default : ''

            if (defaultValue !== '' && parent?.actor?.data?.token?.randomImg) {
                const dimensions = getTokenDimensions(parent, defaultValue);
                let updateInfo = { img: defaultValue , ...dimensions };
                mergeObject(data, updateInfo);
                parent.data.update(updateInfo);
            }
        })
    },

This fix works perfectly but I can't make the other one actually work. Need to check it a bit more

@javieros105
Copy link
Owner

Oh ok,yeah I get the second fix, I was mixing it up

@javieros105
Copy link
Owner

Hey guys, bit of an update, thanks to @cs96and for reporting the issue on getTokenImages it was added to the dev pipeline and apparently fixed for version 10 prototype 1. So I have high hopes we will recover full functionality of the module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants