Refactor the sections of the PC sheet into their own partials for ease of reading, and localize the Aspect block labels

This commit is contained in:
Oliver-Akins 2023-12-28 22:55:49 -07:00
parent be197617cc
commit fae962dc7e
13 changed files with 350 additions and 318 deletions

View file

@ -75,6 +75,11 @@
"dotdungeon.actor.pc.skill.explosives": "Explosives", "dotdungeon.actor.pc.skill.explosives": "Explosives",
"dotdungeon.actor.pc.skill.piloting": "Piloting", "dotdungeon.actor.pc.skill.piloting": "Piloting",
"dotdungeon.actor.pc.aspect.name.placeholder": "Name...",
"dotdungeon.actor.pc.aspect.used": "Used",
"dotdungeon.actor.pc.aspect.duration": "Duration",
"dotdungeon.actor.pc.aspect.description.placeholder": "Description...",
"dotdungeon.actor.pc.respawns.header": "Respawns", "dotdungeon.actor.pc.respawns.header": "Respawns",
"dotdungeon.actor.pc.sync.header": "Sync", "dotdungeon.actor.pc.sync.header": "Sync",

View file

@ -6,6 +6,18 @@ export const partials = [
`actors/char-sheet-mvp/partials/skill.hbs`, `actors/char-sheet-mvp/partials/skill.hbs`,
`partials/panel.hbs`, `partials/panel.hbs`,
`items/aspect.hbs`, `items/aspect.hbs`,
// All of the partials for the PC sheet panels
`actors/char-sheet-mvp/panels/aspect.pc.hbs`,
`actors/char-sheet-mvp/panels/backpack.pc.hbs`,
`actors/char-sheet-mvp/panels/mounts.pc.hbs`,
`actors/char-sheet-mvp/panels/profile.pc.hbs`,
`actors/char-sheet-mvp/panels/roles.pc.hbs`,
`actors/char-sheet-mvp/panels/spells.pc.hbs`,
`actors/char-sheet-mvp/panels/storage.pc.hbs`,
`actors/char-sheet-mvp/panels/summons.pc.hbs`,
`actors/char-sheet-mvp/panels/sync.pc.hbs`,
`actors/char-sheet-mvp/panels/weapons.pc.hbs`,
]; ];
export async function registerHandlebarsHelpers() { export async function registerHandlebarsHelpers() {
@ -21,7 +33,18 @@ export async function preloadHandlebarsTemplates() {
for ( const partial of partials ) { for ( const partial of partials ) {
console.debug(`Loading partial: ${partial}`); console.debug(`Loading partial: ${partial}`);
const path = `${pathPrefix}${partial}`; const path = `${pathPrefix}${partial}`;
paths[`dotdungeon.${partial.split(`/`).pop().replace(`.hbs`, ``)}`] = path; /*
Converts a path/to/template.pc.hbs into a "pc.template" alias for
ease of use in partial referencing
*/
const alias = partial
.split(`/`)
.pop()
.split(`.`)
.slice(0, -1)
.reverse()
.join(`.`);
paths[`dotdungeon.${alias}`] = path;
}; };
console.debug(`Loaded ${partials.length} partials`); console.debug(`Loaded ${partials.length} partials`);

View file

@ -0,0 +1,37 @@
{{#> dotdungeon.panel class="aspect" title="dotdungeon.actor.pc.panel.aspect"}}
<input
type="text"
class="aspect__name--input"
name="system.aspect.name"
placeholder="{{localize "dotdungeon.actor.pc.aspect.name.placeholder"}}"
value="{{system.aspect.name}}"
>
<label class="aspect__used--label">
{{localize "dotdungeon.actor.pc.aspect.used"}}
<input
type="checkbox"
class="aspect__used--input"
name="system.aspect.used"
{{checked system.aspect.used}}
>
</label>
<label class="aspect__duration--label">
{{localize "dotdungeon.actor.pc.aspect.duration"}}
{{#if system.aspect.deactivateAfter}}
<span class="friendly-duration aspect__duration--friendly">
({{dotdungeon-toFriendlyDuration system.aspect.deactivateAfter}})
</span>
{{/if}}
<input
type="number"
class="aspect__duration--input"
name="system.aspect.deactivateAfter"
value="{{system.aspect.deactivateAfter}}"
>
</label>
<textarea
class="aspect__description--input"
name="system.aspect.description"
placeholder="{{localize "dotdungeon.actor.pc.aspect.description.placeholder"}}"
>{{system.aspect.description}}</textarea>
{{/ dotdungeon.panel}}

View file

@ -0,0 +1,65 @@
{{#> dotdungeon.panel class="backpack" title="dotdungeon.actor.pc.panel.backpack"}}
<label class="row">
<span class="grow">
{{localize "dotdungeon.actor.pc.backpack.bytes.label"}}
</span>
<input
class="bytes-input"
type="number"
name="system.bytes"
value="{{system.bytes}}"
min="0"
aria-label="{{localize "dotdungeon.aria.actor.pc.input.bytes"}}"
aria-valuemin="0"
aria-valuenow="{{system.bytes}}"
>
</label>
<label class="row">
<span class="grow">
{{localize
(concat
"dotdungeon.settings.resourcesOrSupplies.option."
settings.resourcesOrSupplies
)
}}
{{#if settings.devMode}}
<span class="debug-data">
({{settings.resourcesOrSupplies}})
</span>
{{/if}}
</span>
<input
class="supplies-count"
type="number"
name="system.supplies"
value="{{system.supplies}}"
min="0"
max="5"
aria-label="{{localize "dotdungeon.aria.actor.pc.input.supplies"}}"
aria-valuemin="0"
aria-valuemax="5"
aria-valuenow="{{system.supplies}}"
>
</label>
<label class="row">
<span class="grow">
{{localize "dotdungeon.actor.pc.backpack.materials.label"}}
</span>
<input
class="materials-count"
type="number"
name="system.materials"
value="{{system.materials}}"
min="0"
max="5"
aria-label="{{localize "dotdungeon.aria.actor.pc.input.materials"}}"
aria-valuemin="0"
aria-valuemax="5"
aria-valuenow="{{system.supplies}}"
>
</label>
<label class="grow col">
Inventory
<textarea class="grow" name="system.inventoryString">{{system.inventoryString}}</textarea>
</label>
{{/ dotdungeon.panel}}

View file

@ -0,0 +1,3 @@
{{#> dotdungeon.panel class="mounts" title="dotdungeon.actor.pc.panel.mounts"}}
Mounts
{{/ dotdungeon.panel}}

View file

@ -0,0 +1,43 @@
{{#> dotdungeon.panel class="profile" title="dotdungeon.actor.pc.panel.profile"}}
{{#if settings.showAvatarOnSheet}}
<img
class="avatar"
src="{{actor.img}}"
data-edit="img"
title="{{actor.name}}"
/>
{{else}}
<label>
{{localize "dotdungeon.actor.pc.profile.avatar.label"}}
{{filePicker type="avatar" target="img"}}
</label>
{{/if}}
{{#if settings.devMode}}
<div class="debug-data">
Image URL: {{actor.img}}
</div>
{{/if}}
<label>
{{localize "dotdungeon.actor.pc.profile.name.label"}}
<input
type="text"
name="name"
value="{{actor.name}}"
placeholder="{{localize "dotdungeon.actor.pc.profile.name.placeholder"}}"
>
</label>
{{#if computed.canChangeGroup}}
<label>
{{localize "dotdungeon.actor.pc.profile.group.label"}}
{{#unless settings.playersCanChangeGroup}}
<span>{{localize "dotdungeon.actor.pc.profile.group.gm-edit"}}</span>
{{/unless}}
<input
type="text"
name="system.group"
value="{{system.group}}"
placeholder="{{localize "dotdungeon.actor.pc.profile.group.placeholder"}}"
>
</label>
{{/if}}
{{/ dotdungeon.panel}}

View file

@ -0,0 +1,7 @@
{{#> dotdungeon.panel class="roles" title="dotdungeon.actor.pc.panel.roles"}}
{{#each system.roles}}
<textarea
name="system.roles.{{@key}}"
>{{this}}</textarea>
{{/each}}
{{/ dotdungeon.panel}}

View file

@ -0,0 +1,3 @@
{{#> dotdungeon.panel class="spells" title="dotdungeon.actor.pc.panel.spells"}}
Spells
{{/ dotdungeon.panel}}

View file

@ -0,0 +1,3 @@
{{#> dotdungeon.panel class="storage" title="dotdungeon.actor.pc.panel.storage"}}
Storage
{{/ dotdungeon.panel}}

View file

@ -0,0 +1,3 @@
{{#> dotdungeon.panel class="summons" title="dotdungeon.actor.pc.panel.summons"}}
Summons
{{/ dotdungeon.panel}}

View file

@ -0,0 +1,35 @@
{{#> dotdungeon.panel class="sync" title="dotdungeon.actor.pc.panel.health"}}
{{!--
NOTE: This would be neat to get working at some point, but isn't my highest
priority to do.
<div class="sync">
<h3 class="sync__header">
{{localize "dotdungeon.actor.pc.sync.header"}}
{{#if settings.devMode}}
<span class="debug-data">
({{system.syncDelta}})
</span>
{{/if}}
</h3>
<input
type="number"
class="sync__input sync"
value="{{computed.syncTotal}}"
>
</div>
--}}
<div class="respawns">
<h3 class="respawns__header">
{{localize "dotdungeon.actor.pc.respawns.header"}}
</h3>
{{#each system.respawns}}
<input
type="checkbox"
class="respawns__input"
name="system.respawns.{{@key}}"
{{checked this}}
>
{{/each}}
</div>
{{/ dotdungeon.panel}}

View file

@ -0,0 +1,112 @@
{{#> dotdungeon.panel class="weapons" title="dotdungeon.actor.pc.panel.weapons"}}
<details class="main-hand" {{dotdungeon-expanded meta.expanded "weapons.main-hand"}}>
<summary data-collapse-id="weapons.main-hand">
{{localize "dotdungeon.actor.pc.weapon.main-hand"}}
</summary>
<div class="weapon-container">
<label>
{{localize "dotdungeon.actor.pc.weapon.name"}}
<input
type="text"
name="system.weapon.mainHand.name"
>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.damage-type.label"}}
<select name="system.weapon.mainHand.damage">
{{#select system.weapon.mainHand.damage}}
<option value="">Select...</option>
{{#each (dotdungeon-array "slashing" "piercing" "smashing" "gun" "neon" "shadow" "solar")}}
<option value="{{this}}">
{{localize (concat "dotdungeon.actor.pc.weapon.damage-type." this)}}
</option>
{{/each}}
{{/select}}
</select>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.is-ranged"}}
<input
type="checkbox"
name="system.weapon.mainHand.ranged"
{{checked system.weapon.mainHand.ranged}}
>
</label>
{{#if system.weapon.mainHand.ranged}}
<label>
{{localize "dotdungeon.actor.pc.weapon.is-scoped"}}
<input
type="checkbox"
name="system.weapon.mainHand.scope"
{{checked system.weapon.mainHand.scope}}
>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.ammo-type.label"}}
<select name="system.weapon.mainHand.ammo">
{{#select system.weapon.mainHand.ammo}}
<option value="">{{localize "dotdungeon.actor.pc.weapon.ammo-type.ammoless"}}</option>
<option value="quivers">{{localize "dotdungeon.actor.pc.weapon.ammo-type.quiver"}}</option>
<option value="mags">{{localize "dotdungeon.actor.pc.weapon.ammo-type.mag"}}</option>
<option value="cells">{{localize "dotdungeon.actor.pc.weapon.ammo-type.cell"}}</option>
{{/select}}
</select>
</label>
</div>
{{/if}}
</details>
<details {{dotdungeon-expanded meta.expanded "weapons.off-hand"}}>
<summary data-collapse-id="weapons.off-hand">
{{localize "dotdungeon.actor.pc.weapon.off-hand"}}
</summary>
<label>
{{localize "dotdungeon.actor.pc.weapon.name"}}
<input
type="text"
name="system.weapon.offHand.name"
>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.damage-type.label"}}
<select name="system.weapon.offHand.damage">
{{#select system.weapon.offHand.damage}}
<option value="">Select...</option>
{{#each (dotdungeon-array "slashing" "piercing" "smashing" "gun" "neon" "shadow" "solar")}}
<option value="{{this}}">
{{localize (concat "dotdungeon.actor.pc.weapon.damage-type." this)}}
</option>
{{/each}}
{{/select}}
</select>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.is-ranged"}}
<input
type="checkbox"
name="system.weapon.offHand.ranged"
{{checked system.weapon.offHand.ranged}}
>
</label>
{{#if system.weapon.offHand.ranged}}
<label>
{{localize "dotdungeon.actor.pc.weapon.is-scoped"}}
<input
type="checkbox"
name="system.weapon.offHand.scope"
{{checked system.weapon.offHand.scope}}
>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.ammo-type.label"}}
<select name="system.weapon.offHand.ammo">
{{#select system.weapon.offHand.ammo}}
<option value="">{{localize "dotdungeon.actor.pc.weapon.ammo-type.ammoless"}}</option>
<option value="quivers">{{localize "dotdungeon.actor.pc.weapon.ammo-type.quiver"}}</option>
<option value="mags">{{localize "dotdungeon.actor.pc.weapon.ammo-type.mag"}}</option>
<option value="cells">{{localize "dotdungeon.actor.pc.weapon.ammo-type.cell"}}</option>
{{/select}}
</select>
</label>
{{/if}}
</details>
{{/ dotdungeon.panel}}

View file

@ -1,47 +1,5 @@
<form autocomplete="off" class="actor--pc"> <form autocomplete="off" class="actor--pc">
{{#> dotdungeon.panel class="profile" title="dotdungeon.actor.pc.panel.profile"}} {{> dotdungeon.pc.profile }}
{{#if settings.showAvatarOnSheet}}
<img
class="avatar"
src="{{actor.img}}"
data-edit="img"
title="{{actor.name}}"
/>
{{else}}
<label>
{{localize "dotdungeon.actor.pc.profile.avatar.label"}}
{{filePicker type="avatar" target="img"}}
</label>
{{/if}}
{{#if settings.devMode}}
<div class="debug-data">
Image URL: {{actor.img}}
</div>
{{/if}}
<label>
{{localize "dotdungeon.actor.pc.profile.name.label"}}
<input
type="text"
name="name"
value="{{actor.name}}"
placeholder="{{localize "dotdungeon.actor.pc.profile.name.placeholder"}}"
>
</label>
{{#if computed.canChangeGroup}}
<label>
{{localize "dotdungeon.actor.pc.profile.group.label"}}
{{#unless settings.playersCanChangeGroup}}
<span>{{localize "dotdungeon.actor.pc.profile.group.gm-edit"}}</span>
{{/unless}}
<input
type="text"
name="system.group"
value="{{system.group}}"
placeholder="{{localize "dotdungeon.actor.pc.profile.group.placeholder"}}"
>
</label>
{{/if}}
{{/ dotdungeon.panel}}
{{#> dotdungeon.panel class="stats" title="dotdungeon.actor.pc.panel.statistics"}} {{#> dotdungeon.panel class="stats" title="dotdungeon.actor.pc.panel.statistics"}}
@ -63,288 +21,23 @@
{{/ dotdungeon.panel}} {{/ dotdungeon.panel}}
{{#> dotdungeon.panel class="backpack" title="dotdungeon.actor.pc.panel.backpack"}} {{> dotdungeon.pc.backpack }}
<label class="row">
<span class="grow">
{{localize "dotdungeon.actor.pc.backpack.bytes.label"}}
</span>
<input
class="bytes-input"
type="number"
name="system.bytes"
value="{{system.bytes}}"
min="0"
aria-label="{{localize "dotdungeon.aria.actor.pc.input.bytes"}}"
aria-valuemin="0"
aria-valuenow="{{system.bytes}}"
>
</label>
<label class="row">
<span class="grow">
{{localize
(concat
"dotdungeon.settings.resourcesOrSupplies.option."
settings.resourcesOrSupplies
)
}}
{{#if settings.devMode}}
<span class="debug-data">
({{settings.resourcesOrSupplies}})
</span>
{{/if}}
</span>
<input
class="supplies-count"
type="number"
name="system.supplies"
value="{{system.supplies}}"
min="0"
max="5"
aria-label="{{localize "dotdungeon.aria.actor.pc.input.supplies"}}"
aria-valuemin="0"
aria-valuemax="5"
aria-valuenow="{{system.supplies}}"
>
</label>
<label class="row">
<span class="grow">
{{localize "dotdungeon.actor.pc.backpack.materials.label"}}
</span>
<input
class="materials-count"
type="number"
name="system.materials"
value="{{system.materials}}"
min="0"
max="5"
aria-label="{{localize "dotdungeon.aria.actor.pc.input.materials"}}"
aria-valuemin="0"
aria-valuemax="5"
aria-valuenow="{{system.supplies}}"
>
</label>
<label class="grow col">
Inventory
<textarea class="grow" name="system.inventoryString">{{system.inventoryString}}</textarea>
</label>
{{/ dotdungeon.panel}}
{{> dotdungeon.pc.sync }}
{{#> dotdungeon.panel class="sync" title="dotdungeon.actor.pc.panel.health"}} {{> dotdungeon.pc.aspect }}
{{!--
NOTE: This would be neat to get working at some point, but isn't my highest
priority to do.
<div class="sync"> {{> dotdungeon.pc.weapons }}
<h3 class="sync__header">
{{localize "dotdungeon.actor.pc.sync.header"}}
{{#if settings.devMode}}
<span class="debug-data">
({{system.syncDelta}})
</span>
{{/if}}
</h3>
<input
type="number"
class="sync__input sync"
value="{{computed.syncTotal}}"
>
</div>
--}}
<div class="respawns">
<h3 class="respawns__header">
{{localize "dotdungeon.actor.pc.respawns.header"}}
</h3>
{{#each system.respawns}}
<input
type="checkbox"
class="respawns__input"
name="system.respawns.{{@key}}"
{{checked this}}
>
{{/each}}
</div>
{{/ dotdungeon.panel}}
{{> dotdungeon.pc.spells }}
{{#> dotdungeon.panel class="aspect" title="dotdungeon.actor.pc.panel.aspect"}} {{> dotdungeon.pc.roles}}
<input
type="text"
class="aspect__name--input"
name="system.aspect.name"
value="{{system.aspect.name}}"
>
<label class="aspect__used--label">
Used
<input
type="checkbox"
class="aspect__used--input"
name="system.aspect.used"
{{checked system.aspect.used}}
>
</label>
<label class="aspect__duration--label">
Duration
{{#if system.aspect.deactivateAfter}}
<span class="friendly-duration aspect__duration--friendly">
({{dotdungeon-toFriendlyDuration system.aspect.deactivateAfter}})
</span>
{{/if}}
<input
type="number"
class="aspect__duration--input"
name="system.aspect.deactivateAfter"
value="{{system.aspect.deactivateAfter}}"
>
</label>
<textarea
class="aspect__description--input"
name="system.aspect.description"
>{{system.aspect.description}}</textarea>
{{/ dotdungeon.panel}}
{{> dotdungeon.pc.mounts}}
{{#> dotdungeon.panel class="weapons" title="dotdungeon.actor.pc.panel.weapons"}} {{> dotdungeon.pc.summons }}
<details class="main-hand" {{dotdungeon-expanded meta.expanded "weapons.main-hand"}}>
<summary data-collapse-id="weapons.main-hand">
{{localize "dotdungeon.actor.pc.weapon.main-hand"}}
</summary>
<div class="weapon-container">
<label>
{{localize "dotdungeon.actor.pc.weapon.name"}}
<input
type="text"
name="system.weapon.mainHand.name"
>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.damage-type.label"}}
<select name="system.weapon.mainHand.damage">
{{#select system.weapon.mainHand.damage}}
<option value="">Select...</option>
{{#each (dotdungeon-array "slashing" "piercing" "smashing" "gun" "neon" "shadow" "solar")}}
<option value="{{this}}">
{{localize (concat "dotdungeon.actor.pc.weapon.damage-type." this)}}
</option>
{{/each}}
{{/select}}
</select>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.is-ranged"}}
<input
type="checkbox"
name="system.weapon.mainHand.ranged"
{{checked system.weapon.mainHand.ranged}}
>
</label>
{{#if system.weapon.mainHand.ranged}}
<label>
{{localize "dotdungeon.actor.pc.weapon.is-scoped"}}
<input
type="checkbox"
name="system.weapon.mainHand.scope"
{{checked system.weapon.mainHand.scope}}
>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.ammo-type.label"}}
<select name="system.weapon.mainHand.ammo">
{{#select system.weapon.mainHand.ammo}}
<option value="">{{localize "dotdungeon.actor.pc.weapon.ammo-type.ammoless"}}</option>
<option value="quivers">{{localize "dotdungeon.actor.pc.weapon.ammo-type.quiver"}}</option>
<option value="mags">{{localize "dotdungeon.actor.pc.weapon.ammo-type.mag"}}</option>
<option value="cells">{{localize "dotdungeon.actor.pc.weapon.ammo-type.cell"}}</option>
{{/select}}
</select>
</label>
</div>
{{/if}}
</details>
<details {{dotdungeon-expanded meta.expanded "weapons.off-hand"}}>
<summary data-collapse-id="weapons.off-hand">
{{localize "dotdungeon.actor.pc.weapon.off-hand"}}
</summary>
<label>
{{localize "dotdungeon.actor.pc.weapon.name"}}
<input
type="text"
name="system.weapon.offHand.name"
>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.damage-type.label"}}
<select name="system.weapon.offHand.damage">
{{#select system.weapon.offHand.damage}}
<option value="">Select...</option>
{{#each (dotdungeon-array "slashing" "piercing" "smashing" "gun" "neon" "shadow" "solar")}}
<option value="{{this}}">
{{localize (concat "dotdungeon.actor.pc.weapon.damage-type." this)}}
</option>
{{/each}}
{{/select}}
</select>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.is-ranged"}}
<input
type="checkbox"
name="system.weapon.offHand.ranged"
{{checked system.weapon.offHand.ranged}}
>
</label>
{{#if system.weapon.offHand.ranged}}
<label>
{{localize "dotdungeon.actor.pc.weapon.is-scoped"}}
<input
type="checkbox"
name="system.weapon.offHand.scope"
{{checked system.weapon.offHand.scope}}
>
</label>
<label>
{{localize "dotdungeon.actor.pc.weapon.ammo-type.label"}}
<select name="system.weapon.offHand.ammo">
{{#select system.weapon.offHand.ammo}}
<option value="">{{localize "dotdungeon.actor.pc.weapon.ammo-type.ammoless"}}</option>
<option value="quivers">{{localize "dotdungeon.actor.pc.weapon.ammo-type.quiver"}}</option>
<option value="mags">{{localize "dotdungeon.actor.pc.weapon.ammo-type.mag"}}</option>
<option value="cells">{{localize "dotdungeon.actor.pc.weapon.ammo-type.cell"}}</option>
{{/select}}
</select>
</label>
{{/if}}
</details>
{{/ dotdungeon.panel}}
{{> dotdungeon.pc.storage}}
{{#> dotdungeon.panel class="spells" title="dotdungeon.actor.pc.panel.spells"}}
Spells
{{/ dotdungeon.panel}}
{{#> dotdungeon.panel class="roles" title="dotdungeon.actor.pc.panel.roles"}}
{{#each system.roles}}
<textarea
name="system.roles.{{@key}}"
>{{this}}</textarea>
{{/each}}
{{/ dotdungeon.panel}}
{{#> dotdungeon.panel class="mounts" title="dotdungeon.actor.pc.panel.mounts"}}
Mounts
{{/ dotdungeon.panel}}
{{#> dotdungeon.panel class="summons" title="dotdungeon.actor.pc.panel.summons"}}
Summons
{{/ dotdungeon.panel}}
{{#> dotdungeon.panel class="storage" title="dotdungeon.actor.pc.panel.storage"}}
Storage
{{/ dotdungeon.panel}}
{{#if settings.devMode}} {{#if settings.devMode}}
<div class="debug-data" style="grid-column: 1 / span 3"> <div class="debug-data" style="grid-column: 1 / span 3">