Advertisement
Guest User

Untitled

a guest
May 27th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. package com.unicus.api.methods;
  2.  
  3. import com.unicus.api.wrapper.*;
  4.  
  5. public enum Tab {
  6. COMBAT(48),
  7. STATS(49),
  8. QUESTS(50),
  9. INVENTORY(51),
  10. EQUIPMENT(52),
  11. PRAYER(53),
  12. MAGIC(54),
  13. CLAN_CHAT(31),
  14. FRIENDS_LIST(32),
  15. IGNORE_LIST(33),
  16. LOGOUT(34),
  17. OPTIONS(35),
  18. EMOTES(36),
  19. MUSIC(37);
  20.  
  21. public static final int TABS_WIDGET_ID = 548;
  22. private static final int[] TAB_TEXTURES = new int[Tab.values().length];
  23.  
  24. private final int widgetId;
  25. private RSWidget widget;
  26.  
  27. private Tab(int widgetId) {
  28. this.widgetId = widgetId;
  29. }
  30.  
  31. public int getWidgetId() {
  32. return widgetId;
  33. }
  34.  
  35. public RSWidget getWidget() {
  36. if (widget != null) {
  37. return widget;
  38. }
  39. Object[][] widgets = RSClient.get().getWidgets();
  40. if (widgets == null || widgets[TABS_WIDGET_ID] == null) {
  41. return null;
  42. }
  43. Object reference = widgets[TABS_WIDGET_ID][getWidgetId()];
  44. return reference == null ? null : (widget = new RSWidget(reference));
  45. }
  46.  
  47. public boolean isOpen() {
  48. return getOpenTab() == this;
  49. }
  50.  
  51. public static Tab getOpenTab() {
  52. updateTextures();
  53. i: for (int i = 0; i < TAB_TEXTURES.length; i++) {
  54. int num = TAB_TEXTURES[i];
  55. // check for duplicated
  56. for (int j = 0; j < TAB_TEXTURES.length; j++) {
  57. if (j == i) continue;
  58. if (TAB_TEXTURES[j] == num)
  59. continue i;
  60. }
  61. return values()[i];
  62. }
  63. return INVENTORY;
  64. }
  65.  
  66. private static void updateTextures() {
  67. Tab[] tabs = values();
  68. for (int i = 0; i < tabs.length; i++) {
  69. Tab tab = tabs[i];
  70. RSWidget widget = tab.getWidget();
  71. TAB_TEXTURES[i] = widget == null ? -1 : widget.getTextureId();
  72. }
  73. }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement