Minimal working example for a character sheet

This commit is contained in:
Oliver-Akins 2023-11-21 22:59:22 -07:00
parent 08a8b89ec0
commit e5c1cfec97
11 changed files with 91 additions and 31 deletions

View file

@ -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,
});
})

View file

@ -1 +1,9 @@
{} {
"stat.title": "Stats",
"stat.build": "Build",
"stat.meta": "Meta",
"stat.presence": "Presence",
"stat.hands": "Hands",
"stat.tilt": "Tilt",
"stat.rng": "RNG"
}

View file

@ -0,0 +1 @@
export class CharacterActor extends Actor {}

25
module/dotdungeon.js Normal file
View 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
View 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);
};

View file

@ -2,13 +2,13 @@
* Extend the basic ActorSheet with some very simple modifications * Extend the basic ActorSheet with some very simple modifications
* @extends {ActorSheet} * @extends {ActorSheet}
*/ */
export class ActorSheetPC extends ActorSheet { export class CharacterSheet extends ActorSheet {
static get defaultOptions() { static get defaultOptions() {
return mergeObject( return mergeObject(
super.defaultOptions, super.defaultOptions,
{ {
classes: ["dotdungeon", "sheet", "actor"], classes: ["dotdungeon", "sheet", "actor"],
template: "systems/dotdungeon/templates/actors/character-sheet-mvp.hbs" template: "systems/dotdungeon/templates/actors/char-sheet-mvp/sheet.hbs"
} }
); );
}; };

View file

@ -16,9 +16,11 @@
], ],
"url": "https://github.com/Oliver-Akins/foundry.dungeon", "url": "https://github.com/Oliver-Akins/foundry.dungeon",
"esmodules": [ "esmodules": [
"dotdungeon.mjs" "module/dotdungeon.js"
],
"styles": [
".css/root.css"
], ],
"styles": [],
"languages": [ "languages": [
{ {
"lang": "en", "lang": "en",

View file

@ -0,0 +1,5 @@
<select>
{{#each (dotdungeon-array "d4" "d6" "d8" "d10" "d12" "d20")}}
<option value="{{this}}">{{this}}</option>
{{/each}}
</select>

View file

@ -0,0 +1,4 @@
<div class="stat">
<label>{{localize (concat "stat." stat)}}</label>
{{> dotdungeon.dice_choice }}
</div>

View 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>

View file

@ -1,16 +0,0 @@
<form autocomplete="off">
Build:
<br>
Meta:
<br>
Presence:
<br>
Hands:
<br>
Tilt:
<br>
RNG:
<br>
<br>
Respawns: [ ] [ ] [ ]
</form>