Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.unicus.api.methods;
- import com.unicus.api.wrapper.*;
- public enum Tab {
- COMBAT(48),
- STATS(49),
- QUESTS(50),
- INVENTORY(51),
- EQUIPMENT(52),
- PRAYER(53),
- MAGIC(54),
- CLAN_CHAT(31),
- FRIENDS_LIST(32),
- IGNORE_LIST(33),
- LOGOUT(34),
- OPTIONS(35),
- EMOTES(36),
- MUSIC(37);
- public static final int TABS_WIDGET_ID = 548;
- private static final int[] TAB_TEXTURES = new int[Tab.values().length];
- private final int widgetId;
- private RSWidget widget;
- private Tab(int widgetId) {
- this.widgetId = widgetId;
- }
- public int getWidgetId() {
- return widgetId;
- }
- public RSWidget getWidget() {
- if (widget != null) {
- return widget;
- }
- Object[][] widgets = RSClient.get().getWidgets();
- if (widgets == null || widgets[TABS_WIDGET_ID] == null) {
- return null;
- }
- Object reference = widgets[TABS_WIDGET_ID][getWidgetId()];
- return reference == null ? null : (widget = new RSWidget(reference));
- }
- public boolean isOpen() {
- return getOpenTab() == this;
- }
- public static Tab getOpenTab() {
- updateTextures();
- i: for (int i = 0; i < TAB_TEXTURES.length; i++) {
- int num = TAB_TEXTURES[i];
- // check for duplicated
- for (int j = 0; j < TAB_TEXTURES.length; j++) {
- if (j == i) continue;
- if (TAB_TEXTURES[j] == num)
- continue i;
- }
- return values()[i];
- }
- return INVENTORY;
- }
- private static void updateTextures() {
- Tab[] tabs = values();
- for (int i = 0; i < tabs.length; i++) {
- Tab tab = tabs[i];
- RSWidget widget = tab.getWidget();
- TAB_TEXTURES[i] = widget == null ? -1 : widget.getTextureId();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement