Merge pull request #407 from SomeoneWithAnInternetConnection/boundingbox
Add support for built in runescape bounding/clickbox debug drawing modes to devtools
This commit is contained in:
@@ -176,7 +176,6 @@ public interface Client extends GameEngine
|
|||||||
|
|
||||||
List<Projectile> getProjectiles();
|
List<Projectile> getProjectiles();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Play a sound effect at the player's current location.
|
* Play a sound effect at the player's current location.
|
||||||
* This is how UI, and player-generated (e.g. mining, woodcutting) sound effects are normally played
|
* This is how UI, and player-generated (e.g. mining, woodcutting) sound effects are normally played
|
||||||
@@ -195,6 +194,45 @@ public interface Client extends GameEngine
|
|||||||
*/
|
*/
|
||||||
void playSoundEffect(int id, int x, int y, int range);
|
void playSoundEffect(int id, int x, int y, int range);
|
||||||
|
|
||||||
|
boolean getDrawBoundingBoxes2D();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When {@code shouldDraw} is true, a 2D bounding box will be drawn for all on-screen objects
|
||||||
|
*
|
||||||
|
* @param shouldDraw whether or not to draw 2D bounding boxes
|
||||||
|
*/
|
||||||
|
void setDrawBoundingBoxes2D(boolean shouldDraw);
|
||||||
|
|
||||||
|
boolean getDrawBoundingBoxes3D();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When {@code shouldDraw} is true, 3D bounding boxes will be drawn
|
||||||
|
* either for the object under the cursor, or every object on screen
|
||||||
|
* according to {@link #setBoundingBoxAlwaysOnMode(boolean) BoundingBoxAlwaysOnMode}
|
||||||
|
*
|
||||||
|
* @param shouldDraw whether or not to draw 3D bounding boxes
|
||||||
|
*/
|
||||||
|
void setDrawBoundingBoxes3D(boolean shouldDraw);
|
||||||
|
|
||||||
|
boolean getdrawObjectGeometry2D();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When {@code shouldDraw} is true, the clickbox geometry for the object under the cursor will be displayed
|
||||||
|
*
|
||||||
|
* @param shouldDraw whether or not to draw the clickbox geometry
|
||||||
|
*/
|
||||||
|
void setdrawObjectGeometry2D(boolean shouldDraw);
|
||||||
|
|
||||||
|
boolean getBoundingBoxAlwaysOnMode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes how {@link #getDrawBoundingBoxes3D()} behaves when active.
|
||||||
|
* When {@code alwaysDrawBoxes} is true, 3D bounding boxes will be drawn.
|
||||||
|
* When false, a 3D bounding box will only be drawn for the object under the cursor
|
||||||
|
*
|
||||||
|
* @param alwaysDrawBoxes whether or not to draw every 3D bounding box, when 3D bounding boxes are enabled
|
||||||
|
*/
|
||||||
|
void setBoundingBoxAlwaysOnMode(boolean alwaysDrawBoxes);
|
||||||
|
|
||||||
BufferProvider getBufferProvider();
|
BufferProvider getBufferProvider();
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,13 @@ import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
|
|||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@@ -61,6 +64,7 @@ public class DevToolsPanel extends PluginPanel
|
|||||||
private JButton renderDecorBtn = new JButton();
|
private JButton renderDecorBtn = new JButton();
|
||||||
private JButton renderInventoryBtn = new JButton();
|
private JButton renderInventoryBtn = new JButton();
|
||||||
private JButton renderProjectilesBtn = new JButton();
|
private JButton renderProjectilesBtn = new JButton();
|
||||||
|
private JPanel boundsDebugPanel = new JPanel();
|
||||||
|
|
||||||
private JLabel textLbl = new JLabel();
|
private JLabel textLbl = new JLabel();
|
||||||
private JLabel textColorLbl = new JLabel();
|
private JLabel textColorLbl = new JLabel();
|
||||||
@@ -167,6 +171,9 @@ public class DevToolsPanel extends PluginPanel
|
|||||||
});
|
});
|
||||||
container.add(renderProjectilesBtn);
|
container.add(renderProjectilesBtn);
|
||||||
|
|
||||||
|
boundsDebugPanel = createBoundsDebugMultiButton();
|
||||||
|
container.add(boundsDebugPanel);
|
||||||
|
|
||||||
JButton settingsSnapshotBtn = new JButton("Get Settings");
|
JButton settingsSnapshotBtn = new JButton("Get Settings");
|
||||||
settingsSnapshotBtn.addActionListener(settingsTracker::snapshot);
|
settingsSnapshotBtn.addActionListener(settingsTracker::snapshot);
|
||||||
container.add(settingsSnapshotBtn);
|
container.add(settingsSnapshotBtn);
|
||||||
@@ -178,6 +185,70 @@ public class DevToolsPanel extends PluginPanel
|
|||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JPanel createBoundsDebugMultiButton()
|
||||||
|
{
|
||||||
|
ImageIcon bBox2DIcon;
|
||||||
|
ImageIcon bBox3DIcon;
|
||||||
|
ImageIcon clickBoxIcon;
|
||||||
|
ImageIcon bBox3DMousoverIcon;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bBox2DIcon = new ImageIcon(ImageIO.read(DevToolsPlugin.class.getResourceAsStream("2D_bounding_box.png")));
|
||||||
|
bBox3DIcon = new ImageIcon(ImageIO.read(DevToolsPlugin.class.getResourceAsStream("3D_bounding_box.png")));
|
||||||
|
clickBoxIcon = new ImageIcon(ImageIO.read(DevToolsPlugin.class.getResourceAsStream("2D_clickbox_geometry.png")));
|
||||||
|
bBox3DMousoverIcon = new ImageIcon(ImageIO.read(DevToolsPlugin.class.getResourceAsStream("mouseover_3D_bounding_box.png")));
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
log.warn("unable to load bounding box images", ex);
|
||||||
|
return new JPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
JPanel buttonPanel = new JPanel();
|
||||||
|
buttonPanel.setLayout(new GridLayout(1, 4));
|
||||||
|
JButton bBox2DButton = new JButton(bBox2DIcon);
|
||||||
|
bBox2DButton.addActionListener(e ->
|
||||||
|
{
|
||||||
|
client.setDrawBoundingBoxes2D(!client.getDrawBoundingBoxes2D());
|
||||||
|
highlightButton(bBox2DButton);
|
||||||
|
});
|
||||||
|
buttonPanel.add(bBox2DButton);
|
||||||
|
|
||||||
|
JButton bBox3DButton = new JButton(bBox3DIcon);
|
||||||
|
bBox3DButton.addActionListener(e ->
|
||||||
|
{
|
||||||
|
client.setDrawBoundingBoxes3D(!client.getDrawBoundingBoxes3D());
|
||||||
|
highlightButton(bBox3DButton);
|
||||||
|
});
|
||||||
|
buttonPanel.add(bBox3DButton);
|
||||||
|
|
||||||
|
JButton clickBoxButton = new JButton(clickBoxIcon);
|
||||||
|
clickBoxButton.addActionListener(e ->
|
||||||
|
{
|
||||||
|
client.setdrawObjectGeometry2D(!client.getdrawObjectGeometry2D());
|
||||||
|
highlightButton(clickBoxButton);
|
||||||
|
});
|
||||||
|
buttonPanel.add(clickBoxButton);
|
||||||
|
|
||||||
|
JButton mouseoverModeButton = new JButton(client.getBoundingBoxAlwaysOnMode() ? bBox3DIcon : bBox3DMousoverIcon);
|
||||||
|
mouseoverModeButton.addActionListener(e ->
|
||||||
|
{
|
||||||
|
client.setBoundingBoxAlwaysOnMode(!client.getBoundingBoxAlwaysOnMode());
|
||||||
|
if (client.getBoundingBoxAlwaysOnMode())
|
||||||
|
{
|
||||||
|
mouseoverModeButton.setIcon(bBox3DIcon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mouseoverModeButton.setIcon(bBox3DMousoverIcon);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttonPanel.add(mouseoverModeButton);
|
||||||
|
|
||||||
|
return buttonPanel;
|
||||||
|
}
|
||||||
|
|
||||||
private JPanel createWidgetTreePanel()
|
private JPanel createWidgetTreePanel()
|
||||||
{
|
{
|
||||||
JPanel container = new JPanel();
|
JPanel container = new JPanel();
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 233 B |
Binary file not shown.
|
After Width: | Height: | Size: 285 B |
Binary file not shown.
|
After Width: | Height: | Size: 430 B |
Binary file not shown.
|
After Width: | Height: | Size: 312 B |
@@ -375,6 +375,27 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
return new Point(getDestinationX(), getDestinationY());
|
return new Point(getDestinationX(), getDestinationY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Override
|
||||||
|
public boolean getBoundingBoxAlwaysOnMode()
|
||||||
|
{
|
||||||
|
return getboundingBox3DDrawMode() == getALWAYSDrawMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Override
|
||||||
|
public void setBoundingBoxAlwaysOnMode(boolean alwaysDrawBoxes)
|
||||||
|
{
|
||||||
|
if (alwaysDrawBoxes)
|
||||||
|
{
|
||||||
|
setboundingBox3DDrawMode(getALWAYSDrawMode());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setboundingBox3DDrawMode(getON_MOUSEOVERDrawMode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@FieldHook("skillExperiences")
|
@FieldHook("skillExperiences")
|
||||||
@Inject
|
@Inject
|
||||||
public static void experiencedChanged(int idx)
|
public static void experiencedChanged(int idx)
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, SomeoneWithAnInternetConnection
|
||||||
|
* 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.rs.api;
|
||||||
|
|
||||||
|
public interface RSBoundingBox3DDrawMode
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -373,6 +373,42 @@ public interface RSClient extends RSGameEngine, Client
|
|||||||
@Import("queuedSoundEffectCount")
|
@Import("queuedSoundEffectCount")
|
||||||
void setQueuedSoundEffectCount(int queuedSoundEffectCount);
|
void setQueuedSoundEffectCount(int queuedSoundEffectCount);
|
||||||
|
|
||||||
|
@Import("drawBoundingBoxes2D")
|
||||||
|
@Override
|
||||||
|
boolean getDrawBoundingBoxes2D();
|
||||||
|
|
||||||
|
@Import("drawBoundingBoxes2D")
|
||||||
|
@Override
|
||||||
|
void setDrawBoundingBoxes2D(boolean shouldDraw);
|
||||||
|
|
||||||
|
@Import("drawBoundingBoxes3D")
|
||||||
|
@Override
|
||||||
|
boolean getDrawBoundingBoxes3D();
|
||||||
|
|
||||||
|
@Import("drawBoundingBoxes3D")
|
||||||
|
@Override
|
||||||
|
void setDrawBoundingBoxes3D(boolean shouldDraw);
|
||||||
|
|
||||||
|
@Import("drawObjectGeometry2D")
|
||||||
|
@Override
|
||||||
|
boolean getdrawObjectGeometry2D();
|
||||||
|
|
||||||
|
@Import("drawObjectGeometry2D")
|
||||||
|
@Override
|
||||||
|
void setdrawObjectGeometry2D(boolean shouldDraw);
|
||||||
|
|
||||||
|
@Import("boundingBox3DDrawMode")
|
||||||
|
RSBoundingBox3DDrawMode getboundingBox3DDrawMode();
|
||||||
|
|
||||||
|
@Import("boundingBox3DDrawMode")
|
||||||
|
void setboundingBox3DDrawMode(RSBoundingBox3DDrawMode drawMode);
|
||||||
|
|
||||||
|
@Import("ON_MOUSEOVER")
|
||||||
|
RSBoundingBox3DDrawMode getON_MOUSEOVERDrawMode();
|
||||||
|
|
||||||
|
@Import("ALWAYS")
|
||||||
|
RSBoundingBox3DDrawMode getALWAYSDrawMode();
|
||||||
|
|
||||||
@Import("rasterProvider")
|
@Import("rasterProvider")
|
||||||
@Override
|
@Override
|
||||||
BufferProvider getBufferProvider();
|
BufferProvider getBufferProvider();
|
||||||
|
|||||||
Reference in New Issue
Block a user