Misc ui fixes

move distinct filter to reflectutil as it is spitting out
inherited(overriden) property names after the current class' property
name.
remove original (default) memory strings; had removed Items.Clear()
earlier (why would I need to clear if there was nothing there?) but
there was something there needing to be cleared. Remove the useless
initialization to fix that :)

Thanks Davil!
https://projectpokemon.org/home/forums/topic/45321-distsupertrain/
This commit is contained in:
Kurt 2018-05-20 07:46:59 -07:00
parent 1f8c72af5a
commit 30dc87df7e
4 changed files with 23 additions and 83 deletions

View file

@ -38,12 +38,12 @@ namespace PKHeX.Core
var p = new string[Types.Length][]; var p = new string[Types.Length][];
for (int i = 0; i < p.Length; i++) for (int i = 0; i < p.Length; i++)
{ {
var pz = ReflectUtil.GetPropertiesCanWritePublic(Types[i]).Distinct(); var pz = ReflectUtil.GetPropertiesCanWritePublic(Types[i]);
p[i] = pz.Concat(CustomProperties).OrderBy(a => a).ToArray(); p[i] = pz.Concat(CustomProperties).OrderBy(a => a).ToArray();
} }
// Properties for any PKM // Properties for any PKM
var any = ReflectUtil.GetPropertiesCanWritePublic(typeof(PK1)).Distinct().Union(p.SelectMany(a => a)).OrderBy(a => a).ToArray(); var any = ReflectUtil.GetPropertiesCanWritePublic(typeof(PK1)).Union(p.SelectMany(a => a)).OrderBy(a => a).ToArray();
// Properties shared by all PKM // Properties shared by all PKM
var all = p.Aggregate(new HashSet<string>(p[0]), (h, e) => { h.IntersectWith(e); return h; }).OrderBy(a => a).ToArray(); var all = p.Aggregate(new HashSet<string>(p[0]), (h, e) => { h.IntersectWith(e); return h; }).OrderBy(a => a).ToArray();

View file

@ -29,11 +29,15 @@ namespace PKHeX.Core
{ {
return type.GetTypeInfo().GetAllTypeInfo().SelectMany(GetAllProperties) return type.GetTypeInfo().GetAllTypeInfo().SelectMany(GetAllProperties)
.Where(p => p.Name.StartsWith(prefix, StringComparison.Ordinal)) .Where(p => p.Name.StartsWith(prefix, StringComparison.Ordinal))
.Select(p => p.Name); .Select(p => p.Name)
.Distinct()
;
} }
public static IEnumerable<string> GetPropertiesCanWritePublic(Type type) public static IEnumerable<string> GetPropertiesCanWritePublic(Type type)
{ {
return GetAllPropertyInfoCanWritePublic(type).Select(p => p.Name); return GetAllPropertyInfoCanWritePublic(type).Select(p => p.Name)
.Distinct()
;
} }
public static IEnumerable<PropertyInfo> GetAllPropertyInfoCanWritePublic(Type type) public static IEnumerable<PropertyInfo> GetAllPropertyInfoCanWritePublic(Type type)
{ {
@ -45,7 +49,9 @@ namespace PKHeX.Core
{ {
return type.GetTypeInfo().GetAllProperties() return type.GetTypeInfo().GetAllProperties()
.Where(p => p.CanWrite && p.SetMethod.IsPublic) .Where(p => p.CanWrite && p.SetMethod.IsPublic)
.Select(p => p.Name); .Select(p => p.Name)
.Distinct()
;
} }
private static object ConvertValue(object value, Type type) private static object ConvertValue(object value, Type type)

View file

@ -53,6 +53,7 @@
this.L_OT_Affection = new System.Windows.Forms.Label(); this.L_OT_Affection = new System.Windows.Forms.Label();
this.M_OT_Affection = new System.Windows.Forms.MaskedTextBox(); this.M_OT_Affection = new System.Windows.Forms.MaskedTextBox();
this.GB_Residence = new System.Windows.Forms.GroupBox(); this.GB_Residence = new System.Windows.Forms.GroupBox();
this.B_ClearAll = new System.Windows.Forms.Button();
this.CB_Region4 = new System.Windows.Forms.ComboBox(); this.CB_Region4 = new System.Windows.Forms.ComboBox();
this.CB_Region3 = new System.Windows.Forms.ComboBox(); this.CB_Region3 = new System.Windows.Forms.ComboBox();
this.CB_Region2 = new System.Windows.Forms.ComboBox(); this.CB_Region2 = new System.Windows.Forms.ComboBox();
@ -88,7 +89,6 @@
this.L_Handler = new System.Windows.Forms.Label(); this.L_Handler = new System.Windows.Forms.Label();
this.CB_Handler = new System.Windows.Forms.ComboBox(); this.CB_Handler = new System.Windows.Forms.ComboBox();
this.L_Arguments = new System.Windows.Forms.Label(); this.L_Arguments = new System.Windows.Forms.Label();
this.B_ClearAll = new System.Windows.Forms.Button();
this.GB_M_OT.SuspendLayout(); this.GB_M_OT.SuspendLayout();
this.GB_Residence.SuspendLayout(); this.GB_Residence.SuspendLayout();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
@ -296,14 +296,6 @@
// //
this.CB_OTQual.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CB_OTQual.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_OTQual.FormattingEnabled = true; this.CB_OTQual.FormattingEnabled = true;
this.CB_OTQual.Items.AddRange(new object[] {
"The Pokémon remembers",
"The Pokémon remembers",
"The Pokémon remembers",
"The Pokémon remembers",
"The Pokémon fondly remembers",
"The Pokémon clearly remembers",
"The Pokémon definitely remembers"});
this.CB_OTQual.Location = new System.Drawing.Point(86, 88); this.CB_OTQual.Location = new System.Drawing.Point(86, 88);
this.CB_OTQual.Name = "CB_OTQual"; this.CB_OTQual.Name = "CB_OTQual";
this.CB_OTQual.Size = new System.Drawing.Size(240, 21); this.CB_OTQual.Size = new System.Drawing.Size(240, 21);
@ -314,31 +306,6 @@
// //
this.CB_OTFeel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CB_OTFeel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_OTFeel.FormattingEnabled = true; this.CB_OTFeel.FormattingEnabled = true;
this.CB_OTFeel.Items.AddRange(new object[] {
"it was happy",
"it had fun",
"it was glad",
"it grinned",
"it got overwhelmed by emotion",
"its feelings were indescribable",
"it felt good",
"it got teary eyed",
"it got lighthearted",
"it got nervous",
"it felt comfortable",
"it was restless",
"it got a bit carried away",
"it felt sorry",
"it got emotional",
"it felt nostalgic",
"it had some difficulty",
"it felt exhausted",
"it couldnt be true to its feelings",
"it felt proud",
"they ended up in a foul mood",
"it got angry",
"it got jealous",
"it got sleepy"});
this.CB_OTFeel.Location = new System.Drawing.Point(86, 111); this.CB_OTFeel.Location = new System.Drawing.Point(86, 111);
this.CB_OTFeel.Name = "CB_OTFeel"; this.CB_OTFeel.Name = "CB_OTFeel";
this.CB_OTFeel.Size = new System.Drawing.Size(170, 21); this.CB_OTFeel.Size = new System.Drawing.Size(170, 21);
@ -390,6 +357,16 @@
this.GB_Residence.TabStop = false; this.GB_Residence.TabStop = false;
this.GB_Residence.Text = "Pokémon has Resided in:"; this.GB_Residence.Text = "Pokémon has Resided in:";
// //
// B_ClearAll
//
this.B_ClearAll.Location = new System.Drawing.Point(82, 157);
this.B_ClearAll.Name = "B_ClearAll";
this.B_ClearAll.Size = new System.Drawing.Size(76, 23);
this.B_ClearAll.TabIndex = 79;
this.B_ClearAll.Text = "Clear All";
this.B_ClearAll.UseVisualStyleBackColor = true;
this.B_ClearAll.Click += new System.EventHandler(this.B_ClearAll_Click);
//
// CB_Region4 // CB_Region4
// //
this.CB_Region4.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.CB_Region4.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
@ -637,14 +614,6 @@
// //
this.CB_CTQual.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CB_CTQual.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_CTQual.FormattingEnabled = true; this.CB_CTQual.FormattingEnabled = true;
this.CB_CTQual.Items.AddRange(new object[] {
"The Pokémon remembers",
"The Pokémon remembers",
"The Pokémon remembers",
"The Pokémon remembers",
"The Pokémon fondly remembers",
"The Pokémon clearly remembers",
"The Pokémon definitely remembers"});
this.CB_CTQual.Location = new System.Drawing.Point(86, 88); this.CB_CTQual.Location = new System.Drawing.Point(86, 88);
this.CB_CTQual.Name = "CB_CTQual"; this.CB_CTQual.Name = "CB_CTQual";
this.CB_CTQual.Size = new System.Drawing.Size(240, 21); this.CB_CTQual.Size = new System.Drawing.Size(240, 21);
@ -655,31 +624,6 @@
// //
this.CB_CTFeel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CB_CTFeel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_CTFeel.FormattingEnabled = true; this.CB_CTFeel.FormattingEnabled = true;
this.CB_CTFeel.Items.AddRange(new object[] {
"it was happy",
"it had fun",
"it was glad",
"it grinned",
"it got overwhelmed by emotion",
"its feelings were indescribable",
"it felt good",
"it got teary eyed",
"it got lighthearted",
"it got nervous",
"it felt comfortable",
"it was restless",
"it got a bit carried away",
"it felt sorry",
"it got emotional",
"it felt nostalgic",
"it had some difficulty",
"it felt exhausted",
"it couldnt be true to its feelings",
"it felt proud",
"they ended up in a foul mood",
"it got angry",
"it got jealous",
"it got sleepy"});
this.CB_CTFeel.Location = new System.Drawing.Point(86, 111); this.CB_CTFeel.Location = new System.Drawing.Point(86, 111);
this.CB_CTFeel.Name = "CB_CTFeel"; this.CB_CTFeel.Name = "CB_CTFeel";
this.CB_CTFeel.Size = new System.Drawing.Size(170, 21); this.CB_CTFeel.Size = new System.Drawing.Size(170, 21);
@ -798,16 +742,6 @@
this.L_Arguments.Text = "(args)"; this.L_Arguments.Text = "(args)";
this.L_Arguments.Visible = false; this.L_Arguments.Visible = false;
// //
// B_ClearAll
//
this.B_ClearAll.Location = new System.Drawing.Point(82, 157);
this.B_ClearAll.Name = "B_ClearAll";
this.B_ClearAll.Size = new System.Drawing.Size(76, 23);
this.B_ClearAll.TabIndex = 79;
this.B_ClearAll.Text = "Clear All";
this.B_ClearAll.UseVisualStyleBackColor = true;
this.B_ClearAll.Click += new System.EventHandler(this.B_ClearAll_Click);
//
// MemoryAmie // MemoryAmie
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View file

@ -46,7 +46,7 @@ namespace PKHeX.WinForms
private void PopulateRibbons() private void PopulateRibbons()
{ {
// Get a list of all Ribbon Attributes in the PKM // Get a list of all Ribbon Attributes in the PKM
var RibbonNames = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), "Ribbon").Distinct(); var RibbonNames = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), "Ribbon");
foreach (var RibbonName in RibbonNames) foreach (var RibbonName in RibbonNames)
{ {
object RibbonValue = ReflectUtil.GetValue(pkm, RibbonName); object RibbonValue = ReflectUtil.GetValue(pkm, RibbonName);