Skip to content

Commit

Permalink
Merge pull request #51 from Roger92/devRoger
Browse files Browse the repository at this point in the history
Dev roger
  • Loading branch information
Roger92 authored Aug 18, 2024
2 parents 7894fe2 + 0322a81 commit e945082
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 37 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 2 additions & 5 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 2 additions & 5 deletions languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
36 changes: 14 additions & 22 deletions scripts/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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++) {
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit e945082

Please sign in to comment.