Minor clean

no functional change
This commit is contained in:
Kurt 2021-12-04 17:56:56 -08:00
parent 9a1b2719ec
commit f55c5bea66
30 changed files with 288 additions and 332 deletions

View file

@ -47,11 +47,13 @@ namespace PKHeX.Core
private int Compare(ComboItem i1, ComboItem i2)
{
// split into 2 groups: Allowed & Not, and sort each sublist
var c1 = AllowedMoves.Contains(i1.Value);
var c2 = AllowedMoves.Contains(i2.Value);
var (strA, value1) = i1;
var (strB, value2) = i2;
var c1 = AllowedMoves.Contains(value1);
var c2 = AllowedMoves.Contains(value2);
if (c1)
return c2 ? string.CompareOrdinal(i1.Text, i2.Text) : -1;
return c2 ? 1 : string.CompareOrdinal(i1.Text, i2.Text);
return c2 ? string.CompareOrdinal(strA, strB) : -1;
return c2 ? 1 : string.CompareOrdinal(strA, strB);
}
public void ReloadMoves(IReadOnlyList<ComboItem> moves)

View file

@ -74,15 +74,12 @@ namespace PKHeX.Core
Entity = pk;
}
private static SaveFile? ReadSettingsDefinedPKM(IStartupSettings startup, PKM pkm)
private static SaveFile? ReadSettingsDefinedPKM(IStartupSettings startup, PKM pkm) => startup.AutoLoadSaveOnStartup switch
{
var opt = startup.AutoLoadSaveOnStartup;
if (opt is AutoLoadSetting.LastLoaded)
return GetMostRecentlyLoaded(startup.RecentlyLoaded).FirstOrDefault(z => z.IsCompatiblePKM(pkm));
if (opt is AutoLoadSetting.RecentBackup)
return SaveFinder.DetectSaveFiles().FirstOrDefault(z => z.IsCompatiblePKM(pkm));
return null;
}
AutoLoadSetting.RecentBackup => SaveFinder.DetectSaveFiles().FirstOrDefault(z => z.IsCompatiblePKM(pkm)),
AutoLoadSetting.LastLoaded => GetMostRecentlyLoaded(startup.RecentlyLoaded).FirstOrDefault(z => z.IsCompatiblePKM(pkm)),
_ => null,
};
private static SaveFile? ReadSettingsAnyPKM(IStartupSettings startup) => startup.AutoLoadSaveOnStartup switch
{

View file

@ -107,17 +107,20 @@ namespace PKHeX.Core
// Handle edge case with fixed-gender forms.
if (Species is (int) Meowstic or (int) Indeedee)
ReviseGenderedForms();
}
private void ReviseGenderedForms()
{
if (Gender == 1) // Recognized with (F)
{
if (Gender == 1) // Recognized with (F)
{
FormName = "F";
Form = 1;
}
else
{
FormName = Form == 1 ? "F" : "M";
Gender = Form;
}
FormName = "F";
Form = 1;
}
else
{
FormName = Form == 1 ? "F" : "M";
Gender = Form;
}
}

View file

@ -6,15 +6,12 @@ namespace PKHeX.Core
/// <summary>
/// Represents an Area where <see cref="PKM"/> can be encountered, which contains a Location ID and <see cref="EncounterSlot"/> data.
/// </summary>
public abstract record EncounterArea : IVersion
public abstract record EncounterArea(GameVersion Version) : IVersion
{
public GameVersion Version { get; }
public int Location { get; protected init; }
public SlotType Type { get; protected init; } = SlotType.Any;
protected abstract IReadOnlyList<EncounterSlot> Raw { get; }
protected EncounterArea(GameVersion game) => Version = game;
/// <summary>
/// Gets the slots contained in the area that match the provided data.
/// </summary>

View file

@ -336,7 +336,7 @@ namespace PKHeX.Core
Location = 214,
Moves = new[] { 344, 270, 207, 220 },
GroundTile = Max_Pt,
Shiny = Shiny.Never
Shiny = Shiny.Never,
},
// Stationary Legendary

View file

@ -536,7 +536,7 @@ namespace PKHeX.Core
new(0xFF01007F) { Species = 595, Level = 28, Location = 037, Ability = 2, Nature = Nature.Docile }, // Joltik @ Chargestone Cave
new(0xFF00007F) { Species = 597, Level = 28, Location = 037, Ability = 1, Nature = Nature.Bashful }, // Ferroseed @ Chargestone Cave
new(0xFF000000) { Species = 599, Level = 28, Location = 037, Ability = 1, Nature = Nature.Rash }, // Klink @ Chargestone Cave
new(0xFF00001F) { Species = 570, Level = 25, Location = 010, Ability = 1, Nature = Nature.Hasty, Gift = true } // N's Zorua @ Driftveil City
new(0xFF00001F) { Species = 570, Level = 25, Location = 010, Ability = 1, Nature = Nature.Hasty, Gift = true }, // N's Zorua @ Driftveil City
};
private static readonly EncounterStatic5[] Encounter_B2W2 = ArrayUtil.ConcatAll(Encounter_B2W2_Regular, Encounter_B2W2_N, Encounter_DreamRadar);

View file

@ -28,10 +28,7 @@ namespace PKHeX.Core
return Pressure ? LegalityCheckStrings.LEncConditionLead : LegalityCheckStrings.LEncCondition;
}
public EncounterSlot6XY CreatePressureFormCopy(int evoForm)
{
return new((EncounterArea6XY) Area, Species, evoForm, LevelMin, LevelMax) {Pressure = true};
}
public EncounterSlot6XY CreatePressureFormCopy(int evoForm) => new((EncounterArea6XY) Area, Species, evoForm, LevelMin, LevelMax) {Pressure = true};
protected override HiddenAbilityPermission IsHiddenAbilitySlot() => IsHorde ? HiddenAbilityPermission.Possible : HiddenAbilityPermission.Never;
}

View file

@ -37,20 +37,17 @@ namespace PKHeX.Core
result[ctr++] = Create(game, a, Move3);
}
private EncounterStatic5 Create(GameVersion game, int ability, int move)
private EncounterStatic5 Create(GameVersion game, int ability, int move) => new(game)
{
return new(game)
{
Species = Species,
Form = Form,
Gender = Gender,
Level = Level,
Ability = ability,
Location = 075,
Shiny = Shiny.Never,
Moves = new[] { move },
};
}
Species = Species,
Form = Form,
Gender = Gender,
Level = Level,
Ability = ability,
Location = 075,
Shiny = Shiny.Never,
Moves = new[] { move },
};
public static EncounterStatic5[] GetArray(GameVersion game, IReadOnlyList<DreamWorldEntry> t)
{

View file

@ -9,7 +9,7 @@ namespace PKHeX.Core
/// <remarks>
/// Static Encounters are fixed position encounters with properties that are not subject to Wild Encounter conditions.
/// </remarks>
public abstract record EncounterStatic : IEncounterable, IMoveset, ILocation, IEncounterMatch, IFixedBall, IFixedAbilityNumber
public abstract record EncounterStatic(GameVersion Version) : IEncounterable, IMoveset, ILocation, IEncounterMatch, IFixedBall, IFixedAbilityNumber
{
public int Species { get; init; }
public int Form { get; init; }
@ -17,7 +17,6 @@ namespace PKHeX.Core
public virtual int LevelMin => Level;
public virtual int LevelMax => Level;
public abstract int Generation { get; }
public GameVersion Version { get; }
public virtual int Location { get; init; }
public int Ability { get; init; }
@ -50,8 +49,6 @@ namespace PKHeX.Core
internal const int FormVivillon = 30;
//protected const int FormRandom = 31;
protected EncounterStatic(GameVersion game) => Version = game;
protected virtual PKM GetBlank(ITrainerInfo tr) => PKMConverter.GetBlank(Generation, Version);
public PKM ConvertToPKM(ITrainerInfo sav) => ConvertToPKM(sav, EncounterCriteria.Unrestricted);

View file

@ -10,7 +10,7 @@ namespace PKHeX.Core
/// <remarks>
/// Trade data is fixed level in all cases except for the first few generations of games.
/// </remarks>
public abstract record EncounterTrade : IEncounterable, IMoveset, ILocation, IEncounterMatch, IFixedBall, IFixedAbilityNumber
public abstract record EncounterTrade(GameVersion Version) : IEncounterable, IMoveset, ILocation, IEncounterMatch, IFixedBall, IFixedAbilityNumber
{
public int Species { get; init; }
public int Form { get; init; }
@ -19,7 +19,6 @@ namespace PKHeX.Core
public int LevelMax => 100;
public IReadOnlyList<int> Moves { get; init; } = Array.Empty<int>();
public abstract int Generation { get; }
public GameVersion Version { get; }
public int CurrentLevel { get; init; } = -1;
public abstract int Location { get; }
@ -63,8 +62,6 @@ namespace PKHeX.Core
public bool HasNickname => Nicknames.Count != 0 && IsNicknamed;
public bool HasTrainerName => TrainerNames.Count != 0;
protected EncounterTrade(GameVersion game) => Version = game;
public PKM ConvertToPKM(ITrainerInfo sav) => ConvertToPKM(sav, EncounterCriteria.Unrestricted);
public PKM ConvertToPKM(ITrainerInfo sav, EncounterCriteria criteria)

View file

@ -136,14 +136,11 @@ namespace PKHeX.Core
};
}
public EvoCriteria GetEvoCriteria(int species, int form, int lvl)
public EvoCriteria GetEvoCriteria(int species, int form, int lvl) => new(species, form)
{
return new(species, form)
{
Level = lvl,
Method = Method,
};
}
Level = lvl,
Method = Method,
};
public static int GetAmpLowKeyResult(int n)
{

View file

@ -160,7 +160,7 @@ namespace PKHeX.Core
Moves = MoveList.GetBaseEggMoves(pk, Species, Form, (GameVersion)pk.Version, Level);
if (Moves.Count != 4)
{
var moves = Moves.ToArray();
int[] moves = Moves.ToArray();
Array.Resize(ref moves, 4);
Moves = moves;
}

View file

@ -223,43 +223,40 @@ namespace PKHeX.Core
return pk7;
}
public SK2 ConvertToSK2()
public SK2 ConvertToSK2() => new(Japanese)
{
return new(Japanese)
{
Species = Species,
HeldItem = HeldItem,
Move1 = Move1,
Move2 = Move2,
Move3 = Move3,
Move4 = Move4,
TID = TID,
EXP = EXP,
EV_HP = EV_HP,
EV_ATK = EV_ATK,
EV_DEF = EV_DEF,
EV_SPE = EV_SPE,
EV_SPC = EV_SPC,
DV16 = DV16,
Move1_PP = Move1_PP,
Move2_PP = Move2_PP,
Move3_PP = Move3_PP,
Move4_PP = Move4_PP,
Move1_PPUps = Move1_PPUps,
Move2_PPUps = Move2_PPUps,
Move3_PPUps = Move3_PPUps,
Move4_PPUps = Move4_PPUps,
CurrentFriendship = CurrentFriendship,
IsEgg = IsEgg,
Stat_Level = Stat_Level,
PKRS_Days = PKRS_Days,
PKRS_Strain = PKRS_Strain,
CaughtData = CaughtData,
Species = Species,
HeldItem = HeldItem,
Move1 = Move1,
Move2 = Move2,
Move3 = Move3,
Move4 = Move4,
TID = TID,
EXP = EXP,
EV_HP = EV_HP,
EV_ATK = EV_ATK,
EV_DEF = EV_DEF,
EV_SPE = EV_SPE,
EV_SPC = EV_SPC,
DV16 = DV16,
Move1_PP = Move1_PP,
Move2_PP = Move2_PP,
Move3_PP = Move3_PP,
Move4_PP = Move4_PP,
Move1_PPUps = Move1_PPUps,
Move2_PPUps = Move2_PPUps,
Move3_PPUps = Move3_PPUps,
Move4_PPUps = Move4_PPUps,
CurrentFriendship = CurrentFriendship,
IsEgg = IsEgg,
Stat_Level = Stat_Level,
PKRS_Days = PKRS_Days,
PKRS_Strain = PKRS_Strain,
CaughtData = CaughtData,
// Only copies until first 0x50 terminator, but just copy everything
Nickname = Nickname,
OT_Name = OT_Name,
};
}
// Only copies until first 0x50 terminator, but just copy everything
Nickname = Nickname,
OT_Name = OT_Name,
};
}
}

View file

@ -147,44 +147,41 @@ namespace PKHeX.Core
public override int MaxAbilityID => Legal.MaxAbilityID_2;
public override int MaxItemID => Legal.MaxItemID_2;
public PK2 ConvertToPK2()
public PK2 ConvertToPK2() => new(Japanese)
{
return new(Japanese)
{
Species = Species,
HeldItem = HeldItem,
Move1 = Move1,
Move2 = Move2,
Move3 = Move3,
Move4 = Move4,
TID = TID,
EXP = EXP,
EV_HP = EV_HP,
EV_ATK = EV_ATK,
EV_DEF = EV_DEF,
EV_SPE = EV_SPE,
EV_SPC = EV_SPC,
DV16 = DV16,
Move1_PP = Move1_PP,
Move2_PP = Move2_PP,
Move3_PP = Move3_PP,
Move4_PP = Move4_PP,
Move1_PPUps = Move1_PPUps,
Move2_PPUps = Move2_PPUps,
Move3_PPUps = Move3_PPUps,
Move4_PPUps = Move4_PPUps,
CurrentFriendship = CurrentFriendship,
Stat_Level = Stat_Level,
IsEgg = IsEgg,
PKRS_Days = PKRS_Days,
PKRS_Strain = PKRS_Strain,
CaughtData = CaughtData,
Species = Species,
HeldItem = HeldItem,
Move1 = Move1,
Move2 = Move2,
Move3 = Move3,
Move4 = Move4,
TID = TID,
EXP = EXP,
EV_HP = EV_HP,
EV_ATK = EV_ATK,
EV_DEF = EV_DEF,
EV_SPE = EV_SPE,
EV_SPC = EV_SPC,
DV16 = DV16,
Move1_PP = Move1_PP,
Move2_PP = Move2_PP,
Move3_PP = Move3_PP,
Move4_PP = Move4_PP,
Move1_PPUps = Move1_PPUps,
Move2_PPUps = Move2_PPUps,
Move3_PPUps = Move3_PPUps,
Move4_PPUps = Move4_PPUps,
CurrentFriendship = CurrentFriendship,
Stat_Level = Stat_Level,
IsEgg = IsEgg,
PKRS_Days = PKRS_Days,
PKRS_Strain = PKRS_Strain,
CaughtData = CaughtData,
// Only copies until first 0x50 terminator, but just copy everything
Nickname = Nickname,
OT_Name = IsRental ? Japanese ? "1337" : "PKHeX" : OT_Name,
};
}
// Only copies until first 0x50 terminator, but just copy everything
Nickname = Nickname,
OT_Name = IsRental ? Japanese ? "1337" : "PKHeX" : OT_Name,
};
private static bool IsJapanese(ReadOnlySpan<byte> data)
{

View file

@ -100,89 +100,86 @@
/// </summary>
/// <typeparam name="T">Generation 3 format to convert to</typeparam>
/// <returns>New object with transferred properties.</returns>
protected T ConvertTo<T>() where T : G3PKM, new()
protected T ConvertTo<T>() where T : G3PKM, new() => new()
{
return new()
{
Species = Species,
Language = Language,
PID = PID,
TID = TID,
SID = SID,
EXP = EXP,
HeldItem = HeldItem,
AbilityBit = AbilityBit,
IsEgg = IsEgg,
FatefulEncounter = FatefulEncounter,
Species = Species,
Language = Language,
PID = PID,
TID = TID,
SID = SID,
EXP = EXP,
HeldItem = HeldItem,
AbilityBit = AbilityBit,
IsEgg = IsEgg,
FatefulEncounter = FatefulEncounter,
Met_Location = Met_Location,
Met_Level = Met_Level,
Version = Version,
Ball = Ball,
Met_Location = Met_Location,
Met_Level = Met_Level,
Version = Version,
Ball = Ball,
Nickname = Nickname,
OT_Name = OT_Name,
OT_Gender = OT_Gender,
OT_Friendship = OT_Friendship,
Nickname = Nickname,
OT_Name = OT_Name,
OT_Gender = OT_Gender,
OT_Friendship = OT_Friendship,
Move1_PPUps = Move1_PPUps,
Move2_PPUps = Move2_PPUps,
Move3_PPUps = Move3_PPUps,
Move4_PPUps = Move4_PPUps,
Move1 = Move1,
Move2 = Move2,
Move3 = Move3,
Move4 = Move4,
Move1_PP = Move1_PP,
Move2_PP = Move2_PP,
Move3_PP = Move3_PP,
Move4_PP = Move4_PP,
Move1_PPUps = Move1_PPUps,
Move2_PPUps = Move2_PPUps,
Move3_PPUps = Move3_PPUps,
Move4_PPUps = Move4_PPUps,
Move1 = Move1,
Move2 = Move2,
Move3 = Move3,
Move4 = Move4,
Move1_PP = Move1_PP,
Move2_PP = Move2_PP,
Move3_PP = Move3_PP,
Move4_PP = Move4_PP,
IV_HP = IV_HP,
IV_ATK = IV_ATK,
IV_DEF = IV_DEF,
IV_SPE = IV_SPE,
IV_SPA = IV_SPA,
IV_SPD = IV_SPD,
EV_HP = EV_HP,
EV_ATK = EV_ATK,
EV_DEF = EV_DEF,
EV_SPE = EV_SPE,
EV_SPA = EV_SPA,
EV_SPD = EV_SPD,
CNT_Cool = CNT_Cool,
CNT_Beauty = CNT_Beauty,
CNT_Cute = CNT_Cute,
CNT_Smart = CNT_Smart,
CNT_Tough = CNT_Tough,
CNT_Sheen = CNT_Sheen,
IV_HP = IV_HP,
IV_ATK = IV_ATK,
IV_DEF = IV_DEF,
IV_SPE = IV_SPE,
IV_SPA = IV_SPA,
IV_SPD = IV_SPD,
EV_HP = EV_HP,
EV_ATK = EV_ATK,
EV_DEF = EV_DEF,
EV_SPE = EV_SPE,
EV_SPA = EV_SPA,
EV_SPD = EV_SPD,
CNT_Cool = CNT_Cool,
CNT_Beauty = CNT_Beauty,
CNT_Cute = CNT_Cute,
CNT_Smart = CNT_Smart,
CNT_Tough = CNT_Tough,
CNT_Sheen = CNT_Sheen,
PKRS_Days = PKRS_Days,
PKRS_Strain = PKRS_Strain,
PKRS_Days = PKRS_Days,
PKRS_Strain = PKRS_Strain,
// Transfer Ribbons
RibbonCountG3Cool = RibbonCountG3Cool,
RibbonCountG3Beauty = RibbonCountG3Beauty,
RibbonCountG3Cute = RibbonCountG3Cute,
RibbonCountG3Smart = RibbonCountG3Smart,
RibbonCountG3Tough = RibbonCountG3Tough,
RibbonChampionG3 = RibbonChampionG3,
RibbonWinning = RibbonWinning,
RibbonVictory = RibbonVictory,
RibbonArtist = RibbonArtist,
RibbonEffort = RibbonEffort,
RibbonChampionBattle = RibbonChampionBattle,
RibbonChampionRegional = RibbonChampionRegional,
RibbonChampionNational = RibbonChampionNational,
RibbonCountry = RibbonCountry,
RibbonNational = RibbonNational,
RibbonEarth = RibbonEarth,
RibbonWorld = RibbonWorld,
Unused1 = Unused1,
Unused2 = Unused2,
Unused3 = Unused3,
Unused4 = Unused4,
};
}
// Transfer Ribbons
RibbonCountG3Cool = RibbonCountG3Cool,
RibbonCountG3Beauty = RibbonCountG3Beauty,
RibbonCountG3Cute = RibbonCountG3Cute,
RibbonCountG3Smart = RibbonCountG3Smart,
RibbonCountG3Tough = RibbonCountG3Tough,
RibbonChampionG3 = RibbonChampionG3,
RibbonWinning = RibbonWinning,
RibbonVictory = RibbonVictory,
RibbonArtist = RibbonArtist,
RibbonEffort = RibbonEffort,
RibbonChampionBattle = RibbonChampionBattle,
RibbonChampionRegional = RibbonChampionRegional,
RibbonChampionNational = RibbonChampionNational,
RibbonCountry = RibbonCountry,
RibbonNational = RibbonNational,
RibbonEarth = RibbonEarth,
RibbonWorld = RibbonWorld,
Unused1 = Unused1,
Unused2 = Unused2,
Unused3 = Unused3,
Unused4 = Unused4,
};
}
}

View file

@ -40,7 +40,7 @@ namespace PKHeX.Core
Capacity = (byte)c;
Entry_Size = GetEntrySize();
StringLength = GetStringLength(jp);
var data = d ?? GetEmptyList(c, jp);
byte[] data = d ?? GetEmptyList(c, jp);
var dataSize = 1 + 1 + (Capacity * (Entry_Size + 1 + (2 * StringLength)));
Array.Resize(ref data, dataSize);

View file

@ -112,10 +112,7 @@ namespace PKHeX.Core
/// </summary>
public static readonly PersonalTable Y = GetTable("y", GameVersion.YW);
private static PersonalTable GetTable(string game, GameVersion format)
{
return new(Util.GetBinaryResource($"personal_{game}"), format);
}
private static PersonalTable GetTable(string game, GameVersion format) => new(Util.GetBinaryResource($"personal_{game}"), format);
private static Func<byte[], PersonalInfo> GetConstructor(GameVersion format) => format switch
{

View file

@ -34,21 +34,18 @@ namespace PKHeX.Core
return Data;
}
private SecretBase3PKM GetPKM(int index)
private SecretBase3PKM GetPKM(int index) => new()
{
return new()
{
PID = BitConverter.ToUInt32(Data, GetOffsetPID(index)),
Species = BitConverter.ToUInt16(Data, GetOffsetSpecies(index)),
HeldItem = BitConverter.ToUInt16(Data, GetOffsetItem(index)),
Move1 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 0)),
Move2 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 1)),
Move3 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 2)),
Move4 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 3)),
Level = Data[O_Level + index],
EVAll = Data[O_EV + index],
};
}
PID = BitConverter.ToUInt32(Data, GetOffsetPID(index)),
Species = BitConverter.ToUInt16(Data, GetOffsetSpecies(index)),
HeldItem = BitConverter.ToUInt16(Data, GetOffsetItem(index)),
Move1 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 0)),
Move2 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 1)),
Move3 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 2)),
Move4 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 3)),
Level = Data[O_Level + index],
EVAll = Data[O_EV + index],
};
private void SetPKM(int index)
{

View file

@ -122,7 +122,7 @@ namespace PKHeX.Core
InventoryType.Balls => 999,
InventoryType.BattleItems => 999,
InventoryType.Treasure => 999,
_ => throw new ArgumentOutOfRangeException(nameof(type))
_ => throw new ArgumentOutOfRangeException(nameof(type)),
};
private static ushort[] GetLegal(InventoryType type) => type switch
@ -135,7 +135,7 @@ namespace PKHeX.Core
InventoryType.Balls => Legal.Pouch_Ball_BS,
InventoryType.BattleItems => Legal.Pouch_Battle_BS,
InventoryType.Treasure => Legal.Pouch_Treasure_BS,
_ => throw new ArgumentOutOfRangeException(nameof(type))
_ => throw new ArgumentOutOfRangeException(nameof(type)),
};
}
}

View file

@ -19,6 +19,7 @@ namespace PKHeX.Core
_ => UndergroundItemList8b.ItemMaxCount,
};
// ReSharper disable once NotAccessedPositionalProperty.Local
private record UgItemDef(int UgItemID, int ItemID, int SphereID, int PedestalID, int StatueID)
{
private bool IsSphere => SphereID > 0;

View file

@ -126,11 +126,11 @@ namespace PKHeX.Core
{
var foldersToCheck = extra.Where(f => !string.IsNullOrWhiteSpace(f)).Concat(CustomBackupPaths);
string path3DS = Path.GetPathRoot(Get3DSLocation(drives));
string? path3DS = Path.GetPathRoot(Get3DSLocation(drives));
if (!string.IsNullOrEmpty(path3DS)) // check for Homebrew/CFW backups
foldersToCheck = foldersToCheck.Concat(Get3DSBackupPaths(path3DS));
string pathNX = Path.GetPathRoot(GetSwitchLocation(drives));
string? pathNX = Path.GetPathRoot(GetSwitchLocation(drives));
if (!string.IsNullOrEmpty(pathNX)) // check for Homebrew/CFW backups
foldersToCheck = foldersToCheck.Concat(GetSwitchBackupPaths(pathNX));

View file

@ -727,7 +727,8 @@ namespace PKHeX.WinForms.Controls
UpdateLegality(skipMoveRepop: true);
if (sender == GB_CurrentMoves)
{
if (!SetSuggestedMoves(random: ModifierKeys == Keys.Control))
bool random = ModifierKeys == Keys.Control;
if (!SetSuggestedMoves(random))
return;
}
else if (sender == GB_RelearnMoves)

View file

@ -72,19 +72,16 @@ namespace PKHeX.WinForms.Controls
public void SetBackground(Image img) => BackgroundImage = img;
public static PictureBox GetControl(int width, int height)
public static PictureBox GetControl(int width, int height) => new()
{
return new()
{
AutoSize = false,
SizeMode = PictureBoxSizeMode.CenterImage,
BackColor = Color.Transparent,
Width = width + (2 * 1),
Height = height + (2 * 1),
Padding = Padding.Empty,
Margin = Padding.Empty,
BorderStyle = BorderStyle.FixedSingle,
};
}
AutoSize = false,
SizeMode = PictureBoxSizeMode.CenterImage,
BackColor = Color.Transparent,
Width = width + (2 * 1),
Height = height + (2 * 1),
Padding = Padding.Empty,
Margin = Padding.Empty,
BorderStyle = BorderStyle.FixedSingle,
};
}
}

View file

@ -21,6 +21,13 @@ namespace PKHeX.WinForms.Controls
}
public bool SameLocation => (Destination != null) && (Source?.Equals(Destination) ?? false);
public bool DragIsParty => Source?.Slot is SlotInfoParty || Destination?.Slot is SlotInfoParty;
private bool SourceIsParty => Source?.Slot is SlotInfoParty;
private bool DestinationIsParty => Destination?.Slot is SlotInfoParty;
/// <summary>
/// Used to indicate if the changes will alter the player's party data state.
/// </summary>
public bool DragIsParty => SourceIsParty || DestinationIsParty;
}
}

View file

@ -119,19 +119,16 @@ namespace PKHeX.WinForms.Controls
private const int PadPixels = 2;
private static PictureBox GetPictureBox(int index, SpriteBuilder s)
private static PictureBox GetPictureBox(int index, SpriteBuilder s) => new()
{
return new()
{
BorderStyle = BorderStyle.FixedSingle,
Width = s.Width + 2,
Height = s.Height + 2,
AllowDrop = true,
Margin = new Padding(PadPixels),
SizeMode = PictureBoxSizeMode.CenterImage,
Name = $"bpkm{index}",
};
}
BorderStyle = BorderStyle.FixedSingle,
Width = s.Width + 2,
Height = s.Height + 2,
AllowDrop = true,
Margin = new Padding(PadPixels),
SizeMode = PictureBoxSizeMode.CenterImage,
Name = $"bpkm{index}",
};
private sealed class LabelType : Label
{

View file

@ -113,15 +113,12 @@ namespace PKHeX.WinForms
button.MouseHover += (_, _) => hover.Show(path, button);
}
private static Button GetCustomButton(string name)
private static Button GetCustomButton(string name) => new()
{
return new()
{
Size = new Size { Height = ButtonHeight, Width = ButtonWidth },
Text = name,
Name = $"B_{name}",
};
}
Size = new Size { Height = ButtonHeight, Width = ButtonWidth },
Text = name,
Name = $"B_{name}",
};
private static IEnumerable<CustomFolderPath> GetUserPaths()
{

View file

@ -304,11 +304,13 @@ namespace PKHeX.WinForms
if (move3 != -1) res = res.Where(mg => mg.HasMove(move3));
if (move4 != -1) res = res.Where(mg => mg.HasMove(move4));
if (CHK_Shiny.CheckState == CheckState.Checked) res = res.Where(pk => pk.IsShiny);
else if (CHK_Shiny.CheckState == CheckState.Unchecked) res = res.Where(pk => !pk.IsShiny);
var shiny = CHK_Shiny.CheckState;
if (shiny == CheckState.Checked) res = res.Where(pk => pk.IsShiny);
else if (shiny == CheckState.Unchecked) res = res.Where(pk => !pk.IsShiny);
if (CHK_IsEgg.CheckState == CheckState.Checked) res = res.Where(pk => pk.IsEgg);
else if (CHK_IsEgg.CheckState == CheckState.Unchecked) res = res.Where(pk => !pk.IsEgg);
var egg = CHK_IsEgg.CheckState;
if (egg == CheckState.Checked) res = res.Where(pk => pk.IsEgg);
else if (egg == CheckState.Unchecked) res = res.Where(pk => !pk.IsEgg);
slotSelected = -1; // reset the slot last viewed

View file

@ -172,16 +172,13 @@ namespace PKHeX.WinForms
}
}
private static List<ComboItem> GetStates()
private static List<ComboItem> GetStates() => new()
{
return new()
{
new ComboItem("Not roamed", 0),
new ComboItem("Roaming", 1),
new ComboItem("Defeated", 2),
new ComboItem("Captured", 3),
};
}
new ComboItem("Not roamed", 0),
new ComboItem("Roaming", 1),
new ComboItem("Defeated", 2),
new ComboItem("Captured", 3),
};
private void SaveMain()
{

View file

@ -105,29 +105,26 @@ namespace PKHeX.WinForms
return dgv;
}
private static DataGridView GetBaseDataGrid(InventoryPouch pouch)
private static DataGridView GetBaseDataGrid(InventoryPouch pouch) => new()
{
return new()
{
Dock = DockStyle.Fill,
Text = pouch.Type.ToString(),
Name = "DGV_" + pouch.Type,
Dock = DockStyle.Fill,
Text = $"{pouch.Type}",
Name = $"DGV_{pouch.Type}",
AllowUserToAddRows = false,
AllowUserToDeleteRows = false,
AllowUserToResizeRows = false,
AllowUserToResizeColumns = false,
RowHeadersVisible = false,
MultiSelect = false,
ShowEditingIcon = false,
AllowUserToAddRows = false,
AllowUserToDeleteRows = false,
AllowUserToResizeRows = false,
AllowUserToResizeColumns = false,
RowHeadersVisible = false,
MultiSelect = false,
ShowEditingIcon = false,
EditMode = DataGridViewEditMode.EditOnEnter,
ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single,
ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize,
SelectionMode = DataGridViewSelectionMode.CellSelect,
CellBorderStyle = DataGridViewCellBorderStyle.None,
};
}
EditMode = DataGridViewEditMode.EditOnEnter,
ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single,
ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize,
SelectionMode = DataGridViewSelectionMode.CellSelect,
CellBorderStyle = DataGridViewCellBorderStyle.None,
};
private static DataGridViewComboBoxColumn GetItemColumn(int c, string name = "Item") => new()
{

View file

@ -586,42 +586,33 @@ namespace PKHeX.WinForms
return pb;
}
private static FlowLayoutPanel GetFlowLayoutPanel()
private static FlowLayoutPanel GetFlowLayoutPanel() => new()
{
return new()
{
Width = 480,
Height = 60,
Padding = new Padding(0),
Margin = new Padding(0),
};
}
Width = 480,
Height = 60,
Padding = new Padding(0),
Margin = new Padding(0),
};
private static Label GetLabel(string text)
private static Label GetLabel(string text) => new()
{
return new()
{
Size = new Size(40, 60),
AutoSize = false,
TextAlign = ContentAlignment.MiddleRight,
Text = text,
Padding = new Padding(0),
Margin = new Padding(0),
};
}
Size = new Size(40, 60),
AutoSize = false,
TextAlign = ContentAlignment.MiddleRight,
Text = text,
Padding = new Padding(0),
Margin = new Padding(0),
};
private static PictureBox GetPictureBox()
private static PictureBox GetPictureBox() => new()
{
return new()
{
Size = new Size(70, 58),
SizeMode = PictureBoxSizeMode.CenterImage,
BorderStyle = BorderStyle.FixedSingle,
BackColor = Color.Transparent,
Padding = new Padding(0),
Margin = new Padding(1),
};
}
Size = new Size(70, 58),
SizeMode = PictureBoxSizeMode.CenterImage,
BorderStyle = BorderStyle.FixedSingle,
BackColor = Color.Transparent,
Padding = new Padding(0),
Margin = new Padding(1),
};
private void B_ModifyAll_Click(object sender, EventArgs e)
{