Add delete criteria method providing for box clear

Can opt to not delete a slot
This commit is contained in:
Kurt 2018-04-30 17:29:13 -07:00
parent ea2c6260fa
commit 57c625d089

View File

@ -601,7 +601,7 @@ public void SortBoxes(int BoxStart = 0, int BoxEnd = -1, Func<IEnumerable<PKM>,
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<PKM, bool> 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<PKM> action, int BoxStart = 0, int BoxEnd = -1)