Compare commits

..

6 Commits

Author SHA1 Message Date
Manuel Vögele d232335e90 Release v1.2.2 2021-02-11 16:08:46 +01:00
Manuel Vögele b309464c76 Add credit for japanese translation 2021-02-11 16:06:46 +01:00
Brother Sharp 9ce3cc5eb8 Add japanese translation (#19) 2021-02-11 16:03:38 +01:00
Manuel Vögele 10346a7dbc Release v1.2.1 2021-02-11 09:11:27 +01:00
Manuel Vögele 6adb69829e Make compatible with Hex Token Size Support (resolves #12) 2021-02-11 09:06:54 +01:00
Manuel Vögele 94f5a49263 Cache canvas.controls.ruler into local variable for readability and performance 2021-02-11 00:27:11 +01:00
6 changed files with 112 additions and 30 deletions
+11 -3
View File
@@ -1,3 +1,11 @@
## 1.2.2
### Translation
- Added japanese translation (thanks to touge)
## 1.2.1
### 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 ## 1.2.0
### New features ### New features
- Right click and spacebar can now be swapped, allowing to place waypoints with right click and removing them with spacebar - Right click and spacebar can now be swapped, allowing to place waypoints with right click and removing them with spacebar
@@ -9,7 +17,7 @@
- Disabling snap to grid with shift now works as expected - Disabling snap to grid with shift now works as expected
- Fixed a bug where the ruler would sometimes jump to a different target location when deleting a waypoint - Fixed a bug where the ruler would sometimes jump to a different target location when deleting a waypoint
## v1.1.1 ## 1.1.1
### Bugfixes ### Bugfixes
- Fixed a bug where tokens wouldn't be moved to the corect end position on gridless maps - 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 - Ruler now appears immediately when the token is being dragged
@@ -17,7 +25,7 @@
- This change has no impact on the distance that is being measured - 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 - In addition to the cosmetical aspect this also fixes a bug that allowed players to glitch through walls
## v1.1.0 ## 1.1.0
### New features ### 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) - 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)
- The drag ruler won't be shown to other players if they cannot see the dragged token - The drag ruler won't be shown to other players if they cannot see the dragged token
@@ -25,7 +33,7 @@
### Bugfixes ### Bugfixes
- Fixed a bug where Drag Ruler wouldn't work at all on some windows installations (specificially where the `foundry.js` has `CRLF` line endings) - Fixed a bug where Drag Ruler wouldn't work at all on some windows installations (specificially where the `foundry.js` has `CRLF` line endings)
## v1.0.1 ## 1.0.1
### Bugfixes ### Bugfixes
- The GM can now move tokens through walls - The GM can now move tokens through walls
- It is now possible to move multiple tokens with Drag Ruler enabled - It is now possible to move multiple tokens with Drag Ruler enabled
+4
View File
@@ -30,6 +30,10 @@ The game systems that offer Drag Ruler integration are:
- Pathfinder 2e (via the module [PF2E Drag Ruler Integration](https://foundryvtt.com/packages/pf2e-dragruler/)) - Pathfinder 2e (via the module [PF2E Drag Ruler Integration](https://foundryvtt.com/packages/pf2e-dragruler/))
## Translations
Drag Ruler is available in the follwing languages:
- Japanese (thanks to touge)
## API ## API
*Audience: This paragraph is intended for module and system devleopers that want to add more complex behavior to Drag Ruler. If you just want to use this plugins features skip this paragraph.* *Audience: This paragraph is intended for module and system devleopers that want to add more complex behavior to Drag Ruler. If you just want to use this plugins features skip this paragraph.*
+35
View File
@@ -0,0 +1,35 @@
{
"drag-ruler": {
"settings": {
"alwaysShowSpeedForPCs": {
"name": "プレイヤーキャラクターの移動速度を全員に公開する",
"hint": "有効にすると、アクターの観察者(Observer)権限を持たない人にも,移動範囲の色分けが表示されるようになります。"
},
"dashMultiplier": {
"name": "早足の倍率",
"hint": "有効にすると、移動範囲に二つ目の色分けが追加されます。0にすると、この機能は無効になります。"
},
"speedAttribute": {
"name": "移動速度の属性値",
"hint": "コマの移動速度が定義された属性値を指定します。移動範囲表示の色分けに使用されます。"
},
"speedProvider": {
"name": "移動速度設定の提供元",
"hint": "色分けに使用する速度情報の提供元を選択します。ゲームシステムやモジュールを選択すると、Drag Ruler自体が提供するものより柔軟な色分けが行える可能性があります。",
"choices": {
"module": "モジュール",
"native": "Drag Ruler",
"system": "ゲームシステム"
}
},
"staticFirstColor": {
"name": "一つ目の色を固定する",
"hint": "一つ目の移動範囲の色に、プレイヤーの色でなく固定された色を使用します。"
},
"swapSpacebarRightClick": {
"name": "スペースキーと右クリックを入れ替える",
"hint": "ドラッグ中のスペースキーと右クリックの機能を入れ替えます。有効にすると右クリックがウェイポイントの配置、スペースキーが削除になります。"
}
}
}
}
+7 -2
View File
@@ -2,7 +2,7 @@
"name": "drag-ruler", "name": "drag-ruler",
"title": "Drag Ruler", "title": "Drag Ruler",
"description": "When dragging a token displays a ruler showing how far you've moved that token.", "description": "When dragging a token displays a ruler showing how far you've moved that token.",
"version": "1.2.0", "version": "1.2.2",
"minimumCoreVersion" : "0.7.9", "minimumCoreVersion" : "0.7.9",
"compatibleCoreVersion" : "0.7.9", "compatibleCoreVersion" : "0.7.9",
"authors": [ "authors": [
@@ -20,10 +20,15 @@
"lang": "en", "lang": "en",
"name": "English", "name": "English",
"path": "lang/en.json" "path": "lang/en.json"
},
{
"lang": "ja",
"name": "日本語",
"path": "lang/ja.json"
} }
], ],
"url": "https://github.com/manuelVo/foundryvtt-drag-ruler", "url": "https://github.com/manuelVo/foundryvtt-drag-ruler",
"download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.2.0.zip", "download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.2.2.zip",
"manifest": "https://raw.githubusercontent.com/manuelVo/foundryvtt-drag-ruler/master/module.json", "manifest": "https://raw.githubusercontent.com/manuelVo/foundryvtt-drag-ruler/master/module.json",
"readme": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/README.md", "readme": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/README.md",
"changelog": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/CHANGELOG.md", "changelog": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/CHANGELOG.md",
+19
View File
@@ -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
}
+36 -25
View File
@@ -1,6 +1,7 @@
"use strict" "use strict"
import {availableSpeedProviders, currentSpeedProvider, registerModule, registerSystem, setCurrentSpeedProvider} from "./api.js" import {availableSpeedProviders, currentSpeedProvider, registerModule, registerSystem, setCurrentSpeedProvider} from "./api.js"
import {getHexSizeSupportTokenGridCenter} from "./compatibility.js"
import {measure, moveTokens, onMouseMove} from "./foundry_imports.js" import {measure, moveTokens, onMouseMove} from "./foundry_imports.js"
import {registerSettings, settingsKey} from "./settings.js" import {registerSettings, settingsKey} from "./settings.js"
@@ -130,52 +131,61 @@ function onKeyX(up) {
} }
function onKeyShift(up) { function onKeyShift(up) {
if (!canvas.controls.ruler.isDragRuler) const ruler = canvas.controls.ruler
if (!ruler.isDragRuler)
return false return false
const mousePosition = canvas.app.renderer.plugins.interaction.mouse.getLocalPosition(canvas.tokens) const mousePosition = canvas.app.renderer.plugins.interaction.mouse.getLocalPosition(canvas.tokens)
const rulerOffset = canvas.controls.ruler.rulerOffset const rulerOffset = ruler.rulerOffset
const measurePosition = {x: mousePosition.x + rulerOffset.x, y: mousePosition.y + rulerOffset.y} const measurePosition = {x: mousePosition.x + rulerOffset.x, y: mousePosition.y + rulerOffset.y}
canvas.controls.ruler.measure(measurePosition, {snap: up}) ruler.measure(measurePosition, {snap: up})
} }
function onTokenLeftDragStart(event) { function onTokenLeftDragStart(event) {
canvas.controls.ruler.draggedToken = this const ruler = canvas.controls.ruler
const tokenCenter = {x: this.x + canvas.grid.grid.w / 2, y: this.y + canvas.grid.grid.h / 2} ruler.draggedToken = this
canvas.controls.ruler.clear(); let tokenCenter
canvas.controls.ruler._state = Ruler.STATES.STARTING; if (canvas.grid.isHex && game.modules.get("hex-size-support")?.active && CONFIG.hexSizeSupport.getAltSnappingFlag(this))
canvas.controls.ruler.rulerOffset = {x: tokenCenter.x - event.data.origin.x, y: tokenCenter.y - event.data.origin.y} tokenCenter = getHexSizeSupportTokenGridCenter(this)
addWaypoint.call(canvas.controls.ruler, tokenCenter, false); 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}
addWaypoint.call(ruler, tokenCenter, false)
} }
function onTokenLeftDragMove(event) { function onTokenLeftDragMove(event) {
if (canvas.controls.ruler.isDragRuler) const ruler = canvas.controls.ruler
onMouseMove.call(canvas.controls.ruler, event) if (ruler.isDragRuler)
onMouseMove.call(ruler, event)
} }
function onTokenDragLeftDrop(event) { function onTokenDragLeftDrop(event) {
if (!canvas.controls.ruler.isDragRuler) const ruler = canvas.controls.ruler
if (!ruler.isDragRuler)
return false return false
const selectedTokens = canvas.tokens.placeables.filter(token => token._controlled) const selectedTokens = canvas.tokens.placeables.filter(token => token._controlled)
moveTokens.call(canvas.controls.ruler, canvas.controls.ruler.draggedToken, selectedTokens) moveTokens.call(ruler, ruler.draggedToken, selectedTokens)
canvas.controls.ruler.draggedToken = null ruler.draggedToken = null
return true return true
} }
function onTokenDragLeftCancel(event) { function onTokenDragLeftCancel(event) {
// This function is invoked by right clicking // This function is invoked by right clicking
if (!canvas.controls.ruler.isDragRuler) const ruler = canvas.controls.ruler
if (!ruler.isDragRuler)
return false return false
if (canvas.controls.ruler._state === Ruler.STATES.MEASURING) { if (ruler._state === Ruler.STATES.MEASURING) {
if (!game.settings.get(settingsKey, "swapSpacebarRightClick")) { if (!game.settings.get(settingsKey, "swapSpacebarRightClick")) {
if (canvas.controls.ruler.waypoints.length > 1) if (ruler.waypoints.length > 1)
event.preventDefault() event.preventDefault()
deleteWaypoint() deleteWaypoint()
} }
else { else {
event.preventDefault() event.preventDefault()
const snap = !event.shiftKey const snap = !event.shiftKey
addWaypoint.call(canvas.controls.ruler, canvas.controls.ruler.destination, snap) addWaypoint.call(ruler, ruler.destination, snap)
} }
} }
return true return true
@@ -204,16 +214,17 @@ function addWaypoint(point, snap=true) {
} }
function deleteWaypoint() { function deleteWaypoint() {
if (canvas.controls.ruler.waypoints.length > 1) { const ruler = canvas.controls.ruler
if (ruler.waypoints.length > 1) {
const mousePosition = canvas.app.renderer.plugins.interaction.mouse.getLocalPosition(canvas.tokens) const mousePosition = canvas.app.renderer.plugins.interaction.mouse.getLocalPosition(canvas.tokens)
const rulerOffset = canvas.controls.ruler.rulerOffset const rulerOffset = ruler.rulerOffset
canvas.controls.ruler._removeWaypoint({x: mousePosition.x + rulerOffset.x, y: mousePosition.y + rulerOffset.y}) ruler._removeWaypoint({x: mousePosition.x + rulerOffset.x, y: mousePosition.y + rulerOffset.y})
game.user.broadcastActivity({ruler: canvas.controls.ruler}) game.user.broadcastActivity({ruler: ruler})
} }
else { else {
const token = canvas.controls.ruler.draggedToken const token = ruler.draggedToken
canvas.controls.ruler._endMeasurement() ruler._endMeasurement()
canvas.controls.ruler.draggedToken = null ruler.draggedToken = null
// Deactivate the drag workflow in mouse // Deactivate the drag workflow in mouse
token.mouseInteractionManager._deactivateDragEvents(); token.mouseInteractionManager._deactivateDragEvents();