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,10 +0,0 @@
|
|||
import ActorSheetPC from "./module/sheets/pc.mjs";
|
||||
|
||||
console.log(`.dungeon | hello from dotdungeon.mjs`)
|
||||
Hooks.once(`init`, async () => {
|
||||
Actors.registerSheet("dotdungeon-pug", ActorSheetPC, {
|
||||
types: ["pc", "pug"],
|
||||
makeDefault: true,
|
||||
canBeDefault: true,
|
||||
});
|
||||
})
|
||||
|
|
@ -1 +1,9 @@
|
|||
{}
|
||||
{
|
||||
"stat.title": "Stats",
|
||||
"stat.build": "Build",
|
||||
"stat.meta": "Meta",
|
||||
"stat.presence": "Presence",
|
||||
"stat.hands": "Hands",
|
||||
"stat.tilt": "Tilt",
|
||||
"stat.rng": "RNG"
|
||||
}
|
||||
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"
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
@ -16,9 +16,11 @@
|
|||
],
|
||||
"url": "https://github.com/Oliver-Akins/foundry.dungeon",
|
||||
"esmodules": [
|
||||
"dotdungeon.mjs"
|
||||
"module/dotdungeon.js"
|
||||
],
|
||||
"styles": [
|
||||
".css/root.css"
|
||||
],
|
||||
"styles": [],
|
||||
"languages": [
|
||||
{
|
||||
"lang": "en",
|
||||
|
|
|
|||
5
templates/actors/char-sheet-mvp/partials/dice_choice.hbs
Normal file
5
templates/actors/char-sheet-mvp/partials/dice_choice.hbs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<select>
|
||||
{{#each (dotdungeon-array "d4" "d6" "d8" "d10" "d12" "d20")}}
|
||||
<option value="{{this}}">{{this}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
4
templates/actors/char-sheet-mvp/partials/stat.hbs
Normal file
4
templates/actors/char-sheet-mvp/partials/stat.hbs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<div class="stat">
|
||||
<label>{{localize (concat "stat." stat)}}</label>
|
||||
{{> dotdungeon.dice_choice }}
|
||||
</div>
|
||||
9
templates/actors/char-sheet-mvp/sheet.hbs
Normal file
9
templates/actors/char-sheet-mvp/sheet.hbs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<form autocomplete="off">
|
||||
<h2>{{localize "stat.title"}}</h2>
|
||||
{{> dotdungeon.stat stat="build" }}
|
||||
{{> dotdungeon.stat stat="meta" }}
|
||||
{{> dotdungeon.stat stat="presence" }}
|
||||
{{> dotdungeon.stat stat="hands" }}
|
||||
{{> dotdungeon.stat stat="tilt" }}
|
||||
{{> dotdungeon.stat stat="rng" }}
|
||||
</form>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<form autocomplete="off">
|
||||
Build:
|
||||
<br>
|
||||
Meta:
|
||||
<br>
|
||||
Presence:
|
||||
<br>
|
||||
Hands:
|
||||
<br>
|
||||
Tilt:
|
||||
<br>
|
||||
RNG:
|
||||
<br>
|
||||
<br>
|
||||
Respawns: [ ] [ ] [ ]
|
||||
</form>
|
||||
Loading…
Add table
Add a link
Reference in a new issue