change config to show buttons, which lead to options rather than all options on one page (#88)
This commit is contained in:
@@ -30,13 +30,8 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.*;
|
||||||
import javax.swing.BoxLayout;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
import net.runelite.client.config.ConfigDescriptor;
|
import net.runelite.client.config.ConfigDescriptor;
|
||||||
import net.runelite.client.config.ConfigItemDescriptor;
|
import net.runelite.client.config.ConfigItemDescriptor;
|
||||||
@@ -53,6 +48,8 @@ public class ConfigPanel extends PluginPanel
|
|||||||
|
|
||||||
private final RuneLite runelite = RuneLite.getRunelite();
|
private final RuneLite runelite = RuneLite.getRunelite();
|
||||||
|
|
||||||
|
private JScrollPane scrollPane;
|
||||||
|
|
||||||
public ConfigPanel()
|
public ConfigPanel()
|
||||||
{
|
{
|
||||||
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||||
@@ -70,7 +67,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
|
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
add(createConfigPanel(), BorderLayout.CENTER);
|
add(createConfigPanel(), BorderLayout.NORTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<ConfigDescriptor> getConfig()
|
private Collection<ConfigDescriptor> getConfig()
|
||||||
@@ -90,6 +87,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
{
|
{
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||||
|
panel.add(new JLabel("Plugin configuration"), BorderLayout.NORTH);
|
||||||
|
|
||||||
ConfigManager configManager = runelite.getConfigManager();
|
ConfigManager configManager = runelite.getConfigManager();
|
||||||
Collection<ConfigDescriptor> config = getConfig();
|
Collection<ConfigDescriptor> config = getConfig();
|
||||||
@@ -97,11 +95,30 @@ public class ConfigPanel extends PluginPanel
|
|||||||
{
|
{
|
||||||
JPanel groupPanel = new JPanel();
|
JPanel groupPanel = new JPanel();
|
||||||
groupPanel.setLayout(new BorderLayout());
|
groupPanel.setLayout(new BorderLayout());
|
||||||
|
JButton viewGroupItemsButton = new JButton(cd.getGroup().name());
|
||||||
|
viewGroupItemsButton.addActionListener(ae -> openGroupConfigPanel(cd, configManager));
|
||||||
|
groupPanel.add(viewGroupItemsButton, BorderLayout.NORTH);
|
||||||
|
panel.add(groupPanel);
|
||||||
|
}
|
||||||
|
|
||||||
groupPanel.add(new JLabel(cd.getGroup().name()), BorderLayout.NORTH);
|
//Make the panel scrollable
|
||||||
|
scrollPane = new JScrollPane(panel);
|
||||||
|
scrollPane.setBorder(BorderFactory.createEmptyBorder());
|
||||||
|
scrollPane.getVerticalScrollBar().setUnitIncrement(16); //Otherwise scrollspeed is really slow
|
||||||
|
return scrollPane;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeConfiguration(ActionEvent ae, JCheckBox checkbox, ConfigDescriptor cd, ConfigItemDescriptor cid)
|
||||||
|
{
|
||||||
|
ConfigManager configManager = runelite.getConfigManager();
|
||||||
|
configManager.setConfiguration(cd.getGroup().keyName(), cid.getItem().keyName(), "" + checkbox.isSelected());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openGroupConfigPanel(ConfigDescriptor cd, ConfigManager configManager)
|
||||||
|
{
|
||||||
JPanel itemPanel = new JPanel();
|
JPanel itemPanel = new JPanel();
|
||||||
itemPanel.setLayout(new BoxLayout(itemPanel, BoxLayout.Y_AXIS));
|
itemPanel.setLayout(new BoxLayout(itemPanel, BoxLayout.Y_AXIS));
|
||||||
|
itemPanel.add(new JLabel(cd.getGroup().name() + " Configuration"), BorderLayout.NORTH);
|
||||||
|
|
||||||
for (ConfigItemDescriptor cid : cd.getItems())
|
for (ConfigItemDescriptor cid : cd.getItems())
|
||||||
{
|
{
|
||||||
@@ -121,22 +138,20 @@ public class ConfigPanel extends PluginPanel
|
|||||||
itemPanel.add(item);
|
itemPanel.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
groupPanel.add(itemPanel, BorderLayout.CENTER);
|
JButton backButton = new JButton("Back");
|
||||||
panel.add(groupPanel);
|
backButton.addActionListener(this::getBackButtonListener);
|
||||||
|
itemPanel.add(backButton, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
removeAll();
|
||||||
|
updateUI();
|
||||||
|
add(itemPanel, BorderLayout.NORTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Make the panel scrollable
|
public void getBackButtonListener(ActionEvent e)
|
||||||
JScrollPane scrollPane = new JScrollPane(panel);
|
|
||||||
scrollPane.setBorder(BorderFactory.createEmptyBorder());
|
|
||||||
scrollPane.getVerticalScrollBar().setUnitIncrement(16); //Otherwise scrollspeed is really slow
|
|
||||||
|
|
||||||
return scrollPane;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void changeConfiguration(ActionEvent ae, JCheckBox checkbox, ConfigDescriptor cd, ConfigItemDescriptor cid)
|
|
||||||
{
|
{
|
||||||
ConfigManager configManager = runelite.getConfigManager();
|
removeAll();
|
||||||
configManager.setConfiguration(cd.getGroup().keyName(), cid.getItem().keyName(), "" + checkbox.isSelected());
|
updateUI();
|
||||||
}
|
|
||||||
|
|
||||||
|
add(scrollPane, BorderLayout.NORTH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user