public SAV_MailBox(SaveFile sav) { InitializeComponent(); WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); SAV = (Origin = sav).Clone(); Gen = SAV.Generation; p = SAV.PartyData; editing = true; Messages = new[] { new[] { NUD_Message00, NUD_Message01, NUD_Message02, NUD_Message03 }, new[] { NUD_Message10, NUD_Message11, NUD_Message12, NUD_Message13 }, new[] { NUD_Message20, NUD_Message21, NUD_Message22, NUD_Message23 } }; PKMLabels = new[] { L_PKM1, L_PKM2, L_PKM3, L_PKM4, L_PKM5, L_PKM6 }; 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 }; AppearPKMs = new[] { CB_AppearPKM1, CB_AppearPKM2, CB_AppearPKM3 }; Miscs = new[] { NUD_Misc1, NUD_Misc2, NUD_Misc3 }; NUD_BoxSize.Visible = L_BoxSize.Visible = Gen == 2; GB_MessageTB.Visible = Gen == 2; GB_MessageNUD.Visible = Gen != 2; Messages[0][3].Visible = Messages[1][3].Visible = Messages[2][3].Visible = Gen is 4 or 5; NUD_AuthorSID.Visible = Gen != 2; Label_OTGender.Visible = CB_AuthorLang.Visible = CB_AuthorVersion.Visible = Gen is 4 or 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++) PKMNUDs[i].Visible = PKMLabels[i].Visible = PKMHeldItems[i].Visible = false; if (Gen != 3) { for (int i = 0; i < PKMNUDs.Length; i++) { PKMNUDs[i].Value = i; PKMNUDs[i].Enabled = false; } } switch (SAV) { case SAV2 sav2: m = new Mail2[6 + 10]; for (int i = 0; i < m.Length; i++) m[i] = new Mail2(sav2, i); NUD_BoxSize.Value = SAV.Data[0x834]; MailItemID = new[] { 0x9E, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD }; PartyBoxCount = 6; break; case SAV3 sav3: m = new Mail3[6 + 10]; for (int i = 0; i < m.Length; i++) { var ofs = sav3.GetMailOffset(i); var data = sav.GetData(ofs, Mail3.SIZE); m[i] = new Mail3(data, ofs, sav3.Japanese); } MailItemID = Enumerable.Range(0x79, 12).ToArray(); PartyBoxCount = 6; break; case SAV4 sav4: m = new Mail4[p.Count + 20]; for (int i = 0; i < p.Count; i++) m[i] = new Mail4(((PK4)p[i]).GetHeldMailData()); for (int i = p.Count, j = 0; i < m.Length; i++, j++) { int ofs = sav4.GetMailOffset(j); m[i] = new Mail4(sav4.GetMailData(ofs), ofs); } var l4 = (Mail4)m.Last(); ResetVer = l4.AuthorVersion; ResetLang = l4.AuthorLanguage; MailItemID = Enumerable.Range(0x89, 12).ToArray(); PartyBoxCount = p.Count; break; case SAV5 sav5: m = new Mail5[p.Count + 20]; for (int i = 0; i < p.Count; i++) m[i] = new Mail5(((PK5)p[i]).GetHeldMailData()); for (int i = p.Count, j = 0; i < m.Length; i++, j++) { int ofs = SAV5.GetMailOffset(j); var data = sav5.GetMailData(ofs); m[i] = new Mail5(data, ofs); } var l5 = (Mail5)m.Last(); ResetVer = l5.AuthorVersion; ResetLang = l5.AuthorLanguage; MailItemID = Enumerable.Range(0x89, 12).ToArray(); PartyBoxCount = p.Count; break; } MakePartyList(); MakePCList(); if (Gen is 2 or 3) { CB_AppearPKM1.Items.Clear(); CB_AppearPKM1.InitializeBinding(); CB_AppearPKM1.DataSource = new BindingSource(GameInfo.FilteredSources.Species.ToList(), null); }
public SAV_MailBox(SaveFile sav) { InitializeComponent(); WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); SAV = (Origin = sav).Clone(); Gen = SAV.Generation; p = SAV.PartyData; editing = true; Messages = new[] { new[] { NUD_Message00, NUD_Message01, NUD_Message02, NUD_Message03 }, new[] { NUD_Message10, NUD_Message11, NUD_Message12, NUD_Message13 }, new[] { NUD_Message20, NUD_Message21, NUD_Message22, NUD_Message23 } }; PKMLabels = new[] { L_PKM1, L_PKM2, L_PKM3, L_PKM4, L_PKM5, L_PKM6 }; 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 }; AppearPKMs = new[] { CB_AppearPKM1, CB_AppearPKM2, CB_AppearPKM3 }; Miscs = new[] { NUD_Misc1, NUD_Misc2, NUD_Misc3 }; NUD_BoxSize.Visible = L_BoxSize.Visible = Gen == 2; GB_MessageTB.Visible = Gen == 2; GB_MessageNUD.Visible = Gen != 2; Messages[0][3].Visible = Messages[1][3].Visible = Messages[2][3].Visible = Gen == 4 || Gen == 5; NUD_AuthorSID.Visible = Gen != 2; 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++) { PKMNUDs[i].Visible = PKMLabels[i].Visible = PKMHeldItems[i].Visible = false; } if (Gen != 3) { for (int i = 0; i < PKMNUDs.Length; i++) { PKMNUDs[i].Value = i; PKMNUDs[i].Enabled = false; } } switch (SAV) { case SAV2 sav2: m = new Mail2[6 + 10]; for (int i = 0; i < m.Length; i++) { m[i] = new Mail2(sav2, i); } NUD_BoxSize.Value = SAV.Data[0x834]; MailItemID = new[] { 0x9E, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD }; PartyBoxCount = 6; break; case SAV3 sav3: m = new Mail3[6 + 10]; for (int i = 0; i < m.Length; i++) { var ofs = sav3.GetMailOffset(i); var data = sav.GetData(ofs, Mail3.SIZE); m[i] = new Mail3(data, ofs, sav3.Japanese); } MailItemID = Enumerable.Range(0x79, 12).ToArray(); PartyBoxCount = 6; break; case SAV4 sav4: m = new Mail4[p.Count + 20]; for (int i = 0; i < p.Count; i++) { m[i] = new Mail4(((PK4)p[i]).HeldMailData); } for (int i = p.Count, j = 0; i < m.Length; i++, j++) { int ofs = sav4.GetMailOffset(j); m[i] = new Mail4(sav4.GetMailData(ofs), ofs); } var l4 = (Mail4)m.Last(); ResetVer = l4.AuthorVersion; ResetLang = l4.AuthorLanguage; MailItemID = Enumerable.Range(0x89, 12).ToArray(); PartyBoxCount = p.Count; break; case SAV5 sav5: m = new Mail5[p.Count + 20]; for (int i = 0; i < p.Count; i++) { m[i] = new Mail5(((PK5)p[i]).GetHeldMailData()); } for (int i = p.Count, j = 0; i < m.Length; i++, j++) { int ofs = SAV5.GetMailOffset(j); var data = sav5.GetMailData(ofs); m[i] = new Mail5(data, ofs); } var l5 = (Mail5)m.Last(); ResetVer = l5.AuthorVersion; ResetLang = l5.AuthorLanguage; MailItemID = Enumerable.Range(0x89, 12).ToArray(); PartyBoxCount = p.Count; break; } MakePartyList(); MakePCList(); if (Gen == 2 || Gen == 3) { CB_AppearPKM1.Items.Clear(); CB_AppearPKM1.InitializeBinding(); CB_AppearPKM1.DataSource = new BindingSource(GameInfo.FilteredSources.Species.ToList(), null); } else if (Gen == 4 || Gen == 5) { var species = GameInfo.FilteredSources.Species.ToList(); foreach (ComboBox a in AppearPKMs) { a.Items.Clear(); a.InitializeBinding(); a.DataSource = new BindingSource(species, null); } CB_AuthorVersion.Items.Clear(); CB_AuthorVersion.InitializeBinding(); CB_AuthorVersion.DataSource = new BindingSource(Gen == 4 ? new[] { new ComboItem("Diamond", (int)GameVersion.D), new ComboItem("Pearl", (int)GameVersion.P), new ComboItem("Platinum", (int)GameVersion.Pt), new ComboItem("HeartGold", (int)GameVersion.HG), new ComboItem("SoulSilver", (int)GameVersion.SS), } : new[] { new ComboItem("Black", (int)GameVersion.B), new ComboItem("White", (int)GameVersion.W), new ComboItem("Black2", (int)GameVersion.B2), new ComboItem("White2", (int)GameVersion.W2), }, null); CB_AuthorLang.Items.Clear(); CB_AuthorLang.InitializeBinding(); CB_AuthorLang.DataSource = new BindingSource(new[] { // not sure new ComboItem("JPN", 1), new ComboItem("ENG", 2), new ComboItem("FRE", 3), new ComboItem("ITA", 4), new ComboItem("GER", 5), new ComboItem("ESP", 7), new ComboItem("KOR", 8), }, null); } var ItemList = GameInfo.Strings.GetItemStrings(Gen, SAV.Version); CB_MailType.Items.Clear(); CB_MailType.Items.Add(ItemList[0]); foreach (int item in MailItemID) { CB_MailType.Items.Add(ItemList[item]); } LoadPKM(true); entry = -1; editing = false; if (LB_PartyHeld.Items.Count > 0) { LB_PartyHeld.SelectedIndex = 0; } else if (LB_PCBOX.Items.Count > 0) { LB_PCBOX.SelectedIndex = 0; } }
public SAV_MailBox(SaveFile sav) { InitializeComponent(); WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); SAV = (Origin = sav).Clone(); Gen = SAV.Generation; p = SAV.PartyData; editing = true; Messages = new[] { new[] { NUD_Message00, NUD_Message01, NUD_Message02, NUD_Message03 }, new[] { NUD_Message10, NUD_Message11, NUD_Message12, NUD_Message13 }, new[] { NUD_Message20, NUD_Message21, NUD_Message22, NUD_Message23 } }; PKMLabels = new[] { L_PKM1, L_PKM2, L_PKM3, L_PKM4, L_PKM5, L_PKM6 }; 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 }; AppearPKMs = new[] { CB_AppearPKM1, CB_AppearPKM2, CB_AppearPKM3 }; Miscs = new[] { NUD_Misc1, NUD_Misc2, NUD_Misc3 }; NUD_BoxSize.Visible = L_BoxSize.Visible = Gen == 2; GB_MessageTB.Visible = Gen == 2; GB_MessageNUD.Visible = Gen != 2; Messages[0][3].Visible = Messages[1][3].Visible = Messages[2][3].Visible = Gen == 4 || Gen == 5; NUD_AuthorSID.Visible = Gen != 2; 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++) { PKMNUDs[i].Visible = PKMLabels[i].Visible = PKMHeldItems[i].Visible = false; } if (Gen != 3) { for (int i = 0; i < PKMNUDs.Length; i++) { PKMNUDs[i].Value = i; PKMNUDs[i].Enabled = false; } } switch (SAV) { case SAV2 sav2: m = new Mail2[6 + 10]; for (int i = 0; i < m.Length; i++) { m[i] = new Mail2(sav2, i); } NUD_BoxSize.Value = SAV.Data[0x834]; MailItemID = new[] { 0x9E, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD }; break; case SAV3 sav3: m = new Mail3[6 + 10]; for (int i = 0; i < m.Length; i++) { m[i] = new Mail3(sav3, i); } MailItemID = Enumerable.Range(0x79, 12).ToArray(); break; case SAV4 sav4: m = new Mail4[p.Count + 20]; for (int i = 0; i < p.Count; i++) { m[i] = new Mail4((p[i] as PK4).HeldMailData); } for (int i = p.Count, j = 0; i < m.Length; i++, j++) { m[i] = new Mail4(sav4, j); } var l4 = m.Last() as Mail4; ResetVer = l4.AuthorVersion; 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(); break; } MakePartyList(); MakePCList(); if (Gen == 2 || Gen == 3) { CB_AppearPKM1.Items.Clear(); CB_AppearPKM1.DisplayMember = "Text"; CB_AppearPKM1.ValueMember = "Value"; CB_AppearPKM1.DataSource = new BindingSource(GameInfo.SpeciesDataSource.Where(id => id.Value <= sav.MaxSpeciesID).ToList(), null); } else if (Gen == 4 || Gen == 5) { var species = GameInfo.SpeciesDataSource.Where(id => id.Value <= sav.MaxSpeciesID).ToList(); foreach (ComboBox a in AppearPKMs) { a.Items.Clear(); a.DisplayMember = "Text"; a.ValueMember = "Value"; a.DataSource = new BindingSource(species, null); } CB_AuthorVersion.Items.Clear(); CB_AuthorVersion.DisplayMember = "Text"; CB_AuthorVersion.ValueMember = "Value"; CB_AuthorVersion.DataSource = new BindingSource(Gen == 4 ? new[] { new ComboItem { Text = "Diamond", Value = (int)GameVersion.D }, new ComboItem { Text = "Pearl", Value = (int)GameVersion.P }, new ComboItem { Text = "Platinum", Value = (int)GameVersion.Pt }, new ComboItem { Text = "HeartGold", Value = (int)GameVersion.HG }, 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.DisplayMember = "Text"; CB_AuthorLang.ValueMember = "Value"; CB_AuthorLang.DataSource = new BindingSource(new[] { // not sure new ComboItem { Text = "JPN", Value = 1 }, new ComboItem { Text = "ENG", Value = 2 }, 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); } string[] ItemList = GameInfo.Strings.GetItemStrings(Gen, SAV.Version); CB_MailType.Items.Clear(); CB_MailType.Items.Add(ItemList[0]); foreach (int item in MailItemID) { CB_MailType.Items.Add(ItemList[item]); } LoadPKM(true); entry = -1; editing = false; LB_PartyHeld.SelectedIndex = 0; }