From df97bff53f269b68ea8480c9de57e9f8eba2f025 Mon Sep 17 00:00:00 2001 From: Exund Date: Sun, 20 Sep 2020 00:33:54 +0200 Subject: [PATCH] Fix some literal edge cases --- src/js/application.js | 10 +++++++++- src/js/game/camera.js | 10 +++++----- src/js/game/hud/parts/shape_viewer.js | 4 ++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/js/application.js b/src/js/application.js index 1a8ca21f..c68a5bc4 100644 --- a/src/js/application.js +++ b/src/js/application.js @@ -231,7 +231,15 @@ export class Application { * @param {MouseEvent} event */ handleMousemove(event) { - this.mousePosition = new Vector(event.clientX, event.clientY); + let x = event.clientX; + let y = event.clientY; + + if (event.type === "mouseout" || event.type === "mouseleave") { + x = -1; + y = -1; + } + + this.mousePosition = new Vector(x, y); } /** diff --git a/src/js/game/camera.js b/src/js/game/camera.js index 2be175b4..534bc1d1 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -862,7 +862,7 @@ export class Camera extends BasicSerializableObject { * @param {number} dt */ internalUpdateMousePanning(now, dt) { - if (!this.root.app.settings.getAllSettings().enableMousePan) { + if (!this.root.app.settings.getAllSettings().enableMousePan || !this.root.app.focused) { // Not enabled return; } @@ -882,10 +882,10 @@ export class Camera extends BasicSerializableObject { } if ( - mousePos.x < 0 || - mousePos.y < 0 || - mousePos.x > this.root.gameWidth || - mousePos.y > this.root.gameHeight + mousePos.x <= 0 || + mousePos.y <= 0 || + mousePos.x >= this.root.gameWidth || + mousePos.y >= this.root.gameHeight ) { // Out of screen return; diff --git a/src/js/game/hud/parts/shape_viewer.js b/src/js/game/hud/parts/shape_viewer.js index ea4273aa..18f55c74 100644 --- a/src/js/game/hud/parts/shape_viewer.js +++ b/src/js/game/hud/parts/shape_viewer.js @@ -48,6 +48,10 @@ export class HUDShapeViewer extends BaseHUDPart { this.close(); } + isBlockingOverlay() { + return this.visible; + } + /** * Called when the copying of a key was requested */