bank: Show Group Ironman storage value (#14395)
This commit is contained in:
@@ -264,32 +264,14 @@ public class BankPlugin extends Plugin
|
||||
{
|
||||
if (event.getScriptId() == ScriptID.BANKMAIN_BUILD)
|
||||
{
|
||||
// Compute bank prices using only the shown items so that we can show bank value during searches
|
||||
final Widget bankItemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
|
||||
final ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
|
||||
final Widget[] children = bankItemContainer.getChildren();
|
||||
long geTotal = 0, haTotal = 0;
|
||||
|
||||
if (bankContainer != null && children != null)
|
||||
ContainerPrices price = getWidgetContainerPrices(WidgetInfo.BANK_ITEM_CONTAINER, InventoryID.BANK);
|
||||
if (price == null)
|
||||
{
|
||||
log.debug("Computing bank price of {} items", bankContainer.size());
|
||||
|
||||
// The first components are the bank items, followed by tabs etc. There are always 816 components regardless
|
||||
// of bank size, but we only need to check up to the bank size.
|
||||
for (int i = 0; i < bankContainer.size(); ++i)
|
||||
{
|
||||
Widget child = children[i];
|
||||
if (child != null && !child.isSelfHidden() && child.getItemId() > -1)
|
||||
{
|
||||
final int alchPrice = getHaPrice(child.getItemId());
|
||||
geTotal += (long) itemManager.getItemPrice(child.getItemId()) * child.getItemQuantity();
|
||||
haTotal += (long) alchPrice * child.getItemQuantity();
|
||||
}
|
||||
}
|
||||
|
||||
Widget bankTitle = client.getWidget(WidgetInfo.BANK_TITLE_BAR);
|
||||
bankTitle.setText(bankTitle.getText() + createValueText(geTotal, haTotal));
|
||||
return;
|
||||
}
|
||||
|
||||
Widget bankTitle = client.getWidget(WidgetInfo.BANK_TITLE_BAR);
|
||||
bankTitle.setText(bankTitle.getText() + createValueText(price.getGePrice(), price.getHighAlchPrice()));
|
||||
}
|
||||
else if (event.getScriptId() == ScriptID.BANKMAIN_SEARCH_REFRESH)
|
||||
{
|
||||
@@ -302,6 +284,17 @@ public class BankPlugin extends Plugin
|
||||
searchString = inputText;
|
||||
}
|
||||
}
|
||||
else if (event.getScriptId() == ScriptID.GROUP_IRONMAN_STORAGE_BUILD)
|
||||
{
|
||||
ContainerPrices price = getWidgetContainerPrices(WidgetInfo.GROUP_STORAGE_ITEM_CONTAINER, InventoryID.GROUP_STORAGE);
|
||||
if (price == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Widget bankTitle = client.getWidget(WidgetInfo.GROUP_STORAGE_UI).getChild(1);
|
||||
bankTitle.setText(bankTitle.getText() + createValueText(price.getGePrice(), price.getHighAlchPrice()));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -537,4 +530,35 @@ public class BankPlugin extends Plugin
|
||||
return itemManager.getItemComposition(itemId).getHaPrice();
|
||||
}
|
||||
}
|
||||
|
||||
private ContainerPrices getWidgetContainerPrices(WidgetInfo widgetInfo, InventoryID inventoryID)
|
||||
{
|
||||
final Widget widget = client.getWidget(widgetInfo);
|
||||
final ItemContainer itemContainer = client.getItemContainer(inventoryID);
|
||||
final Widget[] children = widget.getChildren();
|
||||
ContainerPrices prices = null;
|
||||
|
||||
if (itemContainer != null && children != null)
|
||||
{
|
||||
long geTotal = 0, haTotal = 0;
|
||||
log.debug("Computing bank price of {} items", itemContainer.size());
|
||||
|
||||
// In the bank, the first components are the bank items, followed by tabs etc. There are always 816 components regardless
|
||||
// of bank size, but we only need to check up to the bank size.
|
||||
for (int i = 0; i < itemContainer.size(); ++i)
|
||||
{
|
||||
Widget child = children[i];
|
||||
if (child != null && !child.isSelfHidden() && child.getItemId() > -1)
|
||||
{
|
||||
final int alchPrice = getHaPrice(child.getItemId());
|
||||
geTotal += (long) itemManager.getItemPrice(child.getItemId()) * child.getItemQuantity();
|
||||
haTotal += (long) alchPrice * child.getItemQuantity();
|
||||
}
|
||||
}
|
||||
|
||||
prices = new ContainerPrices(geTotal, haTotal);
|
||||
}
|
||||
|
||||
return prices;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user