runelite-api: Use more general Shape for clickboxes and convex hulls
This commit is contained in:
@@ -26,6 +26,7 @@ package net.runelite.api;
|
|||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
|
import java.awt.Shape;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import net.runelite.api.annotations.VisibleForDevtools;
|
import net.runelite.api.annotations.VisibleForDevtools;
|
||||||
@@ -218,7 +219,7 @@ public interface Actor extends Renderable
|
|||||||
* @return the convex hull
|
* @return the convex hull
|
||||||
* @see net.runelite.api.model.Jarvis
|
* @see net.runelite.api.model.Jarvis
|
||||||
*/
|
*/
|
||||||
Polygon getConvexHull();
|
Shape getConvexHull();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the world area that the actor occupies.
|
* Gets the world area that the actor occupies.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.api;
|
package net.runelite.api;
|
||||||
|
|
||||||
import java.awt.Polygon;
|
import java.awt.Shape;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a decorative object, such as an object on a wall.
|
* Represents a decorative object, such as an object on a wall.
|
||||||
@@ -37,8 +37,8 @@ public interface DecorativeObject extends TileObject
|
|||||||
* @return the convex hull
|
* @return the convex hull
|
||||||
* @see net.runelite.api.model.Jarvis
|
* @see net.runelite.api.model.Jarvis
|
||||||
*/
|
*/
|
||||||
Polygon getConvexHull();
|
Shape getConvexHull();
|
||||||
Polygon getConvexHull2();
|
Shape getConvexHull2();
|
||||||
|
|
||||||
Renderable getRenderable();
|
Renderable getRenderable();
|
||||||
Renderable getRenderable2();
|
Renderable getRenderable2();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.api;
|
package net.runelite.api;
|
||||||
|
|
||||||
import java.awt.Polygon;
|
import java.awt.Shape;
|
||||||
import net.runelite.api.coords.Angle;
|
import net.runelite.api.coords.Angle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,12 +54,12 @@ public interface GameObject extends TileObject
|
|||||||
Point getSceneMaxLocation();
|
Point getSceneMaxLocation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the convex hull of the actors model.
|
* Gets the convex hull of the object's model.
|
||||||
*
|
*
|
||||||
* @return the convex hull
|
* @return the convex hull
|
||||||
* @see net.runelite.api.model.Jarvis
|
* @see net.runelite.api.model.Jarvis
|
||||||
*/
|
*/
|
||||||
Polygon getConvexHull();
|
Shape getConvexHull();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the orientation of the object.
|
* Gets the orientation of the object.
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ package net.runelite.api;
|
|||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
import java.awt.geom.Area;
|
import java.awt.Shape;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
@@ -132,5 +132,5 @@ public interface TileObject
|
|||||||
* @return the clickable area
|
* @return the clickable area
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
Area getClickbox();
|
Shape getClickbox();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.api;
|
package net.runelite.api;
|
||||||
|
|
||||||
import java.awt.Polygon;
|
import java.awt.Shape;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents one or two walls on a tile
|
* Represents one or two walls on a tile
|
||||||
@@ -63,8 +63,8 @@ public interface WallObject extends TileObject
|
|||||||
* @return the convex hull
|
* @return the convex hull
|
||||||
* @see net.runelite.api.model.Jarvis
|
* @see net.runelite.api.model.Jarvis
|
||||||
*/
|
*/
|
||||||
Polygon getConvexHull();
|
Shape getConvexHull();
|
||||||
Polygon getConvexHull2();
|
Shape getConvexHull2();
|
||||||
|
|
||||||
Renderable getRenderable1();
|
Renderable getRenderable1();
|
||||||
Renderable getRenderable2();
|
Renderable getRenderable2();
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
import java.awt.geom.Area;
|
import java.awt.Shape;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
@@ -90,7 +90,7 @@ class AgilityOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Area objectClickbox = object.getClickbox();
|
Shape objectClickbox = object.getClickbox();
|
||||||
if (objectClickbox != null)
|
if (objectClickbox != null)
|
||||||
{
|
{
|
||||||
AgilityShortcut agilityShortcut = obstacle.getShortcut();
|
AgilityShortcut agilityShortcut = obstacle.getShortcut();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ package net.runelite.client.plugins.blastfurnace;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Area;
|
import java.awt.Shape;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.EquipmentInventorySlot;
|
import net.runelite.api.EquipmentInventorySlot;
|
||||||
@@ -110,7 +110,7 @@ class BlastFurnaceClickBoxOverlay extends Overlay
|
|||||||
|
|
||||||
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
|
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
|
||||||
{
|
{
|
||||||
Area objectClickbox = object.getClickbox();
|
Shape objectClickbox = object.getClickbox();
|
||||||
if (objectClickbox != null)
|
if (objectClickbox != null)
|
||||||
{
|
{
|
||||||
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
|
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import java.awt.FontMetrics;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Shape;
|
||||||
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;
|
||||||
@@ -286,10 +287,10 @@ class DevToolsOverlay extends Overlay
|
|||||||
|
|
||||||
// Draw a polygon around the convex hull
|
// Draw a polygon around the convex hull
|
||||||
// of the model vertices
|
// of the model vertices
|
||||||
Polygon p = gameObject.getConvexHull();
|
Shape p = gameObject.getConvexHull();
|
||||||
if (p != null)
|
if (p != null)
|
||||||
{
|
{
|
||||||
graphics.drawPolygon(p);
|
graphics.draw(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,16 +331,16 @@ class DevToolsOverlay extends Overlay
|
|||||||
OverlayUtil.renderTileOverlay(graphics, decorObject, "ID: " + decorObject.getId(), DEEP_PURPLE);
|
OverlayUtil.renderTileOverlay(graphics, decorObject, "ID: " + decorObject.getId(), DEEP_PURPLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Polygon p = decorObject.getConvexHull();
|
Shape p = decorObject.getConvexHull();
|
||||||
if (p != null)
|
if (p != null)
|
||||||
{
|
{
|
||||||
graphics.drawPolygon(p);
|
graphics.draw(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
p = decorObject.getConvexHull2();
|
p = decorObject.getConvexHull2();
|
||||||
if (p != null)
|
if (p != null)
|
||||||
{
|
{
|
||||||
graphics.drawPolygon(p);
|
graphics.draw(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import com.google.inject.Inject;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Area;
|
import java.awt.Shape;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.runelite.api.TileObject;
|
import net.runelite.api.TileObject;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
@@ -103,7 +103,7 @@ class HerbiboarOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
if (config.showClickBoxes())
|
if (config.showClickBoxes())
|
||||||
{
|
{
|
||||||
Area clickbox = object.getClickbox();
|
Shape clickbox = object.getClickbox();
|
||||||
if (clickbox != null)
|
if (clickbox != null)
|
||||||
{
|
{
|
||||||
graphics.setColor(config.getObjectColor());
|
graphics.setColor(config.getObjectColor());
|
||||||
@@ -129,7 +129,7 @@ class HerbiboarOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
if (config.showClickBoxes())
|
if (config.showClickBoxes())
|
||||||
{
|
{
|
||||||
Area clickbox = object.getClickbox();
|
Shape clickbox = object.getClickbox();
|
||||||
if (clickbox != null)
|
if (clickbox != null)
|
||||||
{
|
{
|
||||||
Color col = config.getObjectColor();
|
Color col = config.getObjectColor();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
|
import java.awt.Shape;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -167,7 +168,7 @@ public class NpcSceneOverlay extends Overlay
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HULL:
|
case HULL:
|
||||||
Polygon objectClickbox = actor.getConvexHull();
|
Shape objectClickbox = actor.getConvexHull();
|
||||||
|
|
||||||
renderPoly(graphics, color, objectClickbox);
|
renderPoly(graphics, color, objectClickbox);
|
||||||
break;
|
break;
|
||||||
@@ -185,7 +186,7 @@ public class NpcSceneOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderPoly(Graphics2D graphics, Color color, Polygon polygon)
|
private void renderPoly(Graphics2D graphics, Color color, Shape polygon)
|
||||||
{
|
{
|
||||||
if (polygon != null)
|
if (polygon != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ package net.runelite.client.plugins.objectindicators;
|
|||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Shape;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.DecorativeObject;
|
import net.runelite.api.DecorativeObject;
|
||||||
@@ -66,8 +66,8 @@ class ObjectIndicatorsOverlay extends Overlay
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Polygon polygon;
|
final Shape polygon;
|
||||||
Polygon polygon2 = null;
|
Shape polygon2 = null;
|
||||||
|
|
||||||
if (object instanceof GameObject)
|
if (object instanceof GameObject)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
|
import java.awt.Shape;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
@@ -65,11 +66,11 @@ public class RoguesDenOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
if (tile.getPlane() == client.getPlane() && obstacle.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE)
|
if (tile.getPlane() == client.getPlane() && obstacle.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE)
|
||||||
{
|
{
|
||||||
Polygon p = tile.getGameObjects()[0].getConvexHull();
|
Shape p = tile.getGameObjects()[0].getConvexHull();
|
||||||
if (p != null)
|
if (p != null)
|
||||||
{
|
{
|
||||||
graphics.setColor(Color.CYAN);
|
graphics.setColor(Color.CYAN);
|
||||||
graphics.drawPolygon(p);
|
graphics.draw(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -82,7 +83,7 @@ public class RoguesDenOverlay extends Overlay
|
|||||||
if (p != null)
|
if (p != null)
|
||||||
{
|
{
|
||||||
graphics.setColor(Color.CYAN);
|
graphics.setColor(Color.CYAN);
|
||||||
graphics.drawPolygon(p);
|
graphics.draw(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ package net.runelite.client.plugins.runecraft;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
import java.awt.geom.Area;
|
import java.awt.Shape;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
@@ -105,7 +105,7 @@ class AbyssOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
Point mousePosition = client.getMouseCanvasPosition();
|
Point mousePosition = client.getMouseCanvasPosition();
|
||||||
Area objectClickbox = object.getClickbox();
|
Shape objectClickbox = object.getClickbox();
|
||||||
if (objectClickbox != null)
|
if (objectClickbox != null)
|
||||||
{
|
{
|
||||||
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
|
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.awt.BasicStroke;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Shape;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
@@ -71,7 +71,7 @@ public class TargetClickboxOverlay extends Overlay
|
|||||||
|
|
||||||
private void renderTargetOverlay(Graphics2D graphics, NPC actor, Color color)
|
private void renderTargetOverlay(Graphics2D graphics, NPC actor, Color color)
|
||||||
{
|
{
|
||||||
Polygon objectClickbox = actor.getConvexHull();
|
Shape objectClickbox = actor.getConvexHull();
|
||||||
if (objectClickbox != null)
|
if (objectClickbox != null)
|
||||||
{
|
{
|
||||||
graphics.setColor(color);
|
graphics.setColor(color);
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ import java.awt.Dimension;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.Shape;
|
||||||
import java.awt.Stroke;
|
import java.awt.Stroke;
|
||||||
import java.awt.geom.Area;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import net.runelite.api.Actor;
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
@@ -50,14 +50,14 @@ public class OverlayUtil
|
|||||||
private static final int MINIMAP_DOT_RADIUS = 4;
|
private static final int MINIMAP_DOT_RADIUS = 4;
|
||||||
private static final double UNIT = Math.PI / 1024.0d;
|
private static final double UNIT = Math.PI / 1024.0d;
|
||||||
|
|
||||||
public static void renderPolygon(Graphics2D graphics, Polygon poly, Color color)
|
public static void renderPolygon(Graphics2D graphics, Shape poly, Color color)
|
||||||
{
|
{
|
||||||
graphics.setColor(color);
|
graphics.setColor(color);
|
||||||
final Stroke originalStroke = graphics.getStroke();
|
final Stroke originalStroke = graphics.getStroke();
|
||||||
graphics.setStroke(new BasicStroke(2));
|
graphics.setStroke(new BasicStroke(2));
|
||||||
graphics.drawPolygon(poly);
|
graphics.draw(poly);
|
||||||
graphics.setColor(new Color(0, 0, 0, 50));
|
graphics.setColor(new Color(0, 0, 0, 50));
|
||||||
graphics.fillPolygon(poly);
|
graphics.fill(poly);
|
||||||
graphics.setStroke(originalStroke);
|
graphics.setStroke(originalStroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ public class OverlayUtil
|
|||||||
renderImageLocation(client, graphics, localLocation, image, 0);
|
renderImageLocation(client, graphics, localLocation, image, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderHoverableArea(Graphics2D graphics, Area area, net.runelite.api.Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor)
|
public static void renderHoverableArea(Graphics2D graphics, Shape area, net.runelite.api.Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor)
|
||||||
{
|
{
|
||||||
if (area != null)
|
if (area != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user