Merge pull request #1302 from ThatGamerBlue/flexo-removal

client: remove flexo for splitting
This commit is contained in:
Tyler Bochard
2019-08-12 17:34:32 -04:00
committed by GitHub
6 changed files with 0 additions and 1249 deletions

View File

@@ -31,7 +31,6 @@ dependencies {
implementation group: 'org.javassist', name: 'javassist', version: '3.25.0-GA'
implementation group: 'org.xeustechnologies', name: 'jcl-core', version: '2.8'
implementation group: 'org.jetbrains', name: 'annotations', version: '17.0.0'
implementation group: 'com.github.joonasvali.naturalmouse', name: 'naturalmouse', version: '[1.0.0,)'
implementation group: 'org.ow2.asm', name: 'asm-all', version: '6.0_BETA'
implementation group: 'org.codehaus.plexus', name: 'plexus-utils', version: '3.2.1'
implementation group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.11'

View File

@@ -1,317 +0,0 @@
/*
*
* Copyright (c) 2019, Zeruth <TheRealNull@gmail.com>
* 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 OWNER 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.
*
*/
/*
Modified java.awt.Robot for use with RuneLitePlus. Hopefully we can make it stand far apart.
Uses
https://github.com/JoonasVali/NaturalMouseMotion
for mouse motion.
*/
package net.runelite.client.flexo;
import com.github.joonasvali.naturalmouse.api.MouseMotionFactory;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.Random;
import java.util.logging.Logger;
import net.runelite.api.Client;
import net.runelite.api.Constants;
import net.runelite.client.ui.ClientUI;
public class Flexo extends Robot
{
public ThreadGroup flexoThreads = new ThreadGroup("flexo");
public static boolean isActive;
public static double scale;
public static Client client;
public static ClientUI clientUI;
public static final int fixedWidth = Constants.GAME_FIXED_WIDTH;
public static final int fixedHeight = Constants.GAME_FIXED_HEIGHT;
public static boolean isStretched;
public static int minDelay = 45;
public static MouseMotionFactory currentMouseMotionFactory;
public boolean pausedIndefinitely = false;
private Robot peer;
public Flexo() throws AWTException
{
if (GraphicsEnvironment.isHeadless())
{
throw new AWTException("headless environment");
}
init(GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice());
}
private void init(GraphicsDevice screen) throws AWTException
{
try
{
peer = new Robot();
}
catch (Exception e)
{
client.getLogger().error("Flexo not supported on this system configuration.");
}
}
private transient Object anchor = new Object();
private void pauseMS(int delayMS)
{
long initialMS = System.currentTimeMillis();
while (System.currentTimeMillis() < initialMS + delayMS)
{
try
{
Thread.sleep(10);
}
catch (Exception e)
{
e.printStackTrace();
}
}
isActive = false;
}
@Override
public synchronized void mouseMove(int x, int y)
{
try
{
//TODO: Must be better way to determine titlebar width
currentMouseMotionFactory.build(ClientUI.frame.getX() + x + determineHorizontalOffset(), ClientUI.frame.getY() + y + determineVerticalOffset()).move();
this.delay(getMinDelay());
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
public synchronized void mouseMove(Point p)
{
mouseMove((int) p.getX(), (int) p.getY());
try
{
Thread.sleep(150);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
@Override
public synchronized void mousePress(int buttonID)
{
if (buttonID < 1 || buttonID > 5)
{
Logger.getAnonymousLogger().warning("Invalid mouse button ID. please use 1-5.");
return;
}
peer.mousePress(InputEvent.getMaskForButton(buttonID));
this.delay(getMinDelay());
}
public synchronized void mousePressAndRelease(int buttonID)
{
if (buttonID < 1 || buttonID > 5)
{
Logger.getAnonymousLogger().warning("Invalid mouse button ID. please use 1-5.");
return;
}
peer.mousePress(InputEvent.getMaskForButton(buttonID));
this.delay(getMinDelay());
peer.mouseRelease(InputEvent.getMaskForButton(buttonID));
this.delay(getMinDelay());
}
//TODO: Symbols are nut supported at this time
public synchronized void typeMessage(String message)
{
Random r = new Random();
char[] charArray = message.toCharArray();
for (char c : charArray)
{
keyPress(KeyEvent.getExtendedKeyCodeForChar(c));
this.delay(93 + r.nextInt(getMinDelay()));
}
keyPress(KeyEvent.VK_ENTER);
this.delay(93 + r.nextInt(getMinDelay()));
ClientUI.allowInput = true;
}
@Override
public synchronized void mouseRelease(int buttonID)
{
if (buttonID < 1 || buttonID > 5)
{
Logger.getAnonymousLogger().warning("Invalid mouse button ID. please use 1-5.");
return;
}
peer.mouseRelease(InputEvent.getMaskForButton(buttonID));
this.delay(getMinDelay());
}
private int getMinDelay()
{
Random random = new Random();
int random1 = random.nextInt(minDelay);
if (random1 < minDelay / 2)
{
random1 = random.nextInt(minDelay / 2) + minDelay / 2 + random.nextInt(minDelay / 2);
}
return random1;
}
private int getWheelDelay()
{
Random random = new Random();
int random1 = random.nextInt(minDelay);
if (random1 < minDelay / 2)
{
random1 = random.nextInt(minDelay / 2) + minDelay / 2 + random.nextInt(minDelay / 2);
}
return random1;
}
/**
* Rotates the scroll wheel on wheel-equipped mice.
*
* @param wheelAmt number of "notches" to move the mouse wheel
* Negative values indicate movement up/away from the user,
* positive values indicate movement down/towards the user.
* @since 1.4
*/
@Override
public synchronized void mouseWheel(int wheelAmt)
{
for (int i : new int[wheelAmt])
{
peer.mouseWheel(wheelAmt);
this.delay(getWheelDelay());
}
}
/**
* Presses a given key. The key should be released using the
* <code>keyRelease</code> method.
* <p>
* Key codes that have more than one physical key associated with them
* (e.g. <code>KeyEvent.VK_SHIFT</code> could mean either the
* left or right shift key) will map to the left key.
*
* @param keycode Key to press (e.g. <code>KeyEvent.VK_A</code>)
* @throws IllegalArgumentException if <code>keycode</code> is not
* a valid key
* @see #keyRelease(int)
* @see java.awt.event.KeyEvent
*/
@Override
public synchronized void keyPress(int keycode)
{
peer.keyPress(keycode);
this.delay(getMinDelay());
}
@Override
public synchronized void keyRelease(int keycode)
{
peer.keyRelease(keycode);
this.delay(getMinDelay());
}
public synchronized void holdKey(int keycode, int timeMS)
{
new Thread(() ->
{
peer.keyPress(keycode);
long startTime = System.currentTimeMillis();
while ((startTime + timeMS) > System.currentTimeMillis())
{
}
peer.keyRelease(keycode);
this.delay(getMinDelay());
}).start();
}
public synchronized void holdKeyIndefinitely(int keycode)
{
Thread holdKeyThread = new Thread(() ->
{
pausedIndefinitely = true;
peer.keyPress(keycode);
while (pausedIndefinitely)
{
try
{
Thread.sleep(10);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
peer.keyRelease(keycode);
this.delay(getMinDelay());
});
holdKeyThread.start();
}
public Color getPixelColor(int x, int y)
{
return peer.getPixelColor(x, y);
}
@Override
public void delay(int ms)
{
pauseMS(ms);
}
public int determineHorizontalOffset()
{
return clientUI.getCanvasOffset().getX();
}
public int determineVerticalOffset()
{
return clientUI.getCanvasOffset().getY();
}
}

View File

@@ -1,225 +0,0 @@
/*
*
* Copyright (c) 2019, Zeruth <TheRealNull@gmail.com>
* 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 OWNER 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.flexo;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.Random;
import java.util.logging.Logger;
import net.runelite.api.Constants;
import net.runelite.client.ui.ClientUI;
public class FlexoMouse
{
/*
Should pass unstretched coords, handles all conversions here.
*/
public static Point getClickPoint(Rectangle rect)
{
if (rect != null)
{
Random r = new Random();
int x = -1;
int y = -1;
x = rect.x + r.nextInt(rect.width);
y = rect.y + r.nextInt(rect.height);
if (Flexo.isStretched)
{
double wScale;
double hScale;
if (Flexo.client.isResized())
{
wScale = (Flexo.client.getStretchedDimensions().width / (double) Flexo.client.getRealDimensions().width);
hScale = (Flexo.client.getStretchedDimensions().height / (double) Flexo.client.getRealDimensions().height);
int newX = (int) (x * wScale);
int newY = (int) (y * hScale);
if (newX > 0 && newX < ClientUI.frame.getWidth())
{
if (newY > 0 && newY < ClientUI.frame.getHeight())
{
return new Point(newX, newY);
}
}
Logger.getAnonymousLogger().warning("[RuneLit]Flexo - Off screen point attempted. Split the step, or rotate the screen.");
return null;
}
else
{
if (x > 0 && x < ClientUI.frame.getWidth())
{
if (y > 0 && y < ClientUI.frame.getHeight())
{
return new Point(x, y);
}
}
Logger.getAnonymousLogger().warning("[RuneLit]Flexo - Off screen point attempted. Split the step, or rotate the screen.");
return null;
}
}
else if (!Flexo.client.isResized())
{
final int fixedWidth = Constants.GAME_FIXED_WIDTH;
int widthDif = ClientUI.frame.getWidth();
if (ClientUI.pluginToolbar.isVisible())
{
widthDif -= ClientUI.pluginToolbar.getWidth();
}
if (ClientUI.pluginPanel != null)
{
widthDif -= ClientUI.pluginPanel.getWidth();
}
widthDif -= fixedWidth;
if (x + (widthDif / 2) > 0 && x + (widthDif / 2) < ClientUI.frame.getWidth())
{
if (y > 0 && y < ClientUI.frame.getHeight())
{
return new Point(x, y);
}
}
Logger.getAnonymousLogger().warning("[RuneLit]Flexo - Off screen point attempted. Split the step, or rotate the screen.");
return null;
}
else
{
if (x > 0 && x < ClientUI.frame.getWidth())
{
if (y > 0 && y < ClientUI.frame.getHeight())
{
return new Point(x, y);
}
}
Logger.getAnonymousLogger().warning("[RuneLit]Flexo - Off screen point attempted. Split the step, or rotate the screen.");
return null;
}
}
return null;
}
public static Rectangle getClickArea(Rectangle rect)
{
if (Flexo.isStretched)
{
double wScale;
double hScale;
if (Flexo.client.isResized())
{
wScale = (Flexo.client.getStretchedDimensions().width / (double) Flexo.client.getRealDimensions().width);
hScale = (Flexo.client.getStretchedDimensions().height / (double) Flexo.client.getRealDimensions().height);
}
else
{
wScale = (Flexo.client.getStretchedDimensions().width) / (double) Flexo.fixedWidth;
hScale = (Flexo.client.getStretchedDimensions().height) / (double) Flexo.fixedHeight;
}
int xPadding = (int) rect.getWidth() / 5;
int yPadding = (int) rect.getHeight() / 5;
Random r = new Random();
Rectangle clickRect = new Rectangle();
clickRect.width = rect.width - xPadding * 2;
clickRect.height = rect.height - yPadding * 2;
clickRect.x = rect.x + xPadding;
clickRect.y = rect.y + yPadding;
if (clickRect.width > 0 && clickRect.height > 0)
{
int x = clickRect.x + r.nextInt(clickRect.width);
int y = clickRect.y + r.nextInt(clickRect.height);
double tScale = 1 + (Flexo.scale / 100);
if (Flexo.client.isResized())
{
return new Rectangle((int) (clickRect.x * wScale), (int) (clickRect.y * wScale), (int) (clickRect.width * wScale), (int) (clickRect.getHeight() * hScale));
}
else
{
return new Rectangle(clickRect.x, clickRect.y, clickRect.width, (int) (clickRect.getHeight()));
}
}
}
//Fixed, not stretched
else if (!Flexo.client.isResized())
{
int fixedWidth = 765;
int widthDif = ClientUI.frame.getWidth();
if (ClientUI.pluginToolbar.isVisible())
{
widthDif -= ClientUI.pluginToolbar.getWidth();
}
if (ClientUI.pluginPanel != null)
{
widthDif -= ClientUI.pluginPanel.getWidth();
}
widthDif -= fixedWidth;
int xPadding = (int) rect.getWidth() / 5;
int yPadding = (int) rect.getHeight() / 5;
Random r = new Random();
Rectangle clickRect = new Rectangle();
clickRect.width = rect.width - xPadding;
clickRect.height = rect.height - yPadding;
clickRect.x = rect.x + xPadding;
clickRect.y = rect.y + yPadding;
if (clickRect.height > 0 && clickRect.width > 0)
{
int x = clickRect.x + r.nextInt(clickRect.width);
int y = clickRect.y + r.nextInt(clickRect.height);
return new Rectangle(clickRect.x, clickRect.y, clickRect.width, (int) (clickRect.getHeight()));
}
}
//Resizable, not stretched
else
{
int xPadding = (int) rect.getWidth() / 5;
int yPadding = (int) rect.getHeight() / 5;
Random r = new Random();
Rectangle clickRect = new Rectangle();
clickRect.width = rect.width - xPadding * 2;
clickRect.height = rect.height - yPadding * 2;
clickRect.x = rect.x + xPadding;
clickRect.y = rect.y + yPadding;
if (clickRect.height > 0 && clickRect.width > 0)
{
int x = clickRect.x + r.nextInt(clickRect.width);
int y = clickRect.y + r.nextInt(clickRect.height);
return new Rectangle(clickRect.x, clickRect.y, clickRect.width, (int) (clickRect.getHeight()));
}
}
return null;
}
}

View File

@@ -1,271 +0,0 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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 OWNER 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.flexo;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Stub;
@ConfigGroup("flexo")
public interface FlexoConfig extends Config
{
@ConfigItem(
keyName = "overlayStub",
name = "Overlay",
description = "",
position = 1
)
default Stub overlayStub()
{
return new Stub();
}
@ConfigItem(
position = 2,
keyName = "overlayEnabled",
name = "Overlay Enabled",
description = "Shows clicking area and points etc.",
parent = "overlayStub"
)
default boolean overlayEnabled()
{
return true;
}
@ConfigItem(
position = 3,
keyName = "debugNPCs",
name = "Debug NPCs",
description = "Draws clickArea and clickPoints across all visible npcs",
parent = "overlayStub",
hidden = true,
unhide = "overlayEnabled"
)
default boolean getDebugNPCs()
{
return false;
}
@ConfigItem(
position = 4,
keyName = "debugPlayers",
name = "Debug Players",
description = "Draws clickArea and clickPoints across all visible players",
parent = "overlayStub",
hidden = true,
unhide = "overlayEnabled"
)
default boolean getDebugPlayers()
{
return false;
}
@ConfigItem(
position = 5,
keyName = "debugGroundItems",
name = "Debug Ground Items",
description = "Draws clickArea and clickPoints across all visible ground items",
parent = "overlayStub",
hidden = true,
unhide = "overlayEnabled"
)
default boolean getDebugGroundItems()
{
return false;
}
@ConfigItem(
keyName = "mouseStub",
name = "Mouse",
description = "",
position = 6
)
default Stub mouseStub()
{
return new Stub();
}
@ConfigItem(
position = 7,
keyName = "minDelayAmount",
name = "Min Delay",
description = "Minimum delay that is applied to every action at the end (ms)",
parent = "mouseStub"
)
default int minDelayAmt()
{
return 45;
}
@ConfigItem(
position = 8,
keyName = "reactionTime",
name = "Reaction Time",
description = "The base time between actions (ms)",
parent = "mouseStub"
)
default int getReactionTimeVariation()
{
return 80;
}
@ConfigItem(
position = 9,
keyName = "mouseDragSpeed",
name = "Mouse drag speed",
description = "The speed at which steps are executed. Keep at 49? cuz jagex mouse recorder?",
parent = "mouseStub"
)
default int getMouseDragSpeed()
{
return 49;
}
@ConfigItem(
position = 10,
keyName = "overshoots",
name = "Overshoots",
description = "Higher number = more overshoots",
parent = "mouseStub"
)
default int getOvershoots()
{
return 4;
}
@ConfigItem(
position = 11,
keyName = "variatingFlow",
name = "Flow - Variating",
description = "",
parent = "mouseStub"
)
default boolean getVariatingFlow()
{
return true;
}
@ConfigItem(
position = 12,
keyName = "slowStartupFlow",
name = "Flow - Slow startup",
description = "",
parent = "mouseStub"
)
default boolean getSlowStartupFlow()
{
return true;
}
@ConfigItem(
position = 13,
keyName = "slowStartup2Flow",
name = "Flow - Slow startup 2",
description = "",
parent = "mouseStub"
)
default boolean getSlowStartup2Flow()
{
return true;
}
@ConfigItem(
position = 14,
keyName = "jaggedFlow",
name = "Flow - Jagged",
description = "",
parent = "mouseStub"
)
default boolean getJaggedFlow()
{
return true;
}
@ConfigItem(
position = 15,
keyName = "interruptedFlow",
name = "Flow - Interrupted",
description = "",
parent = "mouseStub"
)
default boolean getInterruptedFlow()
{
return false;
}
@ConfigItem(
position = 16,
keyName = "interruptedFlow2",
name = "Flow - Interrupted 2",
description = "",
parent = "mouseStub"
)
default boolean getInterruptedFlow2()
{
return false;
}
@ConfigItem(
position = 17,
keyName = "stoppingFlow",
name = "Flow - Stopping",
description = "",
parent = "mouseStub"
)
default boolean getStoppingFlow()
{
return false;
}
@ConfigItem(
position = 18,
keyName = "deviationSlopeDivider",
name = "Deviation slope divider",
description = "",
parent = "mouseStub"
)
default int getDeviationSlope()
{
return 10;
}
@ConfigItem(
position = 19,
keyName = "noisinessDivider",
name = "Noisiness divider",
description = "",
parent = "mouseStub"
)
default String getNoisinessDivider()
{
return "2.0D";
}
}

View File

@@ -1,99 +0,0 @@
/*
*
* Copyright (c) 2019, Zeruth <TheRealNull@gmail.com>
* 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 OWNER 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.flexo;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Line2D;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
@Singleton
public class FlexoOverlay extends Overlay
{
@Inject
private FlexoPlugin plugin;
@Inject
public FlexoOverlay(final FlexoPlugin plugin)
{
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_WIDGETS);
this.plugin = plugin;
}
@Override
public Dimension render(Graphics2D graphics)
{
if (!plugin.isOverlayEnabled())
{
return null;
}
if (plugin.isDebugNPCs() || plugin.isDebugGroundItems() || plugin.isDebugPlayers())
{
List<Rectangle> clickAreas = plugin.getClickAreas();
if (clickAreas != null)
{
for (Rectangle clickArea : clickAreas)
{
if (clickArea != null)
{
graphics.draw(clickArea);
}
}
}
List<Point> clickPoints = plugin.getClickPoints();
if (clickPoints != null)
{
for (Point p : clickPoints)
{
if (p != null)
{
graphics.setColor(Color.MAGENTA);
graphics.draw(new Line2D.Double(p.x, p.y, p.x, p.y));
graphics.draw(new Line2D.Double(p.x - 1, p.y - 1, p.x - 1, p.y - 1));
graphics.draw(new Line2D.Double(p.x + 1, p.y + 1, p.x + 1, p.y + 1));
graphics.draw(new Line2D.Double(p.x - 1, p.y + 1, p.x - 1, p.y + 1));
graphics.draw(new Line2D.Double(p.x + 1, p.y - 1, p.x + 1, p.y - 1));
}
}
}
}
return null;
}
}

View File

@@ -1,336 +0,0 @@
/*
*
* Copyright (c) 2019, Zeruth <TheRealNull@gmail.com>
* 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 OWNER 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.flexo;
import com.github.joonasvali.naturalmouse.api.MouseMotionFactory;
import com.github.joonasvali.naturalmouse.support.DefaultNoiseProvider;
import com.github.joonasvali.naturalmouse.support.DefaultOvershootManager;
import com.github.joonasvali.naturalmouse.support.DefaultSpeedManager;
import com.github.joonasvali.naturalmouse.support.Flow;
import com.github.joonasvali.naturalmouse.support.SinusoidalDeviationProvider;
import com.github.joonasvali.naturalmouse.util.FlowTemplates;
import com.google.inject.Provides;
import java.awt.AWTException;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.NPC;
import net.runelite.api.Perspective;
import net.runelite.api.Player;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.events.BeforeRender;
import net.runelite.api.events.ConfigChanged;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.flexo.Flexo;
import net.runelite.client.flexo.FlexoMouse;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.grounditems.GroundItem;
import net.runelite.client.plugins.grounditems.GroundItemsPlugin;
import net.runelite.client.plugins.stretchedmode.StretchedModeConfig;
import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.overlay.OverlayManager;
@PluginDescriptor(
name = "Flexo Config",
description = "Customizes the flexo api",
tags = {"flexo", "null"},
type = PluginType.EXTERNAL,
enabledByDefault = false
)
public class FlexoPlugin extends Plugin
{
private Flexo flexo;
{
try
{
flexo = new Flexo();
}
catch (AWTException e)
{
e.printStackTrace();
}
}
@Inject
private Client client;
@Inject
private ClientUI clientUI;
@Inject
private ConfigManager configManager;
@Inject
private OverlayManager overlayManager;
@Inject
private FlexoOverlay overlay;
@Inject
private FlexoConfig config;
@Inject
private EventBus eventBus;
@Provides
FlexoConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(FlexoConfig.class);
}
@Getter(AccessLevel.PACKAGE)
private boolean overlayEnabled;
@Getter(AccessLevel.PACKAGE)
private boolean debugNPCs;
@Getter(AccessLevel.PACKAGE)
private boolean debugPlayers;
@Getter(AccessLevel.PACKAGE)
private boolean debugGroundItems;
private int minDelayAmt;
private int getReactionTimeVariation;
private int getMouseDragSpeed;
private int getOvershoots;
private boolean getVariatingFlow;
private boolean getSlowStartupFlow;
private boolean getSlowStartup2Flow;
private boolean getJaggedFlow;
private boolean getInterruptedFlow;
private boolean getInterruptedFlow2;
private boolean getStoppingFlow;
private int getDeviationSlope;
private String getNoisinessDivider;
private int scalingFactor;
@Getter(AccessLevel.PACKAGE)
private List<Rectangle> clickAreas = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private List<Point> clickPoints = new ArrayList<>();
private void onConfigChanged(ConfigChanged event)
{
if (event.getGroup().equals("flexo") || event.getGroup().equals("stretchedmode"))
{
updateConfig();
updateMouseMotionFactory();
}
}
private void onBeforeRender(BeforeRender event)
{
if (Flexo.client == null)
{
Flexo.client = client;
}
if (Flexo.clientUI == null)
{
Flexo.clientUI = clientUI;
}
this.clickAreas = new ArrayList<>();
this.clickPoints = new ArrayList<>();
if (this.debugNPCs)
{
Flexo.isStretched = client.isStretchedEnabled();
Flexo.scale = this.scalingFactor;
if (flexo != null)
{
for (NPC npc : client.getNpcs())
{
if (npc != null && npc.getConvexHull() != null)
{
Rectangle r = FlexoMouse.getClickArea(npc.getConvexHull().getBounds());
this.clickAreas.add(r);
java.awt.Point p = FlexoMouse.getClickPoint(r);
this.clickPoints.add(p);
}
}
}
}
if (this.debugPlayers)
{
Flexo.isStretched = client.isStretchedEnabled();
Flexo.scale = this.scalingFactor;
if (flexo != null)
{
for (Player player : client.getPlayers())
{
if (player != null && player.getConvexHull() != null)
{
Rectangle r = FlexoMouse.getClickArea(player.getConvexHull().getBounds());
this.clickAreas.add(r);
java.awt.Point p = FlexoMouse.getClickPoint(r);
this.clickPoints.add(p);
}
}
}
}
// Could still use some improvement
if (this.debugGroundItems)
{
Flexo.isStretched = client.isStretchedEnabled();
Flexo.scale = this.scalingFactor;
if (flexo != null && GroundItemsPlugin.getCollectedGroundItems() != null)
{
for (GroundItem gi : GroundItemsPlugin.getCollectedGroundItems().values())
{
if (gi != null)
{
LocalPoint lp = LocalPoint.fromWorld(client, gi.getLocation());
if (lp != null && Perspective.getCanvasTilePoly(client, lp) != null)
{
Rectangle r1 = FlexoMouse.getClickArea(Perspective.getCanvasTilePoly(client, lp).getBounds());
Rectangle r2 = FlexoMouse.getClickArea(r1);
Rectangle r3 = FlexoMouse.getClickArea(r2);
this.clickAreas.add(r3);
java.awt.Point p = FlexoMouse.getClickPoint(r3);
this.clickPoints.add(p);
}
}
}
}
}
}
private void updateMouseMotionFactory()
{
Flexo.minDelay = this.minDelayAmt;
MouseMotionFactory factory = new MouseMotionFactory();
// TODO:Add Options for various flows to allow more personalization
List<Flow> flows = new ArrayList<>();
// Always add random
flows.add(new Flow(FlowTemplates.random()));
if (this.getVariatingFlow)
{
flows.add(new Flow(FlowTemplates.variatingFlow()));
}
if (this.getSlowStartupFlow)
{
flows.add(new Flow(FlowTemplates.slowStartupFlow()));
}
if (this.getSlowStartup2Flow)
{
flows.add(new Flow(FlowTemplates.slowStartup2Flow()));
}
if (this.getJaggedFlow)
{
flows.add(new Flow(FlowTemplates.jaggedFlow()));
}
if (this.getInterruptedFlow)
{
flows.add(new Flow(FlowTemplates.interruptedFlow()));
}
if (this.getInterruptedFlow2)
{
flows.add(new Flow(FlowTemplates.interruptedFlow2()));
}
if (this.getStoppingFlow)
{
flows.add(new Flow(FlowTemplates.stoppingFlow()));
}
DefaultSpeedManager manager = new DefaultSpeedManager(flows);
//TODO:Add options for custom Deviation Provider and Noise Provider
factory.setDeviationProvider(new SinusoidalDeviationProvider(this.getDeviationSlope));
factory.setNoiseProvider(new DefaultNoiseProvider(Double.valueOf(this.getNoisinessDivider)));
factory.getNature().setReactionTimeVariationMs(this.getReactionTimeVariation);
manager.setMouseMovementBaseTimeMs(this.getMouseDragSpeed);
DefaultOvershootManager overshootManager = (DefaultOvershootManager) factory.getOvershootManager();
overshootManager.setOvershoots(this.getOvershoots);
factory.setSpeedManager(manager);
Flexo.currentMouseMotionFactory = factory;
}
@Override
protected void startUp() throws Exception
{
updateConfig();
addSubscriptions();
Flexo.isStretched = client.isStretchedEnabled();
overlayManager.add(overlay);
updateMouseMotionFactory();
}
@Override
protected void shutDown() throws Exception
{
eventBus.unregister(this);
overlayManager.remove(overlay);
}
private void addSubscriptions()
{
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(BeforeRender.class, this, this::onBeforeRender);
}
private void updateConfig()
{
this.overlayEnabled = config.overlayEnabled();
this.debugNPCs = config.getDebugNPCs();
this.debugPlayers = config.getDebugPlayers();
this.debugGroundItems = config.getDebugGroundItems();
this.minDelayAmt = config.minDelayAmt();
this.getReactionTimeVariation = config.getReactionTimeVariation();
this.getMouseDragSpeed = config.getMouseDragSpeed();
this.getOvershoots = config.getOvershoots();
this.getVariatingFlow = config.getVariatingFlow();
this.getSlowStartupFlow = config.getSlowStartupFlow();
this.getSlowStartup2Flow = config.getSlowStartup2Flow();
this.getJaggedFlow = config.getJaggedFlow();
this.getInterruptedFlow = config.getInterruptedFlow();
this.getInterruptedFlow2 = config.getInterruptedFlow2();
this.getStoppingFlow = config.getStoppingFlow();
this.getDeviationSlope = config.getDeviationSlope();
this.getNoisinessDivider = config.getNoisinessDivider();
this.scalingFactor = configManager.getConfig(StretchedModeConfig.class).scalingFactor();
}
}