diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index ba4ee4282..612ba34d3 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -11,7 +11,7 @@ namespace PKHeX.Core; /// Object representing a 's data and derived properties. /// [DynamicallyAccessedMembers(PublicProperties | NonPublicProperties | PublicParameterlessConstructor)] -public abstract class PKM : ISpeciesForm, ITrainerID32, IGeneration, IShiny, ILangNick, IGameValueLimit, INature, IFatefulEncounter, IStringConverter, ITrashIntrospection +public abstract class PKM : ISpeciesForm, ITrainerID32, IGeneration, IShiny, ILangNick, IGameValueLimit, INature, IFatefulEncounter, IStringConverter, ITrashIntrospection, IContext { public abstract int SIZE_PARTY { get; } public abstract int SIZE_STORED { get; } diff --git a/PKHeX.Core/PKM/Strings/IStringConverter.cs b/PKHeX.Core/PKM/Strings/IStringConverter.cs index 6b797acb4..82308c743 100644 --- a/PKHeX.Core/PKM/Strings/IStringConverter.cs +++ b/PKHeX.Core/PKM/Strings/IStringConverter.cs @@ -35,3 +35,20 @@ public interface IStringConverter /// Count of bytes written to . int SetString(Span data, ReadOnlySpan text, int length, StringConverterOption option); } + +public delegate string StringGetter(ReadOnlySpan data); +public delegate int StringLoader(ReadOnlySpan data, Span text); +public delegate int StringSetter(Span data, ReadOnlySpan text, int length, StringConverterOption option); + +public sealed class CustomStringConverter : IStringConverter, IGeneration, IContext +{ + public required StringGetter Get { get; init; } + public required StringLoader Load { get; init; } + public required StringSetter Set { get; init; } + public required byte Generation { get; init; } + public required EntityContext Context { get; init; } + + public string GetString(ReadOnlySpan data) => Get(data); + public int LoadString(ReadOnlySpan data, Span text) => Load(data, text); + public int SetString(Span data, ReadOnlySpan text, int length, StringConverterOption option) => Set(data, text, length, option); +} diff --git a/PKHeX.Core/Saves/Abstractions/ITrainerInfo.cs b/PKHeX.Core/Saves/Abstractions/ITrainerInfo.cs index 3a2671f8e..53747dcdb 100644 --- a/PKHeX.Core/Saves/Abstractions/ITrainerInfo.cs +++ b/PKHeX.Core/Saves/Abstractions/ITrainerInfo.cs @@ -5,7 +5,7 @@ namespace PKHeX.Core; /// /// Minimal Trainer Information necessary for generating a . /// -public interface ITrainerInfo : ITrainerID32ReadOnly, IVersion, IGeneration +public interface ITrainerInfo : ITrainerID32ReadOnly, IVersion, IGeneration, IContext { string OT { get; } byte Gender { get; } @@ -13,7 +13,6 @@ public interface ITrainerInfo : ITrainerID32ReadOnly, IVersion, IGeneration int Language { get; } new byte Generation { get; } - EntityContext Context { get; } } /// diff --git a/PKHeX.Core/Saves/SAV1.cs b/PKHeX.Core/Saves/SAV1.cs index f903d97f3..4767870df 100644 --- a/PKHeX.Core/Saves/SAV1.cs +++ b/PKHeX.Core/Saves/SAV1.cs @@ -293,13 +293,13 @@ public override ushort TID16 public override ushort SID16 { get => 0; set { } } - public string Rival + public string RivalName { get => GetString(Data.Slice(Offsets.Rival, MaxStringLengthTrainer)); set => SetString(Data.Slice(Offsets.Rival, MaxStringLengthTrainer), value, MaxStringLengthTrainer, StringConverterOption.Clear50); } - public Span RivalTrash { get => Data.Slice(Offsets.Rival, StringLength); set { if (value.Length == StringLength) value.CopyTo(Data[Offsets.Rival..]); } } + public Span RivalNameTrash { get => Data.Slice(Offsets.Rival, StringLength); set { if (value.Length == StringLength) value.CopyTo(Data[Offsets.Rival..]); } } public byte RivalStarter { get => Data[Offsets.Starter - 2]; set => Data[Offsets.Starter - 2] = value; } public byte Starter { get => Data[Offsets.Starter]; set => Data[Offsets.Starter] = value; } diff --git a/PKHeX.Core/Saves/SAV2.cs b/PKHeX.Core/Saves/SAV2.cs index 3fa1f3120..5293a7028 100644 --- a/PKHeX.Core/Saves/SAV2.cs +++ b/PKHeX.Core/Saves/SAV2.cs @@ -325,13 +325,13 @@ public Span OriginalTrainerTrash set { if (value.Length == StringLength) value.CopyTo(Data[(Offsets.Trainer1 + 2)..]); } } - public string Rival + public string RivalName { get => GetString(Data.Slice(Offsets.Rival, (Korean ? 2 : 1) * MaxStringLengthTrainer)); set => SetString(Data.Slice(Offsets.Rival, (Korean ? 2 : 1) * MaxStringLengthTrainer), value, 8, StringConverterOption.Clear50); } - public Span RivalTrash + public Span RivalNameTrash { get => Data.Slice(Offsets.Rival, StringLength); set { if (value.Length == StringLength) value.CopyTo(Data[Offsets.Rival..]); } diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs index 726d79801..deb2b98e4 100644 --- a/PKHeX.Core/Saves/SAV4.cs +++ b/PKHeX.Core/Saves/SAV4.cs @@ -340,13 +340,13 @@ public override int PlayedSeconds public abstract int X { get; set; } public abstract int Y { get; set; } - public string Rival + public string RivalName { - get => GetString(RivalTrash); - set => SetString(RivalTrash, value, MaxStringLengthTrainer, StringConverterOption.ClearZero); + get => GetString(RivalNameTrash); + set => SetString(RivalNameTrash, value, MaxStringLengthTrainer, StringConverterOption.ClearZero); } - public abstract Span RivalTrash { get; set; } + public abstract Span RivalNameTrash { get; set; } public abstract int X2 { get; set; } public abstract int Y2 { get; set; } diff --git a/PKHeX.Core/Saves/SAV4DP.cs b/PKHeX.Core/Saves/SAV4DP.cs index d74230ca1..be26da299 100644 --- a/PKHeX.Core/Saves/SAV4DP.cs +++ b/PKHeX.Core/Saves/SAV4DP.cs @@ -97,7 +97,7 @@ public override void SetBoxWallpaper(int box, int value) public override int X { get => ReadUInt16LittleEndian(General[0x1240..]); set => WriteUInt16LittleEndian(General[0x1240..], (ushort)(X2 = value)); } public override int Y { get => ReadUInt16LittleEndian(General[0x1244..]); set => WriteUInt16LittleEndian(General[0x1244..], (ushort)(Y2 = value)); } - public override Span RivalTrash + public override Span RivalNameTrash { get => General.Slice(0x25A8, MaxStringLengthTrainer * 2); set { if (value.Length == MaxStringLengthTrainer * 2) value.CopyTo(General[0x25A8..]); } diff --git a/PKHeX.Core/Saves/SAV4HGSS.cs b/PKHeX.Core/Saves/SAV4HGSS.cs index 4031c6531..09b7d7706 100644 --- a/PKHeX.Core/Saves/SAV4HGSS.cs +++ b/PKHeX.Core/Saves/SAV4HGSS.cs @@ -190,7 +190,7 @@ protected override void SetPKM(PKM pk, bool isParty = false) public override int X { get => ReadUInt16LittleEndian(General[0x123C..]); set => WriteUInt16LittleEndian(General[0x123C..], (ushort)(X2 = value)); } public override int Y { get => ReadUInt16LittleEndian(General[0x1240..]); set => WriteUInt16LittleEndian(General[0x1240..], (ushort)(Y2 = value)); } - public override Span RivalTrash + public override Span RivalNameTrash { get => RivalSpan; set { if (value.Length == MaxStringLengthTrainer * 2) value.CopyTo(RivalSpan); } diff --git a/PKHeX.Core/Saves/SAV4Pt.cs b/PKHeX.Core/Saves/SAV4Pt.cs index e253a219e..619316045 100644 --- a/PKHeX.Core/Saves/SAV4Pt.cs +++ b/PKHeX.Core/Saves/SAV4Pt.cs @@ -137,7 +137,7 @@ public void SetWallpaperUnlocked(Wallpaper4Pt wallpaperId, bool value) public override int X { get => ReadUInt16LittleEndian(General[0x1288..]); set => WriteUInt16LittleEndian(General[0x1288..], (ushort)(X2 = value)); } public override int Y { get => ReadUInt16LittleEndian(General[0x128C..]); set => WriteUInt16LittleEndian(General[0x128C..], (ushort)(Y2 = value)); } - public override Span RivalTrash + public override Span RivalNameTrash { get => RivalSpan; set { if (value.Length == MaxStringLengthTrainer * 2) value.CopyTo(RivalSpan); } diff --git a/PKHeX.Core/Saves/SAV5B2W2.cs b/PKHeX.Core/Saves/SAV5B2W2.cs index 9b27e4a33..1ee635d9a 100644 --- a/PKHeX.Core/Saves/SAV5B2W2.cs +++ b/PKHeX.Core/Saves/SAV5B2W2.cs @@ -51,13 +51,13 @@ public sealed class SAV5B2W2 : SAV5, ISaveBlock5B2W2 public MedalList5 Medals => Blocks.Medals; public KeySystem5 Keys => Blocks.Keys; - public string Rival + public string RivalName { - get => GetString(RivalTrash); - set => SetString(RivalTrash, value, MaxStringLengthTrainer, StringConverterOption.ClearZero); + get => GetString(RivalNameTrash); + set => SetString(RivalNameTrash, value, MaxStringLengthTrainer, StringConverterOption.ClearZero); } - public Span RivalTrash + public Span RivalNameTrash { get => Data.Slice(0x23BA4, MaxStringLengthTrainer * 2); set { if (value.Length == MaxStringLengthTrainer * 2) value.CopyTo(Data[0x23BA4..]); } diff --git a/PKHeX.Core/Saves/SAV8BS.cs b/PKHeX.Core/Saves/SAV8BS.cs index 2cd05237a..aa242c68a 100644 --- a/PKHeX.Core/Saves/SAV8BS.cs +++ b/PKHeX.Core/Saves/SAV8BS.cs @@ -280,10 +280,12 @@ public override int SetString(Span destBuffer, ReadOnlySpan value, i public override int CurrentBox { get => BoxLayout.CurrentBox; set => BoxLayout.CurrentBox = (byte)value; } public override int BoxesUnlocked { get => BoxLayout.BoxesUnlocked; set => BoxLayout.BoxesUnlocked = (byte)value; } - public string Rival + public Span RivalNameTrash => Data.Slice(0x55F4, 0x1A); + + public string RivalName { - get => GetString(Data.Slice(0x55F4, 0x1A)); - set => SetString(Data.Slice(0x55F4, 0x1A), value, MaxStringLengthTrainer, StringConverterOption.ClearZero); + get => GetString(RivalNameTrash); + set => SetString(RivalNameTrash, value, MaxStringLengthTrainer, StringConverterOption.ClearZero); } public short ZoneID // map diff --git a/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs b/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs index 1c2ea6b2a..cd5c3491a 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs @@ -51,7 +51,7 @@ public int RegistryStatus public string OriginalTrainerName { get => StringConverter3.GetString(OriginalTrainerTrash, Language); - set => StringConverter3.SetString(OriginalTrainerTrash, value, 7, Language, StringConverterOption.ClearFF); + set => StringConverter3.SetString(OriginalTrainerTrash, value, 7, Language, StringConverterOption.None); } public int OriginalTrainerClass => Data[9] % 5; diff --git a/PKHeX.Core/Saves/Substructures/Gen6/MyStatus6.cs b/PKHeX.Core/Saves/Substructures/Gen6/MyStatus6.cs index f8059bd49..bea194071 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/MyStatus6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/MyStatus6.cs @@ -101,7 +101,7 @@ public int Language set => Data[0x2D] = (byte)value; } - private Span OriginalTrainerTrash => Data.Slice(0x48, 0x1A); + public Span OriginalTrainerTrash => Data.Slice(0x48, 0x1A); public string OT { diff --git a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/Misc7b.cs b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/Misc7b.cs index e1620a5f5..3d1139305 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/Misc7b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/Misc7b.cs @@ -11,11 +11,11 @@ public uint Money set => WriteUInt32LittleEndian(Data[4..], value); } - private Span RivalTrash => Data.Slice(0x200, 0x1A); + public Span RivalNameTrash => Data.Slice(0x200, 0x1A); - public string Rival + public string RivalName { - get => SAV.GetString(RivalTrash); - set => SAV.SetString(RivalTrash, value, SAV.MaxStringLengthTrainer, StringConverterOption.ClearZero); + get => SAV.GetString(RivalNameTrash); + set => SAV.SetString(RivalNameTrash, value, SAV.MaxStringLengthTrainer, StringConverterOption.ClearZero); } } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyStatus7b.cs b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyStatus7b.cs index a64262b20..026027b24 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyStatus7b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyStatus7b.cs @@ -60,7 +60,7 @@ public int Language set => Data[0x35] = (byte)value; } - private Span OriginalTrainerTrash => Data.Slice(0x38, 0x1A); + public Span OriginalTrainerTrash => Data.Slice(0x38, 0x1A); public string OT { diff --git a/PKHeX.Core/Saves/Substructures/Gen7/MyStatus7.cs b/PKHeX.Core/Saves/Substructures/Gen7/MyStatus7.cs index 5e5ab2190..b43c4b316 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/MyStatus7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/MyStatus7.cs @@ -93,7 +93,7 @@ public int Language set => Data[0x35] = (byte)value; } - private Span OriginalTrainerTrash => Data.Slice(0x38, 0x1A); + public Span OriginalTrainerTrash => Data.Slice(0x38, 0x1A); public string OT { diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/MyStatus8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/MyStatus8b.cs index 6fbee2bdd..346d5c7d5 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/MyStatus8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/MyStatus8b.cs @@ -14,7 +14,7 @@ public sealed class MyStatus8b(SAV8BS sav, Memory raw) : SaveBlock public const byte MAX_BADGE = 8; // public const byte MAX_RANK = 5; // unused? - private Span OriginalTrainerTrash => Data[..0x1A]; + public Span OriginalTrainerTrash => Data[..0x1A]; public string OT { diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/MyStatus8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/MyStatus8a.cs index 3e9261b9a..8014cfba3 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/MyStatus8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/MyStatus8a.cs @@ -57,7 +57,7 @@ public int Language } } - private Span OriginalTrainerTrash => Data.Slice(0x20, 0x1A); + public Span OriginalTrainerTrash => Data.Slice(0x20, 0x1A); public string OT { diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyStatus8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyStatus8.cs index 559b70f16..4bf29edc4 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyStatus8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyStatus8.cs @@ -175,7 +175,7 @@ public int Language } } - private Span OriginalTrainerTrash => Data.Slice(0xB0, 0x1A); + public Span OriginalTrainerTrash => Data.Slice(0xB0, 0x1A); public string OT { diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TrainerCard8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TrainerCard8.cs index 57713df5d..d62e59d95 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TrainerCard8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TrainerCard8.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core; public sealed class TrainerCard8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Raw) { - private Span OriginalTrainerTrash => Data[..0x1A]; + public Span OriginalTrainerTrash => Data[..0x1A]; public string OT { diff --git a/PKHeX.Core/Saves/Substructures/Gen9/SV/MyStatus9.cs b/PKHeX.Core/Saves/Substructures/Gen9/SV/MyStatus9.cs index 354c03d44..2c2b0a626 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/SV/MyStatus9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/SV/MyStatus9.cs @@ -56,7 +56,7 @@ public RuntimeLanguage RuntimeLanguageId set => SAV.SetValue(SaveBlockAccessor9SV.KGameLanguage, (int)value); } - private Span OriginalTrainerTrash => Data.Slice(0x10, 0x1A); + public Span OriginalTrainerTrash => Data.Slice(0x10, 0x1A); public string OT { diff --git a/PKHeX.Core/Saves/Substructures/Gen9/ZA/MyStatus9a.cs b/PKHeX.Core/Saves/Substructures/Gen9/ZA/MyStatus9a.cs index ff0e58378..43dc117a4 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/ZA/MyStatus9a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/ZA/MyStatus9a.cs @@ -15,7 +15,7 @@ public sealed class MyStatus9a(SAV9ZA sav, SCBlock block) : SaveBlock(sa public int Language { get => Data[0x07]; set => Data[0x07] = (byte)value; } - private Span OriginalTrainerTrash => Data.Slice(0x10, 0x1A); + public Span OriginalTrainerTrash => Data.Slice(0x10, 0x1A); public string OT { diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs index 3cdc58805..909cc7e3c 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs @@ -543,6 +543,7 @@ private void InitializeComponent() // TB_PID.Anchor = System.Windows.Forms.AnchorStyles.Left; TB_PID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + TB_PID.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; TB_PID.Font = new System.Drawing.Font("Courier New", 8.25F); TB_PID.Location = new System.Drawing.Point(0, 3); TB_PID.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0); @@ -3261,6 +3262,7 @@ private void InitializeComponent() // TB_EC // TB_EC.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + TB_EC.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; TB_EC.Font = new System.Drawing.Font("Courier New", 8.25F); TB_EC.Location = new System.Drawing.Point(184, 2); TB_EC.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0); diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 767560b03..8e824c47b 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -1439,10 +1439,11 @@ private void UpdateNicknameClick(object sender, MouseEventArgs e) if (ModifierKeys != Keys.Control) return; + if (sender is not TextBox tb) + return; // Open Trash/Special Character form // Set the string back to the entity in the right spot, so the span fetch has the latest data. Span trash; - TextBox tb = sender as TextBox ?? TB_Nickname; if (tb == TB_Nickname) { Entity.Nickname = tb.Text; @@ -1463,10 +1464,7 @@ private void UpdateNicknameClick(object sender, MouseEventArgs e) return; } - using var d = new TrashEditor(tb, trash, Entity, Entity.Format, Entity.Context); - d.ShowDialog(); - tb.Text = d.FinalString; - d.FinalBytes.CopyTo(trash); + TrashEditor.Show(tb, Entity, trash); } private void UpdateNotOT(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Subforms/PKM Editors/Text.cs b/PKHeX.WinForms/Subforms/PKM Editors/Text.cs index 4cf0ba8d2..4991a0029 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/Text.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/Text.cs @@ -17,16 +17,34 @@ public partial class TrashEditor : Form private readonly byte[] Raw; private bool editing; - public TrashEditor(TextBoxBase TB_NN, IStringConverter sav, byte generation, EntityContext context) - : this(TB_NN, [], sav, generation, context) { } + private static TrashEditor Get(TextBoxBase tb, T provider, Span trash = default) where T : IStringConverter, IGeneration, IContext + => new(tb, provider, provider.Generation, provider.Context, trash); - public TrashEditor(TextBoxBase TB_NN, Span raw, IStringConverter converter, byte generation, EntityContext context) + public static void Show(TextBoxBase tb, T provider, Span trash = default, bool readOnly = false) + where T : IStringConverter, IGeneration, IContext + { + using var form = Get(tb, provider, trash); + if (readOnly) + form.B_Save.Enabled = false; + form.ShowDialog(); + tb.Text = form.FinalString; + form.FinalBytes.CopyTo(trash); + } + + // workaround to being unable to translate this via reflection with the DevUtil scraper with ref structs +#nullable disable + // ReSharper disable once NotNullOrRequiredMemberIsNotInitialized + private TrashEditor() { InitializeComponent(); WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); - Converter = converter; + } +#nullable enable - FinalString = TB_NN.Text; + private TrashEditor(TextBoxBase tb, IStringConverter converter, byte generation, EntityContext context, Span raw = default) : this() + { + Converter = converter; + FinalString = tb.Text; editing = true; if (raw.Length != 0) @@ -41,8 +59,8 @@ public TrashEditor(TextBoxBase TB_NN, Span raw, IStringConverter converter var f = FontUtil.GetPKXFont(); AddCharEditing(f, context); - TB_Text.MaxLength = TB_NN.MaxLength; - TB_Text.Text = TB_NN.Text; + TB_Text.MaxLength = tb.MaxLength; + TB_Text.Text = tb.Text; TB_Text.Font = f; if (FLP_Characters.Controls.Count == 0) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen1/SAV_HallOfFame1.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen1/SAV_HallOfFame1.cs index ca1508424..d2ad3f7f5 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen1/SAV_HallOfFame1.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen1/SAV_HallOfFame1.cs @@ -210,14 +210,7 @@ private void ClickNickname(object sender, MouseEventArgs e) if (tb.Text != pk.Nickname) // preserve trash pk.Nickname = tb.Text; - var nicktrash = pk.NicknameTrash; - var d = new TrashEditor(tb, nicktrash, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; - d.FinalBytes.CopyTo(nicktrash); - - if (tb.Text != pk.Nickname) // preserve trash - tb.Text = pk.Nickname; + TrashEditor.Show(tb, SAV, pk.NicknameTrash); } private void B_Delete_Click(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_HallOfFame3.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_HallOfFame3.cs index 8e2d4f0b4..c397c3902 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_HallOfFame3.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_HallOfFame3.cs @@ -151,13 +151,7 @@ private void ClickNickname(object? sender, EventArgs e) if (tb.Text != pk.Nickname) // preserve trash pk.Nickname = tb.Text; - var nicktrash = pk.NicknameTrash; - var d = new TrashEditor(tb, nicktrash, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; - d.FinalBytes.CopyTo(nicktrash); - if (tb.Text != pk.Nickname) // preserve trash - tb.Text = pk.Nickname; + TrashEditor.Show(tb, SAV, pk.NicknameTrash); } } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.Designer.cs index a46354f9c..3168dcd98 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.Designer.cs @@ -1721,6 +1721,7 @@ private void InitializeComponent() // // TB_PID // + TB_PID.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; TB_PID.Font = new System.Drawing.Font("Courier New", 8F); TB_PID.Location = new System.Drawing.Point(90, 53); TB_PID.Name = "TB_PID"; diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs index ede8e11f1..ef5117f37 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs @@ -56,6 +56,7 @@ public SAV_Misc3(SAV3 sav) if (SAV is SAV3FRLG frlg) { TB_RivalName.Text = frlg.RivalName; + TB_RivalName.Click += (_, _) => TrashEditor.Show(TB_RivalName, frlg, frlg.LargeBlock.RivalNameTrash); // Trainer Card Species ComboBox[] cba = [CB_TCM1, CB_TCM2, CB_TCM3, CB_TCM4, CB_TCM5, CB_TCM6]; @@ -92,7 +93,8 @@ private void B_Save_Click(object sender, EventArgs e) SaveBattleFrontier(); if (SAV is SAV3FRLG frlg) { - frlg.RivalName = TB_RivalName.Text; + if (frlg.RivalName != TB_RivalName.Text) // preserve trash + frlg.RivalName = TB_RivalName.Text; ComboBox[] cba = [CB_TCM1, CB_TCM2, CB_TCM3, CB_TCM4, CB_TCM5, CB_TCM6]; for (int i = 0; i < cba.Length; i++) { diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.Designer.cs index c047169eb..067aea5c9 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.Designer.cs @@ -209,6 +209,7 @@ private void InitializeComponent() // TB_PID // TB_PID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + TB_PID.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; TB_PID.Font = new System.Drawing.Font("Courier New", 8.25F); TB_PID.Location = new System.Drawing.Point(182, 42); TB_PID.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0); diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_SecretBase3.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_SecretBase3.Designer.cs index 9dc96053c..0e5b2b540 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_SecretBase3.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_SecretBase3.Designer.cs @@ -255,6 +255,7 @@ private void InitializeComponent() // // TB_PID // + TB_PID.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; TB_PID.Location = new System.Drawing.Point(384, 132); TB_PID.Name = "TB_PID"; TB_PID.Size = new System.Drawing.Size(100, 23); diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_SecretBase3.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_SecretBase3.cs index 133f6bf45..4ae4f3792 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_SecretBase3.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_SecretBase3.cs @@ -75,9 +75,26 @@ public SAV_SecretBase3(SAV3 sav) if (!TB_PID.Text.All(c => "0123456789abcdefABCDEF\n".Contains(c))) TB_PID.Text = uint.MaxValue.ToString("X8"); }; + TB_Name.Click += (_, _) => + { + if (ModifierKeys != Keys.Control) + return; + + var secret = (SecretBase3)LB_Bases.SelectedItem!; + var language = secret.Language; + var converter = new CustomStringConverter + { + Context = EntityContext.Gen3, + Generation = 3, + Get = data => StringConverter3.GetString(data, language), + Load = (data, result) => StringConverter3.LoadString(data, result, language), + Set = (data, value, maxLength, option) => StringConverter3.SetString(data, value, maxLength, language, option), + }; + TrashEditor.Show(TB_Name, converter, secret.OriginalTrainerTrash); + }; LB_Bases.InitializeBinding(); LB_Bases.DataSource = Manager.Bases; - LB_Bases.DisplayMember = "OriginalTrainerName"; + LB_Bases.DisplayMember = nameof(SecretBase3.OriginalTrainerName); CB_Species.SelectedIndexChanged += (_, _) => { @@ -190,7 +207,7 @@ private void B_UpdateTrainer_Click(object sender, EventArgs e) secret.BattledToday = CHK_Battled.Checked; secret.RegistryStatus = CHK_Registered.Checked ? 1 : 0; LB_Bases.DisplayMember = null!; - LB_Bases.DisplayMember = "OriginalTrainerName"; + LB_Bases.DisplayMember = nameof(SecretBase3.OriginalTrainerName); System.Media.SystemSounds.Asterisk.Play(); } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.Designer.cs index 0e15aba6e..29b12657b 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.Designer.cs @@ -197,6 +197,7 @@ private void InitializeComponent() // TB_EC // TB_EC.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + TB_EC.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; TB_EC.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); TB_EC.Location = new System.Drawing.Point(294, 185); TB_EC.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs index c66e5e78a..7b03728cb 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs @@ -371,12 +371,7 @@ private void ChangeNickname(object sender, MouseEventArgs e) var data = Fame.GetEntity(team, member); var nicktrash = data.Slice(0x18, 26); var text = tb.Text; - SAV.SetString(nicktrash, text, 12, StringConverterOption.ClearZero); - var d = new TrashEditor(tb, nicktrash, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; - d.FinalBytes.CopyTo(nicktrash); - - TB_Nickname.Text = StringConverter6.GetString(nicktrash); + SAV.SetString(nicktrash, text, 12, StringConverterOption.None); + TrashEditor.Show(tb, SAV, nicktrash); } } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_SecretBase.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_SecretBase.Designer.cs index 7a482b633..43fef1c0a 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_SecretBase.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_SecretBase.Designer.cs @@ -666,6 +666,7 @@ private void InitializeComponent() // TB_EC // TB_EC.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + TB_EC.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; TB_EC.Font = new System.Drawing.Font("Courier New", 8.25F); TB_EC.Location = new System.Drawing.Point(82, 37); TB_EC.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_Trainer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_Trainer.cs index fced86d58..e7da83480 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_Trainer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_Trainer.cs @@ -203,7 +203,8 @@ private void Save() SAV.ConsoleRegion = (byte)WinFormsUtil.GetIndex(CB_3DSReg); SAV.Language = WinFormsUtil.GetIndex(CB_Language); - SAV.OT = TB_OTName.Text; + if (SAV.OT != TB_OTName.Text) // only modify if changed (preserve trash bytes?) + SAV.OT = TB_OTName.Text; var status = SAV.Status; status.Saying1 = TB_Saying1.Text; @@ -275,14 +276,11 @@ private void Save() private void ClickOT(object sender, MouseEventArgs e) { - TextBox tb = sender as TextBox ?? TB_OTName; // Special Character Form if (ModifierKeys != Keys.Control) return; - var d = new TrashEditor(tb, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; + TrashEditor.Show(TB_OTName, SAV, SAV.Status.OriginalTrainerTrash); } private void ShowTSV(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs index 12dce5592..f82476377 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs @@ -399,14 +399,12 @@ private void B_AllPhrases_Click(object sender, EventArgs e) private void TB_OTName_MouseDown(object sender, MouseEventArgs e) { - TextBox tb = sender as TextBox ?? TB_OTName; // Special Character Form if (ModifierKeys != Keys.Control) return; - var d = new TrashEditor(tb, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; + var tb = sender as TextBox ?? TB_OTName; + TrashEditor.Show(tb, SAV); } private readonly string[] gendersymbols = ["♂", "♀"]; diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.Designer.cs index 8b6b6d58e..4a3e5633e 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.Designer.cs @@ -1,4 +1,4 @@ -namespace PKHeX.WinForms +namespace PKHeX.WinForms { partial class SAV_HallOfFame7 { @@ -359,6 +359,7 @@ private void InitializeComponent() // TB_EC // TB_EC.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + TB_EC.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; TB_EC.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); TB_EC.Location = new System.Drawing.Point(150, 195); TB_EC.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs index 447d4c7db..cfa7d8b53 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs @@ -334,7 +334,8 @@ private void SaveTrainerInfo() if (CB_AlolaTime.Enabled) SAV.GameTime.AlolaTime = (ulong)WinFormsUtil.GetIndex(CB_AlolaTime); - SAV.OT = TB_OTName.Text; + if (SAV.OT != TB_OTName.Text) // only modify if changed (preserve trash bytes?) + SAV.OT = TB_OTName.Text; // Copy Position if (GB_Map.Enabled && MapUpdated) @@ -479,14 +480,11 @@ private static uint GetBits(ListBox listbox) private void ClickOT(object sender, MouseEventArgs e) { - TextBox tb = sender as TextBox ?? TB_OTName; // Special Character Form if (ModifierKeys != Keys.Control) return; - var d = new TrashEditor(tb, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; + TrashEditor.Show(TB_OTName, SAV, SAV.MyStatus.OriginalTrainerTrash); } private void B_Cancel_Click(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7GG.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7GG.cs index 195994d4d..7774fff5b 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7GG.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7GG.cs @@ -67,7 +67,7 @@ private void LoadTrainerInfo() { // Get Data TB_OTName.Text = SAV.OT; - TB_RivalName.Text = SAV.Blocks.Misc.Rival; + TB_RivalName.Text = SAV.Blocks.Misc.RivalName; CB_Language.SelectedValue = SAV.Language; MT_Money.Text = SAV.Blocks.Misc.Money.ToString(); @@ -114,8 +114,10 @@ private void SaveTrainerInfo() SAV.Money = Util.ToUInt32(MT_Money.Text); SAV.Language = WinFormsUtil.GetIndex(CB_Language); - SAV.OT = TB_OTName.Text; - SAV.Blocks.Misc.Rival = TB_RivalName.Text; + if (SAV.OT != TB_OTName.Text) + SAV.OT = TB_OTName.Text; + if (SAV.Blocks.Misc.RivalName != TB_RivalName.Text) + SAV.Blocks.Misc.RivalName = TB_RivalName.Text; // Copy Position if (GB_Map.Enabled && MapUpdated) @@ -149,12 +151,11 @@ private void ClickString(object sender, MouseEventArgs e) if (ModifierKeys != Keys.Control) return; - TextBox tb = sender as TextBox ?? TB_OTName; + if (sender is not TextBox tb) + return; - // Special Character Form - var d = new TrashEditor(tb, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; + var trash = tb == TB_OTName ? SAV.Status.OriginalTrainerTrash : SAV.Misc.RivalNameTrash; + TrashEditor.Show(tb, SAV, trash); } private void B_Cancel_Click(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8.cs index 2533decd8..a8a3b7288 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8.cs @@ -157,8 +157,13 @@ private void SaveTrainerInfo() SAV.Money = Util.ToUInt32(MT_Money.Text); SAV.Language = WinFormsUtil.GetIndex(CB_Language); - SAV.OT = TB_OTName.Text; - SAV.Blocks.TrainerCard.OT = TB_TrainerCardName.Text; + + // only modify if changed (preserve trash bytes?) + if (SAV.OT != TB_OTName.Text) + SAV.OT = TB_OTName.Text; + if (SAV.Blocks.TrainerCard.OT != TB_TrainerCardName.Text) + SAV.Blocks.TrainerCard.OT = TB_TrainerCardName.Text; + SAV.Blocks.MyStatus.Number = SAV.Blocks.TrainerCard.Number = TB_TrainerCardNumber.Text; SAV.Blocks.TrainerCard.TrainerID = Util.ToInt32(MT_TrainerCardID.Text); SAV.Blocks.TrainerCard.RotoRallyScore = Util.ToInt32(MT_RotoRally.Text); @@ -204,14 +209,13 @@ private void SaveTrainerInfo() private void ClickOT(object sender, MouseEventArgs e) { - TextBox tb = sender as TextBox ?? TB_OTName; + if (sender is not TextBox tb) + return; // Special Character Form if (ModifierKeys != Keys.Control) return; - - var d = new TrashEditor(tb, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; + var trash = tb == TB_OTName ? SAV.MyStatus.OriginalTrainerTrash : SAV.Blocks.TrainerCard.OriginalTrainerTrash; + TrashEditor.Show(tb, SAV, trash); } private void B_Cancel_Click(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8a.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8a.cs index 785fc051a..838908856 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8a.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8a.cs @@ -88,7 +88,10 @@ private void SaveTrainerInfo() SAV.Money = Util.ToUInt32(MT_Money.Text); SAV.Language = WinFormsUtil.GetIndex(CB_Language); - SAV.OT = TB_OTName.Text; + + // only modify if changed (preserve trash bytes?) + if (SAV.OT != TB_OTName.Text) + SAV.OT = TB_OTName.Text; // Copy Position if (GB_Map.Enabled && MapUpdated) @@ -121,20 +124,14 @@ private void SaveTrainerInfo() private void ClickOT(object sender, MouseEventArgs e) { - TextBox tb = sender as TextBox ?? TB_OTName; + var tb = TB_OTName; // Special Character Form if (ModifierKeys != Keys.Control) return; - - var d = new TrashEditor(tb, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; + TrashEditor.Show(tb, SAV, SAV.MyStatus.OriginalTrainerTrash); } - private void B_Cancel_Click(object sender, EventArgs e) - { - Close(); - } + private void B_Cancel_Click(object sender, EventArgs e) => Close(); private void B_Save_Click(object sender, EventArgs e) { diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8b.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8b.cs index 7d050a4bf..236c0da0d 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8b.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Trainer8b.cs @@ -56,7 +56,7 @@ private void GetTextBoxes() trainerID1.LoadIDValues(SAV, SAV.Generation); MT_Money.Text = SAV.Money.ToString(); CB_Language.SelectedValue = SAV.Language; - TB_Rival.Text = SAV.Rival; + TB_Rival.Text = SAV.RivalName; NUD_M.Value = SAV.ZoneID; NUD_X.Value = SAV.MyStatus.X; @@ -108,8 +108,13 @@ private void SaveTrainerInfo() SAV.Money = Util.ToUInt32(MT_Money.Text); SAV.Language = WinFormsUtil.GetIndex(CB_Language); - SAV.OT = TB_OTName.Text; - SAV.Rival = TB_Rival.Text; + + // only modify if changed (preserve trash bytes?) + if (SAV.OT != TB_OTName.Text) + SAV.OT = TB_OTName.Text; + if (SAV.RivalName != TB_Rival.Text) + SAV.RivalName = TB_Rival.Text; + SAV.BattleTower.BP = (uint)NUD_BP.Value; // Copy Position @@ -152,14 +157,15 @@ private static DateTime ReviseTimestamp(DateTime original, DateTime date, DateTi private void ClickOT(object sender, MouseEventArgs e) { - TextBox tb = sender as TextBox ?? TB_OTName; + if (sender is not TextBox tb) + return; + // Special Character Form if (ModifierKeys != Keys.Control) return; - var d = new TrashEditor(tb, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; + var trash = tb == TB_OTName ? SAV.MyStatus.OriginalTrainerTrash : SAV.RivalNameTrash; + TrashEditor.Show(tb, SAV, trash); } private void B_Cancel_Click(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Raid9.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Raid9.Designer.cs index 7c2f2f3a3..6c8884fae 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Raid9.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Raid9.Designer.cs @@ -88,6 +88,7 @@ private void InitializeComponent() // TB_SeedTomorrow // TB_SeedTomorrow.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left; + TB_SeedTomorrow.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; TB_SeedTomorrow.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); TB_SeedTomorrow.Location = new System.Drawing.Point(120, 336); TB_SeedTomorrow.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); @@ -100,6 +101,7 @@ private void InitializeComponent() // TB_SeedToday // TB_SeedToday.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left; + TB_SeedToday.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; TB_SeedToday.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); TB_SeedToday.Location = new System.Drawing.Point(120, 304); TB_SeedToday.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Trainer9.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Trainer9.cs index d4eb36e3c..df0c0d21b 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Trainer9.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Trainer9.cs @@ -159,7 +159,10 @@ private void SaveTrainerInfo() SAV.Money = Util.ToUInt32(MT_Money.Text); SAV.LeaguePoints = Util.ToUInt32(MT_LP.Text); SAV.Language = WinFormsUtil.GetIndex(CB_Language); - SAV.OT = TB_OTName.Text; + + // only modify if changed (preserve trash bytes?) + if (SAV.OT != TB_OTName.Text) + SAV.OT = TB_OTName.Text; // Save PlayTime SAV.PlayedHours = ushort.Parse(MT_Hours.Text); @@ -175,14 +178,10 @@ private void SaveTrainerInfo() private void ClickOT(object sender, MouseEventArgs e) { - TextBox tb = sender as TextBox ?? TB_OTName; // Special Character Form if (ModifierKeys != Keys.Control) return; - - var d = new TrashEditor(tb, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; + TrashEditor.Show(TB_OTName, SAV, SAV.MyStatus.OriginalTrainerTrash); } private void B_Cancel_Click(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Trainer9a.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Trainer9a.cs index 0bfa974a3..c6156190a 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Trainer9a.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Trainer9a.cs @@ -173,7 +173,10 @@ private void SaveTrainerInfo() SAV.Money = Util.ToUInt32(MT_Money.Text); SAV.Language = WinFormsUtil.GetIndex(CB_Language); - SAV.OT = TB_OTName.Text; + + // only modify if changed (preserve trash bytes?) + if (SAV.OT != TB_OTName.Text) + SAV.OT = TB_OTName.Text; // Save PlayTime SAV.PlayedHours = ushort.Parse(MT_Hours.Text); @@ -189,14 +192,10 @@ private void SaveTrainerInfo() private void ClickOT(object sender, MouseEventArgs e) { - TextBox tb = sender as TextBox ?? TB_OTName; // Special Character Form if (ModifierKeys != Keys.Control) return; - - var d = new TrashEditor(tb, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; + TrashEditor.Show(TB_OTName, SAV, SAV.MyStatus.OriginalTrainerTrash); } private void B_Cancel_Click(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs index baffc08b1..fa2099c63 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs @@ -109,7 +109,7 @@ private void CreateBagViews() } } - private DataGridView GetDGV(InventoryPouch pouch) + private DoubleBufferedDataGridView GetDGV(InventoryPouch pouch) { // Add DataGrid var dgv = GetBaseDataGrid(pouch); diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs index bc15f2daa..1575e4c60 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs @@ -205,15 +205,12 @@ public SAV_SimpleTrainer(SaveFile sav) private readonly bool Loading; private bool MapUpdated; - private void ClickOT(Span text, TextBox tb) + private void ClickOT(Span trash, TextBox tb) { // Special Character Form if (ModifierKeys != Keys.Control) return; - - var d = new TrashEditor(tb, text, SAV, SAV.Generation, SAV.Context); - d.ShowDialog(); - tb.Text = d.FinalString; + TrashEditor.Show(tb, SAV, trash); } private void ChangeFFFF(object sender, EventArgs e)