mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-09 04:24:36 -05:00
update box manipulation
closes #1911 , changes end to be inclusive rather than exclusive. abuse the optional to let it fill in the end caps.
This commit is contained in:
parent
a6903953a0
commit
15ce1acfdb
|
|
@ -593,8 +593,8 @@ public void SortBoxes(int BoxStart = 0, int BoxEnd = -1, Func<IEnumerable<PKM>,
|
|||
var BD = BoxData;
|
||||
int start = BoxSlotCount * BoxStart;
|
||||
var Section = BD.Skip(start);
|
||||
if (BoxEnd > BoxStart)
|
||||
Section = Section.Take(BoxSlotCount * (BoxEnd - BoxStart));
|
||||
if (BoxEnd >= BoxStart)
|
||||
Section = Section.Take(BoxSlotCount * (BoxEnd - BoxStart + 1));
|
||||
|
||||
var Sorted = (sortMethod ?? PKMSorting.OrderBySpecies)(Section);
|
||||
|
||||
|
|
@ -604,13 +604,13 @@ public void SortBoxes(int BoxStart = 0, int BoxEnd = -1, Func<IEnumerable<PKM>,
|
|||
public void ClearBoxes(int BoxStart = 0, int BoxEnd = -1)
|
||||
{
|
||||
if (BoxEnd < 0)
|
||||
BoxEnd = BoxCount;
|
||||
BoxEnd = BoxCount - 1;
|
||||
|
||||
var blank = BlankPKM.EncryptedBoxData;
|
||||
if (this is SAV3RSBox)
|
||||
Array.Resize(ref blank, blank.Length + 4); // 00000 TID/SID at end
|
||||
|
||||
for (int i = BoxStart; i < BoxEnd; i++)
|
||||
for (int i = BoxStart; i <= BoxEnd; i++)
|
||||
{
|
||||
int offset = GetBoxOffset(i);
|
||||
for (int p = 0; p < BoxSlotCount; p++)
|
||||
|
|
@ -620,9 +620,9 @@ public void ClearBoxes(int BoxStart = 0, int BoxEnd = -1)
|
|||
public void ModifyBoxes(Action<PKM> action, int BoxStart = 0, int BoxEnd = -1)
|
||||
{
|
||||
if (BoxEnd < 0)
|
||||
BoxEnd = BoxCount;
|
||||
BoxEnd = BoxCount - 1;
|
||||
var BD = BoxData;
|
||||
for (int b = BoxStart; b < BoxEnd; b++)
|
||||
for (int b = BoxStart; b <= BoxEnd; b++)
|
||||
for (int s = 0; s < BoxSlotCount; s++)
|
||||
{
|
||||
if (IsSlotLocked(b, s))
|
||||
|
|
|
|||
|
|
@ -392,32 +392,32 @@ public void ClearCurrent()
|
|||
{
|
||||
if (!CanManipulateRegion(Box.CurrentBox, Box.CurrentBox, MsgSaveBoxClearCurrent, MsgSaveBoxClearCurrentFailBattle))
|
||||
return;
|
||||
SAV.ClearBoxes(Box.CurrentBox, Box.CurrentBox + 1);
|
||||
SAV.ClearBoxes(Box.CurrentBox, Box.CurrentBox);
|
||||
FinishBoxManipulation(MsgSaveBoxClearCurrentSuccess, false);
|
||||
}
|
||||
public void SortAll(Func<IEnumerable<PKM>, IEnumerable<PKM>> sorter)
|
||||
{
|
||||
if (!CanManipulateRegion(0, SAV.BoxCount - 1, MsgSaveBoxSortAll, MsgSaveBoxSortAllFailBattle))
|
||||
return;
|
||||
SAV.SortBoxes(0, SAV.BoxCount - 1, sorter);
|
||||
SAV.SortBoxes(sortMethod: sorter);
|
||||
FinishBoxManipulation(MsgSaveBoxSortAllSuccess, true);
|
||||
}
|
||||
public void SortCurrent(Func<IEnumerable<PKM>, IEnumerable<PKM>> sorter)
|
||||
{
|
||||
if (!CanManipulateRegion(Box.CurrentBox, Box.CurrentBox, MsgSaveBoxSortCurrent, MsgSaveBoxSortCurrentFailBattle))
|
||||
return;
|
||||
SAV.SortBoxes(Box.CurrentBox, Box.CurrentBox + 1, sorter);
|
||||
SAV.SortBoxes(Box.CurrentBox, Box.CurrentBox, sorter);
|
||||
FinishBoxManipulation(MsgSaveBoxSortCurrentSuccess, false);
|
||||
}
|
||||
public void ModifyAll(Action<PKM> action)
|
||||
{
|
||||
SAV.ModifyBoxes(action, 0, SAV.BoxCount - 1);
|
||||
SAV.ModifyBoxes(action);
|
||||
FinishBoxManipulation(null, true);
|
||||
SystemSounds.Asterisk.Play();
|
||||
}
|
||||
public void ModifyCurrent(Action<PKM> action)
|
||||
{
|
||||
SAV.ModifyBoxes(action, Box.CurrentBox, Box.CurrentBox + 1);
|
||||
SAV.ModifyBoxes(action, Box.CurrentBox, Box.CurrentBox);
|
||||
FinishBoxManipulation(null, true);
|
||||
SystemSounds.Asterisk.Play();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user