2018-09-03 17:30:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
public static class BoxManipUtil
|
2018-09-03 17:30:35 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Grouped categories of different <see cref="IBoxManip"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static readonly IReadOnlyList<IBoxManip>[] ManipCategories =
|
2018-09-03 17:30:35 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
BoxManipDefaults.ClearCommon,
|
|
|
|
|
BoxManipDefaults.SortCommon,
|
|
|
|
|
BoxManipDefaults.SortAdvanced,
|
|
|
|
|
BoxManipDefaults.ModifyCommon,
|
|
|
|
|
};
|
2018-09-03 17:30:35 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public static readonly string[] ManipCategoryNames =
|
|
|
|
|
{
|
|
|
|
|
"Delete",
|
|
|
|
|
"Sort",
|
|
|
|
|
"SortAdvanced",
|
|
|
|
|
"Modify",
|
|
|
|
|
};
|
2018-09-03 17:30:35 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <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);
|
2018-09-03 17:30:35 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <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++)
|
2018-09-03 17:30:35 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (ManipCategories[i].Any(z => z.Type == type))
|
|
|
|
|
return ManipCategoryNames[i];
|
2018-09-03 17:30:35 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
return null;
|
|
|
|
|
}
|
2018-09-03 17:30:35 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <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++)
|
2018-09-03 17:30:35 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (ManipCategories[i].Any(z => z == manip))
|
|
|
|
|
return ManipCategoryNames[i];
|
2018-09-03 17:30:35 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
return null;
|
2018-09-03 17:30:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|