module_movie_test.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using Microsoft.Xna.Framework.Input;
  2. using OpenVIII.Encoding.Tags;
  3. using System.Linq;
  4. namespace OpenVIII
  5. {
  6. public static class Module_movie_test
  7. {
  8. private const MODULE defaultReturnState = MODULE.MAINMENU_DEBUG;
  9. private static Movie.Player Player;
  10. /// <summary>
  11. /// Movie file list
  12. /// </summary>
  13. public static MODULE ReturnState { get; set; } = defaultReturnState;
  14. public static int Index { get; set; }
  15. public static void Inputs()
  16. {
  17. if (Input2.DelayedButton(FF8TextTagKey.Confirm) || Input2.DelayedButton(FF8TextTagKey.Cancel) || Input2.DelayedButton(Keys.Space))
  18. {
  19. Return();
  20. }
  21. #if DEBUG
  22. // lets you move through all the feilds just holding left or right. it will just loop
  23. // when it runs out.
  24. else if (Input2.DelayedButton(FF8TextTagKey.Left))
  25. {
  26. init_debugger_Audio.PlaySound(0);
  27. if (Module_movie_test.Index > 0)
  28. Module_movie_test.Index--;
  29. else
  30. Module_movie_test.Index = Movie.Files.Count - 1;
  31. Reset();
  32. }
  33. else if (Input2.DelayedButton(FF8TextTagKey.Right))
  34. {
  35. init_debugger_Audio.PlaySound(0);
  36. if (Module_movie_test.Index < Movie.Files.Count - 1)
  37. Module_movie_test.Index++;
  38. else
  39. Module_movie_test.Index = 0;
  40. Reset();
  41. }
  42. #endif
  43. }
  44. private static void Return()
  45. {
  46. Memory.Module = ReturnState;
  47. Reset();
  48. }
  49. public static void Play()
  50. {
  51. Player = Movie.Player.Load(Index);
  52. Player.StateChanged += Player_StateChanged;
  53. }
  54. private static void Player_StateChanged(object sender, Movie.STATE e)
  55. {
  56. if (e == Movie.STATE.RETURN)
  57. Return();
  58. }
  59. public static void Update()
  60. {
  61. if (Player == null || Player.IsDisposed)
  62. Play();
  63. Player.Update();
  64. Inputs();
  65. }
  66. public static void Draw() => Player?.Draw();
  67. public static void Reset()
  68. {
  69. Player = null;
  70. ReturnState= defaultReturnState;
  71. }
  72. }
  73. }