Add TrainerID control

Now shows tid7/sid7 when gen7+
This commit is contained in:
Kurt 2018-04-28 09:34:54 -07:00
parent fc72323c2e
commit 43507a5ae5
8 changed files with 492 additions and 173 deletions

View file

@ -39,15 +39,12 @@ namespace PKHeX.WinForms.Controls
TB_OT.Text = pk.OT_Name;
Label_OTGender.Text = gendersymbols[pk.OT_Gender];
Label_OTGender.ForeColor = GetGenderColor(pk.OT_Gender);
TB_TID.Text = $"{pk.TID:00000}";
TB_SID.Text = $"{pk.SID:00000}";
TID_Trainer.LoadIDValues(pk);
}
private void SaveOTID(PKM pk)
{
pk.OT_Name = TB_OT.Text;
pk.OT_Gender = PKX.GetGenderFromString(Label_OTGender.Text);
pk.TID = Util.ToInt32(TB_TID.Text);
pk.SID = Util.ToInt32(TB_SID.Text);
}
private void LoadPKRS(PKM pk)
@ -343,11 +340,9 @@ namespace PKHeX.WinForms.Controls
uint EC = Util.GetHexValue(TB_EC.Text);
uint PID = Util.GetHexValue(TB_PID.Text);
uint SID = Util.ToUInt32(TB_SID.Text);
uint TID = Util.ToUInt32(TB_TID.Text);
uint LID = PID & 0xFFFF;
uint HID = PID >> 16;
uint XOR = TID ^ LID ^ SID ^ HID;
uint XOR = (uint)(pkm.TID ^ LID ^ pkm.SID ^ HID);
// Ensure we don't have a shiny.
if (XOR >> 3 == 1) // Illegal, fix. (not 16<XOR>=8)

View file

@ -112,7 +112,6 @@
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.Tab_Met = new System.Windows.Forms.TabPage();
this.CHK_AsEgg = new System.Windows.Forms.CheckBox();
this.GB_EggConditions = new System.Windows.Forms.GroupBox();
@ -148,8 +147,6 @@
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.PB_WarnMove4 = new System.Windows.Forms.PictureBox();
this.PB_WarnMove3 = new System.Windows.Forms.PictureBox();
@ -209,12 +206,12 @@
this.GB_OT = new System.Windows.Forms.GroupBox();
this.Label_OTGender = new System.Windows.Forms.Label();
this.TB_OT = new System.Windows.Forms.TextBox();
this.TB_SID = new System.Windows.Forms.MaskedTextBox();
this.TB_TID = new System.Windows.Forms.MaskedTextBox();
this.Label_OT = new System.Windows.Forms.Label();
this.Label_SID = new System.Windows.Forms.Label();
this.Label_TID = new System.Windows.Forms.Label();
this.Label_EncryptionConstant = new System.Windows.Forms.Label();
this.ShinyLeaf = new PKHeX.WinForms.Controls.ShinyLeaf();
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();
@ -1319,15 +1316,6 @@
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;
this.ShinyLeaf.Value = 0;
//
// Tab_Met
//
this.Tab_Met.AllowDrop = true;
@ -1733,27 +1721,6 @@
this.Tab_Stats.Text = "Stats";
this.Tab_Stats.UseVisualStyleBackColor = true;
//
// Stats
//
this.Stats.Location = new System.Drawing.Point(0, 0);
this.Stats.Name = "Stats";
this.Stats.Size = new System.Drawing.Size(270, 240);
this.Stats.TabIndex = 118;
//
// Contest
//
this.Contest.Beauty = 0;
this.Contest.Cool = 0;
this.Contest.Cute = 0;
this.Contest.Location = new System.Drawing.Point(21, 247);
this.Contest.Margin = new System.Windows.Forms.Padding(0);
this.Contest.Name = "Contest";
this.Contest.Sheen = 0;
this.Contest.Size = new System.Drawing.Size(230, 50);
this.Contest.Smart = 0;
this.Contest.TabIndex = 117;
this.Contest.Tough = 0;
//
// Tab_Attacks
//
this.Tab_Attacks.AllowDrop = true;
@ -2471,13 +2438,10 @@
//
// GB_OT
//
this.GB_OT.Controls.Add(this.TID_Trainer);
this.GB_OT.Controls.Add(this.Label_OTGender);
this.GB_OT.Controls.Add(this.TB_OT);
this.GB_OT.Controls.Add(this.TB_SID);
this.GB_OT.Controls.Add(this.TB_TID);
this.GB_OT.Controls.Add(this.Label_OT);
this.GB_OT.Controls.Add(this.Label_SID);
this.GB_OT.Controls.Add(this.Label_TID);
this.GB_OT.Location = new System.Drawing.Point(40, 8);
this.GB_OT.Name = "GB_OT";
this.GB_OT.Size = new System.Drawing.Size(190, 75);
@ -2506,30 +2470,6 @@
this.TB_OT.TabIndex = 3;
this.TB_OT.MouseDown += new System.Windows.Forms.MouseEventHandler(this.UpdateNicknameClick);
//
// TB_SID
//
this.TB_SID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.TB_SID.Location = new System.Drawing.Point(132, 20);
this.TB_SID.Mask = "00000";
this.TB_SID.Name = "TB_SID";
this.TB_SID.Size = new System.Drawing.Size(40, 20);
this.TB_SID.TabIndex = 2;
this.TB_SID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.TB_SID.MouseHover += new System.EventHandler(this.UpdateTSV);
this.TB_SID.Validated += new System.EventHandler(this.Update_ID);
//
// TB_TID
//
this.TB_TID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.TB_TID.Location = new System.Drawing.Point(46, 20);
this.TB_TID.Mask = "00000";
this.TB_TID.Name = "TB_TID";
this.TB_TID.Size = new System.Drawing.Size(40, 20);
this.TB_TID.TabIndex = 1;
this.TB_TID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.TB_TID.MouseHover += new System.EventHandler(this.UpdateTSV);
this.TB_TID.Validated += new System.EventHandler(this.Update_ID);
//
// Label_OT
//
this.Label_OT.Location = new System.Drawing.Point(4, 48);
@ -2540,24 +2480,6 @@
this.Label_OT.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.Label_OT.Click += new System.EventHandler(this.ClickOT);
//
// Label_SID
//
this.Label_SID.Location = new System.Drawing.Point(86, 22);
this.Label_SID.Name = "Label_SID";
this.Label_SID.Size = new System.Drawing.Size(45, 13);
this.Label_SID.TabIndex = 4;
this.Label_SID.Text = "SID:";
this.Label_SID.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// Label_TID
//
this.Label_TID.Location = new System.Drawing.Point(4, 22);
this.Label_TID.Name = "Label_TID";
this.Label_TID.Size = new System.Drawing.Size(40, 13);
this.Label_TID.TabIndex = 3;
this.Label_TID.Text = "TID:";
this.Label_TID.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// Label_EncryptionConstant
//
this.Label_EncryptionConstant.Location = new System.Drawing.Point(20, 279);
@ -2567,6 +2489,43 @@
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;
this.ShinyLeaf.Value = 0;
//
// Stats
//
this.Stats.Location = new System.Drawing.Point(0, 0);
this.Stats.Name = "Stats";
this.Stats.Size = new System.Drawing.Size(270, 240);
this.Stats.TabIndex = 118;
//
// Contest
//
this.Contest.Beauty = 0;
this.Contest.Cool = 0;
this.Contest.Cute = 0;
this.Contest.Location = new System.Drawing.Point(21, 247);
this.Contest.Margin = new System.Windows.Forms.Padding(0);
this.Contest.Name = "Contest";
this.Contest.Sheen = 0;
this.Contest.Size = new System.Drawing.Size(230, 50);
this.Contest.Smart = 0;
this.Contest.TabIndex = 117;
this.Contest.Tough = 0;
//
// 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;
@ -2852,16 +2811,13 @@
public System.Windows.Forms.GroupBox GB_OT;
private System.Windows.Forms.Label Label_OTGender;
private System.Windows.Forms.TextBox TB_OT;
private System.Windows.Forms.MaskedTextBox TB_SID;
private System.Windows.Forms.MaskedTextBox TB_TID;
private System.Windows.Forms.Label Label_OT;
private System.Windows.Forms.Label Label_SID;
private System.Windows.Forms.Label Label_TID;
private System.Windows.Forms.Label Label_EncryptionConstant;
private System.Windows.Forms.FlowLayoutPanel FLP_ShinyLeaf;
private System.Windows.Forms.Label L_ShinyLeaf;
private Controls.ShinyLeaf ShinyLeaf;
private ContestStat Contest;
private StatEditor Stats;
private TrainerID TID_Trainer;
}
}

View file

@ -45,6 +45,7 @@ namespace PKHeX.WinForms.Controls
Stats.SetMainEditor(this);
LoadShowdownSet = LoadShowdownSetDefault;
TID_Trainer.UpdatedID += Update_ID;
}
private void UpdateStats() => Stats.UpdateStats();
@ -82,7 +83,7 @@ namespace PKHeX.WinForms.Controls
public delegate SaveFile ReturnSAVEventHandler(object sender, EventArgs e);
private readonly PictureBox[] movePB, relearnPB;
private readonly ToolTip Tip1 = new ToolTip(), Tip2 = new ToolTip(), Tip3 = new ToolTip(), NatureTip = new ToolTip();
private readonly ToolTip Tip3 = new ToolTip(), NatureTip = new ToolTip();
private SaveFile RequestSaveFile => SaveFileRequested?.Invoke(this, EventArgs.Empty);
public bool PKMIsUnsaved => FieldsInitialized && FieldsLoaded && LastData != null && LastData.Any(b => b != 0) && !LastData.SequenceEqual(CurrentPKM.Data);
public bool IsEmptyOrEgg => CHK_IsEgg.Checked || CB_Species.SelectedIndex == 0;
@ -278,7 +279,7 @@ namespace PKHeX.WinForms.Controls
if (!Unicode)
{
BTN_Shinytize.Text = "*";
TB_Nickname.Font = TB_OT.Font = TB_OTt2.Font = Label_TID.Font;
TB_Nickname.Font = TB_OT.Font = TB_OTt2.Font = GB_OT.Font;
}
else
{
@ -317,8 +318,7 @@ namespace PKHeX.WinForms.Controls
TB_OT.Text = SAV.OT;
Label_OTGender.Text = gendersymbols[SAV.Gender & 1];
Label_OTGender.ForeColor = GetGenderColor(SAV.Gender & 1);
TB_TID.Text = SAV.TID.ToString("00000");
TB_SID.Text = SAV.SID.ToString("00000");
TID_Trainer.LoadInfo(SAV);
if (SAV.Game >= 0)
CB_GameOrigin.SelectedValue = SAV.Game;
@ -412,10 +412,6 @@ namespace PKHeX.WinForms.Controls
{
if (sender == TB_PID)
pkm.PID = Util.GetHexValue(TB_PID.Text);
else if (sender == TB_TID)
pkm.TID = (int)Util.ToUInt32(TB_TID.Text);
else if (sender == TB_SID)
pkm.SID = (int)Util.ToUInt32(TB_SID.Text);
// Recalculate shininiess
bool isShiny = pkm.IsShiny;
@ -1061,6 +1057,12 @@ namespace PKHeX.WinForms.Controls
if (!FieldsLoaded)
CB_GameOrigin.Focus(); // hacky validation forcing
if (FieldsLoaded)
{
pkm.Version = (int)Version;
TID_Trainer.LoadIDValues(pkm);
}
}
// Visibility logic for Gen 4 encounter type; only show for Gen 4 Pokemon.
@ -1232,7 +1234,7 @@ namespace PKHeX.WinForms.Controls
bool isTraded = false;
var SAV = SaveFileRequested?.Invoke(this, e);
if (SAV != null)
isTraded = SAV.OT != TB_OT.Text || SAV.TID != Util.ToInt32(TB_TID.Text) || SAV.SID != Util.ToInt32(TB_SID.Text);
isTraded = SAV.OT != TB_OT.Text || SAV.TID != pkm.TID || SAV.SID != pkm.SID;
CB_MetLocation.SelectedIndex = isTraded ? 2 : 0;
if (!CHK_Nicknamed.Checked)
@ -1293,8 +1295,6 @@ namespace PKHeX.WinForms.Controls
}
private void UpdateShiny(bool PID)
{
pkm.TID = Util.ToInt32(TB_TID.Text);
pkm.SID = Util.ToInt32(TB_SID.Text);
pkm.PID = Util.GetHexValue(TB_PID.Text);
pkm.Nature = WinFormsUtil.GetIndex(CB_Nature);
pkm.Gender = PKX.GetGenderFromString(Label_Gender.Text);
@ -1314,7 +1314,7 @@ namespace PKHeX.WinForms.Controls
else
{
pkm.SetShinySID();
TB_SID.Text = pkm.SID.ToString();
TID_Trainer.UpdateSID();
}
}
else
@ -1333,12 +1333,7 @@ namespace PKHeX.WinForms.Controls
if (pkm.Format < 6)
return;
string IDstr = $"TSV: {pkm.TSV:d4}";
if (pkm.Format > 6)
IDstr += Environment.NewLine + $"G7TID: ({pkm.TrainerSID7:d4}){pkm.TrainerID7:d6}";
Tip1.SetToolTip(TB_TID, IDstr);
Tip2.SetToolTip(TB_SID, IDstr);
TID_Trainer.UpdateTSV();
pkm.PID = Util.GetHexValue(TB_PID.Text);
Tip3.SetToolTip(TB_PID, $"PSV: {pkm.PSV:d4}");
@ -1349,10 +1344,6 @@ namespace PKHeX.WinForms.Controls
TB_PID.Text = Util.GetHexValue(TB_PID.Text).ToString("X8");
TB_EC.Text = Util.GetHexValue(TB_EC.Text).ToString("X8");
// Max TID/SID is 65535
if (Util.ToUInt32(TB_TID.Text) > ushort.MaxValue) TB_TID.Text = "65535";
if (Util.ToUInt32(TB_SID.Text) > ushort.MaxValue) TB_SID.Text = "65535";
SetIsShiny(sender);
UpdateSprite();
Stats.UpdateIVs(null, null); // If the EC is changed, EC%6 (Characteristic) might be changed.
@ -1519,8 +1510,6 @@ namespace PKHeX.WinForms.Controls
}
private void ToggleInterface(int gen)
{
Tip1.RemoveAll(); Tip2.RemoveAll(); Tip3.RemoveAll(); // TSV/PSV
FLP_Country.Visible = FLP_SubRegion.Visible = FLP_3DSRegion.Visible = gen >= 6;
Label_EncryptionConstant.Visible = BTN_RerollEC.Visible = TB_EC.Visible = gen >= 6;
GB_nOT.Visible = GB_RelearnMoves.Visible = BTN_Medals.Visible = BTN_History.Visible = gen >= 6;
@ -1541,7 +1530,7 @@ namespace PKHeX.WinForms.Controls
GB_Markings.Visible = gen >= 3;
BTN_Ribbons.Visible = gen >= 3;
CB_Form.Enabled = gen >= 3;
BTN_RerollPID.Visible = Label_PID.Visible = TB_PID.Visible = Label_SID.Visible = TB_SID.Visible = gen >= 3;
BTN_RerollPID.Visible = Label_PID.Visible = TB_PID.Visible = gen >= 3;
FLP_FriendshipForm.Visible = gen >= 2;
FLP_HeldItem.Visible = gen >= 2;

View file

@ -123,6 +123,18 @@
<metadata name="GB_EggConditions.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CB_EggLocation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CAL_EggDate.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_EggDate.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_EggLocation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PB_WarnMove4.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -461,36 +473,6 @@
<metadata name="CHK_Shadow.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_AsEgg.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="GB_EggConditions.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CB_EggLocation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CAL_EggDate.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_EggDate.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_EggLocation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CB_EggLocation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CAL_EggDate.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_EggDate.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_EggLocation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_OriginGame.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -1315,42 +1297,18 @@
<metadata name="TB_OT.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TB_SID.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TB_TID.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_OT.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_SID.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_TID.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_OTGender.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TB_OT.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TB_SID.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TB_TID.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_OT.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_SID.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_TID.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label_EncryptionConstant.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

View file

@ -0,0 +1,156 @@
namespace PKHeX.WinForms.Controls
{
partial class TrainerID
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.FLP = new System.Windows.Forms.FlowLayoutPanel();
this.Label_TID = new System.Windows.Forms.Label();
this.TB_TID = new System.Windows.Forms.MaskedTextBox();
this.TB_TID7 = new System.Windows.Forms.MaskedTextBox();
this.Label_SID = new System.Windows.Forms.Label();
this.TB_SID = new System.Windows.Forms.MaskedTextBox();
this.TB_SID7 = new System.Windows.Forms.MaskedTextBox();
this.FLP.SuspendLayout();
this.SuspendLayout();
//
// FLP
//
this.FLP.Controls.Add(this.Label_TID);
this.FLP.Controls.Add(this.TB_TID);
this.FLP.Controls.Add(this.TB_TID7);
this.FLP.Controls.Add(this.Label_SID);
this.FLP.Controls.Add(this.TB_SID);
this.FLP.Controls.Add(this.TB_SID7);
this.FLP.Dock = System.Windows.Forms.DockStyle.Fill;
this.FLP.Location = new System.Drawing.Point(0, 0);
this.FLP.Name = "FLP";
this.FLP.Size = new System.Drawing.Size(125, 54);
this.FLP.TabIndex = 0;
//
// Label_TID
//
this.Label_TID.AutoSize = true;
this.Label_TID.Location = new System.Drawing.Point(3, 6);
this.Label_TID.Margin = new System.Windows.Forms.Padding(3, 6, 2, 0);
this.Label_TID.Name = "Label_TID";
this.Label_TID.Size = new System.Drawing.Size(28, 13);
this.Label_TID.TabIndex = 7;
this.Label_TID.Text = "TID:";
this.Label_TID.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// TB_TID
//
this.TB_TID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.TB_TID.Location = new System.Drawing.Point(33, 3);
this.TB_TID.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);
this.TB_TID.Mask = "00000";
this.TB_TID.Name = "TB_TID";
this.TB_TID.Size = new System.Drawing.Size(40, 20);
this.TB_TID.TabIndex = 5;
this.TB_TID.Text = "12345";
this.TB_TID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.TB_TID.MouseHover += new System.EventHandler(this.UpdateTSV);
this.TB_TID.Validated += new System.EventHandler(this.Update_ID);
//
// TB_TID7
//
this.TB_TID7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.TB_TID7.Location = new System.Drawing.Point(76, 3);
this.TB_TID7.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);
this.TB_TID7.Mask = "000000";
this.TB_TID7.Name = "TB_TID7";
this.TB_TID7.Size = new System.Drawing.Size(42, 20);
this.TB_TID7.TabIndex = 9;
this.TB_TID7.Text = "123456";
this.TB_TID7.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.TB_TID7.MouseHover += new System.EventHandler(this.UpdateTSV);
this.TB_TID7.Validated += new System.EventHandler(this.Update_ID);
//
// Label_SID
//
this.Label_SID.AutoSize = true;
this.Label_SID.Location = new System.Drawing.Point(3, 32);
this.Label_SID.Margin = new System.Windows.Forms.Padding(3, 6, 2, 0);
this.Label_SID.Name = "Label_SID";
this.Label_SID.Size = new System.Drawing.Size(28, 13);
this.Label_SID.TabIndex = 8;
this.Label_SID.Text = "SID:";
this.Label_SID.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// TB_SID
//
this.TB_SID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.TB_SID.Location = new System.Drawing.Point(33, 29);
this.TB_SID.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);
this.TB_SID.Mask = "00000";
this.TB_SID.Name = "TB_SID";
this.TB_SID.Size = new System.Drawing.Size(40, 20);
this.TB_SID.TabIndex = 6;
this.TB_SID.Text = "12345";
this.TB_SID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.TB_SID.MouseHover += new System.EventHandler(this.UpdateTSV);
this.TB_SID.Validated += new System.EventHandler(this.Update_ID);
//
// TB_SID7
//
this.TB_SID7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.TB_SID7.Location = new System.Drawing.Point(76, 29);
this.TB_SID7.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);
this.TB_SID7.Mask = "0000";
this.TB_SID7.Name = "TB_SID7";
this.TB_SID7.Size = new System.Drawing.Size(30, 20);
this.TB_SID7.TabIndex = 10;
this.TB_SID7.Text = "1234";
this.TB_SID7.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.TB_SID7.MouseHover += new System.EventHandler(this.UpdateTSV);
this.TB_SID7.Validated += new System.EventHandler(this.Update_ID);
//
// TrainerID
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.FLP);
this.Name = "TrainerID";
this.Size = new System.Drawing.Size(125, 54);
this.FLP.ResumeLayout(false);
this.FLP.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.FlowLayoutPanel FLP;
private System.Windows.Forms.MaskedTextBox TB_SID;
private System.Windows.Forms.MaskedTextBox TB_TID;
private System.Windows.Forms.Label Label_SID;
private System.Windows.Forms.Label Label_TID;
private System.Windows.Forms.MaskedTextBox TB_TID7;
private System.Windows.Forms.MaskedTextBox TB_SID7;
}
}

View file

@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using PKHeX.Core;
namespace PKHeX.WinForms.Controls
{
public partial class TrainerID : UserControl
{
public TrainerID() => InitializeComponent();
public event EventHandler UpdatedID;
private int Format = -1;
private PKM pkm;
private readonly ToolTip TSVTooltip = new ToolTip();
public void UpdateTSV()
{
string IDstr = $"TSV: {pkm.TSV:d4}";
TSVTooltip.SetToolTip(TB_TID, IDstr);
TSVTooltip.SetToolTip(TB_SID, IDstr);
TSVTooltip.SetToolTip(TB_TID7, IDstr);
TSVTooltip.SetToolTip(TB_SID7, IDstr);
}
public void LoadIDValues(PKM pk)
{
pkm = pk;
SetFormat(pkm.GenNumber);
LoadValues();
}
public void UpdateSID() => LoadValues();
public void LoadInfo(ITrainerInfo info)
{
pkm.TID = info.TID;
pkm.SID = info.SID;
LoadValues();
}
private void LoadValues()
{
if (Format <= 2)
TB_TID.Text = pkm.TID.ToString();
else if (Format <= 6)
LoadTID(pkm.TID, pkm.SID);
else
LoadTID7(pkm.TID, pkm.SID);
}
private void LoadTID(int tid, int sid)
{
TB_TID.Text = tid.ToString("D5");
TB_SID.Text = sid.ToString("D5");
}
private void LoadTID7(int tid, int sid)
{
var repack = (uint)((sid << 16) | tid);
sid = (int)(repack / 1_000_000);
tid = (int)(repack % 1_000_000);
TB_TID7.Text = tid.ToString("D6");
TB_SID7.Text = sid.ToString("D4");
}
private void SetFormat(int format)
{
if (format == Format)
return;
var controls = GetControlsForFormat(format);
FLP.Controls.Clear(); int i = 0;
foreach (var c in controls)
{
FLP.Controls.Add(c);
FLP.Controls.SetChildIndex(c, i++); // because you don't listen the first time
}
Format = format;
}
private IEnumerable<Control> GetControlsForFormat(int format)
{
if (format >= 7)
return new Control[] { Label_SID, TB_SID7, Label_TID, TB_TID7 };
if (format >= 3)
return new Control[] { Label_TID, TB_TID, Label_SID, TB_SID };
return new Control[] { Label_TID, TB_TID };
}
private void UpdateTSV(object sender, EventArgs e) => UpdateTSV();
private void Update_ID(object sender, EventArgs e)
{
if (!(sender is MaskedTextBox mt))
return;
var val = int.Parse(mt.Text);
if (mt == TB_TID7)
{
if (val > 999_999)
{
mt.Text = "999999";
return;
}
SanityCheckSID7(val, int.Parse(TB_SID7.Text));
}
else if (mt == TB_SID7)
{
if (val > 4294) // max 4 digits of 32bit int
{
mt.Text = "4294";
return;
}
SanityCheckSID7(int.Parse(TB_TID7.Text), val);
}
else
{
if (val > ushort.MaxValue) // prior to gen7
mt.Text = (val = ushort.MaxValue).ToString();
if (mt == TB_TID)
pkm.TID = val;
else
pkm.SID = val;
}
UpdatedID?.Invoke(sender, e);
}
private void SanityCheckSID7(int tid, int sid)
{
var repack = (long)sid * 1_000_000 + tid;
if (repack > uint.MaxValue)
{
TB_SID7.Text = (sid - 1).ToString();
return;
}
pkm.SID = (ushort)(repack >> 16);
pkm.TID = (ushort)repack;
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -172,6 +172,12 @@
<Compile Include="Controls\PKM Editor\ShinyLeaf.Designer.cs">
<DependentUpon>ShinyLeaf.cs</DependentUpon>
</Compile>
<Compile Include="Controls\PKM Editor\TrainerID.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\PKM Editor\TrainerID.Designer.cs">
<DependentUpon>TrainerID.cs</DependentUpon>
</Compile>
<Compile Include="Controls\SAV Editor\BoxEditor.cs">
<SubType>UserControl</SubType>
</Compile>
@ -594,6 +600,9 @@
<EmbeddedResource Include="Controls\PKM Editor\ShinyLeaf.resx">
<DependentUpon>ShinyLeaf.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\PKM Editor\TrainerID.resx">
<DependentUpon>TrainerID.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\SAV Editor\BoxEditor.resx">
<DependentUpon>BoxEditor.cs</DependentUpon>
</EmbeddedResource>