From 5f1e04efc34a57164968297c0e541ddc2e8852ec Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 10 Dec 2023 20:04:07 +0100 Subject: [PATCH] Attempted wrapping of hook --- on-site-vtt/module.json | 4 ++-- on-site-vtt/scripts/on-site-vtt.js | 27 +++++++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/on-site-vtt/module.json b/on-site-vtt/module.json index 65e42d7..6ae2748 100644 --- a/on-site-vtt/module.json +++ b/on-site-vtt/module.json @@ -2,7 +2,7 @@ "id": "on-site-vtt", "title": "On-Site VTT - Virtual Tabletop, now with less virtual", "description": "A simple module adding functionality to improve playability for multiple players on a single screen/digital map.", - "version": "0.0.3", + "version": "0.0.4", "compatibility": { "minimum": "10", "verified": "11" @@ -27,7 +27,7 @@ ], "url": "https://gitea.aweleczka.de/aweleczka/On-Site-VTT", "manifest": "https://gitea.aweleczka.de/aweleczka/On-Site-VTT/raw/branch/main/on-site-vtt/module.json", - "download": "https://gitea.aweleczka.de/aweleczka/On-Site-VTT/archive/0.0.3.zip", + "download": "https://gitea.aweleczka.de/aweleczka/On-Site-VTT/archive/0.0.4.zip", "bugs": "https://gitea.aweleczka.de/aweleczka/On-Site-VTT/issues", "readme": "https://gitea.aweleczka.de/aweleczka/On-Site-VTT/raw/branch/main/README.md", "license" :"https://gitea.aweleczka.de/aweleczka/On-Site-VTT/raw/branch/main/LICENSE.txt", diff --git a/on-site-vtt/scripts/on-site-vtt.js b/on-site-vtt/scripts/on-site-vtt.js index 0fa3352..9d9c97a 100644 --- a/on-site-vtt/scripts/on-site-vtt.js +++ b/on-site-vtt/scripts/on-site-vtt.js @@ -1,14 +1,21 @@ -Hooks.on('init', function () { - Hooks.on('getSceneControlButtons', (controls: SceneControl[]) => { - controls.find(x => x.name === 'token').tools.push({ - name: 'rotateView', - title: 'on-site-vtt.rotate', - icon: 'fas fa-refresh', - onClick: () => rotateView(), - button: true - }); +if(game.modules.get("on-site-vtt")?.active) { + Hooks.on("init", function () { + Hooks.on( + "getSceneControlButtons", + (controls: SceneControl[]) => { + controls.find(x => x.name === 'token').tools.push({ + name: "rotateView", + title: "on-site-vtt.rotate", + icon: "fas fa-refresh", + visible: true, + toggle: false, + active: false, + button: true, + onClick: () => rotateView(), + }); + }); }); -}); +} function rotateView() { if(document.getElementsByTagName("body")[0].className.includes("nsvRotate")) {