From 40dde08dddb0f9a778bb67da63ee73cfd19d9315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Thu, 18 Mar 2021 07:41:30 +0100 Subject: [PATCH] Allow getTokenShape on gridless maps (fixes #44) --- CHANGELOG.md | 4 ++++ src/util.js | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dd16a2..53d5d1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## In development +### Bugfixes +- Drag Ruler now works again on gridless maps + ## 1.4.1 ### Bugfixes - Fixed a bug where Drag Ruler wouldn't work at all on hex grids when the Hex Token Size Support isn't installed diff --git a/src/util.js b/src/util.js index 6ef2752..a17f2b9 100644 --- a/src/util.js +++ b/src/util.js @@ -57,9 +57,10 @@ export function getAreaFromPositionAndShape(position, shape) { } export function getTokenShape(token) { - if (token.scene.data.gridType === CONST.GRID_TYPES.GRIDLESS) - throw new Error("getTokenShape cannot be called for tokens on gridless maps") - if (token.scene.data.gridType === CONST.GRID_TYPES.SQUARE) { + if (token.scene.data.gridType === CONST.GRID_TYPES.GRIDLESS) { + return [{x: 0, y: 0}] + } + else if (token.scene.data.gridType === CONST.GRID_TYPES.SQUARE) { const topOffset = -Math.floor(token.data.height / 2) const leftOffset = -Math.floor(token.data.width / 2) const shape = []