Farming plugin panel redesign
Farming Plugin: - Redid the layout, coloring and positioning on the FarmingTrackerPanel to include my new MaterialTabs. - Added section divider labels in the special and tree tabs. - Hid the patch type indicator for some patches (explained in docs). - Added patch names for all instances of FarmingPatch (previously only a portion of them were written for a hack that is no longer necessary). - Created getName() method in PatchImplementation that returns the patch type's name in a formatted style (SPIRIT_TREE -> Spirit Tree). - Created a new tab for bushes. MaterialTabs: - Added onSelectEvent runnable to MaterialTab. - Added horizontal gap to the tabs. - Added getTab() method that returns a tab on a given index. CustomScrollBarUI: - Added functionality to allow the ui colors to be changed from an external call. (setters) ColorScheme: - Created color constants in the ColorScheme file for the progresss bar backgrounds and used them in the CropState enum.
This commit is contained in:
committed by
Tomas Slusny
parent
497d421737
commit
6d331ae5a1
@@ -27,15 +27,16 @@ package net.runelite.client.plugins.farmingtracker;
|
||||
import java.awt.Color;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum CropState
|
||||
{
|
||||
HARVESTABLE(Color.GREEN),
|
||||
GROWING(Color.GREEN),
|
||||
DISEASED(Color.ORANGE),
|
||||
DEAD(Color.RED);
|
||||
HARVESTABLE(ColorScheme.PROGRESS_COMPLETE_COLOR),
|
||||
GROWING(ColorScheme.PROGRESS_COMPLETE_COLOR),
|
||||
DISEASED(ColorScheme.PROGRESS_INPROGRESS_COLOR),
|
||||
DEAD(ColorScheme.PROGRESS_ERROR_COLOR);
|
||||
|
||||
private final Color color;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Abex
|
||||
* Copyright (c) 2018, Psikoi <https://github.com/psikoi>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -24,13 +25,18 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.farmingtracker;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.GroupLayout;
|
||||
import java.awt.GridLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import lombok.Getter;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.components.ThinProgressBar;
|
||||
import net.runelite.client.ui.components.shadowlabel.JShadowedLabel;
|
||||
|
||||
@Getter
|
||||
class FarmingPatchPanel extends JPanel
|
||||
@@ -38,42 +44,69 @@ class FarmingPatchPanel extends JPanel
|
||||
private final FarmingPatch patch;
|
||||
private final JLabel icon = new JLabel();
|
||||
private final JLabel estimate = new JLabel();
|
||||
private final JProgressBar progress = new JProgressBar();
|
||||
private final ThinProgressBar progress = new ThinProgressBar();
|
||||
|
||||
FarmingPatchPanel(FarmingPatch patch)
|
||||
{
|
||||
this.patch = patch;
|
||||
|
||||
GroupLayout layout = new GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
setLayout(new BorderLayout());
|
||||
setOpaque(false);
|
||||
setBorder(new EmptyBorder(7, 0, 0, 0));
|
||||
|
||||
JPanel topContainer = new JPanel();
|
||||
topContainer.setBorder(new EmptyBorder(7, 7, 6, 0));
|
||||
topContainer.setLayout(new BorderLayout());
|
||||
topContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
|
||||
final JLabel location = new JLabel(patch.getRegion().getName() + " " + patch.getName());
|
||||
location.setFont(FontManager.getRunescapeSmallFont());
|
||||
icon.setMinimumSize(new Dimension(36, 32));
|
||||
|
||||
layout.setVerticalGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
|
||||
.addComponent(icon)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(location)
|
||||
.addGap(1)
|
||||
.addComponent(estimate)
|
||||
)
|
||||
)
|
||||
.addComponent(progress, 8, 8, 8)
|
||||
.addGap(4)
|
||||
);
|
||||
JPanel infoPanel = new JPanel();
|
||||
infoPanel.setOpaque(false);
|
||||
infoPanel.setLayout(new GridLayout(2, 1));
|
||||
infoPanel.setBorder(new EmptyBorder(4, 4, 4, 0));
|
||||
|
||||
layout.setHorizontalGroup(layout.createParallelGroup()
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(icon)
|
||||
.addGroup(layout.createParallelGroup()
|
||||
.addComponent(location)
|
||||
.addComponent(estimate)
|
||||
)
|
||||
)
|
||||
.addComponent(progress)
|
||||
);
|
||||
final JLabel location = new JShadowedLabel(patch.getRegion().getName()
|
||||
+ (showFullTitle() ? " (" + patch.getName() + ")" : ""));
|
||||
location.setFont(FontManager.getRunescapeSmallFont());
|
||||
location.setForeground(Color.WHITE);
|
||||
|
||||
estimate.setFont(FontManager.getRunescapeSmallFont());
|
||||
estimate.setForeground(Color.GRAY);
|
||||
|
||||
infoPanel.add(location);
|
||||
infoPanel.add(estimate);
|
||||
|
||||
topContainer.add(icon, BorderLayout.WEST);
|
||||
topContainer.add(infoPanel, BorderLayout.CENTER);
|
||||
|
||||
add(topContainer, BorderLayout.NORTH);
|
||||
add(progress, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* This determines if the label should display location and type, ex:
|
||||
* It makes sense to display:
|
||||
* Catherby (North) <-- for allotment
|
||||
* but not so much for herbs:
|
||||
* Troll Stronghold
|
||||
* as there are no other herb patches in that region.
|
||||
*/
|
||||
private boolean showFullTitle()
|
||||
{
|
||||
switch (patch.getImplementation())
|
||||
{
|
||||
case FLOWER:
|
||||
case HOPS:
|
||||
case BUSH:
|
||||
case FRUIT_TREE:
|
||||
case CALQUAT:
|
||||
case SPIRIT_TREE:
|
||||
case TREE:
|
||||
case HERB:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Abex
|
||||
* Copyright (c) 2018, Psikoi <https://github.com/psikoi>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -29,6 +30,7 @@ import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
@@ -37,9 +39,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
@@ -47,7 +50,11 @@ import net.runelite.api.vars.Autoweed;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.game.AsyncBufferedImage;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
import net.runelite.client.ui.components.materialtabs.MaterialTab;
|
||||
import net.runelite.client.ui.components.materialtabs.MaterialTabGroup;
|
||||
|
||||
@Slf4j
|
||||
class FarmingTrackerPanel extends PluginPanel
|
||||
@@ -61,6 +68,10 @@ class FarmingTrackerPanel extends PluginPanel
|
||||
|
||||
private List<FarmingPatchPanel> patchPanels = new ArrayList<>();
|
||||
|
||||
/* This is the panel the tabs' respective panels will be displayed on. */
|
||||
private final JPanel display = new JPanel();
|
||||
private final MaterialTabGroup tabGroup = new MaterialTabGroup(display);
|
||||
|
||||
FarmingTrackerPanel(
|
||||
Client client,
|
||||
ItemManager itemManager,
|
||||
@@ -77,11 +88,19 @@ class FarmingTrackerPanel extends PluginPanel
|
||||
this.config = config;
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||
|
||||
display.setOpaque(false);
|
||||
display.setBorder(new EmptyBorder(10, 10, 8, 10));
|
||||
|
||||
tabGroup.setBorder(new EmptyBorder(10, 1, 0, 0));
|
||||
|
||||
add(tabGroup, BorderLayout.NORTH);
|
||||
add(display, BorderLayout.CENTER);
|
||||
|
||||
JTabbedPane tabs = new JTabbedPane();
|
||||
farmingWorld.getTabs().forEach((tab, patches) ->
|
||||
{
|
||||
JPanel panel = new JPanel(new GridBagLayout())
|
||||
JPanel container = new JPanel(new GridBagLayout())
|
||||
{
|
||||
@Override
|
||||
public Dimension getPreferredSize()
|
||||
@@ -89,7 +108,7 @@ class FarmingTrackerPanel extends PluginPanel
|
||||
return new Dimension(PluginPanel.PANEL_WIDTH, super.getPreferredSize().height);
|
||||
}
|
||||
};
|
||||
panel.setBorder(new EmptyBorder(2, 6, 6, 6));
|
||||
container.setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
@@ -97,43 +116,77 @@ class FarmingTrackerPanel extends PluginPanel
|
||||
c.gridx = 0;
|
||||
c.gridy = 0;
|
||||
|
||||
PatchImplementation lastImpl = null;
|
||||
|
||||
boolean first = true;
|
||||
for (FarmingPatch patch : patches)
|
||||
{
|
||||
FarmingPatchPanel p = new FarmingPatchPanel(patch);
|
||||
|
||||
/* Show labels to subdivide tabs into sections */
|
||||
if ((tab == Tab.SPECIAL
|
||||
&& patch.getImplementation().ordinal() > 2
|
||||
&& patch.getImplementation() != lastImpl)
|
||||
|| (tab == Tab.TREE
|
||||
&& patch.getImplementation().ordinal() > 9
|
||||
&& patch.getImplementation() != lastImpl))
|
||||
{
|
||||
JLabel groupLabel = new JLabel(patch.getImplementation().getName());
|
||||
groupLabel.setBorder(new EmptyBorder(15, 0, 0, 0));
|
||||
groupLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
|
||||
container.add(groupLabel, c);
|
||||
c.gridy++;
|
||||
lastImpl = patch.getImplementation();
|
||||
}
|
||||
|
||||
patchPanels.add(p);
|
||||
panel.add(p, c);
|
||||
container.add(p, c);
|
||||
c.gridy++;
|
||||
|
||||
/* This is a weird hack to remove the top border on the first tracker of every tab */
|
||||
if (first)
|
||||
{
|
||||
p.setBorder(null);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
JPanel wrapped = new JPanel(new BorderLayout());
|
||||
wrapped.add(panel, BorderLayout.NORTH);
|
||||
wrapped.add(container, BorderLayout.NORTH);
|
||||
wrapped.setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||
|
||||
JScrollPane scroller = new JScrollPane(wrapped);
|
||||
scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scroller.getVerticalScrollBar().setUnitIncrement(16);
|
||||
scroller.getVerticalScrollBar().setPreferredSize(new Dimension(16, 0));
|
||||
scroller.getVerticalScrollBar().setBorder(new EmptyBorder(0, 9, 0, 0));
|
||||
scroller.setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||
|
||||
MaterialTab materialTab = new MaterialTab("", tabGroup, scroller);
|
||||
materialTab.setName(tab.getName());
|
||||
|
||||
AsyncBufferedImage icon = itemManager.getImage(tab.getItemID());
|
||||
tabs.addTab(null, null, scroller, tab.getName());
|
||||
int idx = tabs.getTabCount() - 1;
|
||||
Runnable resize = () ->
|
||||
{
|
||||
tabs.setIconAt(idx, new ImageIcon(icon.getScaledInstance(24, 21, Image.SCALE_SMOOTH)));
|
||||
BufferedImage subIcon = icon.getSubimage(0, 0, 32, 32);
|
||||
materialTab.setIcon(new ImageIcon(subIcon.getScaledInstance(24, 24, Image.SCALE_SMOOTH)));
|
||||
materialTab.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
materialTab.setVerticalAlignment(SwingConstants.CENTER);
|
||||
materialTab.setOpaque(true);
|
||||
materialTab.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
materialTab.setPreferredSize(new Dimension(30, 27));
|
||||
};
|
||||
icon.onChanged(resize);
|
||||
resize.run();
|
||||
|
||||
materialTab.setOnSelectEvent(() -> config.setPatch(tab));
|
||||
|
||||
tabGroup.addTab(materialTab);
|
||||
if (config.patch() == tab)
|
||||
{
|
||||
tabs.setSelectedComponent(scroller);
|
||||
tabGroup.select(materialTab);
|
||||
}
|
||||
tabs.addChangeListener(e ->
|
||||
{
|
||||
if (tabs.getSelectedComponent() == scroller)
|
||||
{
|
||||
config.setPatch(tab);
|
||||
}
|
||||
});
|
||||
});
|
||||
add(tabs, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
void update()
|
||||
@@ -178,10 +231,11 @@ class FarmingTrackerPanel extends PluginPanel
|
||||
PatchState state = unixTime <= 0 ? null : patch.getImplementation().forVarbitValue(value);
|
||||
if (state == null)
|
||||
{
|
||||
panel.getIcon().setIcon(null);
|
||||
itemManager.getImage(Produce.WEEDS.getItemID()).addTo(panel.getIcon());
|
||||
panel.getIcon().setToolTipText("Unknown state");
|
||||
panel.getProgress().setMaximum(0);
|
||||
panel.getProgress().setMaximumValue(0);
|
||||
panel.getProgress().setValue(0);
|
||||
panel.getProgress().setVisible(false);
|
||||
panel.getEstimate().setText("Unknown");
|
||||
panel.getProgress().setBackground(null);
|
||||
}
|
||||
@@ -298,9 +352,20 @@ class FarmingTrackerPanel extends PluginPanel
|
||||
}
|
||||
}
|
||||
|
||||
panel.getProgress().setBackground(state.getCropState().getColor().darker());
|
||||
panel.getProgress().setMaximum(stages - 1);
|
||||
panel.getProgress().setValue(stage);
|
||||
/* Hide any fully grown weeds' progress bar. */
|
||||
if (state.getProduce() != Produce.WEEDS
|
||||
|| (state.getProduce() == Produce.WEEDS && !autoweed && stage < stages - 1))
|
||||
{
|
||||
panel.getProgress().setVisible(true);
|
||||
panel.getProgress().setForeground(state.getCropState().getColor().darker());
|
||||
panel.getProgress().setMaximumValue(stages - 1);
|
||||
panel.getProgress().setValue(stage);
|
||||
panel.getProgress().update();
|
||||
}
|
||||
else
|
||||
{
|
||||
panel.getProgress().setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,11 +66,11 @@ public class FarmingWorld
|
||||
new FarmingPatch("North", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("South", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("Flower", Varbits.FARMING_4773, PatchImplementation.FLOWER),
|
||||
new FarmingPatch("", Varbits.FARMING_4774, PatchImplementation.HERB)
|
||||
new FarmingPatch("Herb", Varbits.FARMING_4774, PatchImplementation.HERB)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Brimhaven", 11058,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE),
|
||||
new FarmingPatch("Fruit Tree", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE),
|
||||
new FarmingPatch("Spirit Tree", Varbits.FARMING_4772, PatchImplementation.SPIRIT_TREE)
|
||||
));
|
||||
|
||||
@@ -78,10 +78,10 @@ public class FarmingWorld
|
||||
new FarmingPatch("North", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("South", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("Flower", Varbits.FARMING_4773, PatchImplementation.FLOWER),
|
||||
new FarmingPatch("", Varbits.FARMING_4774, PatchImplementation.HERB)
|
||||
new FarmingPatch("Herb", Varbits.FARMING_4774, PatchImplementation.HERB)
|
||||
));
|
||||
add(new FarmingRegion("Catherby", 11317,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE)
|
||||
new FarmingPatch("Fruit Tree", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Champion's Guild", 12596,
|
||||
@@ -89,7 +89,7 @@ public class FarmingWorld
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Draynor Manor", 12340,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.BELLADONNA)
|
||||
new FarmingPatch("Belladonna", Varbits.FARMING_4771, PatchImplementation.BELLADONNA)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Entrana", 11060,
|
||||
@@ -102,13 +102,13 @@ public class FarmingWorld
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Falador", 11828,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.TREE)
|
||||
new FarmingPatch("Tree", Varbits.FARMING_4771, PatchImplementation.TREE)
|
||||
));
|
||||
add(new FarmingRegion("Falador", 12083,
|
||||
new FarmingPatch("North West", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("South East", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("Flower", Varbits.FARMING_4773, PatchImplementation.FLOWER),
|
||||
new FarmingPatch("", Varbits.FARMING_4774, PatchImplementation.HERB)
|
||||
new FarmingPatch("Herb", Varbits.FARMING_4774, PatchImplementation.HERB)
|
||||
)
|
||||
{
|
||||
@Override
|
||||
@@ -129,20 +129,20 @@ public class FarmingWorld
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Gnome Stronghold", 9781,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.TREE),
|
||||
new FarmingPatch("", Varbits.FARMING_4772, PatchImplementation.FRUIT_TREE)
|
||||
new FarmingPatch("Tree", Varbits.FARMING_4771, PatchImplementation.TREE),
|
||||
new FarmingPatch("Fruit Tree", Varbits.FARMING_4772, PatchImplementation.FRUIT_TREE)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Harmony", 15148,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("", Varbits.FARMING_4772, PatchImplementation.HERB)
|
||||
new FarmingPatch("Allotment", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("Herb", Varbits.FARMING_4772, PatchImplementation.HERB)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Kourend", 7222,
|
||||
new FarmingPatch("North East", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("South West", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("Flower", Varbits.FARMING_4773, PatchImplementation.FLOWER),
|
||||
new FarmingPatch("", Varbits.FARMING_4774, PatchImplementation.HERB)
|
||||
new FarmingPatch("Herb", Varbits.FARMING_4774, PatchImplementation.HERB)
|
||||
));
|
||||
add(new FarmingRegion("Kourend", 6711,
|
||||
new FarmingPatch("Spirit Tree", Varbits.FARMING_4771, PatchImplementation.SPIRIT_TREE)
|
||||
@@ -163,14 +163,14 @@ public class FarmingWorld
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Lletya", 9265,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE)
|
||||
new FarmingPatch("Fruit Tree", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Lumbridge", 12851,
|
||||
new FarmingPatch("Hops", Varbits.FARMING_4771, PatchImplementation.HOPS)
|
||||
));
|
||||
add(new FarmingRegion("Lumbridge", 12594,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.TREE)
|
||||
new FarmingPatch("Tree", Varbits.FARMING_4771, PatchImplementation.TREE)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Morytania", 13622,
|
||||
@@ -180,7 +180,7 @@ public class FarmingWorld
|
||||
new FarmingPatch("North West", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("South East", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
|
||||
new FarmingPatch("Flower", Varbits.FARMING_4773, PatchImplementation.FLOWER),
|
||||
new FarmingPatch("", Varbits.FARMING_4774, PatchImplementation.HERB)
|
||||
new FarmingPatch("Herb", Varbits.FARMING_4774, PatchImplementation.HERB)
|
||||
));
|
||||
|
||||
|
||||
@@ -193,31 +193,31 @@ public class FarmingWorld
|
||||
), 11826);
|
||||
|
||||
add(new FarmingRegion("Seers' Village", 10551,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.HOPS)
|
||||
new FarmingPatch("Hops", Varbits.FARMING_4771, PatchImplementation.HOPS)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Tai Bwo Wannai", 11056,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.CALQUAT)
|
||||
new FarmingPatch("Calquat", Varbits.FARMING_4771, PatchImplementation.CALQUAT)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Taverly", 11573,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.TREE)
|
||||
new FarmingPatch("Tree", Varbits.FARMING_4771, PatchImplementation.TREE)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Tree Gnome Village", 9777,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE)
|
||||
new FarmingPatch("Fruit Tree", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Troll Stronghold", 11321,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.HERB)
|
||||
new FarmingPatch("Herb", Varbits.FARMING_4771, PatchImplementation.HERB)
|
||||
));
|
||||
|
||||
add(new FarmingRegion("Varrock", 12854,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.TREE)
|
||||
new FarmingPatch("Tree", Varbits.FARMING_4771, PatchImplementation.TREE)
|
||||
), 12853);
|
||||
|
||||
add(new FarmingRegion("Yanille", 10288,
|
||||
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.HOPS)
|
||||
new FarmingPatch("Hops", Varbits.FARMING_4771, PatchImplementation.HOPS)
|
||||
));
|
||||
|
||||
// Finalize
|
||||
|
||||
@@ -970,7 +970,7 @@ public enum PatchImplementation
|
||||
return null;
|
||||
}
|
||||
},
|
||||
BUSH(Tab.SPECIAL)
|
||||
BUSH(Tab.BUSH)
|
||||
{
|
||||
@Override
|
||||
PatchState forVarbitValue(int value)
|
||||
@@ -2271,7 +2271,7 @@ public enum PatchImplementation
|
||||
return null;
|
||||
}
|
||||
},
|
||||
GRAPES(Tab.SPECIAL)
|
||||
GRAPES(Tab.SPECIAL)
|
||||
{
|
||||
@Override
|
||||
PatchState forVarbitValue(int value)
|
||||
@@ -2299,5 +2299,16 @@ public enum PatchImplementation
|
||||
|
||||
abstract PatchState forVarbitValue(int value);
|
||||
|
||||
/**
|
||||
* Returns a formatted name based on the enum's name.
|
||||
* Ex:
|
||||
* SPIRIT_TREE into Spirit Tree
|
||||
* HERB into Herb
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return (name().substring(0, 1).toUpperCase() + name().toLowerCase().substring(1)).replaceAll("_", " ");
|
||||
}
|
||||
|
||||
private final Tab tab;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public enum Tab
|
||||
HERB("Herbs", ItemID.GRIMY_RANARR_WEED),
|
||||
TREE("Trees", ItemID.MAHOGANY_LOGS),
|
||||
FRUIT_TREE("Fruit Trees", ItemID.PINEAPPLE),
|
||||
BUSH("Bushes", ItemID.WHITE_BERRIES),
|
||||
SPECIAL("Special", ItemID.MUSHROOM);
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.client.ui.components;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
@@ -32,6 +33,7 @@ import javax.swing.JComponent;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicScrollBarUI;
|
||||
import lombok.Setter;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
|
||||
/**
|
||||
@@ -40,6 +42,15 @@ import net.runelite.client.ui.ColorScheme;
|
||||
*/
|
||||
public class CustomScrollBarUI extends BasicScrollBarUI
|
||||
{
|
||||
|
||||
/* The background color of the bar's thumb */
|
||||
@Setter
|
||||
private Color thumbColor = ColorScheme.MEDIUM_GRAY_COLOR;
|
||||
|
||||
/* The background color of the bar's track */
|
||||
@Setter
|
||||
private Color trackColor = ColorScheme.SCROLL_TRACK_COLOR;
|
||||
|
||||
/**
|
||||
* Overrides the painting of the bar's track (the darker part underneath that extends
|
||||
* the full page length).
|
||||
@@ -47,7 +58,7 @@ public class CustomScrollBarUI extends BasicScrollBarUI
|
||||
@Override
|
||||
protected void paintTrack(Graphics graphics, JComponent jComponent, Rectangle rectangle)
|
||||
{
|
||||
graphics.setColor(ColorScheme.SCROLL_TRACK_COLOR);
|
||||
graphics.setColor(trackColor);
|
||||
graphics.fillRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
|
||||
}
|
||||
|
||||
@@ -58,7 +69,7 @@ public class CustomScrollBarUI extends BasicScrollBarUI
|
||||
@Override
|
||||
protected void paintThumb(Graphics graphics, JComponent jComponent, Rectangle rectangle)
|
||||
{
|
||||
graphics.setColor(ColorScheme.MEDIUM_GRAY_COLOR);
|
||||
graphics.setColor(thumbColor);
|
||||
graphics.fillRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import javax.swing.JLabel;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
|
||||
/**
|
||||
@@ -59,6 +60,10 @@ public class MaterialTab extends JLabel
|
||||
@Getter
|
||||
private final JComponent content;
|
||||
|
||||
/* To be execuded when the tab is selected */
|
||||
@Setter
|
||||
private Runnable onSelectEvent;
|
||||
|
||||
@Getter
|
||||
private boolean selected;
|
||||
|
||||
@@ -93,6 +98,10 @@ public class MaterialTab extends JLabel
|
||||
setBorder(SELECTED_BORDER);
|
||||
setForeground(Color.WHITE);
|
||||
selected = true;
|
||||
if (onSelectEvent != null)
|
||||
{
|
||||
onSelectEvent.run();
|
||||
}
|
||||
}
|
||||
|
||||
public void unselect()
|
||||
|
||||
@@ -59,10 +59,22 @@ public class MaterialTabGroup extends JPanel
|
||||
{
|
||||
this.display = display;
|
||||
this.display.setLayout(new BorderLayout());
|
||||
setLayout(new FlowLayout());
|
||||
setLayout(new FlowLayout(FlowLayout.CENTER, 8, 0));
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
/* Returns the tab on a certain index. */
|
||||
public MaterialTab getTab(int index)
|
||||
{
|
||||
|
||||
if (tabs == null || tabs.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return tabs.get(index);
|
||||
}
|
||||
|
||||
public void addTab(MaterialTab tab)
|
||||
{
|
||||
tabs.add(tab);
|
||||
@@ -89,6 +101,7 @@ public class MaterialTabGroup extends JPanel
|
||||
{
|
||||
tab.select();
|
||||
display.add(tab.getContent());
|
||||
display.revalidate();
|
||||
display.repaint();
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user