config: Refactor config panel into separate panels for each logical view
This commit is contained in:
@@ -36,12 +36,7 @@ import java.awt.event.ItemEvent;
|
|||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.ArrayList;
|
import javax.inject.Inject;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
@@ -61,66 +56,53 @@ import javax.swing.SpinnerNumberModel;
|
|||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
import javax.swing.event.DocumentEvent;
|
|
||||||
import javax.swing.event.DocumentListener;
|
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.client.config.ChatColorConfig;
|
|
||||||
import net.runelite.client.config.Config;
|
|
||||||
import net.runelite.client.config.ConfigDescriptor;
|
import net.runelite.client.config.ConfigDescriptor;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
import net.runelite.client.config.ConfigItemDescriptor;
|
import net.runelite.client.config.ConfigItemDescriptor;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.config.Keybind;
|
import net.runelite.client.config.Keybind;
|
||||||
import net.runelite.client.config.ModifierlessKeybind;
|
import net.runelite.client.config.ModifierlessKeybind;
|
||||||
import net.runelite.client.config.Range;
|
import net.runelite.client.config.Range;
|
||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.events.PluginChanged;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
|
||||||
import net.runelite.client.plugins.PluginInstantiationException;
|
|
||||||
import net.runelite.client.plugins.PluginManager;
|
import net.runelite.client.plugins.PluginManager;
|
||||||
import net.runelite.client.ui.ColorScheme;
|
import net.runelite.client.ui.ColorScheme;
|
||||||
import net.runelite.client.ui.DynamicGridLayout;
|
import net.runelite.client.ui.DynamicGridLayout;
|
||||||
import net.runelite.client.ui.PluginPanel;
|
import net.runelite.client.ui.PluginPanel;
|
||||||
import net.runelite.client.ui.components.ComboBoxListRenderer;
|
import net.runelite.client.ui.components.ComboBoxListRenderer;
|
||||||
import net.runelite.client.ui.components.IconButton;
|
|
||||||
import net.runelite.client.ui.components.IconTextField;
|
|
||||||
import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
|
import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
|
||||||
import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker;
|
import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
|
import net.runelite.client.util.SwingUtil;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ConfigPanel extends PluginPanel
|
class ConfigPanel extends PluginPanel
|
||||||
{
|
{
|
||||||
private static final int SPINNER_FIELD_WIDTH = 6;
|
private static final int SPINNER_FIELD_WIDTH = 6;
|
||||||
private static final int SCROLLBAR_WIDTH = 17;
|
|
||||||
private static final int OFFSET = 6;
|
|
||||||
private static final ImageIcon BACK_ICON;
|
private static final ImageIcon BACK_ICON;
|
||||||
private static final ImageIcon BACK_ICON_HOVER;
|
private static final ImageIcon BACK_ICON_HOVER;
|
||||||
|
|
||||||
private static final String RUNELITE_GROUP_NAME = RuneLiteConfig.class.getAnnotation(ConfigGroup.class).value();
|
private final FixedWidthPanel mainPanel;
|
||||||
private static final String PINNED_PLUGINS_CONFIG_KEY = "pinnedPlugins";
|
private final JLabel title;
|
||||||
private static final String RUNELITE_PLUGIN = "RuneLite";
|
private final PluginToggleButton pluginToggle;
|
||||||
private static final String CHAT_COLOR_PLUGIN = "Chat Color";
|
|
||||||
|
|
||||||
private final PluginManager pluginManager;
|
@Inject
|
||||||
private final ConfigManager configManager;
|
private PluginListPanel pluginList;
|
||||||
private final ScheduledExecutorService executorService;
|
|
||||||
private final RuneLiteConfig runeLiteConfig;
|
|
||||||
private final ChatColorConfig chatColorConfig;
|
|
||||||
private final ColorPickerManager colorPickerManager;
|
|
||||||
private final List<PluginListItem> pluginList = new ArrayList<>();
|
|
||||||
|
|
||||||
private final IconTextField searchBar = new IconTextField();
|
@Inject
|
||||||
private final JPanel topPanel;
|
private ConfigManager configManager;
|
||||||
private final JPanel mainPanel;
|
|
||||||
private final JScrollPane scrollPane;
|
|
||||||
|
|
||||||
private boolean showingPluginList = true;
|
@Inject
|
||||||
private int scrollBarPosition = 0;
|
private PluginManager pluginManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ColorPickerManager colorPickerManager;
|
||||||
|
|
||||||
|
private PluginConfigurationDescriptor pluginConfig = null;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
@@ -129,48 +111,16 @@ public class ConfigPanel extends PluginPanel
|
|||||||
BACK_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(backIcon, -100));
|
BACK_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(backIcon, -100));
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService,
|
public ConfigPanel()
|
||||||
RuneLiteConfig runeLiteConfig, ChatColorConfig chatColorConfig, ColorPickerManager colorPickerManager)
|
|
||||||
{
|
{
|
||||||
super(false);
|
super(false);
|
||||||
this.pluginManager = pluginManager;
|
|
||||||
this.configManager = configManager;
|
|
||||||
this.executorService = executorService;
|
|
||||||
this.runeLiteConfig = runeLiteConfig;
|
|
||||||
this.chatColorConfig = chatColorConfig;
|
|
||||||
this.colorPickerManager = colorPickerManager;
|
|
||||||
|
|
||||||
searchBar.setIcon(IconTextField.Icon.SEARCH);
|
|
||||||
searchBar.setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH - 20, 30));
|
|
||||||
searchBar.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
|
||||||
searchBar.setHoverBackgroundColor(ColorScheme.DARK_GRAY_HOVER_COLOR);
|
|
||||||
searchBar.getDocument().addDocumentListener(new DocumentListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void insertUpdate(DocumentEvent e)
|
|
||||||
{
|
|
||||||
onSearchBarChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeUpdate(DocumentEvent e)
|
|
||||||
{
|
|
||||||
onSearchBarChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changedUpdate(DocumentEvent e)
|
|
||||||
{
|
|
||||||
onSearchBarChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
|
|
||||||
topPanel = new JPanel();
|
JPanel topPanel = new JPanel();
|
||||||
topPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
|
topPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||||
topPanel.setLayout(new BorderLayout(0, OFFSET));
|
topPanel.setLayout(new BorderLayout(0, BORDER_OFFSET));
|
||||||
add(topPanel, BorderLayout.NORTH);
|
add(topPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
mainPanel = new FixedWidthPanel();
|
mainPanel = new FixedWidthPanel();
|
||||||
@@ -182,139 +132,66 @@ public class ConfigPanel extends PluginPanel
|
|||||||
northPanel.setLayout(new BorderLayout());
|
northPanel.setLayout(new BorderLayout());
|
||||||
northPanel.add(mainPanel, BorderLayout.NORTH);
|
northPanel.add(mainPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
scrollPane = new JScrollPane(northPanel);
|
JScrollPane scrollPane = new JScrollPane(northPanel);
|
||||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
add(scrollPane, BorderLayout.CENTER);
|
add(scrollPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
initializePluginList();
|
JButton topPanelBackButton = new JButton(BACK_ICON);
|
||||||
refreshPluginList();
|
topPanelBackButton.setRolloverIcon(BACK_ICON_HOVER);
|
||||||
}
|
SwingUtil.removeButtonDecorations(topPanelBackButton);
|
||||||
|
|
||||||
private void initializePluginList()
|
|
||||||
{
|
|
||||||
final List<String> pinnedPlugins = getPinnedPluginNames();
|
|
||||||
|
|
||||||
// populate pluginList with all non-hidden plugins
|
|
||||||
pluginManager.getPlugins().stream()
|
|
||||||
.filter(plugin -> !plugin.getClass().getAnnotation(PluginDescriptor.class).hidden())
|
|
||||||
.forEach(plugin ->
|
|
||||||
{
|
|
||||||
final PluginDescriptor descriptor = plugin.getClass().getAnnotation(PluginDescriptor.class);
|
|
||||||
final Config config = pluginManager.getPluginConfigProxy(plugin);
|
|
||||||
final ConfigDescriptor configDescriptor = config == null ? null : configManager.getConfigDescriptor(config);
|
|
||||||
|
|
||||||
final PluginListItem listItem = new PluginListItem(this, plugin, descriptor, config, configDescriptor);
|
|
||||||
listItem.setPinned(pinnedPlugins.contains(listItem.getName()));
|
|
||||||
pluginList.add(listItem);
|
|
||||||
});
|
|
||||||
|
|
||||||
// add special entries for core client configurations
|
|
||||||
final PluginListItem runeLite = new PluginListItem(this, runeLiteConfig,
|
|
||||||
configManager.getConfigDescriptor(runeLiteConfig),
|
|
||||||
RUNELITE_PLUGIN, "RuneLite client settings", "client");
|
|
||||||
runeLite.setPinned(pinnedPlugins.contains(RUNELITE_PLUGIN));
|
|
||||||
pluginList.add(runeLite);
|
|
||||||
|
|
||||||
final PluginListItem chatColor = new PluginListItem(this, chatColorConfig,
|
|
||||||
configManager.getConfigDescriptor(chatColorConfig),
|
|
||||||
CHAT_COLOR_PLUGIN, "Recolor chat text", "colour", "messages");
|
|
||||||
chatColor.setPinned(pinnedPlugins.contains(CHAT_COLOR_PLUGIN));
|
|
||||||
pluginList.add(chatColor);
|
|
||||||
|
|
||||||
pluginList.sort(Comparator.comparing(PluginListItem::getName));
|
|
||||||
}
|
|
||||||
|
|
||||||
void refreshPluginList()
|
|
||||||
{
|
|
||||||
// update enabled / disabled status of all items
|
|
||||||
pluginList.forEach(listItem ->
|
|
||||||
{
|
|
||||||
final Plugin plugin = listItem.getPlugin();
|
|
||||||
if (plugin != null)
|
|
||||||
{
|
|
||||||
listItem.setPluginEnabled(pluginManager.isPluginEnabled(plugin));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (showingPluginList)
|
|
||||||
{
|
|
||||||
openConfigList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void openConfigList()
|
|
||||||
{
|
|
||||||
if (showingPluginList)
|
|
||||||
{
|
|
||||||
scrollBarPosition = scrollPane.getVerticalScrollBar().getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
showingPluginList = true;
|
|
||||||
|
|
||||||
topPanel.removeAll();
|
|
||||||
mainPanel.removeAll();
|
|
||||||
topPanel.add(searchBar, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
onSearchBarChanged();
|
|
||||||
searchBar.requestFocusInWindow();
|
|
||||||
validate();
|
|
||||||
scrollPane.getVerticalScrollBar().setValue(scrollBarPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onSearchBarChanged()
|
|
||||||
{
|
|
||||||
final String text = searchBar.getText();
|
|
||||||
|
|
||||||
pluginList.forEach(mainPanel::remove);
|
|
||||||
|
|
||||||
showMatchingPlugins(true, text);
|
|
||||||
showMatchingPlugins(false, text);
|
|
||||||
|
|
||||||
revalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showMatchingPlugins(boolean pinned, String text)
|
|
||||||
{
|
|
||||||
if (text.isEmpty())
|
|
||||||
{
|
|
||||||
pluginList.stream().filter(item -> pinned == item.isPinned()).forEach(mainPanel::add);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String[] searchTerms = text.toLowerCase().split(" ");
|
|
||||||
pluginList.forEach(listItem ->
|
|
||||||
{
|
|
||||||
if (pinned == listItem.isPinned() && listItem.matchesSearchTerms(searchTerms))
|
|
||||||
{
|
|
||||||
mainPanel.add(listItem);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void openGroupConfigPanel(PluginListItem listItem, Config config, ConfigDescriptor cd)
|
|
||||||
{
|
|
||||||
showingPluginList = false;
|
|
||||||
|
|
||||||
scrollBarPosition = scrollPane.getVerticalScrollBar().getValue();
|
|
||||||
topPanel.removeAll();
|
|
||||||
mainPanel.removeAll();
|
|
||||||
|
|
||||||
final IconButton topPanelBackButton = new IconButton(BACK_ICON, BACK_ICON_HOVER);
|
|
||||||
topPanelBackButton.setPreferredSize(new Dimension(22, 0));
|
topPanelBackButton.setPreferredSize(new Dimension(22, 0));
|
||||||
topPanelBackButton.setBorder(new EmptyBorder(0, 0, 0, 5));
|
topPanelBackButton.setBorder(new EmptyBorder(0, 0, 0, 5));
|
||||||
topPanelBackButton.addActionListener(e -> openConfigList());
|
topPanelBackButton.addActionListener(e -> pluginList.getMuxer().popState());
|
||||||
topPanelBackButton.setToolTipText("Back");
|
topPanelBackButton.setToolTipText("Back");
|
||||||
topPanel.add(topPanelBackButton, BorderLayout.WEST);
|
topPanel.add(topPanelBackButton, BorderLayout.WEST);
|
||||||
|
|
||||||
topPanel.add(listItem.getConfigToggleButton(), BorderLayout.EAST);
|
pluginToggle = new PluginToggleButton();
|
||||||
|
topPanel.add(pluginToggle, BorderLayout.EAST);
|
||||||
String name = listItem.getName();
|
title = new JLabel();
|
||||||
JLabel title = new JLabel(name);
|
|
||||||
title.setForeground(Color.WHITE);
|
title.setForeground(Color.WHITE);
|
||||||
title.setToolTipText("<html>" + name + ":<br>" + listItem.getDescription() + "</html>");
|
|
||||||
PluginListItem.addLabelPopupMenu(title, PluginListItem.wikiLinkMenuItem(listItem.getName()));
|
|
||||||
topPanel.add(title);
|
|
||||||
|
|
||||||
|
topPanel.add(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init(PluginConfigurationDescriptor pluginConfig)
|
||||||
|
{
|
||||||
|
assert this.pluginConfig == null;
|
||||||
|
this.pluginConfig = pluginConfig;
|
||||||
|
|
||||||
|
String name = pluginConfig.getName();
|
||||||
|
title.setText(name);
|
||||||
|
title.setForeground(Color.WHITE);
|
||||||
|
title.setToolTipText("<html>" + name + ":<br>" + pluginConfig.getDescription() + "</html>");
|
||||||
|
PluginListItem.addLabelPopupMenu(title, pluginConfig.createSupportMenuItem());
|
||||||
|
|
||||||
|
if (pluginConfig.getPlugin() != null)
|
||||||
|
{
|
||||||
|
pluginToggle.setSelected(pluginManager.isPluginEnabled(pluginConfig.getPlugin()));
|
||||||
|
pluginToggle.addItemListener(i ->
|
||||||
|
{
|
||||||
|
if (pluginToggle.isSelected())
|
||||||
|
{
|
||||||
|
pluginList.startPlugin(pluginConfig.getPlugin());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pluginList.stopPlugin(pluginConfig.getPlugin());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pluginToggle.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
rebuild();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rebuild()
|
||||||
|
{
|
||||||
|
mainPanel.removeAll();
|
||||||
|
|
||||||
|
ConfigDescriptor cd = pluginConfig.getConfigDescriptor();
|
||||||
for (ConfigItemDescriptor cid : cd.getItems())
|
for (ConfigItemDescriptor cid : cd.getItems())
|
||||||
{
|
{
|
||||||
if (cid.getItem().hidden())
|
if (cid.getItem().hidden())
|
||||||
@@ -325,7 +202,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
JPanel item = new JPanel();
|
JPanel item = new JPanel();
|
||||||
item.setLayout(new BorderLayout());
|
item.setLayout(new BorderLayout());
|
||||||
item.setMinimumSize(new Dimension(PANEL_WIDTH, 0));
|
item.setMinimumSize(new Dimension(PANEL_WIDTH, 0));
|
||||||
name = cid.getItem().name();
|
String name = cid.getItem().name();
|
||||||
JLabel configEntryName = new JLabel(name);
|
JLabel configEntryName = new JLabel(name);
|
||||||
configEntryName.setForeground(Color.WHITE);
|
configEntryName.setForeground(Color.WHITE);
|
||||||
configEntryName.setToolTipText("<html>" + name + ":<br>" + cid.getItem().description() + "</html>");
|
configEntryName.setToolTipText("<html>" + name + ":<br>" + cid.getItem().description() + "</html>");
|
||||||
@@ -336,7 +213,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
JCheckBox checkbox = new JCheckBox();
|
JCheckBox checkbox = new JCheckBox();
|
||||||
checkbox.setBackground(ColorScheme.LIGHT_GRAY_COLOR);
|
checkbox.setBackground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||||
checkbox.setSelected(Boolean.parseBoolean(configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName())));
|
checkbox.setSelected(Boolean.parseBoolean(configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName())));
|
||||||
checkbox.addActionListener(ae -> changeConfiguration(listItem, config, checkbox, cd, cid));
|
checkbox.addActionListener(ae -> changeConfiguration(checkbox, cd, cid));
|
||||||
|
|
||||||
item.add(checkbox, BorderLayout.EAST);
|
item.add(checkbox, BorderLayout.EAST);
|
||||||
}
|
}
|
||||||
@@ -361,7 +238,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
Component editor = spinner.getEditor();
|
Component editor = spinner.getEditor();
|
||||||
JFormattedTextField spinnerTextField = ((JSpinner.DefaultEditor) editor).getTextField();
|
JFormattedTextField spinnerTextField = ((JSpinner.DefaultEditor) editor).getTextField();
|
||||||
spinnerTextField.setColumns(SPINNER_FIELD_WIDTH);
|
spinnerTextField.setColumns(SPINNER_FIELD_WIDTH);
|
||||||
spinner.addChangeListener(ce -> changeConfiguration(listItem, config, spinner, cd, cid));
|
spinner.addChangeListener(ce -> changeConfiguration(spinner, cd, cid));
|
||||||
|
|
||||||
item.add(spinner, BorderLayout.EAST);
|
item.add(spinner, BorderLayout.EAST);
|
||||||
}
|
}
|
||||||
@@ -390,7 +267,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
@Override
|
@Override
|
||||||
public void focusLost(FocusEvent e)
|
public void focusLost(FocusEvent e)
|
||||||
{
|
{
|
||||||
changeConfiguration(listItem, config, textField, cd, cid);
|
changeConfiguration(textField, cd, cid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -433,7 +310,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
colorPickerBtn.setBackground(c);
|
colorPickerBtn.setBackground(c);
|
||||||
colorPickerBtn.setText(ColorUtil.toHexColor(c).toUpperCase());
|
colorPickerBtn.setText(ColorUtil.toHexColor(c).toUpperCase());
|
||||||
});
|
});
|
||||||
colorPicker.setOnClose(c -> changeConfiguration(listItem, config, colorPicker, cd, cid));
|
colorPicker.setOnClose(c -> changeConfiguration(colorPicker, cd, cid));
|
||||||
colorPicker.setVisible(true);
|
colorPicker.setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -499,7 +376,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
{
|
{
|
||||||
if (e.getStateChange() == ItemEvent.SELECTED)
|
if (e.getStateChange() == ItemEvent.SELECTED)
|
||||||
{
|
{
|
||||||
changeConfiguration(listItem, config, box, cd, cid);
|
changeConfiguration(box, cd, cid);
|
||||||
box.setToolTipText(Text.titleCase((Enum) box.getSelectedItem()));
|
box.setToolTipText(Text.titleCase((Enum) box.getSelectedItem()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -519,7 +396,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
@Override
|
@Override
|
||||||
public void focusLost(FocusEvent e)
|
public void focusLost(FocusEvent e)
|
||||||
{
|
{
|
||||||
changeConfiguration(listItem, config, button, cd, cid);
|
changeConfiguration(button, cd, cid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -538,23 +415,21 @@ public class ConfigPanel extends PluginPanel
|
|||||||
|
|
||||||
if (result == JOptionPane.YES_OPTION)
|
if (result == JOptionPane.YES_OPTION)
|
||||||
{
|
{
|
||||||
configManager.setDefaultConfiguration(config, true);
|
configManager.setDefaultConfiguration(pluginConfig.getConfig(), true);
|
||||||
|
|
||||||
// Reload configuration panel
|
rebuild();
|
||||||
openGroupConfigPanel(listItem, config, cd);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mainPanel.add(resetButton);
|
mainPanel.add(resetButton);
|
||||||
|
|
||||||
JButton backButton = new JButton("Back");
|
JButton backButton = new JButton("Back");
|
||||||
backButton.addActionListener(e -> openConfigList());
|
backButton.addActionListener(e -> pluginList.getMuxer().popState());
|
||||||
mainPanel.add(backButton);
|
mainPanel.add(backButton);
|
||||||
|
|
||||||
revalidate();
|
revalidate();
|
||||||
scrollPane.getVerticalScrollBar().setValue(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeConfiguration(PluginListItem listItem, Config config, Component component, ConfigDescriptor cd, ConfigItemDescriptor cid)
|
private void changeConfiguration(Component component, ConfigDescriptor cd, ConfigItemDescriptor cid)
|
||||||
{
|
{
|
||||||
final ConfigItem configItem = cid.getItem();
|
final ConfigItem configItem = cid.getItem();
|
||||||
|
|
||||||
@@ -566,7 +441,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
|
|
||||||
if (result != JOptionPane.YES_OPTION)
|
if (result != JOptionPane.YES_OPTION)
|
||||||
{
|
{
|
||||||
openGroupConfigPanel(listItem, config, cd);
|
rebuild();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -603,102 +478,21 @@ public class ConfigPanel extends PluginPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startPlugin(Plugin plugin, PluginListItem listItem)
|
|
||||||
{
|
|
||||||
executorService.submit(() ->
|
|
||||||
{
|
|
||||||
pluginManager.setPluginEnabled(plugin, true);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pluginManager.startPlugin(plugin);
|
|
||||||
}
|
|
||||||
catch (PluginInstantiationException ex)
|
|
||||||
{
|
|
||||||
log.warn("Error when starting plugin {}", plugin.getClass().getSimpleName(), ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
listItem.setPluginEnabled(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void stopPlugin(Plugin plugin, PluginListItem listItem)
|
|
||||||
{
|
|
||||||
executorService.submit(() ->
|
|
||||||
{
|
|
||||||
pluginManager.setPluginEnabled(plugin, false);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pluginManager.stopPlugin(plugin);
|
|
||||||
}
|
|
||||||
catch (PluginInstantiationException ex)
|
|
||||||
{
|
|
||||||
log.warn("Error when stopping plugin {}", plugin.getClass().getSimpleName(), ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
listItem.setPluginEnabled(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> getPinnedPluginNames()
|
|
||||||
{
|
|
||||||
final String config = configManager.getConfiguration(RUNELITE_GROUP_NAME, PINNED_PLUGINS_CONFIG_KEY);
|
|
||||||
|
|
||||||
if (config == null)
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Text.fromCSV(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
void savePinnedPlugins()
|
|
||||||
{
|
|
||||||
final String value = pluginList.stream()
|
|
||||||
.filter(PluginListItem::isPinned)
|
|
||||||
.map(PluginListItem::getName)
|
|
||||||
.collect(Collectors.joining(","));
|
|
||||||
|
|
||||||
configManager.setConfiguration(RUNELITE_GROUP_NAME, PINNED_PLUGINS_CONFIG_KEY, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void openConfigurationPanel(String configGroup)
|
|
||||||
{
|
|
||||||
for (PluginListItem pluginListItem : pluginList)
|
|
||||||
{
|
|
||||||
if (pluginListItem.getName().equals(configGroup))
|
|
||||||
{
|
|
||||||
openGroupConfigPanel(pluginListItem, pluginListItem.getConfig(), pluginListItem.getConfigDescriptor());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivate()
|
|
||||||
{
|
|
||||||
super.onActivate();
|
|
||||||
|
|
||||||
if (searchBar.getParent() != null)
|
|
||||||
{
|
|
||||||
searchBar.requestFocusInWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize()
|
public Dimension getPreferredSize()
|
||||||
{
|
{
|
||||||
return new Dimension(PANEL_WIDTH + SCROLLBAR_WIDTH, super.getPreferredSize().height);
|
return new Dimension(PANEL_WIDTH + SCROLLBAR_WIDTH, super.getPreferredSize().height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FixedWidthPanel extends JPanel
|
@Subscribe
|
||||||
|
public void onPluginChanged(PluginChanged event)
|
||||||
{
|
{
|
||||||
@Override
|
if (event.getPlugin() == this.pluginConfig.getPlugin())
|
||||||
public Dimension getPreferredSize()
|
|
||||||
{
|
{
|
||||||
return new Dimension(PANEL_WIDTH, super.getPreferredSize().height);
|
SwingUtilities.invokeLater(() ->
|
||||||
|
{
|
||||||
|
pluginToggle.setSelected(event.isLoaded());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
package net.runelite.client.plugins.config;
|
package net.runelite.client.plugins.config;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Provider;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.client.config.ChatColorConfig;
|
import net.runelite.client.config.ChatColorConfig;
|
||||||
@@ -34,13 +34,10 @@ import net.runelite.client.config.ConfigManager;
|
|||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.OverlayMenuClicked;
|
import net.runelite.client.events.OverlayMenuClicked;
|
||||||
import net.runelite.client.events.PluginChanged;
|
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.PluginManager;
|
|
||||||
import net.runelite.client.ui.ClientToolbar;
|
import net.runelite.client.ui.ClientToolbar;
|
||||||
import net.runelite.client.ui.NavigationButton;
|
import net.runelite.client.ui.NavigationButton;
|
||||||
import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
|
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayMenuEntry;
|
import net.runelite.client.ui.overlay.OverlayMenuEntry;
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
@@ -55,31 +52,35 @@ public class ConfigPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private ClientToolbar clientToolbar;
|
private ClientToolbar clientToolbar;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Provider<PluginListPanel> pluginListPanelProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ConfigManager configManager;
|
private ConfigManager configManager;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PluginManager pluginManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ScheduledExecutorService executorService;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RuneLiteConfig runeLiteConfig;
|
private RuneLiteConfig runeLiteConfig;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ChatColorConfig chatColorConfig;
|
private ChatColorConfig chatColorConfig;
|
||||||
|
|
||||||
@Inject
|
private PluginListPanel pluginListPanel;
|
||||||
private ColorPickerManager colorPickerManager;
|
|
||||||
|
|
||||||
private ConfigPanel configPanel;
|
|
||||||
private NavigationButton navButton;
|
private NavigationButton navButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, chatColorConfig, colorPickerManager);
|
pluginListPanel = pluginListPanelProvider.get();
|
||||||
|
pluginListPanel.addFakePlugin(new PluginConfigurationDescriptor(
|
||||||
|
"RuneLite", "RuneLite client settings", new String[]{"client"},
|
||||||
|
null, runeLiteConfig, configManager.getConfigDescriptor(runeLiteConfig)
|
||||||
|
),
|
||||||
|
new PluginConfigurationDescriptor(
|
||||||
|
"Chat Color", "Recolor chat text", new String[]{"colour", "messages"},
|
||||||
|
null, chatColorConfig, configManager.getConfigDescriptor(chatColorConfig)
|
||||||
|
));
|
||||||
|
pluginListPanel.rebuildPluginList();
|
||||||
|
|
||||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "config_icon.png");
|
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "config_icon.png");
|
||||||
|
|
||||||
@@ -87,7 +88,7 @@ public class ConfigPlugin extends Plugin
|
|||||||
.tooltip("Configuration")
|
.tooltip("Configuration")
|
||||||
.icon(icon)
|
.icon(icon)
|
||||||
.priority(0)
|
.priority(0)
|
||||||
.panel(configPanel)
|
.panel(pluginListPanel.getMuxer())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
clientToolbar.addNavigation(navButton);
|
clientToolbar.addNavigation(navButton);
|
||||||
@@ -99,12 +100,6 @@ public class ConfigPlugin extends Plugin
|
|||||||
clientToolbar.removeNavigation(navButton);
|
clientToolbar.removeNavigation(navButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onPluginChanged(PluginChanged event)
|
|
||||||
{
|
|
||||||
SwingUtilities.invokeLater(configPanel::refreshPluginList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked)
|
public void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked)
|
||||||
{
|
{
|
||||||
@@ -126,7 +121,7 @@ public class ConfigPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
navButton.getOnSelect().run();
|
navButton.getOnSelect().run();
|
||||||
}
|
}
|
||||||
configPanel.openConfigurationPanel(descriptor.name());
|
pluginListPanel.openConfigurationPanel(descriptor.name());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.runelite.client.plugins.config;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import net.runelite.client.ui.PluginPanel;
|
||||||
|
|
||||||
|
class FixedWidthPanel extends JPanel
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Dimension getPreferredSize()
|
||||||
|
{
|
||||||
|
return new Dimension(PluginPanel.PANEL_WIDTH, super.getPreferredSize().height);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ import lombok.Getter;
|
|||||||
import net.runelite.client.config.Keybind;
|
import net.runelite.client.config.Keybind;
|
||||||
import net.runelite.client.config.ModifierlessKeybind;
|
import net.runelite.client.config.ModifierlessKeybind;
|
||||||
|
|
||||||
public class HotkeyButton extends JButton
|
class HotkeyButton extends JButton
|
||||||
{
|
{
|
||||||
@Getter
|
@Getter
|
||||||
private Keybind value;
|
private Keybind value;
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Abex
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.runelite.client.plugins.config;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import lombok.Value;
|
||||||
|
import net.runelite.client.config.Config;
|
||||||
|
import net.runelite.client.config.ConfigDescriptor;
|
||||||
|
import net.runelite.client.plugins.Plugin;
|
||||||
|
import net.runelite.client.util.LinkBrowser;
|
||||||
|
|
||||||
|
@Value
|
||||||
|
class PluginConfigurationDescriptor
|
||||||
|
{
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
private final String[] tags;
|
||||||
|
|
||||||
|
// Can be null if its not an actual plugin (RuneLite / ChatColors)
|
||||||
|
@Nullable
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
// Can be null if it has no more configuration than the on/off toggle
|
||||||
|
@Nullable
|
||||||
|
private final Config config;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private final ConfigDescriptor configDescriptor;
|
||||||
|
|
||||||
|
boolean hasConfigurables()
|
||||||
|
{
|
||||||
|
return configDescriptor != null && !configDescriptor.getItems().stream().allMatch(item -> item.getItem().hidden());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a menu item for linking to a support page for the plugin
|
||||||
|
*
|
||||||
|
* @return A {@link JMenuItem} which opens the plugin's wiki page URL in the browser when clicked
|
||||||
|
*/
|
||||||
|
JMenuItem createSupportMenuItem()
|
||||||
|
{
|
||||||
|
final JMenuItem menuItem = new JMenuItem("Wiki");
|
||||||
|
menuItem.addActionListener(e -> LinkBrowser.browse("https://github.com/runelite/runelite/wiki/" + name.replace(' ', '-')));
|
||||||
|
return menuItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,91 +38,49 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.runelite.client.config.Config;
|
|
||||||
import net.runelite.client.config.ConfigDescriptor;
|
|
||||||
import net.runelite.client.plugins.Plugin;
|
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
|
||||||
import net.runelite.client.ui.ColorScheme;
|
import net.runelite.client.ui.ColorScheme;
|
||||||
import net.runelite.client.ui.PluginPanel;
|
import net.runelite.client.ui.PluginPanel;
|
||||||
import net.runelite.client.ui.components.IconButton;
|
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.client.util.LinkBrowser;
|
import net.runelite.client.util.SwingUtil;
|
||||||
import org.apache.commons.text.similarity.JaroWinklerDistance;
|
import org.apache.commons.text.similarity.JaroWinklerDistance;
|
||||||
|
|
||||||
class PluginListItem extends JPanel
|
class PluginListItem extends JPanel
|
||||||
{
|
{
|
||||||
private static final JaroWinklerDistance DISTANCE = new JaroWinklerDistance();
|
private static final JaroWinklerDistance DISTANCE = new JaroWinklerDistance();
|
||||||
private static final String RUNELITE_WIKI_FORMAT = "https://github.com/runelite/runelite/wiki/%s";
|
|
||||||
|
|
||||||
private static final ImageIcon CONFIG_ICON;
|
private static final ImageIcon CONFIG_ICON;
|
||||||
private static final ImageIcon CONFIG_ICON_HOVER;
|
private static final ImageIcon CONFIG_ICON_HOVER;
|
||||||
private static final ImageIcon ON_SWITCHER;
|
|
||||||
private static final ImageIcon OFF_SWITCHER;
|
|
||||||
private static final ImageIcon ON_STAR;
|
private static final ImageIcon ON_STAR;
|
||||||
private static final ImageIcon OFF_STAR;
|
private static final ImageIcon OFF_STAR;
|
||||||
|
|
||||||
private final ConfigPanel configPanel;
|
private final PluginListPanel pluginListPanel;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Nullable
|
private final PluginConfigurationDescriptor pluginConfig;
|
||||||
private final Plugin plugin;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private final Config config;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private final ConfigDescriptor configDescriptor;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final String description;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final IconButton configToggleButton;
|
|
||||||
|
|
||||||
private final List<String> keywords = new ArrayList<>();
|
private final List<String> keywords = new ArrayList<>();
|
||||||
|
|
||||||
private final IconButton pinButton = new IconButton(OFF_STAR);
|
private final JToggleButton pinButton;
|
||||||
private final IconButton configButton = new IconButton(CONFIG_ICON, CONFIG_ICON_HOVER);
|
private final JToggleButton onOffToggle;
|
||||||
private final IconButton toggleButton;
|
|
||||||
|
|
||||||
private boolean isPluginEnabled = false;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private boolean isPinned = false;
|
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
BufferedImage configIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_edit_icon.png");
|
BufferedImage configIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_edit_icon.png");
|
||||||
BufferedImage onSwitcher = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "switcher_on.png");
|
|
||||||
BufferedImage onStar = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "star_on.png");
|
BufferedImage onStar = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "star_on.png");
|
||||||
CONFIG_ICON = new ImageIcon(configIcon);
|
CONFIG_ICON = new ImageIcon(configIcon);
|
||||||
ON_SWITCHER = new ImageIcon(onSwitcher);
|
|
||||||
ON_STAR = new ImageIcon(onStar);
|
ON_STAR = new ImageIcon(onStar);
|
||||||
CONFIG_ICON_HOVER = new ImageIcon(ImageUtil.grayscaleOffset(configIcon, -100));
|
CONFIG_ICON_HOVER = new ImageIcon(ImageUtil.grayscaleOffset(configIcon, -100));
|
||||||
BufferedImage offSwitcherImage = ImageUtil.flipImage(
|
|
||||||
ImageUtil.grayscaleOffset(
|
|
||||||
ImageUtil.grayscaleImage(onSwitcher),
|
|
||||||
0.61f
|
|
||||||
),
|
|
||||||
true,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
OFF_SWITCHER = new ImageIcon(offSwitcherImage);
|
|
||||||
BufferedImage offStar = ImageUtil.grayscaleOffset(
|
BufferedImage offStar = ImageUtil.grayscaleOffset(
|
||||||
ImageUtil.grayscaleImage(onStar),
|
ImageUtil.grayscaleImage(onStar),
|
||||||
0.77f
|
0.77f
|
||||||
@@ -130,76 +88,54 @@ class PluginListItem extends JPanel
|
|||||||
OFF_STAR = new ImageIcon(offStar);
|
OFF_STAR = new ImageIcon(offStar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
PluginListItem(PluginListPanel pluginListPanel, PluginConfigurationDescriptor pluginConfig)
|
||||||
* Creates a new {@code PluginListItem} for a plugin.
|
|
||||||
* <p>
|
|
||||||
* Note that {@code config} and {@code configDescriptor} can be {@code null}
|
|
||||||
* if there is no configuration associated with the plugin.
|
|
||||||
*/
|
|
||||||
PluginListItem(ConfigPanel configPanel, Plugin plugin, PluginDescriptor descriptor,
|
|
||||||
@Nullable Config config, @Nullable ConfigDescriptor configDescriptor)
|
|
||||||
{
|
{
|
||||||
this(configPanel, plugin, config, configDescriptor,
|
this.pluginListPanel = pluginListPanel;
|
||||||
descriptor.name(), descriptor.description(), descriptor.tags());
|
this.pluginConfig = pluginConfig;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
Collections.addAll(keywords, pluginConfig.getName().toLowerCase().split(" "));
|
||||||
* Creates a new {@code PluginListItem} for a core configuration.
|
Collections.addAll(keywords, pluginConfig.getDescription().toLowerCase().split(" "));
|
||||||
*/
|
Collections.addAll(keywords, pluginConfig.getTags());
|
||||||
PluginListItem(ConfigPanel configPanel, Config config, ConfigDescriptor configDescriptor,
|
|
||||||
String name, String description, String... tags)
|
|
||||||
{
|
|
||||||
this(configPanel, null, config, configDescriptor, name, description, tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PluginListItem(ConfigPanel configPanel, @Nullable Plugin plugin, @Nullable Config config,
|
|
||||||
@Nullable ConfigDescriptor configDescriptor, String name, String description, String... tags)
|
|
||||||
{
|
|
||||||
this.configPanel = configPanel;
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.config = config;
|
|
||||||
this.configDescriptor = configDescriptor;
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
Collections.addAll(keywords, name.toLowerCase().split(" "));
|
|
||||||
Collections.addAll(keywords, description.toLowerCase().split(" "));
|
|
||||||
Collections.addAll(keywords, tags);
|
|
||||||
|
|
||||||
final List<JMenuItem> popupMenuItems = new ArrayList<>();
|
final List<JMenuItem> popupMenuItems = new ArrayList<>();
|
||||||
|
|
||||||
setLayout(new BorderLayout(3, 0));
|
setLayout(new BorderLayout(3, 0));
|
||||||
setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH, 20));
|
setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH, 20));
|
||||||
|
|
||||||
JLabel nameLabel = new JLabel(name);
|
JLabel nameLabel = new JLabel(pluginConfig.getName());
|
||||||
nameLabel.setForeground(Color.WHITE);
|
nameLabel.setForeground(Color.WHITE);
|
||||||
|
|
||||||
if (!description.isEmpty())
|
if (!pluginConfig.getDescription().isEmpty())
|
||||||
{
|
{
|
||||||
nameLabel.setToolTipText("<html>" + name + ":<br>" + description + "</html>");
|
nameLabel.setToolTipText("<html>" + pluginConfig.getName() + ":<br>" + pluginConfig.getDescription() + "</html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pinButton = new JToggleButton(OFF_STAR);
|
||||||
|
pinButton.setSelectedIcon(ON_STAR);
|
||||||
|
SwingUtil.removeButtonDecorations(pinButton);
|
||||||
|
SwingUtil.addModalTooltip(pinButton, "Unpin plugin", "Pin plugin");
|
||||||
pinButton.setPreferredSize(new Dimension(21, 0));
|
pinButton.setPreferredSize(new Dimension(21, 0));
|
||||||
add(pinButton, BorderLayout.LINE_START);
|
add(pinButton, BorderLayout.LINE_START);
|
||||||
|
|
||||||
pinButton.addActionListener(e ->
|
pinButton.addActionListener(e ->
|
||||||
{
|
{
|
||||||
setPinned(!isPinned);
|
pluginListPanel.savePinnedPlugins();
|
||||||
configPanel.savePinnedPlugins();
|
pluginListPanel.refresh();
|
||||||
configPanel.openConfigList();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final JPanel buttonPanel = new JPanel();
|
final JPanel buttonPanel = new JPanel();
|
||||||
buttonPanel.setLayout(new GridLayout(1, 2));
|
buttonPanel.setLayout(new GridLayout(1, 2));
|
||||||
add(buttonPanel, BorderLayout.LINE_END);
|
add(buttonPanel, BorderLayout.LINE_END);
|
||||||
|
|
||||||
configButton.setPreferredSize(new Dimension(25, 0));
|
if (pluginConfig.hasConfigurables())
|
||||||
configButton.setVisible(false);
|
|
||||||
buttonPanel.add(configButton);
|
|
||||||
|
|
||||||
// add a listener to configButton only if there are config items to show
|
|
||||||
if (config != null && !configDescriptor.getItems().stream().allMatch(item -> item.getItem().hidden()))
|
|
||||||
{
|
{
|
||||||
|
JButton configButton = new JButton(CONFIG_ICON);
|
||||||
|
configButton.setRolloverIcon(CONFIG_ICON_HOVER);
|
||||||
|
SwingUtil.removeButtonDecorations(configButton);
|
||||||
|
configButton.setPreferredSize(new Dimension(25, 0));
|
||||||
|
configButton.setVisible(false);
|
||||||
|
buttonPanel.add(configButton);
|
||||||
|
|
||||||
configButton.addActionListener(e ->
|
configButton.addActionListener(e ->
|
||||||
{
|
{
|
||||||
configButton.setIcon(CONFIG_ICON);
|
configButton.setIcon(CONFIG_ICON);
|
||||||
@@ -214,72 +150,50 @@ class PluginListItem extends JPanel
|
|||||||
popupMenuItems.add(configMenuItem);
|
popupMenuItems.add(configMenuItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
popupMenuItems.add(wikiLinkMenuItem(name));
|
popupMenuItems.add(pluginConfig.createSupportMenuItem());
|
||||||
addLabelPopupMenu(nameLabel, popupMenuItems);
|
addLabelPopupMenu(nameLabel, popupMenuItems);
|
||||||
add(nameLabel, BorderLayout.CENTER);
|
add(nameLabel, BorderLayout.CENTER);
|
||||||
|
|
||||||
toggleButton = createToggleButton();
|
onOffToggle = new PluginToggleButton();
|
||||||
buttonPanel.add(toggleButton);
|
buttonPanel.add(onOffToggle);
|
||||||
|
if (pluginConfig.getPlugin() != null)
|
||||||
configToggleButton = createToggleButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void attachToggleButtonListener(IconButton button)
|
|
||||||
{
|
|
||||||
// no need for a listener if there is no plugin to enable / disable
|
|
||||||
if (plugin == null)
|
|
||||||
{
|
{
|
||||||
button.setVisible(false);
|
onOffToggle.addItemListener(i ->
|
||||||
return;
|
{
|
||||||
|
if (onOffToggle.isSelected())
|
||||||
|
{
|
||||||
|
pluginListPanel.startPlugin(pluginConfig.getPlugin());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pluginListPanel.stopPlugin(pluginConfig.getPlugin());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
button.addActionListener(e ->
|
|
||||||
{
|
{
|
||||||
if (isPluginEnabled)
|
onOffToggle.setVisible(false);
|
||||||
{
|
}
|
||||||
configPanel.stopPlugin(plugin, PluginListItem.this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
configPanel.startPlugin(plugin, PluginListItem.this);
|
|
||||||
}
|
|
||||||
|
|
||||||
setPluginEnabled(!isPluginEnabled);
|
|
||||||
updateToggleButton(button);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IconButton createToggleButton()
|
boolean isPinned()
|
||||||
{
|
{
|
||||||
final IconButton button = new IconButton(OFF_SWITCHER);
|
return pinButton.isSelected();
|
||||||
button.setPreferredSize(new Dimension(25, 0));
|
|
||||||
updateToggleButton(button);
|
|
||||||
attachToggleButtonListener(button);
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPluginEnabled(boolean enabled)
|
|
||||||
{
|
|
||||||
isPluginEnabled = enabled;
|
|
||||||
updateToggleButton(toggleButton);
|
|
||||||
updateToggleButton(configToggleButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPinned(boolean pinned)
|
void setPinned(boolean pinned)
|
||||||
{
|
{
|
||||||
isPinned = pinned;
|
pinButton.setSelected(pinned);
|
||||||
pinButton.setIcon(pinned ? ON_STAR : OFF_STAR);
|
|
||||||
pinButton.setToolTipText(pinned ? "Unpin plugin" : "Pin plugin");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateToggleButton(IconButton button)
|
void setPluginEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
button.setIcon(isPluginEnabled ? ON_SWITCHER : OFF_SWITCHER);
|
onOffToggle.setSelected(enabled);
|
||||||
button.setToolTipText(isPluginEnabled ? "Disable plugin" : "Enable plugin");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if all the search terms in the given list matches at least one keyword.
|
* Checks if all the search terms in the given list matches at least one keyword.
|
||||||
|
*
|
||||||
* @return true if all search terms matches at least one keyword, or false if otherwise.
|
* @return true if all search terms matches at least one keyword, or false if otherwise.
|
||||||
*/
|
*/
|
||||||
boolean matchesSearchTerms(String[] searchTerms)
|
boolean matchesSearchTerms(String[] searchTerms)
|
||||||
@@ -297,7 +211,7 @@ class PluginListItem extends JPanel
|
|||||||
|
|
||||||
private void openGroupConfigPanel()
|
private void openGroupConfigPanel()
|
||||||
{
|
{
|
||||||
configPanel.openGroupConfigPanel(PluginListItem.this, config, configDescriptor);
|
pluginListPanel.openConfigurationPanel(pluginConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -360,19 +274,4 @@ class PluginListItem extends JPanel
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a menu item for linking to a wiki page which, when clicked, opens a link to the plugin's wiki page for
|
|
||||||
* the passed plugin name.
|
|
||||||
*
|
|
||||||
* @param pluginName The name of the plugin which should be linked to
|
|
||||||
* @return A {@link JMenuItem} which opens the plugin's wiki page URL in the browser when clicked
|
|
||||||
*/
|
|
||||||
static JMenuItem wikiLinkMenuItem(final String pluginName)
|
|
||||||
{
|
|
||||||
final JMenuItem menuItem = new JMenuItem("Wiki");
|
|
||||||
final String sanitizedName = pluginName.replace(' ', '-');
|
|
||||||
menuItem.addActionListener(e -> LinkBrowser.browse(String.format(RUNELITE_WIKI_FORMAT, sanitizedName)));
|
|
||||||
return menuItem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,356 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.runelite.client.plugins.config;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Provider;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.ScrollPaneConstants;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.event.DocumentEvent;
|
||||||
|
import javax.swing.event.DocumentListener;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.runelite.client.config.Config;
|
||||||
|
import net.runelite.client.config.ConfigDescriptor;
|
||||||
|
import net.runelite.client.config.ConfigGroup;
|
||||||
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
|
import net.runelite.client.eventbus.EventBus;
|
||||||
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
import net.runelite.client.events.PluginChanged;
|
||||||
|
import net.runelite.client.plugins.Plugin;
|
||||||
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
|
import net.runelite.client.plugins.PluginInstantiationException;
|
||||||
|
import net.runelite.client.plugins.PluginManager;
|
||||||
|
import net.runelite.client.ui.ColorScheme;
|
||||||
|
import net.runelite.client.ui.DynamicGridLayout;
|
||||||
|
import net.runelite.client.ui.MultiplexingPluginPanel;
|
||||||
|
import net.runelite.client.ui.PluginPanel;
|
||||||
|
import net.runelite.client.ui.components.IconTextField;
|
||||||
|
import net.runelite.client.util.Text;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Singleton
|
||||||
|
class PluginListPanel extends PluginPanel
|
||||||
|
{
|
||||||
|
private static final String RUNELITE_GROUP_NAME = RuneLiteConfig.class.getAnnotation(ConfigGroup.class).value();
|
||||||
|
private static final String PINNED_PLUGINS_CONFIG_KEY = "pinnedPlugins";
|
||||||
|
|
||||||
|
private final ConfigManager configManager;
|
||||||
|
private final PluginManager pluginManager;
|
||||||
|
private final ScheduledExecutorService executorService;
|
||||||
|
private final Provider<ConfigPanel> configPanelProvider;
|
||||||
|
private final List<PluginConfigurationDescriptor> fakePlugins = new ArrayList<>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final MultiplexingPluginPanel muxer;
|
||||||
|
private final IconTextField searchBar;
|
||||||
|
private final JScrollPane scrollPane;
|
||||||
|
private final FixedWidthPanel mainPanel;
|
||||||
|
private List<PluginListItem> pluginList;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public PluginListPanel(
|
||||||
|
ConfigManager configManager,
|
||||||
|
PluginManager pluginManager,
|
||||||
|
ScheduledExecutorService executorService,
|
||||||
|
EventBus eventBus,
|
||||||
|
Provider<ConfigPanel> configPanelProvider)
|
||||||
|
{
|
||||||
|
super(false);
|
||||||
|
|
||||||
|
this.configManager = configManager;
|
||||||
|
this.pluginManager = pluginManager;
|
||||||
|
this.executorService = executorService;
|
||||||
|
this.configPanelProvider = configPanelProvider;
|
||||||
|
|
||||||
|
muxer = new MultiplexingPluginPanel(this)
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void onAdd(PluginPanel p)
|
||||||
|
{
|
||||||
|
eventBus.register(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRemove(PluginPanel p)
|
||||||
|
{
|
||||||
|
eventBus.unregister(p);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
searchBar = new IconTextField();
|
||||||
|
searchBar.setIcon(IconTextField.Icon.SEARCH);
|
||||||
|
searchBar.setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH - 20, 30));
|
||||||
|
searchBar.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
|
searchBar.setHoverBackgroundColor(ColorScheme.DARK_GRAY_HOVER_COLOR);
|
||||||
|
searchBar.getDocument().addDocumentListener(new DocumentListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void insertUpdate(DocumentEvent e)
|
||||||
|
{
|
||||||
|
onSearchBarChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeUpdate(DocumentEvent e)
|
||||||
|
{
|
||||||
|
onSearchBarChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changedUpdate(DocumentEvent e)
|
||||||
|
{
|
||||||
|
onSearchBarChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setLayout(new BorderLayout());
|
||||||
|
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
|
|
||||||
|
JPanel topPanel = new JPanel();
|
||||||
|
topPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||||
|
topPanel.setLayout(new BorderLayout(0, BORDER_OFFSET));
|
||||||
|
topPanel.add(searchBar, BorderLayout.CENTER);
|
||||||
|
add(topPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
mainPanel = new FixedWidthPanel();
|
||||||
|
mainPanel.setBorder(new EmptyBorder(8, 10, 10, 10));
|
||||||
|
mainPanel.setLayout(new DynamicGridLayout(0, 1, 0, 5));
|
||||||
|
mainPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||||
|
|
||||||
|
JPanel northPanel = new FixedWidthPanel();
|
||||||
|
northPanel.setLayout(new BorderLayout());
|
||||||
|
northPanel.add(mainPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
scrollPane = new JScrollPane(northPanel);
|
||||||
|
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
add(scrollPane, BorderLayout.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rebuildPluginList()
|
||||||
|
{
|
||||||
|
final List<String> pinnedPlugins = getPinnedPluginNames();
|
||||||
|
|
||||||
|
// populate pluginList with all non-hidden plugins
|
||||||
|
pluginList = Stream.concat(
|
||||||
|
fakePlugins.stream(),
|
||||||
|
pluginManager.getPlugins().stream()
|
||||||
|
.filter(plugin -> !plugin.getClass().getAnnotation(PluginDescriptor.class).hidden())
|
||||||
|
.map(plugin ->
|
||||||
|
{
|
||||||
|
PluginDescriptor descriptor = plugin.getClass().getAnnotation(PluginDescriptor.class);
|
||||||
|
Config config = pluginManager.getPluginConfigProxy(plugin);
|
||||||
|
ConfigDescriptor configDescriptor = config == null ? null : configManager.getConfigDescriptor(config);
|
||||||
|
|
||||||
|
return new PluginConfigurationDescriptor(
|
||||||
|
descriptor.name(),
|
||||||
|
descriptor.description(),
|
||||||
|
descriptor.tags(),
|
||||||
|
plugin,
|
||||||
|
config,
|
||||||
|
configDescriptor);
|
||||||
|
})
|
||||||
|
).map(desc ->
|
||||||
|
{
|
||||||
|
PluginListItem listItem = new PluginListItem(this, desc);
|
||||||
|
listItem.setPinned(pinnedPlugins.contains(desc.getName()));
|
||||||
|
return listItem;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
pluginList.sort(Comparator.comparing(p -> p.getPluginConfig().getName()));
|
||||||
|
mainPanel.removeAll();
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void addFakePlugin(PluginConfigurationDescriptor... descriptor)
|
||||||
|
{
|
||||||
|
Collections.addAll(fakePlugins, descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void refresh()
|
||||||
|
{
|
||||||
|
// update enabled / disabled status of all items
|
||||||
|
pluginList.forEach(listItem ->
|
||||||
|
{
|
||||||
|
final Plugin plugin = listItem.getPluginConfig().getPlugin();
|
||||||
|
if (plugin != null)
|
||||||
|
{
|
||||||
|
listItem.setPluginEnabled(pluginManager.isPluginEnabled(plugin));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
int scrollBarPosition = scrollPane.getVerticalScrollBar().getValue();
|
||||||
|
|
||||||
|
onSearchBarChanged();
|
||||||
|
searchBar.requestFocusInWindow();
|
||||||
|
validate();
|
||||||
|
|
||||||
|
scrollPane.getVerticalScrollBar().setValue(scrollBarPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onSearchBarChanged()
|
||||||
|
{
|
||||||
|
final String text = searchBar.getText();
|
||||||
|
|
||||||
|
pluginList.forEach(mainPanel::remove);
|
||||||
|
|
||||||
|
showMatchingPlugins(true, text);
|
||||||
|
showMatchingPlugins(false, text);
|
||||||
|
|
||||||
|
revalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showMatchingPlugins(boolean pinned, String text)
|
||||||
|
{
|
||||||
|
if (text.isEmpty())
|
||||||
|
{
|
||||||
|
pluginList.stream().filter(item -> pinned == item.isPinned()).forEach(mainPanel::add);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String[] searchTerms = text.toLowerCase().split(" ");
|
||||||
|
pluginList.forEach(listItem ->
|
||||||
|
{
|
||||||
|
if (pinned == listItem.isPinned() && listItem.matchesSearchTerms(searchTerms))
|
||||||
|
{
|
||||||
|
mainPanel.add(listItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void openConfigurationPanel(String configGroup)
|
||||||
|
{
|
||||||
|
for (PluginListItem pluginListItem : pluginList)
|
||||||
|
{
|
||||||
|
if (pluginListItem.getPluginConfig().getName().equals(configGroup))
|
||||||
|
{
|
||||||
|
openConfigurationPanel(pluginListItem.getPluginConfig());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void openConfigurationPanel(PluginConfigurationDescriptor plugin)
|
||||||
|
{
|
||||||
|
ConfigPanel panel = configPanelProvider.get();
|
||||||
|
panel.init(plugin);
|
||||||
|
muxer.pushState(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void startPlugin(Plugin plugin)
|
||||||
|
{
|
||||||
|
executorService.submit(() ->
|
||||||
|
{
|
||||||
|
pluginManager.setPluginEnabled(plugin, true);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pluginManager.startPlugin(plugin);
|
||||||
|
}
|
||||||
|
catch (PluginInstantiationException ex)
|
||||||
|
{
|
||||||
|
log.warn("Error when starting plugin {}", plugin.getClass().getSimpleName(), ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopPlugin(Plugin plugin)
|
||||||
|
{
|
||||||
|
executorService.submit(() ->
|
||||||
|
{
|
||||||
|
pluginManager.setPluginEnabled(plugin, false);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pluginManager.stopPlugin(plugin);
|
||||||
|
}
|
||||||
|
catch (PluginInstantiationException ex)
|
||||||
|
{
|
||||||
|
log.warn("Error when stopping plugin {}", plugin.getClass().getSimpleName(), ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getPinnedPluginNames()
|
||||||
|
{
|
||||||
|
final String config = configManager.getConfiguration(RUNELITE_GROUP_NAME, PINNED_PLUGINS_CONFIG_KEY);
|
||||||
|
|
||||||
|
if (config == null)
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Text.fromCSV(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
void savePinnedPlugins()
|
||||||
|
{
|
||||||
|
final String value = pluginList.stream()
|
||||||
|
.filter(PluginListItem::isPinned)
|
||||||
|
.map(p -> p.getPluginConfig().getName())
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
|
|
||||||
|
configManager.setConfiguration(RUNELITE_GROUP_NAME, PINNED_PLUGINS_CONFIG_KEY, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onPluginChanged(PluginChanged event)
|
||||||
|
{
|
||||||
|
SwingUtilities.invokeLater(this::refresh);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getPreferredSize()
|
||||||
|
{
|
||||||
|
return new Dimension(PANEL_WIDTH + SCROLLBAR_WIDTH, super.getPreferredSize().height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivate()
|
||||||
|
{
|
||||||
|
super.onActivate();
|
||||||
|
|
||||||
|
if (searchBar.getParent() != null)
|
||||||
|
{
|
||||||
|
searchBar.requestFocusInWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Abex
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.runelite.client.plugins.config;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
import net.runelite.client.util.ImageUtil;
|
||||||
|
import net.runelite.client.util.SwingUtil;
|
||||||
|
|
||||||
|
class PluginToggleButton extends JToggleButton
|
||||||
|
{
|
||||||
|
private static final ImageIcon ON_SWITCHER;
|
||||||
|
private static final ImageIcon OFF_SWITCHER;
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
BufferedImage onSwitcher = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "switcher_on.png");
|
||||||
|
ON_SWITCHER = new ImageIcon(onSwitcher);
|
||||||
|
OFF_SWITCHER = new ImageIcon(ImageUtil.flipImage(
|
||||||
|
ImageUtil.grayscaleOffset(
|
||||||
|
ImageUtil.grayscaleImage(onSwitcher),
|
||||||
|
0.61f
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public PluginToggleButton()
|
||||||
|
{
|
||||||
|
super(OFF_SWITCHER);
|
||||||
|
setSelectedIcon(ON_SWITCHER);
|
||||||
|
SwingUtil.removeButtonDecorations(this);
|
||||||
|
setPreferredSize(new Dimension(25, 0));
|
||||||
|
SwingUtil.addModalTooltip(this, "Disable plugin", "Enable plugin");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Abex
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.runelite.client.ui;
|
||||||
|
|
||||||
|
import java.awt.CardLayout;
|
||||||
|
|
||||||
|
public class MultiplexingPluginPanel extends PluginPanel
|
||||||
|
{
|
||||||
|
private final CardLayout layout;
|
||||||
|
private boolean active = false;
|
||||||
|
private PluginPanel current;
|
||||||
|
|
||||||
|
public MultiplexingPluginPanel(PluginPanel root)
|
||||||
|
{
|
||||||
|
super(false);
|
||||||
|
|
||||||
|
layout = new CardLayout();
|
||||||
|
setLayout(layout);
|
||||||
|
pushState(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy()
|
||||||
|
{
|
||||||
|
for (int i = getComponentCount() - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
onRemove((PluginPanel) getComponent(i));
|
||||||
|
remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pushState(PluginPanel subpanel)
|
||||||
|
{
|
||||||
|
int index = -1;
|
||||||
|
for (int i = getComponentCount() - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (getComponent(i) == subpanel)
|
||||||
|
{
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (active)
|
||||||
|
{
|
||||||
|
current.onDeactivate();
|
||||||
|
subpanel.onActivate();
|
||||||
|
}
|
||||||
|
current = subpanel;
|
||||||
|
|
||||||
|
String name = System.identityHashCode(subpanel) + "";
|
||||||
|
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
for (int i = getComponentCount() - 1; i > index; i--)
|
||||||
|
{
|
||||||
|
popState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
add(subpanel, name);
|
||||||
|
onAdd(subpanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
layout.show(this, name);
|
||||||
|
revalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void popState()
|
||||||
|
{
|
||||||
|
int count = getComponentCount();
|
||||||
|
if (count <= 1)
|
||||||
|
{
|
||||||
|
assert false : "Cannot pop last component";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginPanel subpanel = (PluginPanel) getComponent(count - 2);
|
||||||
|
if (active)
|
||||||
|
{
|
||||||
|
current.onDeactivate();
|
||||||
|
subpanel.onActivate();
|
||||||
|
current = subpanel;
|
||||||
|
}
|
||||||
|
layout.show(this, System.identityHashCode(subpanel) + "");
|
||||||
|
onRemove((PluginPanel) getComponent(count - 1));
|
||||||
|
remove(count - 1);
|
||||||
|
revalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onAdd(PluginPanel p)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onRemove(PluginPanel p)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivate()
|
||||||
|
{
|
||||||
|
active = true;
|
||||||
|
current.onActivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDeactivate()
|
||||||
|
{
|
||||||
|
active = false;
|
||||||
|
current.onDeactivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,9 +36,9 @@ import lombok.Getter;
|
|||||||
public abstract class PluginPanel extends JPanel
|
public abstract class PluginPanel extends JPanel
|
||||||
{
|
{
|
||||||
public static final int PANEL_WIDTH = 225;
|
public static final int PANEL_WIDTH = 225;
|
||||||
private static final int SCROLLBAR_WIDTH = 17;
|
public static final int SCROLLBAR_WIDTH = 17;
|
||||||
private static final int OFFSET = 6;
|
public static final int BORDER_OFFSET = 6;
|
||||||
private static final EmptyBorder BORDER_PADDING = new EmptyBorder(OFFSET, OFFSET, OFFSET, OFFSET);
|
private static final EmptyBorder BORDER_PADDING = new EmptyBorder(BORDER_OFFSET, BORDER_OFFSET, BORDER_OFFSET, BORDER_OFFSET);
|
||||||
private static final Dimension OUTER_PREFERRED_SIZE = new Dimension(PluginPanel.PANEL_WIDTH + SCROLLBAR_WIDTH, 0);
|
private static final Dimension OUTER_PREFERRED_SIZE = new Dimension(PluginPanel.PANEL_WIDTH + SCROLLBAR_WIDTH, 0);
|
||||||
|
|
||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
import java.awt.Insets;
|
||||||
import java.awt.SystemTray;
|
import java.awt.SystemTray;
|
||||||
import java.awt.TrayIcon;
|
import java.awt.TrayIcon;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
@@ -41,6 +42,7 @@ import java.util.concurrent.Callable;
|
|||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import javax.swing.AbstractButton;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
@@ -277,4 +279,18 @@ public class SwingUtil
|
|||||||
navigationButton.setOnSelect(button::doClick);
|
navigationButton.setOnSelect(button::doClick);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeButtonDecorations(AbstractButton button)
|
||||||
|
{
|
||||||
|
button.setBorderPainted(false);
|
||||||
|
button.setContentAreaFilled(false);
|
||||||
|
button.setFocusPainted(false);
|
||||||
|
button.setMargin(new Insets(0, 0, 0, 0));
|
||||||
|
button.setOpaque(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addModalTooltip(AbstractButton button, String on, String off)
|
||||||
|
{
|
||||||
|
button.addItemListener(l -> button.setToolTipText(button.isSelected() ? on : off));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user