Skip to content

Commit

Permalink
add group priorities for ordering groups
Browse files Browse the repository at this point in the history
  • Loading branch information
XtraCube committed Sep 4, 2024
1 parent 9c14db0 commit f83dce9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MiraAPI.Example/Options/ExampleOptions2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class ExampleOptions2 : AbstractOptionGroup
{
public override string GroupName => "Example Options 2";

public override uint GroupPriority => 0; // This group will be displayed first. The default value is uint.MaxValue.

public ModdedToggleOption ToggleOpt1 { get; } = new("Toggle Option 1", false);

public ModdedToggleOption ToggleOpt2 { get; } = new("Toggle Option 2", false)
Expand Down
6 changes: 6 additions & 0 deletions MiraAPI/GameOptions/AbstractOptionGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public abstract class AbstractOptionGroup
/// </summary>
public virtual Color GroupColor => Color.clear;

/// <summary>
/// Gets the group priority. This is used to determine the order in which groups are displayed in the options menu.
/// Zero is the highest priority, and the default value is the max uint value.
/// </summary>
public virtual uint GroupPriority => uint.MaxValue;

/// <summary>
/// Gets the role the group is associated with. This is used for the advanced role options menu.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions MiraAPI/PluginLoading/MiraPluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ private static void RegisterAllOptions(Assembly assembly, MiraPluginInfo pluginI
ModdedOptionsManager.RegisterAttributeOption(type, attribute, property, pluginInfo);
}
}

pluginInfo.OptionGroups.Sort((x, y) => x.GroupPriority.CompareTo(y.GroupPriority));
}

private static void RegisterRoleAttribute(Assembly assembly, MiraPluginInfo pluginInfo)
Expand Down

0 comments on commit f83dce9

Please sign in to comment.