Migrate to FoundryVTT v13 AppV2 +

│ DataModels
│
│ - Reorganize DataModels into src/module/models/ (one .mjs per type)
│ - Create AppV2 actor/item sheets (HandlebarsApplicationMixin)…
This commit is contained in:
2026-04-19 10:54:43 +02:00
parent e3002dd602
commit 86b2cd5777
30 changed files with 445 additions and 1679 deletions

View File

@@ -38,7 +38,7 @@ export default class MGT2ActorSheet extends HandlebarsApplicationMixin(foundry.a
return this._sheetMode === this.constructor.SHEET_MODES.EDIT;
}
tabGroups = { primary: "stats" }
tabGroups = { sidebar: "health" }
/** @override */
async _prepareContext() {
@@ -66,6 +66,9 @@ export default class MGT2ActorSheet extends HandlebarsApplicationMixin(foundry.a
/** @override */
_onRender(context, options) {
super._onRender(context, options);
// Inject theme class dynamically (can't use game.settings in static DEFAULT_OPTIONS)
const theme = game.settings.get("mgt2", "theme");
if (theme) this.element.classList.add(theme);
this._activateTabGroups();
}

View File

@@ -45,7 +45,7 @@ export default class TravellerCharacterSheet extends MGT2ActorSheet {
/** @override */
tabGroups = {
primary: "inventory",
sidebar: "inventory",
characteristics: "core",
inventory: "onhand",
}
@@ -721,7 +721,7 @@ export default class TravellerCharacterSheet extends MGT2ActorSheet {
return;
}
let roll = await new Roll(rollFormula, this.actor.getRollData()).roll({ async: true, rollMode: userRollData.rollMode });
let roll = await new Roll(rollFormula, this.actor.getRollData()).roll({ rollMode: userRollData.rollMode });
if (isInitiative && this.token?.combatant) {
await this.token.combatant.update({ initiative: roll.total });
@@ -733,7 +733,6 @@ export default class TravellerCharacterSheet extends MGT2ActorSheet {
formula: roll._formula,
tooltip: await roll.getTooltip(),
total: Math.round(roll.total * 100) / 100,
type: CONST.CHAT_MESSAGE_TYPES.ROLL,
showButtons: true,
showLifeButtons: false,
showRollRequest: false,
@@ -753,7 +752,7 @@ export default class TravellerCharacterSheet extends MGT2ActorSheet {
chatData.rollFailure = true;
}
const html = await renderTemplate("systems/mgt2/templates/chat/roll.html", chatData);
const html = await foundry.applications.handlebars.renderTemplate("systems/mgt2/templates/chat/roll.html", chatData);
chatData.content = html;
let flags = null;

View File

@@ -22,12 +22,14 @@ export default class TravellerItemSheet extends HandlebarsApplicationMixin(found
},
}
/** @override */
static PARTS = {
sheet: {
// template is dynamic — resolved in _prepareContext / _renderHTML
template: "",
},
/** Dynamic PARTS: template resolved per item type */
get PARTS() {
const type = this.document?.type ?? "item";
return {
sheet: {
template: `systems/mgt2/templates/items/${type}-sheet.html`,
},
};
}
/** Resolve template dynamically based on item type */
@@ -81,7 +83,7 @@ export default class TravellerItemSheet extends HandlebarsApplicationMixin(found
systemFields: item.system.schema.fields,
isEditable: this.isEditable,
isGM: game.user.isGM,
config: CONFIG,
config: CONFIG.MGT2,
settings: settings,
containers: containers,
computers: computers,
@@ -95,13 +97,16 @@ export default class TravellerItemSheet extends HandlebarsApplicationMixin(found
/** @override — resolve the per-type template before rendering */
async _renderHTML(context, options) {
const templatePath = `systems/mgt2/templates/items/${this.document.type}-sheet.html`;
const html = await renderTemplate(templatePath, context);
const html = await foundry.applications.handlebars.renderTemplate(templatePath, context);
return { sheet: html };
}
/** @override — put rendered HTML into the window content */
_replaceHTML(result, content, options) {
content.innerHTML = result.sheet;
// Inject theme class dynamically (can't use game.settings in static DEFAULT_OPTIONS)
const theme = game.settings.get("mgt2", "theme");
if (theme) this.element.classList.add(theme);
this._activateTabGroups();
this._bindItemEvents();
}