mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-01 03:36:43 -05:00
Add ability to batch edit trashbytes
Raw editing of byte fields .Nickname_Trash=$[]43,00,65,00,72,00,66,00,72,00,6F,00,75,00,73,00,73,00,65,00,00,00,00,00 only use cases are OT/Nickname trash bytes not too concerned about speed re-parsing values or storing it to an auto property; it's fast enough.
This commit is contained in:
@@ -56,6 +56,7 @@ private static string[][] GetPropArray()
|
||||
private const string CONST_RAND = "$rand";
|
||||
private const string CONST_SHINY = "$shiny";
|
||||
private const string CONST_SUGGEST = "$suggest";
|
||||
private const string CONST_BYTES = "$[]";
|
||||
|
||||
private const string PROP_LEGAL = "Legal";
|
||||
private static readonly string[] CustomProperties = {PROP_LEGAL};
|
||||
@@ -398,7 +399,7 @@ public static void ScreenStrings(IEnumerable<StringInstruction> il)
|
||||
foreach (var i in il.Where(i => !i.PropertyValue.All(char.IsDigit)))
|
||||
{
|
||||
string pv = i.PropertyValue;
|
||||
if (pv.StartsWith("$") && pv.Contains(','))
|
||||
if (pv.StartsWith("$") && !pv.StartsWith(CONST_BYTES) && pv.Contains(','))
|
||||
i.SetRandRange(pv);
|
||||
|
||||
SetInstructionScreenedValue(i);
|
||||
@@ -455,6 +456,11 @@ private static ModifyResult TryModifyPKM(PKM PKM, IEnumerable<StringInstruction>
|
||||
}
|
||||
private static ModifyResult SetPKMProperty(PKM PKM, PKMInfo info, StringInstruction cmd)
|
||||
{
|
||||
if (cmd.PropertyValue.StartsWith(CONST_BYTES))
|
||||
return SetByteArrayProperty(PKM, cmd)
|
||||
? ModifyResult.Modified
|
||||
: ModifyResult.Error;
|
||||
|
||||
if (cmd.PropertyValue == CONST_SUGGEST)
|
||||
return SetSuggestedPKMProperty(PKM, cmd, info)
|
||||
? ModifyResult.Modified
|
||||
@@ -516,6 +522,21 @@ private static bool SetSuggestedPKMProperty(PKM PKM, StringInstruction cmd, PKMI
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private static bool SetByteArrayProperty(PKM PKM, StringInstruction cmd)
|
||||
{
|
||||
switch (cmd.PropertyName)
|
||||
{
|
||||
case nameof(PKM.Nickname_Trash):
|
||||
PKM.Nickname_Trash = string2arr(cmd.PropertyValue);
|
||||
return true;
|
||||
case nameof(PKM.OT_Trash):
|
||||
PKM.OT_Trash = string2arr(cmd.PropertyValue);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
byte[] string2arr(string str) => str.Substring(CONST_BYTES.Length).Split(',').Select(z => Convert.ToByte(z.Trim(), 16)).ToArray();
|
||||
}
|
||||
private static void SetProperty(PKM PKM, StringInstruction cmd)
|
||||
{
|
||||
if (cmd.PropertyName == nameof(PKM.MetDate))
|
||||
|
||||
Reference in New Issue
Block a user