Skip to content

Commit

Permalink
Merge pull request #49 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 3dede8a + 540ad96 commit 69228e3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ It adds additional labels for the metric measurements to your ruler. It is not c

## NEW --- NEW --- NEW
You can now add your [Customizable Measurement Conversions](#customizable-conversions) and [Travel times](#travel-times) if you want :) Have fun!
Compatability with V11!!!
Compatability with V12!!!

## V12 - Compatability
The latest version is compatible with V12. If you find problems with future subversions of V12, then please let me know.
Expand Down Expand Up @@ -109,6 +109,11 @@ 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.0**
- Compatibility for PF2e Token Drag Ruler (and build in Drag Ruler of the pathfinder system)
- Italian Language Support (Thx to GregoryWarn)
- Fixed warning for unsupported manifest field

**v3.2.0**
- V12 Compatibility

Expand Down
4 changes: 4 additions & 0 deletions languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"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)"
},
"measureTemplateSupport": {
"name": "Anzeige bei Schablonen",
"hint": "Falls aktiviert, werden zusätzliche metrische Angaben bei Benutzung der Schablonen/Formen (Kegel, Kreis, Rechteck, Strahl) angezeigt."
Expand Down
4 changes: 4 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"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) "
},
"measureTemplateSupport": {
"name": "Show on Measure Templates",
"hint": "When enabled, additional metric units are also shown when using the measure templates (circle, cone, ray, rectangle)."
Expand Down
4 changes: 4 additions & 0 deletions languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"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) "
},
"measureTemplateSupport": {
"name": "Mostra in Measure Templates",
"hint": "Se abilitato, vengono visualizzate anche unità metriche aggiuntive quando si utilizzano i modelli di misura (cerchio, cono, raggio, rettangolo)."
Expand Down
25 changes: 20 additions & 5 deletions scripts/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ Hooks.once('ready', () => {
libWrapper.register("metric-ruler-labels", "CONFIG.MeasuredTemplate.layerClass.prototype._onDragLeftDrop", async function (wrapped, ...args) {
let wrappedResult = await wrapped(...args);
let measureTemplateSupport = game.settings.get("metric-ruler-labels", "measureTemplateSupport");
//console.log("MeasuredTemplate.prototype._onDragLeftMove");
//console.log(wrappedResult);
let rulers = game.canvas.controls.rulers.children;
for (let i = 0; i < rulers.length; i++) {
let rulerSegments = rulers[i].segments
Expand Down Expand Up @@ -168,8 +166,10 @@ Hooks.once('ready', () => {
}, 'WRAPPER');

let dragRulerSupportActive = game.settings.get("metric-ruler-labels", "dragRulerSupport")
let pf2eDragRulerSupportActive = game.settings.get("metric-ruler-labels", "pf2eDragRulerSupport")

if (foundryGeneration >= 10 && dragRulerSupportActive) {
//Dragruler p2fe game.canvas.dragRuler.rulers.children
if (foundryGeneration >= 10 && (dragRulerSupportActive || pf2eDragRulerSupportActive)) {

//Handling of DragRuler V10
libWrapper.register("metric-ruler-labels", "Token.prototype._onDragLeftMove", function (wrapped, ...args) {
Expand All @@ -178,9 +178,15 @@ Hooks.once('ready', () => {

//Delay, so that drag-ruler does not overwrite
setTimeout(function () {
let rulers = game.canvas.controls.rulers.children;
let rulers = [];
if (dragRulerSupportActive) {
rulers = game.canvas.controls.rulers.children;

} else if (pf2eDragRulerSupportActive) {
rulers = game.canvas.dragRuler.rulers.children;
}
for (let i = 0; i < rulers.length; i++) {
if (rulers[i].isDragRuler) {
if ((rulers[i].isDragRuler && dragRulerSupportActive) || pf2eDragRulerSupportActive) {
let dragRulerSegments = rulers[i].segments;
if (dragRulerSegments && Array.isArray(dragRulerSegments) && dragRulerSegments.length > 0) {
for (let i = 0; i < dragRulerSegments.length; i++) {
Expand All @@ -195,6 +201,7 @@ Hooks.once('ready', () => {
}
}
}, 60);

return wrappedResult;
}, 'WRAPPER');
}
Expand All @@ -219,6 +226,14 @@ function registerSettings() {
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,
});
game.settings.register("metric-ruler-labels", "hideFoundryMeasurement", {
name: "metric-ruler-labels.settings.hideFoundryMeasurement.name",
hint: "metric-ruler-labels.settings.hideFoundryMeasurement.hint",
Expand Down

0 comments on commit 69228e3

Please sign in to comment.