Skip to content

Commit

Permalink
templates: Fix grid highlight when targeting off
Browse files Browse the repository at this point in the history
Fixes #322
  • Loading branch information
flamewave000 committed Mar 8, 2022
1 parent ed189cf commit 8b99ac8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions df-templates/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Release 1.0.1 (2022-03-07)
- **FIX #325:** Token targeting will no longer be affected by token image scale.
- **FIX #323:** Intersection snapping will no longer bypass setting when placing a spell template in D&D5e.
- **FIX #322:** Grid highlighting was erroneously exiting early after highlighting the first square when Auto-Target was turned off.

## Release 1.0.0 (2022-03-06)

Expand Down
4 changes: 2 additions & 2 deletions df-templates/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"GridlessPointResolutionHint": "How many points along each axis to generate for auto-targetting in gridless scenes. A higher number might cause slower performance with lots of tokens in a scene.",
"PreviewName": "Preview Template Highlight/Targeting",
"PreviewHint": "Show the grid highlight and perform auto-targeting when moving or creating a template.",
"DebugName": "[DEBUG Only] Display Auto-Target Point Grids",
"DebugHint": "For the purposes of debugging the auto-targetting feature, this option will display the points used for detecting token targetting in a gridless scene.",
"DebugName": "[DEBUG Only] Display Auto-Target Point Grids and Test Grids",
"DebugHint": "For the purposes of debugging the auto-targetting feature, this option will display the points used for detecting token targeting in a gridless scene. Or will display the entire test zone for grid highlighting.",
"Patch5e_Name": "Use D&D 5e Style Templates",
"Patch5e_Hint": "Core Foundry requires a grid square's center to be inside a template to be affected. This adjusts templates to follow the D&D5e rules for targeting grid squares where any square TOUCHED by a template is hit (with the exception of circles).",
"Patch5e_Circle_Name": "Make Circle Templates Greedy (Requires D&D 5e Style Templates)",
Expand Down
2 changes: 1 addition & 1 deletion df-templates/module.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "df-templates",
"version": "1.0.0",
"version": "1.0.1",
"title": "DF Template Enhancements",
"description": "Enhanced templates for different types of grid targetting.",
"author": "flamewave000#0001",
Expand Down
10 changes: 7 additions & 3 deletions df-templates/src/TemplateTargeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,15 @@ export default class TemplateTargeting {
}
}

if (!contains) continue;
grid.grid.highlightGridPosition(hl, { x: gx, y: gy, border, color: <any>color });
const DEBUG = SETTINGS.get('template-debug');
if (!DEBUG && !contains) continue;
if (DEBUG)
grid.grid.highlightGridPosition(hl, { x: gx, y: gy, border, color: contains ? 0x00FF00 : 0xFF0000 });
else
grid.grid.highlightGridPosition(hl, { x: gx, y: gy, border, color: <number>color });

// Ignore changing the target selection if we don't own the template, or `shouldAutoSelect` is false
if (!isOwner || !shouldAutoSelect) return;
if (!isOwner || !shouldAutoSelect) continue;
// Iterate over all existing tokens and target the ones within the template area
for (const token of canvas.tokens.placeables) {
const tokenRect = new NormalizedRectangle(token.x, token.y, token.w, token.h);
Expand Down

0 comments on commit 8b99ac8

Please sign in to comment.