mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Improve example options
This commit is contained in:
1 parent
5cccc192b1
commit
7afd899e56
2 files changed
+31
-4
No files matched your search
@@ -6,7 +6,7 @@ using MiraAPI.Utilities;
|
|||||||
|
|
||||||
namespace MiraAPI.Example.Options.Roles;
|
namespace MiraAPI.Example.Options.Roles;
|
||||||
|
|
||||||
public class TeleporterOptions : AbstractOptionGroup<TeleporterRole>
|
public class TeleporterOptions : AbstractRoleOptionGroup<TeleporterRole>
|
||||||
{
|
{
|
||||||
public override string GroupName => "Teleporter";
|
public override string GroupName => "Teleporter";
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
using Il2CppInterop.Runtime.Attributes;
|
using Il2CppInterop.Runtime.Attributes;
|
||||||
using MiraAPI.Modifiers;
|
using MiraAPI.Modifiers;
|
||||||
|
using MiraAPI.Roles;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -79,9 +81,7 @@ public abstract class AbstractOptionGroup<T> : AbstractOptionGroup where T : IOp
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override Type OptionableType => typeof(T);
|
public override Type OptionableType => typeof(T);
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets a value indicating which menu the group is in.
|
|
||||||
/// </summary>
|
|
||||||
public override MenuCategory ParentMenu
|
public override MenuCategory ParentMenu
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -100,6 +100,33 @@ public abstract class AbstractOptionGroup<T> : AbstractOptionGroup where T : IOp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for option groups. An option group is a collection of options that are displayed together in the options menu.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The custom role that the group is for.</typeparam>
|
||||||
|
public abstract class AbstractRoleOptionGroup<T>() : AbstractOptionGroup<T> where T : ICustomRole
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override Type OptionableType => typeof(T);
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override MenuCategory ParentMenu => MenuCategory.Roles;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override OptionNotifConfiguration Configuration
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var role = CustomRoleManager.CustomMiraRoles.FirstOrDefault(x => x.GetType() == OptionableType);
|
||||||
|
if (role == null)
|
||||||
|
{
|
||||||
|
return new(new Color(0.7333f, 0.7333f, 0.7333f, 1));
|
||||||
|
}
|
||||||
|
return new(role.RoleColor, role.Configuration.IconTmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Menu categories for option groups.
|
/// Menu categories for option groups.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in new issue
Block a user