mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-13 17:45:14 -05:00
Add deletion method for database tool
Can delete files from database folder, or save file. Easy way to filter crap out to delete, yay.
This commit is contained in:
@@ -2721,7 +2721,7 @@ private int getSlot(object sender)
|
||||
|
||||
return Array.FindIndex(SlotPictureBoxes, p => p.Name == name);
|
||||
}
|
||||
private void setPKXBoxes()
|
||||
public void setPKXBoxes()
|
||||
{
|
||||
int boxoffset = SAV.Box + CB_BoxSelect.SelectedIndex * (PK6.SIZE_STORED * 30);
|
||||
int boxbgval = SAV.getBoxWallpaper(CB_BoxSelect.SelectedIndex);
|
||||
|
||||
@@ -60,12 +60,14 @@ public SAV_Database(Main f1)
|
||||
|
||||
ContextMenuStrip mnu = new ContextMenuStrip();
|
||||
ToolStripMenuItem mnuView = new ToolStripMenuItem("View");
|
||||
ToolStripMenuItem mnuDelete = new ToolStripMenuItem("Delete");
|
||||
|
||||
// Assign event handlers
|
||||
mnuView.Click += clickView;
|
||||
mnuDelete.Click += clickDelete;
|
||||
|
||||
// Add to main context menu
|
||||
mnu.Items.AddRange(new ToolStripItem[] { mnuView });
|
||||
mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuDelete });
|
||||
|
||||
// Assign to datagridview
|
||||
foreach (PictureBox p in PKXBOXES)
|
||||
@@ -130,6 +132,56 @@ private void clickView(object sender, EventArgs e)
|
||||
L_Viewed.Text = String.Format(Viewed, dataArr[index].Identifier);
|
||||
}
|
||||
}
|
||||
private void clickDelete(object sender, EventArgs e)
|
||||
{
|
||||
string name = (sender is ToolStripItem)
|
||||
? ((sender as ToolStripItem).Owner as ContextMenuStrip).SourceControl.Name
|
||||
: (sender as PictureBox).Name;
|
||||
|
||||
int index = Array.FindIndex(PKXBOXES, p => p.Name == name);
|
||||
var dataArr = Results.Skip(SCR_Box.Value * RES_MIN).Take(RES_MAX).ToArray();
|
||||
if (index >= dataArr.Length)
|
||||
System.Media.SystemSounds.Exclamation.Play();
|
||||
else
|
||||
{
|
||||
var pk = dataArr[index];
|
||||
string path = pk.Identifier;
|
||||
|
||||
if (path.Contains(Path.DirectorySeparatorChar))
|
||||
{
|
||||
// Data from Database: Delete file from disk
|
||||
File.Delete(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Data from Box: Delete from save file
|
||||
string[] split = pk.Identifier.Split(':');
|
||||
int box = Convert.ToInt32(split[0].Substring(1)) - 1;
|
||||
int slot = Convert.ToInt32(split[1]) - 1;
|
||||
int spot = box*30 + slot;
|
||||
int offset = Main.SAV.Box + spot*PK6.SIZE_STORED;
|
||||
var pkSAV = Main.SAV.getPK6Stored(offset);
|
||||
|
||||
File.WriteAllBytes("wtfSAV.bin", pkSAV.Data);
|
||||
File.WriteAllBytes("wtfDB.bin", pk.Data);
|
||||
if (pkSAV.Data.SequenceEqual(pk.Data))
|
||||
{
|
||||
Main.SAV.setEK6Stored(Main.blankEK6, offset);
|
||||
m_parent.setPKXBoxes();
|
||||
}
|
||||
else
|
||||
{
|
||||
Util.Error("Database slot data does not match save data!", "Don't move Pokémon after initializing the Database, please re-open the Database viewer.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Remove from database.
|
||||
RawDB.Remove(pk);
|
||||
Results.Remove(pk);
|
||||
// Refresh database view.
|
||||
FillPKXBoxes(SCR_Box.Value);
|
||||
}
|
||||
}
|
||||
private void populateComboBoxes()
|
||||
{
|
||||
// Set the Text
|
||||
|
||||
Reference in New Issue
Block a user