From 57c625d0898e20560ea1bb6c2d07ee121df5ec1a Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 30 Apr 2018 17:29:13 -0700 Subject: [PATCH] Add delete criteria method providing for box clear Can opt to not delete a slot --- PKHeX.Core/Saves/SaveFile.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Saves/SaveFile.cs b/PKHeX.Core/Saves/SaveFile.cs index a33fb6a9b..bb6ff7a7a 100644 --- a/PKHeX.Core/Saves/SaveFile.cs +++ b/PKHeX.Core/Saves/SaveFile.cs @@ -601,7 +601,7 @@ public void SortBoxes(int BoxStart = 0, int BoxEnd = -1, Func, Sorted.CopyTo(BD, start); BoxData = BD; } - public void ClearBoxes(int BoxStart = 0, int BoxEnd = -1) + public void ClearBoxes(int BoxStart = 0, int BoxEnd = -1, Func deleteCriteria = null) { if (BoxEnd < 0) BoxEnd = BoxCount - 1; @@ -614,7 +614,17 @@ public void ClearBoxes(int BoxStart = 0, int BoxEnd = -1) { int offset = GetBoxOffset(i); for (int p = 0; p < BoxSlotCount; p++) - SetData(blank, offset + SIZE_STORED * p); + { + var ofs = offset + SIZE_STORED * p; + if (deleteCriteria != null) + { + var pk = GetStoredSlot(ofs); + if (!deleteCriteria(pk)) + continue; + } + + SetData(blank, ofs); + } } } public void ModifyBoxes(Action action, int BoxStart = 0, int BoxEnd = -1)