コード例 #1
0
ファイル: MainTabsCache.java プロジェクト: 9Ox/PCaveHorrors
 public static WidgetChild getTab(final MainTabs tab) {
   final Record record = get();
   update(record);
   if (record.index_widget == -1) {
     return null;
   }
   final Widget widget = Widgets.get(record.index_widget);
   if (widget != null) {
     final int index = tab.getIndex();
     if (index < 0 || index > 16) {
       return null;
     }
     if (record.indices_tabs[index] == -1) {
       for (final WidgetChild widgetChild : widget.getChildren()) {
         final String[] actions = widgetChild.getActions();
         if (actions != null
             && actions.length > 0
             && actions[0].equalsIgnoreCase(tab.getDescription())) {
           record.indices_tabs[index] = widgetChild.getIndex();
           break;
         }
       }
     }
     if (record.indices_tabs[index] != -1) {
       return Widgets.get(record.index_widget, record.indices_tabs[index]);
     }
   }
   return null;
 }
コード例 #2
0
ファイル: Equipment.java プロジェクト: Greyn/RSBot-API
 /**
  * Gets all the equipped items.
  *
  * @return an array instance of <code>Item</code>
  */
 public static Item[] getItems() {
   final Widget widget = getWidget();
   if (widget != null) {
     final boolean isBank = widget.getIndex() != WIDGET;
     final WidgetChild[] equip =
         (isBank)
             ? widget.getChild(COMPONENT_EQUIP_INVENTORY).getChildren()
             : widget.getChildren();
     if (equip.length > 0) {
       if (!isBank) {
         final Item[] items = new Item[NUM_SLOTS];
         final Slot[] slots = Slot.values();
         for (int i = 0; i < NUM_SLOTS; i++) {
           items[i] = new Item(equip[slots[i].getComponentIndex()]);
         }
         return items;
       } else {
         final Item[] items = new Item[equip.length];
         for (int i = 0; i < items.length; i++) {
           items[i] = new Item(equip[i]);
         }
         return items;
       }
     }
   }
   return new Item[0];
 }
コード例 #3
0
ファイル: Equipment.java プロジェクト: Greyn/RSBot-API
 /**
  * Gets all the equipped items. If the tab is not currently open, it will not open it and will
  * return the last known array of items.
  *
  * @return an array instance of <code>Item</code>
  */
 public static Item[] getCachedItems() {
   final Widget widget = Widgets.get(WIDGET);
   if (widget != null) {
     final WidgetChild[] components = widget.getChildren();
     if (components.length > 0) {
       final Item[] items = new Item[NUM_SLOTS];
       final Slot[] slots = Slot.values();
       for (int i = 0; i < NUM_SLOTS; i++) {
         items[i] = new Item(components[slots[i].getComponentIndex()]);
       }
       return items;
     }
   }
   return new Item[0];
 }
コード例 #4
0
ファイル: MainTabsCache.java プロジェクト: 9Ox/PCaveHorrors
 public static WidgetChild getMap() {
   final Record record = get();
   update(record);
   if (record.index_widget == -1) {
     return null;
   }
   final Widget widget = Widgets.get(record.index_widget);
   if (widget != null) {
     if (record.index_map == -1) {
       for (final WidgetChild widgetChild : widget.getChildren()) {
         if (widgetChild.getSpecialType() == 1338) {
           record.index_map = widgetChild.getIndex();
           break;
         }
       }
     }
     if (record.index_map != -1) {
       return Widgets.get(record.index_widget, record.index_map);
     }
   }
   return null;
 }
コード例 #5
0
ファイル: MainTabsCache.java プロジェクト: 9Ox/PCaveHorrors
 public static WidgetChild getCompass() {
   final Record record = get();
   update(record);
   if (record.index_widget == -1) {
     return null;
   }
   final Widget widget = Widgets.get(record.index_widget);
   if (widget != null) {
     if (record.index_compass == -1) {
       for (final WidgetChild widgetChild : widget.getChildren()) {
         final String[] actions = widgetChild.getActions();
         if (actions != null && actions.length == 1 && actions[0].equalsIgnoreCase("Face North")) {
           record.index_compass = widgetChild.getIndex();
           break;
         }
       }
     }
     if (record.index_compass != -1) {
       return Widgets.get(record.index_widget, record.index_compass);
     }
   }
   return null;
 }