From 2862643ba87e87d3ba989a60c0cae8036bda8ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Wed, 17 Mar 2021 09:23:05 +0100 Subject: [PATCH] Add missing check for whether hex-size-support module is present (fixes #43) --- CHANGELOG.md | 3 +++ src/util.js | 29 ++++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90703a2..6cf58ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ ## In development +### Bugfixes +- Fixed a bug where Drag Ruler wouldn't work at all on hex grids when the Hex Token Size Support isn't installed + ### Translation - Added chinese translation (thanks to zeteticl) diff --git a/src/util.js b/src/util.js index 1cb0f56..6ef2752 100644 --- a/src/util.js +++ b/src/util.js @@ -117,21 +117,24 @@ export function applyTokenSizeOffset(waypoints, token) { const tokenSize = getTokenSize(token); const waypointOffset = {x: 0, y: 0}; if (canvas.grid.isHex) { - const isAltOrientation = CONFIG.hexSizeSupport.getAltOrientationFlag(token); - if (canvas.grid.grid.options.columns) { - if (tokenSize.w % 2 === 0) { - waypointOffset.x = canvas.grid.w / 2; - if (!isAltOrientation) - waypointOffset.x *= -1; - } - } - else { - if (tokenSize.h % 2 === 0) { - waypointOffset.y = canvas.grid.h / 2; - if (isAltOrientation) - waypointOffset.y *= -1; + if (game.modules.get("hex-size-support")?.active) { + const isAltOrientation = CONFIG.hexSizeSupport.getAltOrientationFlag(token); + if (canvas.grid.grid.options.columns) { + if (tokenSize.w % 2 === 0) { + waypointOffset.x = canvas.grid.w / 2; + if (!isAltOrientation) + waypointOffset.x *= -1; + } + } + else { + if (tokenSize.h % 2 === 0) { + waypointOffset.y = canvas.grid.h / 2; + if (isAltOrientation) + waypointOffset.y *= -1; + } } } + // If hex size support isn't active leave the waypoints like they are } else { if (tokenSize.w % 2 === 0) {