Added support for wildcard paths in beastform token paths

This commit is contained in:
WBHarry 2025-11-08 18:30:36 +01:00
parent a7d035bcdb
commit 200349be3b
11 changed files with 171 additions and 2 deletions

View file

@ -79,7 +79,7 @@ export default class BeastformField extends fields.SchemaField {
* @returns
*/
static async transform(selectedForm, evolvedData, hybridData) {
const formData = evolvedData?.form ? evolvedData.form.toObject() : selectedForm.toObject();
const formData = evolvedData?.form ? evolvedData.form.toObject() : selectedForm;
const beastformEffect = formData.effects.find(x => x.type === 'beastform');
if (!beastformEffect) {
ui.notifications.error('DAGGERHEART.UI.Notifications.beastformMissingEffect');

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,25 @@ 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 { files } = await foundry.applications.apps.FilePicker.implementation.browse('data', 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;