Updated DevTools Plugin (#25)
Updated DevTools and consolidated developer plugins
This commit is contained in:
@@ -59,9 +59,7 @@ public class Point
|
||||
*/
|
||||
public int distanceTo(Point other)
|
||||
{
|
||||
int dx = x - other.x;
|
||||
int dy = y - other.y;
|
||||
return (int) Math.sqrt(dx * dx + dy * dy);
|
||||
return (int) Math.hypot(getX() - other.getX(), getY() - other.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,10 +30,8 @@ import java.util.List;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.plugins.boosts.Boosts;
|
||||
import net.runelite.client.plugins.bosstimer.BossTimers;
|
||||
import net.runelite.client.plugins.debug.Debug;
|
||||
import net.runelite.client.plugins.devtools.DevTools;
|
||||
import net.runelite.client.plugins.fpsinfo.FPS;
|
||||
import net.runelite.client.plugins.gronditems.GroundItems;
|
||||
import net.runelite.client.plugins.hiscore.Hiscore;
|
||||
import net.runelite.client.plugins.idlenotifier.IdleNotifier;
|
||||
import net.runelite.client.plugins.opponentinfo.OpponentInfo;
|
||||
@@ -66,9 +64,6 @@ public class PluginManager
|
||||
if (RuneLite.getOptions().has("developer-mode"))
|
||||
{
|
||||
logger.info("Loading developer plugins");
|
||||
|
||||
load(new Debug());
|
||||
load(new GroundItems());
|
||||
load(new DevTools());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.debug;
|
||||
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
|
||||
public class Debug extends Plugin
|
||||
{
|
||||
private final DebugOverlay debugOverlay = new DebugOverlay();
|
||||
|
||||
@Override
|
||||
public Overlay getOverlay()
|
||||
{
|
||||
return debugOverlay;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.debug;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.DecorativeObject;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.GroundObject;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.Region;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.api.TileObject;
|
||||
import net.runelite.api.WallObject;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
|
||||
public class DebugOverlay extends Overlay
|
||||
{
|
||||
private static final Client client = RuneLite.getClient();
|
||||
|
||||
private static final int REGION_SIZE = 104;
|
||||
|
||||
public DebugOverlay()
|
||||
{
|
||||
super(OverlayPosition.DYNAMIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (client.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
renderTiles(graphics);
|
||||
renderInventory(graphics);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderTiles(Graphics2D graphics)
|
||||
{
|
||||
Region region = client.getRegion();
|
||||
Tile[][][] tiles = region.getTiles();
|
||||
|
||||
int z = client.getPlane();
|
||||
|
||||
for (int x = 0; x < REGION_SIZE; ++x)
|
||||
{
|
||||
for (int y = 0; y < REGION_SIZE; ++y)
|
||||
{
|
||||
Tile tile = tiles[z][x][y];
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
render(graphics, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderInventory(Graphics2D graphics)
|
||||
{
|
||||
Widget inventoryWidget = client.getWidget(WidgetID.INVENTORY_GROUP_ID, WidgetID.INVENTORY_CHILD_ID);
|
||||
if (inventoryWidget == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WidgetItem item : inventoryWidget.getWidgetItems())
|
||||
{
|
||||
Rectangle bounds = item.getCanvasBounds();
|
||||
|
||||
Color[] colors = new Color[]
|
||||
{
|
||||
Color.RED, Color.GREEN, Color.BLUE
|
||||
};
|
||||
graphics.setColor(colors[item.getIndex() % 3]);
|
||||
if (bounds != null)
|
||||
{
|
||||
graphics.draw(bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void render(Graphics2D graphics, Tile tile)
|
||||
{
|
||||
renderDecorativeObject(graphics, tile);
|
||||
renderWallObject(graphics, tile);
|
||||
renderGroundObject(graphics, tile);
|
||||
renderGameObjects(graphics, tile);
|
||||
}
|
||||
|
||||
private void renderDecorativeObject(Graphics2D graphics, Tile tile)
|
||||
{
|
||||
DecorativeObject decorativeObject = tile.getDecorativeObject();
|
||||
if (decorativeObject == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int id = decorativeObject.getId();
|
||||
renderTileObject(graphics, decorativeObject, Color.RED, "D" + id);
|
||||
}
|
||||
|
||||
private void renderWallObject(Graphics2D graphics, Tile tile)
|
||||
{
|
||||
WallObject wallObject = tile.getWallObject();
|
||||
if (wallObject == null)
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
int id = wallObject.getId();
|
||||
renderTileObject(graphics, wallObject, Color.GREEN, "W" + id);
|
||||
}
|
||||
|
||||
private void renderGroundObject(Graphics2D graphics, Tile tile)
|
||||
{
|
||||
GroundObject groundObject = tile.getGroundObject();
|
||||
if (groundObject == null)
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
int id = groundObject.getId();
|
||||
renderTileObject(graphics, groundObject, Color.BLUE, "G" + id);
|
||||
}
|
||||
|
||||
private void renderGameObjects(Graphics2D graphics, Tile tile)
|
||||
{
|
||||
GameObject[] gameObjects = tile.getGameObjects();
|
||||
if (gameObjects == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (GameObject gameObject : gameObjects)
|
||||
{
|
||||
if (gameObject == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
renderTileObject(graphics, gameObject, Color.YELLOW, "GA" + gameObject.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private void renderTileObject(Graphics2D graphics, TileObject tileObject, Color color, String text)
|
||||
{
|
||||
Point canvasLocation = tileObject.getCanvasLocation();
|
||||
|
||||
if (canvasLocation == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
graphics.setColor(color);
|
||||
graphics.drawString(text, canvasLocation.getX(), canvasLocation.getY());
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,70 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.devtools;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.FontFormatException;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DevTools extends Plugin
|
||||
{
|
||||
private final DevToolsOverlay overlay = new DevToolsOverlay();
|
||||
private static final Logger logger = LoggerFactory.getLogger(DevTools.class);
|
||||
|
||||
private final DevToolsOverlay overlay = new DevToolsOverlay(this);
|
||||
private final DevToolsPanel panel = new DevToolsPanel(this);
|
||||
private final NavigationButton navButton = new NavigationButton("DevTools");
|
||||
private final ClientUI ui = RuneLite.getRunelite().getGui();
|
||||
|
||||
private boolean togglePlayers;
|
||||
private boolean toggleNpcs;
|
||||
private boolean toggleGroundItems;
|
||||
private boolean toggleGroundObjects;
|
||||
private boolean toggleGameObjects;
|
||||
private boolean toggleWalls;
|
||||
private boolean toggleDecor;
|
||||
private boolean toggleInventory;
|
||||
|
||||
private Font font;
|
||||
|
||||
public DevTools()
|
||||
{
|
||||
navButton.getButton().addActionListener(this::expandPanel);
|
||||
|
||||
try
|
||||
{
|
||||
ImageIcon icon = new ImageIcon(ImageIO.read(getClass().getResourceAsStream("devtools_icon.png")));
|
||||
navButton.getButton().setIcon(icon);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.warn("Unable to load devtools icon", ex);
|
||||
}
|
||||
|
||||
ui.getNavigationPanel().addNavigation(navButton);
|
||||
|
||||
try
|
||||
{
|
||||
font = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("runescape.ttf"));
|
||||
|
||||
font = font.deriveFont(Font.PLAIN, 16);
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
ge.registerFont(font);
|
||||
}
|
||||
catch (FontFormatException | IOException ex)
|
||||
{
|
||||
logger.warn("Unable to load font", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Overlay getOverlay()
|
||||
@@ -37,4 +95,94 @@ public class DevTools extends Plugin
|
||||
return overlay;
|
||||
}
|
||||
|
||||
private void expandPanel(ActionEvent e)
|
||||
{
|
||||
ui.setPluginPanel(panel);
|
||||
ui.expand();
|
||||
}
|
||||
|
||||
public Font getFont()
|
||||
{
|
||||
return font;
|
||||
}
|
||||
|
||||
public void togglePlayers()
|
||||
{
|
||||
togglePlayers = !togglePlayers;
|
||||
}
|
||||
|
||||
public void toggleNpcs()
|
||||
{
|
||||
toggleNpcs = !toggleNpcs;
|
||||
}
|
||||
|
||||
public void toggleGroundItems()
|
||||
{
|
||||
toggleGroundItems = !toggleGroundItems;
|
||||
}
|
||||
|
||||
public void toggleGroundObjects()
|
||||
{
|
||||
toggleGroundObjects = !toggleGroundObjects;
|
||||
}
|
||||
|
||||
public void toggleGameObjects()
|
||||
{
|
||||
toggleGameObjects = !toggleGameObjects;
|
||||
}
|
||||
|
||||
public void toggleWalls()
|
||||
{
|
||||
toggleWalls = !toggleWalls;
|
||||
}
|
||||
|
||||
public void toggleDecor()
|
||||
{
|
||||
toggleDecor = !toggleDecor;
|
||||
}
|
||||
|
||||
public void toggleInventory()
|
||||
{
|
||||
toggleInventory = !toggleInventory;
|
||||
}
|
||||
|
||||
public boolean isTogglePlayers()
|
||||
{
|
||||
return togglePlayers;
|
||||
}
|
||||
|
||||
public boolean isToggleNpcs()
|
||||
{
|
||||
return toggleNpcs;
|
||||
}
|
||||
|
||||
public boolean isToggleGroundItems()
|
||||
{
|
||||
return toggleGroundItems;
|
||||
}
|
||||
|
||||
public boolean isToggleGroundObjects()
|
||||
{
|
||||
return toggleGroundObjects;
|
||||
}
|
||||
|
||||
public boolean isToggleGameObjects()
|
||||
{
|
||||
return toggleGameObjects;
|
||||
}
|
||||
|
||||
public boolean isToggleWalls()
|
||||
{
|
||||
return toggleWalls;
|
||||
}
|
||||
|
||||
public boolean isToggleDecor()
|
||||
{
|
||||
return toggleDecor;
|
||||
}
|
||||
|
||||
public boolean isToggleInventory()
|
||||
{
|
||||
return toggleInventory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Kronos <https://github.com/KronosDesign>
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -27,26 +28,55 @@ package net.runelite.client.plugins.devtools;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Rectangle;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.DecorativeObject;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.GroundObject;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemLayer;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Node;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.Region;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.api.TileObject;
|
||||
import net.runelite.api.WallObject;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
|
||||
public class DevToolsOverlay extends Overlay
|
||||
{
|
||||
private static final Color RED = new Color(221, 44, 0);
|
||||
private static final Color GREEN = new Color(0, 200, 83);
|
||||
private static final Color ORANGE = new Color(255, 109, 0);
|
||||
private static final Color YELLOW = new Color(255, 214, 0);
|
||||
private static final Color CYAN = new Color(0, 184, 212);
|
||||
private static final Color BLUE = new Color(41, 98, 255);
|
||||
private static final Color DEEP_PURPLE = new Color(98, 0, 234);
|
||||
private static final Color PURPLE = new Color(170, 0, 255);
|
||||
private static final Color GRAY = new Color(158, 158, 158);
|
||||
|
||||
private static final Client client = RuneLite.getClient();
|
||||
private static final int REGION_SIZE = 104;
|
||||
private static final int MAX_DISTANCE = 2400;
|
||||
|
||||
public DevToolsOverlay()
|
||||
private final DevTools tools;
|
||||
private final Client client = RuneLite.getClient();
|
||||
|
||||
public DevToolsOverlay(DevTools tools)
|
||||
{
|
||||
super(OverlayPosition.DYNAMIC);
|
||||
this.tools = tools;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,6 +87,139 @@ public class DevToolsOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
if (tools.isTogglePlayers())
|
||||
{
|
||||
renderPlayers(graphics);
|
||||
}
|
||||
|
||||
if (tools.isToggleNpcs())
|
||||
{
|
||||
renderNpcs(graphics);
|
||||
}
|
||||
|
||||
if (tools.isToggleGroundItems() || tools.isToggleGroundObjects() || tools.isToggleGameObjects() || tools.isToggleWalls() || tools.isToggleDecor())
|
||||
{
|
||||
renderTileObjects(graphics);
|
||||
}
|
||||
|
||||
if (tools.isToggleInventory())
|
||||
{
|
||||
renderInventory(graphics);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderActorOverlay(Graphics2D graphics, Actor actor, String text, Color color)
|
||||
{
|
||||
Polygon poly = actor.getCanvasTilePoly();
|
||||
if (poly != null)
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.setStroke(new BasicStroke(2));
|
||||
graphics.drawPolygon(poly);
|
||||
graphics.setColor(new Color(0, 0, 0, 50));
|
||||
graphics.fillPolygon(poly);
|
||||
}
|
||||
|
||||
Point minimapLocation = actor.getMinimapLocation();
|
||||
if (minimapLocation != null)
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.fillOval(minimapLocation.getX(), minimapLocation.getY(), 5, 5);
|
||||
graphics.setColor(Color.WHITE);
|
||||
graphics.setStroke(new BasicStroke(1));
|
||||
graphics.drawOval(minimapLocation.getX(), minimapLocation.getY(), 5, 5);
|
||||
}
|
||||
|
||||
Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getModelHeight());
|
||||
if (textLocation != null)
|
||||
{
|
||||
int x = textLocation.getX();
|
||||
int y = textLocation.getY();
|
||||
|
||||
Font font = tools.getFont();
|
||||
if (font != null)
|
||||
{
|
||||
graphics.setFont(font);
|
||||
}
|
||||
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.drawString(text, x + 1, y + 1);
|
||||
|
||||
graphics.setColor(color);
|
||||
graphics.drawString(text, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderTileOverlay(Graphics2D graphics, TileObject tileObject, String text, Color color)
|
||||
{
|
||||
Polygon poly = tileObject.getCanvasTilePoly();
|
||||
if (poly != null)
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.setStroke(new BasicStroke(2));
|
||||
graphics.drawPolygon(poly);
|
||||
graphics.setColor(new Color(0, 0, 0, 50));
|
||||
graphics.fillPolygon(poly);
|
||||
}
|
||||
|
||||
Point minimapLocation = tileObject.getMinimapLocation();
|
||||
if (minimapLocation != null)
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.fillOval(minimapLocation.getX(), minimapLocation.getY(), 5, 5);
|
||||
graphics.setColor(Color.WHITE);
|
||||
graphics.setStroke(new BasicStroke(1));
|
||||
graphics.drawOval(minimapLocation.getX(), minimapLocation.getY(), 5, 5);
|
||||
}
|
||||
|
||||
Point textLocation = tileObject.getCanvasTextLocation(graphics, text, 0);
|
||||
if (textLocation != null)
|
||||
{
|
||||
int x = textLocation.getX();
|
||||
int y = textLocation.getY();
|
||||
|
||||
Font font = tools.getFont();
|
||||
if (font != null)
|
||||
{
|
||||
graphics.setFont(font);
|
||||
}
|
||||
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.drawString(text, x + 1, y + 1);
|
||||
|
||||
graphics.setColor(color);
|
||||
graphics.drawString(text, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderPlayers(Graphics2D graphics)
|
||||
{
|
||||
Player[] players = client.getPlayers();
|
||||
Player local = client.getLocalPlayer();
|
||||
|
||||
if (players != null && (players.length - 1) > 0)
|
||||
{
|
||||
for (Player p : players)
|
||||
{
|
||||
if (p != null)
|
||||
{
|
||||
if (!p.getName().equals(local.getName()))
|
||||
{
|
||||
String text = p.getName() + " (A: " + p.getAnimation() + ")";
|
||||
renderActorOverlay(graphics, p, text, BLUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String text = local.getName() + " (A: " + local.getAnimation() + ")";
|
||||
renderActorOverlay(graphics, local, text, CYAN);
|
||||
}
|
||||
|
||||
private void renderNpcs(Graphics2D graphics)
|
||||
{
|
||||
NPC[] npcs = client.getNpcs();
|
||||
if (npcs != null && (npcs.length - 1) > 0)
|
||||
{
|
||||
@@ -67,59 +230,162 @@ public class DevToolsOverlay extends Overlay
|
||||
String text = npc.getName() + " (A: " + npc.getAnimation() + ")";
|
||||
if (npc.getCombatLevel() > 1)
|
||||
{
|
||||
render(graphics, npc, text, new Color(230, 74, 25));
|
||||
renderActorOverlay(graphics, npc, text, YELLOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
render(graphics, npc, text, Color.ORANGE);
|
||||
renderActorOverlay(graphics, npc, text, ORANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Player[] players = client.getPlayers();
|
||||
if (players != null && (players.length - 1) > 0)
|
||||
{
|
||||
for (Player p : players)
|
||||
{
|
||||
if (p != null)
|
||||
{
|
||||
if (!p.getName().equals(client.getLocalPlayer().getName()))
|
||||
{
|
||||
String text = p.getName() + " (A: " + p.getAnimation() + ")";
|
||||
render(graphics, p, text, Color.BLUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Player local = client.getLocalPlayer();
|
||||
String text = local.getName() + " (A: " + local.getAnimation() + ")";
|
||||
render(graphics, local, text, Color.CYAN);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void render(Graphics2D graphics, Actor actor, String text, Color color)
|
||||
private void renderTileObjects(Graphics2D graphics)
|
||||
{
|
||||
Polygon poly = actor.getCanvasTilePoly();
|
||||
if (poly == null)
|
||||
Region region = client.getRegion();
|
||||
Tile[][][] tiles = region.getTiles();
|
||||
|
||||
int z = client.getPlane();
|
||||
|
||||
for (int x = 0; x < REGION_SIZE; ++x)
|
||||
{
|
||||
for (int y = 0; y < REGION_SIZE; ++y)
|
||||
{
|
||||
Tile tile = tiles[z][x][y];
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Player player = client.getLocalPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tools.isToggleGroundItems())
|
||||
{
|
||||
renderGroundItems(graphics, tile, player);
|
||||
}
|
||||
|
||||
if (tools.isToggleGroundObjects())
|
||||
{
|
||||
renderGroundObject(graphics, tile, player);
|
||||
}
|
||||
|
||||
if (tools.isToggleGameObjects())
|
||||
{
|
||||
renderGameObjects(graphics, tile, player);
|
||||
}
|
||||
|
||||
if (tools.isToggleWalls())
|
||||
{
|
||||
renderWallObject(graphics, tile, player);
|
||||
}
|
||||
|
||||
if (tools.isToggleDecor())
|
||||
{
|
||||
renderDecorObject(graphics, tile, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderGroundItems(Graphics2D graphics, Tile tile, Player player)
|
||||
{
|
||||
ItemLayer itemLayer = tile.getItemLayer();
|
||||
if (itemLayer != null)
|
||||
{
|
||||
if (player.getLocalLocation().distanceTo(itemLayer.getLocalLocation()) <= MAX_DISTANCE)
|
||||
{
|
||||
Node current = itemLayer.getBottom();
|
||||
while (current instanceof Item)
|
||||
{
|
||||
Item item = (Item) current;
|
||||
renderTileOverlay(graphics, itemLayer, "ID: " + item.getId() + " Qty:" + item.getQuantity(), RED);
|
||||
current = current.getNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderGameObjects(Graphics2D graphics, Tile tile, Player player)
|
||||
{
|
||||
GameObject[] gameObjects = tile.getGameObjects();
|
||||
if (gameObjects != null)
|
||||
{
|
||||
for (GameObject gameObject : gameObjects)
|
||||
{
|
||||
if (gameObject != null)
|
||||
{
|
||||
if (player.getLocalLocation().distanceTo(gameObject.getLocalLocation()) <= MAX_DISTANCE)
|
||||
{
|
||||
renderTileOverlay(graphics, gameObject, "ID: " + gameObject.getId(), GREEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderGroundObject(Graphics2D graphics, Tile tile, Player player)
|
||||
{
|
||||
GroundObject groundObject = tile.getGroundObject();
|
||||
if (groundObject != null)
|
||||
{
|
||||
if (player.getLocalLocation().distanceTo(groundObject.getLocalLocation()) <= MAX_DISTANCE)
|
||||
{
|
||||
renderTileOverlay(graphics, groundObject, "ID: " + groundObject.getId(), PURPLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderWallObject(Graphics2D graphics, Tile tile, Player player)
|
||||
{
|
||||
WallObject wallObject = tile.getWallObject();
|
||||
if (wallObject != null)
|
||||
{
|
||||
if (player.getLocalLocation().distanceTo(wallObject.getLocalLocation()) <= MAX_DISTANCE)
|
||||
{
|
||||
renderTileOverlay(graphics, wallObject, "ID: " + wallObject.getId(), GRAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderDecorObject(Graphics2D graphics, Tile tile, Player player)
|
||||
{
|
||||
DecorativeObject decorObject = tile.getDecorativeObject();
|
||||
if (decorObject != null)
|
||||
{
|
||||
if (player.getLocalLocation().distanceTo(decorObject.getLocalLocation()) <= MAX_DISTANCE)
|
||||
{
|
||||
renderTileOverlay(graphics, decorObject, "ID: " + decorObject.getId(), DEEP_PURPLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderInventory(Graphics2D graphics)
|
||||
{
|
||||
Widget inventoryWidget = client.getWidget(WidgetID.INVENTORY_GROUP_ID, WidgetID.INVENTORY_CHILD_ID);
|
||||
if (inventoryWidget == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getModelHeight());
|
||||
|
||||
graphics.setColor(color);
|
||||
graphics.setStroke(new BasicStroke(2));
|
||||
graphics.drawPolygon(poly);
|
||||
graphics.setColor(new Color(0, 0, 0, 50));
|
||||
graphics.fillPolygon(poly);
|
||||
|
||||
if (textLocation != null)
|
||||
for (WidgetItem item : inventoryWidget.getWidgetItems())
|
||||
{
|
||||
graphics.setColor(Color.WHITE);
|
||||
graphics.drawString(text, textLocation.getX(), textLocation.getY());
|
||||
Rectangle bounds = item.getCanvasBounds();
|
||||
|
||||
Color[] colors = new Color[]
|
||||
{
|
||||
Color.RED, Color.GREEN, Color.BLUE
|
||||
};
|
||||
graphics.setColor(colors[item.getIndex() % 3]);
|
||||
if (bounds != null)
|
||||
{
|
||||
graphics.draw(bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Kronos <https://github.com/KronosDesign>
|
||||
* 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.devtools;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
|
||||
public class DevToolsPanel extends PluginPanel
|
||||
{
|
||||
private JButton renderPlayersBtn = new JButton();
|
||||
private JButton renderNpcsBtn = new JButton();
|
||||
private JButton renderGroundItemsBtn = new JButton();
|
||||
private JButton renderGroundObjectsBtn = new JButton();
|
||||
private JButton renderGameObjectsBtn = new JButton();
|
||||
private JButton renderWallsBtn = new JButton();
|
||||
private JButton renderDecorBtn = new JButton();
|
||||
private JButton renderInventoryBtn = new JButton();
|
||||
|
||||
public DevToolsPanel(DevTools tools)
|
||||
{
|
||||
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setSize(PANEL_WIDTH, PANEL_HEIGHT);
|
||||
setVisible(true);
|
||||
|
||||
JPanel container = new JPanel();
|
||||
container.setLayout(new GridLayout(4, 2, 3, 3));
|
||||
add(container);
|
||||
|
||||
renderPlayersBtn = new JButton("Players");
|
||||
renderPlayersBtn.addActionListener(e -> {
|
||||
highlightButton(renderPlayersBtn);
|
||||
tools.togglePlayers();
|
||||
});
|
||||
container.add(renderPlayersBtn);
|
||||
|
||||
renderNpcsBtn = new JButton("NPCs");
|
||||
renderNpcsBtn.addActionListener(e -> {
|
||||
highlightButton(renderNpcsBtn);
|
||||
tools.toggleNpcs();
|
||||
});
|
||||
container.add(renderNpcsBtn);
|
||||
|
||||
renderGroundItemsBtn = new JButton("Ground Items");
|
||||
renderGroundItemsBtn.addActionListener(e -> {
|
||||
highlightButton(renderGroundItemsBtn);
|
||||
tools.toggleGroundItems();
|
||||
});
|
||||
container.add(renderGroundItemsBtn);
|
||||
|
||||
renderGroundObjectsBtn = new JButton("Ground Objects");
|
||||
renderGroundObjectsBtn.addActionListener(e -> {
|
||||
highlightButton(renderGroundObjectsBtn);
|
||||
tools.toggleGroundObjects();
|
||||
});
|
||||
container.add(renderGroundObjectsBtn);
|
||||
|
||||
renderGameObjectsBtn = new JButton("Game Objects");
|
||||
renderGameObjectsBtn.addActionListener(e -> {
|
||||
highlightButton(renderGameObjectsBtn);
|
||||
tools.toggleGameObjects();
|
||||
});
|
||||
container.add(renderGameObjectsBtn);
|
||||
|
||||
renderWallsBtn = new JButton("Walls");
|
||||
renderWallsBtn.addActionListener(e -> {
|
||||
highlightButton(renderWallsBtn);
|
||||
tools.toggleWalls();
|
||||
});
|
||||
container.add(renderWallsBtn);
|
||||
|
||||
renderDecorBtn = new JButton("Decorations");
|
||||
renderDecorBtn.addActionListener(e -> {
|
||||
highlightButton(renderDecorBtn);
|
||||
tools.toggleDecor();
|
||||
});
|
||||
container.add(renderDecorBtn);
|
||||
|
||||
renderInventoryBtn = new JButton("Inventory");
|
||||
renderInventoryBtn.addActionListener(e -> {
|
||||
highlightButton(renderInventoryBtn);
|
||||
tools.toggleInventory();
|
||||
});
|
||||
container.add(renderInventoryBtn);
|
||||
}
|
||||
|
||||
private void highlightButton(JButton button)
|
||||
{
|
||||
if (button.getBackground().equals(Color.GREEN))
|
||||
{
|
||||
button.setBackground(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
button.setBackground(Color.GREEN);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.gronditems;
|
||||
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
|
||||
public class GroundItems extends Plugin
|
||||
{
|
||||
private final GroundItemsOverlay groundItemsOverlay = new GroundItemsOverlay();
|
||||
|
||||
@Override
|
||||
public Overlay getOverlay()
|
||||
{
|
||||
return groundItemsOverlay;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.gronditems;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemLayer;
|
||||
import net.runelite.api.Node;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.Region;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
|
||||
public class GroundItemsOverlay extends Overlay
|
||||
{
|
||||
private static final Client client = RuneLite.getClient();
|
||||
|
||||
private static final int REGION_SIZE = 104;
|
||||
|
||||
public GroundItemsOverlay()
|
||||
{
|
||||
super(OverlayPosition.DYNAMIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (client.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Region region = client.getRegion();
|
||||
Tile[][][] tiles = region.getTiles();
|
||||
|
||||
int z = client.getPlane();
|
||||
|
||||
for (int x = 0; x < REGION_SIZE; ++x)
|
||||
{
|
||||
for (int y = 0; y < REGION_SIZE; ++y)
|
||||
{
|
||||
Tile tile = tiles[z][x][y];
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
render(graphics, tile);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void render(Graphics2D graphics, Tile tile)
|
||||
{
|
||||
ItemLayer itemLayer = tile.getItemLayer();
|
||||
|
||||
if (itemLayer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Point canvasLocation = itemLayer.getCanvasLocation();
|
||||
if (canvasLocation == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Node current = itemLayer.getBottom();
|
||||
|
||||
while (current instanceof Item)
|
||||
{
|
||||
Item item = (Item) current;
|
||||
render(graphics, canvasLocation, item);
|
||||
current = current.getNext();
|
||||
}
|
||||
}
|
||||
|
||||
private void render(Graphics2D graphics, Point canvasLocation, Item item)
|
||||
{
|
||||
graphics.setColor(Color.ORANGE);
|
||||
graphics.drawString("I" + item.getId(), canvasLocation.getX(), canvasLocation.getY());
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 966 B |
Binary file not shown.
Reference in New Issue
Block a user