Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a sensitivity multiplier to zoom #62

Merged
merged 3 commits into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import dev.lyzev.api.animation.EasingFunction
import dev.lyzev.api.animation.TimeAnimator
import dev.lyzev.api.events.EventGetFOV
import dev.lyzev.api.events.EventListener
import dev.lyzev.api.events.EventUpdateMouse
import dev.lyzev.api.events.EventMouseScroll
import dev.lyzev.api.events.on
import dev.lyzev.api.glfw.GLFWKey
Expand Down Expand Up @@ -36,6 +37,11 @@ object ModuleToggleableZoom : ModuleToggleable("Zoom", "Allows you to zoom.", ca
*/
val fov by slider("FOV", "The fov of the zoom.", 10f, 1f, 30f, allowOutOfBounds = true)

/**
* The weight of the mouse movement applied while zooming.
*/
val weight by slider("Weight", "The weight of the mouse movement applied while zooming.", 20, 1, 100, "%%")

val smoothCamera by switch("Smooth Camera", "Enables the smooth camera.", false)

val scrollable by switch("Scrolling", "Enables zooming with the mouse wheel.", true)
Expand Down Expand Up @@ -80,6 +86,14 @@ object ModuleToggleableZoom : ModuleToggleable("Zoom", "Allows you to zoom.", ca
var isZooming = false
var scrollOffset = 0
timeAnimator.setReversed(true)
on<EventUpdateMouse> {
if (!isZooming)
return@on
val mouse = mc.mouse
val weight = weight / 100f
mouse.cursorDeltaX *= weight
mouse.cursorDeltaY *= weight
}
on<EventMouseScroll> { event ->
if (isZooming && scrollable) {
event.isCancelled = true
Expand Down