Search in sources :

Example 1 with GroundItem

use of org.powerbot.script.rt6.GroundItem in project powerbot by powerbot.

the class DrawGroundItems method repaint.

public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    final Player player = ctx.players.local();
    if (player == null) {
        return;
    }
    final Tile tile = player.tile();
    if (tile == null) {
        return;
    }
    final FontMetrics metrics = render.getFontMetrics();
    final int tHeight = metrics.getHeight();
    final int plane = ctx.game.floor();
    final List<GroundItem> check = new ArrayList<GroundItem>();
    ctx.groundItems.select(10).addTo(check);
    for (int x = tile.x() - 10; x <= tile.x() + 10; x++) {
        n: for (int y = tile.y() - 10; y <= tile.y() + 10; y++) {
            int d = 0;
            final Tile loc = new Tile(x, y, plane);
            for (final GroundItem groundItem : ctx.groundItems.select(check).at(loc)) {
                final Point screen = new TileMatrix(ctx, loc).centerPoint();
                if (screen.x == -1 || screen.y == -1) {
                    continue n;
                }
                final String name = groundItem.name();
                String s = "";
                s += groundItem.id();
                if (!name.isEmpty()) {
                    s += " " + name;
                }
                final int stack = groundItem.stackSize();
                if (stack > 1) {
                    s += " (" + groundItem.stackSize() + ")";
                }
                final int ty = screen.y - tHeight * (++d) + tHeight / 2;
                final int tx = screen.x - metrics.stringWidth(s) / 2;
                render.setColor(Color.green);
                render.drawString(s, tx, ty);
            }
        }
    }
}
Also used : Player(org.powerbot.script.rt6.Player) FontMetrics(java.awt.FontMetrics) GroundItem(org.powerbot.script.rt6.GroundItem) ArrayList(java.util.ArrayList) Tile(org.powerbot.script.Tile) Point(java.awt.Point) Point(java.awt.Point) TileMatrix(org.powerbot.script.rt6.TileMatrix)

Example 2 with GroundItem

use of org.powerbot.script.rt6.GroundItem in project powerbot by powerbot.

the class DrawGroundItems method repaint.

public void repaint(final Graphics render) {
    if (ctx.game.clientState() != Constants.GAME_LOADED) {
        return;
    }
    final Player player = ctx.players.local();
    if (player == null) {
        return;
    }
    final Tile tile = player.tile();
    if (tile == null) {
        return;
    }
    final FontMetrics metrics = render.getFontMetrics();
    final int tHeight = metrics.getHeight();
    final List<GroundItem> check = new ArrayList<GroundItem>();
    ctx.groundItems.select(10).addTo(check);
    for (int x = -10; x <= 10; x++) {
        for (int y = -10; y <= 10; y++) {
            int d = 0;
            final Tile loc = tile.derive(x, y);
            final Point screen = new TileMatrix(ctx, loc).centerPoint();
            if (screen.x == -1) {
                continue;
            }
            for (final GroundItem groundItem : ctx.groundItems.select(check).at(loc)) {
                final String name = groundItem.name();
                String s = "";
                s += groundItem.id();
                if (!name.isEmpty()) {
                    s += " " + name;
                }
                final int stack = groundItem.stackSize();
                if (stack > 1) {
                    s += " (" + stack + ")";
                }
                final int ty = screen.y - tHeight * (++d) + tHeight / 2;
                final int tx = screen.x - metrics.stringWidth(s) / 2;
                render.setColor(Color.green);
                render.drawString(s, tx, ty);
            }
        }
    }
}
Also used : Player(org.powerbot.script.rt4.Player) FontMetrics(java.awt.FontMetrics) GroundItem(org.powerbot.script.rt4.GroundItem) ArrayList(java.util.ArrayList) Tile(org.powerbot.script.Tile) Point(java.awt.Point) Point(java.awt.Point) TileMatrix(org.powerbot.script.rt4.TileMatrix)

Aggregations

FontMetrics (java.awt.FontMetrics)2 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 Tile (org.powerbot.script.Tile)2 GroundItem (org.powerbot.script.rt4.GroundItem)1 Player (org.powerbot.script.rt4.Player)1 TileMatrix (org.powerbot.script.rt4.TileMatrix)1 GroundItem (org.powerbot.script.rt6.GroundItem)1 Player (org.powerbot.script.rt6.Player)1 TileMatrix (org.powerbot.script.rt6.TileMatrix)1