Make unhide accept multiple arguments and add suport for hide key (#341)

This commit is contained in:
sdburns1998
2019-05-21 10:43:02 +02:00
committed by Kyleeld
parent f2c104f7ba
commit bece4b3689
2 changed files with 28 additions and 7 deletions

View File

@@ -51,5 +51,7 @@ public @interface ConfigItem
String unhide() default "";
String hide() default "";
String parent() default "";
}

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.config;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.primitives.Ints;
import java.awt.BorderLayout;
@@ -503,24 +504,36 @@ public class ConfigPanel extends PluginPanel
continue; // Ignore main 'parent'
}
if (cid.getItem().hidden())
Boolean unhide = cid.getItem().hidden();
Boolean hide = !cid.getItem().hide().isEmpty();
if (unhide || hide)
{
boolean show = false;
String unhideat = cid.getItem().unhide();
List<String> itemHide = Splitter
.onPattern("\\|\\|")
.trimResults()
.omitEmptyStrings()
.splitToList(String.format("%s || %s", cid.getItem().unhide(), cid.getItem().hide()));
for (ConfigItemDescriptor cid2 : cd.getItems())
{
if (cid2.getItem().keyName().equals(unhideat))
if (itemHide.contains(cid2.getItem().keyName()))
{
if (cid2.getType() == boolean.class)
{
show = Boolean.parseBoolean(configManager.getConfiguration(cd.getGroup().value(), cid2.getItem().keyName()));
}
}
if (show)
{
break;
}
}
if (!show)
if ((unhide && !show) || (hide && show))
{
continue;
}
@@ -845,9 +858,15 @@ public class ConfigPanel extends PluginPanel
for (ConfigItemDescriptor cid2 : cd.getItems())
{
if (cid2.getItem().hidden())
if (cid2.getItem().hidden() || !cid2.getItem().hide().isEmpty())
{
if (cid2.getItem().unhide().equals(cid.getItem().keyName()))
List<String> itemHide = Splitter
.onPattern("\\|\\|")
.trimResults()
.omitEmptyStrings()
.splitToList(String.format("%s || %s", cid2.getItem().unhide(), cid2.getItem().hide()));
if (itemHide.contains(cid.getItem().keyName()))
{ // If another options visibility changes depending on the value of this checkbox, then render the entire menu again
openGroupConfigPanel(listItem, config, cd);
return;