Kernel_bin.Menu_abilities.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections.Generic;
  2. using System.IO;
  3. namespace OpenVIII
  4. {
  5. public partial class Kernel_bin
  6. {
  7. /// <summary>
  8. /// Menu Abilities Data
  9. /// </summary>
  10. /// <see cref="https://github.com/alexfilth/doomtrain/wiki/Menu-abilities"/>
  11. public class Menu_abilities :Ability
  12. {
  13. public new const int count = 24;
  14. public new const int id = 17;
  15. public override string ToString() => Name;
  16. public byte Index { get; private set; }
  17. public byte Start { get; private set; }
  18. public byte End { get; private set; }
  19. public override void Read(BinaryReader br, int i)
  20. {
  21. Icon = Icons.ID.Ability_Menu;
  22. Name = Memory.Strings.Read(Strings.FileID.KERNEL, id, i * 2);
  23. //0x0000 2 bytes Offset to name
  24. Description = Memory.Strings.Read(Strings.FileID.KERNEL, id, i * 2 + 1);
  25. //0x0002 2 bytes Offset to description
  26. br.BaseStream.Seek(4, SeekOrigin.Current);
  27. AP = br.ReadByte();
  28. //0x0004 1 byte AP Required to learn ability
  29. Index = br.ReadByte();
  30. //0x0005 1 byte Index to m00X files in menu.fs
  31. //(first 3 sections are treated as special cases)
  32. Start = br.ReadByte();
  33. //0x0006 1 byte Start offset
  34. End = br.ReadByte();
  35. //0x0007 1 byte End offset
  36. }
  37. public static Dictionary<Abilities,Menu_abilities> Read(BinaryReader br)
  38. {
  39. Dictionary<Abilities, Menu_abilities> ret = new Dictionary<Abilities, Menu_abilities>(count);
  40. for (int i = 0; i < count; i++)
  41. {
  42. var tmp = new Menu_abilities();
  43. tmp.Read(br, i);
  44. ret[(Abilities)(i+(int)Abilities.Haggle)] = tmp;
  45. }
  46. return ret;
  47. }
  48. }
  49. }
  50. }