Skip to content

Commit

Permalink
updating controls
Browse files Browse the repository at this point in the history
  • Loading branch information
IronMonk88 committed Feb 28, 2021
1 parent c2cd4e4 commit 423ea3a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 57 deletions.
98 changes: 42 additions & 56 deletions js/controls.js
Original file line number Diff line number Diff line change
@@ -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: '<i class="fas fa-trash"></i>',
label: 'Reset',
callback: () => canvas.terrain.resetGrid(true),
},

cancel: {
icon: '<i class="fas fa-times"></i>',
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) {
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 423ea3a

Please sign in to comment.