From c11fe14fd219e4797a9dcc7d400ee1afe6a5cd79 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:17:45 -0400 Subject: [PATCH] Update README.md --- README.md | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0033b63..fbf2979 100644 --- a/README.md +++ b/README.md @@ -32,28 +32,43 @@ See [this file](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Ex ## 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 two properties, the `GroupName` and `GroupColor`. +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. -The easiest way to create an option within this group is to make a property within a class and assign one of the various Options Attributes listed below: +You can access any group class using the `ModdedGroupSingleton` class like this: +``` +// MyOptionsGroup is a class that implements IModdedOptionGroup +var myGroup = ModdedGroupSingleton.Instance; +``` + +There are two ways to make options inside a group: +- Use an Option Attribute with a property. +- Create a ModdedOption property. + +This is an example of using an Option Attribute on a property: +```csharp +// 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: +```csharp +public ModdedToggleOption YeezusAbility { get; } = new ModdedToggleOption("Yeezus Ability", false); +``` + +Here is a full list of ModdedOption classes you can use: - `ModdedEnumOption` - `ModdedNumberOption` - `ModdedStringOption` - `ModdedToggleOption` -They are used like this: -```csharp -// 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. -``` - -To see a full example, see [this file](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/ExampleOptions.cs). +To see a full example of an options class, see [this file](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/ExampleOptions.cs). ### Role Options -Options can also be used within a Role class to show up in that Role's settings. To do this, simply add your option property to the Role class and specify the `roleType` parameter in the Option attribute. +Options can also be used within a Role class to show up in that Role's settings. To set the role for an entire group, set the `AdvancedRole` property on that group. To set the role for individual options, specify the `roleType` parameter in the option. -An example can be found [here](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/CustomRole2.cs). +An example can be found [here](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/Options/Roles/CustomRoleSettings.cs). ## Buttons