use of net.runelite.api.Point in project runelite by runelite.
the class GroundItemInputListener method mousePressed.
@Override
public MouseEvent mousePressed(MouseEvent e) {
if (plugin.isHotKeyPressed()) {
// Check if left click
if (e.getButton() == MouseEvent.BUTTON1) {
Point mousePos = client.getMouseCanvasPosition();
for (Map.Entry<Rectangle, String> entry : plugin.getHiddenBoxes().entrySet()) {
if (entry.getKey().contains(mousePos.getX(), mousePos.getY())) {
plugin.updateList(entry.getValue(), true);
e.consume();
return e;
}
}
for (Map.Entry<Rectangle, String> entry : plugin.getHighlightBoxes().entrySet()) {
if (entry.getKey().contains(mousePos.getX(), mousePos.getY())) {
plugin.updateList(entry.getValue(), false);
e.consume();
return e;
}
}
}
}
return e;
}
use of net.runelite.api.Point in project runelite by runelite.
the class RSPlayerMixin method getPolygons.
@Inject
@Override
public Polygon[] getPolygons() {
Model model = getModel();
if (model == null) {
return null;
}
int localX = getX();
int localY = getY();
int orientation = getOrientation();
List<Triangle> triangles = model.getTriangles();
triangles = rotate(triangles, orientation);
List<Polygon> polys = new ArrayList<Polygon>();
for (Triangle triangle : triangles) {
Vertex vx = triangle.getA();
Vertex vy = triangle.getB();
Vertex vz = triangle.getC();
Point x = Perspective.worldToCanvas(client, localX - vx.getX(), localY - vx.getZ(), -vx.getY());
Point y = Perspective.worldToCanvas(client, localX - vy.getX(), localY - vy.getZ(), -vy.getY());
Point z = Perspective.worldToCanvas(client, localX - vz.getX(), localY - vz.getZ(), -vz.getY());
int[] xx = { x.getX(), y.getX(), z.getX() };
int[] yy = { x.getY(), y.getY(), z.getY() };
polys.add(new Polygon(xx, yy, 3));
}
return polys.toArray(new Polygon[polys.size()]);
}
use of net.runelite.api.Point in project runelite by runelite.
the class RSModelMixin method getConvexHull.
@Override
@Inject
public Polygon getConvexHull(int localX, int localY, int orientation) {
List<Vertex> vertices = getVertices();
// rotate vertices
for (int i = 0; i < vertices.size(); ++i) {
Vertex v = vertices.get(i);
vertices.set(i, v.rotate(orientation));
}
List<Point> points = new ArrayList<Point>();
for (Vertex v : vertices) {
// Compute canvas location of vertex
Point p = Perspective.worldToCanvas(client, localX - v.getX(), localY - v.getZ(), -v.getY());
if (p != null) {
points.add(p);
}
}
// Run Jarvis march algorithm
points = Jarvis.convexHull(points);
if (points == null) {
return null;
}
// Convert to a polygon
Polygon p = new Polygon();
for (Point point : points) {
p.addPoint(point.getX(), point.getY());
}
return p;
}
use of net.runelite.api.Point in project runelite by runelite.
the class RunepouchOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
Query query = new InventoryWidgetItemQuery().idEquals(ItemID.RUNE_POUCH);
WidgetItem[] items = queryRunner.runQuery(query);
if (items.length == 0) {
return null;
}
WidgetItem runePouch = items[0];
Point location = runePouch.getCanvasLocation();
if (location == null) {
return null;
}
assert AMOUNT_VARBITS.length == RUNE_VARBITS.length;
graphics.setFont(FontManager.getRunescapeSmallFont());
StringBuilder tooltipBuilder = new StringBuilder();
for (int i = 0; i < AMOUNT_VARBITS.length; i++) {
Varbits amountVarbit = AMOUNT_VARBITS[i];
int amount = client.getSetting(amountVarbit);
if (amount <= 0) {
continue;
}
Varbits runeVarbit = RUNE_VARBITS[i];
int runeId = client.getSetting(runeVarbit);
Runes rune = Runes.getRune(runeId);
if (rune == null) {
continue;
}
tooltipBuilder.append(amount).append(" <col=ffff00>").append(rune.getName()).append("</col></br>");
if (config.showOnlyOnHover()) {
continue;
}
graphics.setColor(Color.black);
graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 13 : 6), location.getY() + 14 + (graphics.getFontMetrics().getHeight() - 1) * i);
graphics.setColor(config.fontColor());
graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 12 : 5), location.getY() + 13 + (graphics.getFontMetrics().getHeight() - 1) * i);
if (!config.showIcons()) {
continue;
}
BufferedImage image = getRuneImage(rune);
if (image != null) {
OverlayUtil.renderImageLocation(graphics, new Point(location.getX(), location.getY() + graphics.getFontMetrics().getHeight() * i), image);
}
}
String tooltip = tooltipBuilder.toString();
if (!tooltip.isEmpty() && runePouch.getCanvasBounds().contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY())) {
tooltipManager.add(new Tooltip(tooltip));
}
return null;
}
use of net.runelite.api.Point in project runelite by runelite.
the class RSWidgetMixin method getCanvasLocation.
@Inject
@Override
public Point getCanvasLocation() {
int x = 0;
int y = 0;
RSWidget cur;
for (cur = this; cur.getParent() != null; cur = (RSWidget) cur.getParent()) {
x += cur.getRelativeX();
y += cur.getRelativeY();
x -= cur.getScrollX();
y -= cur.getScrollY();
}
// cur is now the root
int[] widgetBoundsWidth = client.getWidgetPositionsX();
int[] widgetBoundsHeight = client.getWidgetPositionsY();
int boundsIndex = cur.getBoundsIndex();
if (boundsIndex != -1) {
x += widgetBoundsWidth[boundsIndex];
y += widgetBoundsHeight[boundsIndex];
if (cur.getType() > 0) {
x += cur.getRelativeX();
y += cur.getRelativeY();
}
} else {
x += cur.getRelativeX();
y += cur.getRelativeY();
}
return new Point(x, y);
}
Aggregations