@@ -63,4 +63,15 @@ public interface GrandExchangeConfig extends Config
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
keyName = "enableGeLimits",
|
||||
name = "Enable GE Limits on GE",
|
||||
description = "Shows the GE Limits on the GE"
|
||||
)
|
||||
default boolean enableGELimits()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,14 @@ import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.game.AsyncBufferedImage;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.util.LinkBrowser;
|
||||
import net.runelite.client.util.StackFormatter;
|
||||
|
||||
@@ -50,25 +53,26 @@ class GrandExchangeItemPanel extends JPanel
|
||||
private static final Dimension ICON_SIZE = new Dimension(32, 32);
|
||||
|
||||
GrandExchangeItemPanel(AsyncBufferedImage icon, String name, int itemID, int gePrice, Double
|
||||
haPrice)
|
||||
haPrice, int geItemLimit)
|
||||
{
|
||||
BorderLayout layout = new BorderLayout();
|
||||
layout.setHgap(5);
|
||||
setLayout(layout);
|
||||
setToolTipText(name);
|
||||
setBackground(ColorScheme.MEDIUM_GRAY_COLOR);
|
||||
|
||||
Color background = getBackground();
|
||||
|
||||
addMouseListener(new MouseAdapter()
|
||||
Color background = getBackground();
|
||||
List<JPanel> panels = new ArrayList();
|
||||
panels.add(this);
|
||||
|
||||
MouseAdapter itemPanelMouseListener = new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e)
|
||||
{
|
||||
setBackground(background.brighter());
|
||||
for (Component component : getComponents())
|
||||
for (JPanel panel : panels)
|
||||
{
|
||||
component.setBackground(component.getBackground().brighter());
|
||||
matchComponentBackground(panel, background.brighter());
|
||||
}
|
||||
setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
@@ -76,10 +80,9 @@ class GrandExchangeItemPanel extends JPanel
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e)
|
||||
{
|
||||
setBackground(background);
|
||||
for (Component component : getComponents())
|
||||
for (JPanel panel : panels)
|
||||
{
|
||||
component.setBackground(background);
|
||||
matchComponentBackground(panel, background);
|
||||
}
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
@@ -89,7 +92,9 @@ class GrandExchangeItemPanel extends JPanel
|
||||
{
|
||||
geLink(name, itemID);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
addMouseListener(itemPanelMouseListener);
|
||||
|
||||
setBorder(new EmptyBorder(5, 5, 5, 0));
|
||||
|
||||
@@ -104,7 +109,8 @@ class GrandExchangeItemPanel extends JPanel
|
||||
|
||||
// Item details panel
|
||||
JPanel rightPanel = new JPanel(new GridLayout(3, 1));
|
||||
rightPanel.setBackground(ColorScheme.MEDIUM_GRAY_COLOR);
|
||||
panels.add(rightPanel);
|
||||
rightPanel.setBackground(background);
|
||||
|
||||
// Item name
|
||||
JLabel itemName = new JLabel();
|
||||
@@ -127,15 +133,38 @@ class GrandExchangeItemPanel extends JPanel
|
||||
gePriceLabel.setForeground(ColorScheme.GRAND_EXCHANGE_PRICE);
|
||||
rightPanel.add(gePriceLabel);
|
||||
|
||||
JPanel alchAndLimitPanel = new JPanel(new BorderLayout());
|
||||
panels.add(alchAndLimitPanel);
|
||||
alchAndLimitPanel.setBackground(background);
|
||||
|
||||
// Alch price
|
||||
JLabel haPriceLabel = new JLabel();
|
||||
haPriceLabel.setText(StackFormatter.formatNumber(haPrice.intValue()) + " alch");
|
||||
haPriceLabel.setForeground(ColorScheme.GRAND_EXCHANGE_ALCH);
|
||||
rightPanel.add(haPriceLabel);
|
||||
alchAndLimitPanel.add(haPriceLabel, BorderLayout.WEST);
|
||||
|
||||
// GE Limit
|
||||
JLabel geLimitLabel = new JLabel();
|
||||
String limitLabelText = geItemLimit == 0 ? "" : "Limit " + StackFormatter.formatNumber(geItemLimit);
|
||||
geLimitLabel.setText(limitLabelText);
|
||||
geLimitLabel.setForeground(ColorScheme.GRAND_EXCHANGE_LIMIT);
|
||||
geLimitLabel.setBorder(new CompoundBorder(geLimitLabel.getBorder(), new EmptyBorder(0, 0, 0, 7)));
|
||||
alchAndLimitPanel.add(geLimitLabel, BorderLayout.EAST);
|
||||
|
||||
rightPanel.add(alchAndLimitPanel);
|
||||
|
||||
add(rightPanel, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
private void matchComponentBackground(JPanel panel, Color color)
|
||||
{
|
||||
panel.setBackground(color);
|
||||
for (Component c : panel.getComponents())
|
||||
{
|
||||
c.setBackground(color);
|
||||
}
|
||||
}
|
||||
|
||||
private void geLink(String name, int itemID)
|
||||
{
|
||||
final String url = "http://services.runescape.com/m=itemdb_oldschool/"
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.grandexchange;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Value;
|
||||
import net.runelite.client.game.AsyncBufferedImage;
|
||||
|
||||
@Data
|
||||
@Value
|
||||
public class GrandExchangeItems
|
||||
{
|
||||
private final AsyncBufferedImage icon;
|
||||
@@ -35,13 +35,5 @@ public class GrandExchangeItems
|
||||
private final int itemId;
|
||||
private final int gePrice;
|
||||
private final double haPrice;
|
||||
|
||||
GrandExchangeItems(AsyncBufferedImage icon, String name, int itemId, int gePrice, double haPrice)
|
||||
{
|
||||
this.icon = icon;
|
||||
this.name = name;
|
||||
this.itemId = itemId;
|
||||
this.gePrice = gePrice;
|
||||
this.haPrice = haPrice;
|
||||
}
|
||||
private final int geItemLimit;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
package net.runelite.client.plugins.grandexchange;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.JPanel;
|
||||
@@ -90,4 +91,9 @@ class GrandExchangePanel extends PluginPanel
|
||||
tabGroup.select(searchTab);
|
||||
revalidate();
|
||||
}
|
||||
|
||||
void setGELimits(Map<Integer, Integer> itemGELimits)
|
||||
{
|
||||
searchPanel.setItemGELimits(itemGELimits);
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,14 @@
|
||||
package net.runelite.client.plugins.grandexchange;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.SwingUtilities;
|
||||
@@ -84,6 +89,12 @@ public class GrandExchangePlugin extends Plugin
|
||||
private static final GrandExchangeClient CLIENT = new GrandExchangeClient();
|
||||
private static final String OSB_GE_TEXT = "<br>OSBuddy Actively traded price: ";
|
||||
|
||||
private static final String BUY_LIMIT_GE_TEXT = "<br>Buy limit: ";
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final TypeToken<Map<Integer, Integer>> BUY_LIMIT_TOKEN = new TypeToken<Map<Integer, Integer>>()
|
||||
{
|
||||
};
|
||||
|
||||
static final String SEARCH_GRAND_EXCHANGE = "Search Grand Exchange";
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@@ -125,6 +136,7 @@ public class GrandExchangePlugin extends Plugin
|
||||
|
||||
private Widget grandExchangeText;
|
||||
private Widget grandExchangeItem;
|
||||
private Map<Integer, Integer> itemGELimits;
|
||||
|
||||
@Provides
|
||||
GrandExchangeConfig provideConfig(ConfigManager configManager)
|
||||
@@ -135,7 +147,9 @@ public class GrandExchangePlugin extends Plugin
|
||||
@Override
|
||||
protected void startUp()
|
||||
{
|
||||
itemGELimits = loadGELimits();
|
||||
panel = injector.getInstance(GrandExchangePanel.class);
|
||||
panel.setGELimits(itemGELimits);
|
||||
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "ge_icon.png");
|
||||
|
||||
@@ -163,6 +177,7 @@ public class GrandExchangePlugin extends Plugin
|
||||
keyManager.unregisterKeyListener(inputListener);
|
||||
grandExchangeText = null;
|
||||
grandExchangeItem = null;
|
||||
itemGELimits = null;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -301,6 +316,18 @@ public class GrandExchangePlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.enableGELimits() && itemGELimits != null && !geTextString.contains(BUY_LIMIT_GE_TEXT))
|
||||
{
|
||||
final Integer itemLimit = itemGELimits.get(itemId);
|
||||
|
||||
// If we have item buy limit, append it
|
||||
if (itemLimit != null)
|
||||
{
|
||||
final String text = geText.getText() + BUY_LIMIT_GE_TEXT + StackFormatter.formatNumber(itemLimit);
|
||||
geText.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
if (!config.enableOsbPrices() || geTextString.contains(OSB_GE_TEXT))
|
||||
{
|
||||
// OSB prices are disabled or price was already looked up, so no need to set it again
|
||||
@@ -323,4 +350,12 @@ public class GrandExchangePlugin extends Plugin
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static Map<Integer, Integer> loadGELimits()
|
||||
{
|
||||
final InputStream geLimitData = GrandExchangePlugin.class.getResourceAsStream("ge_limits.json");
|
||||
final Map<Integer, Integer> itemGELimits = GSON.fromJson(new InputStreamReader(geLimitData), BUY_LIMIT_TOKEN.getType());
|
||||
log.debug("Loaded {} limits", itemGELimits.size());
|
||||
return itemGELimits;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,13 +32,16 @@ import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
@@ -92,6 +95,9 @@ class GrandExchangeSearchPanel extends JPanel
|
||||
|
||||
private List<GrandExchangeItems> itemsList = new ArrayList<>();
|
||||
|
||||
@Setter
|
||||
private Map<Integer, Integer> itemGELimits = Collections.emptyMap();
|
||||
|
||||
static
|
||||
{
|
||||
SEARCH_ICON = new ImageIcon(ImageUtil.alphaOffset(ImageUtil.grayscaleOffset(ImageUtil.getResourceStreamFromClass(IconTextField.class, "search.png"), 0f), 1.75f));
|
||||
@@ -222,9 +228,10 @@ class GrandExchangeSearchPanel extends JPanel
|
||||
}
|
||||
|
||||
int itemPrice = itemManager.getItemPrice(itemId);
|
||||
int itemLimit = itemGELimits.getOrDefault(itemId, 0);
|
||||
AsyncBufferedImage itemImage = itemManager.getImage(itemId);
|
||||
|
||||
itemsList.add(new GrandExchangeItems(itemImage, item.getName(), itemId, itemPrice, itemComp.getPrice() * 0.6));
|
||||
itemsList.add(new GrandExchangeItems(itemImage, item.getName(), itemId, itemPrice, itemComp.getPrice() * 0.6, itemLimit));
|
||||
|
||||
// If using hotkey to lookup item, stop after finding match.
|
||||
if (exactMatch && item.getName().equalsIgnoreCase(lookup))
|
||||
@@ -246,7 +253,7 @@ class GrandExchangeSearchPanel extends JPanel
|
||||
for (GrandExchangeItems item : itemsList)
|
||||
{
|
||||
GrandExchangeItemPanel panel = new GrandExchangeItemPanel(item.getIcon(), item.getName(),
|
||||
item.getItemId(), item.getGePrice(), item.getHaPrice());
|
||||
item.getItemId(), item.getGePrice(), item.getHaPrice(), item.getGeItemLimit());
|
||||
|
||||
/*
|
||||
Add the first item directly, wrap the rest with margin. This margin hack is because
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ColorScheme
|
||||
public static final Color MEDIUM_GRAY_COLOR = new Color(77, 77, 77);
|
||||
public static final Color LIGHT_GRAY_COLOR = new Color(165, 165, 165);
|
||||
|
||||
public static final Color DARKER_GRAY_HOVER_COLOR = new Color(60, 60 , 60);
|
||||
public static final Color DARKER_GRAY_HOVER_COLOR = new Color(60, 60, 60);
|
||||
public static final Color DARK_GRAY_HOVER_COLOR = new Color(35, 35, 35);
|
||||
|
||||
/* The color for the green progress bar (used in ge offers, farming tracker, etc)*/
|
||||
@@ -60,6 +60,10 @@ public class ColorScheme
|
||||
/* The color for the high alch indicator in the ge search results */
|
||||
public static final Color GRAND_EXCHANGE_ALCH = new Color(240, 207, 123);
|
||||
|
||||
/* The color for the limit indicator in the ge search results */
|
||||
public static final Color GRAND_EXCHANGE_LIMIT = new Color(50, 160, 250);
|
||||
|
||||
/* The background color of the scrollbar's track */
|
||||
public static final Color SCROLL_TRACK_COLOR = new Color(25, 25, 25);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user