diff --git a/module.json b/module.json index a4f0fae..7da55d1 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "id": "dh-countdownsplus", "title": "Daggerheart Countdowns Plus", "description": "A module to allow the Daggerheart countdown tracker to be detached and moved freely.", - "version": "1.0.0", + "version": "1.1.0", "compatibility": { "minimum": "13", "verified": "13" @@ -31,7 +31,7 @@ "styles": [ "styles/module.css" ], - "url": "https://github.com/cptn-cosmo/dh-countdownsplus", + "url": "https://git.geeks.gay/cosmo/dh-countdownsplus", "manifest": "https://github.com/cptn-cosmo/dh-countdownsplus/releases/latest/download/module.json", "download": "https://github.com/cptn-cosmo/dh-countdownsplus/releases/download/1.0.0/dh-countdownsplus.zip" -} \ No newline at end of file +} diff --git a/scripts/MovableCountdowns.js b/scripts/MovableCountdowns.js index 1f54517..8462064 100644 --- a/scripts/MovableCountdowns.js +++ b/scripts/MovableCountdowns.js @@ -6,6 +6,11 @@ export function createMovableCountdownsClass(BaseCountdowns) { return class MovableCountdowns extends BaseCountdowns { constructor(options = {}) { + // Load saved position if exists + const savedPos = game.user.getFlag('dh-countdownsplus', 'windowPosition'); + if (savedPos) { + options.position = foundry.utils.mergeObject(options.position || {}, savedPos); + } super(options); } @@ -132,8 +137,31 @@ export function createMovableCountdownsClass(BaseCountdowns) { } } + /** + * Capture position changes to save them, since close() only has the final state. + * AppV2 doesn't have a simple 'move' hook, but we can override setPosition. + */ + setPosition(position = {}) { + const result = super.setPosition(position); + // Debounce save or just save on close? + // Saving on close is safer for perf, but crash might lose it. + // Let's stick to close() for now as per plan, but we need to ensure 'this.position' is updated. + // In AppV2, this.position is getter/setter. + return result; + } + /** @override */ async close(options = {}) { + // Save position before closing + if (this.position) { + await game.user.setFlag('dh-countdownsplus', 'windowPosition', { + top: this.position.top, + left: this.position.left, + width: this.position.width, + height: this.position.height + }); + } + await super.close(options); // Remove detached class from body diff --git a/styles/module.css b/styles/module.css index b6c2938..fdf41a3 100644 --- a/styles/module.css +++ b/styles/module.css @@ -12,6 +12,10 @@ /* Disable system transition for sliding */ box-shadow: 0 0 10px #000; /* Add shadow for popping out */ + + /* User request: Prevent resizing larger than content */ + max-width: fit-content !important; + max-height: fit-content !important; } /* Ensure window header is visible/draggable */