Update code for Foundry 9

This commit is contained in:
2022-01-05 11:49:14 +01:00
parent cf3cbb892c
commit 3dbaf84db3
7 changed files with 30 additions and 17 deletions

View File

@@ -13,7 +13,7 @@ Door Control icons will be rendered the same size in every scene, regardless of
### Toggle Secret Doors ### Toggle Secret Doors
![Toggle Secret Doors demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/da5872042ea81e2f41875a193d161331a81a2b6d/media/secret_door_toggle.webp) ![Toggle Secret Doors demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/da5872042ea81e2f41875a193d161331a81a2b6d/media/secret_door_toggle.webp)
Easily reveal secret doors to players. Ctrl+left click secrets doors to turn them into regular doors. Ctrl+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. Easily reveal secret doors to players. Alt+left click secrets doors to turn them into regular doors. Alt+left click can also be done on normal doors to turn them into secret doors. The keybinding for this feature can be reconfigured.
### Locked Door Alerts ### Locked Door Alerts

View File

@@ -1,5 +1,11 @@
{ {
"smart-doors": { "smart-doors": {
"keybindings": {
"toggleSecretDoor": {
"name": "Toggle Secret Door",
"hint": "While this key is being pressed, clicking on doors will cause the to toggle between normal and secret door"
}
},
"settings": { "settings": {
"doorControlSizeFactor": { "doorControlSizeFactor": {
"name": "Door Control Size Factor", "name": "Door Control Size Factor",
@@ -16,10 +22,6 @@
"synchronizedDoors": { "synchronizedDoors": {
"name": "Synchronized Doors", "name": "Synchronized Doors",
"hint": "Synchronize the state of configured 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": { "ui": {

View File

@@ -3,8 +3,8 @@
"title": "Smart Doors", "title": "Smart Doors",
"description": "Makes doors smarter. Allows doors to synchronize across multiple scenes and sends chat messages when players try to open locked doors.", "description": "Makes doors smarter. Allows doors to synchronize across multiple scenes and sends chat messages when players try to open locked doors.",
"version": "1.2.9", "version": "1.2.9",
"minimumCoreVersion" : "0.8.7", "minimumCoreVersion" : "9.238",
"compatibleCoreVersion" : "0.8.8", "compatibleCoreVersion" : "9",
"authors": [ "authors": [
{ {
"name": "Manuel Vögele", "name": "Manuel Vögele",

View File

@@ -1,10 +1,11 @@
import {toggleSecretDoor} from "../keybindings.js";
import {settingsKey} from "../settings.js" import {settingsKey} from "../settings.js"
import {updateSynchronizedDoors} from "./synchronized_doors.js"; import {updateSynchronizedDoors} from "./synchronized_doors.js";
// Toggles between normal and secret doors // Toggles between normal and secret doors
export function onDoorLeftClick(event) { export function onDoorLeftClick() {
// We don't trust the event to be filled with the expected data for compatibilty with arms reach (which passes a broken event) // We don't trust the event to be filled with the expected data for compatibilty with arms reach (which passes a broken event)
if (game.settings.get(settingsKey, "toggleSecretDoors") && event.data?.originalEvent?.ctrlKey && game.user.isGM) { if (toggleSecretDoor && game.user.isGM) {
const types = CONST.WALL_DOOR_TYPES const types = CONST.WALL_DOOR_TYPES
const newtype = this.wall.data.door === types.DOOR ? types.SECRET : types.DOOR const newtype = this.wall.data.door === types.DOOR ? types.SECRET : types.DOOR
const updateData = {door: newtype} const updateData = {door: newtype}

15
src/keybindings.js Normal file
View File

@@ -0,0 +1,15 @@
import {settingsKey} from "./settings.js";
export let toggleSecretDoor = false;
export function registerKeybindings() {
game.keybindings.register(settingsKey, "toggleSecretDoor", {
name: "smart-doors.keybindings.toggleSecretDoor.name",
hint: "smart-doors.keybindings.toggleSecretDoor.hint",
onDown: () => toggleSecretDoor = true,
onUp: () => toggleSecretDoor = false,
restricted: true,
editable: [{key: "AltLeft"}],
precedence: -1,
});
}

View File

@@ -8,10 +8,13 @@ import * as SynchronizedDoors from "./features/synchronized_doors.js"
import * as ToggleSecretDoor from "./features/toggle_secret_door.js" import * as ToggleSecretDoor from "./features/toggle_secret_door.js"
import {performMigrations} from "./migration.js" import {performMigrations} from "./migration.js"
import {registerKeybindings} from "./keybindings.js"
import {registerSettings, settingsKey} from "./settings.js" import {registerSettings, settingsKey} from "./settings.js"
Hooks.once("init", () => { Hooks.once("init", () => {
registerSettings() registerSettings()
registerKeybindings()
hookDoorEvents() hookDoorEvents()
hookWallConfigUpdate() hookWallConfigUpdate()
hookDoorControlDraw() hookDoorControlDraw()

View File

@@ -30,14 +30,6 @@ export function registerSettings() {
default: false, default: false,
onChange: reloadGM, 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", { game.settings.register(settingsKey, "lockedDoorAlert", {
name: "smart-doors.settings.lockedDoorAlert.name", name: "smart-doors.settings.lockedDoorAlert.name",
hint: "smart-doors.settings.lockedDoorAlert.hint", hint: "smart-doors.settings.lockedDoorAlert.hint",