Make compatible with Hex Token Size Support (resolves #12)
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
## In development
|
||||
### Compatiblity
|
||||
- Drag Ruler is now compatible with Hex Token Size Support. For compatibility Hex Token Size Support Version 0.5.4 or higher is required. Thanks to Ourobor for helping making this possible.
|
||||
|
||||
## 1.2.0
|
||||
### New features
|
||||
- Right click and spacebar can now be swapped, allowing to place waypoints with right click and removing them with spacebar
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
export function getHexSizeSupportTokenGridCenter(token) {
|
||||
const tokenCenterOffset = CONFIG.hexSizeSupport.getCenterOffset(token)
|
||||
const tokenCenter = {x: token.x + tokenCenterOffset.x, y: token.y + tokenCenterOffset.y}
|
||||
if (token.getFlag("hex-size-support", "borderSize") % 2 === 1)
|
||||
return tokenCenter
|
||||
if (canvas.grid.grid.columns) {
|
||||
let hexOffset = canvas.grid.w / 2
|
||||
if (!CONFIG.hexSizeSupport.getAltOrientationFlag(token))
|
||||
hexOffset *= -1
|
||||
tokenCenter.x += hexOffset
|
||||
}
|
||||
else {
|
||||
let hexOffset = canvas.grid.h / 2
|
||||
if (CONFIG.hexSizeSupport.getAltOrientationFlag(token))
|
||||
hexOffset *= -1
|
||||
tokenCenter.y += hexOffset
|
||||
}
|
||||
return tokenCenter
|
||||
}
|
||||
+6
-1
@@ -1,6 +1,7 @@
|
||||
"use strict"
|
||||
|
||||
import {availableSpeedProviders, currentSpeedProvider, registerModule, registerSystem, setCurrentSpeedProvider} from "./api.js"
|
||||
import {getHexSizeSupportTokenGridCenter} from "./compatibility.js"
|
||||
import {measure, moveTokens, onMouseMove} from "./foundry_imports.js"
|
||||
import {registerSettings, settingsKey} from "./settings.js"
|
||||
|
||||
@@ -143,7 +144,11 @@ function onKeyShift(up) {
|
||||
function onTokenLeftDragStart(event) {
|
||||
const ruler = canvas.controls.ruler
|
||||
ruler.draggedToken = this
|
||||
const tokenCenter = {x: this.x + canvas.grid.grid.w / 2, y: this.y + canvas.grid.grid.h / 2}
|
||||
let tokenCenter
|
||||
if (canvas.grid.isHex && game.modules.get("hex-size-support")?.active && CONFIG.hexSizeSupport.getAltSnappingFlag(this))
|
||||
tokenCenter = getHexSizeSupportTokenGridCenter(this)
|
||||
else
|
||||
tokenCenter = {x: this.x + canvas.grid.grid.w / 2, y: this.y + canvas.grid.grid.h / 2}
|
||||
ruler.clear();
|
||||
ruler._state = Ruler.STATES.STARTING;
|
||||
ruler.rulerOffset = {x: tokenCenter.x - event.data.origin.x, y: tokenCenter.y - event.data.origin.y}
|
||||
|
||||
Reference in New Issue
Block a user