mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-18 20:40:20 -07:00
InputQOLCtrlZoom
This commit is contained in:
parent
ff7951d824
commit
6c288da807
1 changed files with 114 additions and 0 deletions
|
|
@ -0,0 +1,114 @@
|
||||||
|
package BasicInputQOLCtrlZoom
|
||||||
|
|
||||||
|
import plugin.Plugin
|
||||||
|
import plugin.annotations.PluginMeta
|
||||||
|
import plugin.api.*
|
||||||
|
import rt4.Keyboard
|
||||||
|
import java.awt.event.*
|
||||||
|
import javax.swing.SwingUtilities
|
||||||
|
|
||||||
|
@PluginMeta(
|
||||||
|
author = "Ceikry",
|
||||||
|
description = "Provides some basic input QOL like ctrl scroll zoom, middle click panning, etc. Incompatible with BasicInputQOL.",
|
||||||
|
version = 1.0
|
||||||
|
)
|
||||||
|
class plugin : Plugin() {
|
||||||
|
private var cameraDebugEnabled = false
|
||||||
|
private var mouseDebugEnabled = false
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private var lastMouseWheelX = 0
|
||||||
|
private var lastMouseWheelY = 0
|
||||||
|
private val defaultCameraPYZ = Triple(128.0, 0.0, 600)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun Init() {
|
||||||
|
API.AddMouseListener(MouseCallbacks)
|
||||||
|
API.AddMouseWheelListener(MouseWheelCallbacks)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ProcessCommand(commandStr: String?, args: Array<out String>?) {
|
||||||
|
commandStr ?: return
|
||||||
|
if (API.PlayerHasPrivilege(Privileges.JMOD)) {
|
||||||
|
when(commandStr) {
|
||||||
|
"::mousedebug" -> mouseDebugEnabled = !mouseDebugEnabled
|
||||||
|
"::cameradebug" -> cameraDebugEnabled = !cameraDebugEnabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun Draw(timeDelta: Long) {
|
||||||
|
if (mouseDebugEnabled) {
|
||||||
|
API.DrawText(
|
||||||
|
FontType.SMALL,
|
||||||
|
FontColor.YELLOW,
|
||||||
|
TextModifier.LEFT,
|
||||||
|
"Mouse Coords: (${API.GetMouseX()}, ${API.GetMouseY()})",
|
||||||
|
10,
|
||||||
|
40
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (cameraDebugEnabled) {
|
||||||
|
API.DrawText(
|
||||||
|
FontType.SMALL,
|
||||||
|
FontColor.YELLOW,
|
||||||
|
TextModifier.LEFT,
|
||||||
|
"Camera: [P=${API.GetCameraPitch()}, Y=${API.GetCameraYaw()}, Z=${API.GetCameraZoom()}]",
|
||||||
|
10,
|
||||||
|
50
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object MouseWheelCallbacks : MouseWheelListener {
|
||||||
|
override fun mouseWheelMoved(e: MouseWheelEvent?) {
|
||||||
|
e ?: return
|
||||||
|
if (API.IsKeyPressed(Keyboard.KEY_CTRL)) {
|
||||||
|
val previous = API.GetPreviousMouseWheelRotation()
|
||||||
|
val current = API.GetMouseWheelRotation()
|
||||||
|
val diff = current - previous
|
||||||
|
API.UpdateCameraZoom(diff)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object MouseCallbacks : MouseAdapter() {
|
||||||
|
override fun mouseDragged(e: MouseEvent?) {
|
||||||
|
e ?: return
|
||||||
|
if (SwingUtilities.isMiddleMouseButton(e)) {
|
||||||
|
val x = e.x
|
||||||
|
val y = e.y
|
||||||
|
val accelX = lastMouseWheelX - x
|
||||||
|
val accelY = lastMouseWheelY - y
|
||||||
|
lastMouseWheelX = x
|
||||||
|
lastMouseWheelY = y
|
||||||
|
API.UpdateCameraYaw(accelX * 2.0)
|
||||||
|
API.UpdateCameraPitch(-accelY * 2.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseClicked(e: MouseEvent?) {
|
||||||
|
e ?: return
|
||||||
|
|
||||||
|
/* val width = API.GetWindowDimensions().width;
|
||||||
|
val compassBordersX = intArrayOf(width - 165, width - 125)
|
||||||
|
val compassBordersY = intArrayOf(0, 45)
|
||||||
|
if (
|
||||||
|
e.x in compassBordersX[0]..compassBordersX[1]
|
||||||
|
&& e.y in compassBordersY[0]..compassBordersY[1]
|
||||||
|
)
|
||||||
|
{
|
||||||
|
API.SetCameraPitch(defaultCameraPYZ.first)
|
||||||
|
API.SetCameraYaw(defaultCameraPYZ.second)
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mousePressed(e: MouseEvent?) {
|
||||||
|
e ?: return
|
||||||
|
if (SwingUtilities.isMiddleMouseButton(e)) {
|
||||||
|
lastMouseWheelX = e.x
|
||||||
|
lastMouseWheelY = e.y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue