Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2022-04-01 20:09:53 +02:00
7 changed files with 85 additions and 24 deletions

View File

@@ -446,4 +446,7 @@ public final class ScriptID
*/
@ScriptArguments(integer = 4)
public static final int QUEST_FILTER = 3238;
@ScriptArguments(integer = 18, string = 1)
public static final int GROUP_IRONMAN_STORAGE_BUILD = 5269;
}

View File

@@ -311,6 +311,7 @@ public final class WidgetID
static class GroupStorage
{
static final int UI = 2;
static final int ITEM_CONTAINER = 10;
}

View File

@@ -153,6 +153,7 @@ public enum WidgetInfo
BANK_SETTINGS_BUTTON(WidgetID.BANK_GROUP_ID, WidgetID.Bank.SETTINGS_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),
GRAND_EXCHANGE_WINDOW_CONTAINER(WidgetID.GRAND_EXCHANGE_GROUP_ID, WidgetID.GrandExchange.WINDOW_CONTAINER),

View File

@@ -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;
}
}

View File

@@ -155,6 +155,7 @@ class XpInfoBox extends JPanel
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent popupMenuEvent)
{
openXpTracker.setVisible(xpTrackerConfig.wiseOldManOpenOption());
canvasItem.setText(xpTrackerPlugin.hasOverlay(skill) ? REMOVE_STATE : ADD_STATE);
}

View File

@@ -39,6 +39,8 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import net.runelite.api.Skill;
@@ -112,6 +114,24 @@ class XpPanel extends PluginPanel
popupMenu.add(resetPerHour);
popupMenu.add(pauseAll);
popupMenu.add(unpauseAll);
popupMenu.addPopupMenuListener(new PopupMenuListener()
{
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent popupMenuEvent)
{
openXpTracker.setVisible(xpTrackerConfig.wiseOldManOpenOption());
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent popupMenuEvent)
{
}
@Override
public void popupMenuCanceled(PopupMenuEvent popupMenuEvent)
{
}
});
overallPanel.setComponentPopupMenu(popupMenu);
final JLabel overallIcon = new JLabel(new ImageIcon(iconManager.getSkillImage(Skill.OVERALL)));

View File

@@ -211,4 +211,15 @@ public interface XpTrackerConfig extends Config
{
return false;
}
@ConfigItem(
position = 15,
keyName = "wiseOldManOpenOption",
name = "Wise Old Man Option",
description = "Adds an option to the XP info box right-click menu to open Wise Old Man"
)
default boolean wiseOldManOpenOption()
{
return true;
}
}