2019-09-11 05:07:50 +00:00
|
|
|
|
using System;
|
2016-12-30 02:11:51 +00:00
|
|
|
|
using System.Collections.Concurrent;
|
2015-10-06 01:51:52 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
2015-12-20 00:29:44 +00:00
|
|
|
|
using System.Drawing;
|
2015-10-06 01:51:52 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2016-12-29 23:24:02 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2015-10-06 01:51:52 +00:00
|
|
|
|
using System.Windows.Forms;
|
2017-01-08 07:54:09 +00:00
|
|
|
|
using PKHeX.Core;
|
2018-08-17 03:06:40 +00:00
|
|
|
|
using PKHeX.Core.Searching;
|
2021-11-27 23:48:08 +00:00
|
|
|
|
using PKHeX.Drawing.PokeSprite;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
using PKHeX.WinForms.Controls;
|
2019-08-15 05:51:49 +00:00
|
|
|
|
using PKHeX.WinForms.Properties;
|
2018-04-07 04:23:09 +00:00
|
|
|
|
using static PKHeX.Core.MessageStrings;
|
2015-10-06 01:51:52 +00:00
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.WinForms
|
2015-10-06 01:51:52 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class SAV_Database : Form
|
|
|
|
|
{
|
2017-05-23 04:55:05 +00:00
|
|
|
|
private readonly SaveFile SAV;
|
|
|
|
|
private readonly SAVEditor BoxView;
|
|
|
|
|
private readonly PKMEditor PKME_Tabs;
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
public SAV_Database(PKMEditor f1, SAVEditor saveditor)
|
2015-10-06 01:51:52 +00:00
|
|
|
|
{
|
2018-04-03 03:36:13 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
|
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
SAV = saveditor.SAV;
|
|
|
|
|
BoxView = saveditor;
|
|
|
|
|
PKME_Tabs = f1;
|
2016-07-10 17:33:01 +00:00
|
|
|
|
|
|
|
|
|
// Preset Filters to only show PKM available for loaded save
|
|
|
|
|
CB_FormatComparator.SelectedIndex = 3; // <=
|
2019-11-16 23:56:30 +00:00
|
|
|
|
|
|
|
|
|
var grid = DatabasePokeGrid;
|
|
|
|
|
var smallWidth = grid.Width;
|
|
|
|
|
var smallHeight = grid.Height;
|
|
|
|
|
grid.InitializeGrid(6, 11, SpriteUtil.Spriter);
|
|
|
|
|
grid.SetBackground(Resources.box_wp_clean);
|
|
|
|
|
var newWidth = grid.Width;
|
|
|
|
|
var newHeight = grid.Height;
|
|
|
|
|
var wdelta = newWidth - smallWidth;
|
|
|
|
|
if (wdelta != 0)
|
|
|
|
|
Width += wdelta;
|
|
|
|
|
var hdelta = newHeight - smallHeight;
|
|
|
|
|
if (hdelta != 0)
|
|
|
|
|
Height += hdelta;
|
|
|
|
|
PKXBOXES = grid.Entries.ToArray();
|
2015-10-08 03:19:34 +00:00
|
|
|
|
|
|
|
|
|
// Enable Scrolling when hovered over
|
|
|
|
|
foreach (var slot in PKXBOXES)
|
|
|
|
|
{
|
|
|
|
|
// Enable Click
|
2017-07-06 01:39:53 +00:00
|
|
|
|
slot.MouseClick += (sender, e) =>
|
2015-10-08 03:19:34 +00:00
|
|
|
|
{
|
2020-11-14 16:20:48 +00:00
|
|
|
|
if (sender == null)
|
|
|
|
|
return;
|
2019-09-11 05:07:50 +00:00
|
|
|
|
switch (ModifierKeys)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Control: ClickView(sender, e); break;
|
|
|
|
|
case Keys.Alt: ClickDelete(sender, e); break;
|
|
|
|
|
case Keys.Shift: ClickSet(sender, e); break;
|
|
|
|
|
}
|
2015-10-08 03:19:34 +00:00
|
|
|
|
};
|
2019-08-15 05:51:49 +00:00
|
|
|
|
|
2019-10-28 03:39:07 +00:00
|
|
|
|
slot.ContextMenuStrip = mnu;
|
2021-04-12 01:09:54 +00:00
|
|
|
|
if (Main.Settings.Hover.HoverSlotShowText)
|
2020-10-18 18:02:39 +00:00
|
|
|
|
slot.MouseEnter += (o, args) => ShowHoverTextForSlot(slot, args);
|
2015-10-08 03:19:34 +00:00
|
|
|
|
}
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
2015-10-08 03:19:34 +00:00
|
|
|
|
Counter = L_Count.Text;
|
2015-10-12 07:10:40 +00:00
|
|
|
|
Viewed = L_Viewed.Text;
|
2019-09-11 05:07:50 +00:00
|
|
|
|
L_Viewed.Text = string.Empty; // invisible for now
|
2017-06-18 01:37:19 +00:00
|
|
|
|
PopulateComboBoxes();
|
2015-10-08 03:19:34 +00:00
|
|
|
|
|
2016-08-03 00:40:20 +00:00
|
|
|
|
// Load Data
|
2017-09-05 05:22:02 +00:00
|
|
|
|
B_Search.Enabled = false;
|
|
|
|
|
L_Count.Text = "Loading...";
|
2020-11-28 22:53:32 +00:00
|
|
|
|
var task = new Task(LoadDatabase);
|
|
|
|
|
task.ContinueWith(z =>
|
|
|
|
|
{
|
|
|
|
|
if (!z.IsFaulted)
|
|
|
|
|
return;
|
|
|
|
|
Invoke((MethodInvoker)(() => L_Count.Text = "Failed."));
|
|
|
|
|
if (z.Exception == null)
|
|
|
|
|
return;
|
|
|
|
|
WinFormsUtil.Error("Loading database failed.", z.Exception.InnerException ?? new Exception(z.Exception.Message));
|
|
|
|
|
});
|
|
|
|
|
task.Start();
|
2016-08-03 00:40:20 +00:00
|
|
|
|
|
2016-03-23 03:30:48 +00:00
|
|
|
|
Menu_SearchSettings.DropDown.Closing += (sender, e) =>
|
2016-03-23 03:14:11 +00:00
|
|
|
|
{
|
|
|
|
|
if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
};
|
2018-04-07 04:23:09 +00:00
|
|
|
|
CB_Format.Items[0] = MsgAny;
|
2016-04-15 23:11:46 +00:00
|
|
|
|
CenterToParent();
|
2015-10-06 01:51:52 +00:00
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2016-01-17 21:27:24 +00:00
|
|
|
|
private readonly PictureBox[] PKXBOXES;
|
|
|
|
|
private readonly string DatabasePath = Main.DatabasePath;
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
private List<SlotCache> Results = new();
|
|
|
|
|
private List<SlotCache> RawDB = new();
|
2015-10-10 17:28:24 +00:00
|
|
|
|
private int slotSelected = -1; // = null;
|
2020-10-18 18:02:39 +00:00
|
|
|
|
private Image? slotColor;
|
2015-10-10 17:28:24 +00:00
|
|
|
|
private const int RES_MAX = 66;
|
|
|
|
|
private const int RES_MIN = 6;
|
2016-01-17 21:27:24 +00:00
|
|
|
|
private readonly string Counter;
|
|
|
|
|
private readonly string Viewed;
|
2018-04-07 04:23:09 +00:00
|
|
|
|
private const int MAXFORMAT = PKX.Generation;
|
2020-12-22 07:37:07 +00:00
|
|
|
|
private readonly SummaryPreviewer ShowSet = new();
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2015-10-10 17:28:24 +00:00
|
|
|
|
// Important Events
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ClickView(object sender, EventArgs e)
|
2015-10-06 01:51:52 +00:00
|
|
|
|
{
|
2019-09-25 01:14:15 +00:00
|
|
|
|
var pb = WinFormsUtil.GetUnderlyingControl<PictureBox>(sender);
|
|
|
|
|
int index = Array.IndexOf(PKXBOXES, pb);
|
2019-08-15 05:51:49 +00:00
|
|
|
|
if (!GetShiftedIndex(ref index))
|
2015-10-08 03:19:34 +00:00
|
|
|
|
{
|
2017-04-19 10:15:50 +00:00
|
|
|
|
System.Media.SystemSounds.Exclamation.Play();
|
|
|
|
|
return;
|
2015-10-08 03:19:34 +00:00
|
|
|
|
}
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
if (sender == mnu)
|
|
|
|
|
mnu.Hide();
|
|
|
|
|
|
2017-04-19 10:15:50 +00:00
|
|
|
|
slotSelected = index;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
slotColor = SpriteUtil.Spriter.View;
|
2017-04-19 10:15:50 +00:00
|
|
|
|
FillPKXBoxes(SCR_Box.Value);
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
L_Viewed.Text = string.Format(Viewed, Results[index].Identify());
|
|
|
|
|
PKME_Tabs.PopulateFields(Results[index].Entity, false);
|
2015-10-06 01:51:52 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ClickDelete(object sender, EventArgs e)
|
2015-11-15 02:17:54 +00:00
|
|
|
|
{
|
2019-09-25 01:14:15 +00:00
|
|
|
|
var pb = WinFormsUtil.GetUnderlyingControl<PictureBox>(sender);
|
|
|
|
|
int index = Array.IndexOf(PKXBOXES, pb);
|
2019-08-15 05:51:49 +00:00
|
|
|
|
if (!GetShiftedIndex(ref index))
|
2017-04-19 10:15:50 +00:00
|
|
|
|
{
|
|
|
|
|
System.Media.SystemSounds.Exclamation.Play();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
var entry = Results[index];
|
|
|
|
|
var pk = entry.Entity;
|
2017-04-19 10:15:50 +00:00
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
if (entry.Source is SlotInfoFile f)
|
2017-04-19 10:15:50 +00:00
|
|
|
|
{
|
|
|
|
|
// Data from Database: Delete file from disk
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
var path = f.Path;
|
2017-06-10 06:13:41 +00:00
|
|
|
|
if (File.Exists(path))
|
|
|
|
|
File.Delete(path);
|
2017-04-19 10:15:50 +00:00
|
|
|
|
}
|
2021-12-10 03:30:12 +00:00
|
|
|
|
else if (entry.Source is SlotInfoBox(var box, var slot) && entry.SAV == SAV)
|
2015-11-15 02:17:54 +00:00
|
|
|
|
{
|
2017-04-19 10:15:50 +00:00
|
|
|
|
// Data from Box: Delete from save file
|
2019-09-03 02:30:58 +00:00
|
|
|
|
var change = new SlotInfoBox(box, slot);
|
|
|
|
|
var pkSAV = change.Read(SAV);
|
2015-11-15 02:17:54 +00:00
|
|
|
|
|
2018-01-27 18:15:56 +00:00
|
|
|
|
if (!pkSAV.DecryptedBoxData.SequenceEqual(pk.DecryptedBoxData)) // data still exists in SAV, unmodified
|
2015-11-15 02:17:54 +00:00
|
|
|
|
{
|
2018-04-07 04:23:09 +00:00
|
|
|
|
WinFormsUtil.Error(MsgDBDeleteFailModified, MsgDBDeleteFailWarning);
|
2017-04-19 10:15:50 +00:00
|
|
|
|
return;
|
2015-11-15 02:17:54 +00:00
|
|
|
|
}
|
2019-09-03 02:30:58 +00:00
|
|
|
|
BoxView.EditEnv.Slots.Delete(change);
|
2015-11-15 02:17:54 +00:00
|
|
|
|
}
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WinFormsUtil.Error(MsgDBDeleteFailBackup, MsgDBDeleteFailWarning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-04-19 10:15:50 +00:00
|
|
|
|
// Remove from database.
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
RawDB.Remove(entry);
|
|
|
|
|
Results.Remove(entry);
|
2017-04-19 10:15:50 +00:00
|
|
|
|
// Refresh database view.
|
|
|
|
|
L_Count.Text = string.Format(Counter, Results.Count);
|
|
|
|
|
slotSelected = -1;
|
|
|
|
|
FillPKXBoxes(SCR_Box.Value);
|
|
|
|
|
System.Media.SystemSounds.Asterisk.Play();
|
2015-11-15 02:17:54 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ClickSet(object sender, EventArgs e)
|
2015-11-15 03:41:39 +00:00
|
|
|
|
{
|
|
|
|
|
// Don't care what slot was clicked, just add it to the database
|
2019-02-10 01:07:44 +00:00
|
|
|
|
if (!PKME_Tabs.EditsComplete)
|
2015-11-15 03:41:39 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
PKM pk = PKME_Tabs.PreparePKM();
|
2017-10-03 06:13:40 +00:00
|
|
|
|
Directory.CreateDirectory(DatabasePath);
|
2015-11-15 03:41:39 +00:00
|
|
|
|
|
|
|
|
|
string path = Path.Combine(DatabasePath, Util.CleanFileName(pk.FileName));
|
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
if (File.Exists(path))
|
2015-11-15 03:41:39 +00:00
|
|
|
|
{
|
2018-04-07 04:23:09 +00:00
|
|
|
|
WinFormsUtil.Alert(MsgDBAddFailExistsFile);
|
2015-11-15 03:41:39 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-07 20:51:13 +00:00
|
|
|
|
File.WriteAllBytes(path, pk.DecryptedBoxData);
|
2015-11-15 03:41:39 +00:00
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
var info = new SlotInfoFile(path);
|
|
|
|
|
var entry = new SlotCache(info, pk);
|
|
|
|
|
Results.Add(entry);
|
2015-12-20 00:29:44 +00:00
|
|
|
|
|
2015-11-15 03:41:39 +00:00
|
|
|
|
// Refresh database view.
|
2016-02-01 07:15:54 +00:00
|
|
|
|
L_Count.Text = string.Format(Counter, Results.Count);
|
2015-12-20 00:29:44 +00:00
|
|
|
|
slotSelected = Results.Count - 1;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
slotColor = SpriteUtil.Spriter.Set;
|
2015-12-20 00:29:44 +00:00
|
|
|
|
if ((SCR_Box.Maximum+1)*6 < Results.Count)
|
2018-05-12 19:28:48 +00:00
|
|
|
|
SCR_Box.Maximum++;
|
2018-08-03 03:11:42 +00:00
|
|
|
|
SCR_Box.Value = Math.Max(0, SCR_Box.Maximum - (PKXBOXES.Length/6) + 1);
|
2015-11-15 03:41:39 +00:00
|
|
|
|
FillPKXBoxes(SCR_Box.Value);
|
2018-04-07 04:23:09 +00:00
|
|
|
|
WinFormsUtil.Alert(MsgDBAddFromTabsSuccess);
|
2015-11-15 03:41:39 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2019-08-15 05:51:49 +00:00
|
|
|
|
private bool GetShiftedIndex(ref int index)
|
|
|
|
|
{
|
2021-08-05 19:15:55 +00:00
|
|
|
|
if ((uint)index >= RES_MAX)
|
2019-08-15 05:51:49 +00:00
|
|
|
|
return false;
|
|
|
|
|
index += SCR_Box.Value * RES_MIN;
|
2020-10-18 18:02:39 +00:00
|
|
|
|
return index < Results.Count;
|
2019-08-15 05:51:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void PopulateComboBoxes()
|
2015-10-08 03:19:34 +00:00
|
|
|
|
{
|
|
|
|
|
// Set the Text
|
2018-07-14 23:00:28 +00:00
|
|
|
|
CB_HeldItem.InitializeBinding();
|
|
|
|
|
CB_Species.InitializeBinding();
|
|
|
|
|
CB_Ability.InitializeBinding();
|
|
|
|
|
CB_Nature.InitializeBinding();
|
|
|
|
|
CB_GameOrigin.InitializeBinding();
|
|
|
|
|
CB_HPType.InitializeBinding();
|
2015-10-08 03:19:34 +00:00
|
|
|
|
|
2019-06-02 02:12:41 +00:00
|
|
|
|
var Any = new ComboItem(MsgAny, -1);
|
2015-10-08 03:19:34 +00:00
|
|
|
|
|
2016-10-29 22:41:55 +00:00
|
|
|
|
var DS_Species = new List<ComboItem>(GameInfo.SpeciesDataSource);
|
2015-10-08 03:19:34 +00:00
|
|
|
|
DS_Species.RemoveAt(0); DS_Species.Insert(0, Any); CB_Species.DataSource = DS_Species;
|
|
|
|
|
|
2016-10-29 22:41:55 +00:00
|
|
|
|
var DS_Item = new List<ComboItem>(GameInfo.ItemDataSource);
|
2015-10-08 03:19:34 +00:00
|
|
|
|
DS_Item.Insert(0, Any); CB_HeldItem.DataSource = DS_Item;
|
|
|
|
|
|
2016-10-29 22:41:55 +00:00
|
|
|
|
var DS_Nature = new List<ComboItem>(GameInfo.NatureDataSource);
|
2015-10-08 03:19:34 +00:00
|
|
|
|
DS_Nature.Insert(0, Any); CB_Nature.DataSource = DS_Nature;
|
|
|
|
|
|
2016-10-29 22:41:55 +00:00
|
|
|
|
var DS_Ability = new List<ComboItem>(GameInfo.AbilityDataSource);
|
2015-10-08 03:19:34 +00:00
|
|
|
|
DS_Ability.Insert(0, Any); CB_Ability.DataSource = DS_Ability;
|
|
|
|
|
|
2016-10-29 22:41:55 +00:00
|
|
|
|
var DS_Version = new List<ComboItem>(GameInfo.VersionDataSource);
|
2015-10-08 03:19:34 +00:00
|
|
|
|
DS_Version.Insert(0, Any); CB_GameOrigin.DataSource = DS_Version;
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
string[] hptypes = new string[GameInfo.Strings.types.Length - 2]; Array.Copy(GameInfo.Strings.types, 1, hptypes, 0, hptypes.Length);
|
2019-02-02 07:08:03 +00:00
|
|
|
|
var DS_Type = Util.GetCBList(hptypes);
|
2015-10-08 03:19:34 +00:00
|
|
|
|
DS_Type.Insert(0, Any); CB_HPType.DataSource = DS_Type;
|
|
|
|
|
|
|
|
|
|
// Set the Move ComboBoxes too..
|
2016-10-29 22:41:55 +00:00
|
|
|
|
var DS_Move = new List<ComboItem>(GameInfo.MoveDataSource);
|
2015-10-08 03:19:34 +00:00
|
|
|
|
DS_Move.RemoveAt(0); DS_Move.Insert(0, Any);
|
|
|
|
|
{
|
|
|
|
|
foreach (ComboBox cb in new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4 })
|
|
|
|
|
{
|
2018-07-14 23:00:28 +00:00
|
|
|
|
cb.InitializeBinding();
|
2015-10-08 03:19:34 +00:00
|
|
|
|
cb.DataSource = new BindingSource(DS_Move, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Trigger a Reset
|
2020-10-18 18:02:39 +00:00
|
|
|
|
ResetFilters(this, EventArgs.Empty);
|
2015-10-08 03:19:34 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ResetFilters(object sender, EventArgs e)
|
2015-10-06 01:51:52 +00:00
|
|
|
|
{
|
2015-10-08 03:19:34 +00:00
|
|
|
|
CHK_Shiny.Checked = CHK_IsEgg.Checked = true;
|
|
|
|
|
CHK_Shiny.CheckState = CHK_IsEgg.CheckState = CheckState.Indeterminate;
|
2018-04-07 04:23:09 +00:00
|
|
|
|
MT_ESV.Text = string.Empty;
|
2015-10-08 03:19:34 +00:00
|
|
|
|
CB_HeldItem.SelectedIndex = 0;
|
|
|
|
|
CB_Species.SelectedIndex = 0;
|
|
|
|
|
CB_Ability.SelectedIndex = 0;
|
|
|
|
|
CB_Nature.SelectedIndex = 0;
|
|
|
|
|
CB_HPType.SelectedIndex = 0;
|
2015-10-06 01:51:52 +00:00
|
|
|
|
|
2015-10-08 03:19:34 +00:00
|
|
|
|
CB_Level.SelectedIndex = 0;
|
2018-04-07 04:23:09 +00:00
|
|
|
|
TB_Level.Text = string.Empty;
|
2015-10-08 03:19:34 +00:00
|
|
|
|
CB_EVTrain.SelectedIndex = 0;
|
|
|
|
|
CB_IV.SelectedIndex = 0;
|
2015-10-06 01:51:52 +00:00
|
|
|
|
|
2015-10-08 03:19:34 +00:00
|
|
|
|
CB_Move1.SelectedIndex = CB_Move2.SelectedIndex = CB_Move3.SelectedIndex = CB_Move4.SelectedIndex = 0;
|
|
|
|
|
|
|
|
|
|
CB_GameOrigin.SelectedIndex = 0;
|
2015-10-10 17:28:24 +00:00
|
|
|
|
CB_Generation.SelectedIndex = 0;
|
2015-10-12 07:12:21 +00:00
|
|
|
|
|
|
|
|
|
MT_ESV.Visible = L_ESV.Visible = false;
|
2016-07-23 08:04:55 +00:00
|
|
|
|
RTB_Instructions.Clear();
|
2016-01-18 01:11:32 +00:00
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
if (sender != this)
|
2016-01-18 01:11:32 +00:00
|
|
|
|
System.Media.SystemSounds.Asterisk.Play();
|
2015-10-06 01:51:52 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void GenerateDBReport(object sender, EventArgs e)
|
2015-10-11 01:29:02 +00:00
|
|
|
|
{
|
2018-08-03 03:11:42 +00:00
|
|
|
|
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgDBCreateReportPrompt, MsgDBCreateReportWarning) != DialogResult.Yes)
|
2015-10-11 01:29:02 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-10-08 01:40:09 +00:00
|
|
|
|
if (this.OpenWindowExists<ReportGrid>())
|
|
|
|
|
return;
|
2019-09-11 05:07:50 +00:00
|
|
|
|
|
2020-12-22 07:37:07 +00:00
|
|
|
|
ReportGrid reportGrid = new();
|
2017-06-18 01:37:19 +00:00
|
|
|
|
reportGrid.Show();
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
reportGrid.PopulateData(Results);
|
2015-10-11 01:29:02 +00:00
|
|
|
|
}
|
2015-10-08 03:19:34 +00:00
|
|
|
|
|
2022-02-05 17:49:47 +00:00
|
|
|
|
private sealed class SearchFolderDetail
|
|
|
|
|
{
|
|
|
|
|
public string Path { get; }
|
|
|
|
|
public bool IgnoreBackupFiles { get; }
|
|
|
|
|
|
|
|
|
|
public SearchFolderDetail(string path, bool ignoreBackupFiles)
|
|
|
|
|
{
|
|
|
|
|
Path = path;
|
|
|
|
|
IgnoreBackupFiles = ignoreBackupFiles;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-05 05:22:02 +00:00
|
|
|
|
private void LoadDatabase()
|
2018-08-04 17:06:06 +00:00
|
|
|
|
{
|
2021-06-02 17:52:20 +00:00
|
|
|
|
var settings = Main.Settings;
|
2022-02-05 17:49:47 +00:00
|
|
|
|
var otherPaths = new List<SearchFolderDetail>();
|
2021-06-02 17:52:20 +00:00
|
|
|
|
if (settings.EntityDb.SearchExtraSaves)
|
2022-02-05 17:49:47 +00:00
|
|
|
|
otherPaths.AddRange(settings.Backup.OtherBackupPaths.Where(Directory.Exists).Select(z => new SearchFolderDetail(z, true)));
|
|
|
|
|
if (settings.EntityDb.SearchBackups)
|
|
|
|
|
otherPaths.Add(new SearchFolderDetail(Main.BackupPath, false));
|
2021-06-02 17:52:20 +00:00
|
|
|
|
|
|
|
|
|
RawDB = LoadPKMSaves(DatabasePath, SAV, otherPaths, settings.EntityDb.SearchExtraSavesDeep);
|
2018-08-04 17:06:06 +00:00
|
|
|
|
|
|
|
|
|
// Load stats for pkm who do not have any
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
foreach (var entry in RawDB)
|
2018-08-04 17:06:06 +00:00
|
|
|
|
{
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
var pk = entry.Entity;
|
|
|
|
|
pk.ForcePartyData();
|
2018-08-04 17:06:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2020-03-14 21:58:36 +00:00
|
|
|
|
while (!IsHandleCreated) { }
|
2018-08-04 17:06:06 +00:00
|
|
|
|
BeginInvoke(new MethodInvoker(() => SetResults(RawDB)));
|
|
|
|
|
}
|
|
|
|
|
catch { /* Window Closed? */ }
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 17:49:47 +00:00
|
|
|
|
private static List<SlotCache> LoadPKMSaves(string pkmdb, SaveFile SAV, List<SearchFolderDetail> otherPaths, bool otherDeep)
|
2017-09-05 05:22:02 +00:00
|
|
|
|
{
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
var dbTemp = new ConcurrentBag<SlotCache>();
|
2018-10-21 14:21:46 +00:00
|
|
|
|
var extensions = new HashSet<string>(PKM.Extensions.Select(z => $".{z}"));
|
2017-09-05 05:22:02 +00:00
|
|
|
|
|
2019-09-11 05:07:50 +00:00
|
|
|
|
var files = Directory.EnumerateFiles(pkmdb, "*", SearchOption.AllDirectories);
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
Parallel.ForEach(files, file => SlotInfoLoader.AddFromLocalFile(file, dbTemp, SAV, extensions));
|
2017-09-05 05:22:02 +00:00
|
|
|
|
|
2021-02-13 21:04:43 +00:00
|
|
|
|
foreach (var folder in otherPaths)
|
|
|
|
|
{
|
2022-02-05 17:49:47 +00:00
|
|
|
|
if (!SaveUtil.GetSavesFromFolder(folder.Path, otherDeep, out IEnumerable<string> paths, folder.IgnoreBackupFiles))
|
2021-02-13 21:04:43 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
Parallel.ForEach(paths, file => TryAddPKMsFromSaveFilePath(dbTemp, file));
|
2021-02-13 21:04:43 +00:00
|
|
|
|
}
|
2019-10-08 01:40:09 +00:00
|
|
|
|
|
2018-08-04 17:06:06 +00:00
|
|
|
|
// Fetch from save file
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
SlotInfoLoader.AddFromSaveFile(SAV, dbTemp);
|
|
|
|
|
var result = new List<SlotCache>(dbTemp);
|
|
|
|
|
result.RemoveAll(z => !z.IsDataValid());
|
2018-01-25 17:17:39 +00:00
|
|
|
|
|
2021-06-04 00:48:32 +00:00
|
|
|
|
if (Main.Settings.EntityDb.FilterUnavailableSpecies)
|
|
|
|
|
{
|
2022-05-31 04:43:52 +00:00
|
|
|
|
static bool IsPresentInGameSWSH(ISpeciesForm pk) => pk is PK8 || PersonalTable.SWSH.IsPresentInGame(pk.Species, pk.Form);
|
|
|
|
|
static bool IsPresentInGameBDSP(ISpeciesForm pk) => pk is PB8 || PersonalTable.BDSP.IsPresentInGame(pk.Species, pk.Form);
|
|
|
|
|
static bool IsPresentInGamePLA (ISpeciesForm pk) => pk is PA8 || PersonalTable.LA .IsPresentInGame(pk.Species, pk.Form);
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
if (SAV is SAV8SWSH)
|
2021-11-20 02:23:49 +00:00
|
|
|
|
result.RemoveAll(z => !IsPresentInGameSWSH(z.Entity));
|
|
|
|
|
else if (SAV is SAV8BS)
|
|
|
|
|
result.RemoveAll(z => !IsPresentInGameBDSP(z.Entity));
|
2022-02-05 01:36:51 +00:00
|
|
|
|
else if (SAV is SAV8LA)
|
|
|
|
|
result.RemoveAll(z => !IsPresentInGamePLA(z.Entity));
|
2021-06-04 00:48:32 +00:00
|
|
|
|
}
|
2019-11-16 23:56:30 +00:00
|
|
|
|
|
2021-08-06 17:09:16 +00:00
|
|
|
|
var sort = Main.Settings.EntityDb.InitialSortMode;
|
|
|
|
|
if (sort is DatabaseSortMode.SlotIdentity)
|
|
|
|
|
result.Sort();
|
|
|
|
|
else if (sort is DatabaseSortMode.SpeciesForm)
|
|
|
|
|
result.Sort((first, second) => first.CompareToSpeciesForm(second));
|
|
|
|
|
|
2019-09-11 05:07:50 +00:00
|
|
|
|
// Finalize the Database
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
return result;
|
2019-09-11 05:07:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
private static void TryAddPKMsFromSaveFilePath(ConcurrentBag<SlotCache> dbTemp, string file)
|
2019-09-11 05:07:50 +00:00
|
|
|
|
{
|
2019-10-27 06:14:00 +00:00
|
|
|
|
var sav = SaveUtil.GetVariantSAV(file);
|
|
|
|
|
if (sav == null)
|
2019-09-11 05:07:50 +00:00
|
|
|
|
{
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
Debug.WriteLine("Unable to load SaveFile: " + file);
|
2019-10-27 06:14:00 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2019-09-11 05:07:50 +00:00
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
SlotInfoLoader.AddFromSaveFile(sav, dbTemp);
|
2019-09-11 05:07:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-10 17:28:24 +00:00
|
|
|
|
// IO Usage
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void OpenDB(object sender, EventArgs e)
|
2015-10-06 01:51:52 +00:00
|
|
|
|
{
|
|
|
|
|
if (Directory.Exists(DatabasePath))
|
2016-07-17 17:06:52 +00:00
|
|
|
|
Process.Start("explorer.exe", DatabasePath);
|
2015-10-06 01:51:52 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2015-10-13 00:12:20 +00:00
|
|
|
|
private void Menu_Export_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-10-18 18:02:39 +00:00
|
|
|
|
if (Results.Count == 0)
|
2018-04-07 04:23:09 +00:00
|
|
|
|
{ WinFormsUtil.Alert(MsgDBCreateReportFail); return; }
|
2015-10-13 00:12:20 +00:00
|
|
|
|
|
2018-04-07 04:23:09 +00:00
|
|
|
|
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgDBExportResultsPrompt))
|
2015-10-13 00:12:20 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-10-08 01:40:09 +00:00
|
|
|
|
using var fbd = new FolderBrowserDialog();
|
2015-10-13 00:12:20 +00:00
|
|
|
|
if (DialogResult.OK != fbd.ShowDialog())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string path = fbd.SelectedPath;
|
2017-10-03 06:13:40 +00:00
|
|
|
|
Directory.CreateDirectory(path);
|
2015-10-13 00:12:20 +00:00
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
foreach (var pkm in Results.Select(z => z.Entity))
|
2019-11-16 22:03:25 +00:00
|
|
|
|
File.WriteAllBytes(Path.Combine(path, Util.CleanFileName(pkm.FileName)), pkm.DecryptedPartyData);
|
2015-10-13 00:12:20 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2018-02-02 01:29:07 +00:00
|
|
|
|
private void Menu_Import_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2018-12-29 01:58:13 +00:00
|
|
|
|
if (!BoxView.GetBulkImportSettings(out var clearAll, out var overwrite, out var noSetb))
|
2018-02-02 01:29:07 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int box = BoxView.Box.CurrentBox;
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
int ctr = SAV.LoadBoxes(Results.Select(z => z.Entity), out var result, box, clearAll, overwrite, noSetb);
|
2019-02-23 22:37:06 +00:00
|
|
|
|
if (ctr <= 0)
|
2018-02-02 01:29:07 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
BoxView.SetPKMBoxes();
|
|
|
|
|
BoxView.UpdateBoxViewers();
|
|
|
|
|
WinFormsUtil.Alert(result);
|
|
|
|
|
}
|
2015-10-08 03:19:34 +00:00
|
|
|
|
|
2015-10-10 17:28:24 +00:00
|
|
|
|
// View Updates
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
private IEnumerable<SlotCache> SearchDatabase()
|
2015-10-08 03:19:34 +00:00
|
|
|
|
{
|
2018-08-17 03:06:40 +00:00
|
|
|
|
var settings = GetSearchSettings();
|
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
IEnumerable<SlotCache> res = RawDB;
|
2015-10-08 03:19:34 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
// pre-filter based on the file path (if specified)
|
2017-06-11 18:08:03 +00:00
|
|
|
|
if (!Menu_SearchBoxes.Checked)
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
res = res.Where(z => z.SAV != SAV);
|
2017-06-11 18:08:03 +00:00
|
|
|
|
if (!Menu_SearchDatabase.Checked)
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
res = res.Where(z => !IsIndividualFilePKMDB(z));
|
|
|
|
|
if (!Menu_SearchBackups.Checked)
|
|
|
|
|
res = res.Where(z => !IsBackupSaveFile(z));
|
2017-06-11 18:08:03 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
// return filtered results
|
|
|
|
|
return settings.Search(res);
|
|
|
|
|
}
|
2018-07-15 05:18:24 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
private SearchSettings GetSearchSettings()
|
|
|
|
|
{
|
|
|
|
|
var settings = new SearchSettings
|
2018-07-15 05:18:24 +00:00
|
|
|
|
{
|
2018-08-17 03:06:40 +00:00
|
|
|
|
Format = MAXFORMAT - CB_Format.SelectedIndex + 1, // 0->(n-1) => 1->n
|
|
|
|
|
SearchFormat = (SearchComparison)CB_FormatComparator.SelectedIndex,
|
|
|
|
|
Generation = CB_Generation.SelectedIndex,
|
2015-10-08 03:19:34 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
Version = WinFormsUtil.GetIndex(CB_GameOrigin),
|
|
|
|
|
HiddenPowerType = WinFormsUtil.GetIndex(CB_HPType),
|
2016-03-16 04:10:33 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
Species = WinFormsUtil.GetIndex(CB_Species),
|
|
|
|
|
Ability = WinFormsUtil.GetIndex(CB_Ability),
|
|
|
|
|
Nature = WinFormsUtil.GetIndex(CB_Nature),
|
|
|
|
|
Item = WinFormsUtil.GetIndex(CB_HeldItem),
|
2016-12-23 21:37:53 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
BatchInstructions = RTB_Instructions.Lines,
|
2017-09-30 05:58:25 +00:00
|
|
|
|
|
2021-06-03 19:04:19 +00:00
|
|
|
|
Level = int.TryParse(TB_Level.Text, out var lvl) ? lvl : null,
|
2018-08-17 03:06:40 +00:00
|
|
|
|
SearchLevel = (SearchComparison)CB_Level.SelectedIndex,
|
|
|
|
|
EVType = CB_EVTrain.SelectedIndex,
|
|
|
|
|
IVType = CB_IV.SelectedIndex,
|
|
|
|
|
};
|
2018-07-15 05:18:24 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
settings.AddMove(WinFormsUtil.GetIndex(CB_Move1));
|
|
|
|
|
settings.AddMove(WinFormsUtil.GetIndex(CB_Move2));
|
|
|
|
|
settings.AddMove(WinFormsUtil.GetIndex(CB_Move3));
|
|
|
|
|
settings.AddMove(WinFormsUtil.GetIndex(CB_Move4));
|
2018-07-15 05:18:24 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
if (CHK_Shiny.CheckState != CheckState.Indeterminate)
|
|
|
|
|
settings.SearchShiny = CHK_Shiny.CheckState == CheckState.Checked;
|
2018-07-15 05:18:24 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
if (CHK_IsEgg.CheckState != CheckState.Indeterminate)
|
2018-07-15 05:18:24 +00:00
|
|
|
|
{
|
2018-11-10 00:50:39 +00:00
|
|
|
|
settings.SearchEgg = CHK_IsEgg.CheckState == CheckState.Checked;
|
2018-08-17 03:06:40 +00:00
|
|
|
|
if (int.TryParse(MT_ESV.Text, out int esv))
|
|
|
|
|
settings.ESV = esv;
|
2018-07-15 05:18:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
if (Menu_SearchLegal.Checked != Menu_SearchIllegal.Checked)
|
|
|
|
|
settings.SearchLegal = Menu_SearchLegal.Checked;
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
if (Menu_SearchClones.Checked)
|
2017-08-25 01:49:09 +00:00
|
|
|
|
{
|
2019-10-08 01:40:09 +00:00
|
|
|
|
settings.SearchClones = ModifierKeys switch
|
2018-08-17 03:06:40 +00:00
|
|
|
|
{
|
2019-10-08 01:40:09 +00:00
|
|
|
|
Keys.Control => CloneDetectionMethod.HashPID,
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => CloneDetectionMethod.HashDetails,
|
2019-10-08 01:40:09 +00:00
|
|
|
|
};
|
2017-08-25 01:49:09 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2018-08-17 03:06:40 +00:00
|
|
|
|
return settings;
|
2017-08-25 01:49:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-30 02:18:18 +00:00
|
|
|
|
private async void B_Search_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
B_Search.Enabled = false;
|
|
|
|
|
var search = SearchDatabase();
|
2017-09-20 23:46:40 +00:00
|
|
|
|
|
|
|
|
|
bool legalSearch = Menu_SearchLegal.Checked ^ Menu_SearchIllegal.Checked;
|
2021-04-12 01:09:54 +00:00
|
|
|
|
bool wordFilter = ParseSettings.CheckWordFilter;
|
|
|
|
|
if (wordFilter && legalSearch && WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgDBSearchLegalityWordfilter) == DialogResult.No)
|
2018-10-06 02:58:30 +00:00
|
|
|
|
ParseSettings.CheckWordFilter = false;
|
2018-05-25 04:22:44 +00:00
|
|
|
|
var results = await Task.Run(() => search.ToList()).ConfigureAwait(true);
|
2021-04-12 01:09:54 +00:00
|
|
|
|
ParseSettings.CheckWordFilter = wordFilter;
|
2017-09-20 23:46:40 +00:00
|
|
|
|
|
2018-05-25 04:22:44 +00:00
|
|
|
|
if (results.Count == 0)
|
2015-11-14 02:31:01 +00:00
|
|
|
|
{
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
if (!Menu_SearchBoxes.Checked && !Menu_SearchDatabase.Checked && !Menu_SearchBackups.Checked)
|
2018-04-07 04:23:09 +00:00
|
|
|
|
WinFormsUtil.Alert(MsgDBSearchFail, MsgDBSearchNone);
|
2015-11-14 02:31:01 +00:00
|
|
|
|
else
|
2018-04-07 04:23:09 +00:00
|
|
|
|
WinFormsUtil.Alert(MsgDBSearchNone);
|
2015-11-14 02:31:01 +00:00
|
|
|
|
}
|
2018-05-25 04:22:44 +00:00
|
|
|
|
SetResults(results); // updates Count Label as well.
|
2015-10-08 03:19:34 +00:00
|
|
|
|
System.Media.SystemSounds.Asterisk.Play();
|
2017-05-30 02:18:18 +00:00
|
|
|
|
B_Search.Enabled = true;
|
2015-10-08 03:19:34 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateScroll(object sender, ScrollEventArgs e)
|
2015-10-08 03:19:34 +00:00
|
|
|
|
{
|
|
|
|
|
if (e.OldValue != e.NewValue)
|
|
|
|
|
FillPKXBoxes(e.NewValue);
|
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
private void SetResults(List<SlotCache> res)
|
2015-10-10 17:28:24 +00:00
|
|
|
|
{
|
2018-05-25 04:22:44 +00:00
|
|
|
|
Results = res;
|
2021-06-04 00:32:13 +00:00
|
|
|
|
ShowSet.Clear();
|
2015-10-08 03:19:34 +00:00
|
|
|
|
|
2015-10-10 17:28:24 +00:00
|
|
|
|
SCR_Box.Maximum = (int)Math.Ceiling((decimal)Results.Count / RES_MIN);
|
2018-05-12 19:28:48 +00:00
|
|
|
|
if (SCR_Box.Maximum > 0) SCR_Box.Maximum--;
|
2015-10-10 17:28:24 +00:00
|
|
|
|
|
2018-07-15 05:18:24 +00:00
|
|
|
|
slotSelected = -1; // reset the slot last viewed
|
2015-10-10 17:28:24 +00:00
|
|
|
|
SCR_Box.Value = 0;
|
|
|
|
|
FillPKXBoxes(0);
|
|
|
|
|
|
2016-02-01 07:15:54 +00:00
|
|
|
|
L_Count.Text = string.Format(Counter, Results.Count);
|
2017-09-05 05:22:02 +00:00
|
|
|
|
B_Search.Enabled = true;
|
2015-10-10 17:28:24 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2015-10-08 03:19:34 +00:00
|
|
|
|
private void FillPKXBoxes(int start)
|
|
|
|
|
{
|
2020-10-18 18:02:39 +00:00
|
|
|
|
if (Results.Count == 0)
|
2016-09-04 18:02:27 +00:00
|
|
|
|
{
|
2015-10-08 03:19:34 +00:00
|
|
|
|
for (int i = 0; i < RES_MAX; i++)
|
2020-10-18 18:02:39 +00:00
|
|
|
|
{
|
2015-10-08 03:19:34 +00:00
|
|
|
|
PKXBOXES[i].Image = null;
|
2020-10-18 18:02:39 +00:00
|
|
|
|
PKXBOXES[i].BackgroundImage = null;
|
|
|
|
|
}
|
2016-09-04 18:02:27 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2017-04-21 03:52:08 +00:00
|
|
|
|
int begin = start*RES_MIN;
|
2018-08-03 03:11:42 +00:00
|
|
|
|
int end = Math.Min(RES_MAX, Results.Count - begin);
|
2017-04-21 03:52:08 +00:00
|
|
|
|
for (int i = 0; i < end; i++)
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
PKXBOXES[i].Image = Results[i + begin].Entity.Sprite(SAV, -1, -1, true);
|
2017-04-21 03:52:08 +00:00
|
|
|
|
for (int i = end; i < RES_MAX; i++)
|
2015-10-08 03:19:34 +00:00
|
|
|
|
PKXBOXES[i].Image = null;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < RES_MAX; i++)
|
2019-11-16 01:34:18 +00:00
|
|
|
|
PKXBOXES[i].BackgroundImage = SpriteUtil.Spriter.Transparent;
|
2018-08-03 03:11:42 +00:00
|
|
|
|
if (slotSelected != -1 && slotSelected >= begin && slotSelected < begin + RES_MAX)
|
2019-11-16 01:34:18 +00:00
|
|
|
|
PKXBOXES[slotSelected - begin].BackgroundImage = slotColor ?? SpriteUtil.Spriter.View;
|
2015-10-08 03:19:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Misc Update Methods
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ToggleESV(object sender, EventArgs e)
|
2015-10-08 03:19:34 +00:00
|
|
|
|
{
|
|
|
|
|
L_ESV.Visible = MT_ESV.Visible = CHK_IsEgg.CheckState == CheckState.Checked;
|
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ChangeLevel(object sender, EventArgs e)
|
2015-10-08 03:19:34 +00:00
|
|
|
|
{
|
|
|
|
|
if (CB_Level.SelectedIndex == 0)
|
2018-04-07 04:23:09 +00:00
|
|
|
|
TB_Level.Text = string.Empty;
|
2015-10-08 03:19:34 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ChangeGame(object sender, EventArgs e)
|
2015-10-10 17:18:55 +00:00
|
|
|
|
{
|
|
|
|
|
if (CB_GameOrigin.SelectedIndex != 0)
|
|
|
|
|
CB_Generation.SelectedIndex = 0;
|
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ChangeGeneration(object sender, EventArgs e)
|
2015-10-10 17:18:55 +00:00
|
|
|
|
{
|
|
|
|
|
if (CB_Generation.SelectedIndex != 0)
|
|
|
|
|
CB_GameOrigin.SelectedIndex = 0;
|
|
|
|
|
}
|
2015-10-08 03:19:34 +00:00
|
|
|
|
|
2018-07-22 02:20:11 +00:00
|
|
|
|
private void Menu_Exit_Click(object sender, EventArgs e) => Close();
|
|
|
|
|
|
2016-03-19 02:33:09 +00:00
|
|
|
|
protected override void OnMouseWheel(MouseEventArgs e)
|
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
if (!DatabasePokeGrid.RectangleToScreen(DatabasePokeGrid.ClientRectangle).Contains(MousePosition))
|
2016-03-19 02:33:09 +00:00
|
|
|
|
return;
|
|
|
|
|
int oldval = SCR_Box.Value;
|
|
|
|
|
int newval = oldval + (e.Delta < 0 ? 1 : -1);
|
|
|
|
|
if (newval >= SCR_Box.Minimum && SCR_Box.Maximum >= newval)
|
|
|
|
|
FillPKXBoxes(SCR_Box.Value = newval);
|
|
|
|
|
}
|
2016-07-10 17:33:01 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ChangeFormatFilter(object sender, EventArgs e)
|
2016-07-10 17:33:01 +00:00
|
|
|
|
{
|
|
|
|
|
if (CB_FormatComparator.SelectedIndex == 0)
|
|
|
|
|
{
|
|
|
|
|
CB_Format.Visible = false; // !any
|
|
|
|
|
CB_Format.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CB_Format.Visible = true;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
int index = MAXFORMAT - SAV.Generation + 1;
|
2016-09-05 01:17:13 +00:00
|
|
|
|
CB_Format.SelectedIndex = index < CB_Format.Items.Count ? index : 0; // SAV generation (offset by 1 for "Any")
|
2016-07-10 17:33:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-23 22:12:58 +00:00
|
|
|
|
|
|
|
|
|
private void Menu_DeleteClones_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-01-08 07:54:09 +00:00
|
|
|
|
var dr = WinFormsUtil.Prompt(MessageBoxButtons.YesNo,
|
2018-04-07 04:23:09 +00:00
|
|
|
|
MsgDBDeleteCloneWarning + Environment.NewLine +
|
|
|
|
|
MsgDBDeleteCloneAdvice, MsgContinue);
|
2016-12-23 22:12:58 +00:00
|
|
|
|
|
|
|
|
|
if (dr != DialogResult.Yes)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var deleted = 0;
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
var db = RawDB.Where(IsIndividualFilePKMDB)
|
|
|
|
|
.OrderByDescending(GetRevisedTime);
|
2018-08-17 03:06:40 +00:00
|
|
|
|
|
2022-04-19 23:33:11 +00:00
|
|
|
|
const CloneDetectionMethod method = CloneDetectionMethod.HashDetails;
|
|
|
|
|
var hasher = SearchUtil.GetCloneDetectMethod(method);
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
var duplicates = SearchUtil.GetExtraClones(db, z => hasher(z.Entity));
|
|
|
|
|
foreach (var entry in duplicates)
|
2016-12-23 22:12:58 +00:00
|
|
|
|
{
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
var src = entry.Source;
|
|
|
|
|
var path = ((SlotInfoFile)src).Path;
|
|
|
|
|
if (!File.Exists(path))
|
2020-09-19 05:11:13 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
try { File.Delete(path); ++deleted; }
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
catch (Exception ex) { WinFormsUtil.Error(MsgDBDeleteCloneFail + Environment.NewLine + ex.Message + Environment.NewLine + path); }
|
2016-12-23 22:12:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-19 23:33:11 +00:00
|
|
|
|
var boxClear = new BoxManipClearDuplicate<string>(BoxManipType.DeleteClones, pk => SearchUtil.GetCloneDetectMethod(method)(pk));
|
|
|
|
|
var param = new BoxManipParam(0, SAV.BoxCount);
|
|
|
|
|
int count = boxClear.Execute(SAV, param);
|
|
|
|
|
deleted += count;
|
|
|
|
|
|
2016-12-23 22:12:58 +00:00
|
|
|
|
if (deleted == 0)
|
2018-04-07 04:23:09 +00:00
|
|
|
|
{ WinFormsUtil.Alert(MsgDBDeleteCloneNone); return; }
|
2016-12-23 22:12:58 +00:00
|
|
|
|
|
2018-04-07 04:23:09 +00:00
|
|
|
|
WinFormsUtil.Alert(string.Format(MsgFileDeleteCount, deleted), MsgWindowClose);
|
2022-04-19 23:33:11 +00:00
|
|
|
|
BoxView.ReloadSlots();
|
|
|
|
|
|
2016-12-23 22:12:58 +00:00
|
|
|
|
Close();
|
|
|
|
|
}
|
2019-09-11 05:07:50 +00:00
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
private static DateTime GetRevisedTime(SlotCache arg)
|
|
|
|
|
{
|
|
|
|
|
var src = arg.Source;
|
|
|
|
|
if (src is not SlotInfoFile f)
|
|
|
|
|
return DateTime.Now;
|
|
|
|
|
return File.GetLastWriteTimeUtc(f.Path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsBackupSaveFile(SlotCache pk)
|
|
|
|
|
{
|
|
|
|
|
return pk.SAV is not FakeSaveFile && pk.SAV != SAV;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsIndividualFilePKMDB(SlotCache pk)
|
|
|
|
|
{
|
|
|
|
|
return pk.Source is SlotInfoFile f && f.Path.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-11 05:07:50 +00:00
|
|
|
|
private void L_Viewed_MouseEnter(object sender, EventArgs e) => hover.SetToolTip(L_Viewed, L_Viewed.Text);
|
|
|
|
|
|
|
|
|
|
private void ShowHoverTextForSlot(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var pb = (PictureBox)sender;
|
|
|
|
|
int index = Array.IndexOf(PKXBOXES, pb);
|
|
|
|
|
if (!GetShiftedIndex(ref index))
|
|
|
|
|
return;
|
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
|
ShowSet.Show(pb, Results[index].Entity);
|
2019-09-11 05:07:50 +00:00
|
|
|
|
}
|
2015-10-06 01:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|