diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/CameraOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/CameraOverlay.java index 8a17cbb64e..882fe4201c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/CameraOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/CameraOverlay.java @@ -52,7 +52,7 @@ public class CameraOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!plugin.isToggleCamera()) + if (!plugin.getCameraPosition().isActive()) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsButton.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsButton.java new file mode 100644 index 0000000000..52de0309a9 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsButton.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018, Tomas Slusny + * 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); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java index 07eaec5f68..83e430fc08 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java @@ -35,6 +35,9 @@ import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.Getter; +import lombok.Setter; import net.runelite.api.Actor; import net.runelite.api.Client; 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.WidgetInfo; 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.OverlayLayer; 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.TooltipManager; -public class DevToolsOverlay extends Overlay +@Singleton +class DevToolsOverlay extends Overlay { - public static final int ITEM_EMPTY = 6512; - public static final int ITEM_FILLED = 20594; + private static final int ITEM_EMPTY = 6512; + 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 GREEN = new Color(0, 200, 83); 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 TooltipManager toolTipManager; + @Setter + @Getter + private Widget widget; + + @Setter + private int itemIndex = -1; + @Inject - public DevToolsOverlay(Client client, DevToolsPlugin plugin, TooltipManager toolTipManager) + private DevToolsOverlay(Client client, DevToolsPlugin plugin, TooltipManager toolTipManager) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ALWAYS_ON_TOP); @@ -99,38 +112,34 @@ public class DevToolsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - Font font = plugin.getFont(); - if (font != null) - { - graphics.setFont(font); - } + graphics.setFont(FONT); - if (plugin.isTogglePlayers()) + if (plugin.getPlayers().isActive()) { renderPlayers(graphics); } - if (plugin.isToggleNpcs()) + if (plugin.getNpcs().isActive()) { 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); } - if (plugin.isToggleInventory()) + if (plugin.getInventory().isActive()) { renderInventory(graphics); } - if (plugin.isToggleProjectiles()) + if (plugin.getProjectiles().isActive()) { renderProjectiles(graphics); } - if (plugin.isToggleGraphicsObjects()) + if (plugin.getGraphicsObjects().isActive()) { renderGraphicsObjects(graphics); } @@ -213,32 +222,32 @@ public class DevToolsOverlay extends Overlay continue; } - if (plugin.isToggleGroundItems()) + if (plugin.getGroundItems().isActive()) { renderGroundItems(graphics, tile, player); } - if (plugin.isToggleGroundObjects()) + if (plugin.getGroundObjects().isActive()) { renderGroundObject(graphics, tile, player); } - if (plugin.isToggleGameObjects()) + if (plugin.getGameObjects().isActive()) { renderGameObjects(graphics, tile, player); } - if (plugin.isToggleWalls()) + if (plugin.getWalls().isActive()) { renderWallObject(graphics, tile, player); } - if (plugin.isToggleDecor()) + if (plugin.getDecorations().isActive()) { renderDecorObject(graphics, tile, player); } - if (plugin.isToggleTileLocation()) + if (plugin.getTileLocation().isActive()) { 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()) { return; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java index e68577a501..6798d4056b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java @@ -25,16 +25,14 @@ */ package net.runelite.client.plugins.devtools; -import java.awt.Color; import java.awt.GridLayout; import javax.inject.Inject; -import javax.swing.JButton; import javax.swing.JPanel; import net.runelite.api.Client; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.PluginPanel; -public class DevToolsPanel extends PluginPanel +class DevToolsPanel extends PluginPanel { private final Client client; private final DevToolsPlugin plugin; @@ -43,7 +41,7 @@ public class DevToolsPanel extends PluginPanel private final VarInspector varInspector; @Inject - public DevToolsPanel(Client client, DevToolsPlugin plugin, WidgetInspector widgetInspector, VarInspector varInspector) + private DevToolsPanel(Client client, DevToolsPlugin plugin, WidgetInspector widgetInspector, VarInspector varInspector) { super(); this.client = client; @@ -62,204 +60,65 @@ public class DevToolsPanel extends PluginPanel container.setBackground(ColorScheme.DARK_GRAY_COLOR); container.setLayout(new GridLayout(0, 2, 3, 3)); - final JButton renderPlayersBtn = new JButton("Players"); - renderPlayersBtn.addActionListener(e -> - { - highlightButton(renderPlayersBtn); - plugin.togglePlayers(); - }); - container.add(renderPlayersBtn); + container.add(plugin.getPlayers()); + container.add(plugin.getNpcs()); - final JButton renderNpcsBtn = new JButton("NPCs"); - renderNpcsBtn.addActionListener(e -> - { - highlightButton(renderNpcsBtn); - plugin.toggleNpcs(); - }); - container.add(renderNpcsBtn); + container.add(plugin.getGroundItems()); + container.add(plugin.getGroundObjects()); + container.add(plugin.getGameObjects()); + container.add(plugin.getGraphicsObjects()); + container.add(plugin.getWalls()); + container.add(plugin.getDecorations()); - final JButton renderGroundItemsBtn = new JButton("Ground Items"); - renderGroundItemsBtn.addActionListener(e -> - { - highlightButton(renderGroundItemsBtn); - plugin.toggleGroundItems(); - }); - container.add(renderGroundItemsBtn); + container.add(plugin.getInventory()); + container.add(plugin.getProjectiles()); - final JButton renderGroundObjectsBtn = new JButton("Ground Objects"); - renderGroundObjectsBtn.addActionListener(e -> - { - highlightButton(renderGroundObjectsBtn); - plugin.toggleGroundObjects(); - }); - container.add(renderGroundObjectsBtn); + container.add(plugin.getLocation()); + container.add(plugin.getWorldMapLocation()); + container.add(plugin.getTileLocation()); + container.add(plugin.getCameraPosition()); - final JButton renderGameObjectsBtn = new JButton("Game Objects"); - renderGameObjectsBtn.addActionListener(e -> - { - highlightButton(renderGameObjectsBtn); - plugin.toggleGameObjects(); - }); - container.add(renderGameObjectsBtn); + container.add(plugin.getChunkBorders()); + container.add(plugin.getMapSquares()); - final JButton renderWallsBtn = new JButton("Walls"); - renderWallsBtn.addActionListener(e -> - { - highlightButton(renderWallsBtn); - plugin.toggleWalls(); - }); - container.add(renderWallsBtn); + container.add(plugin.getLineOfSight()); + container.add(plugin.getValidMovement()); + container.add(plugin.getInteracting()); + container.add(plugin.getExamine()); - final JButton renderDecorBtn = new JButton("Decorations"); - renderDecorBtn.addActionListener(e -> + container.add(plugin.getDetachedCamera()); + plugin.getDetachedCamera().addActionListener((ev) -> { - highlightButton(renderDecorBtn); - plugin.toggleDecor(); + client.setOculusOrbState(!plugin.getDetachedCamera().isActive() ? 1 : 0); + client.setOculusOrbNormalSpeed(!plugin.getDetachedCamera().isActive() ? 36 : 12); }); - container.add(renderDecorBtn); - final JButton renderInventoryBtn = new JButton("Inventory"); - renderInventoryBtn.addActionListener(e -> + container.add(plugin.getWidgetInspector()); + plugin.getWidgetInspector().addActionListener((ev) -> { - highlightButton(renderInventoryBtn); - plugin.toggleInventory(); + if (plugin.getWidgetInspector().isActive()) + { + widgetInspector.close(); + } + else + { + widgetInspector.open(); + } }); - container.add(renderInventoryBtn); - final JButton renderProjectilesBtn = new JButton("Projectiles"); - renderProjectilesBtn.addActionListener(e -> + container.add(plugin.getVarInspector()); + plugin.getVarInspector().addActionListener((ev) -> { - highlightButton(renderProjectilesBtn); - plugin.toggleProjectiles(); + if (plugin.getVarInspector().isActive()) + { + 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; } - - private void highlightButton(JButton button) - { - if (button.getBackground().equals(Color.GREEN)) - { - button.setBackground(null); - } - else - { - button.setBackground(Color.GREEN); - } - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java index ba4c396090..0994745b42 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java @@ -30,11 +30,11 @@ import com.google.common.collect.ImmutableList; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Provides; -import java.awt.Font; import java.awt.image.BufferedImage; import static java.lang.Math.min; import java.util.List; import javax.inject.Inject; +import lombok.Getter; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; 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.VarbitChanged; import net.runelite.api.kit.KitType; -import net.runelite.api.widgets.Widget; import net.runelite.client.config.ConfigManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.ClientToolbar; -import net.runelite.client.ui.FontManager; import net.runelite.client.ui.JagexColors; import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.overlay.OverlayManager; @@ -67,6 +65,7 @@ import org.slf4j.LoggerFactory; tags = {"panel"}, developerPlugin = true ) +@Getter public class DevToolsPlugin extends Plugin { private static final List EXAMINE_MENU_ACTIONS = ImmutableList.of(MenuAction.EXAMINE_ITEM, @@ -99,31 +98,29 @@ public class DevToolsPlugin extends Plugin @Inject private EventBus eventBus; - 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 boolean toggleProjectiles; - private boolean toggleLocation; - private boolean toggleChunkBorders; - private boolean toggleMapSquares; - private boolean toggleValidMovement; - private boolean toggleLineOfSight; - private boolean toggleGraphicsObjects; - private boolean toggleCamera; - private boolean toggleWorldMapLocation; - private boolean toggleTileLocation; - private boolean toggleInteracting; - private boolean toggleExamineInfo; - - Widget currentWidget; - int itemIndex = -1; - - private Font font; + private DevToolsButton players; + private DevToolsButton npcs; + private DevToolsButton groundItems; + private DevToolsButton groundObjects; + private DevToolsButton gameObjects; + private DevToolsButton graphicsObjects; + private DevToolsButton walls; + private DevToolsButton decorations; + private DevToolsButton inventory; + private DevToolsButton projectiles; + private DevToolsButton location; + private DevToolsButton chunkBorders; + private DevToolsButton mapSquares; + private DevToolsButton validMovement; + private DevToolsButton lineOfSight; + private DevToolsButton cameraPosition; + private DevToolsButton worldMapLocation ; + private DevToolsButton tileLocation; + private DevToolsButton interacting; + private DevToolsButton examine; + private DevToolsButton detachedCamera; + private DevToolsButton widgetInspector; + private DevToolsButton varInspector; private NavigationButton navButton; @Provides @@ -135,6 +132,36 @@ public class DevToolsPlugin extends Plugin @Override 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(locationOverlay); overlayManager.add(sceneOverlay); @@ -153,9 +180,6 @@ public class DevToolsPlugin extends Plugin .build(); clientToolbar.addNavigation(navButton); - - font = FontManager.getRunescapeFont() - .deriveFont(Font.BOLD, 16); } @Override @@ -286,7 +310,7 @@ public class DevToolsPlugin extends Plugin @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if (!toggleExamineInfo) + if (!examine.isActive()) { return; } @@ -321,204 +345,4 @@ public class DevToolsPlugin extends Plugin 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; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/LocationOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/LocationOverlay.java index 32c42bb455..e9f9d2b608 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/LocationOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/LocationOverlay.java @@ -55,7 +55,7 @@ public class LocationOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!plugin.isToggleLocation()) + if (!plugin.getLocation().isActive()) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SceneOverlay.java index c7d5d2769b..9ee625e615 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SceneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SceneOverlay.java @@ -87,27 +87,27 @@ public class SceneOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (plugin.isToggleChunkBorders()) + if (plugin.getChunkBorders().isActive()) { renderChunkBorders(graphics); } - if (plugin.isToggleMapSquares()) + if (plugin.getMapSquares().isActive()) { renderMapSquares(graphics); } - if (plugin.isToggleLineOfSight()) + if (plugin.getLineOfSight().isActive()) { renderLineOfSight(graphics); } - if (plugin.isToggleValidMovement()) + if (plugin.getValidMovement().isActive()) { renderValidMovement(graphics); } - if (plugin.isToggleInteracting()) + if (plugin.getInteracting().isActive()) { renderInteracting(graphics); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java index 382bd6a7e0..4295012d54 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java @@ -84,6 +84,7 @@ class VarInspector extends JFrame private final static int MAX_LOG_ENTRIES = 10_000; private final Client client; + private final DevToolsPlugin plugin; private final EventBus eventBus; private final JPanel tracker = new JPanel(); @@ -98,10 +99,11 @@ class VarInspector extends JFrame private String[] oldStrVarcs = null; @Inject - VarInspector(Client client, EventBus eventBus) + VarInspector(Client client, EventBus eventBus, DevToolsPlugin plugin) { this.eventBus = eventBus; this.client = client; + this.plugin = plugin; setTitle("RuneLite Var Inspector"); setIconImage(ClientUI.ICON); @@ -115,6 +117,7 @@ class VarInspector extends JFrame public void windowClosing(WindowEvent e) { close(); + plugin.getVarInspector().setActive(false); } }); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInspector.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInspector.java index 0992bdec06..e4f1f79632 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInspector.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInspector.java @@ -61,8 +61,9 @@ class WidgetInspector extends JFrame { private final Client client; private final ClientThread clientThread; - private final DevToolsPlugin plugin; private final DevToolsConfig config; + private final DevToolsOverlay overlay; + private final DevToolsPlugin plugin; private final JTree widgetTree; private final WidgetInfoTableModel infoTableModel; @@ -71,13 +72,21 @@ class WidgetInspector extends JFrame private static final Map widgetIdMap = new HashMap<>(); @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.clientThread = clientThread; this.infoTableModel = infoTableModel; this.config = config; + this.overlay = overlay; + this.plugin = plugin; eventBus.register(this); @@ -90,8 +99,8 @@ class WidgetInspector extends JFrame @Override public void windowClosing(WindowEvent e) { - plugin.currentWidget = null; - plugin.itemIndex = -1; + close(); + plugin.getWidgetInspector().setActive(false); } }); @@ -107,16 +116,16 @@ class WidgetInspector extends JFrame { WidgetTreeNode node = (WidgetTreeNode) selected; Widget widget = node.getWidget(); - plugin.currentWidget = widget; - plugin.itemIndex = widget.getItemId(); + overlay.setWidget(widget); + overlay.setItemIndex(widget.getItemId()); refreshInfo(); log.debug("Set widget to {} and item index to {}", widget, widget.getItemId()); } else if (selected instanceof WidgetItemNode) { WidgetItemNode node = (WidgetItemNode) selected; - plugin.itemIndex = node.getWidgetItem().getIndex(); - log.debug("Set item index to {}", plugin.itemIndex); + overlay.setItemIndex(node.getWidgetItem().getIndex()); + log.debug("Set item index to {}", node.getWidgetItem().getIndex()); } }); @@ -145,12 +154,12 @@ class WidgetInspector extends JFrame final JButton revalidateWidget = new JButton("Revalidate"); revalidateWidget.addActionListener(ev -> clientThread.invokeLater(() -> { - if (plugin.currentWidget == null) + if (overlay.getWidget() == null) { return; } - plugin.currentWidget.revalidate(); + overlay.getWidget().revalidate(); })); bottomPanel.add(revalidateWidget); @@ -175,8 +184,8 @@ class WidgetInspector extends JFrame Widget[] rootWidgets = client.getWidgetRoots(); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); - plugin.currentWidget = null; - plugin.itemIndex = -1; + overlay.setWidget(null); + overlay.setItemIndex(-1); for (Widget widget : rootWidgets) { @@ -189,8 +198,8 @@ class WidgetInspector extends JFrame SwingUtilities.invokeLater(() -> { - plugin.currentWidget = null; - plugin.itemIndex = -1; + overlay.setWidget(null); + overlay.setItemIndex(-1); refreshInfo(); widgetTree.setModel(new DefaultTreeModel(root)); }); @@ -264,10 +273,10 @@ class WidgetInspector extends JFrame 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) { @@ -282,4 +291,18 @@ class WidgetInspector extends JFrame return widgetIdMap.get(packedId); } + + public void open() + { + setVisible(true); + toFront(); + repaint(); + } + + public void close() + { + overlay.setWidget(null); + overlay.setItemIndex(-1); + setVisible(false); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WorldMapLocationOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WorldMapLocationOverlay.java index 714ebc5d0e..461f3ee082 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WorldMapLocationOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WorldMapLocationOverlay.java @@ -62,7 +62,7 @@ public class WorldMapLocationOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!plugin.isToggleWorldMapLocation()) + if (!plugin.getWorldMapLocation().isActive()) { return null; }