From bb65f2d2c25bb69c54c05941c153ea92808e8abb Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 9 Oct 2020 20:31:13 -0700 Subject: [PATCH] Show trainer name&id for registered Stadium teams in dropdown --- PKHeX.Core/Saves/SAV1Stadium.cs | 11 ++++++++++- PKHeX.Core/Saves/SAV1StadiumJ.cs | 13 ++++++++++++- PKHeX.Core/Saves/SAV2Stadium.cs | 12 +++++++++++- .../Save Editors/SAV_GroupViewer.Designer.cs | 9 +++++---- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/Saves/SAV1Stadium.cs b/PKHeX.Core/Saves/SAV1Stadium.cs index c18575ba5..cc068971e 100644 --- a/PKHeX.Core/Saves/SAV1Stadium.cs +++ b/PKHeX.Core/Saves/SAV1Stadium.cs @@ -177,7 +177,16 @@ public string GetTeamName(int team) var teamsPerType = Japanese ? TeamCountJ : TeamCountU; var type = team / teamsPerType; var index = team % teamsPerType; - return $"{GetTeamTypeName(type).Replace('_', ' ')} {index + 1}"; + var name = $"{GetTeamTypeName(type).Replace('_', ' ')} {index + 1}"; + + var ofs = GetTeamOffset(team); + var otOfs = ofs + (Japanese ? 2 : 1); + var str = GetString(otOfs, Japanese ? 5 : 7); + if (string.IsNullOrWhiteSpace(str)) + return name; + var idOfs = ofs + (Japanese ? 0xC : 0x8); + var id = BigEndian.ToUInt16(Data, idOfs); + return $"{name} [{id:D5}:{str}]"; } private string GetTeamTypeName(int type) diff --git a/PKHeX.Core/Saves/SAV1StadiumJ.cs b/PKHeX.Core/Saves/SAV1StadiumJ.cs index 6eed45edf..28e6f9434 100644 --- a/PKHeX.Core/Saves/SAV1StadiumJ.cs +++ b/PKHeX.Core/Saves/SAV1StadiumJ.cs @@ -89,7 +89,18 @@ protected override PKM GetPKM(byte[] data) public override int GetBoxOffset(int box) => Box + ListHeaderSize + (box * BoxSizeJ); public static int GetTeamOffset(int team) => 0 + ListHeaderSize + (team * TeamSizeJ); - public static string GetTeamName(int team) => $"Team {team + 1}"; + + public string GetTeamName(int team) + { + var name = $"Team {team + 1}"; + + var ofs = GetTeamOffset(team); + var str = GetString(ofs + 2, 5); + if (string.IsNullOrWhiteSpace(str)) + return name; + var id = BigEndian.ToUInt16(Data, ofs + 8); + return $"{name} [{id:D5}:{str}]"; + } public override SlotGroup GetTeam(int team) { diff --git a/PKHeX.Core/Saves/SAV2Stadium.cs b/PKHeX.Core/Saves/SAV2Stadium.cs index 2f569bd96..09820ea59 100644 --- a/PKHeX.Core/Saves/SAV2Stadium.cs +++ b/PKHeX.Core/Saves/SAV2Stadium.cs @@ -130,7 +130,17 @@ public static int GetTeamOffset(int team) return 0x4000 + ((team - 40) * TeamSize); } - public static string GetTeamName(int team) => $"{((Stadium2TeamType)(team / TeamCountType)).ToString().Replace('_', ' ')} {(team % 10) + 1}"; + public string GetTeamName(int team) + { + var name = $"{((Stadium2TeamType) (team / TeamCountType)).ToString().Replace('_', ' ')} {(team % 10) + 1}"; + + var ofs = GetTeamOffset(team); + var str = GetString(ofs + 4, 7); + if (string.IsNullOrWhiteSpace(str)) + return name; + var id = BigEndian.ToUInt16(Data, ofs + 2); + return $"{name} [{id:D5}:{str}]"; + } public override string GetBoxName(int box) { diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_GroupViewer.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_GroupViewer.Designer.cs index 319ae40e5..c6d45cb18 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_GroupViewer.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_GroupViewer.Designer.cs @@ -41,7 +41,7 @@ private void InitializeComponent() // B_BoxRight // this.B_BoxRight.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.B_BoxRight.Location = new System.Drawing.Point(194, 3); + this.B_BoxRight.Location = new System.Drawing.Point(206, 3); this.B_BoxRight.Name = "B_BoxRight"; this.B_BoxRight.Size = new System.Drawing.Size(27, 23); this.B_BoxRight.TabIndex = 68; @@ -52,7 +52,7 @@ private void InitializeComponent() // B_BoxLeft // this.B_BoxLeft.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.B_BoxLeft.Location = new System.Drawing.Point(28, 3); + this.B_BoxLeft.Location = new System.Drawing.Point(16, 3); this.B_BoxLeft.Name = "B_BoxLeft"; this.B_BoxLeft.Size = new System.Drawing.Size(27, 23); this.B_BoxLeft.TabIndex = 67; @@ -63,10 +63,11 @@ private void InitializeComponent() // CB_BoxSelect // this.CB_BoxSelect.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_BoxSelect.DropDownWidth = 252; this.CB_BoxSelect.FormattingEnabled = true; - this.CB_BoxSelect.Location = new System.Drawing.Point(61, 4); + this.CB_BoxSelect.Location = new System.Drawing.Point(48, 4); this.CB_BoxSelect.Name = "CB_BoxSelect"; - this.CB_BoxSelect.Size = new System.Drawing.Size(127, 21); + this.CB_BoxSelect.Size = new System.Drawing.Size(152, 21); this.CB_BoxSelect.TabIndex = 66; this.CB_BoxSelect.SelectedIndexChanged += new System.EventHandler(this.CB_BoxSelect_SelectedIndexChanged); //