# Config Options

## Adding options

### Creation

Options are added with Java annotations. Any field you annotate with an option will be saved to your config file, which you earlier specified in it's constructor. It'll then be displayed to the user within the OneConfig GUI.

```java
@Switch(
    name = "A random switch",
    size = OptionSize.DUAL, // optional, declares whether the element is single column or dual column
    category = "General", // optional
    subcategory = "Switches" // optional
)
public static boolean bob = false; // this is the default value.
```

### Accessing

Retrieving the value of your options is incredibly easy, as seen in the example below!

```java
System.out.println("My thing in a variable called bob: " + MyConfig.bob);
System.out.println("Is this enabled? " + MyConfig.enabled);
```

{% hint style="info" %}
Subcategories and Options are displayed in the order they are put in the config. You can have multiple subcategories with the same name, but this is not recommended unless it genuinely makes sense (e.g. "HUD Options" for two separate types of HUDs).
{% endhint %}

## Disabling Options

Disabled options are still visible to the user, but cannot be interacted with. You can disable them by adding dependencies.

If you wish to do this, go back to your config's constructer, and put in an `addDependency` line, as seen below. The first argument will specify which variable should be edited, given the value of the second argument.&#x20;

```java
@Switch(
    name = "Master Switch",
    size = OptionSize.DUAL
)
public static boolean masterSwitch = false;

@Switch(
    name = "Sub Switch",
    type = OptionType.SWITCH,
)
public static boolean subSwitch = false;

public TestConfig() {
    super(new Mod("My Mod", ModType.UTIL_QOL), "mymod.json");
    addDependency("subSwitch", () -> masterSwitch); // disable subSwitch if masterSwitch is off, making it dependant
}
```

## Other option features

### Sizes

Options come in two sizes in the GUI, `SINGLE` and `DUAL`. These are stored in a simple enum called `OptionSize`. Here is what a single and dual Text Field look like:

![Difference between Single and Dual Variants of a Text Field](/files/DQhMgsC8cnHqPa8bnov7)

## Option types

There are lots to choose from, so what are you waiting for?

{% content-ref url="/pages/ZUoTKIXDTL2N9gutr76I" %}
[Boolean Configs](/oneconfig/config/adding-options/boolean-config-components.md)
{% endcontent-ref %}

{% content-ref url="/pages/dU9D4OFOWwFPEcXNxAhP" %}
[Number Configs](/oneconfig/config/adding-options/number-config-components.md)
{% endcontent-ref %}

{% content-ref url="/pages/BnHA9PDq4S43hD6ZvbU3" %}
[Selector Configs](/oneconfig/config/adding-options/multi-config-components.md)
{% endcontent-ref %}

{% content-ref url="/pages/I7JKXEi0UaVn8XdGHZfm" %}
[Text Configs](/oneconfig/config/adding-options/text-configs.md)
{% endcontent-ref %}

{% content-ref url="/pages/6eVFq7GxrSoTPmiAtcEm" %}
[Buttons, Colors and Keybinds](/oneconfig/config/adding-options/buttons-colors-and-keybinds.md)
{% endcontent-ref %}

{% content-ref url="/pages/KsQA6RHonkLPePP1WS8v" %}
[Decorative Components](/oneconfig/config/adding-options/decorative-config-components.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.polyfrost.org/oneconfig/config/adding-options.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
