Compare commits

...

14 Commits

Author SHA1 Message Date
Manuel Vögele 0a54a47951 Release v1.3.5 2021-03-10 11:51:41 +01:00
Manuel Vögele 0b71504da3 Fix regression introduced in 6e745820 that made colors flicker during measurement 2021-03-10 11:50:55 +01:00
Manuel Vögele 0a7d8495c6 Release v1.3.4 2021-03-09 09:21:09 +01:00
Manuel Vögele 6e74582089 Stop patching _highlightMeasurement and import it instead to increase compatibility with other modules 2021-03-09 09:09:50 +01:00
Manuel Vögele 20e8713e30 Release v1.3.3 2021-03-03 09:51:01 +01:00
Manuel Vögele 544740b697 Pull current speed provider from game settings for non GM users (fixes #34) 2021-03-03 09:49:08 +01:00
Manuel Vögele 404e978377 Release v1.3.2 2021-03-02 08:30:41 +01:00
Manuel Vögele 4a56cdb0a4 Merge branch 'master' into develop 2021-03-02 08:30:03 +01:00
Manuel Vögele 48e6901b59 Add 15e9104 to the changelog 2021-03-02 08:28:57 +01:00
Brother Sharp 15e910424f update japanese localization (#32) 2021-03-02 08:24:04 +01:00
Manuel Vögele baba6e2986 Fix typo in english translation 2021-02-26 12:29:56 +01:00
Manuel Vögele 6f0a04c20f Add Tormenta20 to list of game systems with integration 2021-02-23 16:47:10 +01:00
Manuel Vögele 8522c9a811 Release v1.3.1 2021-02-22 05:34:08 +01:00
Manuel Vögele d5fd5e0d04 Dash multiplier 0 now works again 2021-02-22 05:29:00 +01:00
9 changed files with 117 additions and 50 deletions
+23
View File
@@ -1,3 +1,26 @@
## 1.3.5
### Bugfixes
- Fixed a regression where spaces could suddenly change their color during measurement
## 1.3.4
### Module compatibility
- Increased compatiblility with other modules (namely Drag Ruler and Terrain Ruler are no longer incompatible)
## 1.3.3
### Bugfixes
- Speed Provider Settings are now being saved for non GM players
## 1.3.2
### Translation
- Updated japanese translation (thanks to togue)
## 1.3.1
### Bugfixes
- Fixed a bug where the coloring of ranges wouldn't work with the generic speed provider if the Dash Multiplier was set to 0
## 1.3.0
### New features
- The color used to indicate speed ranges is now configurable
+1
View File
@@ -29,6 +29,7 @@ The game systems that offer Drag Ruler integration are:
- Cypher System (starting with version 1.13.0)
- Pathfinder 1 (starting with version 0.77.3)
- Pathfinder 2e (via the module [PF2E Drag Ruler Integration](https://foundryvtt.com/packages/pf2e-dragruler/))
- Tormenta20 (starting with version 1.1.37)
## Translations
+1 -1
View File
@@ -37,7 +37,7 @@
"noSettings": "This speed provider doesn't offer any configuration options.",
"color": {
"name": "Color for {colorName}",
"hint": "The color that will be used to color square that are within {colorName} range",
"hint": "The color that will be used to color squares that are within {colorName} range",
"unreachable": {
"name": "unreachable",
"hint": "The color for spaces that aren't reachable by the dragged token"
+46 -19
View File
@@ -1,31 +1,58 @@
{
"drag-ruler": {
"genericSpeedProvider": {
"settings": {
"dashMultiplier": {
"name": "早足の倍率",
"hint": "設定すると、移動経路の測定中に第二の色分けが追加されます。0にすると第二速度が無効になります。"
},
"speedAttribute": {
"name": "移動速度の属性値",
"hint": "コマの移動速度が定義された属性値を指定します。移動範囲表示の色分けに使用されます。"
}
},
"speeds": {
"walk": "歩き",
"dash": "早足"
}
},
"settings": {
"alwaysShowSpeedForPCs": {
"name": "プレイヤーキャラクターの移動速度を全員に公開する",
"hint": "有効にすると、アクターの観察者(Observer)権限を持たない人にも,移動範囲の色分けが表示されるようになります。"
},
"dashMultiplier": {
"name": "早足の倍率",
"hint": "有効にすると、移動範囲に二つ目の色分けが追加されます。0にすると、この機能は無効になります。"
},
"speedAttribute": {
"name": "移動速度の属性値",
"hint": "コマの移動速度が定義された属性値を指定します。移動範囲表示の色分けに使用されます。"
},
"speedProvider": {
"name": "移動速度設定の提供元",
"hint": "色分けに使用する速度情報の提供元を選択します。ゲームシステムやモジュールを選択すると、Drag Ruler自体が提供するものより柔軟な色分けが行える可能性があります。",
"choices": {
"module": "モジュール",
"native": "Drag Ruler",
"system": "ゲームシステム"
"speedProviderSettings": {
"name": "移動速度の提供元",
"hint": "ゲームシステムに固有のすべての設定をここで行います。",
"button": "移動速度の提供元設定",
"windowTitle": "移動速度の提供元設定",
"headers": {
"speedProvider": "移動速度の提供元",
"speedProviderSettings": "提供元に固有の設定"
},
"activeProvider": {
"name": "現在有効な提供元",
"hint": "以下の設定は、現在有効な移動速度の提供元によって変化します。GMが別の提供元を選択すると、利用可能な項目が変更となる場合があります。"
},
"noSettings": "この移動速度提供元には、設定オプションがありません。",
"color": {
"name": "{colorName}の色",
"hint": "{colorName}の範囲に使用するセルの色を指定します。",
"unreachable": {
"name": "到達不能域",
"hint": "ドラッグしたコマが到達できない範囲の色を指定します。"
}
},
"speedProvider": {
"name": "移動速度の提供元",
"hint": "色分けに使用する速度情報の提供元を選択します。Drag Rulerは基本機能を備えた汎用の提供元を備えており、正しく設定すればすべてのゲームシステムで動作するはずです。しかしゲームシステムやモジュールを介することで、より多くの提供元を利用することもできます。こうした提供元を利用すると、ゲームルールとの統合がさらに向上するかもしれません。以下のオプションは、ここで選択した提供元によって変化します。",
"choices": {
"module": "モジュール {name}",
"native": "汎用",
"system": "システム {name}"
}
}
},
"staticFirstColor": {
"name": "一つ目の色を固定する",
"hint": "一つ目の移動範囲の色に、プレイヤーの色でなく固定された色を使用します。"
},
"swapSpacebarRightClick": {
"name": "スペースキーと右クリックを入れ替える",
"hint": "ドラッグ中のスペースキーと右クリックの機能を入れ替えます。有効にすると右クリックがウェイポイントの配置、スペースキーが削除になります。"
+2 -2
View File
@@ -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.3.0",
"version": "1.3.5",
"minimumCoreVersion" : "0.7.9",
"compatibleCoreVersion" : "0.7.9",
"authors": [
@@ -31,7 +31,7 @@
}
],
"url": "https://github.com/manuelVo/foundryvtt-drag-ruler",
"download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.3.0.zip",
"download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.3.5.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",
+41 -1
View File
@@ -166,7 +166,7 @@ export function measure(destination, {gridSpaces=true, snap=false} = {}) {
}
// Highlight grid positions
this._highlightMeasurement(ray, s.startDistance);
highlightMeasurementNative.call(this, ray, s.startDistance);
}
// Draw endpoints
@@ -177,3 +177,43 @@ export function measure(destination, {gridSpaces=true, snap=false} = {}) {
// Return the measured segments
return segments;
}
export function highlightMeasurementNative(ray, startDistance) {
const spacer = canvas.scene.data.gridType === CONST.GRID_TYPES.SQUARE ? 1.41 : 1;
const nMax = Math.max(Math.floor(ray.distance / (spacer * Math.min(canvas.grid.w, canvas.grid.h))), 1);
const tMax = Array.fromRange(nMax+1).map(t => t / nMax);
// Track prior position
let prior = null;
// Iterate over ray portions
for ( let [i, t] of tMax.entries() ) {
let {x, y} = ray.project(t);
// Get grid position
let [x0, y0] = (i === 0) ? [null, null] : prior;
let [x1, y1] = canvas.grid.grid.getGridPositionFromPixels(x, y);
if ( x0 === x1 && y0 === y1 ) continue;
// Highlight the grid position
let [xg, yg] = canvas.grid.grid.getPixelsFromGridPosition(x1, y1);
let subDistance = canvas.grid.measureDistances([{ray: new Ray(ray.A, {x: xg, y: yg})}], {gridSpaces: true})[0]
let color = dragRuler.getColorForDistance.call(this, startDistance, subDistance)
canvas.grid.highlightPosition(this.name, {x: xg, y: yg, color: color});
// Skip the first one
prior = [x1, y1];
if ( i === 0 ) continue;
// If the positions are not neighbors, also highlight their halfway point
if ( !canvas.grid.isNeighbor(x0, y0, x1, y1) ) {
let th = tMax[i - 1] + (0.5 / nMax);
let {x, y} = ray.project(th);
let [x1h, y1h] = canvas.grid.grid.getGridPositionFromPixels(x, y);
let [xgh, ygh] = canvas.grid.grid.getPixelsFromGridPosition(x1h, y1h);
subDistance = canvas.grid.measureDistances([{ray: new Ray(ray.A, {x: xgh, y: ygh})}], {gridSpaces: true})[0]
color = dragRuler.getColorForDistance.call(this, startDistance, subDistance)
canvas.grid.highlightPosition(this.name, {x: xgh, y: ygh, color: color});
}
}
}
-25
View File
@@ -13,7 +13,6 @@ Hooks.once("init", () => {
hookTokenDragHandlers()
hookRulerFunctions()
hookKeyboardManagerFunctions()
patchRulerHighlightMeasurement()
window.dragRuler = {
getColorForDistance,
@@ -238,11 +237,6 @@ function deleteWaypoint() {
}
}
function strInsertAfter(haystack, needle, strToInsert) {
const pos = haystack.indexOf(needle) + needle.length
return haystack.slice(0, pos) + strToInsert + haystack.slice(pos)
}
export function getColorForDistance(startDistance, subDistance=0) {
if (!this.isDragRuler)
return this.color
@@ -263,22 +257,3 @@ export function getColorForDistance(startDistance, subDistance=0) {
}, {range: Infinity, color: getUnreachableColorFromSpeedProvider()})
return currentRange.color
}
// These patches were written with foundry-0.7.9.js as reference
function patchRulerHighlightMeasurement() {
let code = Ruler.prototype._highlightMeasurement.toString()
// Replace CRLF with LF in case foundry.js has CRLF for some reason
code = code.replace(/\r\n/g, "\n")
// Remove function signature and closing curly bracket (those are on the first and last line)
code = code.slice(code.indexOf("\n"), code.lastIndexOf("\n"))
const calcColorCode = `
let subDistance = canvas.grid.measureDistances([{ray: new Ray(ray.A, {x: xg, y: yg})}], {gridSpaces: true})[0]
let color = dragRuler.getColorForDistance.call(this, startDistance, subDistance)
`
code = strInsertAfter(code, "Position(x1, y1);\n", calcColorCode)
code = strInsertAfter(code, "Position(x1h, y1h);\n", calcColorCode.replace("x: xg, y: yg", "x: xgh, y: ygh"))
code = code.replace(/color: this\.color\}/g, "color}")
Ruler.prototype._highlightMeasurement = new Function("ray", "startDistance=undefined", code)
}
+2 -1
View File
@@ -111,6 +111,7 @@ class SpeedProviderSettings extends FormApplication {
}
async _updateObject(event, formData) {
const selectedSpeedProvider = game.user.isGM ? formData.speedProvider : game.settings.get(settingsKey, "speedProvider")
for (let [key, value] of Object.entries(formData)) {
// Check if this is color, convert the value to an integer
const splitKey = key.split(".", 3)
@@ -121,7 +122,7 @@ class SpeedProviderSettings extends FormApplication {
}
// Don't change settings for speed providers that aren't currently active
if (key !== "speedProvider" && !key.startsWith(formData.speedProvider))
if (key !== "speedProvider" && !key.startsWith(selectedSpeedProvider))
continue
// Get the key for the current setting
+1 -1
View File
@@ -115,7 +115,7 @@ export class GenericSpeedProvider extends SpeedProvider {
}
const dashMultiplier = this.getSetting("dashMultiplier")
if (!dashMultiplier)
return [{range: tokenSpeed, color: playercolor}]
return [{range: tokenSpeed, color: "walk"}]
return [{range: tokenSpeed, color: "walk"}, {range: tokenSpeed * dashMultiplier, color: "dash"}]
}