Remember the position and size of the compendium browser

This commit is contained in:
Chris Ryan 2025-08-30 13:28:55 +10:00
parent c6741b1c7a
commit 4f6ddba087
2 changed files with 18 additions and 5 deletions

View file

@ -84,12 +84,16 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
/** @inheritDoc */
async _preRender(context, options) {
this.presets = options.presets ?? {};
const userPresetPosition = game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS[`compendiumBrowser`].position);
options.position = userPresetPosition ?? ItemBrowser.DEFAULT_OPTIONS.position;
const width = this.presets?.render?.noFolder === true || this.presets?.render?.lite === true ? 600 : 850;
if(this.rendered)
this.setPosition({ width });
else
options.position.width = width;
if (!userPresetPosition) {
const width = this.presets?.render?.noFolder === true || this.presets?.render?.lite === true ? 600 : 850;
if(this.rendered)
this.setPosition({ width });
else
options.position.width = width;
}
await super._preRender(context, options);
}
@ -112,6 +116,11 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
});
}
_onPosition(position) {
game.user.setFlag(CONFIG.DH.id, CONFIG.DH.FLAGS[`compendiumBrowser`].position, position);
}
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);

View file

@ -8,6 +8,10 @@ export const encounterCountdown = {
position: 'countdown-encounter-position'
};
export const compendiumBrowser = {
position: 'compendium-browser-position'
};
export const itemAttachmentSource = 'attachmentSource';
export const userFlags = {