From 22bcc428586246c7281c265f8537b744408e7f8e Mon Sep 17 00:00:00 2001 From: Andrio Celos Date: Wed, 22 Feb 2023 23:59:58 +1100 Subject: [PATCH] Enable rotating with the right mouse button --- TableturfBattleClient/src/Board.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/TableturfBattleClient/src/Board.ts b/TableturfBattleClient/src/Board.ts index cd31a4a..25191db 100644 --- a/TableturfBattleClient/src/Board.ts +++ b/TableturfBattleClient/src/Board.ts @@ -214,6 +214,18 @@ class Board { td.dataset.x = x.toString(); td.dataset.y = y.toString(); col.push(td); + td.addEventListener('click', e => { + if (this.autoHighlight && this.cardPlaying != null && this.onclick) { + if (this.touchscreenMode) { + this.onclick(this.highlightX, this.highlightY); + } else { + const x = parseInt((e.target as HTMLTableCellElement).dataset.x!) - (this.flip ? 4 : 3); + const y = parseInt((e.target as HTMLTableCellElement).dataset.y!) - (this.flip ? 4 : 3); + this.onclick(x, y); + } + } + }); + td.addEventListener('contextmenu', e => e.preventDefault()); td.addEventListener('mousemove', e => { if (e.buttons == 0) this.touchscreenMode = false; @@ -229,14 +241,11 @@ class Board { } } }); - td.addEventListener('click', e => { - if (this.autoHighlight && this.cardPlaying != null && this.onclick) { - if (this.touchscreenMode) { - this.onclick(this.highlightX, this.highlightY); - } else { - const x = parseInt((e.target as HTMLTableCellElement).dataset.x!) - (this.flip ? 4 : 3); - const y = parseInt((e.target as HTMLTableCellElement).dataset.y!) - (this.flip ? 4 : 3); - this.onclick(x, y); + td.addEventListener('mouseup', e => { + if (this.autoHighlight && this.cardPlaying != null) { + if (e.button == 2) { + this.cardRotation++; + this.refreshHighlight(); } } });