From 8daec8bd927d5fe817ae587cbf415dd2d82f6f53 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Fri, 9 Oct 2020 19:49:56 -0500 Subject: [PATCH] Add support for Foundry 0.7.3 - Fixed an issue with the actor/item creation dialog that prevented it from working on Foundry 0.7.x versions. - Removed obsolete translation string. - Bumped minimum core version now that 0.7.3 is in beta. --- module/simple.js | 14 ++++++++------ system.json | 4 ++-- templates/sidebar/entity-create.html | 1 - 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/module/simple.js b/module/simple.js index 4d047bb..78db88b 100644 --- a/module/simple.js +++ b/module/simple.js @@ -179,23 +179,23 @@ Hooks.on("getItemDirectoryEntryContext", (html, options) => { /** * Adds the actor template selection dialog. */ -ActorDirectory.prototype._onCreate = async (event) => { +ActorDirectory.prototype._onCreateEntity = async (event) => { // Do not allow the creation event to bubble to other listeners event.preventDefault(); event.stopPropagation(); - _simpleDirectoryTemplates('actor'); + _simpleDirectoryTemplates('actor', event); } /** * Adds the item template selection dialog. */ -ItemDirectory.prototype._onCreate = async (event) => { +ItemDirectory.prototype._onCreateEntity = async (event) => { // Do not allow the creation event to bubble to other listeners event.preventDefault(); event.stopPropagation(); - _simpleDirectoryTemplates('item'); + _simpleDirectoryTemplates('item', event); } /** @@ -205,8 +205,9 @@ ItemDirectory.prototype._onCreate = async (event) => { * defined for the entity type. * * @param {string} entityType - 'actor' or 'item' + * @param {MouseEvent} event - Triggering event */ -async function _simpleDirectoryTemplates(entityType = 'actor') { +async function _simpleDirectoryTemplates(entityType = 'actor', event) { // Retrieve the collection and class. const entityCollection = entityType == 'actor' ? game.actors : game.items; const cls = entityType == 'actor' ? Actor : Item; @@ -252,7 +253,8 @@ async function _simpleDirectoryTemplates(entityType = 'actor') { yes: html => { // Get the form data. const form = html[0].querySelector("form"); - mergeObject(createData, validateForm(form)); + const fd = new FormDataExtended(form); + mergeObject(createData, fd.toObject()); // Store the type and name values, and retrieve the template entity. let templateActor = entityCollection.getName(createData.type); diff --git a/system.json b/system.json index 87ab940..ea7d160 100644 --- a/system.json +++ b/system.json @@ -3,8 +3,8 @@ "title": "Simple World-Building", "description": "A minimalist game system with very simple Actor and Item models to support free-form system agnostic gameplay.", "version": 0.36, - "minimumCoreVersion": "0.5.6", - "compatibleCoreVersion": "0.5.7", + "minimumCoreVersion": "0.7.3", + "compatibleCoreVersion": "0.7.3", "templateVersion": 2, "author": "Atropos", "esmodules": ["module/simple.js"], diff --git a/templates/sidebar/entity-create.html b/templates/sidebar/entity-create.html index 4f7ccb2..19bcb29 100644 --- a/templates/sidebar/entity-create.html +++ b/templates/sidebar/entity-create.html @@ -11,6 +11,5 @@ {{/each}} -

{{localize "ENTITY.TypeHint"}}