module_main_menu_debug.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. using Microsoft.Xna.Framework;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace FF8
  5. {
  6. internal static partial class Module_main_menu_debug
  7. {
  8. #region Fields
  9. private static float fade, lastfade;
  10. private static bool LastActive = false;
  11. private static MainMenuStates State = 0;
  12. private static int vpHeight, vpWidth;
  13. #endregion Fields
  14. #region Enums
  15. /// <summary>
  16. /// What state the menus are in.
  17. /// </summary>
  18. private enum MainMenuStates
  19. {
  20. Init,
  21. MainLobby,
  22. NewGameChoosed,
  23. LoadGameLoading,
  24. LoadGameChooseSlot,
  25. LoadGameChooseGame,
  26. DebugScreen,
  27. LoadGameCheckingSlot
  28. }
  29. #endregion Enums
  30. #region Properties
  31. public static float vpSpace { get; private set; }
  32. private static float Fade { get => fade; set => fade = value; }
  33. private static Dictionary<Enum, Item> strLoadScreen { get; set; }
  34. #endregion Properties
  35. #region Methods
  36. /// <summary>
  37. /// Trigger required draw function.
  38. /// </summary>
  39. internal static void Draw()
  40. {
  41. Memory.graphics.GraphicsDevice.Clear(Color.Black);
  42. lastfade = fade;
  43. vpSpace = vpHeight * 0.09f * Memory.Scale().X;
  44. DFontPos = new Vector2(vpWidth * .10f * Memory.Scale().X, vpHeight * .05f * Memory.Scale().Y) + Offset;
  45. switch (State)
  46. {
  47. case MainMenuStates.Init:
  48. case MainMenuStates.MainLobby:
  49. DrawMainLobby();
  50. break;
  51. case MainMenuStates.DebugScreen:
  52. DrawDebugLobby();
  53. break;
  54. case MainMenuStates.NewGameChoosed:
  55. DrawMainLobby();
  56. break;
  57. case MainMenuStates.LoadGameChooseSlot:
  58. DrawLGChooseSlot();
  59. break;
  60. case MainMenuStates.LoadGameCheckingSlot:
  61. DrawLGCheckSlot();
  62. break;
  63. case MainMenuStates.LoadGameChooseGame:
  64. DrawLGChooseGame();
  65. break;
  66. case MainMenuStates.LoadGameLoading:
  67. DrawLoadingGame();
  68. break;
  69. }
  70. }
  71. /// <summary>
  72. /// Triggers functions depending on state
  73. /// </summary>
  74. internal static void Update()
  75. {
  76. lastscale = scale;
  77. scale = Memory.Scale();
  78. bool forceupdate = false;
  79. Memory.SuppressDraw = true;
  80. if (LastActive != Memory.IsActive)
  81. {
  82. forceupdate = true;
  83. LastActive = Memory.IsActive;
  84. }
  85. if (lastscale != scale)
  86. {
  87. forceupdate = true;
  88. }
  89. if (Fade < 1.0f && State != MainMenuStates.NewGameChoosed)
  90. {
  91. Fade += Memory.gameTime.ElapsedGameTime.Milliseconds / 1000.0f * 3;
  92. }
  93. vpWidth = Memory.PreferredViewportWidth;//Memory.graphics.GraphicsDevice.Viewport.Width;
  94. vpHeight = Memory.PreferredViewportHeight;//Memory.graphics.GraphicsDevice.Viewport.Width;
  95. switch (State)
  96. {
  97. case MainMenuStates.Init:
  98. State++;
  99. Init();
  100. break;
  101. case MainMenuStates.MainLobby:
  102. Memory.IsMouseVisible = true;
  103. Offset = new Vector2(-1000, 0);
  104. if (UpdateMainLobby() || (lastfade != fade))
  105. {
  106. forceupdate = true;
  107. }
  108. break;
  109. case MainMenuStates.DebugScreen:
  110. Memory.IsMouseVisible = true;
  111. if (Offset != Vector2.Zero)
  112. {
  113. Offset = Vector2.SmoothStep(Offset, Vector2.Zero, .15f);
  114. }
  115. if (UpdateDebugLobby() || (lastfade != fade) || Offset != Vector2.Zero)
  116. {
  117. forceupdate = true;
  118. }
  119. break;
  120. case MainMenuStates.NewGameChoosed:
  121. Memory.IsMouseVisible = false;
  122. UpdateNewGame();
  123. break;
  124. case MainMenuStates.LoadGameChooseSlot:
  125. UpdateLGChooseSlot();
  126. Memory.IsMouseVisible = true;
  127. break;
  128. case MainMenuStates.LoadGameCheckingSlot:
  129. UpdateLoadingSlot();
  130. Memory.IsMouseVisible = false;
  131. break;
  132. case MainMenuStates.LoadGameChooseGame:
  133. UpdateLGChooseGame();
  134. Memory.IsMouseVisible = true;
  135. break;
  136. case MainMenuStates.LoadGameLoading:
  137. UpdateLoading();
  138. Memory.IsMouseVisible = false;
  139. break;
  140. //default:
  141. // goto case 0;
  142. }
  143. //disabled because if you resize the window the next update call undoes this before drawing happens.
  144. //need a way to detect if drawing has happened before suppressing draw again.
  145. //if(forceupdate)
  146. Memory.SuppressDraw = false;
  147. }
  148. /// <summary>
  149. /// Init
  150. /// </summary>
  151. private static void Init()
  152. {
  153. InitMain();
  154. InitLoad();
  155. InitDebug();
  156. Memory.Strings.Close();
  157. }
  158. #endregion Methods
  159. }
  160. }