ge plugin: use prices.runescape.wiki for ge link when using wiki prices

This commit is contained in:
Adam
2021-03-15 20:31:08 -04:00
parent 1b917895f0
commit 088cb19752
6 changed files with 30 additions and 14 deletions

View File

@@ -51,7 +51,7 @@ class GrandExchangeItemPanel extends JPanel
{
private static final Dimension ICON_SIZE = new Dimension(32, 32);
GrandExchangeItemPanel(AsyncBufferedImage icon, String name, int itemID,
GrandExchangeItemPanel(GrandExchangePlugin grandExchangePlugin, AsyncBufferedImage icon, String name, int itemID,
int gePrice, int haPrice, int geItemLimit)
{
BorderLayout layout = new BorderLayout();
@@ -89,7 +89,7 @@ class GrandExchangeItemPanel extends JPanel
@Override
public void mouseReleased(MouseEvent e)
{
GrandExchangePlugin.openGeLink(name, itemID);
grandExchangePlugin.openGeLink(name, itemID);
}
};

View File

@@ -66,6 +66,8 @@ public class GrandExchangeOfferSlot extends JPanel
private static final ImageIcon RIGHT_ARROW_ICON;
private static final ImageIcon LEFT_ARROW_ICON;
private final GrandExchangePlugin grandExchangePlugin;
private final JPanel container = new JPanel();
private final CardLayout cardLayout = new CardLayout();
@@ -91,8 +93,10 @@ public class GrandExchangeOfferSlot extends JPanel
* This (sub)panel is used for each GE slot displayed
* in the sidebar
*/
GrandExchangeOfferSlot()
GrandExchangeOfferSlot(GrandExchangePlugin grandExchangePlugin)
{
this.grandExchangePlugin = grandExchangePlugin;
setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR);
setBorder(new EmptyBorder(7, 0, 0, 0));
@@ -235,7 +239,7 @@ public class GrandExchangeOfferSlot extends JPanel
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()));
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

View File

@@ -47,6 +47,8 @@ class GrandExchangeOffersPanel extends JPanel
private static final int MAX_OFFERS = 8;
private final GrandExchangePlugin grandExchangePlugin;
private final GridBagConstraints constraints = new GridBagConstraints();
private final CardLayout cardLayout = new CardLayout();
@@ -59,8 +61,10 @@ class GrandExchangeOffersPanel extends JPanel
private final GrandExchangeOfferSlot[] offerSlotPanels = new GrandExchangeOfferSlot[MAX_OFFERS];
@Inject
private GrandExchangeOffersPanel()
private GrandExchangeOffersPanel(final GrandExchangePlugin grandExchangePlugin)
{
this.grandExchangePlugin = grandExchangePlugin;
setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR);
@@ -125,7 +129,7 @@ class GrandExchangeOffersPanel extends JPanel
GrandExchangeOfferSlot offerSlot = offerSlotPanels[slot];
if (offerSlot == null)
{
offerSlot = new GrandExchangeOfferSlot();
offerSlot = new GrandExchangeOfferSlot(grandExchangePlugin);
offerSlotPanels[slot] = offerSlot;
offerPanel.add(offerSlot, constraints);
constraints.gridy++;

View File

@@ -82,6 +82,7 @@ import net.runelite.client.Notifier;
import net.runelite.client.account.AccountSession;
import net.runelite.client.account.SessionManager;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.events.SessionClose;
@@ -178,6 +179,9 @@ public class GrandExchangePlugin extends Plugin
@Inject
private Gson gson;
@Inject
private RuneLiteConfig runeLiteConfig;
private Widget grandExchangeText;
private Widget grandExchangeItem;
private String grandExchangeExamine;
@@ -877,12 +881,14 @@ public class GrandExchangePlugin extends Plugin
geText.setText(text);
}
static void openGeLink(String name, int itemId)
void openGeLink(String name, int itemId)
{
final String url = "https://services.runescape.com/m=itemdb_oldschool/"
+ name.replaceAll(" ", "+")
+ "/viewitem?obj="
+ itemId;
final String url = runeLiteConfig.useWikiItemPrices() ?
"https://prices.runescape.wiki/osrs/item/" + itemId :
"https://services.runescape.com/m=itemdb_oldschool/"
+ name.replaceAll(" ", "+")
+ "/viewitem?obj="
+ itemId;
LinkBrowser.browse(url);
}

View File

@@ -67,6 +67,7 @@ class GrandExchangeSearchPanel extends JPanel
private final ItemManager itemManager;
private final ScheduledExecutorService executor;
private final RuneLiteConfig runeLiteConfig;
private final GrandExchangePlugin grandExchangePlugin;
private final IconTextField searchBar = new IconTextField();
@@ -83,12 +84,13 @@ class GrandExchangeSearchPanel extends JPanel
@Inject
private GrandExchangeSearchPanel(ClientThread clientThread, ItemManager itemManager,
ScheduledExecutorService executor, RuneLiteConfig runeLiteConfig)
ScheduledExecutorService executor, RuneLiteConfig runeLiteConfig, GrandExchangePlugin grandExchangePlugin)
{
this.clientThread = clientThread;
this.itemManager = itemManager;
this.executor = executor;
this.runeLiteConfig = runeLiteConfig;
this.grandExchangePlugin = grandExchangePlugin;
setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR);
@@ -232,7 +234,7 @@ class GrandExchangeSearchPanel extends JPanel
int index = 0;
for (GrandExchangeItems item : itemsList)
{
GrandExchangeItemPanel panel = new GrandExchangeItemPanel(item.getIcon(), item.getName(),
GrandExchangeItemPanel panel = new GrandExchangeItemPanel(grandExchangePlugin, item.getIcon(), item.getName(),
item.getItemId(), item.getGePrice(), item.getHaPrice(), item.getGeItemLimit());
/*

View File

@@ -47,7 +47,7 @@ public class GrandExchangeOfferSlotTest
{
when(offer.getState()).thenReturn(GrandExchangeOfferState.CANCELLED_BUY);
GrandExchangeOfferSlot offerSlot = new GrandExchangeOfferSlot();
GrandExchangeOfferSlot offerSlot = new GrandExchangeOfferSlot(mock(GrandExchangePlugin.class));
offerSlot.updateOffer(mock(ItemComposition.class), mock(AsyncBufferedImage.class), offer);
}