Skip to content

Commit

Permalink
try adding sheet from DND
Browse files Browse the repository at this point in the history
  • Loading branch information
loulou123546 committed Aug 3, 2023
1 parent 8b167aa commit 19158ac
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 6 deletions.
10 changes: 8 additions & 2 deletions empire-des-cerisiers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/* -------------------------------------------- */
Expand Down Expand Up @@ -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, {
Expand Down
77 changes: 77 additions & 0 deletions scripts/characters/player-sheet-dnd.js
Original file line number Diff line number Diff line change
@@ -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);
}


}
34 changes: 32 additions & 2 deletions scripts/handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions system.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 19158ac

Please sign in to comment.