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 diff --git a/module/apps/PlayerSheet.mjs b/module/apps/PlayerSheet.mjs index eecd4ff..e9caf53 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,30 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) { // #endregion Options // #region Lifecycle + _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; + }; + + return super._initializeApplicationOptions(options); + }; + _getHeaderControls() { const controls = super._getHeaderControls(); @@ -51,13 +78,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 +145,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 }; diff --git a/module/apps/ResizeControlManager.mjs b/module/apps/ResizeControlManager.mjs new file mode 100644 index 0000000..3bd2b08 --- /dev/null +++ b/module/apps/ResizeControlManager.mjs @@ -0,0 +1,61 @@ +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 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..7783d40 --- /dev/null +++ b/styles/Apps/ResizeControlManager.css @@ -0,0 +1,20 @@ +.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; + } + + .controls { + display: flex; + flex-direction: row; + gap: 8px; + + button { + flex-grow: 1; + } + } +} 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/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" 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 @@ +
+ Changes to these settings will only take effect after a reload of Foundry. +
+ +