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)));
}
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);
}
});
}
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);
}
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;
}
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;
}
Aggregations