Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ebde56513d | |||
| 74c7d74c5a | |||
| f1542b7789 | |||
| 46edfa8ae6 |
@@ -1,3 +1,11 @@
|
||||
## v1.1.1
|
||||
### Bugfixes
|
||||
- Fixed a bug where tokens wouldn't be moved to the corect end position on gridless maps
|
||||
- Ruler now appears immediately when the token is being dragged
|
||||
- On gridless maps the ruler will always start measuring at the center of the token
|
||||
- This change has no impact on the distance that is being measured
|
||||
- In addition to the cosmetical aspect this also fixes a bug that allowed players to glitch through walls
|
||||
|
||||
## v1.1.0
|
||||
### New features
|
||||
- The drag ruler will now be colored for other players than the dragging player as well (only if they have at least observer permissions for that token)
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
"name": "drag-ruler",
|
||||
"title": "Drag Ruler",
|
||||
"description": "When dragging a token displays a ruler showing how far you've moved that token.",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"minimumCoreVersion" : "0.7.9",
|
||||
"compatibleCoreVersion" : "0.7.9",
|
||||
"authors": [
|
||||
@@ -23,7 +23,7 @@
|
||||
}
|
||||
],
|
||||
"url": "https://github.com/manuelVo/foundryvtt-drag-ruler",
|
||||
"download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.1.0.zip",
|
||||
"download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.1.1.zip",
|
||||
"manifest": "https://raw.githubusercontent.com/manuelVo/foundryvtt-drag-ruler/master/module.json",
|
||||
"readme": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/README.md",
|
||||
"changelog": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/CHANGELOG.md",
|
||||
|
||||
+32
-4
@@ -44,10 +44,17 @@ async function animateToken(token, rays, tokenOffset, wasPaused) {
|
||||
|
||||
// Determine offset relative to the Token top-left.
|
||||
// This is important so we can position the token relative to the ruler origin for non-1x1 tokens.
|
||||
const origin = canvas.grid.getTopLeft(this.waypoints[0].x + tokenOffset.x, this.waypoints[0].y + tokenOffset.y);
|
||||
const s2 = canvas.dimensions.size / 2;
|
||||
const dx = Math.round((token.data.x - origin[0]) / s2) * s2;
|
||||
const dy = Math.round((token.data.y - origin[1]) / s2) * s2;
|
||||
origin = canvas.grid.getTopLeft(this.waypoints[0].x + tokenOffset.x, this.waypoints[0].y + tokenOffset.y);
|
||||
let dx, dy
|
||||
if (canvas.grid.type === CONST.GRID_TYPES.GRIDLESS) {
|
||||
dx = token.data.x - origin[0]
|
||||
dy = token.data.y - origin[1]
|
||||
}
|
||||
else {
|
||||
const s2 = canvas.dimensions.size / 2;
|
||||
dx = Math.round((token.data.x - origin[0]) / s2) * s2;
|
||||
dy = Math.round((token.data.y - origin[1]) / s2) * s2;
|
||||
}
|
||||
|
||||
token._noAnimate = true;
|
||||
for (let r of offsetRays) {
|
||||
@@ -67,3 +74,24 @@ function calculateTokenOffset(tokenA, tokenB) {
|
||||
function applyOffsetToRay(ray, offset) {
|
||||
return new Ray({x: ray.A.x + offset.x, y: ray.A.y + offset.y}, {x: ray.B.x + offset.x, y: ray.B.y + offset.y})
|
||||
}
|
||||
|
||||
// This is a modified version of Ruler._onMouseMove from foundry 0.7.9
|
||||
export function onMouseMove(event) {
|
||||
if (this._state === Ruler.STATES.MOVING) return;
|
||||
|
||||
// Extract event data
|
||||
const mt = event._measureTime || 0;
|
||||
const originalEvent = event.data.originalEvent;
|
||||
const destination = {x: event.data.destination.x + this.rulerOffset.x, y: event.data.destination.y + this.rulerOffset.y}
|
||||
|
||||
// Hide any existing Token HUD
|
||||
canvas.hud.token.clear();
|
||||
delete event.data.hudState;
|
||||
|
||||
// Draw measurement updates
|
||||
if (Date.now() - mt > 50) {
|
||||
this.measure(destination, { gridSpaces: !originalEvent.shiftKey });
|
||||
event._measureTime = Date.now();
|
||||
this._state = Ruler.STATES.MEASURING;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -1,7 +1,7 @@
|
||||
"use strict"
|
||||
|
||||
import {availableSpeedProviders, currentSpeedProvider, registerModule, registerSystem, setCurrentSpeedProvider} from "./api.js"
|
||||
import {moveTokens} from "./foundry_imports.js"
|
||||
import {moveTokens, onMouseMove} from "./foundry_imports.js"
|
||||
import {registerSettings, settingsKey} from "./settings.js"
|
||||
|
||||
Hooks.once("init", () => {
|
||||
@@ -92,13 +92,17 @@ function hookRulerFunctions() {
|
||||
}
|
||||
|
||||
function onTokenLeftDragStart(event) {
|
||||
canvas.controls.ruler._onDragStart(event)
|
||||
canvas.controls.ruler.draggedToken = this
|
||||
const tokenCenter = {x: this.x + canvas.grid.size / 2, y: this.y + canvas.grid.size / 2}
|
||||
canvas.controls.ruler.clear();
|
||||
canvas.controls.ruler._state = Ruler.STATES.STARTING;
|
||||
canvas.controls.ruler.rulerOffset = {x: tokenCenter.x - event.data.origin.x, y: tokenCenter.y - event.data.origin.y}
|
||||
canvas.controls.ruler._addWaypoint(tokenCenter);
|
||||
}
|
||||
|
||||
function onTokenLeftDragMove(event) {
|
||||
if (canvas.controls.ruler.isDragRuler)
|
||||
canvas.controls.ruler._onMouseMove(event)
|
||||
onMouseMove.call(canvas.controls.ruler, event)
|
||||
}
|
||||
|
||||
function onTokenDragLeftDrop(event) {
|
||||
|
||||
Reference in New Issue
Block a user