Merge pull request #6693 from deathbeam/cleanup-dev-tools

Cleanup dev tools plugin
This commit is contained in:
Tomas Slusny
2018-11-27 09:42:23 +00:00
committed by GitHub
10 changed files with 240 additions and 470 deletions

View File

@@ -52,7 +52,7 @@ public class CameraOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
if (!plugin.isToggleCamera()) if (!plugin.getCameraPosition().isActive())
{ {
return null; return null;
} }

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@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.devtools;
import java.awt.Color;
import javax.swing.JButton;
import lombok.Getter;
class DevToolsButton extends JButton
{
@Getter
private boolean active;
DevToolsButton(String title)
{
super(title);
addActionListener((ev) -> setActive(!active));
}
void setActive(boolean active)
{
this.active = active;
if (active)
{
setBackground(Color.GREEN);
}
else
{
setBackground(null);
}
}
}

View File

@@ -35,6 +35,9 @@ import java.awt.Rectangle;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.Getter;
import lombok.Setter;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Constants; import net.runelite.api.Constants;
@@ -58,6 +61,7 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.widgets.WidgetItem; import net.runelite.api.widgets.WidgetItem;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
@@ -65,11 +69,13 @@ import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.tooltip.Tooltip; import net.runelite.client.ui.overlay.tooltip.Tooltip;
import net.runelite.client.ui.overlay.tooltip.TooltipManager; import net.runelite.client.ui.overlay.tooltip.TooltipManager;
public class DevToolsOverlay extends Overlay @Singleton
class DevToolsOverlay extends Overlay
{ {
public static final int ITEM_EMPTY = 6512; private static final int ITEM_EMPTY = 6512;
public static final int ITEM_FILLED = 20594; private static final int ITEM_FILLED = 20594;
private static final Font FONT = FontManager.getRunescapeFont().deriveFont(Font.BOLD, 16);
private static final Color RED = new Color(221, 44, 0); private static final Color RED = new Color(221, 44, 0);
private static final Color GREEN = new Color(0, 200, 83); private static final Color GREEN = new Color(0, 200, 83);
private static final Color ORANGE = new Color(255, 109, 0); private static final Color ORANGE = new Color(255, 109, 0);
@@ -86,8 +92,15 @@ public class DevToolsOverlay extends Overlay
private final DevToolsPlugin plugin; private final DevToolsPlugin plugin;
private final TooltipManager toolTipManager; private final TooltipManager toolTipManager;
@Setter
@Getter
private Widget widget;
@Setter
private int itemIndex = -1;
@Inject @Inject
public DevToolsOverlay(Client client, DevToolsPlugin plugin, TooltipManager toolTipManager) private DevToolsOverlay(Client client, DevToolsPlugin plugin, TooltipManager toolTipManager)
{ {
setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ALWAYS_ON_TOP); setLayer(OverlayLayer.ALWAYS_ON_TOP);
@@ -99,38 +112,34 @@ public class DevToolsOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
Font font = plugin.getFont(); graphics.setFont(FONT);
if (font != null)
{
graphics.setFont(font);
}
if (plugin.isTogglePlayers()) if (plugin.getPlayers().isActive())
{ {
renderPlayers(graphics); renderPlayers(graphics);
} }
if (plugin.isToggleNpcs()) if (plugin.getNpcs().isActive())
{ {
renderNpcs(graphics); renderNpcs(graphics);
} }
if (plugin.isToggleGroundItems() || plugin.isToggleGroundObjects() || plugin.isToggleGameObjects() || plugin.isToggleWalls() || plugin.isToggleDecor() || plugin.isToggleTileLocation()) if (plugin.getGroundItems().isActive() || plugin.getGroundObjects().isActive() || plugin.getGameObjects().isActive() || plugin.getWalls().isActive() || plugin.getDecorations().isActive() || plugin.getTileLocation().isActive())
{ {
renderTileObjects(graphics); renderTileObjects(graphics);
} }
if (plugin.isToggleInventory()) if (plugin.getInventory().isActive())
{ {
renderInventory(graphics); renderInventory(graphics);
} }
if (plugin.isToggleProjectiles()) if (plugin.getProjectiles().isActive())
{ {
renderProjectiles(graphics); renderProjectiles(graphics);
} }
if (plugin.isToggleGraphicsObjects()) if (plugin.getGraphicsObjects().isActive())
{ {
renderGraphicsObjects(graphics); renderGraphicsObjects(graphics);
} }
@@ -213,32 +222,32 @@ public class DevToolsOverlay extends Overlay
continue; continue;
} }
if (plugin.isToggleGroundItems()) if (plugin.getGroundItems().isActive())
{ {
renderGroundItems(graphics, tile, player); renderGroundItems(graphics, tile, player);
} }
if (plugin.isToggleGroundObjects()) if (plugin.getGroundObjects().isActive())
{ {
renderGroundObject(graphics, tile, player); renderGroundObject(graphics, tile, player);
} }
if (plugin.isToggleGameObjects()) if (plugin.getGameObjects().isActive())
{ {
renderGameObjects(graphics, tile, player); renderGameObjects(graphics, tile, player);
} }
if (plugin.isToggleWalls()) if (plugin.getWalls().isActive())
{ {
renderWallObject(graphics, tile, player); renderWallObject(graphics, tile, player);
} }
if (plugin.isToggleDecor()) if (plugin.getDecorations().isActive())
{ {
renderDecorObject(graphics, tile, player); renderDecorObject(graphics, tile, player);
} }
if (plugin.isToggleTileLocation()) if (plugin.getTileLocation().isActive())
{ {
renderTileTooltip(graphics, tile); renderTileTooltip(graphics, tile);
} }
@@ -435,11 +444,8 @@ public class DevToolsOverlay extends Overlay
} }
} }
public void renderWidgets(Graphics2D graphics) private void renderWidgets(Graphics2D graphics)
{ {
Widget widget = plugin.currentWidget;
int itemIndex = plugin.itemIndex;
if (widget == null || widget.isHidden()) if (widget == null || widget.isHidden())
{ {
return; return;

View File

@@ -25,16 +25,14 @@
*/ */
package net.runelite.client.plugins.devtools; package net.runelite.client.plugins.devtools;
import java.awt.Color;
import java.awt.GridLayout; import java.awt.GridLayout;
import javax.inject.Inject; import javax.inject.Inject;
import javax.swing.JButton;
import javax.swing.JPanel; import javax.swing.JPanel;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
public class DevToolsPanel extends PluginPanel class DevToolsPanel extends PluginPanel
{ {
private final Client client; private final Client client;
private final DevToolsPlugin plugin; private final DevToolsPlugin plugin;
@@ -43,7 +41,7 @@ public class DevToolsPanel extends PluginPanel
private final VarInspector varInspector; private final VarInspector varInspector;
@Inject @Inject
public DevToolsPanel(Client client, DevToolsPlugin plugin, WidgetInspector widgetInspector, VarInspector varInspector) private DevToolsPanel(Client client, DevToolsPlugin plugin, WidgetInspector widgetInspector, VarInspector varInspector)
{ {
super(); super();
this.client = client; this.client = client;
@@ -62,204 +60,65 @@ public class DevToolsPanel extends PluginPanel
container.setBackground(ColorScheme.DARK_GRAY_COLOR); container.setBackground(ColorScheme.DARK_GRAY_COLOR);
container.setLayout(new GridLayout(0, 2, 3, 3)); container.setLayout(new GridLayout(0, 2, 3, 3));
final JButton renderPlayersBtn = new JButton("Players"); container.add(plugin.getPlayers());
renderPlayersBtn.addActionListener(e -> container.add(plugin.getNpcs());
{
highlightButton(renderPlayersBtn);
plugin.togglePlayers();
});
container.add(renderPlayersBtn);
final JButton renderNpcsBtn = new JButton("NPCs"); container.add(plugin.getGroundItems());
renderNpcsBtn.addActionListener(e -> container.add(plugin.getGroundObjects());
{ container.add(plugin.getGameObjects());
highlightButton(renderNpcsBtn); container.add(plugin.getGraphicsObjects());
plugin.toggleNpcs(); container.add(plugin.getWalls());
}); container.add(plugin.getDecorations());
container.add(renderNpcsBtn);
final JButton renderGroundItemsBtn = new JButton("Ground Items"); container.add(plugin.getInventory());
renderGroundItemsBtn.addActionListener(e -> container.add(plugin.getProjectiles());
{
highlightButton(renderGroundItemsBtn);
plugin.toggleGroundItems();
});
container.add(renderGroundItemsBtn);
final JButton renderGroundObjectsBtn = new JButton("Ground Objects"); container.add(plugin.getLocation());
renderGroundObjectsBtn.addActionListener(e -> container.add(plugin.getWorldMapLocation());
{ container.add(plugin.getTileLocation());
highlightButton(renderGroundObjectsBtn); container.add(plugin.getCameraPosition());
plugin.toggleGroundObjects();
});
container.add(renderGroundObjectsBtn);
final JButton renderGameObjectsBtn = new JButton("Game Objects"); container.add(plugin.getChunkBorders());
renderGameObjectsBtn.addActionListener(e -> container.add(plugin.getMapSquares());
{
highlightButton(renderGameObjectsBtn);
plugin.toggleGameObjects();
});
container.add(renderGameObjectsBtn);
final JButton renderWallsBtn = new JButton("Walls"); container.add(plugin.getLineOfSight());
renderWallsBtn.addActionListener(e -> container.add(plugin.getValidMovement());
{ container.add(plugin.getInteracting());
highlightButton(renderWallsBtn); container.add(plugin.getExamine());
plugin.toggleWalls();
});
container.add(renderWallsBtn);
final JButton renderDecorBtn = new JButton("Decorations"); container.add(plugin.getDetachedCamera());
renderDecorBtn.addActionListener(e -> plugin.getDetachedCamera().addActionListener((ev) ->
{ {
highlightButton(renderDecorBtn); client.setOculusOrbState(!plugin.getDetachedCamera().isActive() ? 1 : 0);
plugin.toggleDecor(); client.setOculusOrbNormalSpeed(!plugin.getDetachedCamera().isActive() ? 36 : 12);
}); });
container.add(renderDecorBtn);
final JButton renderInventoryBtn = new JButton("Inventory"); container.add(plugin.getWidgetInspector());
renderInventoryBtn.addActionListener(e -> plugin.getWidgetInspector().addActionListener((ev) ->
{ {
highlightButton(renderInventoryBtn); if (plugin.getWidgetInspector().isActive())
plugin.toggleInventory(); {
widgetInspector.close();
}
else
{
widgetInspector.open();
}
}); });
container.add(renderInventoryBtn);
final JButton renderProjectilesBtn = new JButton("Projectiles"); container.add(plugin.getVarInspector());
renderProjectilesBtn.addActionListener(e -> plugin.getVarInspector().addActionListener((ev) ->
{ {
highlightButton(renderProjectilesBtn); if (plugin.getVarInspector().isActive())
plugin.toggleProjectiles(); {
varInspector.close();
}
else
{
varInspector.open();
}
}); });
container.add(renderProjectilesBtn);
final JButton renderLocationBtn = new JButton("Location");
renderLocationBtn.addActionListener(e ->
{
highlightButton(renderLocationBtn);
plugin.toggleLocation();
});
container.add(renderLocationBtn);
final JButton widgetInspectorBtn = new JButton("Widget Tools");
widgetInspectorBtn.addActionListener(e ->
{
widgetInspector.setVisible(true);
widgetInspector.toFront();
widgetInspector.repaint();
});
container.add(widgetInspectorBtn);
final JButton varInspectorBtn = new JButton("Var Tools");
varInspectorBtn.addActionListener(e ->
{
varInspector.open();
});
container.add(varInspectorBtn);
final JButton chunkBordersBtn = new JButton("Chunk borders");
chunkBordersBtn.addActionListener(e ->
{
highlightButton(chunkBordersBtn);
plugin.toggleChunkBorders();
});
container.add(chunkBordersBtn);
final JButton mapSquaresBtn = new JButton("Map squares");
mapSquaresBtn.addActionListener(e ->
{
highlightButton(mapSquaresBtn);
plugin.toggleMapSquares();
});
container.add(mapSquaresBtn);
final JButton validMovementBtn = new JButton("Valid Moves");
validMovementBtn.addActionListener(e ->
{
highlightButton(validMovementBtn);
plugin.toggleValidMovement();
});
container.add(validMovementBtn);
final JButton lineOfSightBtn = new JButton("Line of Sight");
lineOfSightBtn.addActionListener(e ->
{
highlightButton(lineOfSightBtn);
plugin.toggleLineOfSight();
});
container.add(lineOfSightBtn);
final JButton graphicsObjectsBtn = new JButton("Graphics objects");
graphicsObjectsBtn.addActionListener(e ->
{
highlightButton(graphicsObjectsBtn);
plugin.toggleGraphicsObjects();
});
container.add(graphicsObjectsBtn);
final JButton cameraPositionBtn = new JButton("Camera Position");
cameraPositionBtn.addActionListener(e ->
{
highlightButton(cameraPositionBtn);
plugin.toggleCamera();
});
container.add(cameraPositionBtn);
final JButton worldMapBtn = new JButton("World Map Location");
worldMapBtn.addActionListener(e ->
{
highlightButton(worldMapBtn);
plugin.toggleWorldMapLocation();
});
container.add(worldMapBtn);
final JButton tileLocationBtn = new JButton("Tile Location Tooltip");
tileLocationBtn.addActionListener(e ->
{
highlightButton(tileLocationBtn);
plugin.toggleTileLocation();
});
container.add(tileLocationBtn);
final JButton oculusOrbBtn = new JButton("Detached camera");
oculusOrbBtn.addActionListener(e ->
{
highlightButton(oculusOrbBtn);
boolean enabled = oculusOrbBtn.getBackground().equals(Color.GREEN);
client.setOculusOrbState(enabled ? 1 : 0);
client.setOculusOrbNormalSpeed(enabled ? 36 : 12);
});
container.add(oculusOrbBtn);
final JButton interactingBtn = new JButton("Interacting");
interactingBtn.addActionListener(e ->
{
highlightButton(interactingBtn);
plugin.toggleInteracting();
});
container.add(interactingBtn);
final JButton examineInfoBtn = new JButton("Examine Info");
examineInfoBtn.addActionListener(e ->
{
highlightButton(examineInfoBtn);
plugin.toggleExamineInfo();
});
container.add(examineInfoBtn);
return container; return container;
} }
private void highlightButton(JButton button)
{
if (button.getBackground().equals(Color.GREEN))
{
button.setBackground(null);
}
else
{
button.setBackground(Color.GREEN);
}
}
} }

View File

@@ -30,11 +30,11 @@ import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.Font;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import static java.lang.Math.min; import static java.lang.Math.min;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.Getter;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Experience; import net.runelite.api.Experience;
@@ -49,12 +49,10 @@ import net.runelite.api.events.ExperienceChanged;
import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
import net.runelite.api.kit.KitType; import net.runelite.api.kit.KitType;
import net.runelite.api.widgets.Widget;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.JagexColors; import net.runelite.client.ui.JagexColors;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
@@ -67,6 +65,7 @@ import org.slf4j.LoggerFactory;
tags = {"panel"}, tags = {"panel"},
developerPlugin = true developerPlugin = true
) )
@Getter
public class DevToolsPlugin extends Plugin public class DevToolsPlugin extends Plugin
{ {
private static final List<MenuAction> EXAMINE_MENU_ACTIONS = ImmutableList.of(MenuAction.EXAMINE_ITEM, private static final List<MenuAction> EXAMINE_MENU_ACTIONS = ImmutableList.of(MenuAction.EXAMINE_ITEM,
@@ -99,31 +98,29 @@ public class DevToolsPlugin extends Plugin
@Inject @Inject
private EventBus eventBus; private EventBus eventBus;
private boolean togglePlayers; private DevToolsButton players;
private boolean toggleNpcs; private DevToolsButton npcs;
private boolean toggleGroundItems; private DevToolsButton groundItems;
private boolean toggleGroundObjects; private DevToolsButton groundObjects;
private boolean toggleGameObjects; private DevToolsButton gameObjects;
private boolean toggleWalls; private DevToolsButton graphicsObjects;
private boolean toggleDecor; private DevToolsButton walls;
private boolean toggleInventory; private DevToolsButton decorations;
private boolean toggleProjectiles; private DevToolsButton inventory;
private boolean toggleLocation; private DevToolsButton projectiles;
private boolean toggleChunkBorders; private DevToolsButton location;
private boolean toggleMapSquares; private DevToolsButton chunkBorders;
private boolean toggleValidMovement; private DevToolsButton mapSquares;
private boolean toggleLineOfSight; private DevToolsButton validMovement;
private boolean toggleGraphicsObjects; private DevToolsButton lineOfSight;
private boolean toggleCamera; private DevToolsButton cameraPosition;
private boolean toggleWorldMapLocation; private DevToolsButton worldMapLocation ;
private boolean toggleTileLocation; private DevToolsButton tileLocation;
private boolean toggleInteracting; private DevToolsButton interacting;
private boolean toggleExamineInfo; private DevToolsButton examine;
private DevToolsButton detachedCamera;
Widget currentWidget; private DevToolsButton widgetInspector;
int itemIndex = -1; private DevToolsButton varInspector;
private Font font;
private NavigationButton navButton; private NavigationButton navButton;
@Provides @Provides
@@ -135,6 +132,36 @@ public class DevToolsPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
players = new DevToolsButton("Players");
npcs = new DevToolsButton("NPCs");
groundItems = new DevToolsButton("Ground Items");
groundObjects = new DevToolsButton("Ground Objects");
gameObjects = new DevToolsButton("Game Objects");
graphicsObjects = new DevToolsButton("Graphics Objects");
walls = new DevToolsButton("Walls");
decorations = new DevToolsButton("Decorations");
inventory = new DevToolsButton("Inventory");
projectiles = new DevToolsButton("Projectiles");
location = new DevToolsButton("Location");
worldMapLocation = new DevToolsButton("World Map Location");
tileLocation = new DevToolsButton("Tile Location");
cameraPosition = new DevToolsButton("Camera Position");
chunkBorders = new DevToolsButton("Chunk Borders");
mapSquares = new DevToolsButton("Map Squares");
lineOfSight = new DevToolsButton("Line Of Sight");
validMovement = new DevToolsButton("Valid Movement");
interacting = new DevToolsButton("Interacting");
examine = new DevToolsButton("Examine");
detachedCamera = new DevToolsButton("Detached Camera");
widgetInspector = new DevToolsButton("Widget Inspector");
varInspector = new DevToolsButton("Var Inspector");
overlayManager.add(overlay); overlayManager.add(overlay);
overlayManager.add(locationOverlay); overlayManager.add(locationOverlay);
overlayManager.add(sceneOverlay); overlayManager.add(sceneOverlay);
@@ -153,9 +180,6 @@ public class DevToolsPlugin extends Plugin
.build(); .build();
clientToolbar.addNavigation(navButton); clientToolbar.addNavigation(navButton);
font = FontManager.getRunescapeFont()
.deriveFont(Font.BOLD, 16);
} }
@Override @Override
@@ -286,7 +310,7 @@ public class DevToolsPlugin extends Plugin
@Subscribe @Subscribe
public void onMenuEntryAdded(MenuEntryAdded event) public void onMenuEntryAdded(MenuEntryAdded event)
{ {
if (!toggleExamineInfo) if (!examine.isActive())
{ {
return; return;
} }
@@ -321,204 +345,4 @@ public class DevToolsPlugin extends Plugin
client.setMenuEntries(entries); client.setMenuEntries(entries);
} }
} }
Font getFont()
{
return font;
}
void togglePlayers()
{
togglePlayers = !togglePlayers;
}
void toggleNpcs()
{
toggleNpcs = !toggleNpcs;
}
void toggleGroundItems()
{
toggleGroundItems = !toggleGroundItems;
}
void toggleGroundObjects()
{
toggleGroundObjects = !toggleGroundObjects;
}
void toggleGameObjects()
{
toggleGameObjects = !toggleGameObjects;
}
void toggleWalls()
{
toggleWalls = !toggleWalls;
}
void toggleDecor()
{
toggleDecor = !toggleDecor;
}
void toggleInventory()
{
toggleInventory = !toggleInventory;
}
void toggleProjectiles()
{
toggleProjectiles = !toggleProjectiles;
}
void toggleLocation()
{
toggleLocation = !toggleLocation;
}
void toggleChunkBorders()
{
toggleChunkBorders = !toggleChunkBorders;
}
void toggleMapSquares()
{
toggleMapSquares = !toggleMapSquares;
}
void toggleValidMovement()
{
toggleValidMovement = !toggleValidMovement;
}
void toggleLineOfSight()
{
toggleLineOfSight = !toggleLineOfSight;
}
void toggleGraphicsObjects()
{
toggleGraphicsObjects = !toggleGraphicsObjects;
}
void toggleCamera()
{
toggleCamera = !toggleCamera;
}
void toggleWorldMapLocation()
{
toggleWorldMapLocation = !toggleWorldMapLocation;
}
void toggleTileLocation()
{
toggleTileLocation = !toggleTileLocation;
}
void toggleInteracting()
{
toggleInteracting = !toggleInteracting;
}
void toggleExamineInfo()
{
toggleExamineInfo = !toggleExamineInfo;
}
boolean isTogglePlayers()
{
return togglePlayers;
}
boolean isToggleNpcs()
{
return toggleNpcs;
}
boolean isToggleGroundItems()
{
return toggleGroundItems;
}
boolean isToggleGroundObjects()
{
return toggleGroundObjects;
}
boolean isToggleGameObjects()
{
return toggleGameObjects;
}
boolean isToggleWalls()
{
return toggleWalls;
}
boolean isToggleDecor()
{
return toggleDecor;
}
boolean isToggleInventory()
{
return toggleInventory;
}
boolean isToggleProjectiles()
{
return toggleProjectiles;
}
boolean isToggleLocation()
{
return toggleLocation;
}
boolean isToggleChunkBorders()
{
return toggleChunkBorders;
}
boolean isToggleMapSquares()
{
return toggleMapSquares;
}
boolean isToggleValidMovement()
{
return toggleValidMovement;
}
boolean isToggleLineOfSight()
{
return toggleLineOfSight;
}
boolean isToggleGraphicsObjects()
{
return toggleGraphicsObjects;
}
boolean isToggleCamera()
{
return toggleCamera;
}
boolean isToggleWorldMapLocation()
{
return toggleWorldMapLocation;
}
boolean isToggleTileLocation()
{
return toggleTileLocation;
}
boolean isToggleInteracting()
{
return toggleInteracting;
}
} }

View File

@@ -55,7 +55,7 @@ public class LocationOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
if (!plugin.isToggleLocation()) if (!plugin.getLocation().isActive())
{ {
return null; return null;
} }

View File

@@ -87,27 +87,27 @@ public class SceneOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
if (plugin.isToggleChunkBorders()) if (plugin.getChunkBorders().isActive())
{ {
renderChunkBorders(graphics); renderChunkBorders(graphics);
} }
if (plugin.isToggleMapSquares()) if (plugin.getMapSquares().isActive())
{ {
renderMapSquares(graphics); renderMapSquares(graphics);
} }
if (plugin.isToggleLineOfSight()) if (plugin.getLineOfSight().isActive())
{ {
renderLineOfSight(graphics); renderLineOfSight(graphics);
} }
if (plugin.isToggleValidMovement()) if (plugin.getValidMovement().isActive())
{ {
renderValidMovement(graphics); renderValidMovement(graphics);
} }
if (plugin.isToggleInteracting()) if (plugin.getInteracting().isActive())
{ {
renderInteracting(graphics); renderInteracting(graphics);
} }

View File

@@ -84,6 +84,7 @@ class VarInspector extends JFrame
private final static int MAX_LOG_ENTRIES = 10_000; private final static int MAX_LOG_ENTRIES = 10_000;
private final Client client; private final Client client;
private final DevToolsPlugin plugin;
private final EventBus eventBus; private final EventBus eventBus;
private final JPanel tracker = new JPanel(); private final JPanel tracker = new JPanel();
@@ -98,10 +99,11 @@ class VarInspector extends JFrame
private String[] oldStrVarcs = null; private String[] oldStrVarcs = null;
@Inject @Inject
VarInspector(Client client, EventBus eventBus) VarInspector(Client client, EventBus eventBus, DevToolsPlugin plugin)
{ {
this.eventBus = eventBus; this.eventBus = eventBus;
this.client = client; this.client = client;
this.plugin = plugin;
setTitle("RuneLite Var Inspector"); setTitle("RuneLite Var Inspector");
setIconImage(ClientUI.ICON); setIconImage(ClientUI.ICON);
@@ -115,6 +117,7 @@ class VarInspector extends JFrame
public void windowClosing(WindowEvent e) public void windowClosing(WindowEvent e)
{ {
close(); close();
plugin.getVarInspector().setActive(false);
} }
}); });

View File

@@ -61,8 +61,9 @@ class WidgetInspector extends JFrame
{ {
private final Client client; private final Client client;
private final ClientThread clientThread; private final ClientThread clientThread;
private final DevToolsPlugin plugin;
private final DevToolsConfig config; private final DevToolsConfig config;
private final DevToolsOverlay overlay;
private final DevToolsPlugin plugin;
private final JTree widgetTree; private final JTree widgetTree;
private final WidgetInfoTableModel infoTableModel; private final WidgetInfoTableModel infoTableModel;
@@ -71,13 +72,21 @@ class WidgetInspector extends JFrame
private static final Map<Integer, WidgetInfo> widgetIdMap = new HashMap<>(); private static final Map<Integer, WidgetInfo> widgetIdMap = new HashMap<>();
@Inject @Inject
WidgetInspector(DevToolsPlugin plugin, Client client, ClientThread clientThread, WidgetInfoTableModel infoTableModel, DevToolsConfig config, EventBus eventBus) private WidgetInspector(
Client client,
ClientThread clientThread,
WidgetInfoTableModel infoTableModel,
DevToolsConfig config,
EventBus eventBus,
DevToolsOverlay overlay,
DevToolsPlugin plugin)
{ {
this.plugin = plugin;
this.client = client; this.client = client;
this.clientThread = clientThread; this.clientThread = clientThread;
this.infoTableModel = infoTableModel; this.infoTableModel = infoTableModel;
this.config = config; this.config = config;
this.overlay = overlay;
this.plugin = plugin;
eventBus.register(this); eventBus.register(this);
@@ -90,8 +99,8 @@ class WidgetInspector extends JFrame
@Override @Override
public void windowClosing(WindowEvent e) public void windowClosing(WindowEvent e)
{ {
plugin.currentWidget = null; close();
plugin.itemIndex = -1; plugin.getWidgetInspector().setActive(false);
} }
}); });
@@ -107,16 +116,16 @@ class WidgetInspector extends JFrame
{ {
WidgetTreeNode node = (WidgetTreeNode) selected; WidgetTreeNode node = (WidgetTreeNode) selected;
Widget widget = node.getWidget(); Widget widget = node.getWidget();
plugin.currentWidget = widget; overlay.setWidget(widget);
plugin.itemIndex = widget.getItemId(); overlay.setItemIndex(widget.getItemId());
refreshInfo(); refreshInfo();
log.debug("Set widget to {} and item index to {}", widget, widget.getItemId()); log.debug("Set widget to {} and item index to {}", widget, widget.getItemId());
} }
else if (selected instanceof WidgetItemNode) else if (selected instanceof WidgetItemNode)
{ {
WidgetItemNode node = (WidgetItemNode) selected; WidgetItemNode node = (WidgetItemNode) selected;
plugin.itemIndex = node.getWidgetItem().getIndex(); overlay.setItemIndex(node.getWidgetItem().getIndex());
log.debug("Set item index to {}", plugin.itemIndex); log.debug("Set item index to {}", node.getWidgetItem().getIndex());
} }
}); });
@@ -145,12 +154,12 @@ class WidgetInspector extends JFrame
final JButton revalidateWidget = new JButton("Revalidate"); final JButton revalidateWidget = new JButton("Revalidate");
revalidateWidget.addActionListener(ev -> clientThread.invokeLater(() -> revalidateWidget.addActionListener(ev -> clientThread.invokeLater(() ->
{ {
if (plugin.currentWidget == null) if (overlay.getWidget() == null)
{ {
return; return;
} }
plugin.currentWidget.revalidate(); overlay.getWidget().revalidate();
})); }));
bottomPanel.add(revalidateWidget); bottomPanel.add(revalidateWidget);
@@ -175,8 +184,8 @@ class WidgetInspector extends JFrame
Widget[] rootWidgets = client.getWidgetRoots(); Widget[] rootWidgets = client.getWidgetRoots();
DefaultMutableTreeNode root = new DefaultMutableTreeNode(); DefaultMutableTreeNode root = new DefaultMutableTreeNode();
plugin.currentWidget = null; overlay.setWidget(null);
plugin.itemIndex = -1; overlay.setItemIndex(-1);
for (Widget widget : rootWidgets) for (Widget widget : rootWidgets)
{ {
@@ -189,8 +198,8 @@ class WidgetInspector extends JFrame
SwingUtilities.invokeLater(() -> SwingUtilities.invokeLater(() ->
{ {
plugin.currentWidget = null; overlay.setWidget(null);
plugin.itemIndex = -1; overlay.setItemIndex(-1);
refreshInfo(); refreshInfo();
widgetTree.setModel(new DefaultTreeModel(root)); widgetTree.setModel(new DefaultTreeModel(root));
}); });
@@ -264,10 +273,10 @@ class WidgetInspector extends JFrame
private void refreshInfo() private void refreshInfo()
{ {
infoTableModel.setWidget(plugin.currentWidget); infoTableModel.setWidget(overlay.getWidget());
} }
public static WidgetInfo getWidgetInfo(int packedId) static WidgetInfo getWidgetInfo(int packedId)
{ {
if (widgetIdMap.size() == 0) if (widgetIdMap.size() == 0)
{ {
@@ -282,4 +291,18 @@ class WidgetInspector extends JFrame
return widgetIdMap.get(packedId); return widgetIdMap.get(packedId);
} }
public void open()
{
setVisible(true);
toFront();
repaint();
}
public void close()
{
overlay.setWidget(null);
overlay.setItemIndex(-1);
setVisible(false);
}
} }

View File

@@ -62,7 +62,7 @@ public class WorldMapLocationOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
if (!plugin.isToggleWorldMapLocation()) if (!plugin.getWorldMapLocation().isActive())
{ {
return null; return null;
} }