Add missing check for whether hex-size-support module is present (fixes #43)

This commit is contained in:
Manuel Vögele
2021-03-17 09:23:05 +01:00
parent e3abdeab3a
commit 2862643ba8
2 changed files with 19 additions and 13 deletions
+3
View File
@@ -1,4 +1,7 @@
## In development ## 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 ### Translation
- Added chinese translation (thanks to zeteticl) - Added chinese translation (thanks to zeteticl)
+16 -13
View File
@@ -117,21 +117,24 @@ export function applyTokenSizeOffset(waypoints, token) {
const tokenSize = getTokenSize(token); const tokenSize = getTokenSize(token);
const waypointOffset = {x: 0, y: 0}; const waypointOffset = {x: 0, y: 0};
if (canvas.grid.isHex) { if (canvas.grid.isHex) {
const isAltOrientation = CONFIG.hexSizeSupport.getAltOrientationFlag(token); if (game.modules.get("hex-size-support")?.active) {
if (canvas.grid.grid.options.columns) { const isAltOrientation = CONFIG.hexSizeSupport.getAltOrientationFlag(token);
if (tokenSize.w % 2 === 0) { if (canvas.grid.grid.options.columns) {
waypointOffset.x = canvas.grid.w / 2; if (tokenSize.w % 2 === 0) {
if (!isAltOrientation) waypointOffset.x = canvas.grid.w / 2;
waypointOffset.x *= -1; if (!isAltOrientation)
} waypointOffset.x *= -1;
} }
else { }
if (tokenSize.h % 2 === 0) { else {
waypointOffset.y = canvas.grid.h / 2; if (tokenSize.h % 2 === 0) {
if (isAltOrientation) waypointOffset.y = canvas.grid.h / 2;
waypointOffset.y *= -1; if (isAltOrientation)
waypointOffset.y *= -1;
}
} }
} }
// If hex size support isn't active leave the waypoints like they are
} }
else { else {
if (tokenSize.w % 2 === 0) { if (tokenSize.w % 2 === 0) {