module_main_menu_debug.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using Microsoft.Xna.Framework;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace FF8
  5. {
  6. public 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 Vector2 vp_per;
  13. private static Vector2 vp;
  14. private static bool blinkstate;
  15. private static IGM InGameMenu;
  16. private static IGM_Junction InGameMenu_Junction;
  17. #endregion Fields
  18. #region Enums
  19. /// <summary>
  20. /// What state the menus are in.
  21. /// </summary>
  22. private enum MainMenuStates
  23. {
  24. //Init,
  25. MainLobby,
  26. DebugScreen,
  27. NewGameChoosed,
  28. LoadGameChooseSlot,
  29. SaveGameChooseSlot,
  30. LoadGameChooseGame,
  31. SaveGameChooseGame,
  32. LoadGameCheckingSlot,
  33. SaveGameCheckingSlot,
  34. LoadGameLoading,
  35. SaveGameSaving,
  36. InGameMenu,
  37. IGM_Junction
  38. }
  39. #endregion Enums
  40. #region Properties
  41. public static float vpSpace { get; private set; }
  42. private static float Fade { get => fade; set => fade = value; }
  43. private static Dictionary<Enum, Item> strLoadScreen { get; set; }
  44. private static MainMenuStates State
  45. {
  46. get => state; set
  47. {
  48. // Draw will call before the next update(). This prevents that.
  49. Memory.SuppressDraw = true;
  50. state = value;
  51. }
  52. }
  53. #endregion Properties
  54. #region Methods
  55. /// <summary>
  56. /// Trigger required draw function.
  57. /// </summary>
  58. public static void Draw()
  59. {
  60. Memory.graphics.GraphicsDevice.Clear(Color.Black);
  61. lastfade = fade;
  62. switch (State)
  63. {
  64. //case MainMenuStates.Init:
  65. case MainMenuStates.MainLobby:
  66. DrawMainLobby();
  67. break;
  68. case MainMenuStates.DebugScreen:
  69. DrawDebugLobby();
  70. break;
  71. case MainMenuStates.NewGameChoosed:
  72. DrawMainLobby();
  73. break;
  74. case MainMenuStates.LoadGameLoading:
  75. case MainMenuStates.LoadGameChooseSlot:
  76. case MainMenuStates.LoadGameCheckingSlot:
  77. case MainMenuStates.LoadGameChooseGame:
  78. case MainMenuStates.SaveGameChooseSlot:
  79. case MainMenuStates.SaveGameCheckingSlot:
  80. case MainMenuStates.SaveGameChooseGame:
  81. case MainMenuStates.SaveGameSaving:
  82. DrawLGSG();
  83. break;
  84. case MainMenuStates.InGameMenu:
  85. InGameMenu.Draw();
  86. break;
  87. case MainMenuStates.IGM_Junction:
  88. InGameMenu_Junction.Draw();
  89. break;
  90. }
  91. }
  92. /// <summary>
  93. /// Triggers functions depending on state
  94. /// </summary>
  95. public static void Update()
  96. {
  97. if (blinkstate)
  98. blink_Amount += Memory.gameTime.ElapsedGameTime.Milliseconds / 2000.0f * 3;
  99. else
  100. blink_Amount -= Memory.gameTime.ElapsedGameTime.Milliseconds / 2000.0f * 3;
  101. lastscale = scale;
  102. scale = Memory.Scale();
  103. #pragma warning disable CS0219 // Variable is assigned but its value is never used
  104. bool forceupdate = false;
  105. #pragma warning restore CS0219 // Variable is assigned but its value is never used
  106. if (LastActive != Memory.IsActive)
  107. {
  108. forceupdate = true;
  109. LastActive = Memory.IsActive;
  110. }
  111. if (lastscale != scale)
  112. {
  113. forceupdate = true;
  114. }
  115. if (Fade < 1.0f && State != MainMenuStates.NewGameChoosed)
  116. {
  117. Fade += Memory.gameTime.ElapsedGameTime.Milliseconds / 1000.0f * 3;
  118. }
  119. vp_per.X = Memory.PreferredViewportWidth;//Memory.graphics.GraphicsDevice.Viewport.Width;
  120. vp_per.Y = Memory.PreferredViewportHeight;//Memory.graphics.GraphicsDevice.Viewport.Width;
  121. vp_per = new Vector2(Memory.PreferredViewportWidth, Memory.PreferredViewportHeight);
  122. vp = new Vector2(Memory.graphics.GraphicsDevice.Viewport.Width, Memory.graphics.GraphicsDevice.Viewport.Height);
  123. vpSpace = vp_per.Y * 0.09f;
  124. DFontPos = new Vector2(vp_per.X * .10f, vp_per.Y * .05f) + Offset;
  125. IGM_focus = Matrix.CreateTranslation((vp_per.X / -2), (vp_per.Y / -2), 0) *
  126. Matrix.CreateScale(new Vector3(scale.X, scale.Y, 1)) *
  127. Matrix.CreateTranslation(vp.X / 2, vp.Y / 2, 0);
  128. ml = Input.MouseLocation.Transform(IGM_focus);
  129. switch (State)
  130. {
  131. //case MainMenuStates.Init:
  132. // State++;
  133. // Init();
  134. // break;
  135. case MainMenuStates.MainLobby:
  136. Memory.IsMouseVisible = true;
  137. Offset = new Vector2(-1000, 0);
  138. if (UpdateMainLobby() || (lastfade != fade))
  139. {
  140. forceupdate = true;
  141. }
  142. break;
  143. case MainMenuStates.DebugScreen:
  144. Memory.IsMouseVisible = true;
  145. if (Offset != Vector2.Zero)
  146. {
  147. Offset = Vector2.SmoothStep(Offset, Vector2.Zero, .15f).FloorOrCeiling(Vector2.Zero);
  148. }
  149. if (UpdateDebugLobby() || (lastfade != fade) || Offset != Vector2.Zero)
  150. {
  151. forceupdate = true;
  152. }
  153. break;
  154. case MainMenuStates.NewGameChoosed:
  155. Memory.IsMouseVisible = false;
  156. UpdateNewGame();
  157. break;
  158. case MainMenuStates.LoadGameChooseSlot:
  159. case MainMenuStates.LoadGameCheckingSlot:
  160. case MainMenuStates.LoadGameChooseGame:
  161. case MainMenuStates.LoadGameLoading:
  162. case MainMenuStates.SaveGameChooseSlot:
  163. case MainMenuStates.SaveGameCheckingSlot:
  164. case MainMenuStates.SaveGameChooseGame:
  165. case MainMenuStates.SaveGameSaving:
  166. UpdateLGSG();
  167. break;
  168. case MainMenuStates.InGameMenu:
  169. Memory.IsMouseVisible = true;
  170. InGameMenu.Update();
  171. break;
  172. case MainMenuStates.IGM_Junction:
  173. Memory.IsMouseVisible = true;
  174. InGameMenu_Junction.Update();
  175. break;
  176. default:
  177. goto case 0;
  178. }
  179. //disabled because if you resize the window the next update call undoes this before drawing happens.
  180. //need a way to detect if drawing has happened before suppressing draw again.
  181. //if(forceupdate)
  182. }
  183. /// <summary>
  184. /// Init
  185. /// </summary>
  186. public static void Init()
  187. {
  188. InitMain();
  189. InitLoad();
  190. InitDebug();
  191. InGameMenu = new IGM();
  192. InGameMenu_Junction = new IGM_Junction();
  193. Memory.Strings.Close();
  194. }
  195. #endregion Methods
  196. }
  197. }