Search in sources :

Example 36 with Component

use of org.sbolstandard.core2.Component in project powerbot by powerbot.

the class WidgetCloser method poll.

@Override
public void poll() {
    if (ctx.widgets.component(Constants.INFO_BANWARNING >> 16, Constants.INFO_BANWARNING & 0xffff).visible()) {
        final Component c = ctx.widgets.component(Constants.INFO_BANWARNING >> 16, Constants.INFO_BANWARNING_CLOSE);
        GoogleAnalytics.getInstance().pageview("scripts/0/login/warning", c.valid() ? c.text() : "");
    }
    final List<Integer> w = new ArrayList<Integer>();
    if (!ctx.properties.getProperty("widget.closer.disable", "").equals("true")) {
        for (final int e : ctx.bank.opened() ? Constants.WIDGETCLOSER_ACTIVE : Constants.WIDGETCLOSER_ITEMS) {
            w.add(e);
        }
    }
    if (!ctx.bot().allowTrades()) {
        for (final int e : Constants.WIDGETCLOSER_TRADE_ITEMS) {
            w.add(e);
        }
    }
    for (final int id : w) {
        final AtomicInteger a = attempts.get(id);
        if (a.get() >= 3) {
            continue;
        }
        final Component c = ctx.widgets.component(id >> 16, id & 0xffff);
        final Point p = c.screenPoint();
        if (c.visible() && c.click()) {
            if (Condition.wait(new Condition.Check() {

                @Override
                public boolean poll() {
                    return !c.visible() || !c.screenPoint().equals(p);
                }
            })) {
                a.set(0);
            } else {
                a.incrementAndGet();
            }
        }
    }
    for (final int id : Constants.WIDGETCLOSER_FATAL) {
        if (ctx.widgets.component(id >> 16, id & 0xffff).visible()) {
            ctx.controller.stop();
            return;
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Condition(org.powerbot.script.Condition) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) Point(java.awt.Point) Component(org.powerbot.script.rt6.Component) Point(java.awt.Point)

Example 37 with Component

use of org.sbolstandard.core2.Component in project powerbot by powerbot.

the class WidgetCloser method poll.

@Override
public void poll() {
    final List<Integer> w = new ArrayList<Integer>();
    if (!ctx.bot().allowTrades()) {
        for (final int e : Constants.WIDGETCLOSER_TRADE_ITEMS) {
            w.add(e);
        }
    }
    for (final int id : w) {
        final AtomicInteger a = attempts.get(id);
        if (a.get() >= 3) {
            continue;
        }
        final Component c = ctx.widgets.component(id >> 16, id & 0xffff);
        final Point p = c.screenPoint();
        if (c.visible() && c.click()) {
            if (Condition.wait(new Condition.Check() {

                @Override
                public boolean poll() {
                    return !c.visible() || !c.screenPoint().equals(p);
                }
            })) {
                a.set(0);
            } else {
                a.incrementAndGet();
            }
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Condition(org.powerbot.script.Condition) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) Point(java.awt.Point) Component(org.powerbot.script.rt4.Component) Point(java.awt.Point)

Aggregations

URI (java.net.URI)25 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)22 HashSet (java.util.HashSet)7 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)7 ArrayList (java.util.ArrayList)6 QName (javax.xml.namespace.QName)6 Point (java.awt.Point)5 Component (org.powerbot.script.rt6.Component)5 SBOLDocument (org.sbolstandard.core2.SBOLDocument)5 Condition (org.powerbot.script.Condition)4 Literal (org.sbolstandard.core.datatree.Literal)4 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)4 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)4 Component (org.sbolstandard.core2.Component)4 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)3 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)3 Sequence (org.sbolstandard.core2.Sequence)3 SequenceAnnotation (org.sbolstandard.core2.SequenceAnnotation)3 Font (java.awt.Font)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2