1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Fixed some mouse press/release action interaction conflicts.

This commit is contained in:
David Triphon 2020-07-20 12:46:40 -07:00
parent 0fc6e9ca2c
commit 958797d7c0
3 changed files with 22 additions and 4 deletions

View File

@ -87,7 +87,7 @@ export class Camera extends BasicSerializableObject {
this.downPreHandler = /** @type {TypedSignal<[Vector, enumMouseButton]>} */ (new Signal()); this.downPreHandler = /** @type {TypedSignal<[Vector, enumMouseButton]>} */ (new Signal());
this.movePreHandler = /** @type {TypedSignal<[Vector]>} */ (new Signal()); this.movePreHandler = /** @type {TypedSignal<[Vector]>} */ (new Signal());
// this.pinchPreHandler = /** @type {TypedSignal<[Vector]>} */ (new Signal()); // this.pinchPreHandler = /** @type {TypedSignal<[Vector]>} */ (new Signal());
this.upPostHandler = /** @type {TypedSignal<[Vector]>} */ (new Signal()); this.upPostHandler = /** @type {TypedSignal<[Vector, enumMouseButton]>} */ (new Signal());
this.internalInitEvents(); this.internalInitEvents();
this.clampZoomLevel(); this.clampZoomLevel();
@ -767,7 +767,7 @@ export class Camera extends BasicSerializableObject {
this.userInteraction.dispatch(USER_INTERACT_TOUCHEND); this.userInteraction.dispatch(USER_INTERACT_TOUCHEND);
this.didMoveSinceTouchStart = false; this.didMoveSinceTouchStart = false;
} }
this.upPostHandler.dispatch(new Vector(x, y)); this.upPostHandler.dispatch(new Vector(x, y), buttonKey);
} }
/** /**

View File

@ -824,11 +824,24 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
/** /**
* Mouse up handler * Mouse up handler
*/ */
onMouseUp() { onMouseUp(pos, mouseButton) {
if (this.root.camera.getIsMapOverlayActive()) { if (this.root.camera.getIsMapOverlayActive()) {
return; return;
} }
// prevent releasing the wrong mouse button from cancelling other actions:
// if not dragging, OR
// if not deleting and the released mouse button is not left click, OR
// if deleting and the released mouse button is not right click,
// then ignore the release
if (
!this.currentlyDragging ||
(!this.currentlyDeleting && mouseButton !== enumMouseButton.left) ||
(this.currentlyDeleting && mouseButton !== enumMouseButton.right)
) {
return;
}
// Check for direction lock // Check for direction lock
if (this.lastDragTile && this.currentlyDragging && this.isDirectionLockActive) { if (this.lastDragTile && this.currentlyDragging && this.isDirectionLockActive) {
this.executeDirectionLockedPlacement(); this.executeDirectionLockedPlacement();

View File

@ -213,7 +213,12 @@ export class HUDMassSelector extends BaseHUDPart {
} }
} }
onMouseUp() { onMouseUp(pos, mouseButton) {
// prevent releasing other mouse buttons from stopping a left click action
if (mouseButton !== enumMouseButton.left) {
return;
}
if (this.currentSelectionStartWorld) { if (this.currentSelectionStartWorld) {
const worldStart = this.currentSelectionStartWorld; const worldStart = this.currentSelectionStartWorld;
const worldEnd = this.root.camera.screenToWorld(this.currentSelectionEnd); const worldEnd = this.root.camera.screenToWorld(this.currentSelectionEnd);