mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-08 17:17:07 -05:00
Minor tweaks
== null to is null
This commit is contained in:
@@ -432,7 +432,7 @@ private static ModifyResult SetPKMProperty(StringInstruction cmd, BatchInfo info
|
||||
private static bool IsFilterMatch(StringInstruction cmd, BatchInfo info, Dictionary<string, PropertyInfo>.AlternateLookup<ReadOnlySpan<char>> props)
|
||||
{
|
||||
var match = BatchFilters.FilterMods.Find(z => z.IsMatch(cmd.PropertyName));
|
||||
if (match != null)
|
||||
if (match is not null)
|
||||
return match.IsFiltered(info, cmd);
|
||||
return IsPropertyFiltered(cmd, info.Entity, props);
|
||||
}
|
||||
@@ -447,7 +447,7 @@ private static bool IsFilterMatch(StringInstruction cmd, BatchInfo info, Diction
|
||||
private static bool IsFilterMatch(StringInstruction cmd, PKM pk, Dictionary<string, PropertyInfo>.AlternateLookup<ReadOnlySpan<char>> props)
|
||||
{
|
||||
var match = BatchFilters.FilterMods.Find(z => z.IsMatch(cmd.PropertyName));
|
||||
if (match != null)
|
||||
if (match is not null)
|
||||
return match.IsFiltered(pk, cmd);
|
||||
return IsPropertyFiltered(cmd, pk, props);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public static class BatchMods
|
||||
];
|
||||
|
||||
private static char GetOptionSuffix(ReadOnlySpan<char> str, ReadOnlySpan<char> prefix)
|
||||
=> str.Length == prefix.Length ? default : str[^1];
|
||||
=> str.Length == prefix.Length ? CommonEdits.OptionNone : str[^1];
|
||||
|
||||
private static void SetRandomTeraType(PKM pk)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ public bool TryGetProperty(PKM pk, string prop, [NotNullWhen(true)] out string?
|
||||
{
|
||||
var value = pi.GetValue(pk);
|
||||
result = value?.ToString();
|
||||
return result != null;
|
||||
return result is not null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -89,7 +89,7 @@ public static ModifyResult SetSuggestedMetData(BatchInfo info)
|
||||
{
|
||||
var pk = info.Entity;
|
||||
var encounter = EncounterSuggestion.GetSuggestedMetInfo(pk);
|
||||
if (encounter == null)
|
||||
if (encounter is null)
|
||||
return ModifyResult.Error;
|
||||
|
||||
var location = encounter.Location;
|
||||
|
||||
@@ -444,10 +444,12 @@ public static string GetLocationString(this PKM pk, bool eggmet)
|
||||
return GameInfo.GetLocationName(eggmet, location, pk.Format, pk.Generation, pk.Version);
|
||||
}
|
||||
|
||||
public const char OptionNone = '\0';
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="PKM.EncryptionConstant"/> to match the requested option.
|
||||
/// </summary>
|
||||
public static uint GetComplicatedEC(ISpeciesForm pk, char option = default)
|
||||
public static uint GetComplicatedEC(ISpeciesForm pk, char option = OptionNone)
|
||||
{
|
||||
var species = pk.Species;
|
||||
var form = pk.Form;
|
||||
@@ -455,7 +457,7 @@ public static uint GetComplicatedEC(ISpeciesForm pk, char option = default)
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GetComplicatedEC(ISpeciesForm,char)"/>
|
||||
public static uint GetComplicatedEC(ushort species, byte form, char option = default)
|
||||
public static uint GetComplicatedEC(ushort species, byte form, char option = OptionNone)
|
||||
{
|
||||
var rng = Util.Rand;
|
||||
uint rand = rng.Rand32();
|
||||
|
||||
@@ -46,7 +46,7 @@ public sealed class TrainerDatabase
|
||||
if (possible.Count == 0)
|
||||
return null;
|
||||
|
||||
if (lang != null)
|
||||
if (lang is not null)
|
||||
{
|
||||
possible = possible.Select(z =>
|
||||
{
|
||||
@@ -70,7 +70,7 @@ public sealed class TrainerDatabase
|
||||
if (possible.Count == 0)
|
||||
return null;
|
||||
|
||||
if (lang != null)
|
||||
if (lang is not null)
|
||||
{
|
||||
possible = possible.Select(z =>
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
@@ -23,7 +24,7 @@ public static class QRMessageUtil
|
||||
public static PKM? GetPKM(ReadOnlySpan<char> message, EntityContext context)
|
||||
{
|
||||
var data = DecodeMessagePKM(message);
|
||||
if (data == null)
|
||||
if (data is null)
|
||||
return null;
|
||||
return EntityFormat.GetFromBytes(data, context);
|
||||
}
|
||||
@@ -93,7 +94,7 @@ public static string GetMessageBase64(ReadOnlySpan<byte> data, string server)
|
||||
if (message.StartsWith("http", StringComparison.Ordinal)) // inject url
|
||||
return DecodeMessageDataBase64(message);
|
||||
|
||||
const int g7size = 0xE8;
|
||||
const int g7size = PokeCrypto.SIZE_6STORED; // 0xE8;
|
||||
const int g7intro = 0x30;
|
||||
if (message.StartsWith("POKE", StringComparison.Ordinal) && message.Length > g7intro + g7size) // G7 data
|
||||
return GetBytesFromMessage(message[g7intro..], g7size);
|
||||
@@ -118,9 +119,15 @@ public static string GetMessageBase64(ReadOnlySpan<byte> data, string server)
|
||||
|
||||
private static byte[] GetBytesFromMessage(ReadOnlySpan<char> input, int count)
|
||||
{
|
||||
byte[] data = new byte[count];
|
||||
for (int i = data.Length - 1; i >= 0; i--)
|
||||
data[i] = (byte)input[i];
|
||||
return data;
|
||||
byte[] result = new byte[count];
|
||||
GetBytesFromMessage(input, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void GetBytesFromMessage(ReadOnlySpan<char> input, Span<byte> output)
|
||||
{
|
||||
Debug.Assert(input.Length >= output.Length);
|
||||
for (int i = 0; i < output.Length; i++)
|
||||
output[i] = (byte)input[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public EventBlockDiff(string f1, string f2)
|
||||
return;
|
||||
var s1 = SaveUtil.GetVariantSAV(f1);
|
||||
var s2 = SaveUtil.GetVariantSAV(f2);
|
||||
if (s1 == null || s2 == null || s1.GetType() != s2.GetType() || GetBlock(s1) is not { } t1 || GetBlock(s2) is not { } t2)
|
||||
if (s1 is null || s2 is null || s1.GetType() != s2.GetType() || GetBlock(s1) is not { } t1 || GetBlock(s2) is not { } t2)
|
||||
{
|
||||
Message = DifferentGameGroup;
|
||||
return;
|
||||
|
||||
@@ -51,7 +51,7 @@ private void Diff(SAV7b s1, SAV7b s2)
|
||||
|
||||
public IReadOnlyList<string> Summarize()
|
||||
{
|
||||
if (S1 == null)
|
||||
if (S1 is null)
|
||||
return [];
|
||||
var ew = S1.Blocks.EventWork;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ private void Diff(SAV8BS s1, SAV8BS s2)
|
||||
|
||||
public IReadOnlyList<string> Summarize()
|
||||
{
|
||||
if (S1 == null)
|
||||
if (S1 is null)
|
||||
return [];
|
||||
|
||||
var fOn = SetFlags.Select(z => new FlagSummary(z).ToString());
|
||||
|
||||
@@ -57,7 +57,7 @@ public static List<EventVarGroup> GetVars(IEnumerable<string> lines, Func<int, E
|
||||
continue;
|
||||
|
||||
var group = list.Find(z => z.Type == type);
|
||||
if (group == null)
|
||||
if (group is null)
|
||||
{
|
||||
group = new EventVarGroup(type);
|
||||
list.Add(group);
|
||||
|
||||
@@ -24,7 +24,7 @@ public SavePreview(SaveFile sav, List<INamedFolderPath> paths)
|
||||
var meta = sav.Metadata;
|
||||
var dir = meta.FileFolder;
|
||||
const string notFound = "???";
|
||||
var parent = dir == null ? notFound : paths.Find(z => dir.StartsWith(z.Path, StringComparison.Ordinal))?.DisplayText ?? new DirectoryInfo(dir).Name;
|
||||
var parent = dir is null ? notFound : paths.Find(z => dir.StartsWith(z.Path, StringComparison.Ordinal))?.DisplayText ?? new DirectoryInfo(dir).Name;
|
||||
|
||||
Save = sav;
|
||||
Folder = parent;
|
||||
|
||||
@@ -33,7 +33,7 @@ public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pk)
|
||||
|
||||
private void ResetView(ISlotViewer<T> sub, ISlotInfo slot, SlotTouchType type, PKM pk)
|
||||
{
|
||||
if (Previous != null)
|
||||
if (Previous is not null)
|
||||
sub.NotifySlotOld(Previous);
|
||||
|
||||
if (slot is not SlotInfoBox b || sub.ViewIndex == b.Box)
|
||||
@@ -42,7 +42,7 @@ private void ResetView(ISlotViewer<T> sub, ISlotInfo slot, SlotTouchType type, P
|
||||
|
||||
public void ResetView(ISlotViewer<T> sub)
|
||||
{
|
||||
if (Previous == null || PreviousEntity == null)
|
||||
if (Previous is null || PreviousEntity is null)
|
||||
return;
|
||||
ResetView(sub, Previous, PreviousType, PreviousEntity);
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ private bool Equals(SlotViewInfo<T> other)
|
||||
|
||||
public override bool Equals(object? obj) => ReferenceEquals(this, obj) || (obj is SlotViewInfo<T> other && Equals(other));
|
||||
public override int GetHashCode() => (Slot.GetHashCode() * 397) ^ View.GetHashCode();
|
||||
bool IEquatable<T>.Equals(T? other) => other != null && Equals(other);
|
||||
bool IEquatable<T>.Equals(T? other) => other is not null && Equals(other);
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ private string GetText(GameStrings? strings = null)
|
||||
if (Species is 0 or > MAX_SPECIES)
|
||||
return string.Empty;
|
||||
|
||||
if (strings != null)
|
||||
if (strings is not null)
|
||||
Strings = strings;
|
||||
|
||||
var result = GetSetLines();
|
||||
|
||||
@@ -45,7 +45,7 @@ public static List<PKM> GetLivingDex(this ITrainerInfo tr, IEnumerable<ushort> s
|
||||
for (byte f = 0; f < pi.FormCount; f++)
|
||||
{
|
||||
var entry = tr.GetLivingEntry(pk, s, f, destType);
|
||||
if (entry == null)
|
||||
if (entry is null)
|
||||
continue;
|
||||
result.Add(entry);
|
||||
}
|
||||
@@ -67,12 +67,12 @@ public static List<PKM> GetLivingDex(this ITrainerInfo tr, IEnumerable<ushort> s
|
||||
var first = EncounterMovesetGenerator.GenerateEncounters(template, tr, memory).FirstOrDefault();
|
||||
span.Clear();
|
||||
ArrayPool<ushort>.Shared.Return(moves);
|
||||
if (first == null)
|
||||
if (first is null)
|
||||
return null;
|
||||
|
||||
var pk = first.ConvertToPKM(tr);
|
||||
var result = EntityConverter.ConvertToType(pk, destType, out _);
|
||||
if (result == null)
|
||||
if (result is null)
|
||||
return null;
|
||||
|
||||
result.Species = species;
|
||||
|
||||
@@ -57,7 +57,7 @@ static bool IsTypeCompatible(IEncounterTemplate enc, PKM pk, PIDType type)
|
||||
partial ??= z;
|
||||
}
|
||||
|
||||
if (partial != null)
|
||||
if (partial is not null)
|
||||
{
|
||||
info.ManualFlag = EncounterYieldFlag.InvalidPIDIV;
|
||||
yield return partial;
|
||||
|
||||
@@ -143,7 +143,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
case YieldState.End:
|
||||
|
||||
@@ -163,7 +163,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public bool MoveNext()
|
||||
|
||||
case YieldState.Fallback:
|
||||
State = YieldState.End;
|
||||
if (Deferred != null)
|
||||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -44,10 +44,7 @@ public static EncounterStatic8U Read(ReadOnlySpan<byte> data)
|
||||
protected override void SetTrainerName(ReadOnlySpan<char> name, PK8 pk)
|
||||
{
|
||||
if (ShouldHaveScientistTrash)
|
||||
{
|
||||
var scientist = GetScientistName(pk.Language);
|
||||
pk.SetString(pk.OriginalTrainerTrash, scientist, scientist.Length, StringConverterOption.None);
|
||||
}
|
||||
base.SetTrainerName(GetScientistName(pk.Language), pk);
|
||||
base.SetTrainerName(name, pk);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public static CheckResult VerifyGift(PKM pk, MysteryGift g)
|
||||
private static bool TryGetRestriction(MysteryGift g, out MysteryGiftRestriction val)
|
||||
{
|
||||
var restrict = RestrictionSet[g.Generation];
|
||||
if (restrict != null)
|
||||
if (restrict is not null)
|
||||
return restrict.TryGetValue(g.GetHashCode(), out val);
|
||||
val = MysteryGiftRestriction.None;
|
||||
return false;
|
||||
|
||||
@@ -46,7 +46,7 @@ public static bool IsFiltered(ReadOnlySpan<char> message, [NotNullWhen(true)] ou
|
||||
|
||||
// Check dictionary
|
||||
if (Lookup.TryGetValue(message, out regMatch))
|
||||
return regMatch != null;
|
||||
return regMatch is not null;
|
||||
|
||||
// not in dictionary, check patterns
|
||||
if (WordFilter.TryMatch(message, Regexes, out regMatch))
|
||||
|
||||
@@ -39,7 +39,7 @@ public static bool IsFiltered(ReadOnlySpan<char> message, [NotNullWhen(true)] ou
|
||||
|
||||
// Check dictionary
|
||||
if (Lookup.TryGetValue(message, out regMatch))
|
||||
return regMatch != null;
|
||||
return regMatch is not null;
|
||||
|
||||
// not in dictionary, check patterns
|
||||
if (WordFilter.TryMatch(message, Regexes, out regMatch))
|
||||
|
||||
@@ -301,6 +301,8 @@ private static bool IsMatch45(ReadOnlySpan<char> nickname, ushort species, ReadO
|
||||
|
||||
private static bool IsMatchUpper45(ReadOnlySpan<char> nickname, ReadOnlySpan<char> expect)
|
||||
{
|
||||
if (nickname.Length != expect.Length)
|
||||
return false;
|
||||
for (int i = 0; i < expect.Length; i++)
|
||||
{
|
||||
if (nickname[i] != char.ToUpperInvariant(expect[i]))
|
||||
@@ -311,10 +313,10 @@ private static bool IsMatchUpper45(ReadOnlySpan<char> nickname, ReadOnlySpan<cha
|
||||
|
||||
private static void VerifyNicknameEgg(LegalityAnalysis data)
|
||||
{
|
||||
var Info = data.Info;
|
||||
var pk = data.Entity;
|
||||
var enc = data.Info.EncounterMatch;
|
||||
|
||||
bool flagState = EggStateLegality.IsNicknameFlagSet(Info.EncounterMatch, pk);
|
||||
bool flagState = EggStateLegality.IsNicknameFlagSet(enc, pk);
|
||||
if (pk.IsNicknamed != flagState)
|
||||
data.AddLine(GetInvalid(flagState ? LNickFlagEggYes : LNickFlagEggNo, CheckIdentifier.Egg));
|
||||
|
||||
@@ -324,7 +326,7 @@ private static void VerifyNicknameEgg(LegalityAnalysis data)
|
||||
|
||||
if (pk.Format == 2 && !SpeciesName.IsNicknamedAnyLanguage(0, nickname, 2))
|
||||
data.AddLine(GetValid(LNickMatchLanguageEgg, CheckIdentifier.Egg));
|
||||
else if (!nickname.SequenceEqual(SpeciesName.GetEggName(pk.Language, Info.Generation)))
|
||||
else if (!nickname.SequenceEqual(SpeciesName.GetEggName(pk.Language, enc.Generation)))
|
||||
data.AddLine(GetInvalid(LNickMatchLanguageEggFail, CheckIdentifier.Egg));
|
||||
else
|
||||
data.AddLine(GetValid(LNickMatchLanguageEgg, CheckIdentifier.Egg));
|
||||
|
||||
@@ -188,17 +188,10 @@ public static bool ContainsTooManyNumbers(ReadOnlySpan<char> str, int originalGe
|
||||
|
||||
private static int GetNumberCount(ReadOnlySpan<char> str)
|
||||
{
|
||||
static bool IsNumber(char c)
|
||||
{
|
||||
if (c >= '0')
|
||||
return c <= '9';
|
||||
return (uint)(c - '0') <= 9;
|
||||
}
|
||||
|
||||
int ctr = 0;
|
||||
foreach (var c in str)
|
||||
{
|
||||
if (IsNumber(c))
|
||||
if (char.IsNumber(c))
|
||||
++ctr;
|
||||
}
|
||||
return ctr;
|
||||
|
||||
@@ -26,7 +26,7 @@ public static IEnumerable<MysteryGift> GetGiftsFromFolder(string folder)
|
||||
|
||||
var data = File.ReadAllBytes(file);
|
||||
var gift = MysteryGift.GetMysteryGift(data, fi.Extension);
|
||||
if (gift != null)
|
||||
if (gift is not null)
|
||||
yield return gift;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public PA8 ConvertToPKM(PKH pkh)
|
||||
return null;
|
||||
|
||||
var result = CreateInternal(pkh);
|
||||
if (result == null)
|
||||
if (result is null)
|
||||
return null;
|
||||
|
||||
result.PopulateFromCore(pkh);
|
||||
@@ -154,7 +154,7 @@ public PA8 ConvertToPKM(PKH pkh)
|
||||
private static GameDataPA8? CreateInternal(PKH pkh)
|
||||
{
|
||||
var side = GetNearestNeighbor(pkh);
|
||||
if (side == null)
|
||||
if (side is null)
|
||||
return null;
|
||||
|
||||
var result = new GameDataPA8();
|
||||
|
||||
@@ -158,7 +158,7 @@ public PB7 ConvertToPKM(PKH pkh)
|
||||
// There isn't an actual preference since this format cannot naturally backwards transfer.
|
||||
// Just pick out the first one.
|
||||
var result = CreateInternal(pkh);
|
||||
if (result == null)
|
||||
if (result is null)
|
||||
return null;
|
||||
|
||||
result.PopulateFromCore(pkh);
|
||||
@@ -168,7 +168,7 @@ public PB7 ConvertToPKM(PKH pkh)
|
||||
private static GameDataPB7? CreateInternal(PKH pkh)
|
||||
{
|
||||
var side = GetNearestNeighbor(pkh);
|
||||
if (side == null)
|
||||
if (side is null)
|
||||
return null;
|
||||
|
||||
var ball = side.Ball;
|
||||
|
||||
@@ -94,7 +94,7 @@ public PB8 ConvertToPKM(PKH pkh)
|
||||
public static GameDataPB8? TryCreate(PKH pkh)
|
||||
{
|
||||
var side = GetNearestNeighbor(pkh);
|
||||
if (side == null)
|
||||
if (side is null)
|
||||
return null;
|
||||
|
||||
var result = new GameDataPB8();
|
||||
|
||||
@@ -162,7 +162,7 @@ public PK9 ConvertToPKM(PKH pkh)
|
||||
return null;
|
||||
|
||||
var result = CreateInternal(pkh);
|
||||
if (result == null)
|
||||
if (result is null)
|
||||
return null;
|
||||
|
||||
result.PopulateFromCore(pkh);
|
||||
@@ -172,7 +172,7 @@ public PK9 ConvertToPKM(PKH pkh)
|
||||
private static GameDataPK9? CreateInternal(PKH pkh)
|
||||
{
|
||||
var side = GetNearestNeighbor(pkh);
|
||||
if (side == null)
|
||||
if (side is null)
|
||||
return null;
|
||||
|
||||
var result = new GameDataPK9();
|
||||
|
||||
@@ -170,7 +170,7 @@ private bool SearchIntermediate(PKM pk)
|
||||
return false;
|
||||
if (HiddenPowerType > -1 && pk.HPType != HiddenPowerType)
|
||||
return false;
|
||||
if (SearchShiny != null && pk.IsShiny != SearchShiny)
|
||||
if (SearchShiny is not null && pk.IsShiny != SearchShiny)
|
||||
return false;
|
||||
|
||||
if (IVType > 0 && !SearchUtil.SatisfiesFilterIVs(pk, IVType))
|
||||
@@ -183,11 +183,11 @@ private bool SearchIntermediate(PKM pk)
|
||||
|
||||
private bool SearchComplex(PKM pk)
|
||||
{
|
||||
if (SearchEgg != null && !FilterResultEgg(pk))
|
||||
if (SearchEgg is not null && !FilterResultEgg(pk))
|
||||
return false;
|
||||
if (Level is { } x and not 0 && !SearchUtil.SatisfiesFilterLevel(pk, SearchLevel, x))
|
||||
return false;
|
||||
if (SearchLegal != null && new LegalityAnalysis(pk).Valid != SearchLegal)
|
||||
if (SearchLegal is not null && new LegalityAnalysis(pk).Valid != SearchLegal)
|
||||
return false;
|
||||
if (BatchFilters.Count != 0 && !SearchUtil.SatisfiesFilterBatchInstruction(pk, BatchFilters))
|
||||
return false;
|
||||
@@ -199,7 +199,7 @@ private bool FilterResultEgg(PKM pk)
|
||||
{
|
||||
if (SearchEgg == false)
|
||||
return !pk.IsEgg;
|
||||
if (ESV != null)
|
||||
if (ESV is not null)
|
||||
return pk.IsEgg && pk.PSV == ESV;
|
||||
return pk.IsEgg;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public static bool IsConvertibleToFormat(PKM pk, byte format)
|
||||
while (true)
|
||||
{
|
||||
entity = IntermediaryConvert(entity, destType, ref result);
|
||||
if (entity == null) // fail convert
|
||||
if (entity is null) // fail convert
|
||||
return null;
|
||||
if (entity.GetType() == destType) // finish convert
|
||||
return entity;
|
||||
@@ -308,7 +308,7 @@ public static bool TryMakePKMCompatible(PKM pk, PKM target, out EntityConverterR
|
||||
return false;
|
||||
}
|
||||
var convert = ConvertToType(pk, target.GetType(), out result);
|
||||
if (convert == null)
|
||||
if (convert is null)
|
||||
{
|
||||
converted = target;
|
||||
return false;
|
||||
|
||||
@@ -38,7 +38,7 @@ public AesSession(byte[] key, CipherMode mode, PaddingMode padding, byte[]? iv)
|
||||
_aes.Mode = mode;
|
||||
_aes.Padding = padding;
|
||||
_aes.Key = key;
|
||||
if (iv != null)
|
||||
if (iv is not null)
|
||||
_aes.IV = iv;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ private string GetBlockHint(SCBlock z, int index)
|
||||
var blockName = GetBlockName(z, out _);
|
||||
var isBool = z.Type.IsBoolean();
|
||||
var type = (isBool ? "Bool" : z.Type.ToString());
|
||||
if (blockName != null)
|
||||
if (blockName is not null)
|
||||
return $"*{type} {blockName}";
|
||||
var result = $"{z.Key:X8} - {index:0000} {type}";
|
||||
if (z.Type is SCTypeCode.Object or SCTypeCode.Array)
|
||||
|
||||
@@ -171,7 +171,7 @@ private int GetBoxWallpaperOffset(int box)
|
||||
public string GetBoxName(int box)
|
||||
{
|
||||
// Tweaked for the 1-30/31-60 box showing
|
||||
var dir = box % 2 == 0 ? "◖" : "◗";
|
||||
var dir = box % 2 == 0 ? "◖ " : " ◗";
|
||||
string boxName = $"[{dir}] ";
|
||||
box /= 2;
|
||||
|
||||
@@ -187,7 +187,7 @@ public string GetBoxName(int box)
|
||||
public void SetBoxName(int box, ReadOnlySpan<char> value)
|
||||
{
|
||||
var span = GetBoxNameSpan(box);
|
||||
if (value == BoxDetailNameExtensions.GetDefaultBoxNameCaps(box))
|
||||
if (value.SequenceEqual(BoxDetailNameExtensions.GetDefaultBoxNameCaps(box)))
|
||||
{
|
||||
span.Clear();
|
||||
return;
|
||||
|
||||
@@ -161,7 +161,7 @@ private byte[] GetInnerData()
|
||||
|
||||
// Put save slot back in original save data
|
||||
var destOffset = SLOT_START + (SaveIndex * SLOT_SIZE);
|
||||
byte[] dest = MemoryCard != null ? MemoryCard.ReadSaveGameData().ToArray() : (byte[])BAK.Clone();
|
||||
byte[] dest = MemoryCard is not null ? MemoryCard.ReadSaveGameData().ToArray() : (byte[])BAK.Clone();
|
||||
var destSpan = dest.AsSpan(destOffset, Data.Length);
|
||||
|
||||
// Get updated save slot data
|
||||
|
||||
@@ -726,7 +726,7 @@ public int ClearBoxes(int BoxStart = 0, int BoxEnd = -1, Func<PKM, bool>? delete
|
||||
var ofs = GetBoxSlotOffset(i, p);
|
||||
if (!IsPKMPresent(storage[ofs..]))
|
||||
continue;
|
||||
if (deleteCriteria != null)
|
||||
if (deleteCriteria is not null)
|
||||
{
|
||||
var pk = GetBoxSlotAtIndex(i, p);
|
||||
if (!deleteCriteria(pk))
|
||||
|
||||
@@ -175,7 +175,7 @@ public string GetSuggestedExtension()
|
||||
{
|
||||
var sav = SAV;
|
||||
var fn = sav.Metadata.FileName;
|
||||
if (fn != null)
|
||||
if (fn is not null)
|
||||
return Path.GetExtension(fn);
|
||||
|
||||
if ((sav.Generation is 4 or 5) && sav.Metadata.HasFooter)
|
||||
|
||||
@@ -34,7 +34,7 @@ public uint Identifier
|
||||
set
|
||||
{
|
||||
captured.Identifier = value;
|
||||
if (defeated != null)
|
||||
if (defeated is not null)
|
||||
defeated.Identifier = value;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public bool Defeated
|
||||
get => defeated?.Defeated ?? captured.Defeated;
|
||||
set
|
||||
{
|
||||
if (defeated != null)
|
||||
if (defeated is not null)
|
||||
defeated.Defeated = value;
|
||||
else
|
||||
captured.Defeated = value;
|
||||
|
||||
@@ -13,8 +13,8 @@ public sealed class Mail4 : MailDetail
|
||||
|
||||
public Mail4(byte? lang, byte? version) : base(new byte[SIZE])
|
||||
{
|
||||
if (lang != null) AuthorLanguage = (byte)lang;
|
||||
if (version != null) AuthorVersion = (byte)version;
|
||||
if (lang is not null) AuthorLanguage = (byte)lang;
|
||||
if (version is not null) AuthorVersion = (byte)version;
|
||||
ResetData();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ public sealed class Mail5 : MailDetail
|
||||
|
||||
public Mail5(byte? lang, byte? version) : base(new byte[SIZE])
|
||||
{
|
||||
if (lang != null) AuthorLanguage = (byte)lang;
|
||||
if (version != null) AuthorVersion = (byte)version;
|
||||
if (lang is not null) AuthorLanguage = (byte)lang;
|
||||
if (version is not null) AuthorVersion = (byte)version;
|
||||
ResetData();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ private static List<string> GetSaveFileErrata(this SaveFile sav, PKM pk, IBasicS
|
||||
msg = MsgIndexItemGame;
|
||||
else if (!pk.CanHoldItem(sav.HeldItems))
|
||||
msg = MsgIndexItemHeld;
|
||||
if (msg != null)
|
||||
if (msg is not null)
|
||||
{
|
||||
var itemstr = GameInfo.Strings.GetItemStrings(pk.Context, pk.Version);
|
||||
errata.Add($"{msg} {(held >= itemstr.Length ? held.ToString() : itemstr[held])}");
|
||||
@@ -134,7 +134,7 @@ public static IEnumerable<PKM> GetCompatible(this SaveFile sav, IEnumerable<PKM>
|
||||
foreach (var temp in pks)
|
||||
{
|
||||
var pk = EntityConverter.ConvertToType(temp, savtype, out var c);
|
||||
if (pk == null)
|
||||
if (pk is null)
|
||||
{
|
||||
Debug.WriteLine(c.GetDisplayString(temp, savtype));
|
||||
continue;
|
||||
|
||||
@@ -119,7 +119,7 @@ public static IEnumerable<SaveFile> GetSaveFiles(IReadOnlyList<string> drives, b
|
||||
foreach (var s in byMostRecent)
|
||||
{
|
||||
var sav = SaveUtil.GetVariantSAV(s);
|
||||
if (sav != null)
|
||||
if (sav is not null)
|
||||
yield return sav;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,13 +658,13 @@ private static GameVersion GetIsG9SAV(ReadOnlySpan<byte> data)
|
||||
continue;
|
||||
|
||||
var custom = h.ReadSaveFile(data, path);
|
||||
if (custom != null)
|
||||
if (custom is not null)
|
||||
return custom;
|
||||
}
|
||||
#endif
|
||||
|
||||
var sav = GetVariantSAVInternal(data);
|
||||
if (sav != null)
|
||||
if (sav is not null)
|
||||
return sav;
|
||||
|
||||
#if !EXCLUDE_EMULATOR_FORMATS
|
||||
@@ -674,11 +674,11 @@ private static GameVersion GetIsG9SAV(ReadOnlySpan<byte> data)
|
||||
continue;
|
||||
|
||||
var split = h.TrySplit(data);
|
||||
if (split == null)
|
||||
if (split is null)
|
||||
continue;
|
||||
|
||||
sav = GetVariantSAVInternal(split.Data);
|
||||
if (sav == null)
|
||||
if (sav is null)
|
||||
continue;
|
||||
|
||||
var meta = sav.Metadata;
|
||||
@@ -757,7 +757,7 @@ private static GameVersion GetIsG9SAV(ReadOnlySpan<byte> data)
|
||||
return null;
|
||||
|
||||
var split = DolphinHandler.TrySplit(memory.Span);
|
||||
var data = split != null ? split.Data : memory.ToArray();
|
||||
var data = split is not null ? split.Data : memory.ToArray();
|
||||
|
||||
SaveFile sav;
|
||||
switch (memCard.SelectedGameVersion)
|
||||
@@ -771,7 +771,7 @@ private static GameVersion GetIsG9SAV(ReadOnlySpan<byte> data)
|
||||
default: return null;
|
||||
}
|
||||
|
||||
if (split != null)
|
||||
if (split is not null)
|
||||
sav.Metadata.SetExtraInfo(split.Header, split.Footer, split.Handler);
|
||||
return sav;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public static int FindNextValidIndex<T>(Span<T> dest, Func<int, bool> skip, int
|
||||
if ((uint)ctr >= dest.Length)
|
||||
return -1;
|
||||
var exist = dest[ctr];
|
||||
if (exist == null || !skip(ctr))
|
||||
if (exist is null || !skip(ctr))
|
||||
return ctr;
|
||||
ctr++;
|
||||
}
|
||||
|
||||
@@ -140,9 +140,9 @@ private sealed class FunctorComparer<T>(Comparison<T> Comparison) : IComparer<T>
|
||||
{
|
||||
public int Compare(T? x, T? y)
|
||||
{
|
||||
if (x == null)
|
||||
return y == null ? 0 : -1;
|
||||
return y == null ? 1 : Comparison(x, y);
|
||||
if (x is null)
|
||||
return y is null ? 0 : -1;
|
||||
return y is null ? 1 : Comparison(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public static bool IsFileTooBig(long length)
|
||||
public static bool TryGetSAV(byte[] data, [NotNullWhen(true)] out SaveFile? sav)
|
||||
{
|
||||
sav = SaveUtil.GetVariantSAV(data);
|
||||
return sav != null;
|
||||
return sav is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -221,7 +221,7 @@ public static bool TryGetPKM(byte[] data, [NotNullWhen(true)] out PKM? pk, ReadO
|
||||
}
|
||||
var format = EntityFileExtension.GetContextFromExtension(ext, sav?.Context ?? EntityContext.Gen6);
|
||||
pk = EntityFormat.GetFromBytes(data, prefer: format);
|
||||
return pk != null;
|
||||
return pk is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -277,7 +277,7 @@ private static bool IsNoDataPresent(ReadOnlySpan<byte> data)
|
||||
public static bool TryGetBattleVideo(byte[] data, [NotNullWhen(true)] out IBattleVideo? bv)
|
||||
{
|
||||
bv = BattleVideo.GetVariantBattleVideo(data);
|
||||
return bv != null;
|
||||
return bv is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -292,7 +292,7 @@ public static bool TryGetMysteryGift(byte[] data, [NotNullWhen(true)] out Myster
|
||||
mg = ext.Length == 0
|
||||
? MysteryGift.GetMysteryGift(data)
|
||||
: MysteryGift.GetMysteryGift(data, ext);
|
||||
return mg != null;
|
||||
return mg is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -328,7 +328,7 @@ public static string GetPKMTempFileName(PKM pk, bool encrypt)
|
||||
var ext = fi.Extension;
|
||||
var mg = MysteryGift.GetMysteryGift(data, ext);
|
||||
var gift = mg?.ConvertToPKM(sav);
|
||||
if (gift != null)
|
||||
if (gift is not null)
|
||||
return gift;
|
||||
_ = TryGetPKM(data, out var pk, ext, sav);
|
||||
return pk;
|
||||
|
||||
@@ -13,7 +13,7 @@ public static class LocalizeUtil
|
||||
public static void InitializeStrings(string lang, SaveFile? sav = null, bool hax = false)
|
||||
{
|
||||
var str = GameInfo.Strings = GameInfo.GetStrings(lang);
|
||||
if (sav != null)
|
||||
if (sav is not null)
|
||||
GameInfo.FilteredSources = new FilteredGameDataSource(sav, GameInfo.Sources, hax);
|
||||
|
||||
// Update Legality Analysis strings
|
||||
|
||||
@@ -12,7 +12,7 @@ public static class NetUtil
|
||||
try
|
||||
{
|
||||
var stream = GetStreamFromURL(url);
|
||||
if (stream == null)
|
||||
if (stream is null)
|
||||
return null;
|
||||
|
||||
using var reader = new StreamReader(stream);
|
||||
|
||||
@@ -143,7 +143,7 @@ public static IEnumerable<PropertyInfo> GetAllProperties(this TypeInfo typeInfo)
|
||||
|
||||
public static IEnumerable<TypeInfo> GetAllTypeInfo(this TypeInfo? typeInfo)
|
||||
{
|
||||
while (typeInfo != null)
|
||||
while (typeInfo is not null)
|
||||
{
|
||||
yield return typeInfo;
|
||||
typeInfo = typeInfo.BaseType?.GetTypeInfo();
|
||||
@@ -168,12 +168,12 @@ public static bool TryGetPropertyInfo(this TypeInfo typeInfo, string name, [NotN
|
||||
foreach (var t in typeInfo.GetAllTypeInfo())
|
||||
{
|
||||
pi = t.GetDeclaredProperty(name);
|
||||
if (pi != null)
|
||||
if (pi is not null)
|
||||
return true;
|
||||
foreach (var i in t.ImplementedInterfaces)
|
||||
{
|
||||
pi = i.GetTypeInfo().GetDeclaredProperty(name);
|
||||
if (pi != null)
|
||||
if (pi is not null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,13 +170,13 @@ private Bitmap GetBaseImageFallback(ushort species, byte form, byte gender, uint
|
||||
if (shiny) // try again without shiny
|
||||
{
|
||||
var img = GetBaseImageDefault(species, form, gender, formarg, false, context);
|
||||
if (img != null)
|
||||
if (img is not null)
|
||||
return img;
|
||||
}
|
||||
|
||||
// try again without form
|
||||
var baseImage = (Bitmap?)Resources.ResourceManager.GetObject(GetSpriteStringSpeciesOnly(species));
|
||||
if (baseImage == null) // failed again
|
||||
if (baseImage is null) // failed again
|
||||
return Unknown;
|
||||
return ImageUtil.LayerImage(baseImage, Unknown, 0, 0, UnknownFormTransparency);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ private void Reset(object sender, EventArgs e)
|
||||
if (Entity is null)
|
||||
return;
|
||||
var sav = WinFormsUtil.FindFirstControlOfType<IMainEditor>(this)?.RequestSaveFile;
|
||||
if (sav == null)
|
||||
if (sav is null)
|
||||
return;
|
||||
NUD_CatchRate.Value = CatchRateApplicator.GetSuggestedCatchRate(Entity, sav);
|
||||
}
|
||||
|
||||
@@ -827,7 +827,7 @@ private static string GetMoveListPrint(Span<ushort> moves, ReadOnlySpan<string>
|
||||
private bool SetSuggestedMetLocation(bool silent = false)
|
||||
{
|
||||
var encounter = EncounterSuggestion.GetSuggestedMetInfo(Entity);
|
||||
if (encounter == null || (Entity.Format >= 3 && encounter.Location == 0))
|
||||
if (encounter is null || (Entity.Format >= 3 && encounter.Location == 0))
|
||||
{
|
||||
if (!silent)
|
||||
WinFormsUtil.Alert(MsgPKMSuggestionNone);
|
||||
@@ -1660,7 +1660,7 @@ private void ValidateComboBox(ComboBox cb)
|
||||
{
|
||||
if (cb.Text.Length == 0 && cb.Items.Count > 0)
|
||||
cb.SelectedIndex = 0;
|
||||
else if (cb.SelectedValue == null)
|
||||
else if (cb.SelectedValue is null)
|
||||
cb.BackColor = Draw.InvalidSelection;
|
||||
else
|
||||
cb.ResetBackColor();
|
||||
|
||||
@@ -36,7 +36,7 @@ public void LoadPKM(PKM entity)
|
||||
ss = entity as IScaledSize;
|
||||
sv = entity as IScaledSizeValue;
|
||||
scale = entity as IScaledSize3;
|
||||
if (ss == null)
|
||||
if (ss is null)
|
||||
return;
|
||||
TryResetStats();
|
||||
}
|
||||
@@ -63,23 +63,23 @@ private void ResetCalculatedStats()
|
||||
private void LoadStoredValues()
|
||||
{
|
||||
Loading = true;
|
||||
if (ss != null)
|
||||
if (ss is not null)
|
||||
{
|
||||
if (NUD_HeightScalar.Focused || NUD_WeightScalar.Focused)
|
||||
CHK_Auto.Focus();
|
||||
NUD_HeightScalar.Value = ss.HeightScalar;
|
||||
NUD_WeightScalar.Value = ss.WeightScalar;
|
||||
}
|
||||
if (sv != null)
|
||||
if (sv is not null)
|
||||
{
|
||||
TB_HeightAbs.Text = GetString(sv.HeightAbsolute);
|
||||
TB_WeightAbs.Text = GetString(sv.WeightAbsolute);
|
||||
}
|
||||
if (scale != null)
|
||||
if (scale is not null)
|
||||
{
|
||||
NUD_Scale.Value = scale.Scale;
|
||||
}
|
||||
if (pk != null)
|
||||
if (pk is not null)
|
||||
{
|
||||
MT_CP.Text = Math.Min(65535, pk.Stat_CP).ToString();
|
||||
}
|
||||
@@ -97,13 +97,13 @@ private void UpdateFlagState(object sender, EventArgs e)
|
||||
|
||||
private void MT_CP_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (pk != null && int.TryParse(MT_CP.Text, out var cp))
|
||||
if (pk is not null && int.TryParse(MT_CP.Text, out var cp))
|
||||
pk.Stat_CP = Math.Min(65535, cp);
|
||||
}
|
||||
|
||||
private void NUD_HeightScalar_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (ss != null)
|
||||
if (ss is not null)
|
||||
{
|
||||
if (!Loading)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ private void NUD_HeightScalar_ValueChanged(object sender, EventArgs e)
|
||||
SetLabelColorHeightWeight(label);
|
||||
}
|
||||
|
||||
if (!CHK_Auto.Checked || Loading || sv == null)
|
||||
if (!CHK_Auto.Checked || Loading || sv is null)
|
||||
return;
|
||||
sv.ResetHeight();
|
||||
sv.ResetWeight();
|
||||
@@ -127,7 +127,7 @@ private void NUD_HeightScalar_ValueChanged(object sender, EventArgs e)
|
||||
|
||||
private void NUD_WeightScalar_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (ss != null)
|
||||
if (ss is not null)
|
||||
{
|
||||
if (!Loading)
|
||||
ss.WeightScalar = (byte)NUD_WeightScalar.Value;
|
||||
@@ -137,7 +137,7 @@ private void NUD_WeightScalar_ValueChanged(object sender, EventArgs e)
|
||||
SetLabelColorHeightWeight(label);
|
||||
}
|
||||
|
||||
if (!CHK_Auto.Checked || Loading || sv == null)
|
||||
if (!CHK_Auto.Checked || Loading || sv is null)
|
||||
return;
|
||||
sv.ResetWeight();
|
||||
TB_WeightAbs.Text = GetString(sv.WeightAbsolute);
|
||||
@@ -145,7 +145,7 @@ private void NUD_WeightScalar_ValueChanged(object sender, EventArgs e)
|
||||
|
||||
private void NUD_Scale_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (scale != null)
|
||||
if (scale is not null)
|
||||
{
|
||||
if (!Loading)
|
||||
{
|
||||
@@ -174,7 +174,7 @@ private void SetLabelColorHeightWeight(Control label)
|
||||
|
||||
private void TB_HeightAbs_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (sv == null || Loading)
|
||||
if (sv is null || Loading)
|
||||
return;
|
||||
if (CHK_Auto.Checked)
|
||||
sv.ResetHeight();
|
||||
@@ -184,7 +184,7 @@ private void TB_HeightAbs_TextChanged(object sender, EventArgs e)
|
||||
|
||||
private void TB_WeightAbs_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (sv == null || Loading)
|
||||
if (sv is null || Loading)
|
||||
return;
|
||||
if (CHK_Auto.Checked)
|
||||
sv.ResetWeight();
|
||||
|
||||
@@ -34,7 +34,7 @@ public sealed class BitmapAnimator : IDisposable
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (pb == null || !Enabled)
|
||||
if (pb is null || !Enabled)
|
||||
return;
|
||||
|
||||
lock (Lock)
|
||||
@@ -81,7 +81,7 @@ private void TimerElapsed(object? sender, ElapsedEventArgs? elapsedEventArgs)
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
if (pb == null)
|
||||
if (pb is null)
|
||||
return;
|
||||
try { pb.BackgroundImage = GetFrame(frameIndex); } // drawing GDI can be silly sometimes #2072
|
||||
catch (AccessViolationException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); }
|
||||
@@ -93,7 +93,7 @@ private Image GetFrame(int frameIndex)
|
||||
var cache = GlowCache;
|
||||
ArgumentNullException.ThrowIfNull(cache);
|
||||
var frame = cache[frameIndex];
|
||||
if (frame != null)
|
||||
if (frame is not null)
|
||||
return frame;
|
||||
|
||||
var elapsedFraction = (double)frameIndex / GlowInterval;
|
||||
@@ -109,9 +109,9 @@ private Image GetFrame(int frameIndex)
|
||||
frameSpan.Clear();
|
||||
ArrayPool<byte>.Shared.Return(frameData);
|
||||
|
||||
if (ExtraLayer != null)
|
||||
if (ExtraLayer is not null)
|
||||
frame = ImageUtil.LayerImage(frame, ExtraLayer, 0, 0);
|
||||
if (OriginalBackground != null)
|
||||
if (OriginalBackground is not null)
|
||||
frame = ImageUtil.LayerImage(OriginalBackground, frame, 0, 0);
|
||||
return cache[frameIndex] = frame;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ private void MenuOpening(object sender, CancelEventArgs e)
|
||||
bool canView = !info.IsEmpty() || Main.HaX;
|
||||
bool canSet = info.CanWriteTo();
|
||||
bool canDelete = canSet && canView;
|
||||
bool canLegality = (ModifierKeys == Keys.Control || Main.Settings.Display.SlotLegalityAlwaysVisible) && canView && RequestEditorLegality != null;
|
||||
bool canLegality = (ModifierKeys == Keys.Control || Main.Settings.Display.SlotLegalityAlwaysVisible) && canView && RequestEditorLegality is not null;
|
||||
|
||||
ToggleItem(mnuView, canView);
|
||||
ToggleItem(mnuSet, canSet);
|
||||
|
||||
@@ -13,7 +13,7 @@ partial class SAVEditor
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
if (disposing && (components is not null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ private void ResetDaycare()
|
||||
L_SlotOccupied[i].Text = $"{i + 1}: ✘";
|
||||
var pb = UpdateSlot(i);
|
||||
var current = pb.Image;
|
||||
if (current != null)
|
||||
if (current is not null)
|
||||
pb.Image = ImageUtil.ChangeOpacity(current, 0.6);
|
||||
}
|
||||
}
|
||||
@@ -474,7 +474,7 @@ private void ClickBoxDouble(object sender, MouseEventArgs e)
|
||||
if (M.Boxes.Count > 1) // subview open
|
||||
{
|
||||
var z = M.Boxes[1].ParentForm;
|
||||
if (z == null)
|
||||
if (z is null)
|
||||
return;
|
||||
z.CenterToForm(ParentForm);
|
||||
z.BringToFront();
|
||||
@@ -696,7 +696,7 @@ private void B_OtherSlots_Click(object sender, EventArgs e)
|
||||
void TryOpen(SaveFile sav, IReadOnlyList<SlotGroup> g)
|
||||
{
|
||||
var form = WinFormsUtil.FirstFormOfType<SAV_GroupViewer>();
|
||||
if (form != null)
|
||||
if (form is not null)
|
||||
{
|
||||
form.CenterToForm(ParentForm);
|
||||
}
|
||||
@@ -1059,7 +1059,7 @@ public bool LoadBoxes(out string result, string? path = null)
|
||||
if (!SAV.HasBox)
|
||||
return false;
|
||||
|
||||
if (path == null && !IsFolderPath(out path))
|
||||
if (path is null && !IsFolderPath(out path))
|
||||
{
|
||||
result = path;
|
||||
return false;
|
||||
@@ -1121,7 +1121,7 @@ private void ToggleViewReset()
|
||||
if (height > allowed)
|
||||
{
|
||||
var form = FindForm();
|
||||
if (form != null)
|
||||
if (form is not null)
|
||||
form.Height += height - allowed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public void MouseLeave(object? sender, EventArgs e)
|
||||
|
||||
public void MouseClick(object? sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
if (sender is null)
|
||||
return;
|
||||
if (!Drag.Info.DragDropInProgress)
|
||||
SE.ClickSlot(sender, e);
|
||||
@@ -55,7 +55,7 @@ public void MouseClick(object? sender, MouseEventArgs e)
|
||||
|
||||
public void MouseUp(object? sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
if (sender is null)
|
||||
return;
|
||||
if (e.Button == MouseButtons.Left)
|
||||
Drag.Info.LeftMouseIsDown = false;
|
||||
@@ -64,7 +64,7 @@ public void MouseUp(object? sender, MouseEventArgs e)
|
||||
|
||||
public void MouseDown(object? sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
if (sender is null)
|
||||
return;
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ public void MouseDown(object? sender, MouseEventArgs e)
|
||||
|
||||
public void QueryContinueDrag(object? sender, QueryContinueDragEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
if (sender is null)
|
||||
return;
|
||||
if (e.Action != DragAction.Cancel && e.Action != DragAction.Drop)
|
||||
return;
|
||||
@@ -85,11 +85,11 @@ public void QueryContinueDrag(object? sender, QueryContinueDragEventArgs e)
|
||||
|
||||
public void DragEnter(object? sender, DragEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
if (sender is null)
|
||||
return;
|
||||
if ((e.AllowedEffect & DragDropEffects.Copy) != 0) // external file
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
else if (e.Data != null) // within
|
||||
else if (e.Data is not null) // within
|
||||
e.Effect = DragDropEffects.Move;
|
||||
|
||||
if (Drag.Info.DragDropInProgress)
|
||||
@@ -115,7 +115,7 @@ public void MouseMove(object? sender, MouseEventArgs e)
|
||||
return;
|
||||
|
||||
// Abort if there is no Pokémon in the given slot.
|
||||
if (pb.Image == null)
|
||||
if (pb.Image is null)
|
||||
return;
|
||||
bool encrypt = Control.ModifierKeys == Keys.Control;
|
||||
HandleMovePKM(pb, encrypt);
|
||||
@@ -217,7 +217,7 @@ private bool TryMakeDragDropPKM(PictureBox pb, ReadOnlySpan<byte> data, string n
|
||||
// Thread Blocks on DoDragDrop
|
||||
Drag.Info.CurrentPath = newfile;
|
||||
var result = pb.DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Copy);
|
||||
var external = Drag.Info.Destination == null || result != DragDropEffects.Link;
|
||||
var external = Drag.Info.Destination is null || result != DragDropEffects.Link;
|
||||
if (external || Drag.Info.SameLocation) // not dropped to another box slot, restore img
|
||||
{
|
||||
pb.Image = img;
|
||||
@@ -228,7 +228,7 @@ private bool TryMakeDragDropPKM(PictureBox pb, ReadOnlySpan<byte> data, string n
|
||||
|
||||
if (result == DragDropEffects.Copy) // viewed in tabs or cloned
|
||||
{
|
||||
if (Drag.Info.Destination == null) // apply 'view' highlight
|
||||
if (Drag.Info.Destination is null) // apply 'view' highlight
|
||||
Env.Slots.Get(Drag.Info.Source!.Slot);
|
||||
return false;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ private void HandleDropPKM(PictureBox pb, DragEventArgs? e, DropModifier mod)
|
||||
|
||||
var dest = Drag.Info.Destination;
|
||||
|
||||
if (Drag.Info.Source == null) // external source
|
||||
if (Drag.Info.Source is null) // external source
|
||||
{
|
||||
bool badDest = !dest!.CanWriteTo();
|
||||
if (!TryLoadFiles(files, e, badDest))
|
||||
@@ -289,14 +289,14 @@ private bool TryLoadFiles(ReadOnlySpan<string> files, DragEventArgs e, bool badD
|
||||
var sav = Drag.Info.Destination!.View.SAV;
|
||||
var path = files[0];
|
||||
var temp = FileUtil.GetSingleFromPath(path, sav);
|
||||
if (temp == null)
|
||||
if (temp is null)
|
||||
{
|
||||
Drag.RequestDD(this, e); // pass through
|
||||
return true; // treat as handled
|
||||
}
|
||||
|
||||
var pk = EntityConverter.ConvertToType(temp, sav.PKMType, out var result);
|
||||
if (pk == null)
|
||||
if (pk is null)
|
||||
{
|
||||
var c = result.GetDisplayString(temp, sav.PKMType);
|
||||
WinFormsUtil.Error(c);
|
||||
@@ -340,7 +340,7 @@ private bool TrySetPKMDestination(PictureBox pb, DropModifier mod)
|
||||
if (msg != WriteBlockedMessage.None)
|
||||
return false;
|
||||
|
||||
if (Drag.Info.Source != null)
|
||||
if (Drag.Info.Source is not null)
|
||||
TrySetPKMSource(mod);
|
||||
|
||||
// Copy from temp to destination slot.
|
||||
@@ -354,7 +354,7 @@ private bool TrySetPKMSource(DropModifier mod)
|
||||
{
|
||||
var info = Drag.Info;
|
||||
var dest = info.Destination;
|
||||
if (dest == null || mod == DropModifier.Clone)
|
||||
if (dest is null || mod == DropModifier.Clone)
|
||||
return false;
|
||||
|
||||
if (dest.IsEmpty() || mod == DropModifier.Overwrite)
|
||||
|
||||
@@ -11,7 +11,7 @@ public sealed class DragManager
|
||||
|
||||
public void SetCursor(Form? f, Cursor? z)
|
||||
{
|
||||
if (f != null)
|
||||
if (f is not null)
|
||||
f.Cursor = z;
|
||||
Info.Cursor = z;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public void Reset()
|
||||
Cursor = null;
|
||||
}
|
||||
|
||||
public bool SameLocation => (Destination != null) && (Source?.Equals(Destination) ?? false);
|
||||
public bool SameLocation => (Destination is not null) && (Source?.Equals(Destination) ?? false);
|
||||
|
||||
private bool SourceIsParty => Source?.Slot is SlotInfoParty;
|
||||
private bool DestinationIsParty => Destination?.Slot is SlotInfoParty;
|
||||
|
||||
@@ -26,7 +26,7 @@ public sealed class SlotHoverHandler : IDisposable
|
||||
public void Start(PictureBox pb, SlotTrackerImage lastSlot)
|
||||
{
|
||||
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
||||
if (view == null)
|
||||
if (view is null)
|
||||
throw new InvalidCastException(nameof(view));
|
||||
var data = view.GetSlotData(pb);
|
||||
var pk = data.Read(view.SAV);
|
||||
@@ -52,7 +52,7 @@ public void Start(PictureBox pb, SlotTrackerImage lastSlot)
|
||||
bg = Hover;
|
||||
}
|
||||
|
||||
if (orig != null)
|
||||
if (orig is not null)
|
||||
bg = ImageUtil.LayerImage(orig, bg, 0, 0);
|
||||
pb.BackgroundImage = LastSlot.CurrentBackground = bg;
|
||||
|
||||
@@ -61,7 +61,7 @@ public void Start(PictureBox pb, SlotTrackerImage lastSlot)
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (Slot != null)
|
||||
if (Slot is not null)
|
||||
{
|
||||
if (HoverWorker.Enabled)
|
||||
HoverWorker.Stop();
|
||||
|
||||
@@ -88,7 +88,7 @@ public ISlotInfo GetSlotData(PictureBox view)
|
||||
public int GetSlot(PictureBox sender)
|
||||
{
|
||||
var view = WinFormsUtil.GetUnderlyingControl<PictureBox>(sender);
|
||||
if (view == null)
|
||||
if (view is null)
|
||||
return -1;
|
||||
return slots.IndexOf(view);
|
||||
}
|
||||
|
||||
@@ -608,7 +608,7 @@ private void OpenFromPath(string path)
|
||||
private void OpenFile(byte[] input, string path, string ext)
|
||||
{
|
||||
var obj = FileUtil.GetSupportedFile(input, ext, C_SAV.SAV);
|
||||
if (obj != null && LoadFile(obj, path))
|
||||
if (obj is not null && LoadFile(obj, path))
|
||||
return;
|
||||
|
||||
WinFormsUtil.Error(GetHintInvalidFile(input, path),
|
||||
@@ -635,7 +635,7 @@ private static string GetHintInvalidFile(ReadOnlySpan<byte> input, string path)
|
||||
|
||||
private bool LoadFile(object? input, string path)
|
||||
{
|
||||
if (input == null)
|
||||
if (input is null)
|
||||
return false;
|
||||
|
||||
switch (input)
|
||||
@@ -664,7 +664,7 @@ private bool OpenPKM(PKM pk)
|
||||
var destType = C_SAV.SAV.PKMType;
|
||||
var tmp = EntityConverter.ConvertToType(pk, destType, out var c);
|
||||
Debug.WriteLine(c.GetDisplayString(pk, destType));
|
||||
if (tmp == null)
|
||||
if (tmp is null)
|
||||
return false;
|
||||
C_SAV.SAV.AdaptPKM(tmp);
|
||||
PKME_Tabs.PopulateFields(tmp);
|
||||
@@ -692,7 +692,7 @@ private bool OpenMysteryGift(MysteryGift tg, string path)
|
||||
var destType = C_SAV.SAV.PKMType;
|
||||
var pk = EntityConverter.ConvertToType(temp, destType, out var c);
|
||||
|
||||
if (pk == null)
|
||||
if (pk is null)
|
||||
{
|
||||
WinFormsUtil.Alert(c.GetDisplayString(temp, destType));
|
||||
return true;
|
||||
@@ -1175,7 +1175,7 @@ private void GetPreview(PictureBox pb, PKM? pk = null)
|
||||
pk ??= PreparePKM(false); // don't perform control loss click
|
||||
|
||||
var menu = dragout.ContextMenuStrip;
|
||||
if (menu != null)
|
||||
if (menu is not null)
|
||||
menu.Enabled = pk.Species != 0 || HaX; // Species
|
||||
|
||||
pb.Image = pk.Sprite(C_SAV.SAV);
|
||||
@@ -1211,7 +1211,7 @@ private static void Main_DragEnter(object? sender, DragEventArgs? e)
|
||||
return;
|
||||
if (e.AllowedEffect == (DragDropEffects.Copy | DragDropEffects.Link)) // external file
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
else if (e.Data != null) // within
|
||||
else if (e.Data is not null) // within
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public static class PluginLoader
|
||||
Debug.WriteLine(ex.Message);
|
||||
continue;
|
||||
}
|
||||
if (activate != null)
|
||||
if (activate is not null)
|
||||
yield return activate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public QR(Image qr, Image icon, PKM pk, params string[] lines)
|
||||
private void ResizeWindow()
|
||||
{
|
||||
var img = PB_QR.Image;
|
||||
if (img == null)
|
||||
if (img is null)
|
||||
return;
|
||||
splitContainer1.Height = splitContainer1.Panel1.Height + img.Height;
|
||||
splitContainer1.Width = img.Width;
|
||||
|
||||
@@ -116,7 +116,7 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc
|
||||
{
|
||||
Error("You have installed PKHeX incorrectly. Please ensure you have unzipped all files before running.");
|
||||
}
|
||||
else if (ex != null)
|
||||
else if (ex is not null)
|
||||
{
|
||||
var msg = GetErrorMessage(ex);
|
||||
ErrorWindow.ShowErrorDialog($"{msg}\nPKHeX must now close.", ex, false);
|
||||
|
||||
2
PKHeX.WinForms/Subforms/KChart.Designer.cs
generated
2
PKHeX.WinForms/Subforms/KChart.Designer.cs
generated
@@ -13,7 +13,7 @@ partial class KChart
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
if (disposing && (components is not null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public PropertyComparer(PropertyDescriptor property, ListSortDirection direction
|
||||
propertyDescriptor = property;
|
||||
Type comparerForPropertyType = typeof(Comparer<>).MakeGenericType(property.PropertyType);
|
||||
var ci = comparerForPropertyType.InvokeMember("Default", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.Public, null, null, null);
|
||||
comparer = ci == null ? new Comparer(CultureInfo.InvariantCulture) : (IComparer) ci;
|
||||
comparer = ci is null ? new Comparer(CultureInfo.InvariantCulture) : (IComparer) ci;
|
||||
SetListSortDirection(direction);
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ private void RunBatchEdit(StringInstructionSet[] sets, string source, string? de
|
||||
RunBatchEditSaveFile(sets, boxes: true);
|
||||
else if (RB_Party.Checked)
|
||||
RunBatchEditSaveFile(sets, party: true);
|
||||
else if (destination != null)
|
||||
else if (destination is not null)
|
||||
RunBatchEditFolder(sets, source, destination);
|
||||
finished = true;
|
||||
};
|
||||
@@ -269,7 +269,7 @@ private void TryProcess(string source, string destDir, IReadOnlyList<StringInstr
|
||||
|
||||
byte[] data = File.ReadAllBytes(source);
|
||||
_ = FileUtil.TryGetPKM(data, out var pk, fi.Extension, SAV);
|
||||
if (pk == null)
|
||||
if (pk is null)
|
||||
return;
|
||||
|
||||
var info = new SlotInfoFile(source);
|
||||
|
||||
@@ -135,7 +135,7 @@ private void PressKeyCell(object sender, KeyEventArgs e)
|
||||
return;
|
||||
|
||||
var row = dgv.CurrentRow;
|
||||
if (row == null)
|
||||
if (row is null)
|
||||
return;
|
||||
|
||||
// Toggle the checkbox of cell 0
|
||||
|
||||
@@ -13,7 +13,7 @@ partial class TrashEditor
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
if (disposing && (components is not null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ private void HideSpecifiedColumns(ReadOnlySpan<string> hide)
|
||||
if (prop.Length == 0)
|
||||
continue;
|
||||
var col = dgData.Columns[prop];
|
||||
if (col != null)
|
||||
if (col is not null)
|
||||
col.Visible = false;
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
|
||||
var content = dgData.GetClipboardContent();
|
||||
if (content == null)
|
||||
if (content is null)
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
|
||||
string data = content.GetText();
|
||||
|
||||
@@ -116,7 +116,7 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor)
|
||||
if (!z.IsFaulted)
|
||||
return;
|
||||
Invoke((MethodInvoker)(() => L_Count.Text = "Failed."));
|
||||
if (z.Exception == null)
|
||||
if (z.Exception is null)
|
||||
return;
|
||||
WinFormsUtil.Error("Loading database failed.", z.Exception.InnerException ?? new Exception(z.Exception.Message));
|
||||
});
|
||||
@@ -410,7 +410,7 @@ private static List<SlotCache> LoadPKMSaves(string pkmdb, SaveFile sav, List<Sea
|
||||
if (Main.Settings.EntityDb.FilterUnavailableSpecies)
|
||||
{
|
||||
var filter = GetFilterForSaveFile(sav);
|
||||
if (filter != null)
|
||||
if (filter is not null)
|
||||
result.RemoveAll(z => !filter(z.Entity));
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ private static List<SlotCache> LoadPKMSaves(string pkmdb, SaveFile sav, List<Sea
|
||||
private static void TryAddPKMsFromSaveFilePath(ConcurrentBag<SlotCache> dbTemp, string file)
|
||||
{
|
||||
var sav = SaveUtil.GetVariantSAV(file);
|
||||
if (sav == null)
|
||||
if (sav is null)
|
||||
{
|
||||
if (FileUtil.TryGetMemoryCard(file, out var mc))
|
||||
TryAddPKMsFromMemoryCard(dbTemp, mc, file);
|
||||
|
||||
@@ -256,9 +256,9 @@ private IEnumerable<IEncounterInfo> SearchDatabase(CancellationToken token)
|
||||
var versions = settings.GetVersions(SAV);
|
||||
var species = settings.Species == 0 ? GetFullRange(SAV.MaxSpeciesID) : [settings.Species];
|
||||
var results = GetAllSpeciesFormEncounters(species, SAV.Personal, versions, moves, pk, token);
|
||||
if (settings.SearchEgg != null)
|
||||
if (settings.SearchEgg is not null)
|
||||
results = results.Where(z => z.IsEgg == settings.SearchEgg);
|
||||
if (settings.SearchShiny != null)
|
||||
if (settings.SearchShiny is not null)
|
||||
results = results.Where(z => z.IsShiny == settings.SearchShiny);
|
||||
|
||||
// return filtered results
|
||||
@@ -333,9 +333,9 @@ private sealed class ReferenceComparer<T> : IEqualityComparer<T> where T : class
|
||||
{
|
||||
public bool Equals(T? x, T? y)
|
||||
{
|
||||
if (x == null)
|
||||
if (x is null)
|
||||
return false;
|
||||
if (y == null)
|
||||
if (y is null)
|
||||
return false;
|
||||
return RuntimeHelpers.GetHashCode(x).Equals(RuntimeHelpers.GetHashCode(y));
|
||||
}
|
||||
|
||||
@@ -128,11 +128,11 @@ private static IEnumerable<CustomFolderPath> GetUserPaths()
|
||||
private static IEnumerable<CustomFolderPath> GetConsolePaths(IEnumerable<string> drives)
|
||||
{
|
||||
var path3DS = SaveFinder.Get3DSLocation(drives);
|
||||
if (path3DS == null)
|
||||
if (path3DS is null)
|
||||
return [];
|
||||
|
||||
var root = Path.GetPathRoot(path3DS);
|
||||
if (root == null)
|
||||
if (root is null)
|
||||
return [];
|
||||
|
||||
var paths = SaveFinder.Get3DSBackupPaths(root);
|
||||
@@ -142,11 +142,11 @@ private static IEnumerable<CustomFolderPath> GetConsolePaths(IEnumerable<string>
|
||||
private static IEnumerable<CustomFolderPath> GetSwitchPaths(IEnumerable<string> drives)
|
||||
{
|
||||
var pathNX = SaveFinder.GetSwitchLocation(drives);
|
||||
if (pathNX == null)
|
||||
if (pathNX is null)
|
||||
return [];
|
||||
|
||||
var root = Path.GetPathRoot(pathNX);
|
||||
if (root == null)
|
||||
if (root is null)
|
||||
return [];
|
||||
|
||||
var paths = SaveFinder.GetSwitchBackupPaths(root);
|
||||
@@ -204,7 +204,7 @@ private ContextMenuStrip GetContextMenu(DataGridView dgv)
|
||||
private void ClickOpenFile(DataGridView dgv)
|
||||
{
|
||||
var sav = GetSaveFile(dgv);
|
||||
if (sav == null || !File.Exists(sav.FilePath))
|
||||
if (sav is null || !File.Exists(sav.FilePath))
|
||||
{
|
||||
WinFormsUtil.Alert(MsgFileLoadFail);
|
||||
return;
|
||||
@@ -216,7 +216,7 @@ private void ClickOpenFile(DataGridView dgv)
|
||||
private void ClickOpenFolder(DataGridView dgv)
|
||||
{
|
||||
var sav = GetSaveFile(dgv);
|
||||
if (sav == null || !File.Exists(sav.FilePath))
|
||||
if (sav is null || !File.Exists(sav.FilePath))
|
||||
{
|
||||
WinFormsUtil.Alert(MsgFileLoadFail);
|
||||
return;
|
||||
@@ -388,7 +388,7 @@ private static void ToggleRowVisibility(DataGridView dg, int column, ReadOnlySpa
|
||||
}
|
||||
var cell = row.Cells[column];
|
||||
var value = cell.Value?.ToString();
|
||||
if (value == null)
|
||||
if (value is null)
|
||||
{
|
||||
row.Visible = false;
|
||||
return;
|
||||
|
||||
@@ -134,7 +134,7 @@ private void ClickView(object sender, EventArgs e)
|
||||
return;
|
||||
var temp = Results[index].ConvertToPKM(SAV);
|
||||
var pk = EntityConverter.ConvertToType(temp, SAV.PKMType, out var c);
|
||||
if (pk == null)
|
||||
if (pk is null)
|
||||
{
|
||||
WinFormsUtil.Error(c.GetDisplayString(temp, SAV.PKMType));
|
||||
return;
|
||||
|
||||
@@ -275,7 +275,7 @@ private void ChangeStat1(object sender, EventArgs e)
|
||||
rb.Checked = false;
|
||||
|
||||
var bft = BFT[BFF[facility][1]];
|
||||
if (bft == null)
|
||||
if (bft is null)
|
||||
{
|
||||
CB_Stats2.Visible = false;
|
||||
}
|
||||
@@ -308,7 +308,7 @@ private void StatAddrControl(int SetValToSav = -2, bool SetSavToVal = false)
|
||||
|
||||
int BattleType = CB_Stats2.SelectedIndex;
|
||||
var bft = BFT[BFF[Facility][1]];
|
||||
if (bft == null)
|
||||
if (bft is null)
|
||||
BattleType = 0;
|
||||
else if (BattleType < 0)
|
||||
return;
|
||||
@@ -455,7 +455,7 @@ private void SaveBattleFrontier()
|
||||
private void BTN_Symbol_Click(object sender, EventArgs e)
|
||||
{
|
||||
var match = Array.Find(SymbolButtonA, z => z == sender);
|
||||
if (match == null)
|
||||
if (match is null)
|
||||
return;
|
||||
|
||||
var color = match.BackColor;
|
||||
@@ -475,7 +475,7 @@ private void LoadRecords()
|
||||
|
||||
CB_Record.SelectedIndexChanged += (_, _) =>
|
||||
{
|
||||
if (CB_Record.SelectedValue == null)
|
||||
if (CB_Record.SelectedValue is null)
|
||||
return;
|
||||
|
||||
var index = WinFormsUtil.GetIndex(CB_Record);
|
||||
@@ -487,7 +487,7 @@ private void LoadRecords()
|
||||
LoadRecordID(0);
|
||||
NUD_RecordValue.ValueChanged += (_, _) =>
|
||||
{
|
||||
if (CB_Record.SelectedValue == null)
|
||||
if (CB_Record.SelectedValue is null)
|
||||
return;
|
||||
|
||||
var index = WinFormsUtil.GetIndex(CB_Record);
|
||||
|
||||
@@ -86,7 +86,7 @@ private void ReadTree()
|
||||
|
||||
private void SaveTree()
|
||||
{
|
||||
if (Tree == null)
|
||||
if (Tree is null)
|
||||
return;
|
||||
|
||||
Tree.Time = (uint)NUD_Time.Value;
|
||||
|
||||
@@ -280,7 +280,7 @@ private void ToggleSeen(object sender, EventArgs e)
|
||||
if (editing)
|
||||
return;
|
||||
var lb = sender == B_GLeft ? LB_NGender : LB_Gender;
|
||||
if (lb == null || lb.SelectedIndex < 0)
|
||||
if (lb is null || lb.SelectedIndex < 0)
|
||||
{
|
||||
WinFormsUtil.Alert("No Gender selected.");
|
||||
return;
|
||||
@@ -299,7 +299,7 @@ private void MoveGender(object sender, EventArgs e)
|
||||
if (editing)
|
||||
return;
|
||||
var lb = LB_Gender;
|
||||
if (lb == null || lb.SelectedIndex < 0)
|
||||
if (lb is null || lb.SelectedIndex < 0)
|
||||
{
|
||||
WinFormsUtil.Alert("No Gender selected.");
|
||||
return;
|
||||
@@ -329,7 +329,7 @@ private void ToggleForm(object sender, EventArgs e)
|
||||
if (editing)
|
||||
return;
|
||||
var lb = sender == B_FLeft ? LB_NForm : LB_Form;
|
||||
if (lb == null || lb.SelectedIndex < 0)
|
||||
if (lb is null || lb.SelectedIndex < 0)
|
||||
{
|
||||
WinFormsUtil.Alert("No Form selected.");
|
||||
return;
|
||||
@@ -348,7 +348,7 @@ private void MoveForm(object sender, EventArgs e)
|
||||
if (editing)
|
||||
return;
|
||||
var lb = LB_Form;
|
||||
if (lb == null || lb.SelectedIndex < 0)
|
||||
if (lb is null || lb.SelectedIndex < 0)
|
||||
{
|
||||
WinFormsUtil.Alert("No Form selected.");
|
||||
return;
|
||||
|
||||
@@ -567,7 +567,7 @@ public static string GetSpeciesName(ushort species)
|
||||
|
||||
private void UpdateSlotValue(object sender, EventArgs e)
|
||||
{
|
||||
if (CurrentSlot == null)
|
||||
if (CurrentSlot is null)
|
||||
return;
|
||||
|
||||
if (sender == CB_Species)
|
||||
|
||||
@@ -202,7 +202,7 @@ private void ChangeBoxBackground(object sender, EventArgs e)
|
||||
private bool MoveItem(int direction)
|
||||
{
|
||||
// Checking selected item
|
||||
if (LB_BoxSelect.SelectedItem == null || LB_BoxSelect.SelectedIndex < 0)
|
||||
if (LB_BoxSelect.SelectedItem is null || LB_BoxSelect.SelectedIndex < 0)
|
||||
return false; // No selected item - nothing to do
|
||||
|
||||
// Calculate new index using move direction
|
||||
|
||||
@@ -270,7 +270,7 @@ private void ChangeIndexBase(object sender, EventArgs e)
|
||||
return;
|
||||
|
||||
var bdata = CurrentBase;
|
||||
if (bdata != null)
|
||||
if (bdata is not null)
|
||||
SaveCurrent(bdata);
|
||||
|
||||
ResetLoadNew();
|
||||
@@ -466,7 +466,7 @@ private void B_Save_Click(object sender, EventArgs e)
|
||||
SAV.Records.SetRecord(080, (int)flags);
|
||||
|
||||
var bdata = CurrentBase;
|
||||
if (bdata != null)
|
||||
if (bdata is not null)
|
||||
SaveCurrent(bdata);
|
||||
|
||||
Origin.CopyChangesFrom(SAV);
|
||||
|
||||
@@ -119,7 +119,7 @@ private void GetTextBoxes()
|
||||
CB_AlolaTime.SelectedValue = (int)timeA;
|
||||
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
if (CB_AlolaTime.SelectedValue == null)
|
||||
if (CB_AlolaTime.SelectedValue is null)
|
||||
CB_AlolaTime.Enabled = false;
|
||||
|
||||
NUD_M.Value = SAV.Situation.M;
|
||||
|
||||
@@ -41,7 +41,7 @@ private void Main_DragEnter(object? sender, DragEventArgs? e)
|
||||
return;
|
||||
if (e.AllowedEffect == (DragDropEffects.Copy | DragDropEffects.Link)) // external file
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
else if (e.Data != null) // within
|
||||
else if (e.Data is not null) // within
|
||||
e.Effect = DragDropEffects.Move;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user