Module_face_test.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System;
  4. namespace FF8
  5. {
  6. internal static class Module_face_test
  7. {
  8. #region Fields
  9. private static Mode currentMode;
  10. private static Faces.ID[] FaceValue;
  11. private static int pointer = -1;
  12. private static int time;
  13. #endregion Fields
  14. #region Enums
  15. private enum Mode
  16. {
  17. Initialize,
  18. Draw,
  19. Wait
  20. }
  21. #endregion Enums
  22. #region Methods
  23. public static void Draw()
  24. {
  25. switch (currentMode)
  26. {
  27. case Mode.Initialize:
  28. break;
  29. case Mode.Wait:
  30. case Mode.Draw:
  31. DrawFace();
  32. break;
  33. }
  34. }
  35. public static void Update()
  36. {
  37. switch (currentMode)
  38. {
  39. case Mode.Initialize:
  40. Initialize();
  41. currentMode++;
  42. break;
  43. case Mode.Draw:
  44. pointer++;
  45. if (pointer >= FaceValue.Length) pointer = 0;
  46. currentMode++;
  47. break;
  48. case Mode.Wait:
  49. time += Memory.gameTime.ElapsedGameTime.Milliseconds;
  50. if (time > 2000)
  51. {
  52. currentMode--;
  53. time = 0;
  54. }
  55. else
  56. Memory.SuppressDraw = true;
  57. break;
  58. }
  59. }
  60. private static void DrawFace()
  61. {
  62. if (pointer >= 0)
  63. {
  64. Viewport vp = Memory.graphics.GraphicsDevice.Viewport;
  65. int rows = 2;
  66. int cols = 8;
  67. int totalitems = rows * cols;
  68. Faces.ID id = FaceValue[pointer];
  69. int pos = (int)id;
  70. int i = Memory.Faces.GetEntry(id).File;
  71. int col = (pos % cols);
  72. int row = (pos / cols) % rows;
  73. float scale = vp.Height / Memory.Faces.GetEntry(id).Height;
  74. Rectangle dst = new Rectangle(new Point(0), (Memory.Faces.GetEntry(id).Size * scale).ToPoint());
  75. dst.Offset(vp.Width / 2 - dst.Center.X, 0);
  76. Memory.SpriteBatchStartStencil();
  77. Memory.spriteBatch.GraphicsDevice.Clear(Color.Black);
  78. Memory.Faces.Draw(id, dst);
  79. Memory.font.RenderBasicText(Font.CipherDirty($"{FaceValue[pointer].ToString().Replace('_', ' ')}\npos: {pos}\nfile: {i}\ncol: {col}\nrow: {row}\nx: {Memory.Faces.GetEntry(id).X}\ny: {Memory.Faces.GetEntry(id).Y}\nwidth: {Memory.Faces.GetEntry(id).Width}\nheight: {Memory.Faces.GetEntry(id).Height}"),
  80. (int)(vp.Width * 0.10f), (int)(vp.Height * 0.05f), 1f, 2f, 0, 1);
  81. Memory.SpriteBatchEnd();
  82. }
  83. }
  84. private static void Initialize()
  85. {
  86. FaceValue = (Faces.ID[])Enum.GetValues(typeof(Faces.ID));
  87. Array.Sort(FaceValue);
  88. }
  89. #endregion Methods
  90. }
  91. }