Options - All-Of-Us-Mods/MiraAPI-Docs GitHub Wiki

Options

Options are also very simple in Mira API. Options are split up into Groups and Options. Every Option needs to be in a Group.

To create a group, you need to create a class that implements the IModdedOptionGroup interface. Groups contain 4 properties, GroupName, GroupColor, GroupVisible, and AdvancedRole. Only the GroupName is required.

Here is an example of a group class:

public class MyOptionsGroup : IModdedOptionGroup
{
    public string GroupName => "My Options"; // this is required
    
    [ModdedNumberOption("My Number Option", min: 0, max: 10)]
    public float MyNumberOption { get; set; } = 5f;
}

You can access any group class using the ModdedGroupSingleton class like this:

// MyOptionsGroup is a class that implements IModdedOptionGroup
var myGroup = ModdedGroupSingleton<MyOptionsGroup>.Instance; // gets the instance of the group
System.Out.Console.WriteLine(myGroup.MyNumberOption); // prints the value of the option to the console

Once you have an options group, there are two ways to make the actual options:

  • Use an Option Attribute with a property.
  • Create a ModdedOption property.

This is an example of using an Option Attribute on a property:

// The first parameter is always the name of the option. The rest are dependent on the type of option.
[ModdedNumberOption("Sussy level", min: 0, max: 10)]
public float SussyLevel { get; set; } = 4f; // You can set a default value here.

And this is an example of a ModdedOption property:

public ModdedToggleOption YeezusAbility { get; } = new ModdedToggleOption("Yeezus Ability", false);

Here is a full list of ModdedOption classes you can use:

  • ModdedEnumOption
  • ModdedNumberOption
  • ModdedStringOption
  • ModdedToggleOption

Example

public class ExampleOptions : IModdedOptionGroup
{
    public string GroupName => "General Group";
    public Color GroupColor => Color.red;

    [ModdedToggleOption("Use Thing")]
    public bool UseThing { get; set; } = false;

    [ModdedToggleOption("Use another thing")]
    public bool UseAnotherThing { get; set; } = true;

    [ModdedNumberOption("Sussy level", min: 0, max: 10)]
    public float SussyLevel { get; set; } = 4f;

    [ModdedStringOption("Sus choices", ["hello", "hello 2", "hello 3"])]
    public int SusChoices { get; set; } = 2;

    [ModdedEnumOption("Enum test", typeof(TestEnum))]
    public TestEnum EnumTest { get; set; } = TestEnum.Bye;
}

public enum TestEnum
{
    Hello,
    Hi,
    Bye
}