camera: add option to preserve yaw when world hopping

This commit is contained in:
Adam
2021-06-07 18:53:47 -04:00
parent 89a3838275
commit c9f5f93b52
2 changed files with 32 additions and 1 deletions

View File

@@ -191,4 +191,15 @@ public interface CameraConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "preserveYaw",
name = "Preserve yaw on world hop",
description = "Preserves the camera yaw (left/right) when world hopping.",
position = 14
)
default boolean preserveYaw()
{
return false;
}
}

View File

@@ -43,6 +43,7 @@ import net.runelite.api.VarPlayer;
import net.runelite.api.events.BeforeRender;
import net.runelite.api.events.ClientTick;
import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.api.events.ScriptPreFired;
@@ -89,7 +90,8 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
* Whether or not the current menu has any non-ignored menu entries
*/
private boolean menuHasEntries;
private int savedCameraYaw;
@Inject
private Client client;
@@ -418,6 +420,24 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
}
}
@Subscribe
public void onGameStateChanged(GameStateChanged gameStateChanged)
{
switch (gameStateChanged.getGameState())
{
case HOPPING:
savedCameraYaw = client.getMapAngle();
break;
case LOGGED_IN:
if (savedCameraYaw != 0 && config.preserveYaw())
{
client.setCameraYawTarget(savedCameraYaw);
}
savedCameraYaw = 0;
break;
}
}
/**
* The event that is triggered when a mouse button is pressed
* In this method the right click is changed to a middle-click to enable rotating the camera