Aedif / TokenVariants

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

FEATURE REQUEST: Let a token image's Filename affect its Scale. #111

Closed GambetTV closed 1 year ago

GambetTV commented 1 year ago

I'm wondering if you could implement a feature from the long-abandoned module Token HUD Wildcard. Essentially that module let you set a default Scale value to an image by changing its filename to reflect that change. You'd simply add a scaleX tag to its filename, so Aragorn.png would become Aragornscale1.5.png.

I really want to switch to your module, but I have over 3,000 images that I'd have to configure the scales of, and the workflow in your module is just prohibitively slow for setting up that many token images. I would be super grateful if you could make this work, and pretty much anyone else who still uses Token HUD Wildcard would probably switch over if they knew their old system was compatible with your modules'.

For reference, here's the link to the original module: https://github.com/javieros105/FVTT-TokenHUDWildcard

Aedif commented 1 year ago

I could add this as a setting sure. Will be part of the next release.

Aedif commented 1 year ago

New setting added in latest release: https://github.com/Aedif/TokenVariants/releases/tag/4.41.0

GambetTV commented 1 year ago

Thank you very much for adding this!

There's one minor bug with it, which is that if a token doesn't have a scale set in its file name, it is unclear to me how it's choosing what its scale should be. In the other module, tokens that didn't have a scale set in the file name would default to the Prototype Token's default scale. After some testing, I think when you first load into Foundry or refresh Foundry, it takes a snapshot of the on-scene token's current scale, and assumes that's what you want it to be from there after. It disregards it if the token has the scaleX in its filename though.

Either way, would it be possible to get it to look at what the Prototype Token's scale is set to, and have all tokens that don't have a scaleX default to that scale?

Thank you so much for this!

Aedif commented 1 year ago

I'm not sure if I follow your explanation of the issue, but there was a bug with default wildcard image not being examined for dimensions present in its names upon token creation. It should be fixed in: https://github.com/Aedif/TokenVariants/releases/tag/4.41.1

Perhaps this might fix your problem? The module doesn't actually do any snapshoting or the like. On token create it simply checks if the image contains the scale/width fields and updates the token appropriately. Otherwise these values should be the same as those of the prototype.

GambetTV commented 1 year ago

Apologies for my poor explanation of the problem! The problem seems to occur when a Prototype Token does not have a Default Wildcard Image set. It's useful to not have a Default Image set because if you do, then when you copy and paste the token or use a teleporter mod to move a token from one map to another, the token will revert back to its default image, which isn't always what you want. So I like to not set a default token, which seems to preserve the current image from one scene to another. Anyway, if you have a Default Wildcard Image set, then there isn't a problem.

However, if you don't have a Default Wildcard Image set, then the module no longer seems to check the Prototype Token for scale on tokens that lack a scaleX set in their filename. Instead, when you drag the token onto the map, it throws a random image onto the token. If that token does not have a scale set, then it still defaults to the prototype token default, which is good. However, if the random image it chooses does have a scaleX value in its filename, then when you switch to a token that doesn't, it seems to get confused and think that your original token's scale value is the value it should apply to images that lack the scaleX in their name.

I'll admit this is a confusing issue to explain. But an easy way for you to see what I'm talking about is to create a token with 2 images. Set the scale of the prototype token to 1, and make one of the images filenames Bob.png and the other Bobscale2.png, but don't set a Default Wildcard Image, so that when you drag the token to a scene it picks at random. Drag the token onto the scene, and when the image it randomly chooses is the scale2 image, swap to the other image and watch as its scale, despite not having a scale set, and therefore should default to the prototype token's scale of 1, will actually be scale 2 because it seems to think that the default is that of the first image it pulled from.

Hopefully that makes sense!

Aedif commented 1 year ago

Dimensions in file names should now be treated the same as custom configurations you can attach to images using Shift-Left click in the token hud. Meaning they will get reverted and applied as you switch to/away from them

https://github.com/Aedif/TokenVariants/releases/tag/4.41.2

https://github.com/Aedif/TokenVariants/assets/7693704/0c854b12-c574-4e6e-8c99-2a5a109c126a

GambetTV commented 1 year ago

Brilliant! Works perfect! Thank you soooo much!