Examples of RSComponent


Examples of org.rsbot.script.wrappers.RSComponent

   *
   * @param index The index of inventory item.
   * @return The item, or <tt>null</tt> if not found.
   */
  public RSItem getItemAt(final int index) {
    final RSComponent comp = getInterface().getComponent(index);
    return 0 <= index && index < 28 && comp != null ? new RSItem(methods,
        comp) : null;
  }
View Full Code Here

Examples of org.rsbot.script.wrappers.RSComponent

   *               returning the items.
   * @return <tt>RSItem</tt> array of the current inventory items or an
   *         empty <tt>RSItem[]</tt> if unavailable.
   */
  public RSItem[] getItems(final boolean cached) {
    final RSComponent invIface = getInterface(cached);
    if (invIface != null) {
      final RSComponent[] comps = invIface.getComponents();
      if (comps.length > 0) {
        int len = 0;
        for (final RSComponent com : comps) {
          if (com.getType() == 5) {
            ++len;
          }
        }

        final RSItem[] inv = new RSItem[len];
        for (int i = 0; i < len; ++i) {
          final RSComponent item = comps[i];
          final int idx = item.getComponentIndex();
          if (idx >= 0) {
            inv[idx] = new RSItem(methods, item);
          } else {
            return new RSItem[0];
          }
View Full Code Here

Examples of org.rsbot.script.wrappers.RSComponent

   * @param cached <tt>true</tt> to skip updating the inventory interface.
   * @return the current inventory interface if available; otherwise null.
   */
  public RSComponent getInterface(final boolean cached) {
    if (methods.interfaces.get(INTERFACE_INVENTORY_BANK).isValid()) {
      final RSComponent bankInv = methods.interfaces.getComponent(
          INTERFACE_INVENTORY_BANK, 0);
      if (bankInv != null && bankInv.getAbsoluteX() > 50) {
        return bankInv;
      }
    }
    if (methods.interfaces.get(INTERFACE_INVENTORY_DEPOSIT_BOX).isValid()) {
      final RSComponent bankInv = methods.interfaces.getComponent(
          INTERFACE_INVENTORY_DEPOSIT_BOX, 17);
      if (bankInv != null && bankInv.getAbsoluteX() > 50) {
        return bankInv;
      }
    }
    if (methods.interfaces.get(INTERFACE_INVENTORY_SHOP).isValid()) {
      final RSComponent shopInv = methods.interfaces.getComponent(
          INTERFACE_INVENTORY_SHOP, 0);
      if (shopInv != null && shopInv.getAbsoluteX() > 50) {
        return shopInv;
      }
    }
    if (methods.interfaces.get(INTERFACE_INVENTORY_PRICE_CHECK).isValid()) {
      final RSComponent priceInv = methods.interfaces.getComponent(INTERFACE_INVENTORY_PRICE_CHECK, 0);
      if (priceInv != null && priceInv.getAbsoluteX() > 50) {
        return priceInv;
      }
    }
    if (methods.interfaces.get(INTERFACE_INVENTORY_EQUIPMENT_BONUSES).isValid()) {
      final RSComponent equipInv = methods.interfaces.getComponent(INTERFACE_INVENTORY_EQUIPMENT_BONUSES, 0);
      if (equipInv != null && equipInv.getAbsoluteX() > 50) {
        return equipInv;
      }
    }
    if (methods.interfaces.get(INTERFACE_INVENTORY_DUNGEONEERING_SHOP).isValid()) {
      final RSComponent dungInv = methods.interfaces.getComponent(INTERFACE_INVENTORY_DUNGEONEERING_SHOP, 0);
      if (dungInv != null && dungInv.getAbsoluteX() > 50) {
        return dungInv;
      }
    }

    if (!cached && methods.game.getTab() != Game.Tab.INVENTORY) {
View Full Code Here

Examples of org.rsbot.script.wrappers.RSComponent

      return false;
    }
    if (mode == ChatMode.VIEW) {
      return mouseChatButton(option, true);
    }
    final RSComponent chat = methods.interfaces.getComponent(CHAT_OPTION, option.textIdx());
    if (chat != null) {
      String setting = chat.getText();
      setting = setting.substring(setting.indexOf(">") + 1);
      if (setting.toUpperCase().equals(mode.toString())) {
        return false;
      }
    }
View Full Code Here

Examples of org.rsbot.script.wrappers.RSComponent

      if (methods.skills.getRealLevel(Skills.PRAYER) < pray.getRequiredLevel()) {
        return false;
      }
      methods.game.openTab(Game.Tab.PRAYER);
      if (methods.game.getTab() == Game.Tab.PRAYER) {
        RSComponent component = methods.interfaces.getComponent(INTERFACE_PRAYER, 8)
            .getComponent(pray.getComponentIndex());
        if (component.isValid()) {
          component.interact(active ? "Activate" : "Deactivate");
        }
      }
    }
    return isPrayerOn(pray) == active;
  }
View Full Code Here

Examples of org.rsbot.script.wrappers.RSComponent

  /**
   * @return <tt>true</tt> if continue component was clicked; otherwise
   *         <tt>false</tt>.
   */
  public boolean clickContinue() {
    final RSComponent cont = getContinueComponent();
    return cont != null && cont.isValid() && cont.doClick(true);
  }
View Full Code Here

Examples of org.rsbot.script.wrappers.RSComponent

   * @param component   component to scroll to
   * @param scrollBarID scrollbar to scroll with
   * @return true when scrolled successfully
   */
  public boolean scrollTo(final RSComponent component, final int scrollBarID) {
    final RSComponent scrollBar = getComponent(scrollBarID);

    return scrollTo(component, scrollBar);
  }
View Full Code Here

Examples of org.rsbot.script.wrappers.RSComponent

    if (scrollBar.getComponents().length != 6) {
      return true; // no scrollbar, so probably not scrollable
    }

    // Find scrollable area
    RSComponent scrollableArea = component;
    while (scrollableArea.getScrollableContentHeight() == 0
        && scrollableArea.getParentID() != -1) {
      scrollableArea = getComponent(scrollableArea.getParentID());
    }

    // Check scrollable area
    if (scrollableArea.getScrollableContentHeight() == 0) {
      return false;
    }

    // Get scrollable area height
    final int areaY = scrollableArea.getAbsoluteY();
    final int areaHeight = scrollableArea.getRealHeight();

    // Check if the component is already visible
    if (component.getAbsoluteY() >= areaY
        && component.getAbsoluteY() <= areaY + areaHeight
        - component.getRealHeight()) {
      return true;
    }

    // Calculate scroll bar position to click
    final RSComponent scrollBarArea = scrollBar.getComponent(0);
    final int contentHeight = scrollableArea.getScrollableContentHeight();

    int pos = (int) ((float) scrollBarArea.getRealHeight() / contentHeight * (component.getRelativeY() + random(-areaHeight / 2, areaHeight / 2 - component.getRealHeight())));
    if (pos < 0) // inner
    {
      pos = 0;
    } else if (pos >= scrollBarArea.getRealHeight()) {
      pos = scrollBarArea.getRealHeight() - 1; // outer
    }

    // Click on the scrollbar
    methods.mouse.click(scrollBarArea.getAbsoluteX() + random(0, scrollBarArea.getRealWidth()), scrollBarArea.getAbsoluteY() + pos, true);

    // Wait a bit
    sleep(random(200, 400));

    // Scroll to it if we missed it
View Full Code Here

Examples of org.rsbot.script.wrappers.RSComponent

        }
        return State.ERROR;
    }

    private RSComponent getRewardInterface(Reward r) {
        RSComponent mainBox = interfaces.getComponent(Values.INTERFACE_MAIN_BOX, Values.INTERFACE_BOX_SELECTION);
        if (mainBox == null) {
            return null;
        }
        RSComponent[] selection = mainBox.getComponents();
        for (int i = 0; i < selection.length; i++) {
            if (selection[i].getText().toLowerCase().contains(r.toString())) {
                return selection[i - 6];
            }
        }
View Full Code Here

Examples of org.rsbot.script.wrappers.RSComponent

                }
                /** scroll to reward interface */
                if (scrollTo(SELECTED_REWARD)) {
                    sleep(300, 700);
                }
                RSComponent REWARD_INTERFACE = getRewardInterface(SELECTED_REWARD),
                 CONFIRM = interfaces.getComponent(Values.INTERFACE_MAIN_BOX, Values.INTERFACE_BOX_CONFIRM_BUTTON);
                if (REWARD_INTERFACE == null || CONFIRM == null) {
                    return 10;
                }
                /** Click reward & Confirm */
                return REWARD_INTERFACE.doClick() && CONFIRM.doClick() ? random(500, 1500) : 10;
            case HANDLE_XP_REWARD:
                if (SELECTED_REWARD == null) {
                    return 100;
                }
                if (XP_POINT != null && XP_POINT.length > 0) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.