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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user