mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-09 04:24:36 -05:00
Add get/set for swsh current box
Closes #2742 Co-Authored-By: Matt <sora10pls@users.noreply.github.com>
This commit is contained in:
parent
eccfb61839
commit
f9bbeba3ad
|
|
@ -110,6 +110,7 @@ public SaveBlockAccessor8SWSH(SAV8SWSH sav)
|
|||
private const uint KBonusRewards = 0xEFCAE04E; // bonus_rewards
|
||||
|
||||
// Values
|
||||
public const uint KCurrentBox = 0x017C3CBB; // U32 Box Index
|
||||
public const uint KGameLanguage = 0x0BFDEBA1; // U32 Game Language
|
||||
public const uint KRepel = 0x9ec079da; // U16 Repel Steps remaining
|
||||
public const uint KRotoRally = 0x38548020; // U32 Roto Rally Score (99,999 cap)
|
||||
|
|
|
|||
|
|
@ -80,23 +80,22 @@ public static Type GetType(this SCTypeCode type)
|
|||
|
||||
public static object GetValue(this SCTypeCode type, byte[] data)
|
||||
{
|
||||
return type switch
|
||||
// don't use a switch expression here, we want to box our underlying type rather than the last type (double)
|
||||
switch (type)
|
||||
{
|
||||
SCTypeCode.Byte => data[0],
|
||||
SCTypeCode.UInt16 => BitConverter.ToUInt16(data, 0),
|
||||
SCTypeCode.UInt32 => BitConverter.ToUInt32(data, 0),
|
||||
SCTypeCode.UInt64 => BitConverter.ToUInt64(data, 0),
|
||||
|
||||
SCTypeCode.SByte => (sbyte)data[0],
|
||||
SCTypeCode.Int16 => BitConverter.ToInt16(data, 0),
|
||||
SCTypeCode.Int32 => BitConverter.ToInt32(data, 0),
|
||||
SCTypeCode.Int64 => BitConverter.ToInt64(data, 0),
|
||||
|
||||
SCTypeCode.Single => BitConverter.ToSingle(data, 0),
|
||||
SCTypeCode.Double => BitConverter.ToDouble(data, 0),
|
||||
|
||||
_ => throw new ArgumentException(type.ToString(), nameof(type))
|
||||
};
|
||||
case SCTypeCode.Byte: return data[0];
|
||||
case SCTypeCode.UInt16: return BitConverter.ToUInt16(data, 0);
|
||||
case SCTypeCode.UInt32: return BitConverter.ToUInt32(data, 0);
|
||||
case SCTypeCode.UInt64: return BitConverter.ToUInt64(data, 0);
|
||||
case SCTypeCode.SByte: return (sbyte) data[0];
|
||||
case SCTypeCode.Int16: return BitConverter.ToInt16(data, 0);
|
||||
case SCTypeCode.Int32: return BitConverter.ToInt32(data, 0);
|
||||
case SCTypeCode.Int64: return BitConverter.ToInt64(data, 0);
|
||||
case SCTypeCode.Single: return BitConverter.ToSingle(data, 0);
|
||||
case SCTypeCode.Double: return BitConverter.ToDouble(data, 0);
|
||||
default:
|
||||
throw new ArgumentException(type.ToString(), nameof(type));
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetValue(this SCTypeCode type, byte[] data, object value)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,12 @@ public override void CopyChangesFrom(SaveFile sav)
|
|||
public override TitleScreen8 TitleScreen => Blocks.TitleScreen;
|
||||
public override TeamIndexes8 TeamIndexes => Blocks.TeamIndexes;
|
||||
|
||||
public object GetValue(uint key) => Blocks.GetBlockValue(key);
|
||||
public object GetValue(uint key)
|
||||
{
|
||||
if (!Exportable)
|
||||
return (byte)0;
|
||||
return Blocks.GetBlockValue(key);
|
||||
}
|
||||
|
||||
public void SetValue(uint key, object value)
|
||||
{
|
||||
|
|
@ -112,5 +117,7 @@ public override StorageSlotFlag GetSlotFlags(int index)
|
|||
val |= StorageSlotFlag.Locked;
|
||||
return val;
|
||||
}
|
||||
|
||||
public override int CurrentBox { get => BoxLayout.CurrentBox; set => BoxLayout.CurrentBox = value; }
|
||||
}
|
||||
}
|
||||
|
|
@ -27,5 +27,11 @@ public void SetBoxName(int box, string value)
|
|||
get => GetBoxName(i);
|
||||
set => SetBoxName(i, value);
|
||||
}
|
||||
|
||||
public int CurrentBox
|
||||
{
|
||||
get => (byte)((SAV8SWSH)SAV).GetValue(SaveBlockAccessor8SWSH.KCurrentBox);
|
||||
set => ((SAV8SWSH)SAV).SetValue(SaveBlockAccessor8SWSH.KCurrentBox, (byte)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user