From 598e323689efc126a9d4287e938a4fa9314eb3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Mon, 7 Dec 2020 21:09:20 +0100 Subject: [PATCH] Tint secret doors in grey for the GM --- CHANGELOG.md | 4 ++++ README.md | 14 ++++++++++---- lang/en.json | 4 ++++ main.js | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d62b6e..40677a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.1.0 (in development) +### New features +- Tint secret doors grey for the GM to differentiate them from regular doors + ## v1.0.1 - When adding a door to a synchronization group adjust it's state to bring it in sync with the other doors - Use the players character as speaker for the Locked Door Alert diff --git a/README.md b/README.md index 078b9ae..77e7d49 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,21 @@ Makes doors smarter. Allows doors to synchronize across multiple scenes and send ## Feature overview -### Locked door alerts -![Locked door alerts demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/360d724240634dbc6cc493a3b62243a8b28b7056/media/locked_door_alert.webp) +### Tint Secret Doors +![Tint Secret Doors demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/dc5d328cd9bc4a0e2aacc5c86ab59e15739cc6d1/media/tint_secret_doors.webp) + +Which where the secret doors again? This tints all secret doors grey in the GM view, allowing to easily differentiate between normal and secret doors. + + +### Locked Door Alerts +![Locked Door Alerts demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/360d724240634dbc6cc493a3b62243a8b28b7056/media/locked_door_alert.webp) Keep everyone informed who tried to open which door. Whenever a player tries to open a door that is locked, a chat message stating that fact will be sent to all players. Additionally the door locked sound will be played for everyone. When the chat message is hovered with the mouse, the door that the player tried to open will be highlighted. If the GM tries to open a locked door the sound will only played for him and no chat message will be sent. -### Synchronized doors -![Synchronized doors demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/360d724240634dbc6cc493a3b62243a8b28b7056/media/synchronized_doors.webp) +### Synchronized Doors +![Synchronized Doors demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/360d724240634dbc6cc493a3b62243a8b28b7056/media/synchronized_doors.webp) Keep multiple doors in sync - even across different scenes. Example use cases: - A tavern has an outdoor and an indoor scene. If a player opens the entrance door on the outdoor map, the entrance door in the indoor map will be opened as well diff --git a/lang/en.json b/lang/en.json index 83e0149..9a7c523 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1,6 +1,10 @@ { "smart-doors": { "settings": { + "highlightSecretDoors": { + "name": "Tint Secret Doors", + "hint": "Shade secret doors in a different color on the gm screen to differentiate them from normal doors" + }, "lockedDoorAlert": { "name": "Locked Door Alert", "hint": "Send a message in chat when a player tried to open a locked door" diff --git a/main.js b/main.js index 13360b9..a16fd09 100644 --- a/main.js +++ b/main.js @@ -37,6 +37,31 @@ Hooks.on("renderChatMessage", (message, html, data) => { html.on("mouseleave", mouseLeave); }) +const SECRET_DOOR_TINT = 0x222222 + +// Tint all secret doors dark grey +Hooks.on("canvasReady", () => { + if (game.settings.get(settingsKey, "highlightSecretDoors")) { + const types = CONST.WALL_DOOR_TYPES + const secretDoors = canvas.controls.doors.children.filter(control => control.wall.data.door == types.SECRET) + secretDoors.forEach(control => control.icon.tint = SECRET_DOOR_TINT) + } +}) + +// If door type has been changed, tint the door accordingly +Hooks.on("updateWall", (scene, wall, update) => { + const types = CONST.WALL_DOOR_TYPES + if (wall.door === types.NONE) + return + const changedDoor = canvas.controls.doors.children.find(control => control.wall.data._id === wall._id); + if (wall.door === types.DOOR) + changedDoor.icon.tint = 0xFFFFFF + else if (wall.door === types.SECRET) + changedDoor.icon.tint = SECRET_DOOR_TINT + else + console.warn("Smart Doors | Encountered unknown door type " + wall.door + " while highlighting secret doors.") +}) + // Inject our custom settings into the WallConfig dialog Hooks.on("renderWallConfig", (wallConfig, html, data) => { // Settings for synchronized doors @@ -272,6 +297,11 @@ function performMigrations() { ui.notifications.error(game.i18n.localize("smart-doors.ui.messages.unknownVersion"), {permanent: true}) } +function reloadGM() { + if (game.user.isGM) + location.reload() +} + function registerSettings() { game.settings.register(settingsKey, "dataVersion", { scope: "world", @@ -279,6 +309,15 @@ function registerSettings() { type: String, default: "fresh install" }) + game.settings.register(settingsKey, "highlightSecretDoors", { + name: "smart-doors.settings.highlightSecretDoors.name", + hint: "smart-doors.settings.highlightSecretDoors.hint", + scope: "world", + config: true, + type: Boolean, + default: true, + onChange: reloadGM, + }) game.settings.register(settingsKey, "lockedDoorAlert", { name: "smart-doors.settings.lockedDoorAlert.name", hint: "smart-doors.settings.lockedDoorAlert.hint",