Skip to content

Commit

Permalink
Merge branch 'main' into canvas-scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
ScoreUnder committed Aug 21, 2022
2 parents 5eea923 + 9fa93db commit d4b232e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

- Fix a potential process lingering issue when the renderer fails to load – [#119](https://github.com/ConnorDY/OSRS-Environment-Exporter/pull/119) @ScoreUnder

- Fix camera flickering when mouse warping is enabled but the warp destination is outside of the screen – [#124](https://github.com/ConnorDY/OSRS-Environment-Exporter/pull/124) @ScoreUnder

- Scale canvas correctly even under high-DPI modes – [#125](https://github.com/ConnorDY/OSRS-Environment-Exporter/pull/125) @ScoreUnder

## 2.2.0
Expand Down
16 changes: 13 additions & 3 deletions src/main/kotlin/controllers/worldRenderer/InputHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class InputHandler internal constructor(
}
}

private fun warpMouse(x: Int, y: Int) {
private fun warpMouse(x: Int, y: Int): Boolean {
val screen = GraphicsEnvironment.getLocalGraphicsEnvironment().screenDevices.find { device ->
device.configurations.find { it.bounds.contains(x, y) } != null
}
Expand All @@ -173,6 +173,7 @@ class InputHandler internal constructor(
}
robot.mouseMove(x, y)
}
return screen != null
}

override fun mouseMoved(e: MouseEvent) {
Expand Down Expand Up @@ -215,8 +216,17 @@ class InputHandler internal constructor(
}

if (warp) {
warpMouse(offsetX + x, offsetY + y)
discardUntil = System.currentTimeMillis()
val warpSuccess = warpMouse(offsetX + x, offsetY + y)
if (warpSuccess) {
// Discard queued events if we warped the mouse successfully
// because the old events will be relative to the old mouse position
discardUntil = System.currentTimeMillis()
} else {
// If the mouse failed to warp, set x and y back to normal
// so that the camera doesn't jump around
x = e.x
y = e.y
}
}
}

Expand Down

0 comments on commit d4b232e

Please sign in to comment.