Merge pull request #562 from Abextm/zoom-extend-inner
Zoom plugin: Relax inner zoom constraint
This commit is contained in:
@@ -37,10 +37,20 @@ public interface ZoomConfig extends Config
|
|||||||
{
|
{
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "enabled",
|
keyName = "enabled",
|
||||||
name = "Enabled",
|
name = "Expand outer zoom limit",
|
||||||
description = "Configures whether or not the zoom limit is reduced"
|
description = "Configures whether or not the outer zoom limit is reduced"
|
||||||
)
|
)
|
||||||
default boolean enabled()
|
default boolean outerLimit()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "inner",
|
||||||
|
name = "Expand inner zoom limit",
|
||||||
|
description = "Configures whether or not the inner zoom limit is reduced"
|
||||||
|
)
|
||||||
|
default boolean innerLimit()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,9 +41,6 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ZoomPlugin extends Plugin
|
public class ZoomPlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static final int INCREASED_RESIZABLE_ZOOM_LIMIT = 70;
|
|
||||||
private static final int INCREASED_FIXED_ZOOM_LIMIT = 95;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@@ -58,27 +55,56 @@ public class ZoomPlugin extends Plugin
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onScriptEvent(ScriptEvent event)
|
public void onScriptEvent(ScriptEvent event)
|
||||||
{
|
|
||||||
if (!zoomConfig.enabled())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (event.getEventName())
|
|
||||||
{
|
|
||||||
case "fixedOuterZoomLimit":
|
|
||||||
popAndReplace(INCREASED_FIXED_ZOOM_LIMIT);
|
|
||||||
break;
|
|
||||||
case "resizableOuterZoomLimit":
|
|
||||||
popAndReplace(INCREASED_RESIZABLE_ZOOM_LIMIT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void popAndReplace(int newValue)
|
|
||||||
{
|
{
|
||||||
int[] intStack = client.getIntStack();
|
int[] intStack = client.getIntStack();
|
||||||
int intStackSize = client.getIntStackSize();
|
int intStackSize = client.getIntStackSize();
|
||||||
intStack[intStackSize - 1] = newValue;
|
if (zoomConfig.outerLimit())
|
||||||
|
{
|
||||||
|
switch (event.getEventName())
|
||||||
|
{
|
||||||
|
case "fixedOuterZoomLimit":
|
||||||
|
intStack[intStackSize - 1] = 95;
|
||||||
|
break;
|
||||||
|
case "resizableOuterZoomLimit":
|
||||||
|
intStack[intStackSize - 1] = 70;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zoomConfig.innerLimit())
|
||||||
|
{
|
||||||
|
switch (event.getEventName())
|
||||||
|
{
|
||||||
|
case "fixedInnerZoomLimit":
|
||||||
|
intStack[intStackSize - 1] = 2100;
|
||||||
|
break;
|
||||||
|
case "resizableInnerZoomLimit":
|
||||||
|
intStack[intStackSize - 1] = 2200;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zoomConfig.outerLimit() || zoomConfig.innerLimit())
|
||||||
|
{
|
||||||
|
// This lets the options panel's slider have an exponential rate
|
||||||
|
final double exponent = 3.d;
|
||||||
|
switch (event.getEventName())
|
||||||
|
{
|
||||||
|
case "zoomLinToExp":
|
||||||
|
{
|
||||||
|
double range = intStack[intStackSize - 1];
|
||||||
|
double value = intStack[intStackSize - 2];
|
||||||
|
value = Math.pow(value / range, exponent) * range;
|
||||||
|
intStack[intStackSize - 2] = (int) value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "zoomExpToLin":
|
||||||
|
{
|
||||||
|
double range = intStack[intStackSize - 1];
|
||||||
|
double value = intStack[intStackSize - 2];
|
||||||
|
value = Math.pow(value / range, 1.d / exponent) * range;
|
||||||
|
intStack[intStackSize - 2] = (int) value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,6 +237,8 @@ LABEL198:
|
|||||||
LABEL210:
|
LABEL210:
|
||||||
get_varc 73
|
get_varc 73
|
||||||
load_int 700
|
load_int 700
|
||||||
|
load_string "fixedInnerZoomLimit"
|
||||||
|
runelite_callback
|
||||||
if_icmple LABEL214
|
if_icmple LABEL214
|
||||||
jump LABEL226
|
jump LABEL226
|
||||||
LABEL214:
|
LABEL214:
|
||||||
@@ -249,6 +251,8 @@ LABEL214:
|
|||||||
LABEL218:
|
LABEL218:
|
||||||
get_varc 74
|
get_varc 74
|
||||||
load_int 715
|
load_int 715
|
||||||
|
load_string "resizableInnerZoomLimit"
|
||||||
|
runelite_callback
|
||||||
if_icmple LABEL222
|
if_icmple LABEL222
|
||||||
jump LABEL226
|
jump LABEL226
|
||||||
LABEL222:
|
LABEL222:
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
.string_stack_count 0
|
.string_stack_count 0
|
||||||
.int_var_count 8
|
.int_var_count 8
|
||||||
.string_var_count 0
|
.string_var_count 0
|
||||||
|
; locals
|
||||||
|
; 2 bar size
|
||||||
get_varbit 4606
|
get_varbit 4606
|
||||||
load_int 0
|
load_int 0
|
||||||
if_icmpne LABEL4
|
if_icmpne LABEL4
|
||||||
@@ -33,22 +35,30 @@ LABEL5:
|
|||||||
invoke 1046
|
invoke 1046
|
||||||
istore 2
|
istore 2
|
||||||
load_int 715
|
load_int 715
|
||||||
|
load_string "resizableInnerZoomLimit"
|
||||||
|
runelite_callback
|
||||||
load_int 175
|
load_int 175
|
||||||
load_string "resizableOuterZoomLimit"
|
load_string "resizableOuterZoomLimit"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
isub
|
isub
|
||||||
istore 6
|
istore 6 ; resizable delta
|
||||||
load_int 700
|
load_int 700
|
||||||
|
load_string "fixedInnerZoomLimit"
|
||||||
|
runelite_callback
|
||||||
load_int 195
|
load_int 195
|
||||||
load_string "fixedOuterZoomLimit"
|
load_string "fixedOuterZoomLimit"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
isub
|
isub
|
||||||
istore 7
|
istore 7 ; fixed delta
|
||||||
iload 2
|
iload 2
|
||||||
iload 6
|
iload 6
|
||||||
imul
|
imul
|
||||||
iload 5
|
iload 5
|
||||||
idiv
|
idiv
|
||||||
|
iload 6
|
||||||
|
load_string "zoomLinToExp"
|
||||||
|
runelite_callback
|
||||||
|
pop_int
|
||||||
load_int 175
|
load_int 175
|
||||||
load_string "resizableOuterZoomLimit"
|
load_string "resizableOuterZoomLimit"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
@@ -58,7 +68,11 @@ LABEL5:
|
|||||||
iload 7
|
iload 7
|
||||||
imul
|
imul
|
||||||
iload 5
|
iload 5
|
||||||
idiv
|
idiv
|
||||||
|
iload 7
|
||||||
|
load_string "zoomLinToExp"
|
||||||
|
runelite_callback
|
||||||
|
pop_int
|
||||||
load_int 195
|
load_int 195
|
||||||
load_string "fixedOuterZoomLimit"
|
load_string "fixedOuterZoomLimit"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
|
|||||||
@@ -3,13 +3,21 @@
|
|||||||
.string_stack_count 0
|
.string_stack_count 0
|
||||||
.int_var_count 6
|
.int_var_count 6
|
||||||
.string_var_count 0
|
.string_var_count 0
|
||||||
|
; locals
|
||||||
|
; 0 resizableZoomRange
|
||||||
|
; 1 fixedZoomRange
|
||||||
|
; 2 bar size
|
||||||
load_int 715
|
load_int 715
|
||||||
|
load_string "resizableInnerZoomLimit"
|
||||||
|
runelite_callback
|
||||||
load_int 175
|
load_int 175
|
||||||
load_string "resizableOuterZoomLimit"
|
load_string "resizableOuterZoomLimit"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
isub
|
isub
|
||||||
istore 0
|
istore 0
|
||||||
load_int 700
|
load_int 700
|
||||||
|
load_string "fixedInnerZoomLimit"
|
||||||
|
runelite_callback
|
||||||
load_int 195
|
load_int 195
|
||||||
load_string "fixedOuterZoomLimit"
|
load_string "fixedOuterZoomLimit"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
@@ -39,7 +47,11 @@ LABEL27:
|
|||||||
load_int 175
|
load_int 175
|
||||||
load_string "resizableOuterZoomLimit"
|
load_string "resizableOuterZoomLimit"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
isub
|
isub
|
||||||
|
iload 0
|
||||||
|
load_string "zoomExpToLin"
|
||||||
|
runelite_callback
|
||||||
|
pop_int
|
||||||
iload 2
|
iload 2
|
||||||
imul
|
imul
|
||||||
iload 0
|
iload 0
|
||||||
@@ -51,7 +63,11 @@ LABEL36:
|
|||||||
load_int 195
|
load_int 195
|
||||||
load_string "fixedOuterZoomLimit"
|
load_string "fixedOuterZoomLimit"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
isub
|
isub
|
||||||
|
iload 1
|
||||||
|
load_string "zoomExpToLin"
|
||||||
|
runelite_callback
|
||||||
|
pop_int
|
||||||
iload 2
|
iload 2
|
||||||
imul
|
imul
|
||||||
iload 1
|
iload 1
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ LABEL4:
|
|||||||
return
|
return
|
||||||
LABEL5:
|
LABEL5:
|
||||||
load_int 700
|
load_int 700
|
||||||
|
load_string "fixedInnerZoomLimit"
|
||||||
|
runelite_callback
|
||||||
iload 0
|
iload 0
|
||||||
invoke 1046
|
invoke 1046
|
||||||
istore 0
|
istore 0
|
||||||
@@ -21,6 +23,8 @@ LABEL5:
|
|||||||
invoke 1045
|
invoke 1045
|
||||||
istore 0
|
istore 0
|
||||||
load_int 715
|
load_int 715
|
||||||
|
load_string "resizableInnerZoomLimit"
|
||||||
|
runelite_callback
|
||||||
iload 1
|
iload 1
|
||||||
invoke 1046
|
invoke 1046
|
||||||
istore 1
|
istore 1
|
||||||
|
|||||||
Reference in New Issue
Block a user