Skip to content

Commit

Permalink
Merge pull request runelite#10575 from raiyni/move-equipment-button
Browse files Browse the repository at this point in the history
Move bank equipment button into title bar
  • Loading branch information
deathbeam authored Apr 28, 2020
2 parents 5bfefcc + cac0828 commit 06d8a21
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ static class Bank
static final int BANK_CONTAINER = 1;
static final int INVENTORY_ITEM_CONTAINER = 3;
static final int BANK_TITLE_BAR = 3;
static final int ITEM_COUNT_TOP = 4;
static final int ITEM_COUNT_BAR = 5;
static final int ITEM_COUNT_BOTTOM = 6;
static final int CONTENT_CONTAINER = 8;
static final int TAB_CONTAINER = 9;
static final int ITEM_CONTAINER = 11;
Expand All @@ -260,6 +263,7 @@ static class Bank
static final int INCINERATOR = 44;
static final int INCINERATOR_CONFIRM = 45;
static final int EQUIPMENT_CONTENT_CONTAINER = 66;
static final int EQUIPMENT_BUTTON = 107;
}

static class GrandExchange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ public enum WidgetInfo
BANK_DEPOSIT_INVENTORY(WidgetID.BANK_GROUP_ID, WidgetID.Bank.DEPOSIT_INVENTORY),
BANK_TAB_CONTAINER(WidgetID.BANK_GROUP_ID, WidgetID.Bank.TAB_CONTAINER),
BANK_EQUIPMENT_CONTAINER(WidgetID.BANK_GROUP_ID, WidgetID.Bank.EQUIPMENT_CONTENT_CONTAINER),
BANK_EQUIPMENT_BUTTON(WidgetID.BANK_GROUP_ID, WidgetID.Bank.EQUIPMENT_BUTTON),
BANK_ITEM_COUNT_TOP(WidgetID.BANK_GROUP_ID, WidgetID.Bank.ITEM_COUNT_TOP),
BANK_ITEM_COUNT_BAR(WidgetID.BANK_GROUP_ID, WidgetID.Bank.ITEM_COUNT_BAR),
BANK_ITEM_COUNT_BOTTOM(WidgetID.BANK_GROUP_ID, WidgetID.Bank.ITEM_COUNT_BOTTOM),

GRAND_EXCHANGE_WINDOW_CONTAINER(WidgetID.GRAND_EXCHANGE_GROUP_ID, WidgetID.GrandExchange.WINDOW_CONTAINER),
GRAND_EXCHANGE_OFFER_CONTAINER(WidgetID.GRAND_EXCHANGE_GROUP_ID, WidgetID.GrandExchange.OFFER_CONTAINER),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import net.runelite.api.widgets.JavaScriptCallback;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetConfig;
import net.runelite.api.widgets.WidgetID;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.widgets.WidgetSizeMode;
import net.runelite.api.widgets.WidgetType;
Expand Down Expand Up @@ -235,6 +236,35 @@ public void init()
client.setVarbit(Varbits.CURRENT_BANK_TAB, 0);
openTag(config.tab());
}

Widget equipmentButton = client.getWidget(WidgetInfo.BANK_EQUIPMENT_BUTTON);
Widget titleBar = client.getWidget(WidgetInfo.BANK_TITLE_BAR);
if (equipmentButton == null || titleBar == null || titleBar.getOriginalX() > 0)
{
// don't keep moving widgets if they have already been moved
return;
}

equipmentButton.setOriginalX(6);
equipmentButton.setOriginalY(4);
equipmentButton.revalidate();

// the bank item count is 3 widgets
for (int child = WidgetInfo.BANK_ITEM_COUNT_TOP.getChildId(); child <= WidgetInfo.BANK_ITEM_COUNT_BOTTOM.getChildId(); child++)
{
Widget widget = client.getWidget(WidgetID.BANK_GROUP_ID, child);
if (widget == null)
{
return;
}

widget.setOriginalX(widget.getOriginalX() + equipmentButton.getWidth());
widget.revalidate();
}

titleBar.setOriginalX(equipmentButton.getWidth() / 2);
titleBar.setOriginalWidth(titleBar.getWidth() - equipmentButton.getWidth());
titleBar.revalidate();
}

private void handleDeposit(MenuOptionClicked event, Boolean inventory)
Expand Down Expand Up @@ -982,7 +1012,7 @@ private void scrollTab(int direction)
}

int proposedIndex = currentTabIndex + direction;
int numTabs = tabManager.size() + 1;
int numTabs = tabManager.size();

if (proposedIndex >= numTabs || proposedIndex < 0)
{
Expand Down Expand Up @@ -1076,7 +1106,7 @@ private void updateTabs()
{
int y = bounds.y + MARGIN + BUTTON_HEIGHT;

if (maxTabs > tabManager.size())
if (maxTabs >= tabManager.size())
{
currentTabIndex = 0;
}
Expand Down Expand Up @@ -1123,8 +1153,6 @@ private void updateTabs()
}
}

updateWidget(newTab, y);

boolean hidden = !(tabManager.size() > 0);

upButton.setHidden(hidden);
Expand Down

0 comments on commit 06d8a21

Please sign in to comment.