From 9cf237a1f633738b5908f7ca0e6737de51c9f990 Mon Sep 17 00:00:00 2001 From: Ganom <8338284+Ganom@users.noreply.github.com> Date: Sun, 18 Oct 2020 22:45:42 -0400 Subject: [PATCH] config: add documentation for items and sections. (#2829) --- .../runelite/client/config/ConfigItem.java | 93 ++++++++++++++++++- .../runelite/client/config/ConfigSection.java | 51 ++++++++++ .../client/config/ConfigTitleSection.java | 55 +++++++++++ 3 files changed, 198 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java index b704ec0f08..2863e3f6a3 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java @@ -33,36 +33,127 @@ import java.lang.annotation.Target; @Target(ElementType.METHOD) public @interface ConfigItem { + /** + * If there is a section set, it will display in order + * starting from lowest value and ending at highest value + * in that specific section. Else, it will display in order + * for the config panel in a whole. + * + * @return The index of the config item. + */ int position() default -1; + /** + * This is not visible to users + * + * @return name used for finding the config item + * from the properties map. Hence, KEY name. + */ String keyName(); + /** + * This is the name that is shown to users when looking + * at the config panel. + *

+ * Choose a name carefully, as there is a maximum width + * that depends on the users DPI scaling. Short is best. + * + * @return display name for the config item. + */ String name(); + /** + * This will be shown to the user if they are hovering + * the config item in the config panel. + * + * @return the description of the config item. + */ String description(); + /** + * If this is set to true, the config field will be + * hidden. You are able to change this value at runtime + * by having another config field unhide it {@link #unhide()} + */ boolean hidden() default false; + /** + * This is only used for {@link Boolean} config fields. + *

+ * If this is set, then a warning(y/n) will be displayed + * when the user enables said config field. If they accept + * then the value will be set updated. + * + * @return a warning for enabling the config field. + */ String warning() default ""; + /** + * This is only used for {@link String} config fields. + *

+ * If this is set to true, any input from the user + * will be hidden, and not displayed. This should + * be used for any sensitive information that may + * be accidentally leaked. + *

+ * For example; api keys. + */ boolean secret() default false; + /** + * If this is set, it will look for a section + * by that {@link ConfigSection#name()}, if it exists, + * it will insert the config item under that + * section in order. + * + * @return title of the section. + */ String section() default ""; + /** + * If this is set, it will look for a title section + * by that {@link ConfigTitleSection#name()}, if it exists, + * it will insert the config item under that + * section in order. + * + * @return title of the section. + */ String titleSection() default ""; + /** + * If this is set, it will look for a config item + * by that name. If it is hidden, it will unhide the item. + * + * @return {@link #name()} to unhide. + */ String unhide() default ""; String unhideValue() default ""; + /** + * If this is set, it will look for a config item + * by that name. If it is not hidden, it will hide the item. + * + * @return {@link #name()} to hide. + */ String hide() default ""; String hideValue() default ""; + /** + * If this is set, it will look for a config item + * by the name provided, if that config item is enabled + * then this item will also be enabled. + */ String enabledBy() default ""; String enabledByValue() default ""; + /** + * If this is set, it will look for a config item + * by the name provided, if that config item is disabled + * then this item will also be disabled. + */ String disabledBy() default ""; String disabledByValue() default ""; @@ -81,4 +172,4 @@ public @interface ConfigItem */ Class enumClass() default Enum.class; -} \ No newline at end of file +} diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigSection.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigSection.java index 4cc17008fc..cb243f6692 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigSection.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigSection.java @@ -33,25 +33,76 @@ import java.lang.annotation.Target; @Target(ElementType.METHOD) public @interface ConfigSection { + /** + * Displayed position of the section. + * + * @return The index of the section. + */ int position(); + /** + * This is not visible to users + * + * @return name used for finding the config section + * from the properties map. Hence, KEY name. + */ String keyName(); + /** + * This is the name that is shown to users when looking + * at the config panel. + *

+ * Choose a name carefully, as there is a maximum width + * that depends on the users DPI scaling. Short is best. + * + * @return display name for the config section. + */ String name(); + /** + * This will be shown to the user if they are hovering + * the config item in the config panel. + * + * @return the description of the config item. + */ String description(); + /** + * Setting this will tell the panel + * that this section should be placed beneath + * said section. + * + * @return parent section. + */ String section() default ""; + /** + * NOT USED. + */ String titleSection() default ""; + /** + * NOT USED. + */ boolean hidden() default false; + /** + * NOT USED. + */ String unhide() default ""; + /** + * NOT USED. + */ String unhideValue() default ""; + /** + * NOT USED. + */ String hide() default ""; + /** + * NOT USED. + */ String hideValue() default ""; } diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigTitleSection.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigTitleSection.java index 435ed7885f..0b63aec49e 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigTitleSection.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigTitleSection.java @@ -33,25 +33,80 @@ import java.lang.annotation.Target; @Target(ElementType.METHOD) public @interface ConfigTitleSection { + /** + * Displayed position of the title section. + * + * @return The index of the title section. + */ int position(); + /** + * This is not visible to users + * + * @return name used for finding the config section + * from the properties map. Hence, KEY name. + */ String keyName(); + /** + * This is the name that is shown to users when looking + * at the config panel. + *

+ * Choose a name carefully, as there is a maximum width + * that depends on the users DPI scaling. Short is best. + * + * @return display name for the config title section. + */ String name(); + /** + * This will be shown to the user if they are hovering + * the config item in the config panel. + * + * @return the description of the config item. + */ String description(); + /** + * Setting this will tell the panel + * that this title should be placed beneath + * said section. + * + * @return parent section. + */ String section() default ""; + /** + * Setting this will tell the panel + * that this title should be placed beneath + * said title. + * + * @return parent title section. + */ String titleSection() default ""; + /** + * NOT USED. + */ boolean hidden() default false; + /** + * NOT USED. + */ String unhide() default ""; + /** + * NOT USED. + */ String unhideValue() default ""; + /** + * NOT USED. + */ String hide() default ""; + /** + * NOT USED. + */ String hideValue() default ""; }