diff --git a/runelite-api/src/main/java/net/runelite/api/ScriptID.java b/runelite-api/src/main/java/net/runelite/api/ScriptID.java
index 56f29fb073..355aa5cffa 100644
--- a/runelite-api/src/main/java/net/runelite/api/ScriptID.java
+++ b/runelite-api/src/main/java/net/runelite/api/ScriptID.java
@@ -139,6 +139,17 @@ public final class ScriptID
*/
public static final int DIARY_QUEST_UPDATE_LINECOUNT = 2523;
+ /**
+ * Handles zoom input
+ *
+ * Updates the VarClientInts (73, 74) to this same value
+ *
+ * - int Reset zoom position
+ * - int Reset zoom position
+ *
+ */
+ public static final int CAMERA_DO_ZOOM = 42;
+
/**
* Does nothing
*
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ControlFunction.java b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ControlFunction.java
new file mode 100644
index 0000000000..1f3b431808
--- /dev/null
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ControlFunction.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019, Jacob M
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package net.runelite.client.plugins.zoom;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum ControlFunction
+{
+ NONE("None"),
+ CONTROL_TO_ZOOM("Hold to zoom"),
+ CONTROL_TO_RESET("Reset zoom");
+
+ private final String name;
+
+ @Override
+ public String toString()
+ {
+ return getName();
+ }
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java
index 577ddf03ab..0bc1f33140 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java
@@ -73,13 +73,28 @@ public interface ZoomConfig extends Config
}
@ConfigItem(
- keyName = "requireControlDown",
- name = "Require control down",
- description = "Configures if holding control is required for zooming",
+ keyName = "controlFunction",
+ name = "Control Function",
+ description = "Configures the zoom function when control is pressed",
position = 4
)
- default boolean requireControlDown()
+ default ControlFunction controlFunction()
{
- return false;
+ return ControlFunction.NONE;
+ }
+
+ @ConfigItem(
+ keyName = "ctrlZoomValue",
+ name = "Reset zoom position",
+ description = "Position of zoom when it is reset",
+ position = 5
+ )
+ @Range(
+ min = OUTER_LIMIT_MIN,
+ max = OUTER_LIMIT_MAX
+ )
+ default int ctrlZoomValue()
+ {
+ return 512;
}
}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java
index 6a46934de3..db5ffaa5ca 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java
@@ -30,9 +30,11 @@ import com.google.inject.Inject;
import com.google.inject.Provides;
import java.awt.event.KeyEvent;
import net.runelite.api.Client;
+import net.runelite.api.ScriptID;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.ScriptCallbackEvent;
+import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.input.KeyListener;
@@ -60,6 +62,9 @@ public class ZoomPlugin extends Plugin implements KeyListener
@Inject
private Client client;
+ @Inject
+ private ClientThread clientThread;
+
@Inject
private ZoomConfig zoomConfig;
@@ -85,7 +90,7 @@ public class ZoomPlugin extends Plugin implements KeyListener
int[] intStack = client.getIntStack();
int intStackSize = client.getIntStackSize();
- if ("scrollWheelZoom".equals(event.getEventName()) && zoomConfig.requireControlDown() && !controlDown)
+ if (!controlDown && "scrollWheelZoom".equals(event.getEventName()) && zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_ZOOM)
{
intStack[intStackSize - 1] = 1;
}
@@ -138,7 +143,7 @@ public class ZoomPlugin extends Plugin implements KeyListener
controlDown = false;
}
}
-
+
@Override
protected void startUp()
{
@@ -180,6 +185,12 @@ public class ZoomPlugin extends Plugin implements KeyListener
if (e.getKeyCode() == KeyEvent.VK_CONTROL)
{
controlDown = false;
+
+ if (zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_RESET)
+ {
+ final int zoomValue = Ints.constrainToRange(zoomConfig.ctrlZoomValue(), zoomConfig.OUTER_LIMIT_MIN, INNER_ZOOM_LIMIT);
+ clientThread.invokeLater(() -> client.runScript(ScriptID.CAMERA_DO_ZOOM, zoomValue, zoomValue));
+ }
}
}
}