From 8a0f9a83d902c31ecd8876248e97768fa16d4a9e Mon Sep 17 00:00:00 2001 From: Blair Date: Sun, 15 Dec 2024 14:30:04 +1000 Subject: [PATCH] v2.8.3 - Added the ability to ignore certain compendiums when importing all entities. - This is useful if you have a compendium that you don't want to bulk import from, such as a "prefabs" compendium. - This can be set via the "init" script - see `ignoredCompendiumPacks` in the [readme](https://github.com/League-of-Foundry-Developers/scene-packer#module-code-requirements). - Updated French translation (machine translated). --- .github/workflows/main.yml | 2 +- CHANGELOG.md | 7 +++ README.md | 12 +++++ languages/en.json | 6 +++ languages/fr.json | 6 +++ module.json | 2 +- packs/journals.db | 2 +- .../adventure-converter.js | 1 + scripts/scene-packer.js | 52 ++++++++++++++++++- 9 files changed, 86 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 381a6e2..9e702dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: env: version: ${{github.event.release.tag_name}} url: https://github.com/${{github.repository}} - manifest: https://github.com/${{github.repository}}/releases/latest/download/module.json + manifest: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.json download: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.zip # Create a zip file with all files required by the module to add to the release diff --git a/CHANGELOG.md b/CHANGELOG.md index 22e19d9..6d35f4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## v2.8.3 + +- Added the ability to ignore certain compendiums when importing all entities. + - This is useful if you have a compendium that you don't want to bulk import from, such as a "prefabs" compendium. + - This can be set via the "init" script - see `ignoredCompendiumPacks` in the [readme](https://github.com/League-of-Foundry-Developers/scene-packer#module-code-requirements). +- Updated French translation (machine translated). + ## v2.8.2 - Fix bug that broke everything (sorry about that). diff --git a/README.md b/README.md index 3552e10..e25812e 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,17 @@ Include the following in your [module javascript](https://foundryvtt.com/article * const additionalModulePacks = []; */ const additionalModulePacks = [moduleName, 'dnd5e']; + /** + * ignoredCompendiumPacks is a list of compendium packs to ignore when "importing all" content. + * Content from this pack will still be imported if it is directly referenced by another entity. + * + * The value to use is the "name" of the pack as defined in the module.json file. + * Only packs from the active module can be ignored and the id of the module should not be provided. + * + * For example, if you wanted to ignore the "mymoduleid.prefabs" pack: + * const ignoredCompendiumPacks = ['prefabs']; + */ + const ignoredCompendiumPacks = []; Hooks.once('scenePackerReady', ScenePacker => { // Initialise the Scene Packer with your adventure name and module name @@ -166,6 +177,7 @@ Include the following in your [module javascript](https://foundryvtt.com/article welcomeJournal, additionalJournals, additionalMacros, + ignoredCompendiumPacks, allowImportPrompts: true, // Set to false if you don't want the popup }); }); diff --git a/languages/en.json b/languages/en.json index 7dc9895..ad5b39e 100644 --- a/languages/en.json +++ b/languages/en.json @@ -231,6 +231,12 @@ "ui": "Invalid call to SetAdditionalModulePacks(). See console for details.", "details": "You must pass an array of strings to \"SetAdditionalModulePacks()\". They must be the names of Modules. Received: {pack}", "missing": "SetAdditionalModulePacks() called with no value." + }, + "ignoredPacks": { + "ui": "Invalid call to SetIgnoredCompendiumPacks(). See console for details.", + "details": "You must pass an array of strings to \"SetIgnoredCompendiumPacks()\". They must be the names of Module Packs. Received: {pack} Available packs are: {packs}", + "invalid": "Invalid value passed to \"SetIgnoredCompendiumPacks()\". Received: {pack} Available packs are: {packs}", + "missing": "SetIgnoredCompendiumPacks() called with no value." } }, "world-conversion": { diff --git a/languages/fr.json b/languages/fr.json index 8b5e32d..dc0b5e7 100644 --- a/languages/fr.json +++ b/languages/fr.json @@ -215,6 +215,12 @@ "details": "Vous devez passer un tableau de chaînes de caractères à \"SetAdditionalMacrosToImport()\". Il doit s'agir des noms des Modules. Reçu : {pack}", "missing": "SetAdditionalModulePacks() appelé sans valeur." }, + "ignoredPacks": { + "ui": "Appel invalide à SetIgnoredCompendiumPacks(). Voir la console pour plus de détails.", + "details": "Vous devez passer un tableau de chaînes de caractères à \"SetAdditionalMacrosToImport()\". Il doit s'agir des noms packs de Module. Reçu : {pack}. Les packs disponibles sont : {packs}", + "invalid": "Valeur invalide passée à “SetIgnoredCompendiumPacks()”. Reçu : {pack}. Les packs disponibles sont : {packs}.", + "missing": "SetIgnoredCompendiumPacks() appelé sans valeur." + }, "version": { "packed-low": "La scène \"{scene}\" (du module \"{sourceModule}\") a été empaquetée avec la version de Scene Packer \"{version}\" qui est plus ancienne que la version minimale compatible de \"{supportedVersion}\". Veuillez contacter l'auteur et lui demander de ré-empaqueter la scène avec une version actuelle." } diff --git a/module.json b/module.json index b87754f..2e37e3e 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.8.2", + "version": "2.8.3", "library": "true", "manifestPlusVersion": "1.2.0", "minimumCoreVersion": "0.8.6", diff --git a/packs/journals.db b/packs/journals.db index fabca2c..e493756 100644 --- a/packs/journals.db +++ b/packs/journals.db @@ -3,6 +3,6 @@ {"_id":"6W7WVWeexVsFhtSQ","name":"Usage as a GM","permission":{"default":0,"Ajg91HDqjNrrkzqL":3},"folder":"","flags":{},"content":"

Using Scene Packer as a GM

\n

Using modules that have been packed with Scene Packer is very straight forward. When you first enable a module packed with Scene Packer, it will prompt you asking you if you want to import all of the Scenes.

\n

\"\"

\n

 

\n

Selecting \"Yes import all\" will import all of the Scenes into a folder, unpack them and you'll be ready to go.

\n

 

\n

Selecting \"Let me choose\" will open the Scene compendium allowing you to manually import just the Scenes you want. The first time you view a Scene, it will unpack itself automatically and you'll be ready to go.

\n

 

\n

If you choose the \"Don't ask me again\" option and now want to import the Scenes, you can manually import any of the Scenes from the module Compendium. The first time you view a Scene it will unpack itself automatically and you'll be ready to go.

\n

 

\n

What is this \"Pack Scene Data\" option I see when I right-click on a Scene?

\n

\"\"

\n

This option is used by module developers. You should not need to select this option, otherwise you will waste CPU time packing and then unpacking your scene data. If you accidentally click it, simply choose the \"Clear Packed Scene Data\" from the same context menu. To hide the option, uncheck the module setting called \"Enable Scene Packer context menu\".

\n

\"\"

\n

 

\n

Help! I have an issue!

\n

Please report issues via the Bug Reporter module, or join the \"Scene Scene Packer discord server.

"} {"_id":"9uxj0T3z1vTUNkVx","name":"Packing a scene that contains a Quick Encounter","content":"

How to

\n

The following are the steps to take to correctly pack a scene that contains Quick Encounter data.

\n

These steps assume that you are familiar with how to use Scene Packer. See @Compendium[scene-packer.journals.5H4wVwtnrbhZE8Ko]{Usage as a Content Creator}.

\n
    \n
  1. Create your Scene as you normally would.
  2. \n
  3. Import your monsters/enemies from a compendium pack into your world (e.g. Monsters (SRD) (dnd5e)) or create your NPC actors manually in your world.
  4. \n
  5. Drag your monsters/enemies onto your scene, placing them appropriately.
  6. \n
  7. Follow the Quick Encounter steps to create your quick encounter.\n
      \n
    • For example, select all monsters/enemies on the scene and click on the Quick Encounters button in the sidebar.
    • \n
    \n
  8. \n
  9. You should now have a Journal Pin on the map, and the monsters/enemies should have disappeared.
  10. \n
  11. Export the monsters/enemies to your module's Actor compendium.\n
      \n
    • The actor compendium you export to must be one that is referenced as one of the creaturePacks in your module's javascript initialisation code. See @Compendium[scene-packer.journals.d1ZkWfANsQYKSuty]{Example module javascript}.
    • \n
    \n
  12. \n
  13. Export the Journal entry/entries created by Quick Encounter to your module's Journal compendium.\n
      \n
    • The journal compendium you export to must be one that is referenced as one of the journalPacks in your module's javascript initialisation code. See @Compendium[scene-packer.journals.d1ZkWfANsQYKSuty]{Example module javascript}.
    • \n
    \n
  14. \n
  15. Run the @Compendium[scene-packer.macros.IeiuU5QSNgwJygTL]{Relink compendium journal entries} macro to update the references within the Quick Encounter journal/s.
  16. \n
  17. Right click on your Scene in the sidebar and choose \"Pack Scene Data\"
  18. \n
  19. Export your Scene to your module's Scene compendium.
  20. \n
","folder":null,"sort":0,"permission":{"default":0,"Rt2brfVFebtCuVnc":3},"flags":{"core":{"sourceId":"JournalEntry.SWRFeKvdoUS2Kc4i"}}} {"_id":"Y8WpVXdzGXRv93gf","name":"Packing folder structures (Compendium Folders)","content":"

Scene Packer will look for data embedded by the Compendium Folders module when it is importing entities. This means that you (as a content creator) can prepare a folder structure that makes sense for your adventure and have the end-user receive that same structure when they import via Scene Packer.

\n

 

\n

An example folder structure:

\n
My Cool Adventure\n│   Welcome and thanks\n│   Credits\n│   \n└───Handouts\n│   │   Approach\n│   │   Big Bad Boss Guy\n│\n└───Keyed Locations\n    │   01 - Entry\n    │   02 - Main hall\n    │   ...\n    │\n    └───Lair\n        │   a - Trap\n        │   b - Nest\n        │   ...
\n

The end-user would then end up with this same folder structure when they import your adventure via Scene Packer.

\n

 

\n

How to pack

\n

To utilise this feature, you simply need to use the \"Export Folder Structure\" functionality of the Compendium Folders module. Scene Packer will then read the data embedded within your compendium to re-create the intended folder structure.

\n

The end-user does not need to have the Compendium Folders module installed.

\n

 

\n

Note: automatic folder structure creation will only happen for entities imported by the Scene Packer module (such as linked Journals and Actors). It will not create folders for Scenes unless the end-user choose the \"Import All\" option presented when they first enable the module. Importing directly from the Compendium will not automatically create the folders.

","folder":null,"sort":0,"permission":{"default":0,"FYKEkGQDWeedzh8v":3},"flags":{"core":{"sourceId":"JournalEntry.xEff7vLf75ZEC00o"},"scene-packer":{"sourceId":"JournalEntry.xEff7vLf75ZEC00o"}}} -{"_id":"d1ZkWfANsQYKSuty","name":"Example module javascript","content":"

The following is an example of the javascript that you would put into your module, adjusting names as appropriate.

\n
\n
(() => {\n  const adventureName = 'Example Scene Packer';\n  const moduleName = 'example-scene-packer';\n\n  /**\n   * welcomeJournal (if set) will automatically be imported and opened after the first activation of a\n   * scene imported from the module compendium.\n   * The name here corresponds to a Journal entry in your compendium and must match exactly (it is case\n   * sensitive).\n   * Set to the following to disable:\n   *   const welcomeJournal = '';\n   */\n  const welcomeJournal = 'Introduction';\n  /**\n   * additionalJournals will automatically be imported. This is a list of Journals by name that should\n   * also be imported.\n   * Set to the following to disable:\n   *   const additionalJournals = [];\n   */\n  const additionalJournals = ['Credits'];\n  /**\n   * additionalMacros will automatically be imported. Each name must match exactly and are case sensitive.\n   * Set to the following to disable:\n   *   const additionalMacros = [];\n   */\n  const additionalMacros = ['Example Macro'];\n  /**\n   * creaturePacks is a list of compendium packs to look in for Actors by name (in prioritised order).\n   * If the creature is not found in the first pack, it will search through each subsequent pack.\n   * The first entry here assumes that you have an Actor pack in your module with the \"name\" of \"actors\".\n   * The second entry here lists the DnD5e SRD Monsters compendium that comes with the DnD5e system. Feel\n   * free to delete the 'dnd5e.monsters' reference if you want, or swapping it to any other system compendium\n   * reference.\n   * Set to the following to disable:\n   *   const creaturePacks = [];\n   */\n  const creaturePacks = [`${moduleName}.actors`, 'dnd5e.monsters'];\n  /**\n   * journalPacks is a list of compendium packs to look in for Journals by name (in prioritised order).\n   * The first entry here assumes that you have a Journal pack in your module with the \"name\" of \"journals\".\n   * Set to the following to disable:\n   *   const journalPacks = [];\n   */\n  const journalPacks = [`${moduleName}.journals`];\n  /**\n   * macroPacks is a list of compendium packs to look in for Macros by name (in prioritised order).\n   * The first entry here assumes that you have a Macro pack in your module with the \"name\" of \"macros\".\n   * Set to the following to disable:\n   *   const macroPacks = [];\n   */\n  const macroPacks = [`${moduleName}.macros`];\n  /**\n   * playlistPacks is a list of compendium packs to look in for Playlists by name (in prioritised order).\n   * The first entry here assumes that you have a Playlist pack in your module with the \"name\" of \"playlists\".\n   * Set to the following to disable:\n   *   const playlistPacks = [];\n   */\n  const playlistPacks = [`${moduleName}.playlists`];
/**\n * additionalModulePacks is a list of modules whose compendium packs can be looked in for entities by name (in prioritised order).\n * Enter just the \"name\" of the module/s you want to be considered.\n * For example, if you wanted to allow the packs from\n * the [Free Loot Tavern's Magic Item Vault]{@link https://foundryvtt.com/packages/free-loot-tavern-compendium}\n * and [Dynamic Active Effects SRD]{@link https://foundryvtt.com/packages/Dynamic-Effects-SRD}
* modules to be searchable:\n * const playlistPacks = ['free-loot-tavern-compendium', 'Dynamic-Effects-SRD'];\n * Set to the following to disable:\n * const additionalModulePacks = [];\n */\n const additionalModulePacks = ['dnd5e'];\n\n Hooks.once('scenePackerReady', ScenePacker => {\n // Initialise the Scene Packer with your adventure name and module name\n let packer = ScenePacker.Initialise({\n adventureName,\n moduleName,\n creaturePacks,\n journalPacks,\n macroPacks,\n playlistPacks,
additionalModulePacks,\n welcomeJournal,\n additionalJournals,\n additionalMacros,\n allowImportPrompts: true, // Set to false if you don't want the initial popup\n });\n });\n})();
","folder":null,"sort":0,"permission":{"default":0,"Ajg91HDqjNrrkzqL":3},"flags":{"core":{"sourceId":"JournalEntry.8xXIOgLTdW6BINJr"}}} +{"_id":"d1ZkWfANsQYKSuty","name":"Example module javascript","content":"

The following is an example of the javascript that you would put into your module, adjusting names as appropriate.

\n
\n
(() => {\n  const adventureName = 'Example Scene Packer';\n  const moduleName = 'example-scene-packer';\n\n  /**\n   * welcomeJournal (if set) will automatically be imported and opened after the first activation of a\n   * scene imported from the module compendium.\n   * The name here corresponds to a Journal entry in your compendium and must match exactly (it is case\n   * sensitive).\n   * Set to the following to disable:\n   *   const welcomeJournal = '';\n   */\n  const welcomeJournal = 'Introduction';\n  /**\n   * additionalJournals will automatically be imported. This is a list of Journals by name that should\n   * also be imported.\n   * Set to the following to disable:\n   *   const additionalJournals = [];\n   */\n  const additionalJournals = ['Credits'];\n  /**\n   * additionalMacros will automatically be imported. Each name must match exactly and are case sensitive.\n   * Set to the following to disable:\n   *   const additionalMacros = [];\n   */\n  const additionalMacros = ['Example Macro'];\n  /**\n   * creaturePacks is a list of compendium packs to look in for Actors by name (in prioritised order).\n   * If the creature is not found in the first pack, it will search through each subsequent pack.\n   * The first entry here assumes that you have an Actor pack in your module with the \"name\" of \"actors\".\n   * The second entry here lists the DnD5e SRD Monsters compendium that comes with the DnD5e system. Feel\n   * free to delete the 'dnd5e.monsters' reference if you want, or swapping it to any other system compendium\n   * reference.\n   * Set to the following to disable:\n   *   const creaturePacks = [];\n   */\n  const creaturePacks = [`${moduleName}.actors`, 'dnd5e.monsters'];\n  /**\n   * journalPacks is a list of compendium packs to look in for Journals by name (in prioritised order).\n   * The first entry here assumes that you have a Journal pack in your module with the \"name\" of \"journals\".\n   * Set to the following to disable:\n   *   const journalPacks = [];\n   */\n  const journalPacks = [`${moduleName}.journals`];\n  /**\n   * macroPacks is a list of compendium packs to look in for Macros by name (in prioritised order).\n   * The first entry here assumes that you have a Macro pack in your module with the \"name\" of \"macros\".\n   * Set to the following to disable:\n   *   const macroPacks = [];\n   */\n  const macroPacks = [`${moduleName}.macros`];\n  /**\n   * playlistPacks is a list of compendium packs to look in for Playlists by name (in prioritised order).\n   * The first entry here assumes that you have a Playlist pack in your module with the \"name\" of \"playlists\".\n   * Set to the following to disable:\n   *   const playlistPacks = [];\n   */\n  const playlistPacks = [`${moduleName}.playlists`];
/**\n * additionalModulePacks is a list of modules whose compendium packs can be looked in for entities by name (in prioritised order).\n * Enter just the \"name\" of the module/s you want to be considered.\n * For example, if you wanted to allow the packs from\n * the [Free Loot Tavern's Magic Item Vault]{@link https://foundryvtt.com/packages/free-loot-tavern-compendium}\n * and [Dynamic Active Effects SRD]{@link https://foundryvtt.com/packages/Dynamic-Effects-SRD}
* modules to be searchable:\n * const playlistPacks = ['free-loot-tavern-compendium', 'Dynamic-Effects-SRD'];\n * Set to the following to disable:\n * const additionalModulePacks = [];\n */\n const additionalModulePacks = ['dnd5e'];\n /**\n * ignoredCompendiumPacks is a list of compendium packs to ignore when \"importing all\" content.\n * Content from this pack will still be imported if it is directly referenced by another entity.\n *\n * The value to use is the \"name\" of the pack as defined in the module.json file.\n * Only packs from the active module can be ignored and the id of the module should not be provided.\n * \n * For example, if you wanted to ignore the \"mymoduleid.prefabs\" pack:\n * const ignoredCompendiumPacks = ['prefabs'];\n */\n const ignoredCompendiumPacks = [];\n\n Hooks.once('scenePackerReady', ScenePacker => {\n // Initialise the Scene Packer with your adventure name and module name\n let packer = ScenePacker.Initialise({\n adventureName,\n moduleName,\n creaturePacks,\n journalPacks,\n macroPacks,\n playlistPacks,
additionalModulePacks,\n welcomeJournal,\n additionalJournals,\n additionalMacros,\n allowImportPrompts: true, // Set to false if you don't want the initial popup\n });\n });\n})();
","folder":null,"sort":0,"permission":{"default":0,"Ajg91HDqjNrrkzqL":3},"flags":{"core":{"sourceId":"JournalEntry.8xXIOgLTdW6BINJr"}}} {"_id":"l4B4aob1n9tM2DJv","name":"Packing your Scenes","content":"

To pack your scene ready for distribution:

\n
    \n
  1. Enable the Scene Packer context menu in Module Settings.
  2. \n
  3. Build your scene as normal, adding Actors and Journal Pins where you'd like.
  4. \n
  5. Export your Scenes/Actors/Journals/Roll Tables/Items/Macros/Playlists to your compendiums as normal.
  6. \n
  7. Run the script to @Compendium[scene-packer.macros.IeiuU5QSNgwJygTL]{Relink compendium journal entries} to fix up the journal compendium linking (see section below)
  8. \n
  9. Right click on your Scene in the Scenes Directory and choose \"Pack Scene Data\".
  10. \n
  11. Important step that is often missed: Export your Scene/s to your compendium again (replacing your existing entry, merging by name to retain the ID reference).
  12. \n
  13. Run the @Compendium[scene-packer.macros.mkNKay70v790Fu4h]{Show asset report} macro against your module to verify that all of your assets will work for your users when imported into their world.
  14. \n
\n

","folder":null,"sort":0,"permission":{"default":0,"XKmxUPdkcWMuKdfu":3},"flags":{"core":{"sourceId":"JournalEntry.fN4rFcgk779mLs5l"},"scene-packer":{"sourceId":"JournalEntry.fN4rFcgk779mLs5l"}}} {"name":"Moulinette Integration","content":"

Integration with Moulinette was added in v2.4.0 of Scene Packer.

\n

With this integration, your end-users don't need to install a new module every time you do a release and all of your carefully placed actors, journals and folder structures will just work.

\n

The video below guides you through the process of using Scene Packer with Moulinette:

\n

 

\n

","folder":null,"sort":0,"permission":{"default":0,"0r6mrq3YfoHRSSBu":3},"flags":{"scene-packer":{"hash":"13a0bb09962f384e662824b79f9172e2870996ce","sourceId":"JournalEntry.iCxvSgAvma8zSNj0"},"core":{"sourceId":"JournalEntry.iCxvSgAvma8zSNj0"}},"_id":"wKfAMThrphxfL8z7"} diff --git a/scripts/adventure-converter/adventure-converter.js b/scripts/adventure-converter/adventure-converter.js index 18cc6b3..d6a8d30 100644 --- a/scripts/adventure-converter/adventure-converter.js +++ b/scripts/adventure-converter/adventure-converter.js @@ -653,6 +653,7 @@ export default class AdventureConverter extends FormApplication { name: pathPart, type: document.documentName, parent: parent?.id || null, + folder: parent?.id || null, color: cfColor || null, sorting: cfSorting, sort: cfSort, diff --git a/scripts/scene-packer.js b/scripts/scene-packer.js index 0b181b9..403b177 100644 --- a/scripts/scene-packer.js +++ b/scripts/scene-packer.js @@ -57,6 +57,8 @@ export default class ScenePacker { playlists: [], modules: [], }; + /** @type {Set} */ + ignoredCompendiumPacks = new Set(); allowImportPrompts = true; /** @@ -70,6 +72,7 @@ export default class ScenePacker { * @param {String} welcomeJournal Set the name of the journal to be imported and automatically opened after activation. * @param {String[]} additionalJournals Set which journals (by name) should be automatically imported. * @param {String[]} additionalMacros Set which macros (by name) should be automatically imported. + * @param {String[]} ignoredCompendiumPacks Set which compendium packs should be ignored when bulk importing entities. * @param {Boolean} allowImportPrompts Set whether import prompts should be allowed. */ constructor( @@ -84,6 +87,7 @@ export default class ScenePacker { welcomeJournal = '', additionalJournals = [], additionalMacros = [], + ignoredCompendiumPacks = [], allowImportPrompts = true, } = {}, ) { @@ -125,6 +129,9 @@ export default class ScenePacker { if (additionalMacros?.length) { this.SetAdditionalMacrosToImport(additionalMacros); } + if (ignoredCompendiumPacks?.length) { + this.SetIgnoredCompendiumPacks(ignoredCompendiumPacks); + } this.allowImportPrompts = allowImportPrompts; if (typeof window.DEV?.registerPackageDebugFlag === 'function') { @@ -440,7 +447,7 @@ export default class ScenePacker { type: game.i18n.format(CONSTANTS.TYPE_HUMANISE[packType]), })}

`; di.render(); - const packs = game.packs.filter((p) => (p.metadata.packageName || p.metadata.package) === this.moduleName && (p.documentName || p.entity) === packType); + const packs = game.packs.filter((p) => (p.metadata.packageName || p.metadata.package) === this.moduleName && (p.documentName || p.entity) === packType && !this.ignoredCompendiumPacks.has(p.metadata.id)); for (let i = 0; i < packs.length; i++) { let createData = []; const pack = packs[i]; @@ -867,6 +874,7 @@ export default class ScenePacker { name: pathPart, type: entityType, parent: parent?.id || null, + folder: parent?.id || null, color: cfColor || null, sorting: cfSorting, sort: cfSort, @@ -1450,6 +1458,48 @@ export default class ScenePacker { return this; } + /** + * Set which packs should be ignored when importing all entities. + * @param {String[]} packs + * @returns this to support chaining + */ + SetIgnoredCompendiumPacks(packs) { + if (packs) { + const availablePacks = Array.from(game.modules.get(this.moduleName)?.packs?.map(p => p.name) ?? []); + packs = packs instanceof Array ? packs : [packs]; + packs.forEach((j) => { + if (typeof j !== 'string') { + ui.notifications.error( + game.i18n.localize('SCENE-PACKER.errors.ignoredPacks.ui'), + ); + throw game.i18n.format('SCENE-PACKER.errors.ignoredPacks.details', { + pack: j, + packs: availablePacks.join(', '), + }); + } else { + if (!availablePacks.includes(j)) { + ui.notifications.error( + game.i18n.localize('SCENE-PACKER.errors.ignoredPacks.ui'), + ); + throw game.i18n.format('SCENE-PACKER.errors.ignoredPacks.invalid', { + pack: j, + packs: availablePacks.join(', '), + }); + } else { + this.ignoredCompendiumPacks.add(`${this.moduleName}.${j}`); + } + } + }); + } else { + this.log( + false, + game.i18n.localize('SCENE-PACKER.errors.ignoredPacks.missing'), + ); + } + + return this; + } + /** * Renders a dialog showing which Scenes in the world contain data that would benefit from being Packed. */