Entry.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using Microsoft.Xna.Framework;
  2. using System;
  3. using System.IO;
  4. namespace FF8
  5. {
  6. public class Entry
  7. {
  8. #region Fields
  9. public Vector2 End;
  10. public Vector2 Location;
  11. public Vector2 Offset;
  12. public Vector2 Size;
  13. public string ToStringHeader { get; } = "{File},{Part},{CustomPallet},{Location.X},{Location.Y},{Size.X},{Size.Y},{Offset.X},{Offset.Y},{End.X},{End.Y},{Tile.X},{Tile.Y},{Fill.X},{Fill.Y},{Snap_Right},{Snap_Bottom}\n";
  14. public byte[] UNK;
  15. private Loc loc;
  16. #endregion Fields
  17. #region Constructors
  18. public Entry()
  19. {
  20. UNK = new byte[2];
  21. File = 0;
  22. Part = 1;
  23. }
  24. #endregion Constructors
  25. #region Properties
  26. public ushort CurrentPos { get; set; }
  27. public sbyte CustomPallet { get; set; } = -1;
  28. public byte File { get; set; }
  29. public Vector2 Fill { get; set; }
  30. //public Loc GetLoc => loc;
  31. public Rectangle GetRectangle => new Rectangle(Location.ToPoint(), Size.ToPoint());
  32. public float Height { get => Size.Y; set => Size.Y = value; }
  33. public byte Part { get; set; } = 1;
  34. /// <summary>
  35. /// point where you want to stop drawing from bottom side so -8 would stop 8*scale pixels
  36. /// from edge
  37. /// </summary>
  38. //public sbyte Offset_Y2 { get; set; }
  39. public bool Snap_Bottom { get; set; } = false;
  40. /// <summary>
  41. /// point where you want to stop drawing from right side so -8 would stop 8*scale pixels from edge
  42. /// </summary>
  43. //public sbyte Offset_X2 { get; set; }
  44. public bool Snap_Right { get; set; } = false;
  45. /// <summary>
  46. /// Vector2.Zero = no tile, Vector2.One = tile x & y, Vector.UnitX = tile x, Vector.UnitY = tile y
  47. /// </summary>
  48. public Vector2 Tile { get; set; } = Vector2.Zero;
  49. public float Width { get => Size.X; set => Size.X = value; }
  50. public float X { get => Location.X; set => Location.X = value; }
  51. public float Y { get => Location.Y; set => Location.Y = value; }
  52. /// <summary>
  53. /// Shadowcopy
  54. /// </summary>
  55. /// <returns>Copy of class</returns>
  56. public Entry Clone()
  57. => (Entry)MemberwiseClone();
  58. #endregion Properties
  59. #region Methods
  60. public void LoadfromStreamSP1(BinaryReader br)
  61. {
  62. CurrentPos = (ushort)br.BaseStream.Position;
  63. Location.X = br.ReadByte();
  64. Location.Y = br.ReadByte();
  65. UNK = br.ReadBytes(2);
  66. Size.X = br.ReadByte();
  67. Offset.X = br.ReadSByte();
  68. Size.Y = br.ReadByte();
  69. Offset.Y = br.ReadSByte();
  70. }
  71. public void LoadfromStreamSP2(BinaryReader br, UInt16 loc, Entry prev, ref byte fid)
  72. {
  73. if (loc > 0)
  74. br.BaseStream.Seek(loc + 4, SeekOrigin.Begin);
  75. CurrentPos = loc;
  76. Location.X = br.ReadByte();
  77. Location.Y = br.ReadByte();
  78. UNK = br.ReadBytes(2);
  79. Size.X = br.ReadByte();
  80. Offset.X = br.ReadSByte();
  81. Size.Y = br.ReadByte();
  82. Offset.Y = br.ReadSByte();
  83. if (prev != null && Location.Y < prev.Y)
  84. fid++;
  85. File = fid;
  86. }
  87. public void SetLoc(Loc value) => loc = value;
  88. public override string ToString()
  89. {
  90. return $"{File},{Part},{CustomPallet},{Location.X},{Location.Y},{Size.X},{Size.Y},{Offset.X},{Offset.Y},{End.X},{End.Y},{Tile.X},{Tile.Y},{Fill.X},{Fill.Y},{Snap_Right},{Snap_Bottom}\n";
  91. }
  92. #endregion Methods
  93. }
  94. }