Skip to content

Commit

Permalink
Merge pull request #364 from chsami/development
Browse files Browse the repository at this point in the history
1.4.4
  • Loading branch information
chsami authored Aug 20, 2024
2 parents f5d9547 + 5fe833d commit 7f5ef0d
Show file tree
Hide file tree
Showing 129 changed files with 7,907 additions and 474 deletions.
6 changes: 0 additions & 6 deletions runelite-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@
<artifactId>RoaringBitmap</artifactId>
<version>0.9.44</version>
</dependency>
<!-- Archive Patcher library -->
<dependency>
<groupId>com.google.archivepatcher</groupId>
<artifactId>archive-patch-applier</artifactId>
<version>1.0.4</version>
</dependency>
<!-- CFR decompiler library -->
<dependency>
<groupId>org.benf</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,8 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.primitives.Ints;
import com.google.inject.Provides;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import javax.inject.Inject;
import javax.swing.SwingUtilities;
import net.runelite.api.Client;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.ScriptID;
import net.runelite.api.SettingID;
import net.runelite.api.VarClientInt;
import net.runelite.api.VarPlayer;
import net.runelite.api.events.BeforeRender;
import net.runelite.api.events.ClientTick;
import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.api.events.ScriptPreFired;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.*;
import net.runelite.api.events.*;
import net.runelite.api.widgets.ComponentID;
import net.runelite.api.widgets.InterfaceID;
import net.runelite.api.widgets.JavaScriptCallback;
Expand All @@ -63,6 +48,11 @@
import net.runelite.client.ui.overlay.tooltip.Tooltip;
import net.runelite.client.ui.overlay.tooltip.TooltipManager;

import javax.inject.Inject;
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;

@PluginDescriptor(
name = "Camera",
description = "Expands zoom limit, provides vertical camera, and remaps mouse input keys",
Expand Down Expand Up @@ -274,7 +264,7 @@ public void keyTyped(KeyEvent e)
@Override
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_CONTROL)
if (e.getKeyCode() == KeyEvent.VK_F1)
{
controlDown = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ private JPanel createOptionsPanel()
container.add(plugin.getValidMovement());
container.add(plugin.getMovementFlags());
container.add(plugin.getInteracting());
container.add(plugin.getMouseClick());
container.add(plugin.getMouseMovement());
container.add(plugin.getExamine());

container.add(plugin.getDetachedCamera());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,50 @@ public class DevToolsPlugin extends Plugin

@Inject
private ChatMessageManager chatMessageManager;

@Inject
private DevToolsConfig config;
private final HotkeyListener swingInspectorHotkeyListener = new HotkeyListener(() -> config.swingInspectorHotkey()) {
Object inspector;

@Override
public void hotkeyPressed() {
Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
try {
if (inspector == null) {
JRootPane rootPane = ((RootPaneContainer) window).getRootPane();
FlatInspector fi = new FlatInspector(rootPane);
fi.setEnabled(true);
inspector = fi;
fi.addPropertyChangeListener(ev ->
{
if ("enabled".equals(ev.getPropertyName()) && !fi.isEnabled() && inspector == ev.getSource()) {
inspector = null;
}
});
} else {
((FlatInspector) inspector).setEnabled(false);
}
} catch (LinkageError | Exception e) {
log.warn("unable to open swing inspector", e);
JOptionPane.showMessageDialog(window, "The swing inspector is not available.");
}
}
};
private final AWTEventListener swingInspectorKeyListener = rawEv ->
{
if (rawEv instanceof KeyEvent) {
KeyEvent kev = (KeyEvent) rawEv;
if (kev.getID() == KeyEvent.KEY_PRESSED) {
swingInspectorHotkeyListener.keyPressed(kev);
} else if (kev.getID() == KeyEvent.KEY_RELEASED) {
swingInspectorHotkeyListener.keyReleased(kev);
}
}
};
@Inject
private MicrobotClickOverlay microbotClickOverlay;
@Inject
private MicrobotMouseOverlay microbotMouseOverlay;
private DevToolsButton players;
private DevToolsButton npcs;
private DevToolsButton inventory;
Expand Down Expand Up @@ -163,61 +203,10 @@ public class DevToolsPlugin extends Plugin
private DevToolsButton shell;
private DevToolsButton menus;
private DevToolsButton uiDefaultsInspector;
private DevToolsButton mouseClick;
private DevToolsButton mouseMovement;
private NavigationButton navButton;

private final HotkeyListener swingInspectorHotkeyListener = new HotkeyListener(() -> config.swingInspectorHotkey())
{
Object inspector;

@Override
public void hotkeyPressed()
{
Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
try
{
if (inspector == null)
{
JRootPane rootPane = ((RootPaneContainer) window).getRootPane();
FlatInspector fi = new FlatInspector(rootPane);
fi.setEnabled(true);
inspector = fi;
fi.addPropertyChangeListener(ev ->
{
if ("enabled".equals(ev.getPropertyName()) && !fi.isEnabled() && inspector == ev.getSource())
{
inspector = null;
}
});
}
else
{
((FlatInspector) inspector).setEnabled(false);
}
}
catch (LinkageError | Exception e)
{
log.warn("unable to open swing inspector", e);
JOptionPane.showMessageDialog(window, "The swing inspector is not available.");
}
}
};

private final AWTEventListener swingInspectorKeyListener = rawEv ->
{
if (rawEv instanceof KeyEvent)
{
KeyEvent kev = (KeyEvent) rawEv;
if (kev.getID() == KeyEvent.KEY_PRESSED)
{
swingInspectorHotkeyListener.keyPressed(kev);
}
else if (kev.getID() == KeyEvent.KEY_RELEASED)
{
swingInspectorHotkeyListener.keyReleased(kev);
}
}
};

@Provides
DevToolsConfig provideConfig(ConfigManager configManager)
{
Expand Down Expand Up @@ -267,13 +256,18 @@ protected void startUp() throws Exception

uiDefaultsInspector = new DevToolsButton("Swing Defaults");

mouseClick = new DevToolsButton("Bot Clicks");
mouseMovement = new DevToolsButton("Bot Mouse");

overlayManager.add(overlay);
overlayManager.add(locationOverlay);
overlayManager.add(sceneOverlay);
overlayManager.add(cameraOverlay);
overlayManager.add(worldMapLocationOverlay);
overlayManager.add(mapRegionOverlay);
overlayManager.add(soundEffectOverlay);
overlayManager.add(microbotClickOverlay);
overlayManager.add(microbotMouseOverlay);

final DevToolsPanel panel = injector.getInstance(DevToolsPanel.class);

Expand Down Expand Up @@ -304,6 +298,8 @@ protected void shutDown() throws Exception
overlayManager.remove(worldMapLocationOverlay);
overlayManager.remove(mapRegionOverlay);
overlayManager.remove(soundEffectOverlay);
overlayManager.remove(microbotClickOverlay);
overlayManager.remove(microbotMouseOverlay);
clientToolbar.removeNavigation(navButton);
Toolkit.getDefaultToolkit().removeAWTEventListener(swingInspectorKeyListener);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package net.runelite.client.plugins.devtools;

import net.runelite.api.Client;
import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;

import javax.inject.Inject;
import java.awt.*;

public class MicrobotClickOverlay extends Overlay {
private final Client client;
private final DevToolsPlugin plugin;

@Inject
MicrobotClickOverlay(Client client, DevToolsPlugin plugin) {
this.client = client;
this.plugin = plugin;
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_WIDGETS);
setPriority(Overlay.PRIORITY_LOW);
}

@Override
public Dimension render(Graphics2D g) {
if (plugin.getMouseClick().isActive()) {

g.setFont(new Font("Tahoma", Font.BOLD, 18));

// Get the FontMetrics for the current font
FontMetrics metrics = g.getFontMetrics(g.getFont());

// Get the width and height of the character
int charWidth = metrics.stringWidth("X");
int charHeight = metrics.getAscent(); // ascent gives the height of the character above the baseline

int x = Microbot.getMouse().getLastClick().getX() - (charWidth / 2);
int y = Microbot.getMouse().getLastClick().getY() + (charHeight / 2);

OverlayUtil.renderTextLocation(g, new net.runelite.api.Point(x, y), "X", Color.WHITE);

x = Microbot.getMouse().getLastClick2().getX() - (charWidth / 2);
y = Microbot.getMouse().getLastClick2().getY() + (charHeight / 2);

OverlayUtil.renderTextLocation(g, new net.runelite.api.Point(x, y), "X", Color.GREEN);



}

return null;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package net.runelite.client.plugins.devtools;

import net.runelite.api.Client;
import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;

import javax.inject.Inject;
import java.awt.*;
import java.awt.geom.Path2D;

public class MicrobotMouseOverlay extends Overlay {
private final Client client;
private final DevToolsPlugin plugin;

@Inject
MicrobotMouseOverlay(Client client, DevToolsPlugin plugin) {
this.client = client;
this.plugin = plugin;
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_WIDGETS);
setPriority(Overlay.PRIORITY_LOW);
}

@Override
public Dimension render(Graphics2D g) {
if (plugin.getMouseMovement().isActive()) {
if (!Microbot.getMouse().getTimer().isRunning()) {
Microbot.getMouse().getTimer().start();
}
//g.setFont(new Font("Tahoma", Font.BOLD, 18));
g.setFont(g.getFont().deriveFont(40.0f));
// Get the FontMetrics for the current font
FontMetrics metrics = g.getFontMetrics(g.getFont());

// Get the width and height of the character
int charWidth = metrics.stringWidth("⊹");
int charHeight = metrics.getAscent(); // ascent gives the height of the character above the baseline

// Calculate the new position
int x = Microbot.getMouse().getLastMove().getX() - (charWidth / 2);
int y = Microbot.getMouse().getLastMove().getY() + (charHeight / 2);

OverlayUtil.renderTextLocation(g, new net.runelite.api.Point(x, y), "⊹", Microbot.getMouse().getRainbowColor());

g.setStroke(new BasicStroke(3));
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
var points = Microbot.getMouse().getPoints();
if (points.size() > 1) {
Path2D path = new Path2D.Double();
net.runelite.api.Point firstPoint = points.getFirst();
path.moveTo(firstPoint.getX(), firstPoint.getY());

for (int i = 1; i < points.size(); i++) {
net.runelite.api.Point p = points.get(i);
path.lineTo(p.getX(), p.getY());
g.setColor(Microbot.getMouse().getRainbowColor());
}

g.draw(path);
}
// draw trail of mouse movements

} else {
Microbot.getMouse().getPoints().clear();
Microbot.getMouse().getTimer().stop();
}

return null;
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.runelite.client.plugins.microbot.construction2;
package net.runelite.client.plugins.microbot.GeoffPlugins.construction2;

import net.runelite.api.ItemID;
import net.runelite.client.config.Config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.runelite.client.plugins.microbot.construction2;
package net.runelite.client.plugins.microbot.GeoffPlugins.construction2;

import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.LineComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.runelite.client.plugins.microbot.construction2;
package net.runelite.client.plugins.microbot.GeoffPlugins.construction2;

import com.google.inject.Provides;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -9,7 +9,7 @@
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.plugins.microbot.construction2.enums.Construction2State;
import net.runelite.client.plugins.microbot.GeoffPlugins.construction2.enums.Construction2State;
import net.runelite.client.plugins.microbot.util.mouse.VirtualMouse;
import net.runelite.client.ui.overlay.OverlayManager;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.runelite.client.plugins.microbot.construction2;
package net.runelite.client.plugins.microbot.GeoffPlugins.construction2;

import net.runelite.api.*;
import net.runelite.api.widgets.Widget;
import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.plugins.microbot.Script;
import net.runelite.client.plugins.microbot.construction2.enums.Construction2State;
import net.runelite.client.plugins.microbot.GeoffPlugins.construction2.enums.Construction2State;
import net.runelite.client.plugins.microbot.util.dialogues.Rs2Dialogue;
import net.runelite.client.plugins.microbot.util.gameobject.Rs2GameObject;
import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.runelite.client.plugins.microbot.construction2.enums;
package net.runelite.client.plugins.microbot.GeoffPlugins.construction2.enums;

public enum Construction2State {
Idle,
Expand Down
Loading

0 comments on commit 7f5ef0d

Please sign in to comment.