diff --git a/PKHeX.Core/Game/GameStrings/GameDataSource.cs b/PKHeX.Core/Game/GameStrings/GameDataSource.cs
index 927f8526c..6ceb9a85f 100644
--- a/PKHeX.Core/Game/GameStrings/GameDataSource.cs
+++ b/PKHeX.Core/Game/GameStrings/GameDataSource.cs
@@ -36,6 +36,7 @@ public sealed class GameDataSource
/// Gets a list of languages to display based on the generation.
///
/// Generation to get the language list for.
+ /// Entity context as a sub-generation specifier.
/// List of languages to display.
public IReadOnlyList LanguageDataSource(byte generation, EntityContext context) => generation switch
{
diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterGift9a.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterGift9a.cs
index f018e984c..f7937b36d 100644
--- a/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterGift9a.cs
+++ b/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterGift9a.cs
@@ -85,13 +85,14 @@ public PA9 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria)
private void SetPINGA(PA9 pk, EncounterCriteria criteria, PersonalInfo9ZA pi)
{
+ var generate = criteria;
if (IVs.IsSpecified || Correlation is LumioseCorrelation.ReApplyIVs)
- criteria = criteria.WithoutIVs();
+ generate = criteria.WithoutIVs();
var param = GetParams(pi);
ulong init = Util.Rand.Rand64();
- var success = this.TryApply64(pk, init, param, criteria);
- if (!success && !this.TryApply64(pk, init, param, criteria.WithoutIVs()))
+ var success = this.TryApply64(pk, init, param, generate);
+ if (!success && !this.TryApply64(pk, init, param, generate.WithoutIVs()))
this.TryApply64(pk, init, param, EncounterCriteria.Unrestricted);
if (IVs.IsSpecified)
diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterSlot9a.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterSlot9a.cs
index d1c395f31..4af3241ac 100644
--- a/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterSlot9a.cs
+++ b/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterSlot9a.cs
@@ -65,19 +65,11 @@ public PA9 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria)
private void SetPINGA(PA9 pk, EncounterCriteria criteria, PersonalInfo9ZA pi)
{
- if (Correlation is LumioseCorrelation.ReApplyIVs)
- criteria = criteria.WithoutIVs();
-
- var param = GetParams(pi);
- if (criteria.Shiny.IsShiny())
- param = param with { RollCount = 1 + 3 }; // Give the +3 for Shiny Charm so that the generator search is more likely to succeed.
+ var param = GetParams(pi, criteria.Shiny.IsShiny());
ulong init = Util.Rand.Rand64();
var success = this.TryApply64(pk, init, param, criteria);
if (!success && !this.TryApply64(pk, init, param, criteria.WithoutIVs()))
this.TryApply64(pk, init, param, EncounterCriteria.Unrestricted);
-
- if (Correlation is LumioseCorrelation.ReApplyIVs)
- criteria.SetRandomIVs(pk, FlawlessIVCount);
}
private void SetMoves(PA9 pk, PersonalInfo9ZA pi, byte level)
@@ -103,7 +95,7 @@ private void SetMoves(PA9 pk, PersonalInfo9ZA pi, byte level)
public bool IsMatchExact(PKM pk, EvoCriteria evo)
{
- if (Form != evo.Form && !IsRandomUnspecificForm && !IsValidOutOfBoundsForm(pk))
+ if (Form != evo.Form && !IsRandomUnspecificForm && !IsValidOutOfBoundsForm())
return false;
if (!this.IsLevelWithinRange(pk.MetLevel))
return false;
@@ -112,7 +104,7 @@ public bool IsMatchExact(PKM pk, EvoCriteria evo)
return true;
}
- private bool IsValidOutOfBoundsForm(PKM pk) => Species switch
+ private bool IsValidOutOfBoundsForm() => Species switch
{
(int)Core.Species.Furfrou => true, // Can change forms in-game.
_ => false,
@@ -136,20 +128,28 @@ public EncounterMatchRating GetMatchRating(PKM pk)
public SeedCorrelationResult TryGetSeed(PKM pk, out ulong seed)
{
- if (GetParams(PersonalTable.ZA[Species, Form]).TryGetSeed(pk, out seed))
+ var param = GetParams(PersonalTable.ZA[Species, Form], false);
+ if (param.TryGetSeed(pk, out seed))
return SeedCorrelationResult.Success;
- if (pk.IsShiny && !LumioseSolver.SearchShiny1)
- return SeedCorrelationResult.Ignore;
- if (!LumioseSolver.SearchShinyN)
+ if (pk.IsShiny && !LumioseSolver.SearchShiny1 || !LumioseSolver.SearchShinyN)
return SeedCorrelationResult.Ignore;
+
+ param = param with { RollCount = 1 + ShinyCharm };
+ if (param.TryGetSeed(pk, out seed))
+ return SeedCorrelationResult.Success;
return SeedCorrelationResult.Invalid;
}
public LumioseCorrelation Correlation => IsAlpha ? LumioseCorrelation.PreApplyIVs : LumioseCorrelation.Normal;
- public GenerateParam9a GetParams(PersonalInfo9ZA pi)
+ private const byte ShinyCharm = 3;
+
+ public GenerateParam9a GetParams(PersonalInfo9ZA pi) => GetParams(pi, shinyCharm: false);
+
+ public GenerateParam9a GetParams(PersonalInfo9ZA pi, bool shinyCharm)
{
- const byte rollCount = 1;
+ // Give the +3 for Shiny Charm so that the generator search is more likely to succeed.
+ var rollCount = (byte)(1 + (shinyCharm ? ShinyCharm : 0));
var scaleValue = IsAlpha ? (byte)255 : (byte)0;
var scaleType = IsAlpha ? SizeType9.VALUE : SizeType9.RANDOM;
var gender = Gender switch
diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterStatic9a.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterStatic9a.cs
index ff7a14ab3..69c05f4ce 100644
--- a/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterStatic9a.cs
+++ b/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterStatic9a.cs
@@ -78,13 +78,14 @@ public PA9 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria)
private void SetPINGA(PA9 pk, EncounterCriteria criteria, PersonalInfo9ZA pi)
{
+ var generate = criteria;
if (IVs.IsSpecified || Correlation is LumioseCorrelation.ReApplyIVs)
- criteria = criteria.WithoutIVs();
+ generate = criteria.WithoutIVs();
var param = GetParams(pi);
ulong init = Util.Rand.Rand64();
- var success = this.TryApply64(pk, init, param, criteria);
- if (!success && !this.TryApply64(pk, init, param, criteria.WithoutIVs()))
+ var success = this.TryApply64(pk, init, param, generate);
+ if (!success && !this.TryApply64(pk, init, param, generate.WithoutIVs()))
this.TryApply64(pk, init, param, EncounterCriteria.Unrestricted);
if (IVs.IsSpecified)
diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterTrade9a.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterTrade9a.cs
index e60f2d428..ded28986b 100644
--- a/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterTrade9a.cs
+++ b/PKHeX.Core/Legality/Encounters/Templates/Gen9a/EncounterTrade9a.cs
@@ -108,13 +108,14 @@ public PA9 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria)
private void SetPINGA(PA9 pk, EncounterCriteria criteria, PersonalInfo9ZA pi)
{
+ var generate = criteria;
if (IVs.IsSpecified || Correlation is LumioseCorrelation.ReApplyIVs)
- criteria = criteria.WithoutIVs();
+ generate = criteria.WithoutIVs();
var param = GetParams(pi);
ulong init = Util.Rand.Rand64();
- var success = this.TryApply64(pk, init, param, criteria);
- if (!success && !this.TryApply64(pk, init, param, criteria.WithoutIVs()))
+ var success = this.TryApply64(pk, init, param, generate);
+ if (!success && !this.TryApply64(pk, init, param, generate.WithoutIVs()))
this.TryApply64(pk, init, param, EncounterCriteria.Unrestricted);
if (IVs.IsSpecified)
diff --git a/PKHeX.Core/MysteryGifts/PGF.cs b/PKHeX.Core/MysteryGifts/PGF.cs
index 7d0b5d51c..b2d753ec6 100644
--- a/PKHeX.Core/MysteryGifts/PGF.cs
+++ b/PKHeX.Core/MysteryGifts/PGF.cs
@@ -6,11 +6,10 @@ namespace PKHeX.Core;
///
/// Generation 5 Mystery Gift Template File
///
-public sealed class PGF : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, ILangNick,
+public sealed class PGF(Memory raw) : DataMysteryGift(raw), IRibbonSetEvent3, IRibbonSetEvent4, ILangNick,
IContestStats, INature, IMetLevel, IRestrictVersion
{
public PGF() : this(new byte[Size]) { }
- public PGF(Memory raw) : base(raw) { }
public override PGF Clone() => new(Data.ToArray());
public int RestrictLanguage { get; set; } // None
diff --git a/PKHeX.Core/MysteryGifts/PGT.cs b/PKHeX.Core/MysteryGifts/PGT.cs
index e75b725cb..d8515cfcb 100644
--- a/PKHeX.Core/MysteryGifts/PGT.cs
+++ b/PKHeX.Core/MysteryGifts/PGT.cs
@@ -8,10 +8,9 @@ namespace PKHeX.Core;
///
/// Generation 4 Mystery Gift Template File (Inner Gift Data, no card data)
///
-public sealed class PGT : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, IRandomCorrelation
+public sealed class PGT(Memory raw) : DataMysteryGift(raw), IRibbonSetEvent3, IRibbonSetEvent4, IRandomCorrelation
{
public PGT() : this(new byte[Size]) { }
- public PGT(Memory raw) : base(raw) { }
public override PGT Clone() => new(Data.ToArray());
public const int Size = 0x104; // 260
diff --git a/PKHeX.Core/MysteryGifts/WR7.cs b/PKHeX.Core/MysteryGifts/WR7.cs
index 257802676..2dbd30fc7 100644
--- a/PKHeX.Core/MysteryGifts/WR7.cs
+++ b/PKHeX.Core/MysteryGifts/WR7.cs
@@ -10,10 +10,9 @@ namespace PKHeX.Core;
/// A full is not stored in the structure, as it is immediately converted to upon receiving from server.
/// The save file just stores a summary of the received data for the user to look back at.
///
-public sealed class WR7 : DataMysteryGift
+public sealed class WR7(Memory raw) : DataMysteryGift(raw)
{
public WR7() : this(new byte[Size]) { }
- public WR7(Memory raw) : base(raw) { }
public override WR7 Clone() => new(Data.ToArray());
public const int Size = 0x140;
diff --git a/PKHeX.Drawing/ImageUtil.cs b/PKHeX.Drawing/ImageUtil.cs
index b7f8cf003..92c7d3b79 100644
--- a/PKHeX.Drawing/ImageUtil.cs
+++ b/PKHeX.Drawing/ImageUtil.cs
@@ -144,7 +144,7 @@ private static void SetAllTransparencyTo(Span data, double trans)
public static void SetAllTransparencyTo(Span data, Color c, byte trans, int start, int end)
{
var arr = MemoryMarshal.Cast(data);
- var value = Color.FromArgb(trans, c.R, c.G, c.B).ToArgb();
+ var value = Color.FromArgb(trans, c).ToArgb();
for (int i = end; i >= start; i -= 4)
{
if (data[i + 3] == 0)
@@ -155,7 +155,7 @@ public static void SetAllTransparencyTo(Span data, Color c, byte trans, in
public static void BlendAllTransparencyTo(Span data, Color c, byte trans, int start, int end)
{
var arr = MemoryMarshal.Cast(data);
- var value = Color.FromArgb(trans, c.R, c.G, c.B).ToArgb();
+ var value = Color.FromArgb(trans, c).ToArgb();
for (int i = end; i >= start; i -= 4)
{
var alpha = data[i + 3];
diff --git a/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs b/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs
index f95955534..7dee87c28 100644
--- a/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs
+++ b/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs
@@ -22,12 +22,6 @@ public sealed class DrawConfig : IDisposable
[Category(Hovering), LocalizedDescription("Hovering over a PKM color 2.")]
public Color GlowFinal => SystemColors.Highlight;
- [Category(PKM), LocalizedDescription("Vertical tab selected primary color.")]
- public Color VerticalSelectPrimary => SystemColors.ControlLightLight;
-
- [Category(PKM), LocalizedDescription("Vertical tab selected secondary color.")]
- public Color VerticalSelectSecondary => SystemColors.ScrollBar;
-
#region PKM
[Category(PKM), LocalizedDescription("Background color of a ComboBox when the selected item is not valid.")]
diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs
index ad4609cfd..01dbeb555 100644
--- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs
+++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs
@@ -1953,7 +1953,7 @@ private void B_PlusRecord_Click(object sender, EventArgs e)
if (ModifierKeys.HasFlag(Keys.Shift))
{
m.SetPlusFlags(Entity, p, PlusRecordApplicatorOption.LegalCurrent);
- if (Entity is PA9 { IsAlpha: true } pa9 && pa9.PersonalInfo is PersonalInfo9ZA pi)
+ if (Entity is PA9 { IsAlpha: true, PersonalInfo: { } pi } pa9)
PlusRecordApplicator.SetPlusFlagsSpecific(pa9, pi, pi.AlphaMove);
UpdateLegality();
@@ -2133,13 +2133,18 @@ private void CenterSubEditors()
public void EnableDragDrop(DragEventHandler enter, DragEventHandler drop)
{
- AllowDrop = true;
- DragDrop += drop;
+ Enable(this);
+ Enable(TC_Editor);
+
foreach (var tab in Hidden_TC.TabPages.OfType())
+ Enable(tab);
+ return;
+
+ void Enable(Control c)
{
- tab.AllowDrop = true;
- tab.DragEnter += enter;
- tab.DragDrop += drop;
+ c.AllowDrop = true;
+ c.DragEnter += enter;
+ c.DragDrop += drop;
}
}
diff --git a/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs b/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs
index 7bc0f4ead..85f5e8c7e 100644
--- a/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs
+++ b/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs
@@ -78,8 +78,7 @@ protected override void OnDrawItem(DrawItemEventArgs e)
var graphics = e.Graphics;
if (e.State == DrawItemState.Selected)
{
- var settings = Main.Settings.Draw;
- var (c1, c2) = (settings.VerticalSelectPrimary, settings.VerticalSelectSecondary);
+ var (c1, c2) = (SystemColors.ControlLightLight, SystemColors.ScrollBar);
using var brush = new LinearGradientBrush(bounds, c1, c2, 90f);
graphics.FillRectangle(brush, bounds);
diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs
index 81d12b47e..238a08aec 100644
--- a/PKHeX.WinForms/MainWindow/Main.cs
+++ b/PKHeX.WinForms/MainWindow/Main.cs
@@ -88,6 +88,12 @@ private void FormLoadAddEvents()
GiveFeedback += (_, e) => e.UseDefaultCursors = false;
PKME_Tabs.EnableDragDrop(Main_DragEnter, Main_DragDrop);
C_SAV.EnableDragDrop(Main_DragEnter, Main_DragDrop);
+ menuStrip1.AllowDrop = true;
+ menuStrip1.DragEnter += Main_DragEnter;
+ menuStrip1.DragDrop += Main_DragDrop;
+ PB_Legal.AllowDrop = true;
+ PB_Legal.DragEnter += Main_DragEnter;
+ PB_Legal.DragDrop += Main_DragDrop;
// ToolTips for Drag&Drop
toolTip.SetToolTip(dragout, "Drag to Save");
@@ -515,8 +521,8 @@ private void OpenFromPath(string path)
#if DEBUG
OpenFile(input, path, ext);
#else
- try { OpenFile(input, path, ext); }
- catch (Exception e) { WinFormsUtil.Error(MsgFileLoadFail + "\nPath: " + path, e); }
+ try { OpenFile(input, path, ext); }
+ catch (Exception e) { WinFormsUtil.Error(MsgFileLoadFail + "\nPath: " + path, e); }
#endif
}
@@ -591,10 +597,10 @@ private bool OpenPKM(PKM pk)
private bool OpenGroup(IPokeGroup b)
{
- bool result = C_SAV.OpenGroup(b, out string c);
- if (!string.IsNullOrWhiteSpace(c))
- WinFormsUtil.Alert(c);
- Debug.WriteLine(c);
+ bool result = C_SAV.OpenGroup(b, out var msg);
+ if (!string.IsNullOrWhiteSpace(msg))
+ WinFormsUtil.Alert(msg);
+ Debug.WriteLine(msg);
return result;
}
@@ -627,13 +633,13 @@ private bool OpenPCBoxBin(ConcatenatedEntitySet pkms)
if (C_SAV.IsBoxDragActive)
return true;
Cursor = Cursors.Default;
- if (!C_SAV.OpenPCBoxBin(pkms.Data.Span, out string c))
+ if (!C_SAV.OpenPCBoxBin(pkms.Data.Span, out var msg))
{
- WinFormsUtil.Alert(MsgFileLoadIncompatible, c);
+ WinFormsUtil.Alert(MsgFileLoadIncompatible, msg);
return true;
}
- WinFormsUtil.Alert(c);
+ WinFormsUtil.Alert(msg);
return true;
}
@@ -885,6 +891,7 @@ private static bool SanityCheckSAV(ref SaveFile sav)
var s = s3.ForceLoad(game);
if (s is SAV3FRLG frlg)
{
+ // Try to give the correct Deoxys form stats (different in R/S, E, FR and LG)
bool result = frlg.ResetPersonal(game);
if (!result)
return false;
@@ -924,14 +931,15 @@ static ComboItem[] GetGameList(ReadOnlySpan g)
}
}
- public static void SetCountrySubRegion(ComboBox CB, string type)
+ public static void SetCountrySubRegion(ComboBox cb, string type)
{
- int index = CB.SelectedIndex;
+ // Try to retain previous selection index. If triggered by language change, the list will be reloaded.
+ int index = cb.SelectedIndex;
string cl = GameInfo.CurrentLanguage;
- CB.DataSource = Util.GetCountryRegionList(type, cl);
+ cb.DataSource = Util.GetCountryRegionList(type, cl);
- if (index > 0 && index < CB.Items.Count)
- CB.SelectedIndex = index;
+ if (index > 0 && index < cb.Items.Count)
+ cb.SelectedIndex = index;
}
// Language Translation
diff --git a/PKHeX.WinForms/Subforms/PKM Editors/PlusRecordEditor.cs b/PKHeX.WinForms/Subforms/PKM Editors/PlusRecordEditor.cs
index 5a1f58ba9..e4620c1ba 100644
--- a/PKHeX.WinForms/Subforms/PKM Editors/PlusRecordEditor.cs
+++ b/PKHeX.WinForms/Subforms/PKM Editors/PlusRecordEditor.cs
@@ -129,7 +129,7 @@ private void B_All_Click(object sender, EventArgs e)
Plus.SetPlusFlags(Entity, Permit, option);
if (option != PlusRecordApplicatorOption.None)
{
- if (Entity is PA9 { IsAlpha: true } pa9 && pa9.PersonalInfo is PersonalInfo9ZA pi)
+ if (Entity is PA9 { IsAlpha: true, PersonalInfo: { } pi } pa9)
PlusRecordApplicator.SetPlusFlagsSpecific(pa9, pi, pi.AlphaMove);
}
Close();
diff --git a/PKHeX.WinForms/Subforms/ReportGrid.Designer.cs b/PKHeX.WinForms/Subforms/ReportGrid.Designer.cs
index 00b27fa2e..e2fc8175a 100644
--- a/PKHeX.WinForms/Subforms/ReportGrid.Designer.cs
+++ b/PKHeX.WinForms/Subforms/ReportGrid.Designer.cs
@@ -37,7 +37,7 @@ private void InitializeComponent()
//
dgData.AllowUserToAddRows = false;
dgData.AllowUserToDeleteRows = false;
- dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.ControlLight;
dgData.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
dgData.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
dgData.Dock = System.Windows.Forms.DockStyle.Fill;
diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Pokedex9a.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Pokedex9a.cs
index 0f7703c62..3646a2b98 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Pokedex9a.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/Gen9/SAV_Pokedex9a.cs
@@ -71,7 +71,7 @@ public SAV_Pokedex9a(SAV9ZA sav)
private record DexMap
{
public ushort Species { get; }
- public bool IsInAnyDex => Dex != default;
+ public bool IsInAnyDex => Dex != 0;
public ushort Dex { get; }
public string Name { get; }
public int ListIndex { get; set; }