bank: Show Group Ironman storage value (#14395)
This commit is contained in:
@@ -402,4 +402,7 @@ public final class ScriptID
|
|||||||
*/
|
*/
|
||||||
@ScriptArguments(integer = 4)
|
@ScriptArguments(integer = 4)
|
||||||
public static final int QUEST_FILTER = 3238;
|
public static final int QUEST_FILTER = 3238;
|
||||||
|
|
||||||
|
@ScriptArguments(integer = 18, string = 1)
|
||||||
|
public static final int GROUP_IRONMAN_STORAGE_BUILD = 5269;
|
||||||
}
|
}
|
||||||
@@ -297,6 +297,7 @@ public final class WidgetID
|
|||||||
|
|
||||||
static class GroupStorage
|
static class GroupStorage
|
||||||
{
|
{
|
||||||
|
static final int UI = 2;
|
||||||
static final int ITEM_CONTAINER = 10;
|
static final int ITEM_CONTAINER = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ public enum WidgetInfo
|
|||||||
BANK_SETTINGS_BUTTON(WidgetID.BANK_GROUP_ID, WidgetID.Bank.SETTINGS_BUTTON),
|
BANK_SETTINGS_BUTTON(WidgetID.BANK_GROUP_ID, WidgetID.Bank.SETTINGS_BUTTON),
|
||||||
BANK_TUTORIAL_BUTTON(WidgetID.BANK_GROUP_ID, WidgetID.Bank.TUTORIAL_BUTTON),
|
BANK_TUTORIAL_BUTTON(WidgetID.BANK_GROUP_ID, WidgetID.Bank.TUTORIAL_BUTTON),
|
||||||
|
|
||||||
|
GROUP_STORAGE_UI(WidgetID.GROUP_STORAGE_GROUP_ID, WidgetID.GroupStorage.UI),
|
||||||
GROUP_STORAGE_ITEM_CONTAINER(WidgetID.GROUP_STORAGE_GROUP_ID, WidgetID.GroupStorage.ITEM_CONTAINER),
|
GROUP_STORAGE_ITEM_CONTAINER(WidgetID.GROUP_STORAGE_GROUP_ID, WidgetID.GroupStorage.ITEM_CONTAINER),
|
||||||
|
|
||||||
GRAND_EXCHANGE_WINDOW_CONTAINER(WidgetID.GRAND_EXCHANGE_GROUP_ID, WidgetID.GrandExchange.WINDOW_CONTAINER),
|
GRAND_EXCHANGE_WINDOW_CONTAINER(WidgetID.GRAND_EXCHANGE_GROUP_ID, WidgetID.GrandExchange.WINDOW_CONTAINER),
|
||||||
|
|||||||
@@ -264,32 +264,14 @@ public class BankPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
if (event.getScriptId() == ScriptID.BANKMAIN_BUILD)
|
if (event.getScriptId() == ScriptID.BANKMAIN_BUILD)
|
||||||
{
|
{
|
||||||
// Compute bank prices using only the shown items so that we can show bank value during searches
|
ContainerPrices price = getWidgetContainerPrices(WidgetInfo.BANK_ITEM_CONTAINER, InventoryID.BANK);
|
||||||
final Widget bankItemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
|
if (price == null)
|
||||||
final ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
|
|
||||||
final Widget[] children = bankItemContainer.getChildren();
|
|
||||||
long geTotal = 0, haTotal = 0;
|
|
||||||
|
|
||||||
if (bankContainer != null && children != null)
|
|
||||||
{
|
{
|
||||||
log.debug("Computing bank price of {} items", bankContainer.size());
|
return;
|
||||||
|
|
||||||
// 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
else if (event.getScriptId() == ScriptID.BANKMAIN_SEARCH_REFRESH)
|
||||||
{
|
{
|
||||||
@@ -302,6 +284,17 @@ public class BankPlugin extends Plugin
|
|||||||
searchString = inputText;
|
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
|
@Subscribe
|
||||||
@@ -537,4 +530,35 @@ public class BankPlugin extends Plugin
|
|||||||
return itemManager.getItemComposition(itemId).getHaPrice();
|
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