Allow getTokenShape on gridless maps (fixes #44)

This commit is contained in:
Manuel Vögele
2021-03-18 07:41:30 +01:00
parent 8234aa566d
commit 40dde08ddd
2 changed files with 8 additions and 3 deletions
+4
View File
@@ -1,3 +1,7 @@
## In development
### Bugfixes
- Drag Ruler now works again on gridless maps
## 1.4.1 ## 1.4.1
### Bugfixes ### Bugfixes
- Fixed a bug where Drag Ruler wouldn't work at all on hex grids when the Hex Token Size Support isn't installed - Fixed a bug where Drag Ruler wouldn't work at all on hex grids when the Hex Token Size Support isn't installed
+4 -3
View File
@@ -57,9 +57,10 @@ export function getAreaFromPositionAndShape(position, shape) {
} }
export function getTokenShape(token) { export function getTokenShape(token) {
if (token.scene.data.gridType === CONST.GRID_TYPES.GRIDLESS) if (token.scene.data.gridType === CONST.GRID_TYPES.GRIDLESS) {
throw new Error("getTokenShape cannot be called for tokens on gridless maps") return [{x: 0, y: 0}]
if (token.scene.data.gridType === CONST.GRID_TYPES.SQUARE) { }
else if (token.scene.data.gridType === CONST.GRID_TYPES.SQUARE) {
const topOffset = -Math.floor(token.data.height / 2) const topOffset = -Math.floor(token.data.height / 2)
const leftOffset = -Math.floor(token.data.width / 2) const leftOffset = -Math.floor(token.data.width / 2)
const shape = [] const shape = []