Merge pull request #5578 from MagicfTail/ctr-zoom-rs2asm
Add option to require control to be held for zooming
This commit is contained in:
@@ -34,7 +34,8 @@ public interface ZoomConfig extends Config
|
|||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "enabled",
|
keyName = "enabled",
|
||||||
name = "Expand outer zoom limit",
|
name = "Expand outer zoom limit",
|
||||||
description = "Configures whether or not the outer zoom limit is reduced"
|
description = "Configures whether or not the outer zoom limit is reduced",
|
||||||
|
position = 1
|
||||||
)
|
)
|
||||||
default boolean outerLimit()
|
default boolean outerLimit()
|
||||||
{
|
{
|
||||||
@@ -44,7 +45,8 @@ public interface ZoomConfig extends Config
|
|||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "inner",
|
keyName = "inner",
|
||||||
name = "Expand inner zoom limit",
|
name = "Expand inner zoom limit",
|
||||||
description = "Configures whether or not the inner zoom limit is reduced"
|
description = "Configures whether or not the inner zoom limit is reduced",
|
||||||
|
position = 2
|
||||||
)
|
)
|
||||||
default boolean innerLimit()
|
default boolean innerLimit()
|
||||||
{
|
{
|
||||||
@@ -54,10 +56,22 @@ public interface ZoomConfig extends Config
|
|||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "relaxCameraPitch",
|
keyName = "relaxCameraPitch",
|
||||||
name = "Vertical camera",
|
name = "Vertical camera",
|
||||||
description = "Relax the camera's upper pitch limit"
|
description = "Relax the camera's upper pitch limit",
|
||||||
|
position = 3
|
||||||
)
|
)
|
||||||
default boolean relaxCameraPitch()
|
default boolean relaxCameraPitch()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "requireControlDown",
|
||||||
|
name = "Require control down",
|
||||||
|
description = "Configures if holding control is required for zooming",
|
||||||
|
position = 4
|
||||||
|
)
|
||||||
|
default boolean requireControlDown()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,14 @@ package net.runelite.client.plugins.zoom;
|
|||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.events.ConfigChanged;
|
import net.runelite.api.events.ConfigChanged;
|
||||||
|
import net.runelite.api.events.FocusChanged;
|
||||||
import net.runelite.api.events.ScriptCallbackEvent;
|
import net.runelite.api.events.ScriptCallbackEvent;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.client.input.KeyListener;
|
||||||
|
import net.runelite.client.input.KeyManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
|
|
||||||
@@ -41,14 +45,19 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
tags = {"limit", "vertical"},
|
tags = {"limit", "vertical"},
|
||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
public class ZoomPlugin extends Plugin
|
public class ZoomPlugin extends Plugin implements KeyListener
|
||||||
{
|
{
|
||||||
|
private boolean controlDown;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ZoomConfig zoomConfig;
|
private ZoomConfig zoomConfig;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private KeyManager keyManager;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
ZoomConfig getConfig(ConfigManager configManager)
|
ZoomConfig getConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -67,6 +76,12 @@ public class ZoomPlugin extends Plugin
|
|||||||
|
|
||||||
int[] intStack = client.getIntStack();
|
int[] intStack = client.getIntStack();
|
||||||
int intStackSize = client.getIntStackSize();
|
int intStackSize = client.getIntStackSize();
|
||||||
|
|
||||||
|
if ("scrollWheelZoom".equals(event.getEventName()) && zoomConfig.requireControlDown() && !controlDown)
|
||||||
|
{
|
||||||
|
intStack[intStackSize - 1] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (zoomConfig.outerLimit())
|
if (zoomConfig.outerLimit())
|
||||||
{
|
{
|
||||||
switch (event.getEventName())
|
switch (event.getEventName())
|
||||||
@@ -117,16 +132,28 @@ public class ZoomPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onFocusChanged(FocusChanged event)
|
||||||
|
{
|
||||||
|
if (!event.isFocused())
|
||||||
|
{
|
||||||
|
controlDown = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp()
|
protected void startUp()
|
||||||
{
|
{
|
||||||
client.setCameraPitchRelaxerEnabled(zoomConfig.relaxCameraPitch());
|
client.setCameraPitchRelaxerEnabled(zoomConfig.relaxCameraPitch());
|
||||||
|
keyManager.registerKeyListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void shutDown()
|
protected void shutDown()
|
||||||
{
|
{
|
||||||
client.setCameraPitchRelaxerEnabled(false);
|
client.setCameraPitchRelaxerEnabled(false);
|
||||||
|
keyManager.unregisterKeyListener(this);
|
||||||
|
controlDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -134,4 +161,27 @@ public class ZoomPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
client.setCameraPitchRelaxerEnabled(zoomConfig.relaxCameraPitch());
|
client.setCameraPitchRelaxerEnabled(zoomConfig.relaxCameraPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyTyped(KeyEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e)
|
||||||
|
{
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_CONTROL)
|
||||||
|
{
|
||||||
|
controlDown = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent e)
|
||||||
|
{
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_CONTROL)
|
||||||
|
{
|
||||||
|
controlDown = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
E9536E0A6FD51C058A40D644FD0AD28A93778FD53873601DCCE04C97DD835BB0
|
49E9E1634C15928A1C5F03B8949E68C741D508A18B528CCB4B6D080EF29180D8
|
||||||
@@ -1,91 +1,48 @@
|
|||||||
.id 42
|
.id 39
|
||||||
.int_stack_count 2
|
.int_stack_count 1
|
||||||
.string_stack_count 0
|
.string_stack_count 0
|
||||||
.int_var_count 6
|
.int_var_count 4
|
||||||
.string_var_count 0
|
.string_var_count 0
|
||||||
|
load_int 1
|
||||||
|
load_int 0
|
||||||
|
load_string "scrollWheelZoom"
|
||||||
|
runelite_callback
|
||||||
|
if_icmpeq LABEL18
|
||||||
|
load_int 0
|
||||||
|
iload 0
|
||||||
|
load_int 5
|
||||||
|
imul
|
||||||
|
isub
|
||||||
|
istore 1
|
||||||
|
load_int 320
|
||||||
|
istore 2
|
||||||
|
load_int 256
|
||||||
|
istore 3
|
||||||
|
get_varbit 6357
|
||||||
|
load_int 0
|
||||||
|
if_icmpeq LABEL14
|
||||||
|
jump LABEL33
|
||||||
|
LABEL14:
|
||||||
get_varbit 4606
|
get_varbit 4606
|
||||||
load_int 0
|
load_int 0
|
||||||
if_icmpne LABEL4
|
if_icmpne LABEL18
|
||||||
jump LABEL5
|
jump LABEL19
|
||||||
LABEL4:
|
LABEL18:
|
||||||
return
|
return
|
||||||
LABEL5:
|
LABEL19:
|
||||||
load_int 700
|
get_zoom_distance
|
||||||
load_string "fixedInnerZoomLimit"
|
|
||||||
runelite_callback
|
|
||||||
iload 0
|
|
||||||
invoke 1046
|
|
||||||
istore 0
|
|
||||||
load_int 195
|
|
||||||
load_string "fixedOuterZoomLimit"
|
|
||||||
runelite_callback
|
|
||||||
iload 0
|
|
||||||
invoke 1045
|
|
||||||
istore 0
|
|
||||||
load_int 715
|
|
||||||
load_string "resizableInnerZoomLimit"
|
|
||||||
runelite_callback
|
|
||||||
iload 1
|
|
||||||
invoke 1046
|
|
||||||
istore 1
|
|
||||||
load_int 175
|
|
||||||
load_string "resizableOuterZoomLimit"
|
|
||||||
runelite_callback
|
|
||||||
iload 1
|
|
||||||
invoke 1045
|
|
||||||
istore 1
|
|
||||||
iload 0
|
|
||||||
iload 1
|
|
||||||
set_zoom_distance
|
|
||||||
load_int 0
|
|
||||||
istore 2
|
istore 2
|
||||||
load_int 0
|
|
||||||
istore 3
|
istore 3
|
||||||
get_viewport_size
|
iload 3
|
||||||
|
iload 1
|
||||||
|
add_percent
|
||||||
istore 3
|
istore 3
|
||||||
|
iload 2
|
||||||
|
iload 1
|
||||||
|
add_percent
|
||||||
istore 2
|
istore 2
|
||||||
iload 3
|
iload 3
|
||||||
load_int 334
|
iload 2
|
||||||
isub
|
invoke 42
|
||||||
istore 4
|
LABEL33:
|
||||||
iload 4
|
return
|
||||||
load_int 0
|
|
||||||
if_icmplt LABEL39
|
|
||||||
jump LABEL42
|
|
||||||
LABEL39:
|
|
||||||
load_int 0
|
|
||||||
istore 4
|
|
||||||
jump LABEL48
|
|
||||||
LABEL42:
|
|
||||||
iload 4
|
|
||||||
load_int 100
|
|
||||||
if_icmpgt LABEL46
|
|
||||||
jump LABEL48
|
|
||||||
LABEL46:
|
|
||||||
load_int 100
|
|
||||||
istore 4
|
|
||||||
LABEL48:
|
|
||||||
iload 0
|
|
||||||
iload 1
|
|
||||||
iload 0
|
|
||||||
isub
|
|
||||||
iload 4
|
|
||||||
imul
|
|
||||||
load_int 100
|
|
||||||
idiv
|
|
||||||
iadd
|
|
||||||
istore 5
|
|
||||||
load_int 25
|
|
||||||
load_int 25
|
|
||||||
iload 5
|
|
||||||
imul
|
|
||||||
load_int 256
|
|
||||||
idiv
|
|
||||||
iadd
|
|
||||||
set_camera_focal_point_height
|
|
||||||
iload 0
|
|
||||||
iload 1
|
|
||||||
put_varc 74
|
|
||||||
put_varc 73
|
|
||||||
invoke 1049
|
|
||||||
return
|
|
||||||
1
runelite-client/src/main/scripts/ZoomHandler.hash
Normal file
1
runelite-client/src/main/scripts/ZoomHandler.hash
Normal file
@@ -0,0 +1 @@
|
|||||||
|
E9536E0A6FD51C058A40D644FD0AD28A93778FD53873601DCCE04C97DD835BB0
|
||||||
91
runelite-client/src/main/scripts/ZoomHandler.rs2asm
Normal file
91
runelite-client/src/main/scripts/ZoomHandler.rs2asm
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
.id 42
|
||||||
|
.int_stack_count 2
|
||||||
|
.string_stack_count 0
|
||||||
|
.int_var_count 6
|
||||||
|
.string_var_count 0
|
||||||
|
get_varbit 4606
|
||||||
|
load_int 0
|
||||||
|
if_icmpne LABEL4
|
||||||
|
jump LABEL5
|
||||||
|
LABEL4:
|
||||||
|
return
|
||||||
|
LABEL5:
|
||||||
|
load_int 700
|
||||||
|
load_string "fixedInnerZoomLimit"
|
||||||
|
runelite_callback
|
||||||
|
iload 0
|
||||||
|
invoke 1046
|
||||||
|
istore 0
|
||||||
|
load_int 195
|
||||||
|
load_string "fixedOuterZoomLimit"
|
||||||
|
runelite_callback
|
||||||
|
iload 0
|
||||||
|
invoke 1045
|
||||||
|
istore 0
|
||||||
|
load_int 715
|
||||||
|
load_string "resizableInnerZoomLimit"
|
||||||
|
runelite_callback
|
||||||
|
iload 1
|
||||||
|
invoke 1046
|
||||||
|
istore 1
|
||||||
|
load_int 175
|
||||||
|
load_string "resizableOuterZoomLimit"
|
||||||
|
runelite_callback
|
||||||
|
iload 1
|
||||||
|
invoke 1045
|
||||||
|
istore 1
|
||||||
|
iload 0
|
||||||
|
iload 1
|
||||||
|
set_zoom_distance
|
||||||
|
load_int 0
|
||||||
|
istore 2
|
||||||
|
load_int 0
|
||||||
|
istore 3
|
||||||
|
get_viewport_size
|
||||||
|
istore 3
|
||||||
|
istore 2
|
||||||
|
iload 3
|
||||||
|
load_int 334
|
||||||
|
isub
|
||||||
|
istore 4
|
||||||
|
iload 4
|
||||||
|
load_int 0
|
||||||
|
if_icmplt LABEL39
|
||||||
|
jump LABEL42
|
||||||
|
LABEL39:
|
||||||
|
load_int 0
|
||||||
|
istore 4
|
||||||
|
jump LABEL48
|
||||||
|
LABEL42:
|
||||||
|
iload 4
|
||||||
|
load_int 100
|
||||||
|
if_icmpgt LABEL46
|
||||||
|
jump LABEL48
|
||||||
|
LABEL46:
|
||||||
|
load_int 100
|
||||||
|
istore 4
|
||||||
|
LABEL48:
|
||||||
|
iload 0
|
||||||
|
iload 1
|
||||||
|
iload 0
|
||||||
|
isub
|
||||||
|
iload 4
|
||||||
|
imul
|
||||||
|
load_int 100
|
||||||
|
idiv
|
||||||
|
iadd
|
||||||
|
istore 5
|
||||||
|
load_int 25
|
||||||
|
load_int 25
|
||||||
|
iload 5
|
||||||
|
imul
|
||||||
|
load_int 256
|
||||||
|
idiv
|
||||||
|
iadd
|
||||||
|
set_camera_focal_point_height
|
||||||
|
iload 0
|
||||||
|
iload 1
|
||||||
|
put_varc 74
|
||||||
|
put_varc 73
|
||||||
|
invoke 1049
|
||||||
|
return
|
||||||
Reference in New Issue
Block a user