Allow speed providers to disable Drag Ruler on a per-token basis (resolves #24)
This commit is contained in:
@@ -12,6 +12,7 @@ This release introduces a new API that is incompatible with the old API. The new
|
|||||||
The following things have changed with the new API:
|
The following things have changed with the new API:
|
||||||
- Colors used by speed providers can now be changed by the user via configuration
|
- Colors used by speed providers can now be changed by the user via configuration
|
||||||
- Speed Providers can now offer settings to the user that will be integrated into Drag Ruler's settings menu
|
- Speed Providers can now offer settings to the user that will be integrated into Drag Ruler's settings menu
|
||||||
|
- Speed Providers can now conditionally disable Drag Ruler for some tokens
|
||||||
|
|
||||||
|
|
||||||
## 1.2.2
|
## 1.2.2
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ function register(module, type, speedProvider) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
speedProvider.id = id
|
speedProvider.id = id
|
||||||
|
speedProvider.usesRuler = () => true
|
||||||
providerInstance = speedProvider
|
providerInstance = speedProvider
|
||||||
}
|
}
|
||||||
setupProvider(providerInstance)
|
setupProvider(providerInstance)
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,6 @@
|
|||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
import {getRangesFromSpeedProvider, getUnreachableColorFromSpeedProvider, initApi, registerModule, registerSystem} from "./api.js"
|
import {currentSpeedProvider, getRangesFromSpeedProvider, getUnreachableColorFromSpeedProvider, initApi, registerModule, registerSystem} from "./api.js"
|
||||||
import {getHexSizeSupportTokenGridCenter} from "./compatibility.js"
|
import {getHexSizeSupportTokenGridCenter} from "./compatibility.js"
|
||||||
import {measure, moveTokens, onMouseMove} from "./foundry_imports.js"
|
import {measure, moveTokens, onMouseMove} from "./foundry_imports.js"
|
||||||
import {performMigrations} from "./migration.js"
|
import {performMigrations} from "./migration.js"
|
||||||
@@ -142,6 +142,8 @@ function onKeyShift(up) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onTokenLeftDragStart(event) {
|
function onTokenLeftDragStart(event) {
|
||||||
|
if (!currentSpeedProvider.usesRuler(this))
|
||||||
|
return
|
||||||
const ruler = canvas.controls.ruler
|
const ruler = canvas.controls.ruler
|
||||||
ruler.draggedToken = this
|
ruler.draggedToken = this
|
||||||
let tokenCenter
|
let tokenCenter
|
||||||
|
|||||||
@@ -73,6 +73,16 @@ export class SpeedProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a boolean indicating whether this token will use a Ruler or not.
|
||||||
|
* If this is returns `false` for a token Drag Ruler will be disabled for that token. Dragging a token for which this function
|
||||||
|
* returns false will behave as if Drag Ruler wasn't installed.
|
||||||
|
* If usesRuler returns `false` it's guranteed that the `getRanges` function won't be called for that token.
|
||||||
|
*/
|
||||||
|
usesRuler(token) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new instance of he speed provider
|
* Constructs a new instance of he speed provider
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user