Skip to content

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
caewok committed Jul 10, 2021
2 parents 8566abc + 3693e5c commit dba21ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.2.1
Catch when no Levels tiles are present under the ruler position, so that Levels floor labels do not appear unnecessarily.

## 0.2.0
Add levels measurement function
- When over a levels tile, default to the bottom elevation of that tile.
Expand Down
9 changes: 7 additions & 2 deletions scripts/segments.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ UX goals:
}

if(game.settings.get(MODULE_ID, "enable-levels-floor-label")) {
this.setFlag(MODULE_ID, "elevation_level_name", LevelNameAtPoint(this.ray.B, ending_elevation));
const level_name = LevelNameAtPoint(this.ray.B, ending_elevation);
log(`Level name for segment ${this.segment_num} is ${level_name}`);

this.setFlag(MODULE_ID, "elevation_level_name", level_name);
}
this.setFlag(MODULE_ID, "starting_elevation", starting_elevation);
this.setFlag(MODULE_ID, "ending_elevation", ending_elevation);
Expand Down Expand Up @@ -198,6 +201,8 @@ export function elevationRulerGetText(wrapped, ...args) {
let elevation_label = segmentElevationLabel(ending_elevation - starting_elevation, ending_elevation);
if(game.settings.get(MODULE_ID, "enable-levels-floor-label")) {
const level_name = this.getFlag(MODULE_ID, "elevation_level_name");
log(`elevationRulerGetText: Level name is ${level_name}`);

if(level_name) {
elevation_label += `\n${level_name}`;
}
Expand Down Expand Up @@ -343,7 +348,7 @@ function LevelNameAtPoint(p, zz) {
}

const floors = _levels.getFloorsForPoint(p);
if(!floors) { return undefined; }
if(!floors || floors.length < 1) { return undefined; }

const levels_data = canvas.scene.getFlag("levels", "sceneLevels") // array with [0]: bottom; [1]: top; [2]: name
for(let l of levels_data) {
Expand Down

0 comments on commit dba21ec

Please sign in to comment.