[PR] [Feature] Beastform Wildcards (#1247)

* Added support for wildcard paths in beastform token paths

* Fixed browse dataSource
This commit is contained in:
WBHarry 2025-11-10 16:30:04 +01:00 committed by GitHub
parent 2d6390248f
commit 7055591a76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 176 additions and 2 deletions

View file

@ -33,11 +33,13 @@ export default class DHBeastform extends BaseDataItem {
tokenImg: new fields.FilePathField({
initial: 'icons/svg/mystery-man.svg',
categories: ['IMAGE'],
wildcard: true,
base64: false
}),
tokenRingImg: new fields.FilePathField({
initial: 'icons/svg/mystery-man.svg',
categories: ['IMAGE'],
wildcard: true,
base64: false
}),
tokenSize: new fields.SchemaField({
@ -108,6 +110,30 @@ export default class DHBeastform extends BaseDataItem {
};
}
static async getWildcardImage(actor, beastform) {
const usesDynamicToken = actor.prototypeToken.ring.enabled && beastform.system.tokenRingImg;
const tokenPath = usesDynamicToken ? beastform.system.tokenRingImg : beastform.system.tokenImg;
const usesWildcard = tokenPath.includes('*');
if (usesWildcard) {
const filePicker = new foundry.applications.apps.FilePicker.implementation(tokenPath);
const { files } = await foundry.applications.apps.FilePicker.implementation.browse(
filePicker.activeSource,
tokenPath,
{
wildcard: true,
type: 'image'
}
);
const selectedImage = await game.system.api.applications.dialogs.ImageSelectDialog.configure(
game.i18n.localize('DAGGERHEART.APPLICATIONS.ImageSelect.title'),
files
);
return { usesDynamicToken, selectedImage };
}
return null;
}
async _preCreate() {
if (!this.actor) return;