Merge pull request #1689 from pokecal/master

fix MailBoxEditor
This commit is contained in:
Kurt 2017-12-03 07:14:49 -08:00 committed by GitHub
commit 792910a485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 303 additions and 50 deletions

View file

@ -244,6 +244,7 @@ namespace PKHeX.Core
public override int Stat_SPE { get => BitConverter.ToUInt16(Data, 0x96); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x96); } public override int Stat_SPE { get => BitConverter.ToUInt16(Data, 0x96); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x96); }
public override int Stat_SPA { get => BitConverter.ToUInt16(Data, 0x98); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x98); } public override int Stat_SPA { get => BitConverter.ToUInt16(Data, 0x98); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x98); }
public override int Stat_SPD { get => BitConverter.ToUInt16(Data, 0x9A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x9A); } public override int Stat_SPD { get => BitConverter.ToUInt16(Data, 0x9A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x9A); }
public byte[] HeldMailData { get => Data.Skip(0x9C).Take(0x38).ToArray(); set => value.CopyTo(Data, 0x9C); }
// Generated Attributes // Generated Attributes
public override int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 3); public override int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 3);

View file

@ -6,12 +6,14 @@ namespace PKHeX.Core
protected int DataOffset; protected int DataOffset;
public void CopyTo(SaveFile sav) => sav.SetData(Data, DataOffset); public void CopyTo(SaveFile sav) => sav.SetData(Data, DataOffset);
public virtual void CopyTo(PK4 pk4) { } public virtual void CopyTo(PK4 pk4) { }
public virtual void CopyTo(PK5 pk5) { }
public virtual string GetMessage(bool isLastLine) => null; public virtual string GetMessage(bool isLastLine) => null;
public virtual ushort GetMessage(int index1, int index2) => 0; public virtual ushort GetMessage(int index1, int index2) => 0;
public virtual void SetMessage(string line1, string line2) { } public virtual void SetMessage(string line1, string line2) { }
public virtual void SetMessage(int index1, int index2, ushort value) { } public virtual void SetMessage(int index1, int index2, ushort value) { }
public virtual string AuthorName { get; set; } public virtual string AuthorName { get; set; }
public virtual ushort AuthorTID { get; set; } public virtual ushort AuthorTID { get; set; }
public virtual byte AuthorGender { get; set; }
public virtual int AppearPKM { get; set; } public virtual int AppearPKM { get; set; }
public virtual int MailType { get; set; } public virtual int MailType { get; set; }
public abstract bool? IsEmpty { get; } // true: empty, false: legal mail, null: illegal mail public abstract bool? IsEmpty { get; } // true: empty, false: legal mail, null: illegal mail

View file

@ -41,7 +41,7 @@ namespace PKHeX.Core
public override void CopyTo(PK4 pk4) => pk4.HeldMailData = Data; public override void CopyTo(PK4 pk4) => pk4.HeldMailData = Data;
public override ushort AuthorTID { get => BitConverter.ToUInt16(Data, 0); set => BitConverter.GetBytes(value).CopyTo(Data, 0); } public override ushort AuthorTID { get => BitConverter.ToUInt16(Data, 0); set => BitConverter.GetBytes(value).CopyTo(Data, 0); }
public ushort AuthorSID { get => BitConverter.ToUInt16(Data, 2); set => BitConverter.GetBytes(value).CopyTo(Data, 2); } public ushort AuthorSID { get => BitConverter.ToUInt16(Data, 2); set => BitConverter.GetBytes(value).CopyTo(Data, 2); }
public byte AuthorGender { get => Data[4]; set => Data[4] = value; } public override byte AuthorGender { get => Data[4]; set => Data[4] = value; }
public byte AuthorLanguage { get => Data[5]; set => Data[5] = value; } public byte AuthorLanguage { get => Data[5]; set => Data[5] = value; }
public byte AuthorVersion { get => Data[6]; set => Data[6] = value; } public byte AuthorVersion { get => Data[6]; set => Data[6] = value; }
public override int MailType { get => Data[7]; set => Data[7] = (byte)value; } public override int MailType { get => Data[7]; set => Data[7] = (byte)value; }

View file

@ -0,0 +1,63 @@
using System;
using System;
namespace PKHeX.Core
{
public class Mail5 : Mail
{
private const int SIZE = 0x38;
public Mail5(SAV5 sav, int index)
{
DataOffset = index * SIZE + 0x1DD00;
Data = sav.GetData(DataOffset, SIZE);
}
public Mail5(byte[] data)
{
Data = data;
DataOffset = -1;
}
public Mail5(byte? lang = null, byte? ver = null)
{
Data = new byte[SIZE];
DataOffset = -1;
AuthorTID = 0;
AuthorSID = 0;
AuthorGender = 0;
if (lang != null) AuthorLanguage = (byte)lang;
if (ver != null) AuthorVersion = (byte)ver;
MailType = 0xFF;
AuthorName = "";
for (int i = 0; i < 3; i++)
SetMisc(i, 0);
MessageEnding = 0xFFFF;
for (int y = 0; y < 3; y++)
for (int x = 0; x < 4; x++)
SetMessage(y, x, (ushort)(x == 1 ? 0 : 0xFFFF));
}
public override void CopyTo(PK5 pk5) => pk5.HeldMailData = Data;
public override ushort AuthorTID { get => BitConverter.ToUInt16(Data, 0); set => BitConverter.GetBytes(value).CopyTo(Data, 0); }
public ushort AuthorSID { get => BitConverter.ToUInt16(Data, 2); set => BitConverter.GetBytes(value).CopyTo(Data, 2); }
public override byte AuthorGender { get => Data[4]; set => Data[4] = value; }
public byte AuthorLanguage { get => Data[5]; set => Data[5] = value; }
public byte AuthorVersion { get => Data[6]; set => Data[6] = value; }
public override int MailType { get => Data[7]; set => Data[7] = (byte)value; }
public override string AuthorName { get => StringConverter.GetString5(Data, 8, 0x10); set => StringConverter.SetString5(value, 7, 8, 0).CopyTo(Data, 8); }
public int GetMisc(int index) => BitConverter.ToUInt16(Data, 0x1C - index * 2);
public void SetMisc(int index, int value) => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1C - index * 2);
public ushort MessageEnding { get => BitConverter.ToUInt16(Data, 0x1E); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1E); }
public override ushort GetMessage(int index1, int index2) => BitConverter.ToUInt16(Data, 0x20 + (index1 * 4 + index2) * 2);
public override void SetMessage(int index1, int index2, ushort value) => BitConverter.GetBytes(value).CopyTo(Data, 0x20 + (index1 * 4 + index2) * 2);
public override bool? IsEmpty
{
get
{
if (MailType == 0xFF) return true;
if (MailType <= 11) return false;
return null;
}
}
public override void SetBlank() => SetBlank();
public void SetBlank(byte? lang = null, byte? ver = null) => (new Mail5(lang: lang, ver: ver)).Data.CopyTo(Data, 0);
}
}

View file

@ -1010,7 +1010,7 @@ namespace PKHeX.WinForms.Controls
B_OpenRTCEditor.Enabled = sav.RS || sav.E || sav.Generation == 2; B_OpenRTCEditor.Enabled = sav.RS || sav.E || sav.Generation == 2;
B_OpenUGSEditor.Enabled = sav.DP || sav.Pt; B_OpenUGSEditor.Enabled = sav.DP || sav.Pt;
B_FestivalPlaza.Enabled = sav.Generation == 7; B_FestivalPlaza.Enabled = sav.Generation == 7;
B_MailBox.Enabled = sav.Generation >= 2 && sav.Generation <= 4; B_MailBox.Enabled = sav.Generation >= 2 && sav.Generation <= 5;
} }
GB_SAVtools.Visible = sav.Exportable && FLP_SAVtools.Controls.Cast<Control>().Any(c => c.Enabled); GB_SAVtools.Visible = sav.Exportable && FLP_SAVtools.Controls.Cast<Control>().Any(c => c.Enabled);
foreach (Control c in FLP_SAVtools.Controls.Cast<Control>()) foreach (Control c in FLP_SAVtools.Controls.Cast<Control>())

View file

@ -45,6 +45,7 @@
this.NUD_BoxSize = new System.Windows.Forms.NumericUpDown(); this.NUD_BoxSize = new System.Windows.Forms.NumericUpDown();
this.GB_MessageTB = new System.Windows.Forms.GroupBox(); this.GB_MessageTB = new System.Windows.Forms.GroupBox();
this.GB_MessageNUD = new System.Windows.Forms.GroupBox(); this.GB_MessageNUD = new System.Windows.Forms.GroupBox();
this.NUD_MessageEnding = new System.Windows.Forms.NumericUpDown();
this.NUD_Message23 = new System.Windows.Forms.NumericUpDown(); this.NUD_Message23 = new System.Windows.Forms.NumericUpDown();
this.NUD_Message13 = new System.Windows.Forms.NumericUpDown(); this.NUD_Message13 = new System.Windows.Forms.NumericUpDown();
this.NUD_Message03 = new System.Windows.Forms.NumericUpDown(); this.NUD_Message03 = new System.Windows.Forms.NumericUpDown();
@ -86,11 +87,16 @@
this.L_PCBOX = new System.Windows.Forms.Label(); this.L_PCBOX = new System.Windows.Forms.Label();
this.CB_AppearPKM2 = new System.Windows.Forms.ComboBox(); this.CB_AppearPKM2 = new System.Windows.Forms.ComboBox();
this.CB_AppearPKM3 = new System.Windows.Forms.ComboBox(); this.CB_AppearPKM3 = new System.Windows.Forms.ComboBox();
this.L_MiscValue = new System.Windows.Forms.Label();
this.NUD_Misc1 = new System.Windows.Forms.NumericUpDown();
this.NUD_Misc2 = new System.Windows.Forms.NumericUpDown();
this.NUD_Misc3 = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.NUD_AuthorTID)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_AuthorTID)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_AuthorSID)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_AuthorSID)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_BoxSize)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_BoxSize)).BeginInit();
this.GB_MessageTB.SuspendLayout(); this.GB_MessageTB.SuspendLayout();
this.GB_MessageNUD.SuspendLayout(); this.GB_MessageNUD.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_MessageEnding)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Message23)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Message23)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Message13)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Message13)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Message03)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Message03)).BeginInit();
@ -111,6 +117,9 @@
((System.ComponentModel.ISupportInitialize)(this.NUD_MailID3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_MailID3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_MailID2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_MailID2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_MailID1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_MailID1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Misc1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Misc2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Misc3)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// B_Cancel // B_Cancel
@ -227,7 +236,7 @@
// //
this.CB_AppearPKM1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CB_AppearPKM1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_AppearPKM1.FormattingEnabled = true; this.CB_AppearPKM1.FormattingEnabled = true;
this.CB_AppearPKM1.Location = new System.Drawing.Point(235, 276); this.CB_AppearPKM1.Location = new System.Drawing.Point(235, 304);
this.CB_AppearPKM1.Name = "CB_AppearPKM1"; this.CB_AppearPKM1.Name = "CB_AppearPKM1";
this.CB_AppearPKM1.Size = new System.Drawing.Size(107, 20); this.CB_AppearPKM1.Size = new System.Drawing.Size(107, 20);
this.CB_AppearPKM1.TabIndex = 11; this.CB_AppearPKM1.TabIndex = 11;
@ -236,7 +245,7 @@
// //
this.CB_MailType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CB_MailType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_MailType.FormattingEnabled = true; this.CB_MailType.FormattingEnabled = true;
this.CB_MailType.Location = new System.Drawing.Point(235, 247); this.CB_MailType.Location = new System.Drawing.Point(235, 275);
this.CB_MailType.Name = "CB_MailType"; this.CB_MailType.Name = "CB_MailType";
this.CB_MailType.Size = new System.Drawing.Size(107, 20); this.CB_MailType.Size = new System.Drawing.Size(107, 20);
this.CB_MailType.TabIndex = 12; this.CB_MailType.TabIndex = 12;
@ -290,6 +299,7 @@
// //
// GB_MessageNUD // GB_MessageNUD
// //
this.GB_MessageNUD.Controls.Add(this.NUD_MessageEnding);
this.GB_MessageNUD.Controls.Add(this.NUD_Message23); this.GB_MessageNUD.Controls.Add(this.NUD_Message23);
this.GB_MessageNUD.Controls.Add(this.NUD_Message13); this.GB_MessageNUD.Controls.Add(this.NUD_Message13);
this.GB_MessageNUD.Controls.Add(this.NUD_Message03); this.GB_MessageNUD.Controls.Add(this.NUD_Message03);
@ -304,11 +314,28 @@
this.GB_MessageNUD.Controls.Add(this.NUD_Message00); this.GB_MessageNUD.Controls.Add(this.NUD_Message00);
this.GB_MessageNUD.Location = new System.Drawing.Point(144, 47); this.GB_MessageNUD.Location = new System.Drawing.Point(144, 47);
this.GB_MessageNUD.Name = "GB_MessageNUD"; this.GB_MessageNUD.Name = "GB_MessageNUD";
this.GB_MessageNUD.Size = new System.Drawing.Size(261, 105); this.GB_MessageNUD.Size = new System.Drawing.Size(261, 133);
this.GB_MessageNUD.TabIndex = 16; this.GB_MessageNUD.TabIndex = 16;
this.GB_MessageNUD.TabStop = false; this.GB_MessageNUD.TabStop = false;
this.GB_MessageNUD.Text = "Message"; this.GB_MessageNUD.Text = "Message";
// //
// NUD_MessageEnding
//
this.NUD_MessageEnding.Location = new System.Drawing.Point(9, 105);
this.NUD_MessageEnding.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.NUD_MessageEnding.Name = "NUD_MessageEnding";
this.NUD_MessageEnding.Size = new System.Drawing.Size(54, 19);
this.NUD_MessageEnding.TabIndex = 12;
this.NUD_MessageEnding.Value = new decimal(new int[] {
65535,
0,
0,
0});
//
// NUD_Message23 // NUD_Message23
// //
this.NUD_Message23.Location = new System.Drawing.Point(198, 77); this.NUD_Message23.Location = new System.Drawing.Point(198, 77);
@ -521,7 +548,7 @@
this.GB_Author.Controls.Add(this.TB_AuthorName); this.GB_Author.Controls.Add(this.TB_AuthorName);
this.GB_Author.Controls.Add(this.NUD_AuthorTID); this.GB_Author.Controls.Add(this.NUD_AuthorTID);
this.GB_Author.Controls.Add(this.NUD_AuthorSID); this.GB_Author.Controls.Add(this.NUD_AuthorSID);
this.GB_Author.Location = new System.Drawing.Point(144, 161); this.GB_Author.Location = new System.Drawing.Point(144, 189);
this.GB_Author.Name = "GB_Author"; this.GB_Author.Name = "GB_Author";
this.GB_Author.Size = new System.Drawing.Size(261, 77); this.GB_Author.Size = new System.Drawing.Size(261, 77);
this.GB_Author.TabIndex = 17; this.GB_Author.TabIndex = 17;
@ -530,6 +557,7 @@
// //
// CB_AuthorVersion // CB_AuthorVersion
// //
this.CB_AuthorVersion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_AuthorVersion.FormattingEnabled = true; this.CB_AuthorVersion.FormattingEnabled = true;
this.CB_AuthorVersion.Location = new System.Drawing.Point(135, 48); this.CB_AuthorVersion.Location = new System.Drawing.Point(135, 48);
this.CB_AuthorVersion.Name = "CB_AuthorVersion"; this.CB_AuthorVersion.Name = "CB_AuthorVersion";
@ -538,6 +566,7 @@
// //
// CB_AuthorLang // CB_AuthorLang
// //
this.CB_AuthorLang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_AuthorLang.FormattingEnabled = true; this.CB_AuthorLang.FormattingEnabled = true;
this.CB_AuthorLang.Location = new System.Drawing.Point(135, 19); this.CB_AuthorLang.Location = new System.Drawing.Point(135, 19);
this.CB_AuthorLang.Name = "CB_AuthorLang"; this.CB_AuthorLang.Name = "CB_AuthorLang";
@ -557,7 +586,7 @@
// //
// L_MailType // L_MailType
// //
this.L_MailType.Location = new System.Drawing.Point(157, 247); this.L_MailType.Location = new System.Drawing.Point(157, 275);
this.L_MailType.Name = "L_MailType"; this.L_MailType.Name = "L_MailType";
this.L_MailType.Size = new System.Drawing.Size(72, 18); this.L_MailType.Size = new System.Drawing.Size(72, 18);
this.L_MailType.TabIndex = 18; this.L_MailType.TabIndex = 18;
@ -566,7 +595,7 @@
// //
// L_AppearPKM // L_AppearPKM
// //
this.L_AppearPKM.Location = new System.Drawing.Point(144, 276); this.L_AppearPKM.Location = new System.Drawing.Point(144, 304);
this.L_AppearPKM.Name = "L_AppearPKM"; this.L_AppearPKM.Name = "L_AppearPKM";
this.L_AppearPKM.Size = new System.Drawing.Size(85, 18); this.L_AppearPKM.Size = new System.Drawing.Size(85, 18);
this.L_AppearPKM.TabIndex = 19; this.L_AppearPKM.TabIndex = 19;
@ -863,7 +892,7 @@
// //
this.CB_AppearPKM2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CB_AppearPKM2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_AppearPKM2.FormattingEnabled = true; this.CB_AppearPKM2.FormattingEnabled = true;
this.CB_AppearPKM2.Location = new System.Drawing.Point(351, 276); this.CB_AppearPKM2.Location = new System.Drawing.Point(351, 304);
this.CB_AppearPKM2.Name = "CB_AppearPKM2"; this.CB_AppearPKM2.Name = "CB_AppearPKM2";
this.CB_AppearPKM2.Size = new System.Drawing.Size(107, 20); this.CB_AppearPKM2.Size = new System.Drawing.Size(107, 20);
this.CB_AppearPKM2.TabIndex = 23; this.CB_AppearPKM2.TabIndex = 23;
@ -872,16 +901,80 @@
// //
this.CB_AppearPKM3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CB_AppearPKM3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_AppearPKM3.FormattingEnabled = true; this.CB_AppearPKM3.FormattingEnabled = true;
this.CB_AppearPKM3.Location = new System.Drawing.Point(467, 276); this.CB_AppearPKM3.Location = new System.Drawing.Point(464, 304);
this.CB_AppearPKM3.Name = "CB_AppearPKM3"; this.CB_AppearPKM3.Name = "CB_AppearPKM3";
this.CB_AppearPKM3.Size = new System.Drawing.Size(107, 20); this.CB_AppearPKM3.Size = new System.Drawing.Size(107, 20);
this.CB_AppearPKM3.TabIndex = 24; this.CB_AppearPKM3.TabIndex = 24;
// //
// L_MiscValue
//
this.L_MiscValue.Location = new System.Drawing.Point(183, 304);
this.L_MiscValue.Name = "L_MiscValue";
this.L_MiscValue.Size = new System.Drawing.Size(46, 18);
this.L_MiscValue.TabIndex = 25;
this.L_MiscValue.Text = "Misc:";
this.L_MiscValue.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_Misc1
//
this.NUD_Misc1.Location = new System.Drawing.Point(235, 305);
this.NUD_Misc1.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.NUD_Misc1.Name = "NUD_Misc1";
this.NUD_Misc1.Size = new System.Drawing.Size(54, 19);
this.NUD_Misc1.TabIndex = 26;
this.NUD_Misc1.Value = new decimal(new int[] {
65535,
0,
0,
0});
//
// NUD_Misc2
//
this.NUD_Misc2.Location = new System.Drawing.Point(298, 305);
this.NUD_Misc2.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.NUD_Misc2.Name = "NUD_Misc2";
this.NUD_Misc2.Size = new System.Drawing.Size(54, 19);
this.NUD_Misc2.TabIndex = 27;
this.NUD_Misc2.Value = new decimal(new int[] {
65535,
0,
0,
0});
//
// NUD_Misc3
//
this.NUD_Misc3.Location = new System.Drawing.Point(361, 305);
this.NUD_Misc3.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.NUD_Misc3.Name = "NUD_Misc3";
this.NUD_Misc3.Size = new System.Drawing.Size(54, 19);
this.NUD_Misc3.TabIndex = 28;
this.NUD_Misc3.Value = new decimal(new int[] {
65535,
0,
0,
0});
//
// SAV_MailBox // SAV_MailBox
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(599, 409); this.ClientSize = new System.Drawing.Size(599, 409);
this.Controls.Add(this.NUD_Misc3);
this.Controls.Add(this.NUD_Misc2);
this.Controls.Add(this.NUD_Misc1);
this.Controls.Add(this.L_MiscValue);
this.Controls.Add(this.CB_AppearPKM3); this.Controls.Add(this.CB_AppearPKM3);
this.Controls.Add(this.CB_AppearPKM2); this.Controls.Add(this.CB_AppearPKM2);
this.Controls.Add(this.L_PCBOX); this.Controls.Add(this.L_PCBOX);
@ -911,6 +1004,7 @@
this.GB_MessageTB.ResumeLayout(false); this.GB_MessageTB.ResumeLayout(false);
this.GB_MessageTB.PerformLayout(); this.GB_MessageTB.PerformLayout();
this.GB_MessageNUD.ResumeLayout(false); this.GB_MessageNUD.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NUD_MessageEnding)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Message23)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Message23)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Message13)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Message13)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Message03)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Message03)).EndInit();
@ -932,6 +1026,9 @@
((System.ComponentModel.ISupportInitialize)(this.NUD_MailID3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_MailID3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_MailID2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_MailID2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_MailID1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_MailID1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Misc1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Misc2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Misc3)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -995,5 +1092,10 @@
private System.Windows.Forms.ComboBox CB_AuthorVersion; private System.Windows.Forms.ComboBox CB_AuthorVersion;
private System.Windows.Forms.ComboBox CB_AuthorLang; private System.Windows.Forms.ComboBox CB_AuthorLang;
private System.Windows.Forms.Label Label_OTGender; private System.Windows.Forms.Label Label_OTGender;
private System.Windows.Forms.NumericUpDown NUD_MessageEnding;
private System.Windows.Forms.Label L_MiscValue;
private System.Windows.Forms.NumericUpDown NUD_Misc1;
private System.Windows.Forms.NumericUpDown NUD_Misc2;
private System.Windows.Forms.NumericUpDown NUD_Misc3;
} }
} }

View file

@ -29,16 +29,22 @@ namespace PKHeX.WinForms
PKMHeldItems = new[] { L_HeldItem1, L_HeldItem2, L_HeldItem3, L_HeldItem4, L_HeldItem5, L_HeldItem6 }; PKMHeldItems = new[] { L_HeldItem1, L_HeldItem2, L_HeldItem3, L_HeldItem4, L_HeldItem5, L_HeldItem6 };
PKMNUDs = new[] { NUD_MailID1, NUD_MailID2, NUD_MailID3, NUD_MailID4, NUD_MailID5, NUD_MailID6 }; PKMNUDs = new[] { NUD_MailID1, NUD_MailID2, NUD_MailID3, NUD_MailID4, NUD_MailID5, NUD_MailID6 };
AppearPKMs = new[] { CB_AppearPKM1, CB_AppearPKM2, CB_AppearPKM3 }; AppearPKMs = new[] { CB_AppearPKM1, CB_AppearPKM2, CB_AppearPKM3 };
Miscs = new[] { NUD_Misc1, NUD_Misc2, NUD_Misc3 };
NUD_BoxSize.Visible = L_BoxSize.Visible = Gen == 2; NUD_BoxSize.Visible = L_BoxSize.Visible = Gen == 2;
GB_MessageTB.Visible = Gen == 2; GB_MessageTB.Visible = Gen == 2;
GB_MessageNUD.Visible = Gen != 2; GB_MessageNUD.Visible = Gen != 2;
Messages[0][3].Visible = Messages[1][3].Visible = Messages[2][3].Visible = Gen == 4; Messages[0][3].Visible = Messages[1][3].Visible = Messages[2][3].Visible = Gen == 4 || Gen == 5;
NUD_AuthorSID.Visible = Gen != 2; NUD_AuthorSID.Visible = Gen != 2;
Label_OTGender.Visible = CB_AuthorLang.Visible = CB_AuthorVersion.Visible = AppearPKMs[1].Visible = AppearPKMs[2].Visible = Gen == 4; Label_OTGender.Visible = CB_AuthorLang.Visible = CB_AuthorVersion.Visible = Gen == 4 || Gen == 5;
L_AppearPKM.Visible = AppearPKMs[0].Visible = Gen != 5;
AppearPKMs[1].Visible = AppearPKMs[2].Visible = Gen == 4;
NUD_MessageEnding.Visible = Gen == 5;
L_MiscValue.Visible = NUD_Misc1.Visible = NUD_Misc2.Visible = NUD_Misc3.Visible = Gen == 5;
for (int i = p.Count; i < 6; i++) for (int i = p.Count; i < 6; i++)
PKMNUDs[i].Visible = PKMLabels[i].Visible = PKMHeldItems[i].Visible = false; PKMNUDs[i].Visible = PKMLabels[i].Visible = PKMHeldItems[i].Visible = false;
if (Gen == 2 || Gen == 4) if (Gen != 3)
{ {
for (int i = 0; i < PKMNUDs.Length; i++) for (int i = 0; i < PKMNUDs.Length; i++)
{ {
@ -55,8 +61,6 @@ namespace PKHeX.WinForms
m[i] = new Mail2(sav2, i); m[i] = new Mail2(sav2, i);
NUD_BoxSize.Value = SAV.Data[0x834]; NUD_BoxSize.Value = SAV.Data[0x834];
MakePartyList();
MakePCList();
MailItemID = new[] { 0x9E, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD }; MailItemID = new[] { 0x9E, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD };
break; break;
case SAV3 sav3: case SAV3 sav3:
@ -64,8 +68,6 @@ namespace PKHeX.WinForms
for (int i = 0; i < m.Length; i++) for (int i = 0; i < m.Length; i++)
m[i] = new Mail3(sav3, i); m[i] = new Mail3(sav3, i);
MakePartyList();
MakePCList();
MailItemID = Enumerable.Range(0x79, 12).ToArray(); MailItemID = Enumerable.Range(0x79, 12).ToArray();
break; break;
case SAV4 sav4: case SAV4 sav4:
@ -74,12 +76,25 @@ namespace PKHeX.WinForms
m[i] = new Mail4((p[i] as PK4).HeldMailData); m[i] = new Mail4((p[i] as PK4).HeldMailData);
for (int i = p.Count, j = 0; i < m.Length; i++, j++) for (int i = p.Count, j = 0; i < m.Length; i++, j++)
m[i] = new Mail4(sav4, j); m[i] = new Mail4(sav4, j);
var l4 = m.Last() as Mail4;
MakePartyList(); ResetVer = l4.AuthorVersion;
MakePCList(); ResetLang = l4.AuthorLanguage;
MailItemID = Enumerable.Range(0x89, 12).ToArray();
break;
case SAV5 sav5:
m = new Mail5[p.Count + 20];
for (int i = 0; i < p.Count; i++)
m[i] = new Mail5((p[i] as PK5).HeldMailData);
for (int i = p.Count, j = 0; i < m.Length; i++, j++)
m[i] = new Mail5(sav5, j);
var l5 = m.Last() as Mail5;
ResetVer = l5.AuthorVersion;
ResetLang = l5.AuthorLanguage;
MailItemID = Enumerable.Range(0x89, 12).ToArray(); MailItemID = Enumerable.Range(0x89, 12).ToArray();
break; break;
} }
MakePartyList();
MakePCList();
if (Gen == 2 || Gen == 3) if (Gen == 2 || Gen == 3)
{ {
@ -88,10 +103,10 @@ namespace PKHeX.WinForms
CB_AppearPKM1.ValueMember = "Value"; CB_AppearPKM1.ValueMember = "Value";
CB_AppearPKM1.DataSource = new BindingSource(GameInfo.SpeciesDataSource.Where(id => id.Value <= sav.MaxSpeciesID).ToList(), null); CB_AppearPKM1.DataSource = new BindingSource(GameInfo.SpeciesDataSource.Where(id => id.Value <= sav.MaxSpeciesID).ToList(), null);
} }
else if (Gen == 4) else if (Gen == 4 || Gen == 5)
{ {
var species = GameInfo.SpeciesDataSource.Where(id => id.Value <= sav.MaxSpeciesID).ToList(); var species = GameInfo.SpeciesDataSource.Where(id => id.Value <= sav.MaxSpeciesID).ToList();
foreach(ComboBox a in AppearPKMs) foreach (ComboBox a in AppearPKMs)
{ {
a.Items.Clear(); a.Items.Clear();
a.DisplayMember = "Text"; a.DisplayMember = "Text";
@ -102,22 +117,33 @@ namespace PKHeX.WinForms
CB_AuthorVersion.Items.Clear(); CB_AuthorVersion.Items.Clear();
CB_AuthorVersion.DisplayMember = "Text"; CB_AuthorVersion.DisplayMember = "Text";
CB_AuthorVersion.ValueMember = "Value"; CB_AuthorVersion.ValueMember = "Value";
CB_AuthorVersion.DataSource = new BindingSource(new[] { CB_AuthorVersion.DataSource = new BindingSource(Gen == 4
new ComboItem { Text = "Diamond", Value = (int)GameVersion.D }, ? new[] {
new ComboItem { Text = "Pearl", Value = (int)GameVersion.P }, new ComboItem { Text = "Diamond", Value = (int)GameVersion.D },
new ComboItem { Text = "Platinum", Value = (int)GameVersion.Pt }, new ComboItem { Text = "Pearl", Value = (int)GameVersion.P },
new ComboItem { Text = "HeartGold", Value = (int)GameVersion.HG }, new ComboItem { Text = "Platinum", Value = (int)GameVersion.Pt },
new ComboItem { Text = "SoulSilver", Value = (int)GameVersion.P }, new ComboItem { Text = "HeartGold", Value = (int)GameVersion.HG },
}.ToList(), null); new ComboItem { Text = "SoulSilver", Value = (int)GameVersion.SS },
}.ToList()
: new[] {
new ComboItem { Text = "Black", Value = (int)GameVersion.B },
new ComboItem { Text = "White", Value = (int)GameVersion.W },
new ComboItem { Text = "Black2", Value = (int)GameVersion.B2 },
new ComboItem { Text = "White2", Value = (int)GameVersion.W2 },
}.ToList(), null);
CB_AuthorLang.Items.Clear(); CB_AuthorLang.Items.Clear();
CB_AuthorLang.DisplayMember = "Text"; CB_AuthorLang.DisplayMember = "Text";
CB_AuthorLang.ValueMember = "Value"; CB_AuthorLang.ValueMember = "Value";
CB_AuthorLang.DataSource = new BindingSource(new[] { CB_AuthorLang.DataSource = new BindingSource(new[] {
// not sure // not sure
new ComboItem { Text = "JP", Value = 1 }, new ComboItem { Text = "JPN", Value = 1 },
new ComboItem { Text = "US", Value = 2 }, new ComboItem { Text = "ENG", Value = 2 },
new ComboItem { Text = "KOR", Value = 3 }, new ComboItem { Text = "FRE", Value = 3 },
new ComboItem { Text = "ITA", Value = 4 },
new ComboItem { Text = "GER", Value = 5 },
new ComboItem { Text = "ESP", Value = 7 },
new ComboItem { Text = "KOR", Value = 8 },
}.ToList(), null); }.ToList(), null);
} }
@ -151,7 +177,7 @@ namespace PKHeX.WinForms
LB_PartyHeld.BeginUpdate(); LB_PartyHeld.BeginUpdate();
int s = LB_PartyHeld.SelectedIndex; int s = LB_PartyHeld.SelectedIndex;
LB_PartyHeld.Items.Clear(); LB_PartyHeld.Items.Clear();
for (int i = 0, j = Gen == 4 ? p.Count : 6; i < j; i++) for (int i = 0, j = Gen >= 4 ? p.Count : 6; i < j; i++)
LB_PartyHeld.Items.Add($"{i}: {m[i].AuthorName}"); LB_PartyHeld.Items.Add($"{i}: {m[i].AuthorName}");
if (s != LB_PartyHeld.SelectedIndex && s < LB_PartyHeld.Items.Count) if (s != LB_PartyHeld.SelectedIndex && s < LB_PartyHeld.Items.Count)
LB_PartyHeld.SelectedIndex = s; LB_PartyHeld.SelectedIndex = s;
@ -173,13 +199,14 @@ namespace PKHeX.WinForms
case 3: case 3:
for (int i = 6; i < m.Length; i++) for (int i = 6; i < m.Length; i++)
{ {
LB_PCBOX.Items.Add(m[i].MailType != 0 ? $"{i}: {m[i].AuthorName}" : "x"); LB_PCBOX.Items.Add(m[i].IsEmpty != true ? $"{i}: {m[i].AuthorName}" : "x");
} }
break; break;
case 4: case 4:
case 5:
for (int i = p.Count; i < m.Length; i++) for (int i = p.Count; i < m.Length; i++)
{ {
LB_PCBOX.Items.Add(m[i].MailType <= 11 ? $"{i}: {m[i].AuthorName}" : "x"); LB_PCBOX.Items.Add(m[i].IsEmpty != true ? $"{i}: {m[i].AuthorName}" : "x");
} }
break; break;
} }
@ -206,10 +233,11 @@ namespace PKHeX.WinForms
private bool editing; private bool editing;
private int entry; private int entry;
private readonly NumericUpDown[][] Messages; private readonly NumericUpDown[][] Messages;
private readonly NumericUpDown[] PKMNUDs; private readonly NumericUpDown[] PKMNUDs, Miscs;
private readonly Label[] PKMLabels, PKMHeldItems; private readonly Label[] PKMLabels, PKMHeldItems;
private readonly ComboBox[] AppearPKMs; private readonly ComboBox[] AppearPKMs;
private readonly int Gen; private readonly int Gen;
private readonly byte ResetVer, ResetLang;
private void Save() private void Save()
{ {
switch (Gen) switch (Gen)
@ -236,6 +264,12 @@ namespace PKHeX.WinForms
for (int i = p.Count; i < m.Length; i++) for (int i = p.Count; i < m.Length; i++)
m[i].CopyTo(SAV); m[i].CopyTo(SAV);
break; break;
case 5:
for (int i = 0; i < p.Count; i++)
m[i].CopyTo(p[i] as PK5);
for (int i = p.Count; i < m.Length; i++)
m[i].CopyTo(SAV);
break;
} }
SAV.PartyData = p; SAV.PartyData = p;
} }
@ -256,8 +290,8 @@ namespace PKHeX.WinForms
m3.AuthorTID = (ushort)NUD_AuthorTID.Value; m3.AuthorTID = (ushort)NUD_AuthorTID.Value;
m3.MailType = CBIndexToMailType(CB_MailType.SelectedIndex); m3.MailType = CBIndexToMailType(CB_MailType.SelectedIndex);
for (int y = 0; y < 2; y++) for (int y = 0; y < 3; y++)
for (int x = 0; x < 2; x++) for (int x = 0; x < 3; x++)
m3.SetMessage(y, x, (ushort)Messages[y][x].Value); m3.SetMessage(y, x, (ushort)Messages[y][x].Value);
m3.AuthorSID = (ushort)NUD_AuthorSID.Value; m3.AuthorSID = (ushort)NUD_AuthorSID.Value;
int v = CB_AppearPKM1.SelectedValue as int? ?? 0; int v = CB_AppearPKM1.SelectedValue as int? ?? 0;
@ -269,14 +303,32 @@ namespace PKHeX.WinForms
v = CB_MailType.SelectedIndex; v = CB_MailType.SelectedIndex;
m4.MailType = v > 0 ? v - 1 : 0xFF; m4.MailType = v > 0 ? v - 1 : 0xFF;
for (int y = 0; y < 2; y++) for (int y = 0; y < 3; y++)
for (int x = 0; x < 3; x++) for (int x = 0; x < 4; x++)
m4.SetMessage(y, x, (ushort)Messages[y][x].Value); m4.SetMessage(y, x, (ushort)Messages[y][x].Value);
m4.AuthorSID = (ushort)NUD_AuthorSID.Value; m4.AuthorSID = (ushort)NUD_AuthorSID.Value;
for (int i = 0; i < AppearPKMs.Length; i++) for (int i = 0; i < AppearPKMs.Length; i++)
m4.SetAppearPKM(i, (AppearPKMs[i].SelectedValue as int?) + 7 ?? 0); m4.SetAppearPKM(i, (AppearPKMs[i].SelectedValue as int?) + 7 ?? 0);
m4.AuthorVersion = CB_AuthorVersion.SelectedValue as byte? ?? 0; if (CB_AuthorVersion.SelectedValue != null)
m4.AuthorLanguage = CB_AuthorLang.SelectedValue as byte? ?? 0; m4.AuthorVersion = (byte)((int?)CB_AuthorVersion.SelectedValue ?? 0);
if (CB_AuthorLang.SelectedValue != null)
m4.AuthorLanguage = (byte)((int?)CB_AuthorLang.SelectedValue ?? 0);
break;
case Mail5 m5:
m5.AuthorName = TB_AuthorName.Text;
m5.AuthorTID = (ushort)NUD_AuthorTID.Value;
v = CB_MailType.SelectedIndex;
m5.MailType = v > 0 ? v - 1 : 0xFF;
for (int y = 0; y < 3; y++)
for (int x = 0; x < 4; x++)
m5.SetMessage(y, x, (ushort)Messages[y][x].Value);
m5.AuthorSID = (ushort)NUD_AuthorSID.Value;
for (int i = 0; i < Miscs.Length; i++)
m5.SetMisc(i, (ushort)Miscs[i].Value);
m5.MessageEnding = (ushort)NUD_MessageEnding.Value;
m5.AuthorVersion = (byte)((int?)CB_AuthorVersion.SelectedValue ?? 0);
m5.AuthorLanguage = (byte)((int?)CB_AuthorLang.SelectedValue ?? 0);
break; break;
} }
} }
@ -330,6 +382,20 @@ namespace PKHeX.WinForms
ret += $"{Environment.NewLine}MailID{i} MailType mismatch"; ret += $"{Environment.NewLine}MailID{i} MailType mismatch";
} }
} }
// Gen5
// P
// gen5, move mail to pc will not erase mail data, still remains, duplicates.
else if (Gen == 5)
{
for (int i = 0; i < p.Count; i++)
{
if (ItemIsMail(p[i].HeldItem))
{
if (m[i].IsEmpty == true) //P
ret += $"{Environment.NewLine}MailID{i} MailType mismatch";
}
}
}
// Gen* // Gen*
// Z: mail type is illegal // Z: mail type is illegal
for (int i = 0; i < m.Length; i++) for (int i = 0; i < m.Length; i++)
@ -365,7 +431,6 @@ namespace PKHeX.WinForms
private DialogResult ModifyHeldItem() private DialogResult ModifyHeldItem()
{ {
DialogResult ret = DialogResult.Abort; DialogResult ret = DialogResult.Abort;
if (entry >= p.Count) return ret;
PKM s = p[entry]; PKM s = p[entry];
if (!ItemIsMail(s.HeldItem)) return ret; if (!ItemIsMail(s.HeldItem)) return ret;
System.Media.SystemSounds.Question.Play(); System.Media.SystemSounds.Question.Play();
@ -379,13 +444,18 @@ namespace PKHeX.WinForms
private void B_Delete_Click(object sender, EventArgs e) private void B_Delete_Click(object sender, EventArgs e)
{ {
if (entry < 0) return; if (entry < 0) return;
if (entry < 6) if (entry < p.Count)
{ {
DialogResult ret= ModifyHeldItem(); DialogResult ret= ModifyHeldItem();
if (ret == DialogResult.Cancel) return; if (ret == DialogResult.Cancel) return;
} }
switch (m[entry])
{
case Mail4 m4: m4.SetBlank(ResetLang, ResetVer); break;
case Mail5 m5: m5.SetBlank(ResetLang, ResetVer); break;
default: m[entry].SetBlank(); break;
}
editing = true; editing = true;
m[entry].SetBlank();
LoadList(); LoadList();
LoadMail(); LoadMail();
editing = false; editing = false;
@ -414,7 +484,7 @@ namespace PKHeX.WinForms
if (partyIndex >= 0) if (partyIndex >= 0)
entry = partyIndex; entry = partyIndex;
else if (pcIndex >= 0) else if (pcIndex >= 0)
entry = 6 + pcIndex; entry = (Gen >= 4 ? p.Count : 6) + pcIndex;
else entry = -1; else entry = -1;
if (entry >= 0) LoadMail(); if (entry >= 0) LoadMail();
editing = false; editing = false;
@ -447,8 +517,7 @@ namespace PKHeX.WinForms
case Mail4 m4: case Mail4 m4:
TB_AuthorName.Text = m4.AuthorName; TB_AuthorName.Text = m4.AuthorName;
NUD_AuthorTID.Value = m4.AuthorTID; NUD_AuthorTID.Value = m4.AuthorTID;
v = m4.MailType; CB_MailType.SelectedIndex = m4.IsEmpty == false ? m4.MailType + 1 : 0;
CB_MailType.SelectedIndex = v <= 11 ? v + 1 : 0;
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
for (int x = 0; x < 4; x++) for (int x = 0; x < 4; x++)
@ -460,6 +529,22 @@ namespace PKHeX.WinForms
CB_AuthorVersion.SelectedValue = (int)m4.AuthorVersion; CB_AuthorVersion.SelectedValue = (int)m4.AuthorVersion;
CB_AuthorLang.SelectedValue = (int)m4.AuthorLanguage; CB_AuthorLang.SelectedValue = (int)m4.AuthorLanguage;
break; break;
case Mail5 m5:
TB_AuthorName.Text = m5.AuthorName;
NUD_AuthorTID.Value = m5.AuthorTID;
CB_MailType.SelectedIndex = m5.IsEmpty == false ? m5.MailType + 1 : 0;
for (int y = 0; y < 3; y++)
for (int x = 0; x < 4; x++)
Messages[y][x].Value = m5.GetMessage(y, x);
NUD_AuthorSID.Value = m5.AuthorSID;
for (int i = 0; i < Miscs.Length; i++)
Miscs[i].Value = m5.GetMisc(i);
NUD_MessageEnding.Value = m5.MessageEnding;
LoadOTlabel(m5.AuthorGender);
CB_AuthorVersion.SelectedValue = (int)m5.AuthorVersion;
CB_AuthorLang.SelectedValue = (int)m5.AuthorLanguage;
break;
} }
} }
@ -472,8 +557,8 @@ namespace PKHeX.WinForms
private void Label_OTGender_Click(object sender, EventArgs e) private void Label_OTGender_Click(object sender, EventArgs e)
{ {
if (entry < 0) return; if (entry < 0) return;
if (Gen != 4) return; if (Gen < 4) return;
var mail = m[entry] as Mail4; var mail = m[entry];
var b = mail.AuthorGender; var b = mail.AuthorGender;
b ^= 1; b ^= 1;
mail.AuthorGender = b; mail.AuthorGender = b;