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

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