Add inventory sorting by index number

Closes #1312
This commit is contained in:
Kurt 2017-07-06 17:24:40 -07:00
parent 224544c322
commit 45c891e64f
5 changed files with 54 additions and 13 deletions

View file

@ -144,7 +144,7 @@ namespace PKHeX.Core
{
// Gen4 Mail names not stored in future games. No clever solution like for HM's, so improvise.
for (int i = 137; i <= 148; i++)
itemlist[i] = $"Mail #{i - 137 + 1} (G4)";
itemlist[i] = $"Mail #{i - 137 + 1:00} (G4/G5)";
// Fix Item Names (Duplicate entries)
int len = itemlist[425].Length;

View file

@ -253,6 +253,15 @@ namespace PKHeX.Core
Items = Items.Where(item => item.Index != 0).OrderByDescending(item => item.Count)
.Concat(Items.Where(item => item.Index == 0)).ToArray();
}
public void SortByIndex(bool reverse = false)
{
if (reverse)
Items = Items.Where(item => item.Index != 0).OrderByDescending(item => item.Index)
.Concat(Items.Where(item => item.Index == 0)).ToArray();
else
Items = Items.Where(item => item.Index != 0).OrderBy(item => item.Index)
.Concat(Items.Where(item => item.Index == 0)).ToArray();
}
public void SortByName(string[] names, bool reverse = false)
{
if (reverse)

View file

@ -44,10 +44,12 @@
this.giveMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.giveAll = new System.Windows.Forms.ToolStripMenuItem();
this.giveNone = new System.Windows.Forms.ToolStripMenuItem();
this.giveModify = new System.Windows.Forms.ToolStripMenuItem();
this.L_Count = new System.Windows.Forms.Label();
this.NUD_Count = new System.Windows.Forms.NumericUpDown();
this.CHK_NEW = new System.Windows.Forms.CheckBox();
this.giveModify = new System.Windows.Forms.ToolStripMenuItem();
this.mnuSortIndex = new System.Windows.Forms.ToolStripMenuItem();
this.mnuSortIndexReverse = new System.Windows.Forms.ToolStripMenuItem();
this.sortMenu.SuspendLayout();
this.giveMenu.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_Count)).BeginInit();
@ -133,9 +135,11 @@
this.mnuSortName,
this.mnuSortNameReverse,
this.mnuSortCount,
this.mnuSortCountReverse});
this.mnuSortCountReverse,
this.mnuSortIndex,
this.mnuSortIndexReverse});
this.sortMenu.Name = "modifyMenu";
this.sortMenu.Size = new System.Drawing.Size(159, 92);
this.sortMenu.Size = new System.Drawing.Size(159, 158);
//
// mnuSortName
//
@ -172,22 +176,29 @@
this.giveNone,
this.giveModify});
this.giveMenu.Name = "modifyMenu";
this.giveMenu.Size = new System.Drawing.Size(153, 92);
this.giveMenu.Size = new System.Drawing.Size(113, 70);
//
// giveAll
//
this.giveAll.Name = "giveAll";
this.giveAll.Size = new System.Drawing.Size(152, 22);
this.giveAll.Size = new System.Drawing.Size(112, 22);
this.giveAll.Text = "All";
this.giveAll.Click += new System.EventHandler(this.GiveAllItems);
//
// giveNone
//
this.giveNone.Name = "giveNone";
this.giveNone.Size = new System.Drawing.Size(152, 22);
this.giveNone.Size = new System.Drawing.Size(112, 22);
this.giveNone.Text = "None";
this.giveNone.Click += new System.EventHandler(this.RemoveAllItems);
//
// giveModify
//
this.giveModify.Name = "giveModify";
this.giveModify.Size = new System.Drawing.Size(112, 22);
this.giveModify.Text = "Modify";
this.giveModify.Click += new System.EventHandler(this.ModifyAllItems);
//
// L_Count
//
this.L_Count.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@ -229,12 +240,19 @@
this.CHK_NEW.Text = "Flag NEW";
this.CHK_NEW.UseVisualStyleBackColor = true;
//
// giveModify
// mnuSortIndex
//
this.giveModify.Name = "giveModify";
this.giveModify.Size = new System.Drawing.Size(152, 22);
this.giveModify.Text = "Modify";
this.giveModify.Click += new System.EventHandler(this.ModifyAllItems);
this.mnuSortIndex.Name = "mnuSortIndex";
this.mnuSortIndex.Size = new System.Drawing.Size(158, 22);
this.mnuSortIndex.Text = "Index";
this.mnuSortIndex.Click += new System.EventHandler(this.SortByIndex);
//
// mnuSortIndexReverse
//
this.mnuSortIndexReverse.Name = "mnuSortIndexReverse";
this.mnuSortIndexReverse.Size = new System.Drawing.Size(158, 22);
this.mnuSortIndexReverse.Text = "Index (Reverse)";
this.mnuSortIndexReverse.Click += new System.EventHandler(this.SortByIndex);
//
// SAV_Inventory
//
@ -283,5 +301,7 @@
private System.Windows.Forms.NumericUpDown NUD_Count;
private System.Windows.Forms.CheckBox CHK_NEW;
private System.Windows.Forms.ToolStripMenuItem giveModify;
private System.Windows.Forms.ToolStripMenuItem mnuSortIndex;
private System.Windows.Forms.ToolStripMenuItem mnuSortIndexReverse;
}
}

View file

@ -411,5 +411,17 @@ namespace PKHeX.WinForms
p.SortByCount(reverse:true);
GetBag(dgv, p);
}
private void SortByIndex(object sender, EventArgs e)
{
int pouch = CurrentPouch;
var dgv = Controls.Find(DGVPrefix + Pouches[pouch].Type, true).FirstOrDefault() as DataGridView;
var p = Pouches[pouch];
SetBag(dgv, p);
if (sender == mnuSortIndex)
p.SortByIndex(reverse: false);
if (sender == mnuSortIndexReverse)
p.SortByIndex(reverse: true);
GetBag(dgv, p);
}
}
}

View file

@ -125,7 +125,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAB0
EwAAAk1TRnQBSQFMAgEBCwEAAUABAAFAAQABGAEAARgBAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
EwAAAk1TRnQBSQFMAgEBCwEAAUgBAAFIAQABGAEAARgBAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABYAMAAUgDAAEBAQABCAYAARsYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA