camera: add option to invert camera mouse controls

This commit is contained in:
Max Weber
2020-04-07 02:43:17 -06:00
parent edcfeb25fd
commit a8d4bff423
3 changed files with 43 additions and 2 deletions

View File

@@ -158,4 +158,26 @@ public interface CameraConfig extends Config
{
return true;
}
@ConfigItem(
keyName = "invertYaw",
name = "Invert Yaw",
description = "Makes moving the camera horizontally with the mouse backwards",
position = 11
)
default boolean invertYaw()
{
return false;
}
@ConfigItem(
keyName = "invertPitch",
name = "Invert Pitch",
description = "Makes moving the camera vertically with the mouse backwards",
position = 12
)
default boolean invertPitch()
{
return false;
}
}

View File

@@ -113,7 +113,7 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
rightClick = false;
middleClick = false;
menuHasEntries = false;
client.setCameraPitchRelaxerEnabled(config.relaxCameraPitch());
copyConfigs();
keyManager.registerKeyListener(this);
mouseManager.registerMouseListener(this);
overlayManager.add(cameraOverlay);
@@ -124,11 +124,20 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
{
overlayManager.remove(cameraOverlay);
client.setCameraPitchRelaxerEnabled(false);
client.setInvertYaw(false);
client.setInvertPitch(false);
keyManager.unregisterKeyListener(this);
mouseManager.unregisterMouseListener(this);
controlDown = false;
}
void copyConfigs()
{
client.setCameraPitchRelaxerEnabled(config.relaxCameraPitch());
client.setInvertYaw(config.invertYaw());
client.setInvertPitch(config.invertPitch());
}
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
{
@@ -238,7 +247,7 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
@Subscribe
public void onConfigChanged(ConfigChanged ev)
{
client.setCameraPitchRelaxerEnabled(config.relaxCameraPitch());
copyConfigs();
}
@Override