generated from League-of-Foundry-Developers/FoundryVTT-Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
Showing
8 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |