From 94c89f72e10d169cbbd244cd13c4c10b9040395f Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Wed, 8 Jan 2025 21:16:04 -0700 Subject: [PATCH] RC-80 | Setup Item Sheet --- langs/en-ca.json | 1 + module/Apps/ItemSheets/AllItemSheetV1.mjs | 50 +++++++++++++++++++++++ module/hooks/init.mjs | 15 +++++++ templates/Apps/AllItemSheetV1/content.hbs | 3 ++ templates/Apps/AllItemSheetV1/style.css | 3 ++ templates/Apps/apps.css | 1 + 6 files changed, 73 insertions(+) create mode 100644 module/Apps/ItemSheets/AllItemSheetV1.mjs create mode 100644 templates/Apps/AllItemSheetV1/content.hbs create mode 100644 templates/Apps/AllItemSheetV1/style.css diff --git a/langs/en-ca.json b/langs/en-ca.json index 6f9b392..5103805 100644 --- a/langs/en-ca.json +++ b/langs/en-ca.json @@ -9,6 +9,7 @@ }, "RipCrypt": { "sheet-names": { + "AllItemsSheetV1": "RipCrypt Item Sheet", "HeroSummaryCardV1": "Hero Stat Card", "HeroSkillsCardV1": "Hero Skill Card" }, diff --git a/module/Apps/ItemSheets/AllItemSheetV1.mjs b/module/Apps/ItemSheets/AllItemSheetV1.mjs new file mode 100644 index 0000000..e8c2e03 --- /dev/null +++ b/module/Apps/ItemSheets/AllItemSheetV1.mjs @@ -0,0 +1,50 @@ +import { filePath } from "../../consts.mjs"; +import { GenericAppMixin } from "../GenericApp.mjs"; +import { Logger } from "../../utils/Logger.mjs"; + +const { HandlebarsApplicationMixin } = foundry.applications.api; +const { ItemSheetV2 } = foundry.applications.sheets; + +export class AllItemSheetV1 extends GenericAppMixin(HandlebarsApplicationMixin(ItemSheetV2)) { + + // #region Options + static DEFAULT_OPTIONS = { + classes: [ + `ripcrypt--item`, + `ripcrypt--AllItemSheetV1`, + ], + position: { + width: `auto`, + height: `auto`, + }, + window: { + resizable: false, + }, + actions: { + }, + form: { + submitOnChange: true, + closeOnSubmit: false, + }, + }; + + static PARTS = { + content: { + template: filePath(`templates/Apps/AllItemSheetV1/content.hbs`), + }, + }; + // #endregion + + // #region Lifecycle + async _preparePartContext(partId, ctx, opts) { + ctx = await super._preparePartContext(partId, ctx, opts); + ctx.actor = this.document; + + Logger.debug(`Context:`, ctx); + return ctx; + }; + // #endregion + + // #region Actions + // #endregion +}; diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index c5ad784..e76673f 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -1,4 +1,5 @@ // Applications +import { AllItemSheetV1 } from "../Apps/ItemSheets/AllItemSheetV1.mjs"; import { HeroSkillsCardV1 } from "../Apps/ActorSheets/HeroSkillsCardV1.mjs"; import { HeroSummaryCardV1 } from "../Apps/ActorSheets/HeroSummaryCardV1.mjs"; @@ -34,6 +35,12 @@ Hooks.once(`init`, () => { // #endregion // #region Sheets + // Unregister core sheets + /* eslint-disable no-undef */ + Items.unregisterSheet(`core`, ItemSheet); + Actors.unregisterSheet(`core`, ActorSheet); + /* eslint-enabled no-undef */ + // #region Actors Actors.registerSheet(game.system.id, HeroSummaryCardV1, { makeDefault: true, @@ -47,6 +54,14 @@ Hooks.once(`init`, () => { themes: HeroSkillsCardV1.themes, }); // #endregion + + // #region Items + Items.registerSheet(game.system.id, AllItemSheetV1, { + makeDefault: true, + label: `RipCrypt.sheet-names.AllItemsSheetV1`, + themes: AllItemSheetV1.themes, + }); + // #endregion // #endregion // #region Token Attrs diff --git a/templates/Apps/AllItemSheetV1/content.hbs b/templates/Apps/AllItemSheetV1/content.hbs new file mode 100644 index 0000000..43a098c --- /dev/null +++ b/templates/Apps/AllItemSheetV1/content.hbs @@ -0,0 +1,3 @@ +
+ All Item Sheet V1 +
diff --git a/templates/Apps/AllItemSheetV1/style.css b/templates/Apps/AllItemSheetV1/style.css new file mode 100644 index 0000000..8c2b98e --- /dev/null +++ b/templates/Apps/AllItemSheetV1/style.css @@ -0,0 +1,3 @@ +.ripcrypt .AllItemSheetV1 { + --input-height: 1rem; +} diff --git a/templates/Apps/apps.css b/templates/Apps/apps.css index 5fee16a..07bfaf1 100644 --- a/templates/Apps/apps.css +++ b/templates/Apps/apps.css @@ -1,2 +1,3 @@ +@import url("./AllItemSheetV1/style.css"); @import url("./HeroSummaryCardV1/style.css"); @import url("./HeroSkillsCardV1/style.css");