Merge pull request #11214 from abextm/invert-camera-external

camera: add option to invert camera mouse controls
This commit is contained in:
Adam
2020-04-09 17:51:53 -04:00
committed by GitHub
3 changed files with 43 additions and 2 deletions

View File

@@ -1184,6 +1184,16 @@ public interface Client extends GameEngine
*/
void setCameraPitchRelaxerEnabled(boolean enabled);
/**
* Sets if the moving the camera horizontally should be backwards
*/
void setInvertYaw(boolean invertYaw);
/**
* Sets if the moving the camera vertically should be backwards
*/
void setInvertPitch(boolean invertPitch);
/**
* Gets the world map overview.
*

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