pluginsorter: Add ability to hide per category
This commit is contained in:
@@ -491,14 +491,14 @@ public class ConfigPanel extends PluginPanel
|
|||||||
{
|
{
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
{
|
{
|
||||||
pluginList.stream().filter(item -> pinned == item.isPinned()).forEach(mainPanel::add);
|
pluginList.stream().filter(item -> pinned == item.isPinned() && !item.isHidden()).forEach(mainPanel::add);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] searchTerms = text.toLowerCase().split(" ");
|
final String[] searchTerms = text.toLowerCase().split(" ");
|
||||||
pluginList.forEach(listItem ->
|
pluginList.forEach(listItem ->
|
||||||
{
|
{
|
||||||
if (pinned == listItem.isPinned() && listItem.matchesSearchTerms(searchTerms))
|
if (pinned == listItem.isPinned() && listItem.matchesSearchTerms(searchTerms) && !listItem.isHidden())
|
||||||
{
|
{
|
||||||
mainPanel.add(listItem);
|
mainPanel.add(listItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,9 @@ public class PluginListItem extends JPanel
|
|||||||
@Getter
|
@Getter
|
||||||
private boolean isPinned = false;
|
private boolean isPinned = false;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private boolean isHidden = false;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
BufferedImage configIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_edit_icon.png");
|
BufferedImage configIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_edit_icon.png");
|
||||||
@@ -255,6 +258,11 @@ public class PluginListItem extends JPanel
|
|||||||
pinButton.setToolTipText(pinned ? "Unpin plugin" : "Pin plugin");
|
pinButton.setToolTipText(pinned ? "Unpin plugin" : "Pin plugin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHidden(boolean hidden)
|
||||||
|
{
|
||||||
|
isHidden = hidden;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateToggleButton(IconButton button)
|
private void updateToggleButton(IconButton button)
|
||||||
{
|
{
|
||||||
button.setIcon(isPluginEnabled ? ON_SWITCHER : OFF_SWITCHER);
|
button.setIcon(isPluginEnabled ? ON_SWITCHER : OFF_SWITCHER);
|
||||||
|
|||||||
@@ -29,29 +29,119 @@ import net.runelite.client.config.Alpha;
|
|||||||
import net.runelite.client.config.Config;
|
import net.runelite.client.config.Config;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
|
import net.runelite.client.config.ConfigTitleSection;
|
||||||
|
import net.runelite.client.config.Title;
|
||||||
|
|
||||||
@ConfigGroup("pluginsorter")
|
@ConfigGroup("pluginsorter")
|
||||||
public interface PluginSorterConfig extends Config
|
public interface PluginSorterConfig extends Config
|
||||||
{
|
{
|
||||||
boolean pluginsHidden = false;
|
@ConfigTitleSection(
|
||||||
|
keyName = "hidePluginsTitle",
|
||||||
|
name = "Hiding",
|
||||||
|
description = "",
|
||||||
|
position = 0
|
||||||
|
)
|
||||||
|
default Title hidePluginsTitle()
|
||||||
|
{
|
||||||
|
return new Title();
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 0,
|
position = 1,
|
||||||
keyName = "hidePlugins",
|
keyName = "hidePlugins",
|
||||||
name = "Hide Plugins",
|
name = "Hide Plugins",
|
||||||
description = "Hides all 3rd party plugins if checked"
|
description = "Hides all OpenOSRS plugins if checked",
|
||||||
|
titleSection = "hidePluginsTitle",
|
||||||
|
hide = "hidePvmPlugins || hidePvpPlugins || hideSkillingPlugins || hideUtilityPlugins || hideExternalPlugins"
|
||||||
)
|
)
|
||||||
default boolean hidePlugins()
|
default boolean hidePlugins()
|
||||||
{
|
{
|
||||||
return pluginsHidden;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 6,
|
||||||
|
keyName = "hideExternalPlugins",
|
||||||
|
name = "Hide External Plugins",
|
||||||
|
description = "Hides all OpenOSRS external plugins if checked",
|
||||||
|
titleSection = "hidePluginsTitle",
|
||||||
|
hide = "hidePlugins"
|
||||||
|
)
|
||||||
|
default boolean hideExternalPlugins()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 2,
|
||||||
|
keyName = "hidePvmPlugins",
|
||||||
|
name = "Hide PvM Plugins",
|
||||||
|
description = "Hides all OpenOSRS PvM plugins if checked",
|
||||||
|
titleSection = "hidePluginsTitle",
|
||||||
|
hide = "hidePlugins"
|
||||||
|
)
|
||||||
|
default boolean hidePvmPlugins()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 4,
|
||||||
|
keyName = "hideSkillingPlugins",
|
||||||
|
name = "Hide Skillinh Plugins",
|
||||||
|
description = "Hides all OpenOSRS skilling plugins if checked",
|
||||||
|
titleSection = "hidePluginsTitle",
|
||||||
|
hide = "hidePlugins"
|
||||||
|
)
|
||||||
|
default boolean hideSkillingPlugins()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 3,
|
||||||
|
keyName = "hidePvpPlugins",
|
||||||
|
name = "Hide PvP Plugins",
|
||||||
|
description = "Hides all OpenOSRS Pvp plugins if checked",
|
||||||
|
titleSection = "hidePluginsTitle",
|
||||||
|
hide = "hidePlugins"
|
||||||
|
)
|
||||||
|
default boolean hidePvpPlugins()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 5,
|
||||||
|
keyName = "hideUtilityPlugins",
|
||||||
|
name = "Hide Utility Plugins",
|
||||||
|
description = "Hides all OpenOSRS utility plugins if checked",
|
||||||
|
titleSection = "hidePluginsTitle",
|
||||||
|
hide = "hidePlugins"
|
||||||
|
)
|
||||||
|
default boolean hideUtilityPlugins()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigTitleSection(
|
||||||
|
keyName = "pluginsColorTitle",
|
||||||
|
name = "Colors",
|
||||||
|
description = "",
|
||||||
|
position = 7
|
||||||
|
)
|
||||||
|
default Title pluginsColorTitle()
|
||||||
|
{
|
||||||
|
return new Title();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Alpha
|
@Alpha
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 1,
|
position = 8,
|
||||||
keyName = "externalColor",
|
keyName = "externalColor",
|
||||||
name = "External color",
|
name = "External color",
|
||||||
description = "Configure the color of external plugins"
|
description = "Configure the color of external plugins",
|
||||||
|
titleSection = "pluginsColorTitle"
|
||||||
)
|
)
|
||||||
default Color externalColor()
|
default Color externalColor()
|
||||||
{
|
{
|
||||||
@@ -60,10 +150,11 @@ public interface PluginSorterConfig extends Config
|
|||||||
|
|
||||||
@Alpha
|
@Alpha
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 2,
|
position = 9,
|
||||||
keyName = "pvmColor",
|
keyName = "pvmColor",
|
||||||
name = "PVM color",
|
name = "PVM color",
|
||||||
description = "Configure the color of PVM related plugins"
|
description = "Configure the color of PVM related plugins",
|
||||||
|
titleSection = "pluginsColorTitle"
|
||||||
)
|
)
|
||||||
default Color pvmColor()
|
default Color pvmColor()
|
||||||
{
|
{
|
||||||
@@ -72,10 +163,11 @@ public interface PluginSorterConfig extends Config
|
|||||||
|
|
||||||
@Alpha
|
@Alpha
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 3,
|
position = 10,
|
||||||
keyName = "pvpColor",
|
keyName = "pvpColor",
|
||||||
name = "PVP color",
|
name = "PVP color",
|
||||||
description = "Configure the color of PVP related plugins"
|
description = "Configure the color of PVP related plugins",
|
||||||
|
titleSection = "pluginsColorTitle"
|
||||||
)
|
)
|
||||||
default Color pvpColor()
|
default Color pvpColor()
|
||||||
{
|
{
|
||||||
@@ -84,10 +176,11 @@ public interface PluginSorterConfig extends Config
|
|||||||
|
|
||||||
@Alpha
|
@Alpha
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 4,
|
position = 11,
|
||||||
keyName = "skillingColor",
|
keyName = "skillingColor",
|
||||||
name = "Skilling color",
|
name = "Skilling color",
|
||||||
description = "Configure the color of Skilling related plugins"
|
description = "Configure the color of Skilling related plugins",
|
||||||
|
titleSection = "pluginsColorTitle"
|
||||||
)
|
)
|
||||||
default Color skillingColor()
|
default Color skillingColor()
|
||||||
{
|
{
|
||||||
@@ -96,10 +189,11 @@ public interface PluginSorterConfig extends Config
|
|||||||
|
|
||||||
@Alpha
|
@Alpha
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 5,
|
position = 12,
|
||||||
keyName = "utilityColor",
|
keyName = "utilityColor",
|
||||||
name = "Utility color",
|
name = "Utility color",
|
||||||
description = "Configure the color of Utility related plugins"
|
description = "Configure the color of Utility related plugins",
|
||||||
|
titleSection = "pluginsColorTitle"
|
||||||
)
|
)
|
||||||
default Color utilityColor()
|
default Color utilityColor()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ package net.runelite.client.plugins.pluginsorter;
|
|||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import net.runelite.api.events.ConfigChanged;
|
import net.runelite.api.events.ConfigChanged;
|
||||||
@@ -50,16 +47,12 @@ import net.runelite.client.plugins.config.PluginListItem;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class PluginSorterPlugin extends Plugin
|
public class PluginSorterPlugin extends Plugin
|
||||||
{
|
{
|
||||||
//Cache the hidden plugins
|
|
||||||
private static final List<PluginListItem> removedPlugins = new ArrayList<>();
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PluginSorterConfig config;
|
private PluginSorterConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
|
|
||||||
private boolean hidePlugins;
|
|
||||||
private Color externalColor;
|
private Color externalColor;
|
||||||
private Color pvmColor;
|
private Color pvmColor;
|
||||||
private Color pvpColor;
|
private Color pvpColor;
|
||||||
@@ -78,7 +71,7 @@ public class PluginSorterPlugin extends Plugin
|
|||||||
updateConfig();
|
updateConfig();
|
||||||
addSubscriptions();
|
addSubscriptions();
|
||||||
|
|
||||||
updateColors();
|
updatePlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -100,16 +93,7 @@ public class PluginSorterPlugin extends Plugin
|
|||||||
|
|
||||||
private void validatePlugins()
|
private void validatePlugins()
|
||||||
{
|
{
|
||||||
if (this.hidePlugins)
|
updatePlugins();
|
||||||
{
|
|
||||||
hidePlugins();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
showPlugins();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateColors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onConfigChanged(ConfigChanged configChanged)
|
private void onConfigChanged(ConfigChanged configChanged)
|
||||||
@@ -120,15 +104,18 @@ public class PluginSorterPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateConfig();
|
updateConfig();
|
||||||
|
updatePlugins();
|
||||||
if (configChanged.getKey().equals("hidePlugins"))
|
|
||||||
{
|
|
||||||
validatePlugins();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateColors()
|
private void updatePlugins()
|
||||||
{
|
{
|
||||||
|
boolean hidePlugins = config.hidePlugins();
|
||||||
|
boolean hidePvmPlugins = config.hidePvmPlugins();
|
||||||
|
boolean hidePvpPlugins = config.hidePvpPlugins();
|
||||||
|
boolean hideSkillingPlugins = config.hideSkillingPlugins();
|
||||||
|
boolean hideUtilityPlugins = config.hideUtilityPlugins();
|
||||||
|
boolean hideExternalPlugins = config.hideExternalPlugins();
|
||||||
|
|
||||||
for (PluginListItem pli : ConfigPanel.pluginList)
|
for (PluginListItem pli : ConfigPanel.pluginList)
|
||||||
{
|
{
|
||||||
if (pli.getPlugin() != null)
|
if (pli.getPlugin() != null)
|
||||||
@@ -137,18 +124,23 @@ public class PluginSorterPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
case EXTERNAL:
|
case EXTERNAL:
|
||||||
pli.nameLabel.setForeground(this.externalColor);
|
pli.nameLabel.setForeground(this.externalColor);
|
||||||
|
pli.setHidden(hidePlugins || hideExternalPlugins);
|
||||||
break;
|
break;
|
||||||
case PVM:
|
case PVM:
|
||||||
pli.nameLabel.setForeground(this.pvmColor);
|
pli.nameLabel.setForeground(this.pvmColor);
|
||||||
|
pli.setHidden(hidePlugins || hidePvmPlugins);
|
||||||
break;
|
break;
|
||||||
case PVP:
|
case PVP:
|
||||||
pli.nameLabel.setForeground(this.pvpColor);
|
pli.nameLabel.setForeground(this.pvpColor);
|
||||||
|
pli.setHidden(hidePlugins || hidePvpPlugins);
|
||||||
break;
|
break;
|
||||||
case SKILLING:
|
case SKILLING:
|
||||||
pli.nameLabel.setForeground(this.skillingColor);
|
pli.nameLabel.setForeground(this.skillingColor);
|
||||||
|
pli.setHidden(hidePlugins || hideSkillingPlugins);
|
||||||
break;
|
break;
|
||||||
case UTILITY:
|
case UTILITY:
|
||||||
pli.nameLabel.setForeground(this.utilityColor);
|
pli.nameLabel.setForeground(this.utilityColor);
|
||||||
|
pli.setHidden(hidePlugins || hideUtilityPlugins);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pli.nameLabel.setForeground(Color.WHITE);
|
pli.nameLabel.setForeground(Color.WHITE);
|
||||||
@@ -158,49 +150,8 @@ public class PluginSorterPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hidePlugins()
|
|
||||||
{
|
|
||||||
Iterator<PluginListItem> iter = ConfigPanel.pluginList.iterator();
|
|
||||||
while (iter.hasNext())
|
|
||||||
{
|
|
||||||
PluginListItem pli = iter.next();
|
|
||||||
if (pli.getPlugin() != null)
|
|
||||||
{
|
|
||||||
switch (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type())
|
|
||||||
{
|
|
||||||
case PVM:
|
|
||||||
case PVP:
|
|
||||||
case SKILLING:
|
|
||||||
case UTILITY:
|
|
||||||
case EXTERNAL:
|
|
||||||
iter.remove();
|
|
||||||
removedPlugins.add(pli);
|
|
||||||
break;
|
|
||||||
case GENERAL_USE:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showPlugins()
|
|
||||||
{
|
|
||||||
List<PluginListItem> tempList = new ArrayList<>(ConfigPanel.pluginList);
|
|
||||||
if (tempList.size() > 0)
|
|
||||||
{
|
|
||||||
tempList.addAll(2, removedPlugins);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tempList.addAll(removedPlugins);
|
|
||||||
}
|
|
||||||
ConfigPanel.pluginList = tempList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateConfig()
|
private void updateConfig()
|
||||||
{
|
{
|
||||||
this.hidePlugins = config.hidePlugins();
|
|
||||||
this.externalColor = config.externalColor();
|
this.externalColor = config.externalColor();
|
||||||
this.pvmColor = config.pvmColor();
|
this.pvmColor = config.pvmColor();
|
||||||
this.pvpColor = config.pvpColor();
|
this.pvpColor = config.pvpColor();
|
||||||
|
|||||||
Reference in New Issue
Block a user