From c50e88e4836bbfe62576981205fc724c1067cc77 Mon Sep 17 00:00:00 2001 From: Eldritch-Oliver Date: Tue, 16 Sep 2025 00:45:08 -0600 Subject: [PATCH] Add an application for controlling the size settings. --- module/apps/ResizeControlManager.mjs | 67 +++++++++++++++++++++ styles/Apps/ResizeControlManager.css | 10 +++ styles/main.css | 1 + templates/ResizeControlManager/controls.hbs | 7 +++ templates/ResizeControlManager/settings.hbs | 29 +++++++++ 5 files changed, 114 insertions(+) create mode 100644 module/apps/ResizeControlManager.mjs create mode 100644 styles/Apps/ResizeControlManager.css create mode 100644 templates/ResizeControlManager/controls.hbs create mode 100644 templates/ResizeControlManager/settings.hbs diff --git a/module/apps/ResizeControlManager.mjs b/module/apps/ResizeControlManager.mjs new file mode 100644 index 0000000..3a42290 --- /dev/null +++ b/module/apps/ResizeControlManager.mjs @@ -0,0 +1,67 @@ +import { __ID__, filePath } from "../consts.mjs"; + +const { HandlebarsApplicationMixin, DocumentSheetV2 } = foundry.applications.api; +const { getProperty } = foundry.utils; + +export class ResizeControlManager extends HandlebarsApplicationMixin(DocumentSheetV2) { + + // #region Options + static DEFAULT_OPTIONS = { + classes: [ + __ID__, + `ResizeControlManager`, + ], + position: { + width: 400, + height: `auto`, + }, + window: { + resizable: true, + }, + form: { + submitOnChange: false, + closeOnSubmit: true, + }, + actions: {}, + }; + + static PARTS = { + settings: { template: filePath(`templates/ResizeControlManager/settings.hbs`) }, + controls: { template: filePath(`templates/ResizeControlManager/controls.hbs`) }, + }; + // #endregion Options + + // #region Instance Data + get title() { + return `Sizing Settings For : ${this.document.name}`; + }; + // #endregion Instance Data + + // #region Lifecycle + async _onRender(context, options) { + await super._onRender(context, options); + }; + // #endregion Lifecycle + + // #region Data Prep + async _prepareContext() { + const sizing = getProperty(this.document, `flags.${__ID__}.PlayerSheet.size`) ?? {}; + + const ctx = { + meta: { + idp: this.id, + }, + width: sizing.width, + height: sizing.height, + resizable: sizing.resizable, + resizeOptions: [ + { label: `Default`, value: `` }, + { label: `Resizable`, value: `true` }, + { label: `No Resizing`, value: `false` }, + ], + }; + + return ctx; + }; + // #endregion Data Prep +}; diff --git a/styles/Apps/ResizeControlManager.css b/styles/Apps/ResizeControlManager.css new file mode 100644 index 0000000..8ccd047 --- /dev/null +++ b/styles/Apps/ResizeControlManager.css @@ -0,0 +1,10 @@ +.taf.ResizeControlManager { + fieldset { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); + align-items: center; + gap: 8px; + border: 1px solid rebeccapurple; + border-radius: 4px; + } +} diff --git a/styles/main.css b/styles/main.css index 16de3e5..bc257ab 100644 --- a/styles/main.css +++ b/styles/main.css @@ -20,3 +20,4 @@ @import url("./Apps/Ask.css") layer(apps); @import url("./Apps/AttributeManager.css") layer(apps); @import url("./Apps/PlayerSheet.css") layer(apps); +@import url("./Apps/ResizeControlManager.css") layer(apps); diff --git a/templates/ResizeControlManager/controls.hbs b/templates/ResizeControlManager/controls.hbs new file mode 100644 index 0000000..6f62afb --- /dev/null +++ b/templates/ResizeControlManager/controls.hbs @@ -0,0 +1,7 @@ +
+ +
diff --git a/templates/ResizeControlManager/settings.hbs b/templates/ResizeControlManager/settings.hbs new file mode 100644 index 0000000..39a1f20 --- /dev/null +++ b/templates/ResizeControlManager/settings.hbs @@ -0,0 +1,29 @@ +
+

+ Changes to these settings will only take effect after a reload of Foundry. +

+
+ Sizing + + + + + + +
+