mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-03-21 17:48:28 -05:00
Minor tweaks
Allow dragdrop into menustrip/legal/vertical tabs to load file ZA: Retain original criteria for cleanup application of IVs Inline vertical tabs color choice Simplify some expressions
This commit is contained in:
parent
0e9d8db2b1
commit
b5c29b3de8
|
|
@ -36,6 +36,7 @@ public sealed class GameDataSource
|
|||
/// Gets a list of languages to display based on the generation.
|
||||
/// </summary>
|
||||
/// <param name="generation">Generation to get the language list for.</param>
|
||||
/// <param name="context">Entity context as a sub-generation specifier.</param>
|
||||
/// <returns>List of languages to display.</returns>
|
||||
public IReadOnlyList<ComboItem> LanguageDataSource(byte generation, EntityContext context) => generation switch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -6,11 +6,10 @@ namespace PKHeX.Core;
|
|||
/// <summary>
|
||||
/// Generation 5 Mystery Gift Template File
|
||||
/// </summary>
|
||||
public sealed class PGF : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, ILangNick,
|
||||
public sealed class PGF(Memory<byte> raw) : DataMysteryGift(raw), IRibbonSetEvent3, IRibbonSetEvent4, ILangNick,
|
||||
IContestStats, INature, IMetLevel, IRestrictVersion
|
||||
{
|
||||
public PGF() : this(new byte[Size]) { }
|
||||
public PGF(Memory<byte> raw) : base(raw) { }
|
||||
public override PGF Clone() => new(Data.ToArray());
|
||||
|
||||
public int RestrictLanguage { get; set; } // None
|
||||
|
|
|
|||
|
|
@ -8,10 +8,9 @@ namespace PKHeX.Core;
|
|||
/// <summary>
|
||||
/// Generation 4 Mystery Gift Template File (Inner Gift Data, no card data)
|
||||
/// </summary>
|
||||
public sealed class PGT : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, IRandomCorrelation
|
||||
public sealed class PGT(Memory<byte> raw) : DataMysteryGift(raw), IRibbonSetEvent3, IRibbonSetEvent4, IRandomCorrelation
|
||||
{
|
||||
public PGT() : this(new byte[Size]) { }
|
||||
public PGT(Memory<byte> raw) : base(raw) { }
|
||||
public override PGT Clone() => new(Data.ToArray());
|
||||
|
||||
public const int Size = 0x104; // 260
|
||||
|
|
|
|||
|
|
@ -10,10 +10,9 @@ namespace PKHeX.Core;
|
|||
/// A full <see cref="WB7"/> is not stored in the <see cref="SAV7b"/> structure, as it is immediately converted to <see cref="PKM"/> upon receiving from server.
|
||||
/// The save file just stores a summary of the received data for the user to look back at.
|
||||
/// </remarks>
|
||||
public sealed class WR7 : DataMysteryGift
|
||||
public sealed class WR7(Memory<byte> raw) : DataMysteryGift(raw)
|
||||
{
|
||||
public WR7() : this(new byte[Size]) { }
|
||||
public WR7(Memory<byte> raw) : base(raw) { }
|
||||
public override WR7 Clone() => new(Data.ToArray());
|
||||
|
||||
public const int Size = 0x140;
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ private static void SetAllTransparencyTo(Span<byte> data, double trans)
|
|||
public static void SetAllTransparencyTo(Span<byte> data, Color c, byte trans, int start, int end)
|
||||
{
|
||||
var arr = MemoryMarshal.Cast<byte, int>(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<byte> data, Color c, byte trans, in
|
|||
public static void BlendAllTransparencyTo(Span<byte> data, Color c, byte trans, int start, int end)
|
||||
{
|
||||
var arr = MemoryMarshal.Cast<byte, int>(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];
|
||||
|
|
|
|||
|
|
@ -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.")]
|
||||
|
|
|
|||
|
|
@ -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<TabPage>())
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<GameVersion> 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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
2
PKHeX.WinForms/Subforms/ReportGrid.Designer.cs
generated
2
PKHeX.WinForms/Subforms/ReportGrid.Designer.cs
generated
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user