2019-09-23 23:56:47 +00:00
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2020-09-09 19:47:24 +00:00
|
|
|
|
public sealed class BoxLayout8 : SaveBlock, IBoxDetailName
|
2019-09-23 23:56:47 +00:00
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
public const int BoxCount = 32;
|
2019-09-23 23:56:47 +00:00
|
|
|
|
|
2021-05-29 22:31:47 +00:00
|
|
|
|
private const int StringMaxLength = SAV6.LongStringLength / 2;
|
2019-09-23 23:56:47 +00:00
|
|
|
|
|
2019-11-16 01:34:18 +00:00
|
|
|
|
public BoxLayout8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { }
|
2019-09-23 23:56:47 +00:00
|
|
|
|
|
2020-01-21 06:04:52 +00:00
|
|
|
|
private static int GetBoxNameOffset(int box) => SAV6.LongStringLength * box;
|
2019-09-23 23:56:47 +00:00
|
|
|
|
|
|
|
|
|
public string GetBoxName(int box)
|
|
|
|
|
{
|
2019-10-17 02:08:13 +00:00
|
|
|
|
return SAV.GetString(Data, GetBoxNameOffset(box), SAV6.LongStringLength);
|
2019-09-23 23:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetBoxName(int box, string value)
|
|
|
|
|
{
|
2021-05-29 22:31:47 +00:00
|
|
|
|
var data = SAV.SetString(value, StringMaxLength, StringMaxLength, 0);
|
2020-01-21 06:04:52 +00:00
|
|
|
|
var offset = GetBoxNameOffset(box);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
SAV.SetData(Data, data, offset);
|
2019-09-23 23:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string this[int i]
|
|
|
|
|
{
|
|
|
|
|
get => GetBoxName(i);
|
|
|
|
|
set => SetBoxName(i, value);
|
|
|
|
|
}
|
2020-03-11 06:18:51 +00:00
|
|
|
|
|
|
|
|
|
public int CurrentBox
|
|
|
|
|
{
|
2020-03-11 23:31:53 +00:00
|
|
|
|
get => ((SAV8SWSH)SAV).GetValue<byte>(SaveBlockAccessor8SWSH.KCurrentBox);
|
2020-03-11 06:18:51 +00:00
|
|
|
|
set => ((SAV8SWSH)SAV).SetValue(SaveBlockAccessor8SWSH.KCurrentBox, (byte)value);
|
|
|
|
|
}
|
2019-09-23 23:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|