ge plugin: add GE links to the offers panel
This allows looking up GE prices for items already on offer, without the need to manually search for the item on the Search tab. Accessed via a new popup menu.
This commit is contained in:
@@ -39,9 +39,8 @@ import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import net.runelite.client.util.AsyncBufferedImage;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.util.LinkBrowser;
|
||||
import net.runelite.client.util.AsyncBufferedImage;
|
||||
import net.runelite.client.util.QuantityFormatter;
|
||||
|
||||
/**
|
||||
@@ -90,7 +89,7 @@ class GrandExchangeItemPanel extends JPanel
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e)
|
||||
{
|
||||
geLink(name, itemID);
|
||||
GrandExchangePlugin.openGeLink(name, itemID);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -164,14 +163,4 @@ class GrandExchangeItemPanel extends JPanel
|
||||
c.setBackground(color);
|
||||
}
|
||||
}
|
||||
|
||||
private static void geLink(String name, int itemID)
|
||||
{
|
||||
final String url = "http://services.runescape.com/m=itemdb_oldschool/"
|
||||
+ name.replaceAll(" ", "_")
|
||||
+ "/viewitem?obj="
|
||||
+ itemID;
|
||||
|
||||
LinkBrowser.browse(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,10 @@ import java.awt.image.BufferedImage;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import net.runelite.api.GrandExchangeOffer;
|
||||
import net.runelite.api.GrandExchangeOfferState;
|
||||
@@ -98,21 +101,21 @@ public class GrandExchangeOfferSlot extends JPanel
|
||||
@Override
|
||||
public void mousePressed(MouseEvent mouseEvent)
|
||||
{
|
||||
super.mousePressed(mouseEvent);
|
||||
switchPanel();
|
||||
if (SwingUtilities.isLeftMouseButton(mouseEvent))
|
||||
{
|
||||
switchPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent mouseEvent)
|
||||
{
|
||||
super.mouseEntered(mouseEvent);
|
||||
container.setBackground(ColorScheme.DARKER_GRAY_HOVER_COLOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent mouseEvent)
|
||||
{
|
||||
super.mouseExited(mouseEvent);
|
||||
container.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
}
|
||||
};
|
||||
@@ -227,6 +230,13 @@ public class GrandExchangeOfferSlot extends JPanel
|
||||
progressBar.setMaximumValue(newOffer.getTotalQuantity());
|
||||
progressBar.setValue(newOffer.getQuantitySold());
|
||||
|
||||
final JPopupMenu popupMenu = new JPopupMenu();
|
||||
popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
|
||||
final JMenuItem openGeLink = new JMenuItem("Open Grand Exchange website");
|
||||
openGeLink.addActionListener(e -> GrandExchangePlugin.openGeLink(offerItem.getName(), offerItem.getId()));
|
||||
popupMenu.add(openGeLink);
|
||||
|
||||
/* Couldn't set the tooltip for the container panel as the children override it, so I'm setting
|
||||
* the tooltips on the children instead. */
|
||||
for (Component c : container.getComponents())
|
||||
@@ -235,6 +245,7 @@ public class GrandExchangeOfferSlot extends JPanel
|
||||
{
|
||||
JPanel panel = (JPanel) c;
|
||||
panel.setToolTipText(htmlTooltip(((int) progressBar.getPercentage()) + "%"));
|
||||
panel.setComponentPopupMenu(popupMenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.LinkBrowser;
|
||||
import net.runelite.client.util.OSType;
|
||||
import net.runelite.client.util.QuantityFormatter;
|
||||
import net.runelite.client.util.Text;
|
||||
@@ -932,4 +933,13 @@ public class GrandExchangePlugin extends Plugin
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void openGeLink(String name, int itemId)
|
||||
{
|
||||
final String url = "https://services.runescape.com/m=itemdb_oldschool/"
|
||||
+ name.replaceAll(" ", "+")
|
||||
+ "/viewitem?obj="
|
||||
+ itemId;
|
||||
LinkBrowser.browse(url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user