Skip to content

Commit

Permalink
v2.7.15
Browse files Browse the repository at this point in the history
- Added a button in the settings to more easily re-prompt for a module's automatic importer.
  - This functionality always existed via a macro. This button just makes it easier to find.
  • Loading branch information
sneat authored Oct 10, 2024
1 parent ef4dfbe commit b772052
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.7.15
- Added a button in the settings to more easily re-prompt for a module's automatic importer.
- This functionality always existed via a macro. This button just makes it easier to find.

## v2.7.14
- Allow the Moulinette importer tool to correctly handle zip files manually created on Windows.
- Updated [fflate](https://101arrowz.github.io/fflate/) to v0.8.2.
Expand Down
8 changes: 8 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,14 @@
"all-lowercase": "All assets are already lowercase.",
"list-assets": "The following assets will be converted to lowercase:",
"confirm": "Are you sure you want to convert these assets to lowercase?"
},
"reset-prompts": {
"name": "Reset import prompts",
"label": "Choose module",
"hint": "Use this to reset the prompt you received when you first installed a supported module. Handy if you accidentally closed it the first time.",
"nothing": "There are no modules installed that are registered with Scene Packer, so there are no welcome prompts that can be reset. Make sure the module is enabled.",
"refresh-text": "Resetting the prompt will automatically reload your world.",
"select-module-label": "Select module:"
}
}
}
8 changes: 8 additions & 0 deletions languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,14 @@
"title": "Vérifier que des assets existent et les convertir en minuscules",
"description": "Cet outil vérifiera que tous les assets de votre monde existent et convertira leurs références en minuscules. Il énumérera d'abord toutes les références des assets qu'il convertira, puis vous demandera de confirmer.",
"nothing": "Aucun asset n'a été trouvé dans votre monde."
},
"reset-prompts": {
"name": "Réinitialiser les invites d'importation",
"label": "Choisir le module",
"hint": "Utilisez ceci pour réinitialiser l'invite que vous avez reçue lors de la première installation d'un module pris en charge. Pratique si vous l'avez accidentellement fermée la première fois.",
"nothing": "Il n'y a aucun module installé qui soit enregistré avec Scene Packer, donc il n'y a pas d'invites de bienvenue à réinitialiser. Assurez-vous que le module est activé.",
"refresh-text": "La réinitialisation de l'invite rechargera automatiquement votre monde.",
"select-module-label": "Sélectionner le module:"
}
}
}
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.7.14",
"version": "2.7.15",
"library": "true",
"manifestPlusVersion": "1.2.0",
"minimumCoreVersion": "0.8.6",
Expand Down
5 changes: 5 additions & 0 deletions scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ export const CONSTANTS = Object.freeze({
*/
SETTING_IMPORTED_VERSION: 'imported',

/**
* The setting key for triggering the ResetImportPrompt class.
*/
SETTING_RESET_IMPORT_PROMPT: 'resetImportPrompt',

/**
* The setting key for the version of the system that last had a Scene Packer migration run against it.
*/
Expand Down
59 changes: 59 additions & 0 deletions scripts/reset-import-prompts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { CONSTANTS } from './constants.js';

export default class ResetImportPrompts extends FormApplication {

/** @inheritDoc */
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
title: game.i18n.localize('SCENE-PACKER.reset-prompts.name'),
id: 'scene-packer-reset-import-prompts',
template: 'modules/scene-packer/templates/reset-import-prompts.hbs',
classes: ['scene-packer'],
});
}

/**
* @returns {Object|Promise<Object>}
*/
getData(options = {}) {
const instances = Object.values(ScenePacker.instances).map(m => {
const module = game.modules.get(m.moduleName);
return {
id: module?.id || m.moduleName,
name: (module?.title ?? module?.data?.title) || m.adventureName,
}
});
return {
instances,
};
}

/** @inheritdoc */
async _updateObject(event, formData) {
const moduleName = formData['module-name'];
if (!moduleName) {
return;
}

await Promise.allSettled([
game.settings.set(moduleName, CONSTANTS.SETTING_IMPORTED_VERSION, '0.0.0'),
game.settings.set(moduleName, CONSTANTS.SETTING_PROMPTED, '0.0.0'),
game.settings.set(moduleName, CONSTANTS.SETTING_SHOW_WELCOME_PROMPTS, true),
game.settings.set(moduleName, CONSTANTS.SETTING_SYSTEM_MIGRATION_VERSION, '0.0.0'),
]);

if (canvas?.scene?.getFlag(moduleName, CONSTANTS.SETTING_IMPORTED_VERSION)) {
await canvas.scene.setFlag(moduleName, CONSTANTS.SETTING_IMPORTED_VERSION, '0.0.0')
}

setTimeout(() => {
window.location.reload();
}, 200);
}

/** @inheritdoc */
activateListeners(html) {
super.activateListeners(html);
html.find('button[name="close"]').click(this.close.bind(this));
}
}
10 changes: 10 additions & 0 deletions scripts/scene-packer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import MoulinetteImporter from './export-import/moulinette-importer.js';
import Report from './report.js';
import WelcomeJournal from './welcome-journal.js';
import ZipImporter from './export-import/zip-importer.js';
import ResetImportPrompts from './reset-import-prompts.js';

/**
* Tracks the initialised instances of Scene Packer and also exposes some methods to globalThis.
Expand Down Expand Up @@ -5861,6 +5862,15 @@ Hooks.once('setup', () => {
await instance.ProcessScene(readyCanvas.scene);
});

game.settings.registerMenu(CONSTANTS.MODULE_NAME, CONSTANTS.SETTING_RESET_IMPORT_PROMPT, {
name: game.i18n.localize('SCENE-PACKER.reset-prompts.name'),
label: game.i18n.localize('SCENE-PACKER.reset-prompts.label'),
hint: game.i18n.localize('SCENE-PACKER.reset-prompts.hint'),
icon: "fas fa-arrows-rotate",
type: ResetImportPrompts,
restricted: true,
})

game.settings.register(CONSTANTS.MODULE_NAME, CONSTANTS.SETTING_ENABLE_CONTEXT_MENU, {
name: game.i18n.localize('SCENE-PACKER.settings.context-menu.name'),
hint: game.i18n.localize('SCENE-PACKER.settings.context-menu.hint'),
Expand Down
33 changes: 33 additions & 0 deletions templates/reset-import-prompts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<form>
<section class="content">
<h3>{{localize 'SCENE-PACKER.reset-prompts.name'}}</h3>
<div><p>{{localize 'SCENE-PACKER.reset-prompts.hint'}}</p></div>
<hr>
{{#if instances.length}}
<div>
<label>
{{localize 'SCENE-PACKER.reset-prompts.select-module-label'}}
<select name="module-name">
{{#each instances as |instance|}}
<option value="{{instance.id}}">{{instance.id}} ({{instance.name}})</option>
{{/each}}
</select>
</label>
</div>
<div><p>{{localize 'SCENE-PACKER.reset-prompts.refresh-text'}}</p></div>
{{else}}
<div><p>{{localize 'SCENE-PACKER.reset-prompts.nothing'}}</p></div>
{{/if}}
</section>

<footer class="flexrow">
{{#if instances.length}}
<button type="submit" name="convert">
<i class="fas fa-arrows-rotate"></i> {{localize 'SCENE-PACKER.reset-prompts.name'}}
</button>
{{/if}}
<button type="button" name="close">
<i class="fas fa-times"></i> {{localize 'Cancel'}}
</button>
</footer>
</form>

0 comments on commit b772052

Please sign in to comment.