Module_main_menu_LGSG.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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 s_blink;
  10. private static Vector2 PageTarget;
  11. private static Vector2 PageSize;
  12. private static Vector2 CurrentPageLoc;
  13. private static Vector2 CurrentLastPageLoc;
  14. private static Vector2 LastPageTarget;
  15. private static Vector2 lastscale;
  16. private static Vector2 scale;
  17. private static Vector2 TextScale;
  18. private static Point ml;
  19. private static Tuple<FF8String, FF8String, FF8String> LGSGHEADER;
  20. private static Vector2 IGM_Size;
  21. private static Matrix IGM_focus;
  22. #endregion Fields
  23. #region Enums
  24. private enum Litems
  25. {
  26. GameFolder,
  27. Load,
  28. LoadFF8,
  29. Loading,
  30. Slot1,
  31. Slot2,
  32. FF8,
  33. Save,
  34. SaveFF8,
  35. GameFolderSlot1,
  36. GameFolderSlot2,
  37. CheckGameFolder,
  38. BlockToLoad,
  39. BlockToSave,
  40. Saving
  41. }
  42. #endregion Enums
  43. #region Properties
  44. public static float blink_Amount
  45. {
  46. get => s_blink; private set
  47. {
  48. if (value > 1f)
  49. blinkstate = false;
  50. if (value < 0f)
  51. blinkstate = true;
  52. s_blink = value;
  53. }
  54. }
  55. private static float PercentLoaded { get; set; } = .5f;
  56. #endregion Properties
  57. #region Methods
  58. [Flags]
  59. public enum Box_Options
  60. {
  61. Default = 0x0,
  62. Indent = 0x1,
  63. Buttom = 0x2,
  64. SkipDraw = 0x4,
  65. Center = 0x8,
  66. Middle = 0x10,
  67. }
  68. private static Tuple<Rectangle, Point, Rectangle> DrawBox(Rectangle dst, FF8String buffer = null, Icons.ID? title = null, Vector2? textScale = null, Vector2? boxScale = null, Box_Options options = Box_Options.Default)
  69. {
  70. if (textScale == null) textScale = Vector2.One;
  71. if (boxScale == null) boxScale = Vector2.One;
  72. Point cursor = Point.Zero;
  73. dst.Size = (dst.Size.ToVector2()).ToPoint();
  74. dst.Location = (dst.Location.ToVector2()).ToPoint();
  75. Vector2 bgscale = new Vector2(2f) * textScale.Value;
  76. Rectangle box = dst.Scale(boxScale.Value);
  77. Rectangle backup = dst;
  78. Rectangle hotspot = new Rectangle(dst.Location, dst.Size);
  79. Rectangle font = new Rectangle();
  80. if ((options & Box_Options.SkipDraw) == 0)
  81. {
  82. if (dst.Width > 256 * bgscale.X)
  83. Memory.Icons.Draw(Icons.ID.Menu_BG_368, 0, box, bgscale, Fade);
  84. else
  85. Memory.Icons.Draw(Icons.ID.Menu_BG_256, 0, box, bgscale, Fade);
  86. if (title != null)
  87. {
  88. //dst.Size = (Memory.Icons[title.Value].GetRectangle.Size.ToVector2() * 2.823317308f).ToPoint();
  89. dst.Offset(15, 0);
  90. dst.Y = (int)(dst.Y * boxScale.Value.Y);
  91. Memory.Icons.Draw(title.Value, 2, dst, (bgscale + new Vector2(.5f)), fade);
  92. }
  93. dst = backup;
  94. }
  95. if (buffer != null && buffer.Length > 0)
  96. {
  97. font = Memory.font.RenderBasicText(buffer, dst.Location.ToVector2(), TextScale * textScale.Value, Fade: fade, skipdraw: true);
  98. if ((options & Box_Options.Indent) != 0)
  99. dst.Offset(70 * textScale.Value.X, 0);
  100. else if ((options & Box_Options.Center) != 0)
  101. dst.Offset(dst.Width/2 - font.Width/2, 0);
  102. else
  103. dst.Offset(25 * textScale.Value.X, 0);
  104. if ((options & Box_Options.Buttom) != 0)
  105. dst.Offset(0, (dst.Height - 48));
  106. else if ((options & Box_Options.Middle) != 0)
  107. dst.Offset (0, dst.Height/2 - font.Height/2);
  108. else
  109. dst.Offset(0, 21);
  110. dst.Y = (int)(dst.Y * boxScale.Value.Y);
  111. font = Memory.font.RenderBasicText(buffer, dst.Location.ToVector2(), TextScale * textScale.Value, Fade: fade, skipdraw: (options & Box_Options.SkipDraw) != 0);
  112. cursor = dst.Location;
  113. cursor.Y += (int)(TextScale.Y * 6); // 12 * (3.0375/2)
  114. }
  115. return new Tuple<Rectangle, Point, Rectangle>(hotspot, cursor, font);
  116. }
  117. private static void DrawLGSG()
  118. {
  119. if (State == MainMenuStates.SaveGameChooseGame || State == MainMenuStates.LoadGameChooseGame)
  120. DrawLGSGChooseBlocks();
  121. Memory.SpriteBatchStartAlpha(tm: IGM_focus);
  122. switch (State)
  123. {
  124. case MainMenuStates.LoadGameChooseSlot:
  125. DrawLGChooseSlot();
  126. break;
  127. case MainMenuStates.LoadGameCheckingSlot:
  128. DrawLGCheckSlot();
  129. break;
  130. case MainMenuStates.LoadGameChooseGame:
  131. DrawLGChooseGame();
  132. break;
  133. case MainMenuStates.LoadGameLoading:
  134. DrawLG_Loading();
  135. break;
  136. case MainMenuStates.SaveGameChooseSlot:
  137. DrawSGChooseSlot();
  138. break;
  139. case MainMenuStates.SaveGameCheckingSlot:
  140. DrawSGCheckSlot();
  141. break;
  142. case MainMenuStates.SaveGameChooseGame:
  143. DrawSGChooseGame();
  144. break;
  145. case MainMenuStates.SaveGameSaving:
  146. DrawSG_Saving();
  147. break;
  148. }
  149. Memory.SpriteBatchEnd();
  150. Memory.SpriteBatchStartAlpha();
  151. DrawLGSGHeader();
  152. Memory.SpriteBatchEnd();
  153. }
  154. private static void UpdateLGSG()
  155. {
  156. Rectangle dst = new Rectangle
  157. {
  158. X = 220,
  159. Y = 42,
  160. Width = 840,
  161. Height = 477,
  162. };
  163. IGM_Size = new Vector2 { X = 843, Y = 630 };
  164. Vector2 Zoom = Memory.Scale(IGM_Size.X, IGM_Size.Y, Memory.ScaleMode.FitBoth);
  165. IGM_focus = Matrix.CreateTranslation(-dst.X + (IGM_Size.X / -2), -dst.Y + (IGM_Size.Y / -2), 0) *
  166. Matrix.CreateScale(new Vector3(Zoom.X, Zoom.Y, 1)) *
  167. Matrix.CreateTranslation(vp.X / 2, vp.Y / 2, 0);
  168. Memory.IsMouseVisible = true;
  169. ml = Input.MouseLocation.Transform(IGM_focus);
  170. switch (State)
  171. {
  172. case MainMenuStates.LoadGameChooseSlot:
  173. UpdateLGChooseSlot();
  174. break;
  175. case MainMenuStates.LoadGameCheckingSlot:
  176. UpdateLGCheckSlot();
  177. Memory.IsMouseVisible = false;
  178. break;
  179. case MainMenuStates.LoadGameChooseGame:
  180. UpdateLGChooseGame();
  181. break;
  182. case MainMenuStates.LoadGameLoading:
  183. UpdateLG_Loading();
  184. Memory.IsMouseVisible = false;
  185. break;
  186. case MainMenuStates.SaveGameChooseSlot:
  187. UpdateSGChooseSlot();
  188. break;
  189. case MainMenuStates.SaveGameCheckingSlot:
  190. UpdateSGCheckSlot();
  191. Memory.IsMouseVisible = false;
  192. break;
  193. case MainMenuStates.SaveGameChooseGame:
  194. UpdateSGChooseGame();
  195. break;
  196. case MainMenuStates.SaveGameSaving:
  197. UpdateSG_Saving();
  198. Memory.IsMouseVisible = false;
  199. break;
  200. }
  201. }
  202. private static void DrawLGSGHeader(FF8String info, FF8String name, FF8String help) => LGSGHEADER = new Tuple<FF8String, FF8String, FF8String>(info, name, help);
  203. private static Rectangle DrawLGSGHeader() => LGSGHEADER != null ? DrawLGSGHeader(LGSGHEADER) : Rectangle.Empty;
  204. private static Rectangle DrawLGSGHeader(Tuple<FF8String, FF8String, FF8String> tuple)
  205. {
  206. FF8String info = tuple.Item1;
  207. FF8String name = tuple.Item2;
  208. FF8String help = tuple.Item3;
  209. Vector2 TextZoom = Memory.Scale(Width: 960, scaleMode: Memory.ScaleMode.FitBoth);
  210. Vector2 BoxZoom = new Vector2(1, TextZoom.Y);
  211. Rectangle dst = new Rectangle((int)(vp.X * 0.82421875f), 0, (int)(vp.X * 0.17578125f), (int)(vp_per.Y * 0.0916666666666667f));
  212. DrawBox(dst, name, boxScale: BoxZoom, textScale: TextZoom);
  213. dst = new Rectangle(0, dst.Y, (int)(vp.X * 0.8203125f), dst.Height);
  214. DrawBox(dst, info, Icons.ID.INFO, boxScale: BoxZoom, textScale: TextZoom, options: Box_Options.Indent);
  215. dst = new Rectangle((int)(vp.X * 0.0282101167315175f), (int)(dst.Height + dst.Y + vp_per.Y * 0.0041666666666667f), (int)(vp.X * 0.943579766536965f), dst.Height);
  216. DrawBox(dst, help, Icons.ID.HELP, boxScale: BoxZoom, textScale: TextZoom);
  217. return dst;
  218. }
  219. private static void DrawLGSGLoadBar()
  220. {
  221. Rectangle dst = new Rectangle
  222. {
  223. X = (int)(vp_per.X * 0.328125f),
  224. Y = (int)(vp_per.Y * 0.45f),
  225. Width = (int)(vp_per.X * 0.34375f),
  226. Height = (int)(vp_per.Y * 0.1f),
  227. };
  228. dst = DrawBox(dst, null, Icons.ID.INFO).Item1;
  229. dst.Offset(new Vector2
  230. {
  231. X = (vp_per.X * 0.01328125f),
  232. Y = (vp_per.Y * 0.0333333333333333f),
  233. });
  234. dst.Size = (new Point
  235. {
  236. X = (int)(vp_per.X * 0.3171875f),
  237. Y = (int)(vp_per.Y * 0.0333333333333333f),
  238. }.ToVector2()).ToPoint();
  239. Memory.Icons.Draw(Icons.ID.Bar_BG, -1, dst, Vector2.UnitY, fade);
  240. dst.Width = (int)(dst.Width * PercentLoaded);
  241. Memory.Icons.Draw(Icons.ID.Bar_Fill, -1, dst, Vector2.UnitY, fade);
  242. }
  243. private static Tuple<Rectangle, Point, Rectangle> DrawLGSGSlot(Vector2 offset, FF8String title, FF8String main)
  244. {
  245. Rectangle dst = new Rectangle((int)(vp_per.X * 0.3703125f), (int)(vp_per.Y * 0.386111111f), (int)(vp_per.X * 0.259375f), (int)(vp_per.Y * 0.141666667f));
  246. Rectangle slot = new Rectangle(dst.Location, new Point((int)(vp_per.X * 0.1f), (int)(vp_per.Y * 0.0875f)));
  247. slot.Offset(vp_per.X * -0.00859375f, vp_per.Y * -0.033333333f);
  248. slot.Offset(offset);
  249. dst.Offset(offset);
  250. Tuple<Rectangle, Point, Rectangle> location = DrawBox(dst, main, options: Box_Options.Buttom);
  251. DrawBox(slot, title);
  252. return location;
  253. }
  254. private static void DrawPointer(Point cursor, sbyte xoffset = -10, bool blink = false)
  255. {
  256. Rectangle dst = new Rectangle(cursor, new Point(24 * 2, 16 * 2));
  257. dst.Offset(-(dst.Width) + xoffset, -(dst.Height * .25f));
  258. if (blink)
  259. {
  260. Memory.Icons.Draw(Icons.ID.Finger_Right, 7, dst, new Vector2(2f), fade);
  261. }
  262. Memory.Icons.Draw(Icons.ID.Finger_Right, 2, dst, new Vector2(2f), blink ? fade * s_blink : fade);
  263. }
  264. private static void InitLoad()
  265. {
  266. strLoadScreen = new Dictionary<Enum, Item>()
  267. {
  268. { Litems.GameFolder, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,86) } },
  269. { Litems.Load, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,54) } },
  270. { Litems.LoadFF8, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,128) } },
  271. { Litems.Save, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,14) } },
  272. { Litems.SaveFF8, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,117) } },
  273. { Litems.FF8, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,127) } },
  274. { Litems.Loading, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,93) } },
  275. { Litems.Saving, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,94) } },
  276. { Litems.Slot1, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,87) } },
  277. { Litems.Slot2, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,88) } },
  278. { Litems.GameFolderSlot1, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,121) } },
  279. { Litems.GameFolderSlot2, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,122) } },
  280. { Litems.CheckGameFolder, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,110) } },
  281. { Litems.BlockToLoad, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,114) } },
  282. { Litems.BlockToSave, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,89) } },
  283. };
  284. SlotLoc = 0;
  285. BlockLoc = 0;
  286. SlotLocs = new Tuple<Rectangle, Point, Rectangle>[2];
  287. BlockLocs = new Tuple<Rectangle, Point, Rectangle>[3];
  288. }
  289. #endregion Methods
  290. }
  291. }