Search in sources :

Example 1 with Vector2

use of org.powerbot.script.Vector2 in project powerbot by powerbot.

the class Menu method hoverIndex.

private Point hoverIndex(final Client client, final int index) {
    int _index = 0, main = -1;
    Vector2 addum = new Vector2(0, 16 * index);
    collapsed: if (client.isMenuCollapsed()) {
        for (final MenuGroupNode g : NodeQueue.get(client.getCollapsedMenuItems(), MenuGroupNode.class)) {
            main++;
            final List<MenuItemNode> t = NodeQueue.get(g.getItems(), MenuItemNode.class);
            for (int i = 0; i < t.size(); i++) {
                if (_index++ == index) {
                    if (i == 0) {
                        addum = new Vector2(0, 16 * main);
                        break collapsed;
                    } else {
                        return hoverSub(client, main, i);
                    }
                }
            }
        }
        if (client.isMenuOpen()) {
            close();
        }
        return new Point(-1, -1);
    }
    final Vector2 p = new Vector2(client.getMenuX() + Random.nextInt(4, client.getMenuWidth() - 5), client.getMenuY() + 21 + Random.nextInt(2, 15)).add(addum);
    return ctx.input.move(p.toPoint()) && client.isMenuOpen() ? p.toPoint() : new Point(-1, -1);
}
Also used : MenuItemNode(org.powerbot.bot.rt6.client.MenuItemNode) Vector2(org.powerbot.script.Vector2) List(java.util.List) LinkedList(java.util.LinkedList) Point(java.awt.Point) MenuGroupNode(org.powerbot.bot.rt6.client.MenuGroupNode) Point(java.awt.Point)

Example 2 with Vector2

use of org.powerbot.script.Vector2 in project powerbot by powerbot.

the class Menu method hoverSub.

private Point hoverSub(final Client client, final int main, final int sub) {
    final Vector2 dv = new Vector2(client.getMenuX() + Random.nextInt(4, client.getMenuWidth() - 5), client.getMenuY() + (21 + 16 * main + Random.nextInt(2, 15)));
    if (ctx.input.move(dv.toPoint())) {
        Condition.sleep();
        if (client.isMenuOpen()) {
            final Point p = ctx.input.getLocation();
            final int cX;
            final int subX = client.getSubMenuX();
            if (ctx.input.move(cX = subX + Random.nextInt(4, client.getSubMenuWidth() - 5), p.y) && client.isMenuOpen()) {
                final int subY = client.getSubMenuY();
                final Point p2 = new Point(cX, subY + (16 * sub + Random.nextInt(2, 15) + 21));
                if (ctx.input.move(p2)) {
                    Condition.sleep();
                    return client.isMenuOpen() ? p2 : new Point(-1, -1);
                }
            }
        }
    }
    if (client.isMenuOpen()) {
        close();
    }
    return new Point(-1, -1);
}
Also used : Vector2(org.powerbot.script.Vector2) Point(java.awt.Point) Point(java.awt.Point)

Aggregations

Point (java.awt.Point)2 Vector2 (org.powerbot.script.Vector2)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1 MenuGroupNode (org.powerbot.bot.rt6.client.MenuGroupNode)1 MenuItemNode (org.powerbot.bot.rt6.client.MenuItemNode)1