diff --git a/CHANGELOG.md b/CHANGELOG.md index 82eef12..7bef632 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# Version 1.0.42 + +Fixed icon sizing for the HUD Terrain cost. + +Fixed issue setting settings when the canvas terrain layer doesn't exist yet. + +Fixed issues with adding the Terrain tab to various config dialogs. + # Version 1.0.41 Fixed issue where editing the colours in the settings was erasing all the colour information. diff --git a/classes/terrainlayer.js b/classes/terrainlayer.js index ee22a3f..56a5e81 100644 --- a/classes/terrainlayer.js +++ b/classes/terrainlayer.js @@ -131,7 +131,6 @@ export class TerrainLayer extends PlaceablesLayer { const hy = (canvas.grid.type == CONST.GRID_TYPES.GRIDLESS || options.ignoreGrid === true ? 0 : canvas.grid.h / 2); for (let pt of pts) { - let cost = null; let [gx, gy] = (canvas.grid.type == CONST.GRID_TYPES.GRIDLESS || options.ignoreGrid === true ? [pt.x, pt.y] : canvas.grid.grid.getPixelsFromGridPosition(pt.y, pt.x)); let tx = (gx + hx); diff --git a/js/settings.js b/js/settings.js index f295f4b..078a126 100644 --- a/js/settings.js +++ b/js/settings.js @@ -4,6 +4,7 @@ export const registerSettings = function () { let modulename = "enhanced-terrain-layer"; const debouncedReload = foundry.utils.debounce(function () { window.location.reload(); }, 100); + const debouncedRefresh = foundry.utils.debounce(function () { canvas.terrain.refresh(); }, 100); let imageoptions = { 'solid': 'Solid', @@ -38,9 +39,7 @@ export const registerSettings = function () { max: 1, step: 0.1 }, - onChange: () => { - canvas.terrain.refresh(); - } + onChange: debouncedRefresh }); game.settings.register(modulename, 'draw-border', { name: "EnhancedTerrainLayer.draw-border.name", @@ -49,9 +48,7 @@ export const registerSettings = function () { config: true, default: true, type: Boolean, - onChange: () => { - canvas.terrain.refresh(); - } + onChange: debouncedRefresh }); game.settings.register(modulename, 'terrain-image', { name: "EnhancedTerrainLayer.terrain-image.name", @@ -70,9 +67,7 @@ export const registerSettings = function () { config: true, default: false, type: Boolean, - onChange: () => { - canvas.terrain.refresh(); - } + onChange: debouncedRefresh }); game.settings.register(modulename, 'show-icon', { name: "EnhancedTerrainLayer.show-icon.name", @@ -81,9 +76,7 @@ export const registerSettings = function () { config: true, default: true, type: Boolean, - onChange: () => { - canvas.terrain.refresh(); - } + onChange: debouncedRefresh }); game.settings.register(modulename, 'show-on-drag', { name: "EnhancedTerrainLayer.show-on-drag.name", @@ -100,9 +93,7 @@ export const registerSettings = function () { config: true, default: false, type: Boolean, - onChange: () => { - canvas.terrain.refresh(); - } + onChange: debouncedRefresh }); game.settings.register(modulename, 'tokens-cause-difficult', { name: "EnhancedTerrainLayer.tokens-cause-difficult.name", diff --git a/module.json b/module.json index d6d1b28..65eb75d 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "name": "enhanced-terrain-layer", "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": "1.0.41", + "version": "1.0.42", "minimumCoreVersion": "9", "compatibleCoreVersion": "9", "author": "IronMonk", @@ -48,7 +48,7 @@ "styles": [ "css/terrainlayer.css" ], "packs": [], "url" : "https://github.com/ironmonk88/enhanced-terrain-layer", - "download" : "https://github.com/ironmonk88/enhanced-terrain-layer/archive/1.0.41.zip", + "download" : "https://github.com/ironmonk88/enhanced-terrain-layer/archive/1.0.42.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-hud.html b/templates/terrain-hud.html index b116a74..808fe80 100644 --- a/templates/terrain-hud.html +++ b/templates/terrain-hud.html @@ -1,7 +1,7 @@
- + {{{cost}}}
diff --git a/terrain-main.js b/terrain-main.js index 1e1ed2a..1fe0a83 100644 --- a/terrain-main.js +++ b/terrain-main.js @@ -432,18 +432,20 @@ Hooks.on('init', async () => { }); Hooks.on("ready", () => { - canvas.terrain._setting["opacity"] = setting("opacity"); - canvas.terrain._setting["draw-border"] = setting("draw-border"); - canvas.terrain._setting["terrain-image"] = setting("terrain-image"); - canvas.terrain._setting["show-text"] = setting("show-text"); - canvas.terrain._setting["show-icon"] = setting("show-icon"); - canvas.terrain._setting["show-on-drag"] = setting("show-on-drag"); - canvas.terrain._setting["only-show-active"] = setting("only-show-active"); - canvas.terrain._setting["tokens-cause-difficult"] = setting("tokens-cause-difficult"); - canvas.terrain._setting["dead-cause-difficult"] = setting("dead-cause-difficult"); - canvas.terrain._setting["use-obstacles"] = setting("use-obstacles"); - canvas.terrain._setting["minimum-cost"] = setting("minimum-cost"); - canvas.terrain._setting["maximum-cost"] = setting("maximum-cost"); + if (canvas.terrain) { + canvas.terrain._setting["opacity"] = setting("opacity"); + canvas.terrain._setting["draw-border"] = setting("draw-border"); + canvas.terrain._setting["terrain-image"] = setting("terrain-image"); + canvas.terrain._setting["show-text"] = setting("show-text"); + canvas.terrain._setting["show-icon"] = setting("show-icon"); + canvas.terrain._setting["show-on-drag"] = setting("show-on-drag"); + canvas.terrain._setting["only-show-active"] = setting("only-show-active"); + canvas.terrain._setting["tokens-cause-difficult"] = setting("tokens-cause-difficult"); + canvas.terrain._setting["dead-cause-difficult"] = setting("dead-cause-difficult"); + canvas.terrain._setting["use-obstacles"] = setting("use-obstacles"); + canvas.terrain._setting["minimum-cost"] = setting("minimum-cost"); + canvas.terrain._setting["maximum-cost"] = setting("maximum-cost"); + } }); Hooks.on('renderMeasuredTemplateConfig', (app, html, data) => { @@ -453,13 +455,16 @@ Hooks.on('renderMeasuredTemplateConfig', (app, html, data) => { $('.sheet-tabs', html).append($('').addClass("item").attr("data-tab", "terrain").html(' Terrain')); tab = $('
').addClass("tab action-sheet").attr('data-tab', 'terrain').insertAfter($('.tab:last', html)); } else { + let root = $('form', html); + if (root.length == 0) + root = html; let basictab = $('
').addClass("tab").attr('data-tab', 'basic'); - $('form > *:not(button)', html).each(function () { + $('> *:not(button)', root).each(function () { basictab.append(this); }); tab = $('
').addClass("tab action-sheet").attr('data-tab', 'terrain'); - $('form', html).prepend(tab).prepend(basictab).prepend( + $(root).prepend(tab).prepend(basictab).prepend( $('