Skip to content

Commit

Permalink
Working on map dragging again.
Browse files Browse the repository at this point in the history
It seems on windows, dragging is fubar.
  • Loading branch information
tyra314 committed Sep 18, 2022
1 parent 83f8d0a commit d88184a
Showing 1 changed file with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,8 @@ public boolean mouseReleased(double mouseX, double mouseY, int mouseState) {
result = selectedButton != null || isDragging;
selectedButton = null;
isDragging = false;
mapOffsetDeltaX = 0;
mapOffsetDeltaY = 0;
}
return super.mouseReleased(mouseX, mouseY, mouseState) || result;
}
Expand All @@ -729,25 +731,17 @@ public boolean mouseDragged(double mouseX, double mouseY, int lastMouseButton, d
mapOffsetDeltaX += deltaX;
mapOffsetDeltaY += deltaY;

if (mapOffsetDeltaX > 1) {
mapOffsetX++;
mapOffsetDeltaX -= 1;
}

if (mapOffsetDeltaX < -1) {
mapOffsetX--;
mapOffsetDeltaX += 1;
}

int offsetX = (int) (Math.signum(mapOffsetDeltaX) * Math.floor(Math.abs(mapOffsetDeltaX)));
int offsetY = (int) (Math.signum(mapOffsetDeltaY) * Math.floor(Math.abs(mapOffsetDeltaY)));

if (mapOffsetDeltaY > 1) {
mapOffsetY++;
mapOffsetDeltaY -= 1;
if (Math.abs(mapOffsetDeltaX) >= 1) {
mapOffsetDeltaX = mapOffsetDeltaX - offsetX;
mapOffsetX += offsetX;
}

if (mapOffsetDeltaY < -1) {
mapOffsetY--;
mapOffsetDeltaY += 1;
if (Math.abs(mapOffsetDeltaY) >= 1) {
mapOffsetDeltaY = mapOffsetDeltaY - offsetY;
mapOffsetY += offsetY;
}

result = true;
Expand Down

0 comments on commit d88184a

Please sign in to comment.