mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-22 18:33:14 +00:00
fc754b346b
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces) Updates all the files, one less level of indentation. Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
63 lines
2 KiB
C#
63 lines
2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
public static class BoxManipUtil
|
|
{
|
|
/// <summary>
|
|
/// Grouped categories of different <see cref="IBoxManip"/>.
|
|
/// </summary>
|
|
public static readonly IReadOnlyList<IBoxManip>[] ManipCategories =
|
|
{
|
|
BoxManipDefaults.ClearCommon,
|
|
BoxManipDefaults.SortCommon,
|
|
BoxManipDefaults.SortAdvanced,
|
|
BoxManipDefaults.ModifyCommon,
|
|
};
|
|
|
|
public static readonly string[] ManipCategoryNames =
|
|
{
|
|
"Delete",
|
|
"Sort",
|
|
"SortAdvanced",
|
|
"Modify",
|
|
};
|
|
|
|
/// <summary>
|
|
/// Gets a <see cref="IBoxManip"/> reference that carries out the action of the requested <see cref="type"/>.
|
|
/// </summary>
|
|
/// <param name="type">Manipulation type.</param>
|
|
/// <returns>Reference to <see cref="IBoxManip"/>.</returns>
|
|
public static IBoxManip GetManip(this BoxManipType type) => ManipCategories.SelectMany(c => c).First(m => m.Type == type);
|
|
|
|
/// <summary>
|
|
/// Gets the corresponding name from <see cref="ManipCategoryNames"/> for the requested <see cref="type"/>.
|
|
/// </summary>
|
|
/// <param name="type">Manipulation type.</param>
|
|
/// <returns>Category Name</returns>
|
|
public static string? GetManipCategoryName(this BoxManipType type)
|
|
{
|
|
for (int i = 0; i < ManipCategories.Length; i++)
|
|
{
|
|
if (ManipCategories[i].Any(z => z.Type == type))
|
|
return ManipCategoryNames[i];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the corresponding name from <see cref="ManipCategoryNames"/> for the requested <see cref="manip"/>.
|
|
/// </summary>
|
|
/// <param name="manip">Manipulation type.</param>
|
|
/// <returns>Category Name</returns>
|
|
public static string? GetManipCategoryName(this IBoxManip manip)
|
|
{
|
|
for (int i = 0; i < ManipCategories.Length; i++)
|
|
{
|
|
if (ManipCategories[i].Any(z => z == manip))
|
|
return ManipCategoryNames[i];
|
|
}
|
|
return null;
|
|
}
|
|
}
|