From 19158ac5850bb6cc079a5680b2195196194fe5dc Mon Sep 17 00:00:00 2001 From: loulou123546 Date: Fri, 4 Aug 2023 00:32:06 +0200 Subject: [PATCH] try adding sheet from DND --- empire-des-cerisiers.mjs | 10 +++- scripts/characters/player-sheet-dnd.js | 77 ++++++++++++++++++++++++++ scripts/handlebars.js | 34 +++++++++++- system.json | 4 +- 4 files changed, 119 insertions(+), 6 deletions(-) create mode 100644 scripts/characters/player-sheet-dnd.js diff --git a/empire-des-cerisiers.mjs b/empire-des-cerisiers.mjs index d95713ecbf..30d70c802c 100644 --- a/empire-des-cerisiers.mjs +++ b/empire-des-cerisiers.mjs @@ -13,13 +13,14 @@ import EDC from "./module/config.mjs"; import registerSystemSettings from "./module/settings.mjs"; // Import Submodules -import * as applications from "./module/applications/_module.mjs"; +// import * as applications from "./module/applications/_module.mjs"; // import * as dataModels from "./module/data/_module.mjs"; // import * as documents from "./module/documents/_module.mjs"; import { PlayerActor } from "./scripts/characters/player.js"; import { PlayerActorSheet } from "./scripts/characters/player-sheet.js"; +import { PlayerActorSheetDND } from "./scripts/characters/player-sheet-dnd.js"; import { preloadHandlebarsTemplates, registerHandlebarsHelpers } from "./scripts/handlebars.js"; /* -------------------------------------------- */ @@ -61,11 +62,16 @@ Hooks.once("init", function() { // Register sheet application classes Actors.unregisterSheet("core", ActorSheet); - Actors.registerSheet("empire-des-cerisiers", applications.actor.ActorSheet5eCharacter , { // PlayerActorSheet + Actors.registerSheet("empire-des-cerisiers", PlayerActorSheet, { types: ["character", "player"], makeDefault: true, label: "DND5E.SheetClassCharacter" }); + Actors.registerSheet("empire-des-cerisiers", PlayerActorSheetDND, { + types: ["character", "player"], + makeDefault: false, + label: "DND5E.SECOND_TEST" + }); // Items.unregisterSheet("core", ItemSheet); // Items.registerSheet("empire-des-cerisiers", applications.item.ItemSheet5e, { diff --git a/scripts/characters/player-sheet-dnd.js b/scripts/characters/player-sheet-dnd.js new file mode 100644 index 0000000000..54713b7b1a --- /dev/null +++ b/scripts/characters/player-sheet-dnd.js @@ -0,0 +1,77 @@ +export class PlayerActorSheetDND extends ActorSheet { + + constructor (object, options) { + let actor = super(object, options); + // console.warn("CharacterSheet | constructor | actor"); + // console.log(actor.token); + return actor; + } + + get template() { + return `systems/empire-des-cerisiers/templates/actors/character-sheet.hbs`; + } + + static get defaultOptions() { + return foundry.utils.mergeObject(super.defaultOptions, { + classes: ["sheet", "character", "player"], + template: `systems/empire-des-cerisiers/templates/actors/character-sheet.hbs`, + width: 1200, + height: 700, + // tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "skills" }], + // dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }], + dragDrop: [ + { dropSelector: "#droppable-journaux"} + ], + }); + } + + async getData(options = {}) { + const sheetData = await super.getData(options); + const system = sheetData.data.system; + + sheetData.data.isGM = game.user.isGM; + + return sheetData; + } + + async activateListeners (html) { + super.activateListeners(html); + + html.find(".clear-journaEntries*").on("click", this._clearJournalEntries.bind(this)); + } + + async _clearJournalEntries (event) { + event.preventDefault(); + if (!game.user.isGM) return; + this.actor.update({ "system.journalEntries": [] }); + } + + async _onDrop (event) { + /* { + "type":"JournalEntryPage", + "uuid":"JournalEntry.X9RVyhaeWkjKiRbs.JournalEntryPage.is8OXOwy5stuQGPl", + "anchor":{"name":"0.\nInventaire"} + } */ + try { + let data = JSON.parse(event.dataTransfer?.getData("text/plain")); + if (data.type === "JournalEntryPage") { + if (!game.user.isGM) return; + let name = data.anchor.name.split('\n').pop(); + let newLink = { + "name": name, + "uuid": data.uuid, + "id": data.uuid.split('.').pop(), + "type": data.type + } + + let je = this.actor.system?.journalEntries || []; + this.actor.update({ "system.journalEntries": [...je, newLink] }); + + return; + } + } catch (error) {} + return super._onDrop(event); + } + + +} diff --git a/scripts/handlebars.js b/scripts/handlebars.js index 219f8d12e1..8b21dadcd3 100644 --- a/scripts/handlebars.js +++ b/scripts/handlebars.js @@ -4,12 +4,42 @@ import { PlayerActorSheet } from "./characters/player-sheet.js"; export async function preloadHandlebarsTemplates() { const partials = [ PlayerActorSheet.templateFiles, + [ + // Shared Partials + "systems/empire-des-cerisiers/templates/actors/parts/active-effects.hbs", + "systems/empire-des-cerisiers/templates/apps/parts/trait-list.hbs", + + // Actor Sheet Partials + "systems/empire-des-cerisiers/templates/actors/parts/actor-traits.hbs", + "systems/empire-des-cerisiers/templates/actors/parts/actor-inventory.hbs", + "systems/empire-des-cerisiers/templates/actors/parts/actor-features.hbs", + "systems/empire-des-cerisiers/templates/actors/parts/actor-spellbook.hbs", + "systems/empire-des-cerisiers/templates/actors/parts/actor-warnings.hbs", + + // Item Sheet Partials + "systems/empire-des-cerisiers/templates/items/parts/item-action.hbs", + "systems/empire-des-cerisiers/templates/items/parts/item-activation.hbs", + "systems/empire-des-cerisiers/templates/items/parts/item-advancement.hbs", + "systems/empire-des-cerisiers/templates/items/parts/item-description.hbs", + "systems/empire-des-cerisiers/templates/items/parts/item-mountable.hbs", + "systems/empire-des-cerisiers/templates/items/parts/item-spellcasting.hbs", + "systems/empire-des-cerisiers/templates/items/parts/item-summary.hbs", + + // Journal Partials + "systems/empire-des-cerisiers/templates/journal/parts/journal-table.hbs", + + // Advancement Partials + "systems/empire-des-cerisiers/templates/advancement/parts/advancement-controls.hbs", + "systems/empire-des-cerisiers/templates/advancement/parts/advancement-spell-config.hbs" + ] ].flat() const paths = {}; for ( const path of partials ) { - paths[path] = path; - paths[`edc.${path.split("/").pop().replace(".html", "")}`] = path; + paths[path] = path; + paths[`edc.${path.split("/").pop().replace(".html", "")}`] = path; + paths[path.replace(".hbs", ".html")] = path; + paths[`dnd5e.${path.split("/").pop().replace(".hbs", "")}`] = path; } return loadTemplates(paths); diff --git a/system.json b/system.json index cf730b65ae..9bb22e1b14 100644 --- a/system.json +++ b/system.json @@ -2,14 +2,14 @@ "id": "empire-des-cerisiers", "title": "L'Empire des Cerisiers", "description": "Non-official system for L'Empire des Cerisiers. Original book written by Olivier Sanfilippo at Arkhane Asylum.", - "version": "1.1.3", + "version": "1.1.4", "compatibility": { "minimum": "10.291", "verified": "11" }, "url": "https://github.com/loulou123546/empire-des-cerisiers", "manifest": "https://raw.githubusercontent.com/loulou123546/empire-des-cerisiers/master/system.json", - "download": "https://github.com/loulou123546/empire-des-cerisiers/archive/refs/tags/1.1.3.zip", + "download": "https://github.com/loulou123546/empire-des-cerisiers/archive/refs/tags/1.1.4.zip", "authors": [ { "name": "Olivier Sanfilippo",