Add tracker editor

This commit is contained in:
Kurt 2020-02-12 18:10:03 -08:00
parent b72c6d4776
commit e77fa205a0
4 changed files with 141 additions and 68 deletions

View file

@ -89,6 +89,38 @@ namespace PKHeX.Core
return result;
}
/// <summary>
/// Parses the hex string into a <see cref="ulong"/>, skipping all characters except for valid digits.
/// </summary>
/// <param name="value">Hex String to parse</param>
/// <returns>Parsed value</returns>
public static ulong GetHexValue64(string value)
{
ulong result = 0;
if (string.IsNullOrEmpty(value))
return result;
foreach (var c in value)
{
if (IsNum(c))
{
result <<= 4;
result += (uint)(c - '0');
}
else if (IsHexUpper(c))
{
result <<= 4;
result += (uint)(c - 'A' + 10);
}
else if (IsHexLower(c))
{
result <<= 4;
result += (uint)(c - 'a' + 10);
}
}
return result;
}
public static byte[] GetBytesFromHexString(string seed)
{
return Enumerable.Range(0, seed.Length)

View file

@ -400,6 +400,7 @@ namespace PKHeX.WinForms.Controls
Stats.CB_DynamaxLevel.SelectedIndex = pk8.DynamaxLevel;
Stats.CHK_Gigantamax.Checked = pk8.CanGigantamax;
CB_HTLanguage.SelectedValue = pk8.HT_Language;
TB_HomeTracker.Text = pk8.Tracker.ToString("X16");
}
private void SaveMisc8(PK8 pk8)

View file

@ -120,10 +120,15 @@
this.CHK_Shadow = new System.Windows.Forms.CheckBox();
this.FLP_ShinyLeaf = new System.Windows.Forms.FlowLayoutPanel();
this.L_ShinyLeaf = new System.Windows.Forms.Label();
this.ShinyLeaf = new PKHeX.WinForms.Controls.ShinyLeaf();
this.FLP_CatchRate = new System.Windows.Forms.FlowLayoutPanel();
this.L_CatchRate = new System.Windows.Forms.Label();
this.CR_PK1 = new PKHeX.WinForms.Controls.CatchRate();
this.FLP_SizeCP = new System.Windows.Forms.FlowLayoutPanel();
this.SizeCP = new PKHeX.WinForms.Controls.SizeCP();
this.Tab_Met = new System.Windows.Forms.TabPage();
this.TB_HomeTracker = new System.Windows.Forms.TextBox();
this.L_HomeTracker = new System.Windows.Forms.Label();
this.CHK_AsEgg = new System.Windows.Forms.CheckBox();
this.GB_EggConditions = new System.Windows.Forms.GroupBox();
this.CB_EggLocation = new System.Windows.Forms.ComboBox();
@ -158,6 +163,8 @@
this.L_MetTimeOfDay = new System.Windows.Forms.Label();
this.CB_MetTimeOfDay = new System.Windows.Forms.ComboBox();
this.Tab_Stats = new System.Windows.Forms.TabPage();
this.Stats = new PKHeX.WinForms.Controls.StatEditor();
this.Contest = new PKHeX.WinForms.Controls.ContestStat();
this.Tab_Attacks = new System.Windows.Forms.TabPage();
this.B_Records = new System.Windows.Forms.Button();
this.PB_WarnMove4 = new System.Windows.Forms.PictureBox();
@ -215,6 +222,7 @@
this.TB_ExtraByte = new System.Windows.Forms.MaskedTextBox();
this.CB_ExtraBytes = new System.Windows.Forms.ComboBox();
this.GB_OT = new System.Windows.Forms.GroupBox();
this.TID_Trainer = new PKHeX.WinForms.Controls.TrainerID();
this.Label_OTGender = new System.Windows.Forms.Label();
this.TB_OT = new System.Windows.Forms.TextBox();
this.Label_OT = new System.Windows.Forms.Label();
@ -222,12 +230,6 @@
this.SpeciesIDTip = new System.Windows.Forms.ToolTip(this.components);
this.NatureTip = new System.Windows.Forms.ToolTip(this.components);
this.Tip3 = new System.Windows.Forms.ToolTip(this.components);
this.ShinyLeaf = new PKHeX.WinForms.Controls.ShinyLeaf();
this.CR_PK1 = new PKHeX.WinForms.Controls.CatchRate();
this.SizeCP = new PKHeX.WinForms.Controls.SizeCP();
this.Stats = new PKHeX.WinForms.Controls.StatEditor();
this.Contest = new PKHeX.WinForms.Controls.ContestStat();
this.TID_Trainer = new PKHeX.WinForms.Controls.TrainerID();
this.tabMain.SuspendLayout();
this.Tab_Main.SuspendLayout();
this.FLP_Main.SuspendLayout();
@ -1425,6 +1427,14 @@
this.L_ShinyLeaf.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.L_ShinyLeaf.Click += new System.EventHandler(this.ClickShinyLeaf);
//
// ShinyLeaf
//
this.ShinyLeaf.Location = new System.Drawing.Point(110, 0);
this.ShinyLeaf.Margin = new System.Windows.Forms.Padding(0);
this.ShinyLeaf.Name = "ShinyLeaf";
this.ShinyLeaf.Size = new System.Drawing.Size(140, 56);
this.ShinyLeaf.TabIndex = 116;
//
// FLP_CatchRate
//
this.FLP_CatchRate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
@ -1446,6 +1456,14 @@
this.L_CatchRate.Text = "Catch Rate:";
this.L_CatchRate.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CR_PK1
//
this.CR_PK1.Location = new System.Drawing.Point(110, 0);
this.CR_PK1.Margin = new System.Windows.Forms.Padding(0);
this.CR_PK1.Name = "CR_PK1";
this.CR_PK1.Size = new System.Drawing.Size(162, 25);
this.CR_PK1.TabIndex = 10;
//
// FLP_SizeCP
//
this.FLP_SizeCP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
@ -1456,9 +1474,20 @@
this.FLP_SizeCP.Size = new System.Drawing.Size(272, 72);
this.FLP_SizeCP.TabIndex = 21;
//
// SizeCP
//
this.SizeCP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.SizeCP.Location = new System.Drawing.Point(50, 0);
this.SizeCP.Margin = new System.Windows.Forms.Padding(50, 0, 0, 0);
this.SizeCP.Name = "SizeCP";
this.SizeCP.Size = new System.Drawing.Size(204, 68);
this.SizeCP.TabIndex = 0;
//
// Tab_Met
//
this.Tab_Met.AllowDrop = true;
this.Tab_Met.Controls.Add(this.TB_HomeTracker);
this.Tab_Met.Controls.Add(this.L_HomeTracker);
this.Tab_Met.Controls.Add(this.CHK_AsEgg);
this.Tab_Met.Controls.Add(this.GB_EggConditions);
this.Tab_Met.Controls.Add(this.FLP_Met);
@ -1470,6 +1499,27 @@
this.Tab_Met.Text = "Met";
this.Tab_Met.UseVisualStyleBackColor = true;
//
// TB_HomeTracker
//
this.TB_HomeTracker.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.TB_HomeTracker.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TB_HomeTracker.Location = new System.Drawing.Point(110, 302);
this.TB_HomeTracker.MaxLength = 8;
this.TB_HomeTracker.Name = "TB_HomeTracker";
this.TB_HomeTracker.Size = new System.Drawing.Size(118, 20);
this.TB_HomeTracker.TabIndex = 10;
this.TB_HomeTracker.Text = "0123456789ABCDEF";
this.TB_HomeTracker.Validated += new System.EventHandler(this.Update_ID64);
//
// L_HomeTracker
//
this.L_HomeTracker.Location = new System.Drawing.Point(-13, 304);
this.L_HomeTracker.Name = "L_HomeTracker";
this.L_HomeTracker.Size = new System.Drawing.Size(120, 13);
this.L_HomeTracker.TabIndex = 9;
this.L_HomeTracker.Text = "HOME Tracker:";
this.L_HomeTracker.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CHK_AsEgg
//
this.CHK_AsEgg.AutoSize = true;
@ -1856,11 +1906,38 @@
this.Tab_Stats.Location = new System.Drawing.Point(4, 22);
this.Tab_Stats.Name = "Tab_Stats";
this.Tab_Stats.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Stats.Size = new System.Drawing.Size(307, 539);
this.Tab_Stats.Size = new System.Drawing.Size(192, 74);
this.Tab_Stats.TabIndex = 2;
this.Tab_Stats.Text = "Stats";
this.Tab_Stats.UseVisualStyleBackColor = true;
//
// Stats
//
this.Stats.EVsFishy = System.Drawing.Color.LightYellow;
this.Stats.EVsInvalid = System.Drawing.Color.Red;
this.Stats.EVsMaxed = System.Drawing.Color.Honeydew;
this.Stats.Location = new System.Drawing.Point(0, 0);
this.Stats.Name = "Stats";
this.Stats.Size = new System.Drawing.Size(270, 264);
this.Stats.StatDecreased = System.Drawing.Color.Blue;
this.Stats.StatHyperTrained = System.Drawing.Color.LightGreen;
this.Stats.StatIncreased = System.Drawing.Color.Red;
this.Stats.TabIndex = 1;
//
// Contest
//
this.Contest.CNT_Beauty = 0;
this.Contest.CNT_Cool = 0;
this.Contest.CNT_Cute = 0;
this.Contest.CNT_Sheen = 0;
this.Contest.CNT_Smart = 0;
this.Contest.CNT_Tough = 0;
this.Contest.Location = new System.Drawing.Point(21, 265);
this.Contest.Margin = new System.Windows.Forms.Padding(0);
this.Contest.Name = "Contest";
this.Contest.Size = new System.Drawing.Size(230, 50);
this.Contest.TabIndex = 2;
//
// Tab_Attacks
//
this.Tab_Attacks.AllowDrop = true;
@ -1874,7 +1951,7 @@
this.Tab_Attacks.Location = new System.Drawing.Point(4, 22);
this.Tab_Attacks.Name = "Tab_Attacks";
this.Tab_Attacks.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Attacks.Size = new System.Drawing.Size(307, 539);
this.Tab_Attacks.Size = new System.Drawing.Size(192, 74);
this.Tab_Attacks.TabIndex = 3;
this.Tab_Attacks.Text = "Attacks";
this.Tab_Attacks.UseVisualStyleBackColor = true;
@ -2273,7 +2350,7 @@
this.Tab_OTMisc.Location = new System.Drawing.Point(4, 22);
this.Tab_OTMisc.Name = "Tab_OTMisc";
this.Tab_OTMisc.Padding = new System.Windows.Forms.Padding(3);
this.Tab_OTMisc.Size = new System.Drawing.Size(307, 539);
this.Tab_OTMisc.Size = new System.Drawing.Size(192, 74);
this.Tab_OTMisc.TabIndex = 4;
this.Tab_OTMisc.Text = "OT/Misc";
this.Tab_OTMisc.UseVisualStyleBackColor = true;
@ -2603,6 +2680,13 @@
this.GB_OT.TabStop = false;
this.GB_OT.Text = "Trainer Information";
//
// TID_Trainer
//
this.TID_Trainer.Location = new System.Drawing.Point(13, 18);
this.TID_Trainer.Name = "TID_Trainer";
this.TID_Trainer.Size = new System.Drawing.Size(178, 27);
this.TID_Trainer.TabIndex = 57;
//
// Label_OTGender
//
this.Label_OTGender.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -2643,65 +2727,6 @@
this.Label_EncryptionConstant.Text = "Encryption Constant:";
this.Label_EncryptionConstant.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// ShinyLeaf
//
this.ShinyLeaf.Location = new System.Drawing.Point(110, 0);
this.ShinyLeaf.Margin = new System.Windows.Forms.Padding(0);
this.ShinyLeaf.Name = "ShinyLeaf";
this.ShinyLeaf.Size = new System.Drawing.Size(140, 56);
this.ShinyLeaf.TabIndex = 116;
//
// CR_PK1
//
this.CR_PK1.Location = new System.Drawing.Point(110, 0);
this.CR_PK1.Margin = new System.Windows.Forms.Padding(0);
this.CR_PK1.Name = "CR_PK1";
this.CR_PK1.Size = new System.Drawing.Size(162, 25);
this.CR_PK1.TabIndex = 10;
//
// SizeCP
//
this.SizeCP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.SizeCP.Location = new System.Drawing.Point(50, 0);
this.SizeCP.Margin = new System.Windows.Forms.Padding(50, 0, 0, 0);
this.SizeCP.Name = "SizeCP";
this.SizeCP.Size = new System.Drawing.Size(204, 68);
this.SizeCP.TabIndex = 0;
//
// Stats
//
this.Stats.EVsFishy = System.Drawing.Color.LightYellow;
this.Stats.EVsInvalid = System.Drawing.Color.Red;
this.Stats.EVsMaxed = System.Drawing.Color.Honeydew;
this.Stats.Location = new System.Drawing.Point(0, 0);
this.Stats.Name = "Stats";
this.Stats.Size = new System.Drawing.Size(270, 264);
this.Stats.StatDecreased = System.Drawing.Color.Blue;
this.Stats.StatHyperTrained = System.Drawing.Color.LightGreen;
this.Stats.StatIncreased = System.Drawing.Color.Red;
this.Stats.TabIndex = 1;
//
// Contest
//
this.Contest.CNT_Beauty = 0;
this.Contest.CNT_Cool = 0;
this.Contest.CNT_Cute = 0;
this.Contest.CNT_Sheen = 0;
this.Contest.CNT_Smart = 0;
this.Contest.CNT_Tough = 0;
this.Contest.Location = new System.Drawing.Point(21, 265);
this.Contest.Margin = new System.Windows.Forms.Padding(0);
this.Contest.Name = "Contest";
this.Contest.Size = new System.Drawing.Size(230, 50);
this.Contest.TabIndex = 2;
//
// TID_Trainer
//
this.TID_Trainer.Location = new System.Drawing.Point(13, 18);
this.TID_Trainer.Name = "TID_Trainer";
this.TID_Trainer.Size = new System.Drawing.Size(178, 27);
this.TID_Trainer.TabIndex = 57;
//
// PKMEditor
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
@ -3017,5 +3042,7 @@
private System.Windows.Forms.ComboBox CB_Form;
private System.Windows.Forms.MaskedTextBox MT_Form;
private System.Windows.Forms.ComboBox CB_FormArgument;
private System.Windows.Forms.TextBox TB_HomeTracker;
private System.Windows.Forms.Label L_HomeTracker;
}
}

View file

@ -1465,6 +1465,19 @@ namespace PKHeX.WinForms.Controls
}
}
private void Update_ID64(object sender, EventArgs e)
{
if (!FieldsLoaded)
return;
// Trim out nonhex characters
if (sender == TB_HomeTracker && Entity is PK8 pk8)
{
var value = Util.GetHexValue64(TB_HomeTracker.Text);
pk8.Tracker = value;
TB_HomeTracker.Text = value.ToString("X16");
}
}
private void UpdateShadowID(object sender, EventArgs e)
{
if (!FieldsLoaded)