From 8b99ac8ee6f9c66eb63196d80424ef9cd96d6f8a Mon Sep 17 00:00:00 2001 From: flamewave000 <3588046+flamewave000@users.noreply.github.com> Date: Mon, 7 Mar 2022 22:26:51 -0500 Subject: [PATCH] templates: Fix grid highlight when targeting off Fixes #322 --- df-templates/CHANGELOG.md | 1 + df-templates/lang/en.json | 4 ++-- df-templates/module.json | 2 +- df-templates/src/TemplateTargeting.ts | 10 +++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/df-templates/CHANGELOG.md b/df-templates/CHANGELOG.md index 79730d4..ac19bf5 100644 --- a/df-templates/CHANGELOG.md +++ b/df-templates/CHANGELOG.md @@ -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) diff --git a/df-templates/lang/en.json b/df-templates/lang/en.json index 6dc8fa3..0da3607 100644 --- a/df-templates/lang/en.json +++ b/df-templates/lang/en.json @@ -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)", diff --git a/df-templates/module.json b/df-templates/module.json index 0155ec9..db2f2c5 100644 --- a/df-templates/module.json +++ b/df-templates/module.json @@ -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", diff --git a/df-templates/src/TemplateTargeting.ts b/df-templates/src/TemplateTargeting.ts index bced1d7..a00b4cc 100644 --- a/df-templates/src/TemplateTargeting.ts +++ b/df-templates/src/TemplateTargeting.ts @@ -490,11 +490,15 @@ export default class TemplateTargeting { } } - if (!contains) continue; - grid.grid.highlightGridPosition(hl, { x: gx, y: gy, border, color: 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: 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);