From 6331510a2d32e26354c435bd092b152d48d6ddf0 Mon Sep 17 00:00:00 2001 From: Blair Date: Sun, 4 Feb 2024 15:57:08 +1000 Subject: [PATCH] v2.7.11 - Fixed actor prototypeToken image not being referenced. - Fixed audioFiles and tile images in [Monk's Active Tile Triggers](https://foundryvtt.com/packages/monks-active-tiles) not being referenced. - Thanks Beneos of https://beneos-battlemaps.com/ for the above reports. --- CHANGELOG.md | 6 ++++++ module.json | 2 +- scripts/asset-report.js | 20 +++++++++++++++++++- scripts/assets/actor.js | 21 +++++++++++++++++---- scripts/assets/journal.js | 21 +++++++++++++++++---- scripts/assets/scene.js | 34 +++++++++++++++++++++++++++++++++- 6 files changed, 93 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdb790f..e44c054 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v2.7.11 + +- Fixed actor prototypeToken image not being referenced. +- Fixed audioFiles and tile images in [Monk's Active Tile Triggers](https://foundryvtt.com/packages/monks-active-tiles) not being referenced. + - Thanks Beneos of https://beneos-battlemaps.com/ for the above reports. + ## v2.7.10 - Migrate "mime" package to a local source to avoid issues with the CDN being offline/having a build error. diff --git a/module.json b/module.json index 9c4e05a..4351f24 100644 --- a/module.json +++ b/module.json @@ -3,7 +3,7 @@ "name": "scene-packer", "title": "Library: Scene Packer", "description": "A module to assist with Scene and Adventure packing and unpacking.", - "version": "2.7.10", + "version": "2.7.11", "library": "true", "manifestPlusVersion": "1.2.0", "minimumCoreVersion": "0.8.6", diff --git a/scripts/asset-report.js b/scripts/asset-report.js index c67dafd..a3c9cd1 100644 --- a/scripts/asset-report.js +++ b/scripts/asset-report.js @@ -511,6 +511,8 @@ export default class AssetReport extends FormApplication { SceneForeground: 'scene-foreground', SceneNoteIcon: 'scene-note-icon', SceneTileImage: 'scene-tile-image', + SceneTileActiveImage: 'scene-tile-monks-active-tile-image', + SceneTileActiveSound: 'scene-tile-monks-active-tile-sound', SceneDrawingImage: 'scene-drawing-texture', SceneTokenImage: 'scene-token-image', SceneTokenEffectIcon: 'scene-token-effect-icon', @@ -763,6 +765,22 @@ export default class AssetReport extends FormApplication { if (img) { this.CheckAsset(scene.id, AssetReport.Sources.Scene, img, AssetReport.Locations.SceneTileImage); } + + const activeTileActions = getProperty(tile, 'flags.monks-active-tiles.actions') || []; + for (const action of activeTileActions) { + const audioFile = action.data?.audiofile; + if (audioFile) { + this.CheckAsset(scene.id, AssetReport.Sources.Scene, audioFile, AssetReport.Locations.SceneTileActiveSound); + } + } + + const activeTileImages = getProperty(tile, 'flags.monks-active-tiles.files') || []; + for (const image of activeTileImages) { + const imagePath = image.name; + if (imagePath) { + this.CheckAsset(scene.id, AssetReport.Sources.Scene, imagePath, AssetReport.Locations.SceneTileActiveImage); + } + } }); drawings.forEach(drawing => { @@ -850,7 +868,7 @@ export default class AssetReport extends FormApplication { this.CheckAsset(actor.id, AssetReport.Sources.Actor, actorData.img, AssetReport.Locations.ActorImage); } - const tokenImage = CONSTANTS.IsV10orNewer() ? actor.token?.img : actor.token?.img || actorData?.token?.img; + const tokenImage = CONSTANTS.IsV10orNewer() ? (actor.prototypeToken?.texture?.src ?? actor.token?.img) : (actor.token?.img ?? actorData?.token?.img); if (tokenImage) { this.CheckAsset(actor.id, AssetReport.Sources.Actor, tokenImage, AssetReport.Locations.ActorTokenImage); } diff --git a/scripts/assets/actor.js b/scripts/assets/actor.js index afdf634..2bb70a7 100644 --- a/scripts/assets/actor.js +++ b/scripts/assets/actor.js @@ -31,17 +31,30 @@ export async function ExtractActorAssets(actor) { }); } - const tokenImage = actor.token?.img || actorData?.token?.img; - if (tokenImage) { + const prototypeTokenImage = actor.prototypeToken?.texture?.src; + if (prototypeTokenImage) { await data.AddAsset({ id: actor.id, - key: 'token.img', + key: 'prototypeToken.texture.src', parentID: actor.id, parentType: actor.documentName, documentType: actor.documentName, location: AssetReport.Locations.ActorTokenImage, - asset: tokenImage, + asset: prototypeTokenImage, }); + } else { + const tokenImage = actor.token?.img ?? actorData?.token?.img; + if (tokenImage) { + await data.AddAsset({ + id: actor.id, + key: 'token.img', + parentID: actor.id, + parentType: actor.documentName, + documentType: actor.documentName, + location: AssetReport.Locations.ActorTokenImage, + asset: tokenImage, + }); + } } const items = []; diff --git a/scripts/assets/journal.js b/scripts/assets/journal.js index f647b57..723a797 100644 --- a/scripts/assets/journal.js +++ b/scripts/assets/journal.js @@ -164,17 +164,30 @@ export async function ExtractQuickEncounterAssets(journal) { data.AddAssetData(await ExtractActorAssets(actor)); for (const token of extractedActor.savedTokensData || []) { - const tokenImage = token?.img; - if (tokenImage) { + const tokenTexture = token.texture?.src; + if (tokenTexture) { await data.AddAsset({ id: actor.id, - key: 'token.img', + key: 'texture.src', parentID: actor.id, parentType: actor.documentName, documentType: actor.documentName, location: AssetReport.Locations.ActorTokenImage, - asset: tokenImage, + asset: tokenTexture, }); + } else { + const tokenImage = token?.img; + if (tokenImage) { + await data.AddAsset({ + id: actor.id, + key: 'token.img', + parentID: actor.id, + parentType: actor.documentName, + documentType: actor.documentName, + location: AssetReport.Locations.ActorTokenImage, + asset: tokenImage, + }); + } } } } diff --git a/scripts/assets/scene.js b/scripts/assets/scene.js index 694bf45..4cc3193 100644 --- a/scripts/assets/scene.js +++ b/scripts/assets/scene.js @@ -108,7 +108,7 @@ export async function ExtractSceneAssets(scene) { for (const tile of tiles) { const tileData = CONSTANTS.IsV10orNewer() ? tile : tile?.data; - const img = tileData?.img || tile?.img; + const img = tileData?.img || tileData?.img; if (img) { await data.AddAsset({ id: tile.id, @@ -131,6 +131,38 @@ export async function ExtractSceneAssets(scene) { asset: tileData.texture.src, }); } + + const activeTileActions = getProperty(tileData, 'flags.monks-active-tiles.actions') || []; + for (const action of activeTileActions) { + const audioFile = action.data?.audiofile; + if (audioFile) { + await data.AddAsset({ + id: tile.id, + key: 'monks-active-tile.audiofile', + parentID: scene.id, + parentType: scene.documentName, + documentType: tile.documentName || 'Tile', + location: AssetReport.Locations.SceneTileActiveSound, + asset: audioFile, + }); + } + } + + const activeTileImages = getProperty(tileData, 'flags.monks-active-tiles.files') || []; + for (const image of activeTileImages) { + const imagePath = image.name; + if (imagePath) { + await data.AddAsset({ + id: tile.id, + key: 'monks-active-tile.image', + parentID: scene.id, + parentType: scene.documentName, + documentType: tile.documentName || 'Tile', + location: AssetReport.Locations.SceneTileActiveImage, + asset: imagePath, + }); + } + } } for (const drawing of drawings) {