Module_main_menu_MainLobby.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. namespace FF8
  7. {
  8. public static partial class Module_main_menu_debug
  9. {
  10. #region Fields
  11. private static Mitems s_mchoose;
  12. private static TextureHandler start;
  13. /// <summary>
  14. /// Strings for the main menu
  15. /// </summary>
  16. private static Dictionary<Enum, Item> strMainLobby;
  17. #endregion Fields
  18. #region Enums
  19. /// <summary>
  20. /// Identifiers and Ordering of main menu items
  21. /// </summary>
  22. private enum Mitems
  23. {
  24. New,
  25. Load,
  26. Debug
  27. }
  28. #endregion Enums
  29. #region Properties
  30. /// <summary>
  31. /// Current choice on main menu
  32. /// </summary>
  33. private static Mitems Mchoose
  34. {
  35. get => s_mchoose;
  36. set
  37. {
  38. if (value > s_mchoose && value > (Mitems)Enum.GetValues(typeof(Mitems)).Cast<int>().Max())
  39. {
  40. value = 0;
  41. }
  42. else if (value < s_mchoose && s_mchoose <= 0)
  43. {
  44. value = (Mitems)Enum.GetValues(typeof(Mitems)).Cast<int>().Max();
  45. }
  46. s_mchoose = value;
  47. }
  48. }
  49. #endregion Properties
  50. #region Methods
  51. /// <summary>
  52. /// Draw Main menu
  53. /// </summary>
  54. private static void DrawMainLobby()
  55. {
  56. float item = 0;
  57. TextScale = new Vector2(2.545454545f, 3.0375f);// scaled in render function.
  58. Vector2 textStart = new Vector2(0.45078125f, .65f)* vp_per;
  59. Memory.SpriteBatchStartAlpha(tm: IGM_focus);
  60. Rectangle dst = new Rectangle()
  61. {
  62. Location = new Point(0),
  63. Size = vp_per.ToPoint()
  64. };
  65. start.Draw(dst, null, Color.White * fade);
  66. foreach (Mitems i in (Mitems[])Enum.GetValues(typeof(Mitems)))
  67. {
  68. Item c = strMainLobby[i];
  69. c.Loc = (Memory.font.RenderBasicText(c.Text,
  70. (int)(textStart.X), (int)(textStart.Y + ((TextScale.Y + vpSpace) * item++)), TextScale.X, TextScale.Y, 0, Fade));
  71. strMainLobby[i] = c;
  72. }
  73. DrawPointer(new Point((int)(textStart.X), (int)((((TextScale.Y + vpSpace) * (float)Mchoose)+textStart.Y+(6*TextScale.Y)))));
  74. Memory.SpriteBatchEnd();
  75. }
  76. private static void InitMain()
  77. {
  78. strMainLobby = new Dictionary<Enum, Item>()
  79. {
  80. { Mitems.New, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,105) } },
  81. { Mitems.Load, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,106) } },
  82. { Mitems.Debug, new Item{Text=new FF8String("OpenVIII debug tools") } }
  83. };
  84. if (start == null)
  85. {
  86. start = new TextureHandler("start{0:00}", 2);
  87. }
  88. }
  89. /// <summary>
  90. /// Update Main Lobby
  91. /// </summary>
  92. /// <returns>true on change</returns>
  93. private static bool UpdateMainLobby()
  94. {
  95. bool ret = false;
  96. foreach (KeyValuePair<Enum, Item> entry in strMainLobby)
  97. {
  98. if (entry.Value.Loc.Contains(ml))
  99. {
  100. Mchoose = (Mitems)entry.Key;
  101. ret = true;
  102. if (Input.Button(Buttons.MouseWheelup) || Input.Button(Buttons.MouseWheeldown))
  103. {
  104. return ret;
  105. }
  106. break;
  107. }
  108. }
  109. if (Input.Button(Buttons.Down))
  110. {
  111. Input.ResetInputLimit();
  112. init_debugger_Audio.PlaySound(0);
  113. Mchoose++;
  114. ret = true;
  115. }
  116. if (Input.Button(Buttons.Up))
  117. {
  118. Input.ResetInputLimit();
  119. init_debugger_Audio.PlaySound(0);
  120. Mchoose--;
  121. ret = true;
  122. }
  123. if (Input.Button(Buttons.Okay))
  124. {
  125. Input.ResetInputLimit();
  126. switch (Mchoose)
  127. {
  128. case Mitems.New:
  129. init_debugger_Audio.PlaySound(28);
  130. State = MainMenuStates.NewGameChoosed;
  131. break;
  132. case Mitems.Load:
  133. init_debugger_Audio.PlaySound(0);
  134. State = MainMenuStates.LoadGameChooseSlot;
  135. break;
  136. case Mitems.Debug:
  137. init_debugger_Audio.PlaySound(0);
  138. Mchoose = 0;
  139. Dchoose = 0;
  140. State = MainMenuStates.DebugScreen;
  141. Fade = 0.0f;
  142. break;
  143. }
  144. ret = true;
  145. }
  146. return ret;
  147. }
  148. /// <summary>
  149. /// Waits for fade to end then triggers new game.
  150. /// </summary>
  151. private static void UpdateNewGame()
  152. {
  153. if (Fade > 0.0f)
  154. {
  155. Fade -= Memory.gameTime.ElapsedGameTime.Milliseconds / 1000.0f / 2;
  156. return;
  157. }
  158. /*reverse engineering notes:
  159. *
  160. * we should happen to reset wm2field values
  161. * also the basic party of Squall is now set: SG_PARTY_FIELD1 = 0, and other members are 0xFF
  162. */
  163. FieldPointer = 74; //RE: startup stage ID is hardcoded. Probably we would want to change it for modding
  164. //the module changes to 1 now
  165. Module_field_debug.ResetField();
  166. Module_movie_test.Index = 30;
  167. Module_movie_test.ReturnState = Memory.MODULE_FIELD_DEBUG;
  168. Memory.module = Memory.MODULE_MOVIETEST;
  169. State = MainMenuStates.MainLobby;
  170. }
  171. #endregion Methods
  172. }
  173. }