mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-11 14:14:57 -05:00
Update 'sorter'
Adds IV count sorting Adds Itemless & Illegal deleting Adds Max level modding, item clearing. Handle egg cases sensitively. remove final sortby for reversal case as the incremental integer prevents further ordering. Any suggestions? Keep in mind that some modifications can be done by the Batch Editor scripts; smart deletions & sorts are highest value additions ;)
This commit is contained in:
parent
9fd0432c41
commit
4b6ee3fbf5
|
|
@ -551,6 +551,29 @@ public static void ForceHatchPKM(this PKM pkm, bool reHatch = false)
|
|||
pkm.SetHatchMemory6();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maximizes the <see cref="PKM.CurrentFriendship"/>. If the <see cref="PKM.IsEgg"/>, the hatch counter is set to 1.
|
||||
/// </summary>
|
||||
/// <param name="pkm">PKM to apply hatch details to</param>
|
||||
public static void MaximizeFriendship(this PKM pkm)
|
||||
{
|
||||
if (pkm.IsEgg)
|
||||
pkm.OT_Friendship = 1;
|
||||
else
|
||||
pkm.CurrentFriendship = byte.MaxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maximizes the <see cref="PKM.CurrentLevel"/>. If the <see cref="PKM.IsEgg"/>, the <see cref="PKM"/> is ignored.
|
||||
/// </summary>
|
||||
/// <param name="pkm">PKM to apply hatch details to</param>
|
||||
public static void MaximizeLevel(this PKM pkm)
|
||||
{
|
||||
if (pkm.IsEgg)
|
||||
return;
|
||||
pkm.CurrentLevel = 100;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Memory details to a Hatched Egg's memories.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public static IEnumerable<PKM> ReverseSort(this IEnumerable<PKM> list)
|
|||
int i = 0;
|
||||
return list.InitialSortBy()
|
||||
.ThenByDescending(z => i++)
|
||||
.FinalSortBy();
|
||||
; // can't sort further
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public static ContextMenuStrip GetSortStrip(this SAVEditor sav)
|
|||
var sortMenu = new ContextMenuStrip();
|
||||
foreach (Level z in Enum.GetValues(typeof(Level)))
|
||||
{
|
||||
var ctrl = new ToolStripMenuItem(z.ToString(), GetImage(z));
|
||||
var ctrl = new ToolStripMenuItem {Name = $"mnu_{z}", Text = z.ToString(), Image = GetImage(z)};
|
||||
sortMenu.Items.Add(ctrl);
|
||||
}
|
||||
|
||||
|
|
@ -34,6 +34,8 @@ Image GetImage(Level l)
|
|||
AddItem(Level.Delete, GetItem("Eggs", "Eggs", () => Clear(pk => pk.IsEgg), Resources.about));
|
||||
AddItem(Level.Delete, GetItem("Foreign", "Foreign", () => Clear(pk => !sav.SAV.IsOriginalHandler(pk, pk.Format > 2)), Resources.users));
|
||||
AddItem(Level.Delete, GetItem("Untrained", "Untrained", () => Clear(pk => pk.EVTotal == 0), Resources.gift));
|
||||
AddItem(Level.Delete, GetItem("Itemless", "No Held Item", () => Clear(pk => pk.HeldItem == 0), Resources.main));
|
||||
AddItem(Level.Delete, GetItem("Illegal", "Illegal", () => Clear(pk => Control.ModifierKeys == Keys.Control != !new LegalityAnalysis(pk).Valid), Resources.export));
|
||||
|
||||
AddItem(Level.SortBox, GetItem("Species", "Pokédex No.", () => Sort(PKMSorting.OrderBySpecies), Resources.numlohi));
|
||||
AddItem(Level.SortBox, GetItem("SpeciesRev", "Pokédex No. (Reverse)", () => Sort(PKMSorting.OrderByDescendingSpecies), Resources.numhilo));
|
||||
|
|
@ -44,20 +46,23 @@ Image GetImage(Level l)
|
|||
AddItem(Level.SortBox, GetItem("Random", "Random", () => Sort(list => list.OrderByCustom(_ => Util.Rand32())), Resources.showdown));
|
||||
|
||||
AddItem(Level.SortBoxAdvanced, GetItem("Usage", "Usage", () => Sort(PKMSorting.OrderByUsage), Resources.heart));
|
||||
AddItem(Level.SortBoxAdvanced, GetItem("Training", "Training", () => Sort(list => list.OrderByCustom(pk => pk.MaxEV * 6 - pk.EVTotal)), Resources.showdown));
|
||||
AddItem(Level.SortBoxAdvanced, GetItem("Potential", "IV Potential", () => Sort(list => list.OrderByCustom(pk => pk.MaxIV * 6 - pk.IVTotal)), Resources.numhilo));
|
||||
AddItem(Level.SortBoxAdvanced, GetItem("Training", "EV Training", () => Sort(list => list.OrderByCustom(pk => pk.MaxEV * 6 - pk.EVTotal)), Resources.showdown));
|
||||
AddItem(Level.SortBoxAdvanced, GetItem("Owner", "Ownership", () => Sort(list => list.OrderByOwnership(sav.SAV)), Resources.users));
|
||||
AddItem(Level.SortBoxAdvanced, GetItem("Type", "Type", () => Sort(list => list.OrderByCustom(pk => pk.PersonalInfo.Type1, pk => pk.PersonalInfo.Type2)), Resources.main));
|
||||
AddItem(Level.SortBoxAdvanced, GetItem("Version", "Version", () => Sort(list => list.OrderByCustom(pk => pk.GenNumber, pk => pk.Version)), Resources.numlohi));
|
||||
AddItem(Level.SortBoxAdvanced, GetItem("BST", "BST", () => Sort(list => list.OrderByCustom(pk => pk.PersonalInfo.BST)), Resources.vallohi));
|
||||
AddItem(Level.SortBoxAdvanced, GetItem("BST", "Base Stat Total", () => Sort(list => list.OrderByCustom(pk => pk.PersonalInfo.BST)), Resources.vallohi));
|
||||
AddItem(Level.SortBoxAdvanced, GetItem("Legal", "Legal", () => Sort(list => list.OrderByCustom(pk => !new LegalityAnalysis(pk).Valid)), Resources.export));
|
||||
|
||||
AddItem(Level.Modify, GetItem("HatchEggs", "Hatch Eggs", () => Modify(z => z.ForceHatchPKM()), Resources.about));
|
||||
AddItem(Level.Modify, GetItem("MaxFriendship", "Max Friendship", () => Modify(z => z.CurrentFriendship = byte.MaxValue), Resources.heart));
|
||||
AddItem(Level.Modify, GetItem("MaxFriendship", "Max Friendship", () => Modify(z => z.MaximizeFriendship()), Resources.heart));
|
||||
AddItem(Level.Modify, GetItem("MaxLevel", "Max Level", () => Modify(z => z.MaximizeLevel()), Resources.showdown));
|
||||
AddItem(Level.Modify, GetItem("RemoveItem", "Delete Held Item", () => Modify(z => z.HeldItem = 0), Resources.gift));
|
||||
|
||||
void AddItem(Level v, ToolStripItem t)
|
||||
{
|
||||
var item = (ToolStripMenuItem)sortMenu.Items[(int) v];
|
||||
t.Name = $"mnu_{v}{t.Name}";
|
||||
t.Name = $"{item.Name}{t.Name}";
|
||||
item.DropDownItems.Add(t);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user