Plugins can now accept colors (not my code)
This commit is contained in:
@@ -130,7 +130,7 @@ public class ConfigPanel extends PluginPanel
|
||||
}
|
||||
|
||||
ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService,
|
||||
RuneLiteConfig runeLiteConfig, ChatColorConfig chatColorConfig)
|
||||
RuneLiteConfig runeLiteConfig, ChatColorConfig chatColorConfig)
|
||||
{
|
||||
super(false);
|
||||
this.pluginManager = pluginManager;
|
||||
@@ -195,28 +195,28 @@ public class ConfigPanel extends PluginPanel
|
||||
|
||||
// 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);
|
||||
.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);
|
||||
});
|
||||
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");
|
||||
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");
|
||||
configManager.getConfigDescriptor(chatColorConfig),
|
||||
CHAT_COLOR_PLUGIN, "Recolor chat text", "colour", "messages");
|
||||
chatColor.setPinned(pinnedPlugins.contains(CHAT_COLOR_PLUGIN));
|
||||
pluginList.add(chatColor);
|
||||
|
||||
@@ -310,7 +310,8 @@ public class ConfigPanel extends PluginPanel
|
||||
String name = listItem.getName();
|
||||
JLabel title = new JLabel(name);
|
||||
title.setForeground(Color.WHITE);
|
||||
title.setToolTipText("<html>" + name + ":<br>" + listItem.getDescription() + "</html>");
|
||||
title.setText("<html>" + name +"</html>");
|
||||
title.setToolTipText("<html>" + ":<br>" + listItem.getDescription() + "</html>");
|
||||
topPanel.add(title);
|
||||
|
||||
for (ConfigItemDescriptor cid : cd.getItems())
|
||||
@@ -421,7 +422,7 @@ public class ConfigPanel extends PluginPanel
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
RuneliteColorPicker colorPicker = new RuneliteColorPicker(SwingUtilities.windowForComponent(ConfigPanel.this),
|
||||
colorPickerBtn.getBackground(), cid.getItem().name(), cid.getAlpha() == null);
|
||||
colorPickerBtn.getBackground(), cid.getItem().name(), cid.getAlpha() == null);
|
||||
colorPicker.setLocation(getLocationOnScreen());
|
||||
colorPicker.setOnColorChange(c ->
|
||||
{
|
||||
@@ -467,7 +468,7 @@ public class ConfigPanel extends PluginPanel
|
||||
heightSpinnerTextField.setColumns(4);
|
||||
|
||||
ChangeListener listener = e ->
|
||||
configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), widthSpinner.getValue() + "x" + heightSpinner.getValue());
|
||||
configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), widthSpinner.getValue() + "x" + heightSpinner.getValue());
|
||||
|
||||
widthSpinner.addChangeListener(listener);
|
||||
heightSpinner.addChangeListener(listener);
|
||||
@@ -512,8 +513,8 @@ public class ConfigPanel extends PluginPanel
|
||||
if (cid.getType() == Keybind.class || cid.getType() == ModifierlessKeybind.class)
|
||||
{
|
||||
Keybind startingValue = configManager.getConfiguration(cd.getGroup().value(),
|
||||
cid.getItem().keyName(),
|
||||
(Class<? extends Keybind>) cid.getType());
|
||||
cid.getItem().keyName(),
|
||||
(Class<? extends Keybind>) cid.getType());
|
||||
|
||||
HotkeyButton button = new HotkeyButton(startingValue, cid.getType() == ModifierlessKeybind.class);
|
||||
|
||||
@@ -536,8 +537,8 @@ public class ConfigPanel extends PluginPanel
|
||||
resetButton.addActionListener((e) ->
|
||||
{
|
||||
final int result = JOptionPane.showOptionDialog(resetButton, "Are you sure you want to reset this plugin's configuration?",
|
||||
"Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
|
||||
null, new String[]{"Yes", "No"}, "No");
|
||||
"Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
|
||||
null, new String[]{"Yes", "No"}, "No");
|
||||
|
||||
if (result == JOptionPane.YES_OPTION)
|
||||
{
|
||||
@@ -564,8 +565,8 @@ public class ConfigPanel extends PluginPanel
|
||||
if (!Strings.isNullOrEmpty(configItem.warning()))
|
||||
{
|
||||
final int result = JOptionPane.showOptionDialog(component, configItem.warning(),
|
||||
"Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
|
||||
null, new String[]{"Yes", "No"}, "No");
|
||||
"Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
|
||||
null, new String[]{"Yes", "No"}, "No");
|
||||
|
||||
if (result != JOptionPane.YES_OPTION)
|
||||
{
|
||||
@@ -659,9 +660,9 @@ public class ConfigPanel extends PluginPanel
|
||||
void savePinnedPlugins()
|
||||
{
|
||||
final String value = pluginList.stream()
|
||||
.filter(PluginListItem::isPinned)
|
||||
.map(PluginListItem::getName)
|
||||
.collect(Collectors.joining(","));
|
||||
.filter(PluginListItem::isPinned)
|
||||
.map(PluginListItem::getName)
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
configManager.setConfiguration(RUNELITE_GROUP_NAME, PINNED_PLUGINS_CONFIG_KEY, value);
|
||||
}
|
||||
@@ -704,4 +705,4 @@ public class ConfigPanel extends PluginPanel
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,17 +99,17 @@ class PluginListItem extends JPanel
|
||||
ON_STAR = new ImageIcon(onStar);
|
||||
CONFIG_ICON_HOVER = new ImageIcon(ImageUtil.grayscaleOffset(configIcon, -100));
|
||||
BufferedImage offSwitcherImage = ImageUtil.flipImage(
|
||||
ImageUtil.grayscaleOffset(
|
||||
ImageUtil.grayscaleImage(onSwitcher),
|
||||
0.61f
|
||||
),
|
||||
true,
|
||||
false
|
||||
ImageUtil.grayscaleOffset(
|
||||
ImageUtil.grayscaleImage(onSwitcher),
|
||||
0.61f
|
||||
),
|
||||
true,
|
||||
false
|
||||
);
|
||||
OFF_SWITCHER = new ImageIcon(offSwitcherImage);
|
||||
BufferedImage offStar = ImageUtil.grayscaleOffset(
|
||||
ImageUtil.grayscaleImage(onStar),
|
||||
0.77f
|
||||
ImageUtil.grayscaleImage(onStar),
|
||||
0.77f
|
||||
);
|
||||
OFF_STAR = new ImageIcon(offStar);
|
||||
}
|
||||
@@ -121,23 +121,23 @@ class PluginListItem extends JPanel
|
||||
* if there is no configuration associated with the plugin.
|
||||
*/
|
||||
PluginListItem(ConfigPanel configPanel, Plugin plugin, PluginDescriptor descriptor,
|
||||
@Nullable Config config, @Nullable ConfigDescriptor configDescriptor)
|
||||
@Nullable Config config, @Nullable ConfigDescriptor configDescriptor)
|
||||
{
|
||||
this(configPanel, plugin, config, configDescriptor,
|
||||
descriptor.name(), descriptor.description(), descriptor.tags());
|
||||
descriptor.name(), descriptor.description(), descriptor.tags());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code PluginListItem} for a core configuration.
|
||||
*/
|
||||
PluginListItem(ConfigPanel configPanel, Config config, ConfigDescriptor configDescriptor,
|
||||
String name, String description, String... tags)
|
||||
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)
|
||||
@Nullable ConfigDescriptor configDescriptor, String name, String description, String... tags)
|
||||
{
|
||||
this.configPanel = configPanel;
|
||||
this.plugin = plugin;
|
||||
@@ -153,8 +153,10 @@ class PluginListItem extends JPanel
|
||||
setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH, 20));
|
||||
|
||||
JLabel nameLabel = new JLabel(name);
|
||||
nameLabel.setText("<html>" + name +"</html>");
|
||||
nameLabel.setForeground(Color.WHITE);
|
||||
|
||||
|
||||
if (!description.isEmpty())
|
||||
{
|
||||
nameLabel.setToolTipText("<html>" + name + ":<br>" + description + "</html>");
|
||||
@@ -260,7 +262,7 @@ class PluginListItem extends JPanel
|
||||
for (String term : searchTerms)
|
||||
{
|
||||
if (keywords.stream().noneMatch((t) -> t.contains(term) ||
|
||||
DISTANCE.apply(t, term) > 0.9))
|
||||
DISTANCE.apply(t, term) > 0.9))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user