diff --git a/CHANGELOG.md b/CHANGELOG.md index b55099c..4fde79f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,27 @@ +# Version 10.6 + +Fixed issue refreshing the terrain shape if the shape doesn't exist + +Added opacity as a default value when creating terrain. + +Fixed issue when treying to use the get function on the terrain layer to get terrain information + +Fixed issue with getting terrain info from measured templates + +Fixed issues with getting terrain from grid and pixels, with the missing options property + +Fixed issues with double-clicking to create a hex terrain. + +Added the option to have the measured template created from a spell template, get the colour from the default environment colour. + +Fixed the terrain config interface so that the default values are used as placeholders + +Fixed issue with Midi Qol settings being inserted between the terrain header and settings. + +Fixed issues with the terrain tab not shrinking to fit the contents when Token Magic FX is enabled. + +Add a Rules Provider API, so systems and modules can register how they want difficult terrain to be calculated. Thank you Stäbchenfisch!! + # Version 10.5 Fixed an issue with determining when a token causes difficult terrain. diff --git a/classes/terrain.js b/classes/terrain.js index 513ae61..7382ed0 100644 --- a/classes/terrain.js +++ b/classes/terrain.js @@ -301,7 +301,8 @@ export class Terrain extends PlaceableObject { const { x, y, hidden, shape } = this.document; // Refresh the primary drawing container - this.shape.refresh(); + if (this.shape) + this.shape.refresh(); //this.shape.position.set(shape.width / 2, shape.height / 2); const bounds = new PIXI.Rectangle(0, 0, shape.width, shape.height).normalize(); @@ -381,12 +382,13 @@ export class Terrain extends PlaceableObject { let sceneElev = sceneFlags?.elevation; let sceneDepth = sceneFlags?.depth; let sceneEnv = sceneFlags?.environment; + let sceneOpacity = sceneFlags?.opacity; return { //rotation:0, locked: false, hidden: false, //drawcolor: setting('environment-color')[sceneEnv] || getflag(canvas.scene, 'defaultcolor') || setting('environment-color')['_default'] || "#FFFFFF", - //opacity: getflag(canvas.scene, 'opacity') ?? setting('opacity') ?? 1, + opacity: (sceneOpacity == undefined || sceneOpacity == "" ? setting('opacity') ?? 1 : sceneOpacity), multiple: (sceneMult == undefined || sceneMult == "" ? this.layer.defaultmultiple : Math.clamped(parseInt(sceneMult), setting('minimum-cost'), setting('maximum-cost'))), elevation: (sceneElev == undefined || sceneElev == "" ? 0 : sceneElev), depth: (sceneDepth == undefined || sceneDepth == "" ? 0 : sceneDepth), diff --git a/classes/terrainlayer.js b/classes/terrainlayer.js index 9967f91..1b3afda 100644 --- a/classes/terrainlayer.js +++ b/classes/terrainlayer.js @@ -66,6 +66,10 @@ export class TerrainLayer extends PlaceablesLayer { return canvas["#scene"].terrain || null; } + get(objectId) { + return canvas["#scene"].terrain?.get(objectId)?.object || undefined; + } + get gridPrecision() { let size = canvas.dimensions.size; if (size >= 128) return 16; @@ -202,7 +206,7 @@ export class TerrainLayer extends PlaceablesLayer { const terrainInfos = options.list || []; for (const template of canvas.templates.placeables) { - const terrainFlag = getProperty(template, "flags.enhanced-terrain-layer"); + const terrainFlag = getProperty(template.document, "flags.enhanced-terrain-layer"); if (!terrainFlag) continue; const terraincost = terrainFlag.multiple ?? 1; @@ -293,12 +297,12 @@ export class TerrainLayer extends PlaceablesLayer { return this.costWithTerrain(pts, terrain, options); } - terrainFromGrid(x, y) { + terrainFromGrid(x, y, options = {}) { let [gx, gy] = canvas.grid.grid.getPixelsFromGridPosition(y, x); - return this.terrainFromPixels(gx, gy); + return this.terrainFromPixels(gx, gy, options); } - terrainFromPixels(x, y) { + terrainFromPixels(x, y, options = {}) { const hx = (x + (canvas.dimensions.size / 2)); const hy = (y + (canvas.dimensions.size / 2)); @@ -492,8 +496,8 @@ export class TerrainLayer extends PlaceablesLayer { return this._onDragLeftDrop(event); } else if (createState == 0 || createState == undefined) { //add a default square - let gW = canvas.dimensions.size; - let gH = canvas.dimensions.size; + let gW = canvas.grid.grid.w; + let gH = canvas.grid.grid.h; //let pos = canvas.grid.getSnappedPosition(event.data.origin.x, event.data.origin.y, 1); let [tX, tY] = canvas.grid.grid.getGridPositionFromPixels(event.data.origin.x, event.data.origin.y); diff --git a/js/settings.js b/js/settings.js index 1fdaad1..146040c 100644 --- a/js/settings.js +++ b/js/settings.js @@ -129,6 +129,14 @@ export const registerSettings = function () { default: false, type: Boolean }); + game.settings.register(modulename, 'transfer-color', { + name: "EnhancedTerrainLayer.transfer-color.name", + hint: "EnhancedTerrainLayer.transfer-color.hint", + scope: "world", + config: game.system.id == 'dnd5e', + default: false, + type: Boolean + }); game.settings.register(modulename, 'minimum-cost', { name: "EnhancedTerrainLayer.minimum-cost.name", hint: "EnhancedTerrainLayer.minimum-cost.hint", diff --git a/lang/en.json b/lang/en.json index 63f64d2..58c25f3 100644 --- a/lang/en.json +++ b/lang/en.json @@ -57,6 +57,9 @@ "EnhancedTerrainLayer.terrain-image.hint": "Change the background texture for terrain", "EnhancedTerrainLayer.rule-provider.name": "Rule provider", "EnhancedTerrainLayer.rule-provider.hint": "Which rule provider should Enhanced Terrain Layer pull it's terrain rules from", + "EnhancedTerrainLayer.transfer-color.name": "Transfer spell colour", + "EnhancedTerrainLayer.transfer-color.hint": "When casting a spell that causes difficult terrain, transfer the default environment colour to the measured template.", + "EnhancedTerrainLayer.rule-provider.choices.builtin": "Built-in", "EnhancedTerrainLayer.rule-provider.choices.module": "Module {name}", "EnhancedTerrainLayer.rule-provider.choices.system": "System {name}", diff --git a/module.json b/module.json index 9a7b2c7..c5c8453 100644 --- a/module.json +++ b/module.json @@ -1,7 +1,7 @@ { "title": "Enhanced Terrain Layer", "description": "A base module that adds a Terrain Layer to Foundry. Used as a library for Rulers and other modules", - "version": "10.5", + "version": "10.6", "authors": [ { "name": "IronMonk", @@ -47,7 +47,7 @@ "css/terrainlayer.css" ], "url": "https://github.com/ironmonk88/enhanced-terrain-layer", - "download": "https://github.com/ironmonk88/enhanced-terrain-layer/archive/10.5.zip", + "download": "https://github.com/ironmonk88/enhanced-terrain-layer/archive/10.6.zip", "manifest": "https://github.com/ironmonk88/enhanced-terrain-layer/releases/latest/download/module.json", "bugs": "https://github.com/ironmonk88/enhanced-terrain-layer/issues", "allowBugReporter": true, diff --git a/templates/terrain-form.html b/templates/terrain-form.html index bd4929b..193eb33 100644 --- a/templates/terrain-form.html +++ b/templates/terrain-form.html @@ -1,26 +1,24 @@ {{#if full}} +
Set the default settings when terrain is created on this scene
Set the opacity for all terrain on this scene
Set the default settings when terrain is created on this scene
{{/if}}