mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using System;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Represents a Box Editor that loads the contents for easy manipulation.
|
|
/// </summary>
|
|
public sealed class BoxEdit(SaveFile SAV)
|
|
{
|
|
private readonly PKM[] CurrentContents = new PKM[SAV.BoxSlotCount];
|
|
|
|
public void Reload() => LoadBox(CurrentBox);
|
|
|
|
public void LoadBox(int box)
|
|
{
|
|
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual((uint)box, (uint)SAV.BoxCount);
|
|
|
|
SAV.AddBoxData(CurrentContents, box, 0);
|
|
CurrentBox = box;
|
|
}
|
|
|
|
public PKM this[int index]
|
|
{
|
|
get => CurrentContents[index];
|
|
set
|
|
{
|
|
CurrentContents[index] = value;
|
|
SAV.SetBoxSlotAtIndex(value, index);
|
|
}
|
|
}
|
|
|
|
public int CurrentBox { get; private set; }
|
|
public int BoxWallpaper { get => SAV.GetBoxWallpaper(CurrentBox); set => SAV.SetBoxWallpaper(CurrentBox, value); }
|
|
public string BoxName { get => SAV.GetBoxName(CurrentBox); set => SAV.SetBoxName(CurrentBox, value); }
|
|
|
|
public int MoveLeft(bool max = false)
|
|
{
|
|
int newBox = max ? 0 : (CurrentBox + SAV.BoxCount - 1) % SAV.BoxCount;
|
|
LoadBox(newBox);
|
|
return newBox;
|
|
}
|
|
|
|
public int MoveRight(bool max = false)
|
|
{
|
|
int newBox = max ? SAV.BoxCount - 1 : (CurrentBox + 1) % SAV.BoxCount;
|
|
LoadBox(newBox);
|
|
return newBox;
|
|
}
|
|
}
|