ge plugin: cleanup

This commit is contained in:
Adam
2021-03-15 20:30:42 -04:00
parent 2725e0452f
commit 1b917895f0
3 changed files with 14 additions and 16 deletions

View File

@@ -252,7 +252,6 @@ public class GrandExchangeOfferSlot extends JPanel
} }
revalidate(); revalidate();
repaint();
} }
private String htmlTooltip(String value) private String htmlTooltip(String value)

View File

@@ -30,6 +30,8 @@ import java.awt.CardLayout;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.Arrays;
import javax.inject.Inject;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import net.runelite.api.GrandExchangeOffer; import net.runelite.api.GrandExchangeOffer;
@@ -56,7 +58,8 @@ class GrandExchangeOffersPanel extends JPanel
private final GrandExchangeOfferSlot[] offerSlotPanels = new GrandExchangeOfferSlot[MAX_OFFERS]; private final GrandExchangeOfferSlot[] offerSlotPanels = new GrandExchangeOfferSlot[MAX_OFFERS];
GrandExchangeOffersPanel() @Inject
private GrandExchangeOffersPanel()
{ {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR); setBackground(ColorScheme.DARK_GRAY_COLOR);
@@ -96,10 +99,7 @@ class GrandExchangeOffersPanel extends JPanel
void resetOffers() void resetOffers()
{ {
offerPanel.removeAll(); offerPanel.removeAll();
for (int i = 0; i < offerSlotPanels.length; i++) Arrays.fill(offerSlotPanels, null);
{
offerSlotPanels[i] = null;
}
updateEmptyOffersPanel(); updateEmptyOffersPanel();
} }
@@ -122,15 +122,16 @@ class GrandExchangeOffersPanel extends JPanel
} }
/* If slot was empty, and is now filled, add it to the list */ /* If slot was empty, and is now filled, add it to the list */
if (offerSlotPanels[slot] == null) GrandExchangeOfferSlot offerSlot = offerSlotPanels[slot];
if (offerSlot == null)
{ {
GrandExchangeOfferSlot newSlot = new GrandExchangeOfferSlot(); offerSlot = new GrandExchangeOfferSlot();
offerSlotPanels[slot] = newSlot; offerSlotPanels[slot] = offerSlot;
offerPanel.add(newSlot, constraints); offerPanel.add(offerSlot, constraints);
constraints.gridy++; constraints.gridy++;
} }
offerSlotPanels[slot].updateOffer(item, itemImage, newOffer); offerSlot.updateOffer(item, itemImage, newOffer);
removeTopMargin(); removeTopMargin();

View File

@@ -48,21 +48,19 @@ class GrandExchangePanel extends PluginPanel
@Getter @Getter
private final GrandExchangeSearchPanel searchPanel; private final GrandExchangeSearchPanel searchPanel;
@Getter @Getter
private GrandExchangeOffersPanel offersPanel; private final GrandExchangeOffersPanel offersPanel;
@Inject @Inject
private GrandExchangePanel(GrandExchangeSearchPanel searchPanel) private GrandExchangePanel(GrandExchangeSearchPanel searchPanel, GrandExchangeOffersPanel offersPanel)
{ {
super(false); super(false);
this.searchPanel = searchPanel; this.searchPanel = searchPanel;
this.offersPanel = offersPanel;
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR); setBackground(ColorScheme.DARK_GRAY_COLOR);
//Offers Panel
offersPanel = new GrandExchangeOffersPanel();
MaterialTab offersTab = new MaterialTab("Offers", tabGroup, offersPanel); MaterialTab offersTab = new MaterialTab("Offers", tabGroup, offersPanel);
searchTab = new MaterialTab("Search", tabGroup, searchPanel); searchTab = new MaterialTab("Search", tabGroup, searchPanel);