Table of Contents

Options

Creating an Option

To create an option, you'll need a few things.

You'll start with the parent class:

[Group(/* Tab = */ "MY STUFF", /* Group = */ "GENERAL")]
public static class MyOptions { }

This class is used to group all of your options together. The Group attribute is used to define the tab and category that the options will appear in.

Multiple groups in one tab

You can also have multiple groups in one tab! This is useful if you have a lot of options.

[Tab("MY STUFF")]
public static class MyOptions {
    [Group("GENERAL")]
    public static class General { }

    [Group("ADVANCED")]
    public static class Advanced { }
}

Then, the option class, which is placed inside your group class:

[Register]
private class MyOptionThing()
    : IntOption(Keys.MyOption, 50, "My Option!", 0, 100);
Note

For information about the Keys class, see State.

You'll notice a few things here. Let's break it down.

The [RegisterOption] comes from Register, and tells ConfigurableWarning to automatically register your option to the game, meaning that you don't have to do that!

The inherited class, IntOption, defines this as an IOption<T> with the int type for its value. This constructor takes a few arguments, namely:

  1. The option's name - Here it's "MyOption". This is used in the state and registry, and the end-user will likely never see it.
  2. The default value - Here it's 50.
  3. The option's display name - Here it's "My Option!". This is what the user will see in the settings menu.
  4. The minimum value - Here it's 0. This is the minumum value that the slider will go to.
  5. The maximum value - Here it's 100. This is the maximum value that the slider will go to.
Note

Unfortunately, due to the nature of how Zorro's Settings API works, each option has to be its own class.