diff --git a/module/Apps/ItemSheets/TraitSheet.mjs b/module/Apps/ItemSheets/TraitSheet.mjs new file mode 100644 index 0000000..1d8c78d --- /dev/null +++ b/module/Apps/ItemSheets/TraitSheet.mjs @@ -0,0 +1,53 @@ +import { filePath } from "../../consts.mjs"; +import { GenericAppMixin } from "../GenericApp.mjs"; + +const { HandlebarsApplicationMixin } = foundry.applications.api; +const { ItemSheetV2 } = foundry.applications.sheets; + +export class TraitSheet extends GenericAppMixin(HandlebarsApplicationMixin(ItemSheetV2)) { + // #region Options + static DEFAULT_OPTIONS = { + classes: [ + `ripcrypt--item`, + `TraitSheet`, + ], + position: { + width: `auto`, + height: `auto`, + }, + window: { + resizable: true, + }, + form: { + submitOnChange: true, + closeOnSubmit: false, + }, + }; + + static PARTS = { + content: { + template: filePath(`templates/Apps/TraitSheet/content.hbs`), + root: true, + }, + }; + // #endregion Options + + // #region Data Prep + async _prepareContext() { + const TextEditor = foundry.applications.ux.TextEditor.implementation; + const ctx = { + meta: { + idp: this.id, + }, + item: this.document, + enriched: { + system: { + description: await TextEditor.enrichHTML(this.document.system.description), + }, + }, + }; + + return ctx; + }; + // #endregion Data Prep +}; diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index e9384d5..f74514d 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -38,6 +38,7 @@ import { registerMetaSettings } from "../settings/metaSettings.mjs"; import { registerSockets } from "../sockets/_index.mjs"; import { registerUserSettings } from "../settings/userSettings.mjs"; import { registerWorldSettings } from "../settings/worldSettings.mjs"; +import { TraitSheet } from "../Apps/ItemSheets/TraitSheet.mjs"; const { Items, Actors } = foundry.documents.collections; @@ -120,8 +121,15 @@ Hooks.once(`init`, () => { label: `RipCrypt.sheet-names.ArmourSheet`, themes: ArmourSheet.themes, }); + Items.registerSheet(game.system.id, TraitSheet, { + makeDefault: true, + types: [`trait`], + label: `RipCrypt.sheet-names.TraitSheet`, + themes: TraitSheet.themes, + }); + Items.unregisterSheet(game.system.id, AllItemSheetV1, { - types: [`armour`, `shield`], + types: [`armour`, `shield`, `trait`], }); // #endregion // #endregion diff --git a/templates/Apps/TraitSheet/content.hbs b/templates/Apps/TraitSheet/content.hbs new file mode 100644 index 0000000..5e60416 --- /dev/null +++ b/templates/Apps/TraitSheet/content.hbs @@ -0,0 +1,21 @@ +
+ + +
{{{ enriched.system.description }}}
+
diff --git a/templates/Apps/TraitSheet/style.css b/templates/Apps/TraitSheet/style.css new file mode 100644 index 0000000..adbf30c --- /dev/null +++ b/templates/Apps/TraitSheet/style.css @@ -0,0 +1,35 @@ +.ripcrypt.TraitSheet { + --input-underline: none; + max-width: 300px; + + > .window-content { + display: flex; + flex-direction: column; + gap: 8px; + padding: 4px; + color: var(--base-text); + background: var(--base-background); + } + + input { + border-radius: 4px; + padding: 2px 4px; + } + + .value { + background: var(--input-background); + color: var(--input-text); + padding: 4px; + + > :first-child { + margin-top: 0; + } + > :last-child { + margin-bottom: 0; + } + + &:empty { + display: none; + } + } +} diff --git a/templates/Apps/apps.css b/templates/Apps/apps.css index db88f7e..e170ca0 100644 --- a/templates/Apps/apps.css +++ b/templates/Apps/apps.css @@ -7,6 +7,7 @@ @import url("./SkillsCardV1/style.css"); @import url("./RichEditor/style.css"); @import url("./ArmourSheet/style.css"); +@import url("./TraitSheet/style.css"); @import url("./popover.css"); @import url("./popovers/AmmoTracker/style.css"); diff --git a/templates/Apps/partials/item-header.hbs b/templates/Apps/partials/item-header.hbs index 300c166..358779d 100644 --- a/templates/Apps/partials/item-header.hbs +++ b/templates/Apps/partials/item-header.hbs @@ -2,7 +2,6 @@ Required parameters: "name" : the name of the item "system.quantity" : the quantity of the item - "meta.idp" : the ID Prefix for the application --}}