Actor sheet -> working !!!
This commit is contained in:
+14
-7
@@ -24,15 +24,24 @@
|
||||
|
||||
.resource-label {
|
||||
font-size: 0.75rem;
|
||||
color: @color-text-light-2;
|
||||
color: @color-text-light-highlight;
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
text-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
|
||||
}
|
||||
|
||||
.resource {
|
||||
border: none;
|
||||
border-left: 1px solid gray;
|
||||
padding: 0.2rem 1rem;
|
||||
border: 1px solid @color-border-dark-3;
|
||||
border-left: 3px solid @theme-color-primary;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
padding: 0.5rem 1rem;
|
||||
text-align: center;
|
||||
.transition();
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
border-color: @theme-color-primary;
|
||||
}
|
||||
|
||||
.flexrow {
|
||||
min-width: 5rem;
|
||||
@@ -56,13 +65,11 @@
|
||||
}
|
||||
|
||||
select {
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
.custom-select-style();
|
||||
color: @color-text-light-1;
|
||||
font-family: "DistressBlack", sans-serif;
|
||||
font-size: 0.875rem;
|
||||
text-align: center;
|
||||
border: none;
|
||||
box-shadow: 0px 0px 3px rgba(31, 26, 26, 0.979) inset;
|
||||
text-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,35 @@ export class VermineBaseActorSheet extends HandlebarsApplicationMixin(foundry.ap
|
||||
_canDragStart() { return this.isEditable }
|
||||
_canDragDrop() { return this.isEditable }
|
||||
|
||||
// ── Soumission du formulaire ────────────────────────────────────────
|
||||
|
||||
/** @override - coerce string values from HTML form inputs to numbers */
|
||||
_prepareSubmitData(submitData, form, formData) {
|
||||
const fd = foundry.utils.deepClone(formData.object)
|
||||
|
||||
for (const [key, value] of Object.entries(fd)) {
|
||||
if (!key.startsWith("system.") || typeof value === "number") continue
|
||||
|
||||
const segments = key.slice(7).split(".")
|
||||
let node = this.document.system.schema
|
||||
for (const seg of segments) {
|
||||
if (node instanceof foundry.data.fields.SchemaField) node = node.fields[seg]
|
||||
else { node = undefined; break }
|
||||
}
|
||||
if (!(node instanceof foundry.data.fields.NumberField)) continue
|
||||
|
||||
// Handle arrays from duplicate-named form inputs
|
||||
let raw = Array.isArray(value) ? value.filter(v => v !== "" && v !== null).pop() : value
|
||||
if (raw === undefined) continue
|
||||
if (typeof raw === "string" && raw.trim() === "") { fd[key] = 0; continue }
|
||||
|
||||
const num = Number(typeof raw === "string" ? raw.trim() : raw)
|
||||
if (!isNaN(num)) fd[key] = num
|
||||
}
|
||||
|
||||
return fd
|
||||
}
|
||||
|
||||
// ── Contexte commun ─────────────────────────────────────────────────
|
||||
|
||||
async _prepareContext() {
|
||||
|
||||
@@ -12,6 +12,7 @@ export class VermineCharacterSheetV2 extends VermineBaseActorSheet {
|
||||
}
|
||||
|
||||
static PARTS = {
|
||||
header: { template: "systems/vermine2047/templates/actor/appv2/character-header.hbs" },
|
||||
main: { template: "systems/vermine2047/templates/actor/appv2/character-main.hbs" },
|
||||
tabs: { template: "templates/generic/tab-navigation.hbs" },
|
||||
abilities: { template: "systems/vermine2047/templates/actor/appv2/character-abilities.hbs" },
|
||||
|
||||
@@ -39,6 +39,14 @@ export class VermineCreatureSheetV2 extends VermineBaseActorSheet {
|
||||
return context
|
||||
}
|
||||
|
||||
changeTab(tab, group, options = {}) {
|
||||
super.changeTab(tab, group, options)
|
||||
if (group === "sheet") {
|
||||
const main = this.element?.querySelector('[data-group="sheet"][data-tab="main"]')
|
||||
if (main) main.classList.add("active")
|
||||
}
|
||||
}
|
||||
|
||||
async _preparePartContext(partId, context) {
|
||||
const doc = this.document
|
||||
switch (partId) {
|
||||
|
||||
@@ -7,7 +7,6 @@ export class VermineGroupSheetV2 extends VermineBaseActorSheet {
|
||||
position: { width: 700, height: 600 },
|
||||
window: { contentClasses: ["group-content"] },
|
||||
actions: {
|
||||
chooseTotem: VermineGroupSheetV2.#onChooseTotem,
|
||||
chooseActor: VermineGroupSheetV2.#onChooseActor,
|
||||
deleteMember: VermineGroupSheetV2.#onDeleteMember,
|
||||
deleteEncounter: VermineGroupSheetV2.#onDeleteEncounter,
|
||||
@@ -62,6 +61,14 @@ export class VermineGroupSheetV2 extends VermineBaseActorSheet {
|
||||
return context
|
||||
}
|
||||
|
||||
changeTab(tab, group, options = {}) {
|
||||
super.changeTab(tab, group, options)
|
||||
if (group === "sheet") {
|
||||
const main = this.element?.querySelector('[data-group="sheet"][data-tab="main"]')
|
||||
if (main) main.classList.add("active")
|
||||
}
|
||||
}
|
||||
|
||||
async _preparePartContext(partId, context) {
|
||||
const doc = this.document
|
||||
switch (partId) {
|
||||
|
||||
@@ -15,6 +15,7 @@ export default class VermineActor extends Actor {
|
||||
* is queried and has a roll executed directly from it).
|
||||
*/
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
const actorData = this;
|
||||
const systemData = actorData.system;
|
||||
const flags = actorData.flags.vermine2047 || {};
|
||||
|
||||
@@ -3,6 +3,18 @@
|
||||
* Fonctions factory retournant des objets SchemaField réutilisables.
|
||||
*/
|
||||
|
||||
const fields = foundry.data.fields
|
||||
|
||||
/** NumberField qui accepte les strings vides en les remplaçant par `initial`. */
|
||||
class LooseNumberField extends fields.NumberField {
|
||||
clean(value, options) {
|
||||
if (value === "" || value === null || value === undefined) {
|
||||
return this.initial ?? 0
|
||||
}
|
||||
return super.clean(value, options)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne un schema pour une blessure (minor/major/deadly)
|
||||
* @param {number} defaultThreshold
|
||||
@@ -63,7 +75,7 @@ export function attributeSchema(defaultVal = 0, defaultMin = 0, defaultMax = 10)
|
||||
const fields = foundry.data.fields
|
||||
const reqInt = { required: true, nullable: false, integer: true }
|
||||
return new fields.SchemaField({
|
||||
value: new fields.NumberField({ ...reqInt, initial: defaultVal, min: defaultMin }),
|
||||
value: new LooseNumberField({ ...reqInt, initial: defaultVal, min: defaultMin }),
|
||||
min: new fields.NumberField({ ...reqInt, initial: defaultMin, min: 0 }),
|
||||
max: new fields.NumberField({ ...reqInt, initial: defaultMax, min: 0 })
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<div class="tab abilities sheet-part" data-group="sheet" data-tab="abilities">
|
||||
{{> "systems/vermine2047/templates/actor/appv2/character-header.hbs"}}
|
||||
{{!-- Character --}}
|
||||
<h3>{{ localize 'VERMINE.abilities' }}</h3>
|
||||
<div class="grid grid-4col">
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<div class="tab combat sheet-part" data-group="sheet" data-tab="combat">
|
||||
{{> "systems/vermine2047/templates/actor/appv2/character-header.hbs"}}
|
||||
<div class="align-center">
|
||||
<div class="shadow">
|
||||
<h4>situation de combat par défaut</h4>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<div class="tab equipment sheet-part" data-group="sheet" data-tab="equipment">
|
||||
{{> "systems/vermine2047/templates/actor/appv2/character-header.hbs"}}
|
||||
<div class="grid grid-2col">
|
||||
<div>
|
||||
<ol class="items-list">
|
||||
|
||||
@@ -44,16 +44,16 @@
|
||||
<div class="reputation flexrow flex-group-center">
|
||||
<label>{{ localize 'VERMINE.reputation' }}</label>
|
||||
{{#if isEditMode}}
|
||||
<input name="system.attributes.reputation.value" type="number" min="0"
|
||||
value="{{#if (or (not system.attributes.reputation.value) (eq system.attributes.reputation.value 0))}}0{{else}}{{system.attributes.reputation.value}}{{/if}}" />
|
||||
<input name="system.attributes.reputation.value" data-type="Number" type="number"
|
||||
value="{{system.attributes.reputation.value}}" />
|
||||
{{else}}
|
||||
<span>{{system.attributes.reputation.value}}</span>
|
||||
{{/if}}
|
||||
|
||||
<label>{{ localize 'VERMINE.experience' }}</label>
|
||||
{{#if isEditMode}}
|
||||
<input name="system.attributes.xp.value" type="number" min="0"
|
||||
value="{{#if (or (not system.attributes.xp.value) (eq system.attributes.xp.value 0))}}0{{else}}{{system.attributes.xp.value}}{{/if}}" />
|
||||
<input name="system.attributes.xp.value" data-type="Number" type="number"
|
||||
value="{{system.attributes.xp.value}}" />
|
||||
{{else}}
|
||||
<span>{{system.attributes.xp.value}}</span>
|
||||
{{/if}}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<div class="tab stories sheet-part" data-group="sheet" data-tab="stories">
|
||||
{{> "systems/vermine2047/templates/actor/appv2/character-header.hbs"}}
|
||||
<section class="flexrow flex-group-left flex-align-left gap-md">
|
||||
<div>
|
||||
<h4>{{ localize 'IDENTITY.theme'}}</h4>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<div class="tab totem sheet-part" data-group="sheet" data-tab="totem">
|
||||
{{> "systems/vermine2047/templates/actor/appv2/character-header.hbs"}}
|
||||
{{#if system.identity.totem}}
|
||||
<div class="totem-details">
|
||||
<img
|
||||
|
||||
Reference in New Issue
Block a user