Merge pull request #1331 from Ganom/detach-hotkey
runeliteplus: add detach cam toggle
This commit is contained in:
@@ -26,11 +26,6 @@
|
||||
*/
|
||||
package net.runelite.client.config;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.Range;
|
||||
|
||||
@ConfigGroup("runeliteplus")
|
||||
public interface RuneLitePlusConfig extends Config
|
||||
{
|
||||
@@ -75,10 +70,21 @@ public interface RuneLitePlusConfig extends Config
|
||||
keyName = "enablePlugins",
|
||||
name = "Enable loading of external plugins",
|
||||
description = "Enable loading of external plugins",
|
||||
position = 10
|
||||
position = 3
|
||||
)
|
||||
default boolean enablePlugins()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "detachHotkey",
|
||||
name = "Detach Cam",
|
||||
description = "Detach Camera hotkey, press this and it will activate detatched camera.",
|
||||
position = 4
|
||||
)
|
||||
default Keybind detachHotkey()
|
||||
{
|
||||
return Keybind.NOT_SET;
|
||||
}
|
||||
}
|
||||
@@ -37,12 +37,14 @@ import net.runelite.api.events.ScriptCallbackEvent;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import static net.runelite.api.widgets.WidgetInfo.*;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.Keybind;
|
||||
import net.runelite.client.config.RuneLitePlusConfig;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.input.KeyListener;
|
||||
import net.runelite.client.input.KeyManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.util.HotkeyListener;
|
||||
|
||||
@PluginDescriptor(
|
||||
loadWhenOutdated = true, // prevent users from disabling
|
||||
@@ -68,9 +70,22 @@ public class RuneLitePlusPlugin extends Plugin
|
||||
|
||||
@Inject
|
||||
private EventBus eventbus;
|
||||
|
||||
private HotkeyListener hotkeyListener = new HotkeyListener(() -> this.keybind)
|
||||
{
|
||||
@Override
|
||||
public void hotkeyPressed()
|
||||
{
|
||||
detach = !detach;
|
||||
client.setOculusOrbState(detach ? 1 : 0);
|
||||
client.setOculusOrbNormalSpeed(detach ? 36 : 12);
|
||||
}
|
||||
};
|
||||
private int entered = -1;
|
||||
private int enterIdx;
|
||||
private boolean expectInput;
|
||||
private boolean detach;
|
||||
private Keybind keybind;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
@@ -80,6 +95,8 @@ public class RuneLitePlusPlugin extends Plugin
|
||||
entered = -1;
|
||||
enterIdx = 0;
|
||||
expectInput = false;
|
||||
this.keybind = config.detachHotkey();
|
||||
keyManager.registerKeyListener(hotkeyListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,6 +108,7 @@ public class RuneLitePlusPlugin extends Plugin
|
||||
enterIdx = 0;
|
||||
expectInput = false;
|
||||
keyManager.unregisterKeyListener(keyListener);
|
||||
keyManager.unregisterKeyListener(hotkeyListener);
|
||||
}
|
||||
|
||||
private void onConfigChanged(ConfigChanged event)
|
||||
@@ -100,6 +118,8 @@ public class RuneLitePlusPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
this.keybind = config.detachHotkey();
|
||||
|
||||
if (!config.keyboardPin())
|
||||
{
|
||||
entered = 0;
|
||||
@@ -228,4 +248,4 @@ public class RuneLitePlusPlugin extends Plugin
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user