Skip to content

Commit

Permalink
v2.8.3
Browse files Browse the repository at this point in the history
- 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).
  • Loading branch information
sneat authored Dec 15, 2024
1 parent b2e3412 commit 8a0f9a8
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
});
});
Expand Down
6 changes: 6 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 6 additions & 0 deletions languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packs/journals.db

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions scripts/adventure-converter/adventure-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
52 changes: 51 additions & 1 deletion scripts/scene-packer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export default class ScenePacker {
playlists: [],
modules: [],
};
/** @type {Set<String>} */
ignoredCompendiumPacks = new Set();
allowImportPrompts = true;

/**
Expand All @@ -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(
Expand All @@ -84,6 +87,7 @@ export default class ScenePacker {
welcomeJournal = '',
additionalJournals = [],
additionalMacros = [],
ignoredCompendiumPacks = [],
allowImportPrompts = true,
} = {},
) {
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -440,7 +447,7 @@ export default class ScenePacker {
type: game.i18n.format(CONSTANTS.TYPE_HUMANISE[packType]),
})}</p>`;
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];
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 8a0f9a8

Please sign in to comment.