Merge pull request #8816 from devLotto/format-config-enums
Format config enums as "Config Option" by default
This commit is contained in:
@@ -24,20 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.chatfilter;
|
package net.runelite.client.plugins.chatfilter;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum ChatFilterType
|
public enum ChatFilterType
|
||||||
{
|
{
|
||||||
CENSOR_WORDS("Censor words"),
|
CENSOR_WORDS,
|
||||||
CENSOR_MESSAGE("Censor message"),
|
CENSOR_MESSAGE,
|
||||||
REMOVE_MESSAGE("Remove message");
|
REMOVE_MESSAGE
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
{
|
{
|
||||||
Enum selectedItem = Enum.valueOf(type, configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName()));
|
Enum selectedItem = Enum.valueOf(type, configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName()));
|
||||||
box.setSelectedItem(selectedItem);
|
box.setSelectedItem(selectedItem);
|
||||||
box.setToolTipText(selectedItem.toString());
|
box.setToolTipText(Text.titleCase(selectedItem));
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex)
|
catch (IllegalArgumentException ex)
|
||||||
{
|
{
|
||||||
@@ -503,7 +503,7 @@ public class ConfigPanel extends PluginPanel
|
|||||||
if (e.getStateChange() == ItemEvent.SELECTED)
|
if (e.getStateChange() == ItemEvent.SELECTED)
|
||||||
{
|
{
|
||||||
changeConfiguration(listItem, config, box, cd, cid);
|
changeConfiguration(listItem, config, box, cd, cid);
|
||||||
box.setToolTipText(box.getSelectedItem().toString());
|
box.setToolTipText(Text.titleCase((Enum) box.getSelectedItem()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
item.add(box, BorderLayout.EAST);
|
item.add(box, BorderLayout.EAST);
|
||||||
|
|||||||
@@ -24,22 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.fps;
|
package net.runelite.client.plugins.fps;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum FpsLimitMode
|
public enum FpsLimitMode
|
||||||
{
|
{
|
||||||
NEVER("Never"),
|
NEVER,
|
||||||
UNFOCUSED("Unfocused"),
|
UNFOCUSED,
|
||||||
ALWAYS("Always");
|
ALWAYS
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,21 +24,8 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.itemidentification;
|
package net.runelite.client.plugins.itemidentification;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum ItemIdentificationMode
|
public enum ItemIdentificationMode
|
||||||
{
|
{
|
||||||
SHORT("Short"),
|
SHORT,
|
||||||
MEDIUM("Medium");
|
MEDIUM
|
||||||
|
|
||||||
private final String type;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,21 +26,8 @@ package net.runelite.client.plugins.npchighlight;
|
|||||||
|
|
||||||
public enum RenderStyle
|
public enum RenderStyle
|
||||||
{
|
{
|
||||||
OFF("Off"),
|
OFF,
|
||||||
TILE("Tile"),
|
TILE,
|
||||||
HULL("Hull"),
|
HULL,
|
||||||
SOUTH_WEST_TILE("South West Tile");
|
SOUTH_WEST_TILE
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
RenderStyle(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,23 +26,10 @@
|
|||||||
|
|
||||||
package net.runelite.client.plugins.prayer;
|
package net.runelite.client.plugins.prayer;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum PrayerFlickLocation
|
public enum PrayerFlickLocation
|
||||||
{
|
{
|
||||||
NONE("Off"),
|
NONE,
|
||||||
PRAYER_ORB("Prayer Orb"),
|
PRAYER_ORB,
|
||||||
PRAYER_BAR("Prayer Bar"),
|
PRAYER_BAR,
|
||||||
BOTH("Both");
|
BOTH
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -24,22 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.runepouch.config;
|
package net.runelite.client.plugins.runepouch.config;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum RunePouchOverlayMode
|
public enum RunePouchOverlayMode
|
||||||
{
|
{
|
||||||
INVENTORY("Inventory"),
|
INVENTORY,
|
||||||
MOUSE_HOVER("Mouse hover"),
|
MOUSE_HOVER,
|
||||||
BOTH("Both");
|
BOTH
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,22 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.worldhopper;
|
package net.runelite.client.plugins.worldhopper;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum SubscriptionFilterMode
|
public enum SubscriptionFilterMode
|
||||||
{
|
{
|
||||||
BOTH("Both"),
|
BOTH,
|
||||||
FREE("Free"),
|
FREE,
|
||||||
MEMBERS("Member");
|
MEMBERS
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,18 +35,10 @@ public interface XpTrackerConfig extends Config
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
enum OnScreenDisplayMode
|
enum OnScreenDisplayMode
|
||||||
{
|
{
|
||||||
XP_GAINED("XP Gained"),
|
XP_GAINED,
|
||||||
XP_LEFT("XP Left"),
|
XP_LEFT,
|
||||||
ACTIONS_DONE("Actions Done"),
|
ACTIONS_DONE,
|
||||||
ACTIONS_LEFT("Actions Left");
|
ACTIONS_LEFT
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import javax.swing.JList;
|
|||||||
import javax.swing.ListCellRenderer;
|
import javax.swing.ListCellRenderer;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import net.runelite.client.ui.ColorScheme;
|
import net.runelite.client.ui.ColorScheme;
|
||||||
|
import net.runelite.client.util.Text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A custom list renderer to avoid substance's weird coloring.
|
* A custom list renderer to avoid substance's weird coloring.
|
||||||
@@ -57,7 +58,16 @@ public final class ComboBoxListRenderer extends JLabel implements ListCellRender
|
|||||||
|
|
||||||
setBorder(new EmptyBorder(5, 5, 5, 0));
|
setBorder(new EmptyBorder(5, 5, 5, 0));
|
||||||
|
|
||||||
String text = o.toString();
|
String text;
|
||||||
|
if (o instanceof Enum)
|
||||||
|
{
|
||||||
|
text = Text.titleCase((Enum) o);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text = o.toString();
|
||||||
|
}
|
||||||
|
|
||||||
setText(text);
|
setText(text);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import com.google.common.base.Splitter;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import org.apache.commons.text.WordUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of utilities to use when dealing with text.
|
* A set of utilities to use when dealing with text.
|
||||||
@@ -159,4 +160,28 @@ public class Text
|
|||||||
String cleaned = name.contains("<img") ? name.substring(name.lastIndexOf('>') + 1) : name;
|
String cleaned = name.contains("<img") ? name.substring(name.lastIndexOf('>') + 1) : name;
|
||||||
return cleaned.replace('\u00A0', ' ');
|
return cleaned.replace('\u00A0', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If passed in enum doesn't implement its own toString,
|
||||||
|
* converts enum name format from THIS_FORMAT to This Format.
|
||||||
|
*
|
||||||
|
* @param o an enum
|
||||||
|
* @return the enum's name in title case,
|
||||||
|
* or if it overrides toString,
|
||||||
|
* the value returned by toString
|
||||||
|
*/
|
||||||
|
public static String titleCase(Enum o)
|
||||||
|
{
|
||||||
|
String toString = o.toString();
|
||||||
|
|
||||||
|
// .toString() returns the value of .name() if not overridden
|
||||||
|
if (o.name().equals(toString))
|
||||||
|
{
|
||||||
|
return WordUtils
|
||||||
|
.capitalize(toString.toLowerCase(), '_')
|
||||||
|
.replace("_", " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
return toString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user