From 171a133563f6356037c7cd167410973a341f89f7 Mon Sep 17 00:00:00 2001 From: Eldritch-Oliver Date: Mon, 15 Sep 2025 21:57:09 -0600 Subject: [PATCH 1/7] Update manifest data --- system.json | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/system.json b/system.json index e3bb983..1b806a5 100644 --- a/system.json +++ b/system.json @@ -4,18 +4,15 @@ "description": "An intentionally minimalist system that enables you to play rules-light games without getting in your way!", "version": "2.2.1", "download": "#{DOWNLOAD}#", - "manifest": "https://github.com/Oliver-Akins/Text-Actors-Foundry/releases/latest/download/system.json", - "url": "https://github.com/Oliver-Akins/Text-Actors-Foundry", + "manifest": "https://github.com/Eldritch-Oliver/Text-Actors-Foundry/releases/latest/download/system.json", + "url": "https://github.com/Eldritch-Oliver/Text-Actors-Foundry", "compatibility": { "minimum": 13, "verified": 13, "maximum": 13 }, "authors": [ - { - "name": "Oliver Akins", - "url": "https://oliver.akins.me" - } + { "name": "Oliver" } ], "esmodules": [ "./module/main.mjs" From a98af33477977906f09c5141e47712c31dac3da9 Mon Sep 17 00:00:00 2001 From: Eldritch-Oliver Date: Tue, 16 Sep 2025 00:35:05 -0600 Subject: [PATCH 2/7] Tweak indentation to be more consistent with other applications --- module/apps/AttributeManager.mjs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/module/apps/AttributeManager.mjs b/module/apps/AttributeManager.mjs index b5f9ce7..c81bb1a 100644 --- a/module/apps/AttributeManager.mjs +++ b/module/apps/AttributeManager.mjs @@ -34,12 +34,8 @@ export class AttributeManager extends HandlebarsApplicationMixin(ApplicationV2) }; static PARTS = { - attributes: { - template: filePath(`templates/AttributeManager/attribute-list.hbs`), - }, - controls: { - template: filePath(`templates/AttributeManager/controls.hbs`), - }, + attributes: { template: filePath(`templates/AttributeManager/attribute-list.hbs`) }, + controls: { template: filePath(`templates/AttributeManager/controls.hbs`) }, }; // #endregion Options From c50e88e4836bbfe62576981205fc724c1067cc77 Mon Sep 17 00:00:00 2001 From: Eldritch-Oliver Date: Tue, 16 Sep 2025 00:45:08 -0600 Subject: [PATCH 3/7] 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 + + + + + + +
+
From dff8a46ebbe02d6459530da246b9740bcfca064d Mon Sep 17 00:00:00 2001 From: Eldritch-Oliver Date: Tue, 16 Sep 2025 00:45:48 -0600 Subject: [PATCH 4/7] Make the size settings apply to the application when it is constructed --- module/apps/PlayerSheet.mjs | 65 ++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/module/apps/PlayerSheet.mjs b/module/apps/PlayerSheet.mjs index eecd4ff..54c7d44 100644 --- a/module/apps/PlayerSheet.mjs +++ b/module/apps/PlayerSheet.mjs @@ -1,9 +1,11 @@ import { __ID__, filePath } from "../consts.mjs"; import { AttributeManager } from "./AttributeManager.mjs"; import { attributeSorter } from "../utils/attributeSort.mjs"; +import { ResizeControlManager } from "./ResizeControlManager.mjs"; const { HandlebarsApplicationMixin } = foundry.applications.api; const { ActorSheetV2 } = foundry.applications.sheets; +const { getProperty } = foundry.utils; export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) { @@ -26,6 +28,7 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) { }, actions: { manageAttributes: this.#manageAttributes, + sizeSettings: this.#configureSizeSettings, }, }; @@ -37,6 +40,31 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) { // #endregion Options // #region Lifecycle + constructor(options) { + if (options.document) { + const sizing = getProperty(options.document, `flags.${__ID__}.PlayerSheet.size`) ?? {}; + + options.window ??= {}; + switch (sizing.resizable) { + case `false`: + options.window.resizable ??= false; + break; + case `true`: + options.window.resizable ??= true; + break; + }; + + options.position ??= {}; + if (sizing.width) { + options.position.width ??= sizing.width; + } + if (sizing.height) { + options.position.height ??= sizing.height; + } + }; + super(options); + }; + _getHeaderControls() { const controls = super._getHeaderControls(); @@ -51,13 +79,22 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) { return isGM || (allowPlayerEdits && editable); }, }); + controls.push({ + icon: `fa-solid fa-crop-simple`, + label: `Configure Size`, + action: `sizeSettings`, + visible: () => { + const isGM = game.user.isGM; + return isGM; + }, + }); return controls; }; async close() { - this.attributeManager?.close(); - this.attributeManager = null; + this.#attributeManager?.close(); + this.#attributeManager = null; return super.close(); }; // #endregion Lifecycle @@ -109,16 +146,26 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) { // #endregion Data Prep // #region Actions - attributeManager = null; - + #attributeManager = null; /** @this {PlayerSheet} */ static async #manageAttributes() { - this.attributeManager ??= new AttributeManager({ document: this.actor }); - if (this.attributeManager.rendered) { - await this.attributeManager.bringToFront(); + this.#attributeManager ??= new AttributeManager({ document: this.actor }); + if (this.#attributeManager.rendered) { + await this.#attributeManager.bringToFront(); } else { - await this.attributeManager.render({ force: true }); - } + await this.#attributeManager.render({ force: true }); + }; + }; + + #sizeSettings = null; + /** @this {PlayerSheet} */ + static async #configureSizeSettings() { + this.#sizeSettings ??= new ResizeControlManager({ document: this.actor }); + if (this.#sizeSettings.rendered) { + await this.#sizeSettings.bringToFront(); + } else { + await this.#sizeSettings.render({ force: true }); + }; }; // #endregion Actions }; From c29fa3e0174cd1da47de80da0b9c54d3499a98af Mon Sep 17 00:00:00 2001 From: Eldritch-Oliver Date: Wed, 17 Sep 2025 19:12:23 -0600 Subject: [PATCH 5/7] Update the size settings to apply without using the constructor --- module/apps/PlayerSheet.mjs | 41 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/module/apps/PlayerSheet.mjs b/module/apps/PlayerSheet.mjs index 54c7d44..e9caf53 100644 --- a/module/apps/PlayerSheet.mjs +++ b/module/apps/PlayerSheet.mjs @@ -40,29 +40,28 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) { // #endregion Options // #region Lifecycle - constructor(options) { - if (options.document) { - const sizing = getProperty(options.document, `flags.${__ID__}.PlayerSheet.size`) ?? {}; + _initializeApplicationOptions(options) { + const sizing = getProperty(options.document, `flags.${__ID__}.PlayerSheet.size`) ?? {}; - options.window ??= {}; - switch (sizing.resizable) { - case `false`: - options.window.resizable ??= false; - break; - case `true`: - options.window.resizable ??= true; - break; - }; - - options.position ??= {}; - if (sizing.width) { - options.position.width ??= sizing.width; - } - if (sizing.height) { - options.position.height ??= sizing.height; - } + options.window ??= {}; + switch (sizing.resizable) { + case `false`: + options.window.resizable ??= false; + break; + case `true`: + options.window.resizable ??= true; + break; }; - super(options); + + options.position ??= {}; + if (sizing.width) { + options.position.width ??= sizing.width; + }; + if (sizing.height) { + options.position.height ??= sizing.height; + }; + + return super._initializeApplicationOptions(options); }; _getHeaderControls() { From baaafcccfc8aaa1faac871a41dcb7bd765bffd3a Mon Sep 17 00:00:00 2001 From: Eldritch-Oliver Date: Wed, 17 Sep 2025 19:13:22 -0600 Subject: [PATCH 6/7] Make the styling of the save button more consistent --- styles/Apps/ResizeControlManager.css | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/styles/Apps/ResizeControlManager.css b/styles/Apps/ResizeControlManager.css index 8ccd047..7783d40 100644 --- a/styles/Apps/ResizeControlManager.css +++ b/styles/Apps/ResizeControlManager.css @@ -7,4 +7,14 @@ border: 1px solid rebeccapurple; border-radius: 4px; } + + .controls { + display: flex; + flex-direction: row; + gap: 8px; + + button { + flex-grow: 1; + } + } } From b683e8b5a04440fa411f02aaf86555c8cf6e810e Mon Sep 17 00:00:00 2001 From: Eldritch-Oliver Date: Wed, 17 Sep 2025 19:20:49 -0600 Subject: [PATCH 7/7] Remove unneeded _onRender method --- module/apps/ResizeControlManager.mjs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/module/apps/ResizeControlManager.mjs b/module/apps/ResizeControlManager.mjs index 3a42290..3bd2b08 100644 --- a/module/apps/ResizeControlManager.mjs +++ b/module/apps/ResizeControlManager.mjs @@ -37,12 +37,6 @@ export class ResizeControlManager extends HandlebarsApplicationMixin(DocumentShe }; // #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`) ?? {};