From 408eee8bc0c4d618edb9ef7a59f63c0393565adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Mon, 7 Dec 2020 23:06:53 +0100 Subject: [PATCH] Toggle between secret and normal door by ctrl+left click --- CHANGELOG.md | 1 + README.md | 6 ++++++ lang/en.json | 4 ++++ main.js | 23 +++++++++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40677a4..eb108dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## v1.1.0 (in development) ### New features - Tint secret doors grey for the GM to differentiate them from regular doors +- Toggle doors between secret and normal with ctrl+click ## v1.0.1 - When adding a door to a synchronization group adjust it's state to bring it in sync with the other doors diff --git a/README.md b/README.md index 77e7d49..3b92ab1 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,12 @@ Makes doors smarter. Allows doors to synchronize across multiple scenes and send 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. +### Toggle Secret Doors +![Toggle Secret Doors demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/da5872042ea81e2f41875a193d161331a81a2b6d/media/secret_door_toggle.webp) + +Easily reveal secret doors to players. Strg+left click secrets doors to turn them into regular doors. Strg+left click can also be done on normal doors to turn them into secret doors. Using this in combination with Tint Secret Doors is recommended so you can actually see what you are doing. + + ### Locked Door Alerts ![Locked Door Alerts demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/360d724240634dbc6cc493a3b62243a8b28b7056/media/locked_door_alert.webp) diff --git a/lang/en.json b/lang/en.json index 9a7c523..a64f0b7 100644 --- a/lang/en.json +++ b/lang/en.json @@ -12,6 +12,10 @@ "synchronizedDoors": { "name": "Synchronized Doors", "hint": "Synchronize the state of configured doors" + }, + "toggleSecretDoors": { + "name": "Toggle Secret Doors", + "hint": "Toggle the door type between normal and secret using ctrl+left click" } }, "ui": { diff --git a/main.js b/main.js index a16fd09..42e5375 100644 --- a/main.js +++ b/main.js @@ -168,6 +168,9 @@ function onDoorMouseDown(event) { if ( game.paused && !game.user.isGM ) return false + if (toggleSecretDoorLeftClick.call(this, event)) + return true + if (lockedDoorAlertLeftClick.call(this)) return true @@ -179,12 +182,24 @@ function onDoorMouseDown(event) { // Our custom handler for rightdown events on doors function onDoorRightDown(event) { + if (synchronizedDoorsRightClick.call(this)) return true return false } +// Toggles between normal and secret doors +function toggleSecretDoorLeftClick(event) { + if (event.data.originalEvent.ctrlKey && game.user.isGM && game.settings.get(settingsKey, "toggleSecretDoors")) { + const types = CONST.WALL_DOOR_TYPES + const newtype = this.wall.data.door === types.DOOR ? types.SECRET : types.DOOR + this.wall.update({door: newtype}) + return true + } + return false +} + // Creates a chat message stating that a player tried to open a locked door function lockedDoorAlertLeftClick() { const state = this.wall.data.ds @@ -318,6 +333,14 @@ function registerSettings() { default: true, onChange: reloadGM, }) + game.settings.register(settingsKey, "toggleSecretDoors", { + name: "smart-doors.settings.toggleSecretDoors.name", + hint: "smart-doors.settings.toggleSecretDoors.hint", + scope: "world", + config: true, + type: Boolean, + default: true, + }) game.settings.register(settingsKey, "lockedDoorAlert", { name: "smart-doors.settings.lockedDoorAlert.name", hint: "smart-doors.settings.lockedDoorAlert.hint",