Search in sources :

Example 36 with Client

use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.

the class Widgets method get.

/**
 * {@inheritDoc}
 */
@Override
protected List<Widget> get() {
    final Client client = ctx.client();
    final org.powerbot.bot.rt4.client.Widget[][] a = client != null ? client.getWidgets() : null;
    final int len = a != null ? a.length : 0;
    if (len <= 0) {
        return new ArrayList<Widget>(0);
    }
    widget(len - 1);
    return new ArrayList<Widget>(Arrays.asList(Arrays.copyOf(sparseCache, len)));
}
Also used : ArrayList(java.util.ArrayList) Client(org.powerbot.bot.rt4.client.Client)

Example 37 with Client

use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.

the class Chat method register.

public void register() {
    if (!registered.compareAndSet(false, true)) {
        return;
    }
    final EventDispatcher e = ((AbstractBot) ctx.bot()).dispatcher;
    e.add(new PaintListener() {

        private final AtomicReference<Entry> previous = new AtomicReference<Entry>(null);

        @Override
        public void repaint(final Graphics graphics) {
            final Client client = ctx.client();
            if (client == null) {
                return;
            }
            final EntryList q = client.getLoggerEntries();
            final Entry s = q.getSentinel();
            Entry c = s.getNext();
            final Entry f = c;
            while (!s.equals(c) && !c.isNull() && !c.equals(previous.get())) {
                final MessageEntry m = new MessageEntry(c.reflector, c);
                e.dispatch(new MessageEvent(m));
                c = c.getNext();
            }
            previous.set(f);
        }
    });
}
Also used : Graphics(java.awt.Graphics) Entry(org.powerbot.bot.rt4.client.Entry) MessageEntry(org.powerbot.bot.rt4.client.MessageEntry) EventDispatcher(org.powerbot.bot.EventDispatcher) PaintListener(org.powerbot.script.PaintListener) MessageEvent(org.powerbot.script.MessageEvent) MessageEntry(org.powerbot.bot.rt4.client.MessageEntry) AtomicReference(java.util.concurrent.atomic.AtomicReference) EntryList(org.powerbot.bot.rt4.client.EntryList) Client(org.powerbot.bot.rt4.client.Client) AbstractBot(org.powerbot.bot.AbstractBot)

Example 38 with Client

use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.

the class Component method screenPoint.

public Point screenPoint() {
    final Client client = ctx.client();
    final org.powerbot.bot.rt4.client.Widget widget = getInternal();
    if (client == null || widget == null) {
        return new Point(-1, -1);
    }
    final int uid = parentId();
    if (uid != -1) {
        final Component c = ctx.widgets.widget(uid >> 16).component(uid & 0xffff);
        final Point p = c.screenPoint();
        if (p.x != -1 && p.y != -1) {
            final boolean b = widget.getScrollHeight() == 0;
            return new Point(p.x + widget.getX() - (b ? c.scrollX() : 0), p.y + widget.getY() - (b ? c.scrollY() : 0));
        }
    }
    final int[] boundsX = client.getWidgetBoundsX(), boundsY = client.getWidgetBoundsY();
    final int bounds = boundsIndex();
    if (boundsX != null && boundsY != null && bounds >= 0 && bounds < boundsX.length && bounds < boundsY.length) {
        final int x = boundsX[bounds], y = boundsY[bounds];
        return new Point(x - widget.getScrollX(), y - widget.getScrollY());
    }
    return new Point(-1, -1);
}
Also used : Point(java.awt.Point) Client(org.powerbot.bot.rt4.client.Client) Point(java.awt.Point)

Example 39 with Client

use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.

the class Component method parentId.

public int parentId() {
    final Client client = ctx.client();
    final org.powerbot.bot.rt4.client.Widget w = getInternal();
    if (client == null || w == null) {
        return -1;
    }
    final int p = w.getParentId();
    if (p != -1) {
        return p;
    }
    final int uid = id() >>> 16;
    for (final WidgetNode node : new HashTable<WidgetNode>(client.getWidgetTable(), WidgetNode.class)) {
        if (uid == node.getUid()) {
            return (int) node.getId();
        }
    }
    return -1;
}
Also used : HashTable(org.powerbot.bot.rt4.HashTable) WidgetNode(org.powerbot.bot.rt4.client.WidgetNode) Client(org.powerbot.bot.rt4.client.Client) Point(java.awt.Point)

Example 40 with Client

use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.

the class Component method getInternal.

private org.powerbot.bot.rt4.client.Widget getInternal() {
    final int wi = widget.id();
    if (wi < 1 || index < 0) {
        return null;
    }
    if (component != null) {
        final org.powerbot.bot.rt4.client.Widget _i = component.getInternal();
        final org.powerbot.bot.rt4.client.Widget[] arr = _i != null ? _i.getChildren() : null;
        if (arr != null && index < arr.length) {
            return arr[index];
        }
        return null;
    }
    final Client client = ctx.client();
    final org.powerbot.bot.rt4.client.Widget[][] arr = client != null ? client.getWidgets() : null;
    if (arr != null && wi < arr.length) {
        final org.powerbot.bot.rt4.client.Widget[] comps = arr[wi];
        return comps != null && index < comps.length ? comps[index] : null;
    }
    return null;
}
Also used : Client(org.powerbot.bot.rt4.client.Client) Point(java.awt.Point)

Aggregations

Client (org.powerbot.bot.rt4.client.Client)36 Client (org.powerbot.bot.rt6.client.Client)33 Point (java.awt.Point)26 ArrayList (java.util.ArrayList)13 Client (org.orcid.jaxb.model.v3.dev1.client.Client)11 Test (org.junit.Test)8 Tile (org.powerbot.script.Tile)8 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)6 HashSet (java.util.HashSet)5 Rectangle (java.awt.Rectangle)4 Reflector (org.powerbot.bot.Reflector)4 Condition (org.powerbot.script.Condition)4 Client (client.Client)3 LinkedList (java.util.LinkedList)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 ClientRedirectUri (org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri)3 Graphics (java.awt.Graphics)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)2