diff --git a/PKHeX.WinForms/Subforms/PKM Editors/Text.cs b/PKHeX.WinForms/Subforms/PKM Editors/Text.cs index cbf1ec8f9..2c526a646 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/Text.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/Text.cs @@ -15,6 +15,7 @@ public TrashEditor(TextBoxBase TB_NN, byte[] raw, SaveFile sav) InitializeComponent(); WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); SAV = sav; + BytesPerChar = sav.Generation > 3 || sav.GameCube ? 2 : 1; FinalString = TB_NN.Text; Raw = FinalBytes = raw; @@ -43,6 +44,8 @@ public TrashEditor(TextBoxBase TB_NN, byte[] raw, SaveFile sav) CenterToParent(); } + private readonly int BytesPerChar; + private readonly List Bytes = new List(); private readonly Font pkxFont = FontUtil.GetPKXFont(12F); public string FinalString; @@ -161,7 +164,7 @@ private void B_ApplyTrash_Click(object sender, EventArgs e) WinFormsUtil.Alert("Trash byte layer is too long to apply."); return; } - for (int i = current.Length; i < data.Length; i++) + for (int i = current.Length + BytesPerChar; i < data.Length; i++) Bytes[i].Value = data[i]; } @@ -172,7 +175,7 @@ private void B_ClearTrash_Click(object sender, EventArgs e) Bytes[i].Value = 0; } - private byte[] SetString(string text) => SAV.SetString(text, Raw.Length); + private byte[] SetString(string text) => SAV.SetString(text, text.Length); private string GetString() => SAV.GetString(Raw, 0, Raw.Length); // Helpers