From 2518c7cf053d7d92d357b035c1e5e934c76e2943 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 13 Mar 2026 01:05:52 -0600 Subject: [PATCH] Begin work on the most basic item sheet version --- module/apps/GenericItemSheet.mjs | 47 ++++++++++++++++++++++++++ module/hooks/init.mjs | 16 +++++++++ styles/Apps/GenericItemSheet.css | 18 ++++++++++ styles/main.css | 1 + templates/GenericItemSheet/content.hbs | 13 +++++++ templates/GenericItemSheet/header.hbs | 25 ++++++++++++++ 6 files changed, 120 insertions(+) create mode 100644 module/apps/GenericItemSheet.mjs create mode 100644 styles/Apps/GenericItemSheet.css create mode 100644 templates/GenericItemSheet/content.hbs create mode 100644 templates/GenericItemSheet/header.hbs diff --git a/module/apps/GenericItemSheet.mjs b/module/apps/GenericItemSheet.mjs new file mode 100644 index 0000000..a5f9ac8 --- /dev/null +++ b/module/apps/GenericItemSheet.mjs @@ -0,0 +1,47 @@ +import { __ID__, filePath } from "../consts.mjs"; + +const { HandlebarsApplicationMixin } = foundry.applications.api; +const { ItemSheetV2 } = foundry.applications.sheets; + +export class GenericItemSheet extends HandlebarsApplicationMixin(ItemSheetV2) { + // #region Options + static DEFAULT_OPTIONS = { + classes: [ + __ID__, + `GenericItemSheet`, + ], + position: { + width: 400, + height: 450, + }, + window: { + resizable: true, + }, + form: { + submitOnChange: true, + closeOnSubmit: false, + }, + actions: {}, + }; + + static PARTS = { + header: { template: filePath(`templates/GenericItemSheet/header.hbs`) }, + content: { template: filePath(`templates/GenericItemSheet/content.hbs`) }, + }; + // #endregion Options + + // #region Instance Data + // #endregion Instance Data + + // #region Lifecycle + async _prepareContext(partID) { + return { + item: this.item, + system: this.item.system, + }; + }; + // #endregion Lifecycle + + // #region Actions + // #endregion Actions +}; diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index 283405a..bcf540e 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -2,6 +2,7 @@ import { AttributeOnlyPlayerSheet } from "../apps/AttributeOnlyPlayerSheet.mjs"; import { PlayerSheet } from "../apps/PlayerSheet.mjs"; import { SingleModePlayerSheet } from "../apps/SingleModePlayerSheet.mjs"; +import { GenericItemSheet } from "../apps/GenericItemSheet.mjs"; // Data Models import { PlayerData } from "../data/Player.mjs"; @@ -25,13 +26,18 @@ import { registerSockets } from "../sockets/_index.mjs"; Hooks.on(`init`, () => { Logger.debug(`Initializing`); + // #region Documents CONFIG.Token.documentClass = TAFTokenDocument; CONFIG.Actor.documentClass = TAFActor; CONFIG.Combatant.documentClass = TAFCombatant; + // #endregion Documents + // #region Data Models CONFIG.Actor.dataModels.player = PlayerData; CONFIG.Item.dataModels.generic = GenericItemData; + // #endregion Data Models + // #region Sheets foundry.documents.collections.Actors.registerSheet( __ID__, PlayerSheet, @@ -51,6 +57,16 @@ Hooks.on(`init`, () => { { label: `taf.sheet-names.AttributeOnlyPlayerSheet` }, ); + foundry.documents.collections.Items.registerSheet( + __ID__, + GenericItemSheet, + { + makeDefault: true, + label: `taf.sheet-names.GenericItemSheet`, + }, + ); + // #endregion Sheets + registerWorldSettings(); registerSockets(); diff --git a/styles/Apps/GenericItemSheet.css b/styles/Apps/GenericItemSheet.css new file mode 100644 index 0000000..4d11f47 --- /dev/null +++ b/styles/Apps/GenericItemSheet.css @@ -0,0 +1,18 @@ +.taf.GenericItemSheet { + .bordered { + border-radius: 8px; + border: 1px solid rebeccapurple; + } + + .sheet-header { + display: grid; + grid-template-columns: auto 1fr min-content 75px; + gap: 4px; + align-items: center; + padding: 4px; + + img { + border-radius: 4px; + } + } +} diff --git a/styles/main.css b/styles/main.css index a4c4a2c..c75456b 100644 --- a/styles/main.css +++ b/styles/main.css @@ -24,6 +24,7 @@ @import url("./Apps/common.css") layer(apps); @import url("./Apps/Ask.css") layer(apps); @import url("./Apps/AttributeManager.css") layer(apps); +@import url("./Apps/GenericItemSheet.css") layer(apps); @import url("./Apps/PlayerSheet.css") layer(apps); @import url("./Apps/QueryStatus.css") layer(apps); @import url("./Apps/TAFDocumentSheetConfig.css") layer(apps); diff --git a/templates/GenericItemSheet/content.hbs b/templates/GenericItemSheet/content.hbs new file mode 100644 index 0000000..0018b47 --- /dev/null +++ b/templates/GenericItemSheet/content.hbs @@ -0,0 +1,13 @@ +
+ + + +
diff --git a/templates/GenericItemSheet/header.hbs b/templates/GenericItemSheet/header.hbs new file mode 100644 index 0000000..1e863fa --- /dev/null +++ b/templates/GenericItemSheet/header.hbs @@ -0,0 +1,25 @@ +
+ + + + +