Fix apv2, WIP

This commit is contained in:
2026-06-06 22:37:29 +02:00
parent c571e6a209
commit c23de0ea66
37 changed files with 199 additions and 118 deletions
@@ -96,6 +96,10 @@ export default class VermineBaseActorSheet extends HandlebarsApplicationMixin(fo
// ── Contexte commun ─────────────────────────────────────────────────
async _prepareContext() {
const enrich = async (path) => {
const val = foundry.utils.getProperty(this.document.system, path);
return val ? await foundry.applications.ux.TextEditor.implementation.enrichHTML(val, { async: true }) : "";
};
return {
fields: this.document.schema.fields,
systemFields: this.document.system.schema.fields,
@@ -107,7 +111,10 @@ export default class VermineBaseActorSheet extends HandlebarsApplicationMixin(fo
isGM: game.user.isGM,
isEditMode: this.isEditMode,
isPlayMode: this.isPlayMode,
isEditable: this.isEditable
isEditable: this.isEditable,
enrichedNotes: await enrich("identity.notes"),
enrichedBiography: await enrich("identity.biography"),
enrichedRelations: await enrich("identity.relations")
}
}
@@ -138,6 +145,19 @@ export default class VermineBaseActorSheet extends HandlebarsApplicationMixin(fo
for (const [group, tab] of Object.entries(this.tabGroups ?? {})) {
this.changeTab(tab, group, {force: true})
}
// Move toggle from hidden main tab to visible position (only for sheets where
// .tab.main is not already displayed as a permanent sidebar via !important)
const mainTab = this.element.querySelector(".tab.main")
const tabs = this.element.querySelector('nav.tabs[data-application-part="tabs"]')
if ( mainTab && tabs && getComputedStyle(mainTab).display === "none" ) {
const existing = tabs.parentNode.querySelector('.sheet-header-toggle[data-moved]')
if (existing) existing.remove()
const toggle = mainTab.querySelector(".sheet-header-toggle")
if (toggle) {
toggle.dataset.moved = "true"
tabs.parentNode.insertBefore(toggle, tabs)
}
}
this.#dragDrop.forEach(d => d.bind(this.element))
this.element.querySelectorAll(".rollable").forEach(el => {
el.addEventListener("click", this._onRoll.bind(this))
@@ -50,7 +50,12 @@ export default class VermineCreatureSheetV2 extends VermineBaseActorSheet {
async _preparePartContext(partId, context) {
const doc = this.document
switch (partId) {
case "main": break
case "main":
context.patternOptions = CONFIG.VERMINE.creaturePatternLevels
context.roleOptions = CONFIG.VERMINE.creatureRoleLevels
context.sizeOptions = CONFIG.VERMINE.creatureSizeLevels
context.packOptions = CONFIG.VERMINE.creaturePackLevels
break
case "info":
context.tab = context.tabs.info
break
+7 -1
View File
@@ -44,7 +44,13 @@ export default class VermineNpcSheetV2 extends VermineBaseActorSheet {
async _preparePartContext(partId, context) {
const doc = this.document
switch (partId) {
case "main": break
case "main":
context.npcThreatOptions = CONFIG.VERMINE.npcThreatLevels
context.npcExperienceOptions = CONFIG.VERMINE.npcExperienceLevels
context.npcRoleOptions = CONFIG.VERMINE.npcRoleLevels
context.totemOptions = CONFIG.VERMINE.totems
context.originOptions = CONFIG.VERMINE.origins
break
case "characteristics":
context.tab = context.tabs.characteristics
break
+1 -1
View File
@@ -80,7 +80,7 @@ export default class VermineItem extends Item {
rollMode: rollMode,
flavor: label,
};
mess.content = await foundry.applications.handlebars.renderTemplate(`systems/vermine2047/templates/item/chatCards/${this.type}.hbs`, { item: this, message: mess }) ?? null;
mess.content = await foundry.applications.handlebars.renderTemplate(`systems/vermine2047/templates/item/chatCards/${this.type}.hbs`, { item: this, message: mess, config: CONFIG.VERMINE }) ?? null;
ChatMessage.create(mess)
}
+2 -2
View File
@@ -61,8 +61,8 @@ export default class VermineCharacterData extends foundry.abstract.TypeDataModel
instincts: new fields.StringField({ required: true, nullable: false, initial: "" }),
prohibits: new fields.StringField({ required: true, nullable: false, initial: "" }),
objectives: new fields.StringField({ required: true, nullable: false, initial: "" }),
relations: new fields.StringField({ required: true, nullable: false, initial: "" }),
biography: new fields.StringField({ required: true, nullable: false, initial: "" })
relations: new fields.HTMLField({ required: true, initial: "" }),
biography: new fields.HTMLField({ required: true, initial: "" })
}),
// Équipement
+2 -2
View File
@@ -32,8 +32,8 @@ export default class VermineCreatureData extends foundry.abstract.TypeDataModel
profile: new fields.StringField({ required: true, nullable: false, initial: "" }),
origin: new fields.StringField({ required: true, nullable: false, initial: "" }),
theme: new fields.StringField({ required: true, nullable: false, initial: "" }),
notes: new fields.StringField({ required: true, nullable: false, initial: "" }),
biography: new fields.StringField({ required: true, nullable: false, initial: "" })
notes: new fields.HTMLField({ required: true, initial: "" }),
biography: new fields.HTMLField({ required: true, initial: "" })
}),
// Compétences (description libre)
+1 -1
View File
@@ -36,7 +36,7 @@ export default class VermineGroupData extends foundry.abstract.TypeDataModel {
theme: new fields.StringField({ required: true, nullable: false, initial: "" }),
instincts: new fields.StringField({ required: true, nullable: false, initial: "" }),
prohibits: new fields.StringField({ required: true, nullable: false, initial: "" }),
notes: new fields.StringField({ required: true, nullable: false, initial: "" })
notes: new fields.HTMLField({ required: true, initial: "" })
}),
// Équipement
+1 -1
View File
@@ -55,7 +55,7 @@ export default class VermineNpcData extends foundry.abstract.TypeDataModel {
origin: new fields.StringField({ required: true, nullable: false, initial: "" }),
totem: new fields.StringField({ required: true, nullable: false, initial: "" }),
theme: new fields.StringField({ required: true, nullable: false, initial: "" }),
notes: new fields.StringField({ required: true, nullable: false, initial: "" })
notes: new fields.HTMLField({ required: true, initial: "" })
}),
// Attributs (XP, réputation, sang-froid, effort)
+6 -17
View File
@@ -90,22 +90,9 @@ export const registerHandlebarsHelpers = function () {
return str.toLowerCase();
});
Handlebars.registerHelper('romanNumber', function (numb) {
switch (numb) {
case 0:
return '';
case 1:
return 'I';
case 2:
return 'II';
case 3:
return 'III';
case 4:
return 'IV';
case 5:
return 'V';
default:
throw new Error('Le handicap rareté doit être comprise entre 0 et 5');
}
const n = Number(numb);
if ( !Number.isFinite(n) || n < 0 ) return '';
return ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X'][n] ?? '';
});
// search translation with variables
@@ -386,7 +373,9 @@ export const registerHandlebarsHelpers = function () {
Handlebars.registerHelper('repeat', function (times, start, indexLabel, block) {
var accum = '';
if (!indexLabel) { indexLabel = "index" }
if (!start) { start = 0; }
times = Number(times);
start = Number(start ?? 0);
if ( !Number.isFinite(times) || !Number.isFinite(start) || times < 0 ) return '';
for (var i = start; i < times + start; ++i) {
block.data[indexLabel] = i;
block.data.first = i === start;