diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 880690e..899d25b 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -9,7 +9,8 @@ import { * Extend the basic ActorSheet with some very simple modifications * @extends {ActorSheet} */ -export default class DeltaGreenActorSheet extends ActorSheet { +export default class DeltaGreenActorSheet extends foundry.appv1.sheets + .ActorSheet { /** @override */ static get defaultOptions() { return foundry.utils.mergeObject(super.defaultOptions, { @@ -200,23 +201,26 @@ export default class DeltaGreenActorSheet extends ActorSheet { switch (this.actor.type) { case "agent": - data.enrichedDescription = await TextEditor.enrichHTML( - this.object.system.physicalDescription, - { async: true } - ); + data.enrichedDescription = + await foundry.applications.ux.TextEditor.implementation.enrichHTML( + this.object.system.physicalDescription, + { async: true } + ); break; case "vehicle": - data.enrichedDescription = await TextEditor.enrichHTML( - this.object.system.description, - { async: true } - ); + data.enrichedDescription = + await foundry.applications.ux.TextEditor.implementation.enrichHTML( + this.object.system.description, + { async: true } + ); break; case "npc": case "unnatural": - data.enrichedDescription = await TextEditor.enrichHTML( - this.object.system.notes, - { async: true } - ); + data.enrichedDescription = + await foundry.applications.ux.TextEditor.implementation.enrichHTML( + this.object.system.notes, + { async: true } + ); break; default: } diff --git a/module/actor/actor.js b/module/actor/actor.js index 32e02b3..16b830f 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -49,7 +49,7 @@ export default class DeltaGreenActor extends Actor { actorData.system.health.protection = protection; - console.log(actor); + //console.log(actor); } _prepareNpcData(actor) { @@ -120,7 +120,7 @@ export default class DeltaGreenActor extends Actor { system.health.protection = protection; - console.log(actor); + //console.log(actor); } /** @@ -148,7 +148,7 @@ export default class DeltaGreenActor extends Actor { system.health.protection = protection; - console.log(actor); + //console.log(actor); } /** @@ -300,7 +300,7 @@ export default class DeltaGreenActor extends Actor { -1 * Math.abs(system.physical.exhaustedPenalty); } - console.log(agent); + //console.log(agent); } /** @override */ diff --git a/module/deltagreen.js b/module/deltagreen.js index 88fa6a8..392072c 100644 --- a/module/deltagreen.js +++ b/module/deltagreen.js @@ -47,12 +47,26 @@ Hooks.once("init", async () => { CONFIG.Item.documentClass = DeltaGreenItem; // Register sheet application classes - Actors.unregisterSheet("core", ActorSheet); - Items.unregisterSheet("core", ItemSheet); - Actors.registerSheet("deltagreen", DeltaGreenActorSheet, { - makeDefault: true, - }); - Items.registerSheet("deltagreen", DeltaGreenItemSheet, { makeDefault: true }); + foundry.documents.collections.Actors.unregisterSheet( + "core", + foundry.appv1.sheets.ActorSheet + ); + foundry.documents.collections.Items.unregisterSheet( + "core", + foundry.appv1.sheets.ItemSheet + ); + foundry.documents.collections.Actors.registerSheet( + "deltagreen", + DeltaGreenActorSheet, + { + makeDefault: true, + } + ); + foundry.documents.collections.Items.registerSheet( + "deltagreen", + DeltaGreenItemSheet, + { makeDefault: true } + ); // Preload Handlebars Templates preloadHandlebarsTemplates(); @@ -98,16 +112,32 @@ Hooks.on("preCreateItem", (item) => { }); // Hook into the render call for the Actors Directory to add an extra button -Hooks.on("renderActorDirectory", (app, html) => { - let importButton = $( - '', - ); - html.find(".directory-footer").append(importButton); +Hooks.on("renderActorDirectory", (app, html, data) => { + if (!game.user.isGM) { + return; + } - // Handle button clicks - importButton.click((ev) => { - ParseDeltaGreenStatBlock(); - }); + if (html.querySelector("#statParserButton")) { + return; + } + + const button = document.createElement("button"); + button.id = "statParserButton"; + + const icon = document.createElement("i"); + + icon.classList.add("fas", "fa-file-import"); + + button.appendChild(icon); + button.append("Delta Green Stat Block Parser"); + + html.querySelector(".directory-footer").appendChild(button); + + if (button) { + button.addEventListener("click", function (event) { + ParseDeltaGreenStatBlock(); + }); + } }); /** diff --git a/module/item/item-sheet.js b/module/item/item-sheet.js index 2d6776c..fcbf356 100644 --- a/module/item/item-sheet.js +++ b/module/item/item-sheet.js @@ -9,7 +9,8 @@ import { * Extend the basic ItemSheet with some very simple modifications * @extends {ItemSheet} */ -export default class DeltaGreenItemSheet extends ItemSheet { +export default class DeltaGreenItemSheet extends foundry.appv1.sheets + .ItemSheet { /** @override */ static get defaultOptions() { return foundry.utils.mergeObject(super.defaultOptions, { @@ -42,13 +43,13 @@ export default class DeltaGreenItemSheet extends ItemSheet { data.enrichedDescription = await TextEditor.enrichHTML( this.object.system.description, - { async: true }, + { async: true } ); if (data.item.type === "tome" || data.item.type === "ritual") { data.enrichedHandlerNotes = await TextEditor.enrichHTML( this.object.system.handlerNotes, - { async: true }, + { async: true } ); } diff --git a/module/templates.js b/module/templates.js index 980e6ab..2e602fa 100644 --- a/module/templates.js +++ b/module/templates.js @@ -4,7 +4,7 @@ * @return {Promise} */ export default async function preloadHandlebarsTemplates() { - return loadTemplates([ + return foundry.applications.handlebars.loadTemplates([ "systems/deltagreen/templates/actor/actor-sheet.html", "systems/deltagreen/templates/actor/limited-sheet.html", "systems/deltagreen/templates/actor/unnatural-sheet.html", diff --git a/system.json b/system.json index cb5dcb8..e355aa3 100644 --- a/system.json +++ b/system.json @@ -17,9 +17,9 @@ ], "version": "1.3.5", "compatibility": { - "minimum": "12", - "verified": "12", - "maximum": "12" + "minimum": "13", + "verified": "13", + "maximum": "13" }, "esmodules": ["module/deltagreen.js"], "styles": ["css/deltagreen.css", "css/dialogue.css"], diff --git a/templates/actor/partials/cv-partial.html b/templates/actor/partials/cv-partial.html index 2d8dabc..f5fd9c0 100644 --- a/templates/actor/partials/cv-partial.html +++ b/templates/actor/partials/cv-partial.html @@ -53,5 +53,5 @@