Minimal working example for a character sheet
This commit is contained in:
parent
08a8b89ec0
commit
e5c1cfec97
11 changed files with 91 additions and 31 deletions
1
module/documents/CharacterActor.js
Normal file
1
module/documents/CharacterActor.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
export class CharacterActor extends Actor {}
|
||||
25
module/dotdungeon.js
Normal file
25
module/dotdungeon.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { CharacterActor } from "./documents/CharacterActor.js";
|
||||
import { CharacterSheet } from "./sheets/CharacterSheet.js";
|
||||
|
||||
import * as hbs from "./handlebars.js";
|
||||
|
||||
// import diceChoice from "../templates/actors/char-sheet-mvp/partials/dice_choice.hbs?raw";
|
||||
|
||||
Hooks.once(`init`, async function () {
|
||||
game.boilerplate = {
|
||||
CharacterActor,
|
||||
};
|
||||
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("dotdungeon", CharacterSheet, { makeDefault: true, });
|
||||
|
||||
|
||||
await hbs.registerHandlebarsHelpers();
|
||||
await hbs.preloadHandlebarsTemplates()
|
||||
console.info(`.dungeon | Dot Dungeon has been initialized fully`);
|
||||
});
|
||||
|
||||
|
||||
Hooks.once(`ready`, function() {
|
||||
console.info(".dungeon | Ready");
|
||||
});
|
||||
32
module/handlebars.js
Normal file
32
module/handlebars.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
export async function registerHandlebarsHelpers() {
|
||||
Handlebars.registerHelper({
|
||||
"dotdungeon-array": createArray
|
||||
});
|
||||
};
|
||||
|
||||
export async function preloadHandlebarsTemplates() {
|
||||
console.groupCollapsed(`.dungeon | Handlebars template loading`)
|
||||
const pathPrefix = `systems/dotdungeon/templates/`;
|
||||
const partials = [
|
||||
"actors/char-sheet-mvp/partials/dice_choice.hbs",
|
||||
"actors/char-sheet-mvp/partials/stat.hbs",
|
||||
];
|
||||
|
||||
const paths = {};
|
||||
|
||||
for ( const partial of partials ) {
|
||||
console.debug(`Loading partial: ${partial}`);
|
||||
const path = `${pathPrefix}${partial}`;
|
||||
paths[path] = path;
|
||||
paths[`dotdungeon.${path.split("/").pop().replace(".hbs", "")}`] = path;
|
||||
}
|
||||
|
||||
console.debug(`Loaded ${partials.length} partials`);
|
||||
console.groupEnd();
|
||||
return loadTemplates(paths);
|
||||
};
|
||||
|
||||
|
||||
function createArray(...args) {
|
||||
return args.slice(0, -1);
|
||||
};
|
||||
|
|
@ -2,13 +2,13 @@
|
|||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
*/
|
||||
export class ActorSheetPC extends ActorSheet {
|
||||
export class CharacterSheet extends ActorSheet {
|
||||
static get defaultOptions() {
|
||||
return mergeObject(
|
||||
super.defaultOptions,
|
||||
{
|
||||
classes: ["dotdungeon", "sheet", "actor"],
|
||||
template: "systems/dotdungeon/templates/actors/character-sheet-mvp.hbs"
|
||||
template: "systems/dotdungeon/templates/actors/char-sheet-mvp/sheet.hbs"
|
||||
}
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue