From c19a4605d5227fb262fe3136e63beea65e88e48d Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 4 Jul 2025 01:32:25 -0500 Subject: [PATCH] Misc tweaks No functional change --- .../Editing/BattleTemplate/Showdown/ShowdownSet.cs | 2 +- PKHeX.Core/Editing/BattleTemplate/StatDisplayConfig.cs | 4 ++-- .../Saves/Editors/EventWork/Diff/EventWorkDiff.cs | 4 ++-- .../Saves/Editors/EventWork/Diff/EventWorkDiff7b.cs | 4 ++-- .../Saves/Editors/EventWork/Diff/EventWorkDiff8b.cs | 6 +++--- .../Legality/Encounters/Data/Gen3/Encounters3Colo.cs | 4 +++- .../Legality/Encounters/Data/Live/EncountersGO.cs | 2 +- .../Templates/Gen4/EncounterTrade4RanchGift.cs | 2 +- .../Encounters/Templates/Gen8b/EncounterEgg8b.cs | 5 ++--- PKHeX.Core/Saves/Util/Recognition/SaveHandlerARDS.cs | 2 +- .../Saves/Util/Recognition/SaveHandlerDeSmuME.cs | 2 +- .../Saves/Util/Recognition/SaveHandlerFooterRTC.cs | 2 +- PKHeX.Core/Saves/Util/Recognition/SaveHandlerGCI.cs | 2 +- PKHeX.Core/Saves/Util/Recognition/SaveHandlerNSO.cs | 2 +- .../Saves/Util/Recognition/SaveHandlerSplitResult.cs | 8 +++++--- PKHeX.WinForms/Controls/PKM Editor/GenderToggle.cs | 2 +- .../Controls/PKM Editor/SelectablePictureBox.cs | 2 +- PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs | 2 +- PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs | 2 +- PKHeX.WinForms/MainWindow/Main.cs | 2 +- PKHeX.WinForms/PKHeX.WinForms.csproj | 1 + PKHeX.WinForms/Subforms/KChart.cs | 2 +- PKHeX.WinForms/Util/WinFormsTranslator.cs | 2 +- PKHeX.WinForms/Util/WinFormsUtil.cs | 10 ++++++++++ 24 files changed, 45 insertions(+), 31 deletions(-) diff --git a/PKHeX.Core/Editing/BattleTemplate/Showdown/ShowdownSet.cs b/PKHeX.Core/Editing/BattleTemplate/Showdown/ShowdownSet.cs index 6154fd06d..923b0acca 100644 --- a/PKHeX.Core/Editing/BattleTemplate/Showdown/ShowdownSet.cs +++ b/PKHeX.Core/Editing/BattleTemplate/Showdown/ShowdownSet.cs @@ -686,7 +686,7 @@ private static string GetAbilityHeldItem(GameStrings strings, int ability, int i } } if (count == 0) - return ""; + return string.Empty; var result = new StringBuilder(); int ctr = 0; diff --git a/PKHeX.Core/Editing/BattleTemplate/StatDisplayConfig.cs b/PKHeX.Core/Editing/BattleTemplate/StatDisplayConfig.cs index a8b5b6f7f..631434229 100644 --- a/PKHeX.Core/Editing/BattleTemplate/StatDisplayConfig.cs +++ b/PKHeX.Core/Editing/BattleTemplate/StatDisplayConfig.cs @@ -33,7 +33,7 @@ public sealed class StatDisplayConfig { Names = [], Separator = "/", - ValueGap = "", + ValueGap = string.Empty, AlwaysShow = true, }; @@ -47,7 +47,7 @@ public sealed class StatDisplayConfig { Names = [], Separator = "/", - ValueGap = "", + ValueGap = string.Empty, AlwaysShow = true, MinimumDigits = 2, }; diff --git a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff.cs b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff.cs index 8821af264..15aaed3b5 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff.cs @@ -97,14 +97,14 @@ public IReadOnlyList Summarize() if (SetFlags.Count == 0) list.Add("None."); - list.Add(""); + list.Add(string.Empty); list.Add("Flags: OFF"); list.Add("=========="); list.AddRange(fOff); if (ClearedFlags.Count == 0) list.Add("None."); - list.Add(""); + list.Add(string.Empty); list.Add("Work:"); list.Add("====="); if (WorkChanged.Count == 0) diff --git a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff7b.cs b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff7b.cs index e2e9ee495..78525b84c 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff7b.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff7b.cs @@ -64,14 +64,14 @@ public IReadOnlyList Summarize() if (SetFlags.Count == 0) list.Add("None."); - list.Add(""); + list.Add(string.Empty); list.Add("Flags: OFF"); list.Add("=========="); list.AddRange(fOff); if (ClearedFlags.Count == 0) list.Add("None."); - list.Add(""); + list.Add(string.Empty); list.Add("Work:"); list.Add("====="); if (WorkChanged.Count == 0) diff --git a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff8b.cs b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff8b.cs index ed31309f4..577cb7da5 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff8b.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff8b.cs @@ -69,7 +69,7 @@ public IReadOnlyList Summarize() if (SetFlags.Count == 0) list.Add("None."); - list.Add(""); + list.Add(string.Empty); list.Add("Flags: OFF"); list.Add("=========="); list.AddRange(fOff); @@ -82,14 +82,14 @@ public IReadOnlyList Summarize() if (SetFlags.Count == 0) list.Add("None."); - list.Add(""); + list.Add(string.Empty); list.Add("System: OFF"); list.Add("=========="); list.AddRange(sOff); if (ClearedSystem.Count == 0) list.Add("None."); - list.Add(""); + list.Add(string.Empty); list.Add("Work:"); list.Add("====="); if (WorkChanged.Count == 0) diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3Colo.cs b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3Colo.cs index 5abd8711d..76b81924d 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3Colo.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3Colo.cs @@ -16,7 +16,9 @@ internal static class Encounters3Colo /// /// When transferring from Gen3->Gen4, a Spanish OT:Duking has the Á char changed to い. /// - /// cref=""/> + /// + /// + /// internal const string TrainerNameDukingSpanish4 = "GERMいN"; internal static readonly EncounterGift3Colo[] Gifts = diff --git a/PKHeX.Core/Legality/Encounters/Data/Live/EncountersGO.cs b/PKHeX.Core/Legality/Encounters/Data/Live/EncountersGO.cs index eb9229bd4..bab606286 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Live/EncountersGO.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Live/EncountersGO.cs @@ -36,7 +36,7 @@ public static void Reload() private static BinLinkerAccessor Get([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan ident) { - var exePath = Path.GetDirectoryName(Environment.ProcessPath) ?? ""; + var exePath = Path.GetDirectoryName(Environment.ProcessPath) ?? string.Empty; var file = $"encounter_{resource}.pkl"; var fullPath = Path.Combine(exePath, file); var data = File.Exists(fullPath) ? File.ReadAllBytes(fullPath) : Util.GetBinaryResource(file); diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs index 7ed2d8074..f2433074a 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs @@ -51,7 +51,7 @@ public sealed record EncounterTrade4RanchGift : IEncounterable, IEncounterMatch, 4 => "GIULIA", 5 => "EUKALIA", 7 => "Eulalia", - _ => "", + _ => string.Empty, }; private const string _name = "My Pokémon Ranch - Trade"; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterEgg8b.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterEgg8b.cs index b03039801..9f37ac9f8 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterEgg8b.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterEgg8b.cs @@ -138,10 +138,9 @@ private void SetPINGA(PB8 pk, in EncounterCriteria criteria, PersonalInfo8BDSP p else if (isRandomGender) { var rand = rng.NextUInt(252) + 1; - var randGender = rand < ratio ? (byte)1 : (byte)0; - if (criteria.IsSpecifiedGender() && !criteria.IsSatisfiedGender(randGender)) + gender = rand < ratio ? (byte)1 : (byte)0; + if (criteria.IsSpecifiedGender() && !criteria.IsSatisfiedGender(gender)) continue; - gender = randGender; } // nature diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerARDS.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerARDS.cs index 17c68d09b..2747b60d4 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerARDS.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerARDS.cs @@ -17,7 +17,7 @@ public SaveHandlerSplitResult TrySplit(ReadOnlySpan input) // No authentication to see if it actually is a header; no size collisions expected. var header = input[..sizeHeader].ToArray(); var data = input[sizeHeader..].ToArray(); - return new SaveHandlerSplitResult(data, header, [], this); + return new SaveHandlerSplitResult(data, header, default, this); } public void Finalize(Span data) { } diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerDeSmuME.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerDeSmuME.cs index 445511136..7f458d7ca 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerDeSmuME.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerDeSmuME.cs @@ -23,7 +23,7 @@ public sealed class SaveHandlerDeSmuME : ISaveHandler var footer = input[RealSize..].ToArray(); var data = input[..RealSize].ToArray(); - return new SaveHandlerSplitResult(data, [], footer, this); + return new SaveHandlerSplitResult(data, default, footer, this); } public void Finalize(Span data) { } diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerFooterRTC.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerFooterRTC.cs index f9fa75efb..0231c23bd 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerFooterRTC.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerFooterRTC.cs @@ -37,7 +37,7 @@ public SaveHandlerSplitResult TrySplit(ReadOnlySpan input) var footer = input[RealSize..].ToArray(); var data = input[..RealSize].ToArray(); - return new SaveHandlerSplitResult(data, [], footer, this); + return new SaveHandlerSplitResult(data, default, footer, this); } public void Finalize(Span data) { } diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerGCI.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerGCI.cs index bce53cdca..044b74092 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerGCI.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerGCI.cs @@ -55,7 +55,7 @@ private static bool IsGameMatchHeader(ReadOnlySpan data, ReadOnlySpan data) { } diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerNSO.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerNSO.cs index fc8943fae..f37709c06 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerNSO.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerNSO.cs @@ -25,7 +25,7 @@ public sealed class SaveHandlerNSO : ISaveHandler var obj = new UnpackedHeaderNSOReadOnly(input); var header = input[..obj.Length]; var data = input[obj.Length..]; - return new SaveHandlerSplitResult([..data], [..header], [], this); + return new SaveHandlerSplitResult([..data], header.ToArray(), default, this); } public void Finalize(Span input) diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerSplitResult.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerSplitResult.cs index 21cd5d023..fb4d496d2 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerSplitResult.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerSplitResult.cs @@ -1,3 +1,5 @@ +using System; + namespace PKHeX.Core; /// @@ -9,10 +11,10 @@ namespace PKHeX.Core; /// The header segment of the save operation, which may contain metadata or other relevant information. /// The footer segment of the save operation, which may contain additional metadata or checksums. /// The save handler responsible for processing the save operation, providing methods for recognition and finalization. -public sealed class SaveHandlerSplitResult(byte[] Data, byte[] Header, byte[] Footer, ISaveHandler Handler) +public sealed class SaveHandlerSplitResult(byte[] Data, Memory Header, Memory Footer, ISaveHandler Handler) { - public readonly byte[] Header = Header; - public readonly byte[] Footer = Footer; + public readonly Memory Header = Header; + public readonly Memory Footer = Footer; public readonly byte[] Data = Data; public readonly ISaveHandler Handler = Handler; } diff --git a/PKHeX.WinForms/Controls/PKM Editor/GenderToggle.cs b/PKHeX.WinForms/Controls/PKM Editor/GenderToggle.cs index 0913c76f7..f19f6c863 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/GenderToggle.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/GenderToggle.cs @@ -33,7 +33,7 @@ protected override void OnEnter(EventArgs e) Invalidate(); base.OnEnter(e); AccessibilityObject.RaiseAutomationNotification(AutomationNotificationKind.Other, - AutomationNotificationProcessing.All, AccessibleDescription ?? AccessibleName ?? ""); + AutomationNotificationProcessing.All, AccessibleDescription ?? AccessibleName ?? string.Empty); } protected override void OnLeave(EventArgs e) diff --git a/PKHeX.WinForms/Controls/PKM Editor/SelectablePictureBox.cs b/PKHeX.WinForms/Controls/PKM Editor/SelectablePictureBox.cs index 3c12a1212..7c92ceb8c 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/SelectablePictureBox.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/SelectablePictureBox.cs @@ -24,7 +24,7 @@ protected override void OnEnter(EventArgs e) Invalidate(); base.OnEnter(e); AccessibilityObject.RaiseAutomationNotification(AutomationNotificationKind.Other, - AutomationNotificationProcessing.All, AccessibleDescription ?? AccessibleName ?? ""); + AutomationNotificationProcessing.All, AccessibleDescription ?? AccessibleName ?? string.Empty); } protected override void OnLeave(EventArgs e) { diff --git a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs index 81def0987..f9475b706 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs @@ -511,7 +511,7 @@ public string UpdateNatureModification(Nature nature) var decr = L_Stats[dn + 1]; incr.ForeColor = StatIncreased; decr.ForeColor = StatDecreased; - return $"+{incr.Text} / -{decr.Text}".Replace(":", ""); + return $"+{incr.Text} / -{decr.Text}".Replace(":", string.Empty); } public void SetATKIVGender(byte gender) diff --git a/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs b/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs index 1b804dcb2..69a13b851 100644 --- a/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs +++ b/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs @@ -141,7 +141,7 @@ public static string AppendEncounterInfo(LegalityAnalysis la, string text) { var result = new List(8) { text }; if (text.Length != 0) // add a blank line between the set and the encounter info if isn't already a blank line - result.Add(""); + result.Add(string.Empty); LegalityFormatting.AddEncounterInfo(la, result); return string.Join(Environment.NewLine, result); } diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index 627b014e2..3f8e8eaa7 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -525,7 +525,7 @@ private void ClickShowdownImportPKM(object sender, EventArgs e) // Get Simulator Data var text = Clipboard.GetText(); var sets = BattleTemplateTeams.TryGetSets(text); - var set = sets.FirstOrDefault() ?? new(""); // take only first set + var set = sets.FirstOrDefault() ?? new(string.Empty); // take only first set if (set.Species == 0) { WinFormsUtil.Alert(MsgSimulatorFailClipboard); return; } diff --git a/PKHeX.WinForms/PKHeX.WinForms.csproj b/PKHeX.WinForms/PKHeX.WinForms.csproj index 8cece3445..88e20267a 100644 --- a/PKHeX.WinForms/PKHeX.WinForms.csproj +++ b/PKHeX.WinForms/PKHeX.WinForms.csproj @@ -5,6 +5,7 @@ net9.0-windows win-x64 true + true SystemAware true false diff --git a/PKHeX.WinForms/Subforms/KChart.cs b/PKHeX.WinForms/Subforms/KChart.cs index 6e0a3cb4b..d508605b9 100644 --- a/PKHeX.WinForms/Subforms/KChart.cs +++ b/PKHeX.WinForms/Subforms/KChart.cs @@ -55,7 +55,7 @@ private void PopEntry(ushort species, byte form, string name, IPersonalTable pt) int c = 0; var bst = p.GetBaseStatTotal(); - cells[c++].Value = species.ToString(pt.MaxSpeciesID > 999 ? "0000" : "000") + (form > 0 ? $"-{form:00}" : ""); + cells[c++].Value = species.ToString(pt.MaxSpeciesID > 999 ? "0000" : "000") + (form > 0 ? $"-{form:00}" : string.Empty); cells[c++].Value = SpriteUtil.GetSprite(species, form, 0, 0, 0, false, Shiny.Never, SAV.Context); cells[c++].Value = name; cells[c++].Value = GetIsNative(p, species); diff --git a/PKHeX.WinForms/Util/WinFormsTranslator.cs b/PKHeX.WinForms/Util/WinFormsTranslator.cs index 9b8d47543..d1bb21204 100644 --- a/PKHeX.WinForms/Util/WinFormsTranslator.cs +++ b/PKHeX.WinForms/Util/WinFormsTranslator.cs @@ -120,7 +120,7 @@ private static ReadOnlySpan GetTranslationFile(ReadOnlySpan lang) } var txt = (string?)Properties.Resources.ResourceManager.GetObject(file); - return txt ?? ""; + return txt ?? string.Empty; } private static IEnumerable GetTranslatableControls(Control f) diff --git a/PKHeX.WinForms/Util/WinFormsUtil.cs b/PKHeX.WinForms/Util/WinFormsUtil.cs index b397811af..c1cdf74d7 100644 --- a/PKHeX.WinForms/Util/WinFormsUtil.cs +++ b/PKHeX.WinForms/Util/WinFormsUtil.cs @@ -57,6 +57,11 @@ internal static void HorizontallyCenter(this Control child, Control parent) } } + /// + /// Searches upwards through the control hierarchy to find the first parent control of type . + /// + /// Child control to start searching from. + /// The first parent control of type , or null if none found. public static T? GetUnderlyingControl(object sender) where T : class { while (true) @@ -77,6 +82,11 @@ internal static void HorizontallyCenter(this Control child, Control parent) } } + /// + /// Checks if a window of type already exists and brings it to the front if it does. + /// + /// The parent form to center the window on. + /// true if the window exists and was brought to the front; otherwise, false. public static bool OpenWindowExists(this Form parent) where T : Form { var form = FirstFormOfType();