mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-19 08:39:31 -05:00
Minor simplifications
Use "SetData" method to automatically apply the Edited flag Use appropriate method for CopyTo simplify expressions a tad
This commit is contained in:
@@ -791,8 +791,7 @@ protected override bool[] MysteryGiftReceivedFlags
|
||||
data[i >> 3] |= (byte)(1 << (i & 7));
|
||||
}
|
||||
|
||||
data.CopyTo(Data, WondercardFlags);
|
||||
Edited = true;
|
||||
SetData(data, WondercardFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1302,6 +1301,13 @@ public override byte[] SetString(string value, int maxLength, int PadToSize = 0,
|
||||
public byte[] SealCase { get => GetData(Seal, (int) Seal4.MAX); set => SetData(value, Seal); }
|
||||
public byte GetSealCount(Seal4 id) => Data[Seal + (int)id];
|
||||
public byte SetSealCount(Seal4 id, byte count) => Data[Seal + (int)id] = Math.Min(SealMaxCount, count);
|
||||
public void SetAllSeals(byte count, bool unreleased = false) => Enumerable.Repeat(Math.Min(SealMaxCount, count), (int)(unreleased ? Seal4.MAX : Seal4.MAXLEGAL)).CopyTo(Data, Seal);
|
||||
|
||||
public void SetAllSeals(byte count, bool unreleased = false)
|
||||
{
|
||||
var sealIndexCount = (int)(unreleased ? Seal4.MAX : Seal4.MAXLEGAL);
|
||||
var val = Math.Min(count, SealMaxCount);
|
||||
for (int i = 0; i < sealIndexCount; i++)
|
||||
Data[Seal + i] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public override string GetBoxName(int box)
|
||||
{
|
||||
if (box >= BoxCount)
|
||||
return string.Empty;
|
||||
return Util.TrimFromFFFF(Encoding.Unicode.GetString(Data, PCLayout + (0x28 * box) + 4, 0x28));
|
||||
return Util.TrimFromFFFF(Encoding.Unicode.GetString(Data, GetBoxNameOffset(box), 0x28));
|
||||
}
|
||||
|
||||
public override void SetBoxName(int box, string value)
|
||||
@@ -235,10 +235,12 @@ public override void SetBoxName(int box, string value)
|
||||
if (value.Length > 38)
|
||||
return;
|
||||
value += '\uFFFF';
|
||||
Encoding.Unicode.GetBytes(value.PadRight(0x14, '\0')).CopyTo(Data, PCLayout + (0x28 * box) + 4);
|
||||
Edited = true;
|
||||
var data = Encoding.Unicode.GetBytes(value.PadRight(0x14, '\0'));
|
||||
SetData(data, GetBoxNameOffset(box));
|
||||
}
|
||||
|
||||
private int GetBoxNameOffset(int box) => PCLayout + (0x28 * box) + 4;
|
||||
|
||||
protected override int GetBoxWallpaperOffset(int box)
|
||||
{
|
||||
return PCLayout + 0x3C4 + box;
|
||||
|
||||
@@ -990,8 +990,7 @@ protected override bool[] MysteryGiftReceivedFlags
|
||||
data[i >> 3] |= (byte)(1 << (i & 7));
|
||||
}
|
||||
|
||||
data.CopyTo(Data, WondercardFlags);
|
||||
Edited = true;
|
||||
SetData(data, WondercardFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1056,9 +1055,7 @@ private void SetWC6(MysteryGift wc6, int index)
|
||||
if (index < 0 || index > GiftCountMax)
|
||||
return;
|
||||
|
||||
wc6.Data.CopyTo(Data, WondercardData + (index * WC6.Size));
|
||||
|
||||
Edited = true;
|
||||
SetData(wc6.Data, WondercardData + (index * WC6.Size));
|
||||
}
|
||||
|
||||
// Gym History
|
||||
|
||||
@@ -957,8 +957,8 @@ public override string GetBoxName(int box)
|
||||
|
||||
public override void SetBoxName(int box, string value)
|
||||
{
|
||||
Encoding.Unicode.GetBytes(value.PadRight(0x11, '\0')).CopyTo(Data, PCLayout + (0x22 * box));
|
||||
Edited = true;
|
||||
var data = Encoding.Unicode.GetBytes(value.PadRight(0x11, '\0'));
|
||||
SetData(data, PCLayout + (0x22 * box));
|
||||
}
|
||||
|
||||
protected override PKM GetPKM(byte[] data)
|
||||
@@ -1427,8 +1427,7 @@ protected override bool[] MysteryGiftReceivedFlags
|
||||
data[i>>3] |= (byte)(1 << (i&7));
|
||||
}
|
||||
|
||||
data.CopyTo(Data, WondercardFlags);
|
||||
Edited = true;
|
||||
SetData(data, WondercardFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1475,9 +1474,7 @@ private void SetWC7(MysteryGift wc7, int index)
|
||||
if (index < 0 || index > GiftCountMax)
|
||||
return;
|
||||
|
||||
wc7.Data.CopyTo(Data, WondercardData + (index * WC7.Size));
|
||||
|
||||
Edited = true;
|
||||
SetData(wc7.Data, WondercardData + (index * WC7.Size));
|
||||
}
|
||||
|
||||
// Writeback Validity
|
||||
|
||||
@@ -196,7 +196,7 @@ private void ImportGP1From(string path, int index)
|
||||
return;
|
||||
}
|
||||
var gp1 = new GP1();
|
||||
data.CopyTo(gp1.Data);
|
||||
data.CopyTo(gp1.Data, 0);
|
||||
Park[index] = gp1;
|
||||
UpdateGoSummary((int)NUD_GoIndex.Value);
|
||||
}
|
||||
|
||||
@@ -91,8 +91,7 @@ private void B_Save_Click(object sender, EventArgs e)
|
||||
// Copy back Constants
|
||||
ChangeConstantIndex(null, EventArgs.Empty); // Trigger Saving
|
||||
SAV.EventConsts = Constants;
|
||||
SAV.Data.CopyTo(Origin.Data, 0);
|
||||
Origin.Edited = true;
|
||||
SAV.SetData(Origin.Data, 0);
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ private static Image GetSprite(SaveFile sav)
|
||||
private static Image GetWallpaper(SaveFile sav, int box)
|
||||
{
|
||||
string s = BoxWallpaper.GetWallpaperResourceName(sav.Version, sav.GetBoxWallpaper(box));
|
||||
return (Bitmap)(Resources.ResourceManager.GetObject(s) ?? Resources.box_wp16xy);
|
||||
return (Bitmap)Resources.ResourceManager.GetObject(s) ?? Resources.box_wp16xy;
|
||||
}
|
||||
|
||||
private static Image GetSprite(PKM pk, SaveFile sav, int box, int slot, bool flagIllegal = false)
|
||||
@@ -159,7 +159,7 @@ private static Image GetSprite(PKM pk, SaveFile sav, int box, int slot, bool fla
|
||||
private const int SlotTeamShiftX = SpriteWidth - 19;
|
||||
private const int FlagIllegalShiftY = SpriteHeight - 16;
|
||||
|
||||
private static readonly Image[] PartyMarks =
|
||||
private static readonly Bitmap[] PartyMarks =
|
||||
{
|
||||
Resources.party1, Resources.party2, Resources.party3, Resources.party4, Resources.party5, Resources.party6,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user