Misc database tweaks

delete now interacts with the box manager, now clears from any box
viewer that is open
filtering to just boxes now filters out the external sav pkm
filtering sources now is done prior to any field filtering
This commit is contained in:
Kurt 2017-06-11 11:08:03 -07:00
parent 5117f3a5c9
commit ffa7529e0f

View file

@ -220,16 +220,13 @@ namespace PKHeX.WinForms
int offset = SAV.getBoxOffset(box) + slot*SAV.SIZE_STORED;
PKM pkSAV = SAV.getStoredSlot(offset);
if (pkSAV.Data.SequenceEqual(pk.Data))
{
SAV.setStoredSlot(SAV.BlankPKM, offset);
BoxView.setPKXBoxes();
}
else
if (!pkSAV.Data.SequenceEqual(pk.Data)) // data still exists in SAV, unmodified
{
WinFormsUtil.Error("Database slot data does not match save data!", "Don't move Pokémon after initializing the Database, please re-open the Database viewer.");
return;
}
var change = new SlotChange {Box = box, Offset = offset, Slot = slot};
BoxView.M.SetPKM(BoxView.SAV.BlankPKM, change, true, Properties.Resources.slotDel);
}
// Remove from database.
RawDB.Remove(pk);
@ -402,6 +399,17 @@ namespace PKHeX.WinForms
// Populate Search Query Result
IEnumerable<PKM> res = RawDB;
// Filter for Selected Source
if (!Menu_SearchBoxes.Checked)
res = res.Where(pk => pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal));
if (!Menu_SearchDatabase.Checked)
{
res = res.Where(pk => !pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal));
#if DEBUG
res = res.Where(pk => !pk.Identifier.StartsWith(EXTERNAL_SAV, StringComparison.Ordinal));
#endif
}
int format = MAXFORMAT + 1 - CB_Format.SelectedIndex;
switch (CB_FormatComparator.SelectedIndex)
{
@ -518,12 +526,6 @@ namespace PKHeX.WinForms
break;
}
// Filter for Selected Source
if (!Menu_SearchBoxes.Checked)
res = res.Where(pk => pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal));
if (!Menu_SearchDatabase.Checked)
res = res.Where(pk => !pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal));
slotSelected = -1; // reset the slot last viewed
if (Menu_SearchLegal.Checked && !Menu_SearchIllegal.Checked)