diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc0eaf..724287f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## In development +### Feature removals +- The door icons now have outlines by defualt in Foundry. As a result the "Door Icon Outline" feature was removed. +- Secret doors now have a different icon from regular doors in Foundry, making the "Tint Secret Doors" feature redundant. As a result it was removed. + ## 1.2.6 ### Compatibility - Smart Doors now uses the libwrapper module and as a result is now compatible with the module "FoundryVTT Arms Reach" diff --git a/README.md b/README.md index cc338d7..1803887 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,6 @@ Makes doors smarter. Allows doors to synchronize across multiple scenes and send Door Control icons will be rendered the same size in every scene, regardless of the configured grid size. The size of the icons is configurable. -### Door Control Outline -![Door Control Outline demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/3b0018ddf424a2a369273029e0e1184a8bed848c/media/door_control_outline.webp) - -Door Control icons will be rendered with an outline to improve their visibility on bright backgrounds. - ### Tint Secret Doors ![Tint Secret Doors demonstration](https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/dc5d328cd9bc4a0e2aacc5c86ab59e15739cc6d1/media/tint_secret_doors.webp) diff --git a/lang/en.json b/lang/en.json index 42bce1b..d81d4f8 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1,18 +1,10 @@ { "smart-doors": { "settings": { - "doorControlOutline": { - "name": "Door Control Outline", - "hint": "Draw outlines around Door Control icons to increase their visiblity" - }, "doorControlSizeFactor": { "name": "Door Control Size Factor", "hint": "Defines by which factor the size of the door control icons should be scaled up" }, - "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/lib/outline_filter/outline_filter.js b/lib/outline_filter/outline_filter.js deleted file mode 100644 index 8df3c08..0000000 --- a/lib/outline_filter/outline_filter.js +++ /dev/null @@ -1,152 +0,0 @@ -/* - -This is a modified version of the PIXI outline filter (https://github.com/pixijs/pixi-filters/tree/master/filters/outline) -and is licensed under the MIT license. - -The MIT License - -Copyright (c) 2013-2017 Mathew Groves, Chad Engler - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -*/ - -const vertex = `attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}` - -const fragment = `varying vec2 vTextureCoord; -uniform sampler2D uSampler; - -uniform vec2 thickness; -uniform vec4 outlineColor; -uniform vec4 filterClamp; - -const float DOUBLE_PI = 3.14159265358979323846264 * 2.; - -void main(void) { - vec4 ownColor = texture2D(uSampler, vTextureCoord); - vec4 curColor; - float maxAlpha = 0.; - vec2 displaced; - for (float angle = 0.; angle <= DOUBLE_PI; angle += \${angleStep}) { - displaced.x = vTextureCoord.x + thickness.x * cos(angle); - displaced.y = vTextureCoord.y + thickness.y * sin(angle); - curColor = texture2D(uSampler, clamp(displaced, filterClamp.xy, filterClamp.zw)); - maxAlpha = max(maxAlpha, curColor.a); - } - float resultAlpha = max(maxAlpha, ownColor.a); - // Original line: - // gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha); - gl_FragColor = vec4(ownColor.rgb + outlineColor.rgb * (resultAlpha - ownColor.a), resultAlpha); -} -` - -/** - * OutlineFilter, originally by mishaa - * http://www.html5gamedevs.com/topic/10640-outline-a-sprite-change-certain-colors/?p=69966 - * http://codepen.io/mishaa/pen/emGNRB
- * ![original](../tools/screenshots/dist/original.png)![filter](../tools/screenshots/dist/outline.png) - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @see {@link https://www.npmjs.com/package/@pixi/filter-outline|@pixi/filter-outline} - * @see {@link https://www.npmjs.com/package/pixi-filters|pixi-filters} - * @param {number} [thickness=1] The tickness of the outline. Make it 2 times more for resolution 2 - * @param {number} [color=0x000000] The color of the outline. - * @param {number} [quality=0.1] The quality of the outline from `0` to `1`, using a higher quality - * setting will result in slower performance and more accuracy. - * - * @example - * someSprite.filters = [new OutlineFilter(2, 0x99ff99)]; - */ -class OutlineFilter extends PIXI.Filter { - - constructor(thickness = 1, color = 0x000000, quality = 0.1) { - const samples = Math.max( - quality * OutlineFilter.MAX_SAMPLES, - OutlineFilter.MIN_SAMPLES - ); - const angleStep = (Math.PI * 2 / samples).toFixed(7); - - super(vertex, fragment.replace(/\$\{angleStep\}/, angleStep)); - this.uniforms.thickness = new Float32Array([0, 0]); - - /** - * The thickness of the outline. - * @member {number} - * @default 1 - */ - this.thickness = thickness; - - this.uniforms.outlineColor = new Float32Array([0, 0, 0, 1]); - this.color = color; - - this.quality = quality; - } - - apply(filterManager, input, output, clear) { - this.uniforms.thickness[0] = this.thickness / input._frame.width; - this.uniforms.thickness[1] = this.thickness / input._frame.height; - - filterManager.applyFilter(this, input, output, clear); - } - - /** - * The color of the glow. - * @member {number} - * @default 0x000000 - */ - get color() { - return PIXI.utils.rgb2hex(this.uniforms.outlineColor); - } - set color(value) { - PIXI.utils.hex2rgb(value, this.uniforms.outlineColor); - } -} - -/** - * The minimum number of samples for rendering outline. - * @static - * @member {number} MIN_SAMPLES - * @memberof PIXI.filters.OutlineFilter - * @default 1 - */ -OutlineFilter.MIN_SAMPLES = 1; - -/** - * The maximum number of samples for rendering outline. - * @static - * @member {number} MAX_SAMPLES - * @memberof PIXI.filters.OutlineFilter - * @default 100 - */ -OutlineFilter.MAX_SAMPLES = 100; - -export { OutlineFilter }; diff --git a/src/features/door_control_outline.js b/src/features/door_control_outline.js deleted file mode 100644 index 75e8e25..0000000 --- a/src/features/door_control_outline.js +++ /dev/null @@ -1,24 +0,0 @@ -import {settingsKey} from "../settings.js" -import {OutlineFilter} from "../../lib/outline_filter/outline_filter.js" - -export function onDoorControlPostDraw() { - if (!game.settings.get(settingsKey, "doorControlOutline")) - return - - const types = CONST.WALL_DOOR_TYPES - if (this.wall.data.door === types.NONE) - return - - // Remove all OutlineFilters from current filters - let pixiFilters = this.icon.filters || [] - pixiFilters = pixiFilters.filter(pixiFilter => !(pixiFilter instanceof OutlineFilter)) - - let outlineFilter; - if (this.wall.data.door === types.SECRET && game.settings.get(settingsKey, "highlightSecretDoors")) - outlineFilter = new OutlineFilter(1, 0xFFFFFF) - else - outlineFilter = new OutlineFilter(1, 0x000000) - - pixiFilters.push(outlineFilter) - this.icon.filters = pixiFilters -} diff --git a/src/features/highlight_secret_doors.js b/src/features/highlight_secret_doors.js deleted file mode 100644 index 9c76e1d..0000000 --- a/src/features/highlight_secret_doors.js +++ /dev/null @@ -1,34 +0,0 @@ -import {settingsKey} from "../settings.js" - -const SECRET_DOOR_TINT = 0x000000 - -// Tint all secret doors dark grey -export function onCanvasReady(currentCanvas) { - 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 -export function onUpdateWall(scene, wall, update) { - if (!game.settings.get(settingsKey, "highlightSecretDoors")) - return - const types = CONST.WALL_DOOR_TYPES - if (wall.door === types.NONE) - return - // Find the door control corresponding to the changed door - const changedDoor = canvas.controls.doors.children.find(control => control.wall.data._id === wall._id); - // If the changed door doesn't have a control it's not on this scene - ignore it - if (!changedDoor) - return - // The wall object we got passed might be from another scene so we replace it with the door from the current scene - wall = changedDoor.wall.data - 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.") -} diff --git a/src/main.js b/src/main.js index 676fa20..d4b7f2b 100644 --- a/src/main.js +++ b/src/main.js @@ -2,8 +2,6 @@ import {libWrapper} from "../lib/libwrapper_shim.js"; import * as DoorControlIconScale from "./features/door_control_icon_scale.js" -import * as DoorControlOutline from "./features/door_control_outline.js" -import * as HighlightSecretDoors from "./features/highlight_secret_doors.js" import * as LockedDoorAlert from "./features/locked_door_alert.js" import * as SynchronizedDoors from "./features/synchronized_doors.js" import * as ToggleSecretDoor from "./features/toggle_secret_door.js" @@ -26,9 +24,6 @@ Hooks.once("ready", () => { Hooks.on("renderChatMessage", LockedDoorAlert.onRenderChatMessage) Hooks.on("canvasReady", DoorControlIconScale.onCanvasReady) -Hooks.on("canvasReady", HighlightSecretDoors.onCanvasReady) - -Hooks.on("updateWall", HighlightSecretDoors.onUpdateWall) // Inject our custom settings into the WallConfig dialog Hooks.on("renderWallConfig", SynchronizedDoors.onRederWallConfig) @@ -46,7 +41,6 @@ function hookDoorControlDraw() { libWrapper.register("smart-doors", "DoorControl.prototype.draw", async function (wrapped) { const result = await wrapped(); DoorControlIconScale.onDoorControlPostDraw.call(this) - DoorControlOutline.onDoorControlPostDraw.call(this) return result; }, "WRAPPER"); } diff --git a/src/settings.js b/src/settings.js index a036c1d..f38d6db 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1,10 +1,5 @@ export const settingsKey = "smart-doors"; -function reloadGM() { - if (game.user.isGM) - location.reload() -} - export function registerSettings() { game.settings.register(settingsKey, "dataVersion", { scope: "world", @@ -21,24 +16,6 @@ export function registerSettings() { default: 1.5, onChange: () => location.reload() }) - game.settings.register(settingsKey, "doorControlOutline", { - name: "smart-doors.settings.doorControlOutline.name", - hint: "smart-doors.settings.doorControlOutline.hint", - scope: "client", - config: true, - type: Boolean, - default: true, - onChange: () => location.reload(), - }) - 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, "toggleSecretDoors", { name: "smart-doors.settings.toggleSecretDoors.name", hint: "smart-doors.settings.toggleSecretDoors.hint",