using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace OpenVIII
{
namespace Kernel
{
#region Classes
///
/// Menu Abilities Data
///
///
public class MenuAbilities : Ability
{
#region Fields
///
/// Section Count
///
public const int Count = 24;
///
/// Section ID
///
public const int ID = 17;
///
/// Icon for this type.
///
private new const Icons.ID Icon = Icons.ID.Ability_Menu;
#endregion Fields
#region Constructors
private MenuAbilities(FF8String name, FF8String description, byte ap, byte index, byte start, byte end)
: base(name, description, ap, Icon)
=> (Index, Start, End) = (index, start, end);
#endregion Constructors
#region Properties
///
/// End offset
///
public byte End { get; }
///
/// Index to m00X files in menu.fs
/// first 3 sections are treated as special cases
///
public byte Index { get; }
///
/// Start offset
///
public byte Start { get; }
#endregion Properties
#region Methods
public static Dictionary Read(BinaryReader br)
=> Enumerable.Range(0, Count)
.ToDictionary(i => (Abilities)(i + (int)Abilities.Haggle), i => CreateInstance(br, i));
private static MenuAbilities CreateInstance(BinaryReader br, int i)
{
//0x0000 2 bytes Offset
FF8StringReference name = Memory.Strings.Read(Strings.FileID.KERNEL, ID, i * 2);
//0x0002 2 bytes Offset
FF8StringReference description = Memory.Strings.Read(Strings.FileID.KERNEL, ID, i * 2 + 1);
br.BaseStream.Seek(4, SeekOrigin.Current);
//0x0004 1 byte
byte ap = br.ReadByte();
//0x0005 1 byte
byte index = br.ReadByte();
//0x0006 1 byte
byte start = br.ReadByte();
//0x0007 1 byte
byte end = br.ReadByte();
return new MenuAbilities(name, description, ap, index, start, end);
}
#endregion Methods
}
#endregion Classes
}
}