Entry.cs 3.6 KB

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