diff --git a/js/5etools-bootstrap.js b/js/5etools-bootstrap.js index 996765cf..1da9efd2 100644 --- a/js/5etools-bootstrap.js +++ b/js/5etools-bootstrap.js @@ -69,6 +69,7 @@ const betteR205etools = function () { d20plus.weather.addWeather(); d20plus.engine.repairPrototypeMethods(); d20plus.engine.disableFrameRecorder(); + d20plus.engine.fixPolygonTool(); // d20plus.ut.fixSidebarLayout(); d20plus.chat.enhanceChat(); diff --git a/js/base-engine.js b/js/base-engine.js index e761d78a..8e67e8c0 100644 --- a/js/base-engine.js +++ b/js/base-engine.js @@ -844,6 +844,18 @@ function d20plusEngine () { d20.engine.frame_recorder._active = false; } }; + + d20plus.engine.fixPolygonTool = () => { + if (d20plus.isOptedInNewUI) return; + $("#editor-wrapper").on("pointerdown", x => { d20plus.engine.leftClicked = x.which === 1 }); + $("#editor-wrapper").on("pointerup", x => { d20plus.engine.leftClicked = false }); + d20plus.ut.injectCode(d20.engine, "finishCurrentPolygon", (finishDrawing, params) => { + if (!d20plus.engine.leftClicked) finishDrawing(...params); + }); + d20plus.ut.injectCode(d20.engine, "finishPolygonReveal", (finishRevealing, params) => { + if (!d20plus.engine.leftClicked) finishRevealing(...params); + }); + }; } SCRIPT_EXTENSIONS.push(d20plusEngine); diff --git a/js/core-bootstrap.js b/js/core-bootstrap.js index 528a5607..6e5c0817 100644 --- a/js/core-bootstrap.js +++ b/js/core-bootstrap.js @@ -53,6 +53,7 @@ const betteR20Core = function () { d20plus.weather.addWeather(); d20plus.engine.repairPrototypeMethods(); d20plus.engine.disableFrameRecorder(); + d20plus.engine.fixPolygonTool(); // d20plus.ut.fixSidebarLayout(); d20plus.chat.enhanceChat();