From 423ea3a30760485ebe2523a10338167a6fbc2789 Mon Sep 17 00:00:00 2001 From: IronMonk88 Date: Sat, 27 Feb 2021 16:35:55 -0800 Subject: [PATCH] updating controls --- js/controls.js | 98 ++++++++++++++++++++++---------------------------- module.json | 2 +- 2 files changed, 43 insertions(+), 57 deletions(-) diff --git a/js/controls.js b/js/controls.js index c30af2b..d98db58 100644 --- a/js/controls.js +++ b/js/controls.js @@ -1,61 +1,47 @@ +import { TerrainLayerToolBar } from '../classes/terraincontrols.js'; + Hooks.on('getSceneControlButtons', (controls) => { - if (game.user.isGM && canvas != null) { - controls.push({ - name: 'terrain', - title: game.i18n.localize('EM.sf'), - icon: 'fas fa-mountain', - layer: 'TerrainLayer', - tools: [ - { - name: 'terraintoggle', - title: game.i18n.localize('EM.onoff'), - icon: 'fas fa-eye', - onClick: () => { - canvas.terrain.toggle(true); - }, - active: canvas.terrain.highlight.children[0].visible, - toggle: true - }, - { - name: 'addterrain', - title:'EM.select', - icon:'fas fa-plus-square' - }, - { - name:'subtractterrain', - title:'EM.subtract', - icon:'fas fa-minus-square' + const isGM = game.user.isGM; + controls.push({ + name: 'terrain', + title: game.i18n.localize('TerrainLayer.sf'), + icon: 'fas fa-mountain', + visible: isGM, + layer: 'TerrainLayer', + activeTool: 'select', + tools: [ + { + name: 'select', + title: 'TerrainLayer.select', + icon: 'fas fa-expand' + }, + { + name: 'addterrain', + title: 'TerrainLayer.add', + icon: 'fas fa-marker' + }, + { + name: 'terraintoggle', + title: game.i18n.localize('TerrainLayer.onoff'), + icon: 'fas fa-eye', + onClick: () => { + canvas.terrain.toggle(null, true); }, - { - name: 'clearterrain', - title: game.i18n.localize('EM.reset'), - icon: 'fas fa-trash', - onClick: () => { - const dg = new Dialog({ - title: game.i18n.localize('EM.reset'), - content: game.i18n.localize('EM.confirmReset'), - buttons: { - reset: { - icon: '', - label: 'Reset', - callback: () => canvas.terrain.resetGrid(true), - }, - - cancel: { - icon: '', - label: 'Cancel', - }, - }, - default: 'cancel', - }); - dg.render(true); - }, - button: true, - }, - ], - activeTool:'addterrain' - }) - } + active: (canvas?.terrain?.showterrain || game.settings.get("TerrainLayer", "showterrain")), + toggle: true + }, + { + name: 'clearterrain', + title: game.i18n.localize('TerrainLayer.reset'), + icon: 'fas fa-trash', + visible: isGM, + onClick: () => canvas.terrain.deleteAll(), + button: true, + } + ] + }); + //show the terrain if show button is toggled, or if the current tool is the terrain tool + //canvas.terrain.highlight.children[0].visible = (canvas.terrain.showterrain || controls["terrain"].active); }); Hooks.on('renderSceneControls', (controls) => { if (canvas != null) { diff --git a/module.json b/module.json index f1b9b23..320b827 100644 --- a/module.json +++ b/module.json @@ -31,6 +31,6 @@ "socket":true, "url":"https://github.com/ironmonk88/TerrainLayer", "changelog":"https://raw.githubusercontent.com/ironmonk88/TerrainLayer/main/README.md", - "download": "https://github.com/ironmonk88/TerrainLayer/archive/1.0.2.zip", + "download": "https://github.com/ironmonk88/TerrainLayer/archive/1.0.2.zip", "manifest": "https://github.com/ironmonk88/TerrainLayer/releases/download/1.0.2/module.json" }