diff --git a/README.md b/README.md index 95de1ec..84c1c6f 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,10 @@ Nothing yet. Feel free to recommend enhancements. If you find a bug or have any feedback for me just add an issue in the [issuetracker](https://github.com/Roger92/metric-ruler-labels/issues). Thx alot and i hope this module helps you in your game :) ## Changelog + +**v3.2.2** +- Setting for Drag Ruler support is now a dropdown + **v3.2.1** - Compatibility for PF2e Token Drag Ruler (and build in Drag Ruler of the pathfinder system) - Italian Language Support (Thx to GregoryWarn) diff --git a/languages/de.json b/languages/de.json index 340bcec..9fa09f2 100644 --- a/languages/de.json +++ b/languages/de.json @@ -3,11 +3,8 @@ "settings": { "dragRulerSupport": { "name": "Anzeige bei DragRuler", - "hint": "Falls aktiviert, werden zusätzliche metrische Angaben bei Benutzung des Moduls DragRuler (by Stäbchenfisch) angezeigt. (Änderung nach Neuladen aktiv)" - }, - "pf2eDragRulerSupport": { - "name": "Anzeige bei PF2e Token Drag Ruler", - "hint": "Falls aktiviert, werden zusätzliche metrische Angaben bei Benutzung des Moduls PF2e Token Drag Ruler (by 7H3LaughingMan) angezeigt. (Änderung nach Neuladen aktiv)" + "hint": "Falls aktiviert, werden zusätzliche metrische Angaben bei Benutzung eines Dragruler Moduls angezeigt. Zur Verfügung stehen DragRuler (by Stäbchenfisch) und PF2e Token Drag Ruler (by 7H3LaughingMan) (Änderung nach Neuladen aktiv)", + "disabled": "Deaktiviert" }, "measureTemplateSupport": { "name": "Anzeige bei Schablonen", diff --git a/languages/en.json b/languages/en.json index 321da73..0a69e67 100644 --- a/languages/en.json +++ b/languages/en.json @@ -3,11 +3,8 @@ "settings": { "dragRulerSupport": { "name": "Show on DragRuler", - "hint": "When enabled, additional metric units are also shown for the DragRuler package from the author Stäbchenfisch. (Changes apply after reload) " - }, - "pf2eDragRulerSupport": { - "name": "Show on PF2e Token Drag Ruler", - "hint": "When enabled, additional metric units are also shown for the PF2e Token Drag Ruler package from the author 7H3LaughingMan. (Changes apply after reload) " + "hint": "If activated, additional metric information is displayed when using a drag ruler module. DragRuler (by Stäbchenfisch) and PF2e Token Drag Ruler (by 7H3LaughingMan) are available (change active after reload)", + "disabled": "Disabled" }, "measureTemplateSupport": { "name": "Show on Measure Templates", diff --git a/languages/it.json b/languages/it.json index 5ad542f..6684df2 100644 --- a/languages/it.json +++ b/languages/it.json @@ -3,11 +3,8 @@ "settings": { "dragRulerSupport": { "name": "Mostra in DragRuler", - "hint": "Se abilitato, vengono visualizzate anche unità metriche aggiuntive per il pacchetto DragRuler dell'autore Stäbchenfisch. (Le modifiche si applicano dopo il riavvio) " - }, - "pf2eDragRulerSupport": { - "name": "Mostra in PF2e Token Drag Ruler", - "hint": "Se abilitato, vengono visualizzate anche unità metriche aggiuntive per il pacchetto PF2e Token Drag Ruler dell'autore 7H3LaughingMan. (Le modifiche si applicano dopo il riavvio) " + "hint": "Se attivato, vengono visualizzate informazioni metriche aggiuntive quando si utilizza un modulo righello di trascinamento. DragRuler (di Stäbchenfisch) e PF2e Token Drag Ruler (di 7H3LaughingMan) sono disponibili. (Le modifiche si applicano dopo il riavvio) ", + "disabled": "Disattivato" }, "measureTemplateSupport": { "name": "Mostra in Measure Templates", diff --git a/scripts/module.js b/scripts/module.js index 0c29022..1f4a59e 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -76,7 +76,6 @@ Hooks.once('ready', () => { libWrapper.register("metric-ruler-labels", "MeasuredTemplate.prototype._refreshRulerText", async function (wrapped, ...args) { let wrappedResult = await wrapped(...args); let measureTemplateSupport = game.settings.get("metric-ruler-labels", "measureTemplateSupport"); - //console.log("MeasuredTemplate.prototype._onDragLeftMove"); let templates = game.canvas.templates.children[0].children; for (let i = 0; i < templates.length; i++) { if (measureTemplateSupport && templates[i].ruler && templates[i].ruler.text.split("\n").length === 1) { @@ -103,8 +102,6 @@ Hooks.once('ready', () => { libWrapper.register("metric-ruler-labels", "TemplateLayer.prototype._onDragLeftMove", async function (wrapped, ...args) { let wrappedResult = await wrapped(...args); let measureTemplateSupport = game.settings.get("metric-ruler-labels", "measureTemplateSupport"); - //console.log("MeasuredTemplate.prototype.refresh"); - //console.log(wrappedResult); if (foundryGeneration < 10) { if (measureTemplateSupport && wrappedResult && wrappedResult.hud.ruler) { wrappedResult.hud.ruler.text = addMetricLabels(wrappedResult.hud.ruler.text); @@ -125,8 +122,7 @@ Hooks.once('ready', () => { //Handling of Ruler libWrapper.register("metric-ruler-labels", "Ruler.prototype.measure", function (wrapped, ...args) { let wrappedResult = wrapped(...args); - let dragRulerSupportActive = game.settings.get("metric-ruler-labels", "dragRulerSupport"); - //console.log("Ruler.prototype.measure"); + let dragRulerSupport = game.settings.get("metric-ruler-labels", "dragRulerSupport"); let foundryGeneration = game.release.generation; if (foundryGeneration < 10) { @@ -143,7 +139,7 @@ Hooks.once('ready', () => { segment = segment.prior_segment; } while (segment !== undefined && Object.keys(segment).length > 0); - } else if (dragRulerSupportActive && Array.isArray(wrappedResult) && wrappedResult.length > 0) { //Handling for Dragruler Support + } else if ((dragRulerSupport === "dragRulerSupport") && Array.isArray(wrappedResult) && wrappedResult.length > 0) { //Handling for Dragruler Support for (let i = 0; i < wrappedResult.length; i++) { wrappedResult[i].label.text = addMetricLabels(wrappedResult[i].label.text); wrappedResult[i].label.text = addConvertedLabels(wrappedResult[i].label.text); @@ -165,11 +161,10 @@ Hooks.once('ready', () => { return wrappedResult; }, 'WRAPPER'); - let dragRulerSupportActive = game.settings.get("metric-ruler-labels", "dragRulerSupport") - let pf2eDragRulerSupportActive = game.settings.get("metric-ruler-labels", "pf2eDragRulerSupport") + let dragRulerSupport = game.settings.get("metric-ruler-labels", "dragRulerSupport") //Dragruler p2fe game.canvas.dragRuler.rulers.children - if (foundryGeneration >= 10 && (dragRulerSupportActive || pf2eDragRulerSupportActive)) { + if (foundryGeneration >= 10 && (dragRulerSupport !== "noDragRulerSupport")) { //Handling of DragRuler V10 libWrapper.register("metric-ruler-labels", "Token.prototype._onDragLeftMove", function (wrapped, ...args) { @@ -179,14 +174,14 @@ Hooks.once('ready', () => { //Delay, so that drag-ruler does not overwrite setTimeout(function () { let rulers = []; - if (dragRulerSupportActive) { + if (dragRulerSupport === "dragRulerSupport") { rulers = game.canvas.controls.rulers.children; - } else if (pf2eDragRulerSupportActive) { + } else if (dragRulerSupport === "pf2eDragRulerSupport") { rulers = game.canvas.dragRuler.rulers.children; } for (let i = 0; i < rulers.length; i++) { - if ((rulers[i].isDragRuler && dragRulerSupportActive) || pf2eDragRulerSupportActive) { + if ((rulers[i].isDragRuler && dragRulerSupport === "dragRulerSupport") || (dragRulerSupport === "pf2eDragRulerSupport")) { let dragRulerSegments = rulers[i].segments; if (dragRulerSegments && Array.isArray(dragRulerSegments) && dragRulerSegments.length > 0) { for (let i = 0; i < dragRulerSegments.length; i++) { @@ -223,16 +218,13 @@ function registerSettings() { hint: "metric-ruler-labels.settings.dragRulerSupport.hint", scope: "client", config: true, - type: Boolean, - default: true, - }); - game.settings.register("metric-ruler-labels", "pf2eDragRulerSupport", { - name: "metric-ruler-labels.settings.pf2eDragRulerSupport.name", - hint: "metric-ruler-labels.settings.pf2eDragRulerSupport.hint", - scope: "client", - config: true, - type: Boolean, - default: true, + type: String, + default: "dragRulerSupport", + choices:{ + "noDragRulerSupport": "metric-ruler-labels.settings.dragRulerSupport.disabled", + "dragRulerSupport" : "Drag Ruler (by Staebchenfish)", + "pf2eDragRulerSupport" : "PF2e Token Drag Ruler (by 7H3LaughingMan)" + } }); game.settings.register("metric-ruler-labels", "hideFoundryMeasurement", { name: "metric-ruler-labels.settings.hideFoundryMeasurement.name",