Add an application for controlling the size settings.

This commit is contained in:
Eldritch-Oliver 2025-09-16 00:45:08 -06:00
parent a98af33477
commit c50e88e483
5 changed files with 114 additions and 0 deletions

View file

@ -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
};

View file

@ -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;
}
}

View file

@ -20,3 +20,4 @@
@import url("./Apps/Ask.css") layer(apps); @import url("./Apps/Ask.css") layer(apps);
@import url("./Apps/AttributeManager.css") layer(apps); @import url("./Apps/AttributeManager.css") layer(apps);
@import url("./Apps/PlayerSheet.css") layer(apps); @import url("./Apps/PlayerSheet.css") layer(apps);
@import url("./Apps/ResizeControlManager.css") layer(apps);

View file

@ -0,0 +1,7 @@
<div class="controls">
<button
type="submit"
>
Save and Close
</button>
</div>

View file

@ -0,0 +1,29 @@
<div class="settings">
<p>
Changes to these settings will only take effect after a reload of Foundry.
</p>
<fieldset>
<legend>Sizing</legend>
<label for="{{ meta.idp }}-width">Width</label>
<input
type="number"
id="{{ meta.idp }}-width"
value="{{ width }}"
name="flags.taf.PlayerSheet.size.width"
>
<label for="{{ meta.idp }}-height">Height</label>
<input
type="number"
id="{{ meta.idp }}-height"
value="{{ height }}"
name="flags.taf.PlayerSheet.size.height"
>
<label for="{{ meta.idp }}-resizable">Resizable?</label>
<select
id="{{ meta.idp }}-resizable"
name="flags.taf.PlayerSheet.size.resizable"
>
{{ taf-options resizable resizeOptions }}
</select>
</fieldset>
</div>