Expand shorthand parameters

int i => int index, or whatever the value is representing.
This commit is contained in:
Kurt 2021-08-05 20:33:25 -07:00
parent a1f5c76790
commit 5c472a400d
27 changed files with 118 additions and 120 deletions

View file

@ -17,15 +17,15 @@ namespace PKHeX.Core
public int OT_Feeling { get; set; } public int OT_Feeling { get; set; }
public int OT_Intensity { get; set; } public int OT_Intensity { get; set; }
public EncounterTrade8(GameVersion game, int species, int level, int m, int a, int f, int i) : base(game) public EncounterTrade8(GameVersion game, int species, int level, int memory, int arg, int feel, int intensity) : base(game)
{ {
Species = species; Species = species;
Level = level; Level = level;
OT_Memory = m; OT_Memory = memory;
OT_TextVar = a; OT_TextVar = arg;
OT_Feeling = f; OT_Feeling = feel;
OT_Intensity = i; OT_Intensity = intensity;
} }
public override bool IsMatchExact(PKM pkm, DexLevel evo) public override bool IsMatchExact(PKM pkm, DexLevel evo)

View file

@ -16,7 +16,7 @@ namespace PKHeX.Core
return s; return s;
} }
private static string RestrictionSetName(int i) => $"mgrestrict{i}.pkl"; private static string RestrictionSetName(int generation) => $"mgrestrict{generation}.pkl";
private static Dictionary<int, MysteryGiftRestriction> GetRestriction(int generation) private static Dictionary<int, MysteryGiftRestriction> GetRestriction(int generation)
{ {

View file

@ -95,11 +95,11 @@ namespace PKHeX.Core
/// </summary> /// </summary>
public static string GetSource(object parse, int generation, int index) public static string GetSource(object parse, int generation, int index)
{ {
static string GetLine<T>(T[] arr, Func<T, string> act, int i) static string GetLine<T>(T[] arr, Func<T, string> act, int index)
{ {
if (i >= arr.Length) if ((uint)index >= arr.Length)
return LMoveSourceEmpty; return LMoveSourceEmpty;
return act(arr[i]); return act(arr[index]);
} }
return generation switch return generation switch

View file

@ -78,9 +78,9 @@ namespace PKHeX.Core
return result; return result;
} }
private int GetOffsetPKMData(int base_ofs, int i) => base_ofs + (Entry_Size * i); private int GetOffsetPKMData(int base_ofs, int index) => base_ofs + (Entry_Size * index);
private int GetOffsetPKMOT(int base_ofs, int i) => GetOffsetPKMData(base_ofs, Capacity) + (StringLength * i); private int GetOffsetPKMOT(int base_ofs, int index) => GetOffsetPKMData(base_ofs, Capacity) + (StringLength * index);
private int GetOffsetPKMNickname(int base_ofs, int i) => GetOffsetPKMOT(base_ofs, Capacity) + (StringLength * i); private int GetOffsetPKMNickname(int base_ofs, int index) => GetOffsetPKMOT(base_ofs, Capacity) + (StringLength * index);
private static int GetStringLength(bool jp) => jp ? GBPKML.StringLengthJapanese : GBPKML.StringLengthNotJapan; private static int GetStringLength(bool jp) => jp ? GBPKML.StringLengthJapanese : GBPKML.StringLengthNotJapan;
protected bool IsFormatParty => IsCapacityPartyFormat((PokeListType)Capacity); protected bool IsFormatParty => IsCapacityPartyFormat((PokeListType)Capacity);
@ -131,26 +131,26 @@ namespace PKHeX.Core
return Data; return Data;
} }
private T GetEntry(int base_ofs, int i) private T GetEntry(int base_ofs, int index)
{ {
int pkOfs = GetOffsetPKMData(base_ofs, i); int pkOfs = GetOffsetPKMData(base_ofs, index);
int otOfs = GetOffsetPKMOT(base_ofs, i); int otOfs = GetOffsetPKMOT(base_ofs, index);
int nkOfs = GetOffsetPKMNickname(base_ofs, i); int nkOfs = GetOffsetPKMNickname(base_ofs, index);
var dat = Data.Slice(pkOfs, Entry_Size); var dat = Data.Slice(pkOfs, Entry_Size);
var otname = Data.Slice(otOfs, StringLength); var otname = Data.Slice(otOfs, StringLength);
var nick = Data.Slice(nkOfs, StringLength); var nick = Data.Slice(nkOfs, StringLength);
return GetEntry(dat, otname, nick, Data[1 + i] == 0xFD); return GetEntry(dat, otname, nick, Data[1 + index] == 0xFD);
} }
private void SetEntry(int base_ofs, int i) private void SetEntry(int base_ofs, int index)
{ {
int pkOfs = GetOffsetPKMData(base_ofs, i); int pkOfs = GetOffsetPKMData(base_ofs, index);
int otOfs = GetOffsetPKMOT(base_ofs, i); int otOfs = GetOffsetPKMOT(base_ofs, index);
int nkOfs = GetOffsetPKMNickname(base_ofs, i); int nkOfs = GetOffsetPKMNickname(base_ofs, index);
var pk = Pokemon[i]; var pk = Pokemon[index];
Array.Copy(pk.Data, 0, Data, pkOfs, Entry_Size); Array.Copy(pk.Data, 0, Data, pkOfs, Entry_Size);
pk.RawOT.CopyTo(Data, otOfs); pk.RawOT.CopyTo(Data, otOfs);
pk.RawNickname.CopyTo(Data, nkOfs); pk.RawNickname.CopyTo(Data, nkOfs);

View file

@ -72,14 +72,14 @@ namespace PKHeX.Core
return text[(8 + 3 + 4 + 1)..]; return text[(8 + 3 + 4 + 1)..];
} }
private string GetBlockHint(SCBlock z, int i) private string GetBlockHint(SCBlock z, int index)
{ {
var blockName = GetBlockName(z, out _); var blockName = GetBlockName(z, out _);
var isBool = z.Type.IsBoolean(); var isBool = z.Type.IsBoolean();
var type = (isBool ? "Bool" : z.Type.ToString()); var type = (isBool ? "Bool" : z.Type.ToString());
if (blockName != null) if (blockName != null)
return $"*{type} {blockName}"; return $"*{type} {blockName}";
var result = $"{z.Key:X8} - {i:0000} {type}"; var result = $"{z.Key:X8} - {index:0000} {type}";
if (z.Type is SCTypeCode.Object or SCTypeCode.Array) if (z.Type is SCTypeCode.Object or SCTypeCode.Array)
result += $" 0x{z.Data.Length:X3}"; result += $" 0x{z.Data.Length:X3}";
else if (!isBool) else if (!isBool)

View file

@ -175,11 +175,11 @@ namespace PKHeX.Core
return outData; return outData;
} }
private int GetBoxRawDataOffset(int i) private int GetBoxRawDataOffset(int box)
{ {
if (i < BoxCount / 2) if (box < BoxCount / 2)
return 0x4000 + (i * SIZE_STOREDBOX); return 0x4000 + (box * SIZE_STOREDBOX);
return 0x6000 + ((i - (BoxCount / 2)) * SIZE_STOREDBOX); return 0x6000 + ((box - (BoxCount / 2)) * SIZE_STOREDBOX);
} }
// Configuration // Configuration

View file

@ -71,26 +71,26 @@ namespace PKHeX.Core
ClearBoxes(); ClearBoxes();
} }
protected override bool GetIsBoxChecksumValid(int i) protected override bool GetIsBoxChecksumValid(int box)
{ {
var boxOfs = GetBoxOffset(i) - ListHeaderSize; var boxOfs = GetBoxOffset(box) - ListHeaderSize;
var size = BoxSize - 2; var size = BoxSize - 2;
var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size)); var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size));
var actual = BigEndian.ToUInt16(Data, boxOfs + size); var actual = BigEndian.ToUInt16(Data, boxOfs + size);
return chk == actual; return chk == actual;
} }
protected override void SetBoxChecksum(int i) protected override void SetBoxChecksum(int box)
{ {
var boxOfs = GetBoxOffset(i) - ListHeaderSize; var boxOfs = GetBoxOffset(box) - ListHeaderSize;
var size = BoxSize - 2; var size = BoxSize - 2;
var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size)); var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size));
BigEndian.GetBytes(chk).CopyTo(Data, boxOfs + size); BigEndian.GetBytes(chk).CopyTo(Data, boxOfs + size);
} }
protected override void SetBoxMetadata(int i) protected override void SetBoxMetadata(int box)
{ {
var bdata = GetBoxOffset(i); var bdata = GetBoxOffset(box);
// Set box count // Set box count
int count = 0; int count = 0;

View file

@ -56,24 +56,24 @@ namespace PKHeX.Core
ClearBoxes(); ClearBoxes();
} }
protected override bool GetIsBoxChecksumValid(int i) protected override bool GetIsBoxChecksumValid(int box)
{ {
var boxOfs = GetBoxOffset(i) - ListHeaderSize; var boxOfs = GetBoxOffset(box) - ListHeaderSize;
const int size = BoxSizeJ - 2; const int size = BoxSizeJ - 2;
var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size)); var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size));
var actual = BigEndian.ToUInt16(Data, boxOfs + size); var actual = BigEndian.ToUInt16(Data, boxOfs + size);
return chk == actual; return chk == actual;
} }
protected override void SetBoxChecksum(int i) protected override void SetBoxChecksum(int box)
{ {
var boxOfs = GetBoxOffset(i) - ListHeaderSize; var boxOfs = GetBoxOffset(box) - ListHeaderSize;
const int size = BoxSizeJ - 2; const int size = BoxSizeJ - 2;
var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size)); var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size));
BigEndian.GetBytes(chk).CopyTo(Data, boxOfs + size); BigEndian.GetBytes(chk).CopyTo(Data, boxOfs + size);
} }
protected override void SetBoxMetadata(int i) protected override void SetBoxMetadata(int box)
{ {
// Not implemented // Not implemented
} }

View file

@ -69,18 +69,18 @@ namespace PKHeX.Core
ClearBoxes(); ClearBoxes();
} }
protected override bool GetIsBoxChecksumValid(int i) protected override bool GetIsBoxChecksumValid(int box)
{ {
var boxOfs = GetBoxOffset(i) - ListHeaderSizeBox; var boxOfs = GetBoxOffset(box) - ListHeaderSizeBox;
var size = BoxSize - 2; var size = BoxSize - 2;
var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size)); var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size));
var actual = BigEndian.ToUInt16(Data, boxOfs + size); var actual = BigEndian.ToUInt16(Data, boxOfs + size);
return chk == actual; return chk == actual;
} }
protected override void SetBoxMetadata(int i) protected override void SetBoxMetadata(int box)
{ {
var bdata = GetBoxOffset(i); var bdata = GetBoxOffset(box);
// Set box count // Set box count
int count = 0; int count = 0;
@ -105,9 +105,9 @@ namespace PKHeX.Core
} }
} }
protected override void SetBoxChecksum(int i) protected override void SetBoxChecksum(int box)
{ {
var boxOfs = GetBoxOffset(i) - ListHeaderSizeBox; var boxOfs = GetBoxOffset(box) - ListHeaderSizeBox;
var size = BoxSize - 2; var size = BoxSize - 2;
var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size)); var chk = Checksums.CheckSum16(new ReadOnlySpan<byte>(Data, boxOfs, size));
BigEndian.GetBytes(chk).CopyTo(Data, boxOfs + size); BigEndian.GetBytes(chk).CopyTo(Data, boxOfs + size);

View file

@ -555,9 +555,9 @@ namespace PKHeX.Core
protected abstract int MailOffset { get; } protected abstract int MailOffset { get; }
public int GetMailOffset(int index) => (index * Mail3.SIZE) + MailOffset; public int GetMailOffset(int index) => (index * Mail3.SIZE) + MailOffset;
public Mail GetMail(int i) public Mail GetMail(int mailIndex)
{ {
var ofs = GetMailOffset(i); var ofs = GetMailOffset(mailIndex);
var data = Large.Slice(ofs, Mail3.SIZE); var data = Large.Slice(ofs, Mail3.SIZE);
return new Mail3(data, ofs, Japanese); return new Mail3(data, ofs, Japanese);
} }

View file

@ -534,9 +534,9 @@ namespace PKHeX.Core
public byte[] GetMailData(int ofs) => General.Slice(ofs, Mail4.SIZE); public byte[] GetMailData(int ofs) => General.Slice(ofs, Mail4.SIZE);
public Mail4 GetMail(int i) public Mail4 GetMail(int mailIndex)
{ {
int ofs = GetMailOffset(i); int ofs = GetMailOffset(mailIndex);
return new Mail4(GetMailData(ofs), ofs); return new Mail4(GetMailData(ofs), ofs);
} }
} }

View file

@ -220,8 +220,8 @@ namespace PKHeX.Core
} }
// Apricorn Pouch // Apricorn Pouch
public int GetApricornCount(int i) => General[0xE558 + i]; public int GetApricornCount(int index) => General[0xE558 + index];
public void SetApricornCount(int i, int count) => General[0xE558 + i] = (byte)count; public void SetApricornCount(int index, int count) => General[0xE558 + index] = (byte)count;
// Pokewalker // Pokewalker
public const int WalkerPair = 0xE5E0; public const int WalkerPair = 0xE5E0;

View file

@ -210,9 +210,9 @@ namespace PKHeX.Core
public byte[] GetMailData(int offset) => GetData(offset, Mail5.SIZE); public byte[] GetMailData(int offset) => GetData(offset, Mail5.SIZE);
public int GetBattleBoxSlot(int slot) => BattleBoxOffset + (slot * SIZE_STORED); public int GetBattleBoxSlot(int slot) => BattleBoxOffset + (slot * SIZE_STORED);
public Mail GetMail(int i) public Mail GetMail(int mailIndex)
{ {
int ofs = GetMailOffset(i); int ofs = GetMailOffset(mailIndex);
var data = GetMailData(ofs); var data = GetMailData(ofs);
return new Mail5(data, ofs); return new Mail5(data, ofs);
} }

View file

@ -48,10 +48,10 @@
public sealed override void SetBoxName(int box, string value) { } public sealed override void SetBoxName(int box, string value) { }
public sealed override bool ChecksumsValid => GetBoxChecksumsValid(); public sealed override bool ChecksumsValid => GetBoxChecksumsValid();
public sealed override string ChecksumInfo => ChecksumsValid ? "Checksum valid." : "Checksum invalid"; public sealed override string ChecksumInfo => ChecksumsValid ? "Checksum valid." : "Checksum invalid";
protected abstract void SetBoxChecksum(int i); protected abstract void SetBoxChecksum(int box);
protected abstract bool GetIsBoxChecksumValid(int i); protected abstract bool GetIsBoxChecksumValid(int box);
protected sealed override void SetChecksums() => SetBoxChecksums(); protected sealed override void SetChecksums() => SetBoxChecksums();
protected abstract void SetBoxMetadata(int i); protected abstract void SetBoxMetadata(int box);
protected void SetBoxChecksums() protected void SetBoxChecksums()
{ {

View file

@ -290,9 +290,9 @@ namespace PKHeX.Core
return true; return true;
} }
private bool IsPartySlotNotEggOrEmpty(int i) private bool IsPartySlotNotEggOrEmpty(int index)
{ {
var slot = GetPartySlotAtIndex(i); var slot = GetPartySlotAtIndex(index);
return !slot.IsEgg && slot.Species != 0; return !slot.IsEgg && slot.Species != 0;
} }

View file

@ -15,19 +15,15 @@ namespace PKHeX.Core
int eCount = data.Length/SIZE_ENTRY; int eCount = data.Length/SIZE_ENTRY;
Entries = new ShadowInfoEntryXD[eCount]; Entries = new ShadowInfoEntryXD[eCount];
for (int i = 0; i < eCount; i++) for (int i = 0; i < eCount; i++)
{ Entries[i] = GetEntry(data, i);
var entry = GetEntry(data, i);
Entries[i] = entry;
}
} }
public ShadowInfoTableXD() : this(new byte[SIZE_ENTRY * MaxCount]) { } public ShadowInfoTableXD() : this(new byte[SIZE_ENTRY * MaxCount]) { }
private static ShadowInfoEntryXD GetEntry(byte[] data, int i) private static ShadowInfoEntryXD GetEntry(byte[] data, int index)
{ {
var d = data.Slice(i * SIZE_ENTRY, SIZE_ENTRY); var slice = data.Slice(index * SIZE_ENTRY, SIZE_ENTRY);
var entry = new ShadowInfoEntryXD(d); return new ShadowInfoEntryXD(slice);
return entry;
} }
public byte[] Write() => Entries.SelectMany(entry => entry.Data).Take(MaxLength).ToArray(); public byte[] Write() => Entries.SelectMany(entry => entry.Data).Take(MaxLength).ToArray();

View file

@ -19,8 +19,8 @@ namespace PKHeX.Core
Offset = offset; Offset = offset;
} }
private int GetMemberOffset(int i) => Offset + (i * HallFame3PKM.SIZE); private int GetMemberOffset(int index) => Offset + (index * HallFame3PKM.SIZE);
private HallFame3PKM GetMember(int i) => new(Parent, GetMemberOffset(i), Japanese); private HallFame3PKM GetMember(int index) => new(Parent, GetMemberOffset(index), Japanese);
public HallFame3PKM[] Team public HallFame3PKM[] Team
{ {

View file

@ -11,10 +11,10 @@ namespace PKHeX.Core
private const int O_Level = 0x3C; private const int O_Level = 0x3C;
private const int O_EV = 0x42; private const int O_EV = 0x42;
private static int GetOffsetPID(int i) => O_PID + (i * 4); private static int GetOffsetPID(int index) => O_PID + (index * 4);
private static int GetOffsetMove(int i, int move) => O_Moves + (i * 8) + (move * 2); private static int GetOffsetMove(int index, int move) => O_Moves + (index * 8) + (move * 2);
private static int GetOffsetSpecies(int i) => O_Species + (i * 2); private static int GetOffsetSpecies(int index) => O_Species + (index * 2);
private static int GetOffsetItem(int i) => O_Item + (i * 2); private static int GetOffsetItem(int index) => O_Item + (index * 2);
public readonly SecretBase3PKM[] Team; public readonly SecretBase3PKM[] Team;
private readonly byte[] Data; private readonly byte[] Data;
@ -34,34 +34,34 @@ namespace PKHeX.Core
return Data; return Data;
} }
private SecretBase3PKM GetPKM(int i) private SecretBase3PKM GetPKM(int index)
{ {
return new() return new()
{ {
PID = BitConverter.ToUInt32(Data, GetOffsetPID(i)), PID = BitConverter.ToUInt32(Data, GetOffsetPID(index)),
Species = BitConverter.ToUInt16(Data, GetOffsetSpecies(i)), Species = BitConverter.ToUInt16(Data, GetOffsetSpecies(index)),
HeldItem = BitConverter.ToUInt16(Data, GetOffsetItem(i)), HeldItem = BitConverter.ToUInt16(Data, GetOffsetItem(index)),
Move1 = BitConverter.ToUInt16(Data, GetOffsetMove(i, 0)), Move1 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 0)),
Move2 = BitConverter.ToUInt16(Data, GetOffsetMove(i, 1)), Move2 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 1)),
Move3 = BitConverter.ToUInt16(Data, GetOffsetMove(i, 2)), Move3 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 2)),
Move4 = BitConverter.ToUInt16(Data, GetOffsetMove(i, 3)), Move4 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 3)),
Level = Data[O_Level + i], Level = Data[O_Level + index],
EVAll = Data[O_EV + i], EVAll = Data[O_EV + index],
}; };
} }
private void SetPKM(int i) private void SetPKM(int index)
{ {
var pk = Team[i]; var pk = Team[index];
BitConverter.GetBytes(pk.PID).CopyTo(Data, GetOffsetPID(i)); BitConverter.GetBytes(pk.PID).CopyTo(Data, GetOffsetPID(index));
BitConverter.GetBytes((ushort)pk.Species).CopyTo(Data, GetOffsetSpecies(i)); BitConverter.GetBytes((ushort)pk.Species).CopyTo(Data, GetOffsetSpecies(index));
BitConverter.GetBytes((ushort)pk.HeldItem).CopyTo(Data, GetOffsetItem(i)); BitConverter.GetBytes((ushort)pk.HeldItem).CopyTo(Data, GetOffsetItem(index));
BitConverter.GetBytes((ushort)pk.Move1).CopyTo(Data, GetOffsetMove(i, 0)); BitConverter.GetBytes((ushort)pk.Move1).CopyTo(Data, GetOffsetMove(index, 0));
BitConverter.GetBytes((ushort)pk.Move2).CopyTo(Data, GetOffsetMove(i, 1)); BitConverter.GetBytes((ushort)pk.Move2).CopyTo(Data, GetOffsetMove(index, 1));
BitConverter.GetBytes((ushort)pk.Move3).CopyTo(Data, GetOffsetMove(i, 2)); BitConverter.GetBytes((ushort)pk.Move3).CopyTo(Data, GetOffsetMove(index, 2));
BitConverter.GetBytes((ushort)pk.Move4).CopyTo(Data, GetOffsetMove(i, 3)); BitConverter.GetBytes((ushort)pk.Move4).CopyTo(Data, GetOffsetMove(index, 3));
Data[O_Level + i] = (byte) pk.Level; Data[O_Level + index] = (byte)pk.Level;
Data[O_EV + i] = (byte) pk.EVAll; Data[O_EV + index] = (byte)pk.EVAll;
} }
} }
} }

View file

@ -97,8 +97,8 @@ namespace PKHeX.Core
set => ConfigValue = ((ConfigValue & ~0xF0) | SetLanguageID(value) << 4); set => ConfigValue = ((ConfigValue & ~0xF0) | SetLanguageID(value) << 4);
} }
private static int GetLanguageID(int i) => i >= (int)LanguageID.UNUSED_6 ? i + 1 : i; // sets langBank to LanguageID private static int GetLanguageID(int rawValue) => rawValue >= (int)LanguageID.UNUSED_6 ? rawValue + 1 : rawValue; // sets langBank to LanguageID
private static int SetLanguageID(int i) => i > (int)LanguageID.UNUSED_6 ? i - 1 : i; // sets LanguageID to langBank private static int SetLanguageID(int rawValue) => rawValue > (int)LanguageID.UNUSED_6 ? rawValue - 1 : rawValue; // sets LanguageID to langBank
public enum BattleAnimationSetting public enum BattleAnimationSetting
{ {

View file

@ -69,8 +69,8 @@ namespace PKHeX.Core
set => ConfigValue = ((ConfigValue & ~0xF0) | SetLanguageID(value) << 4); set => ConfigValue = ((ConfigValue & ~0xF0) | SetLanguageID(value) << 4);
} }
private static int GetLanguageID(int i) => i >= (int)LanguageID.UNUSED_6 ? i + 1 : i; // sets langBank to LanguageID private static int GetLanguageID(int rawValue) => rawValue >= (int)LanguageID.UNUSED_6 ? rawValue + 1 : rawValue; // sets langBank to LanguageID
private static int SetLanguageID(int i) => i > (int)LanguageID.UNUSED_6 ? i - 1 : i; // sets LanguageID to langBank private static int SetLanguageID(int rawValue) => rawValue > (int)LanguageID.UNUSED_6 ? rawValue - 1 : rawValue; // sets LanguageID to langBank
public enum BattleAnimationSetting public enum BattleAnimationSetting
{ {

View file

@ -50,8 +50,8 @@ namespace PKHeX.Core
set => ConfigValue = ((ConfigValue & ~0xF0) | SetLanguageID(value) << 4); set => ConfigValue = ((ConfigValue & ~0xF0) | SetLanguageID(value) << 4);
} }
private static int GetLanguageID(int i) => i >= (int) LanguageID.UNUSED_6 ? i + 1 : i; // sets langBank to LanguageID private static int GetLanguageID(int rawValue) => rawValue >= (int) LanguageID.UNUSED_6 ? rawValue + 1 : rawValue; // sets langBank to LanguageID
private static int SetLanguageID(int i) => i > (int) LanguageID.UNUSED_6 ? i - 1 : i; // sets LanguageID to langBank private static int SetLanguageID(int rawValue) => rawValue > (int) LanguageID.UNUSED_6 ? rawValue - 1 : rawValue; // sets LanguageID to langBank
public enum BattleAnimationSetting public enum BattleAnimationSetting
{ {

View file

@ -92,11 +92,11 @@ namespace PKHeX.Core
return false; return false;
} }
public bool GetSeen(int species, int i) => GetFlag(OFS_SEEN + (i * BitSeenSize), species - 1); public bool GetSeen(int species, int bitRegion) => GetFlag(OFS_SEEN + (bitRegion * BitSeenSize), species - 1);
public void SetSeen(int species, int i, bool value) => SetFlag(OFS_SEEN + (i * BitSeenSize), species - 1, value); public void SetSeen(int species, int bitRegion, bool value) => SetFlag(OFS_SEEN + (bitRegion * BitSeenSize), species - 1, value);
public bool GetDisplayed(int bit, int i) => GetFlag(OFS_SEEN + ((i + 4) * BitSeenSize), bit); public bool GetDisplayed(int bit, int bitRegion) => GetFlag(OFS_SEEN + ((bitRegion + 4) * BitSeenSize), bit);
public void SetDisplayed(int bit, int i, bool value) => SetFlag(OFS_SEEN + ((i + 4) * BitSeenSize), bit, value); public void SetDisplayed(int bit, int bitRegion, bool value) => SetFlag(OFS_SEEN + ((bitRegion + 4) * BitSeenSize), bit, value);
public bool GetLanguageFlag(int bit, int lang) => GetFlag(PokeDexLanguageFlags, (bit * DexLangIDCount) + lang); public bool GetLanguageFlag(int bit, int lang) => GetFlag(PokeDexLanguageFlags, (bit * DexLangIDCount) + lang);
public void SetLanguageFlag(int bit, int lang, bool value) => SetFlag(PokeDexLanguageFlags, (bit * DexLangIDCount) + lang, value); public void SetLanguageFlag(int bit, int lang, bool value) => SetFlag(PokeDexLanguageFlags, (bit * DexLangIDCount) + lang, value);

View file

@ -228,12 +228,12 @@ namespace PKHeX.WinForms
mi.Invoke(); mi.Invoke();
} }
private void SetProgressBar(int i) private void SetProgressBar(int position)
{ {
if (PB_Show.InvokeRequired) if (PB_Show.InvokeRequired)
PB_Show.Invoke((MethodInvoker)(() => PB_Show.Value = i)); PB_Show.Invoke((MethodInvoker)(() => PB_Show.Value = position));
else else
PB_Show.Value = i; PB_Show.Value = position;
} }
// Mass Editing // Mass Editing

View file

@ -356,9 +356,9 @@ namespace PKHeX.WinForms
cm.ResumeBinding(); cm.ResumeBinding();
} }
private static void ToggleRowVisibility(DataGridView dg, int column, string text, int i) private static void ToggleRowVisibility(DataGridView dg, int column, string text, int rowIndex)
{ {
var row = dg.Rows[i]; var row = dg.Rows[rowIndex];
if (text.Length == 0 || column < 0) if (text.Length == 0 || column < 0)
{ {
row.Visible = true; row.Visible = true;

View file

@ -30,7 +30,7 @@ namespace PKHeX.WinForms
Updating = false; Updating = false;
} }
private string GetPoffinText(int i) => $"{i + 1:000} - {Case.Poffins[i].Type.ToString().Replace('_', '-')}"; private string GetPoffinText(int index) => $"{index + 1:000} - {Case.Poffins[index].Type.ToString().Replace('_', '-')}";
public void Save() public void Save()
{ {
@ -38,24 +38,24 @@ namespace PKHeX.WinForms
Case.Save(); Case.Save();
} }
private void SaveIndex(int i) private void SaveIndex(int index)
{ {
// do nothing, propertygrid handles everything // do nothing, propertygrid handles everything
if (i < 0) if (index < 0)
return; return;
Updating = true; Updating = true;
LB_Poffins.Items[i] = GetPoffinText(i); LB_Poffins.Items[index] = GetPoffinText(index);
Updating = false; Updating = false;
} }
private void LoadIndex(int i) private void LoadIndex(int index)
{ {
if (i < 0) if (index < 0)
{ {
LB_Poffins.SelectedIndex = 0; LB_Poffins.SelectedIndex = 0;
return; return;
} }
PG_Poffins.SelectedObject = Case.Poffins[i]; PG_Poffins.SelectedObject = Case.Poffins[index];
} }
private void LB_Poffins_SelectedIndexChanged(object sender, EventArgs e) private void LB_Poffins_SelectedIndexChanged(object sender, EventArgs e)

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using PKHeX.Core; using PKHeX.Core;

View file

@ -224,10 +224,13 @@ namespace PKHeX.WinForms
}; };
} }
private int GetColorCount(int i) => private int GetColorCount(int type)
i >= 0 && i < RES_FacilityColor.Length - (SAV is SAV7USUM ? 0 : 1) {
? RES_FacilityColor[i].Length - 1 var colors = RES_FacilityColor;
: 3; if (type >= 0 && type < colors.Length - (SAV is SAV7USUM ? 0 : 1))
return colors[type].Length - 1;
return 3;
}
private void LoadFacility() private void LoadFacility()
{ {