Module_main_menu_Loading.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using Microsoft.Xna.Framework.Input;
  4. using System;
  5. using System.Collections.Generic;
  6. namespace FF8
  7. {
  8. /// <summary>
  9. /// class to add offset to point
  10. /// </summary>
  11. public static class PointEx
  12. {
  13. #region Methods
  14. public static Point Offset(this ref Point source, Point offset)
  15. {
  16. source = (source.ToVector2() + offset.ToVector2()).ToPoint();
  17. return source;
  18. }
  19. public static Point Offset(this ref Point source, Vector2 offset)
  20. {
  21. source = (source.ToVector2() + offset).ToPoint();
  22. return source;
  23. }
  24. public static Rectangle Scale(this Rectangle source, Vector2 scale)
  25. {
  26. source.Location = (source.Location.ToVector2() * scale).RoundedPoint();
  27. source.Size = (source.Size.ToVector2() * scale).RoundedPoint();
  28. return source;
  29. }
  30. public static Rectangle Scale(this Rectangle source)
  31. {
  32. Vector2 scale = Memory.Scale();
  33. source.Location = (source.Location.ToVector2() * scale).RoundedPoint();
  34. source.Size = (source.Size.ToVector2() * scale).RoundedPoint();
  35. return source;
  36. }
  37. public static Point Scale(this Point source, Vector2 scale)
  38. {
  39. source = (source.ToVector2() * scale).RoundedPoint();
  40. return source;
  41. }
  42. public static Point Scale(this Point source)
  43. {
  44. Vector2 scale = Memory.Scale();
  45. source = (source.ToVector2() * scale).RoundedPoint();
  46. return source;
  47. }
  48. public static Point RoundedPoint(this Vector2 v) => new Point((int)Math.Round(v.X), (int)Math.Round(v.Y));
  49. public static Point CeilingPoint(this Vector2 v) => v.Ceiling().ToPoint();
  50. public static Point FloorPoint(this Vector2 v) => v.Floor().ToPoint();
  51. public static Vector2 Round(this Vector2 v) => new Vector2 ((float)Math.Round(v.X), (float)Math.Round(v.Y));
  52. public static Vector2 Ceiling(this Vector2 v) => new Vector2((float)Math.Ceiling(v.X), (float)Math.Ceiling(v.Y));
  53. public static Vector2 Floor(this Vector2 v) => new Vector2((float)Math.Floor(v.X), (float)Math.Floor(v.Y));
  54. public static Vector2 FloorOrCeiling(this Vector2 v, Vector2 target)
  55. {
  56. float X, Y;
  57. X = v.X < target.X ? (float)Math.Ceiling(v.X) : (float)Math.Floor(v.X);
  58. Y = v.Y < target.Y ? (float)Math.Ceiling(v.Y) : (float)Math.Floor(v.Y);
  59. return new Vector2(X, Y);
  60. }
  61. #endregion Methods
  62. }
  63. internal static partial class Module_main_menu_debug
  64. {
  65. #region Fields
  66. private static sbyte _slotLoc, _blockLoc;
  67. private static bool blinkstate;
  68. private static int blockpage;
  69. private static RenderTarget2D OffScreenBuffer;
  70. private static float s_blink;
  71. /// <summary>
  72. /// Rectangle is hotspot for mouse, Point is where the finger points
  73. /// </summary>
  74. private static Tuple<Rectangle, Point>[] SlotLocs = new Tuple<Rectangle, Point>[2];
  75. private static Tuple<Rectangle, Point>[] BlockLocs = new Tuple<Rectangle, Point>[3];
  76. private static Texture2D LastPage;
  77. private static Vector2 PageTarget;
  78. private static Vector2 PageSize;
  79. private static Vector2 CurrentPageLoc;
  80. private static Vector2 CurrentLastPageLoc;
  81. private static Vector2 LastPageTarget;
  82. private static Vector2 lastscale;
  83. private static Vector2 scale;
  84. #endregion Fields
  85. #region Enums
  86. private enum Litems
  87. {
  88. GameFolder,
  89. Load,
  90. LoadFF8,
  91. Loading,
  92. Slot1,
  93. Slot2,
  94. FF8,
  95. Save,
  96. SaveFF8,
  97. GameFolderSlot1,
  98. GameFolderSlot2,
  99. CheckGameFolder,
  100. BlockToLoad,
  101. BlockToSave
  102. }
  103. #endregion Enums
  104. #region Properties
  105. public static float blink
  106. {
  107. get => s_blink; private set
  108. {
  109. if (value > 1f)
  110. blinkstate = false;
  111. if (value < 0f)
  112. blinkstate = true;
  113. s_blink = value;
  114. }
  115. }
  116. private static float PercentLoaded { get; set; } = .5f;
  117. private static sbyte SlotLoc
  118. {
  119. get => _slotLoc; set
  120. {
  121. if (value >= SlotLocs.Length)
  122. value = 0;
  123. else if (value < 0)
  124. value = (sbyte)(SlotLocs.Length - 1);
  125. _slotLoc = value;
  126. }
  127. }
  128. private static sbyte BlockLoc
  129. {
  130. get => _blockLoc; set
  131. {
  132. if (value >= BlockLocs.Length)
  133. value = 0;
  134. else if (value < 0)
  135. value = (sbyte)(BlockLocs.Length - 1);
  136. _blockLoc = value;
  137. }
  138. }
  139. public static int Blockpage
  140. {
  141. get => blockpage; set
  142. {
  143. if (value >= 10)
  144. value = 0;
  145. else if (value < 0)
  146. value = 9;
  147. blockpage = value;
  148. }
  149. }
  150. #endregion Properties
  151. #region Methods
  152. private static Tuple<Rectangle, Point> DrawBlock(int block, Saves.Data d)
  153. {
  154. block++;
  155. Rectangle dst = new Rectangle
  156. {
  157. X = 0,
  158. Y = (OffScreenBuffer.Height/3 * ((block - 1) % 3)),
  159. Width = (OffScreenBuffer.Width),
  160. Height = OffScreenBuffer.Height/3,
  161. };
  162. Vector2 offset = dst.Location.ToVector2();
  163. DrawBox(null, null, dst, false, false, true);
  164. Vector2 blocknumpos = new Vector2
  165. {
  166. X = (OffScreenBuffer.Width * 0.00952381f),
  167. Y = 0,
  168. } + offset;
  169. Vector2 blocknumsize = new Vector2(OffScreenBuffer.Height * 0.00628930817610063f);
  170. Memory.Icons.Draw(block++, 4, 2, "D2", blocknumpos, blocknumsize, fade); // 2,2 looks close
  171. Rectangle faceRect = new Rectangle
  172. {
  173. X = (int)(OffScreenBuffer.Width * 0.0654761904761905f),
  174. Y = (int)(OffScreenBuffer.Height * 0.0157232704402516f),
  175. Width = (int)(OffScreenBuffer.Width * 0.113095238095238f),
  176. Height = (int)(OffScreenBuffer.Height * 0.30188679245283f),
  177. };
  178. faceRect.Offset(offset);
  179. sbyte mainchar = -1;
  180. for (byte face = 0; d != null && d.charactersportraits != null && face < d.charactersportraits.Length; face++)
  181. {
  182. if (face != 0)
  183. faceRect.Offset(faceRect.Width, 0);
  184. if (d.charactersportraits[face] != 0xFF)
  185. {
  186. Memory.Faces.Draw((Faces.ID)d.charactersportraits[face], faceRect, Vector2.UnitY, fade);
  187. Memory.Icons.Draw(Icons.ID.MenuBorder, 2, faceRect, new Vector2(1f), fade);
  188. if (mainchar == -1) mainchar = (sbyte)face;
  189. }
  190. }
  191. if (mainchar > -1 && d!=null && d.charactersportraits != null && d.charactersportraits[mainchar] != 0xFF)
  192. {
  193. Point detailsLoc = (new Point
  194. {
  195. X = (int)(OffScreenBuffer.Width * 0.408333333333333f),
  196. Y = (int)(OffScreenBuffer.Height * 0.0251572327044026f),
  197. }.ToVector2() + offset).ToPoint();
  198. FF8String name = Memory.Strings.GetName((Faces.ID)d.charactersportraits[mainchar],d);
  199. FF8String lv_ = new FF8String($"LV. {d.firstcharacterslevel}");
  200. Vector2 TextScale = new Vector2(OffScreenBuffer.Width * 0.0030303030297619f, OffScreenBuffer.Height * 0.00636792452830189f);
  201. Memory.font.RenderBasicText(name, detailsLoc, TextScale, 1, 0, fade, true);
  202. int playy = detailsLoc.Y;
  203. detailsLoc.Y += (int)(OffScreenBuffer.Height * 0.0817610062893082f);
  204. Rectangle disc = Memory.font.RenderBasicText(lv_, detailsLoc, TextScale, 1, 0, fade, true);
  205. disc.Offset(0, (int)(OffScreenBuffer.Height * 0.0125786163522013f));
  206. disc.X = (int)(OffScreenBuffer.Width * 0.583333333333333f);
  207. Vector2 DiscScale = new Vector2(OffScreenBuffer.Height * 0.0060987230787661f);
  208. Memory.Icons.Draw(Icons.ID.DISC, 2, disc, DiscScale, fade);
  209. Vector2 CurrDiscLoc = new Vector2(disc.X + (0.119047619047619f * OffScreenBuffer.Width), disc.Y);
  210. Memory.Icons.Draw((int)d.CurrentDisk+1, 0, 2, "D1", CurrDiscLoc, DiscScale, fade);
  211. float X1 = OffScreenBuffer.Width * 0.952380952380952f;
  212. float X2 = OffScreenBuffer.Width * -0.0238095238095238f;
  213. float X3 = OffScreenBuffer.Width * -0.0952380952380952f;
  214. disc.Location = new Vector2 { X = X1, Y = disc.Y }.ToPoint();
  215. Memory.Icons.Draw(Icons.ID.G, 2, disc, DiscScale, fade);
  216. double digits = Math.Floor(Math.Log10(d.AmountofGil) + 2);
  217. disc.Offset(new Vector2 { X = (float)(digits *X2) });
  218. Memory.Icons.Draw((int)d.AmountofGil, 0, 2, "D1", disc.Location.ToVector2(), DiscScale, fade);
  219. disc.Location = new Vector2 { X = X1, Y = playy }.ToPoint();
  220. disc.Offset(new Vector2 { X =X2 });
  221. Memory.Icons.Draw(d.timeplayed.Minutes, 0, 2, "D2", disc.Location.ToVector2(), DiscScale, fade);
  222. if ((int)d.timeplayed.TotalHours > 0)
  223. {
  224. disc.Offset(new Vector2 { X = 1 *X2 });
  225. Memory.Icons.Draw(Icons.ID.Colon, 13, disc, DiscScale, fade);
  226. disc.Offset(new Vector2 { X = (float)Math.Floor(Math.Log10((int)d.timeplayed.TotalHours) + 1) *X2 });
  227. Memory.Icons.Draw((int)d.timeplayed.TotalHours, 0, 2, "D1", disc.Location.ToVector2(), DiscScale, fade);
  228. }
  229. disc.Offset(new Vector2 { X = X3+X2 });
  230. Memory.Icons.Draw(Icons.ID.PLAY, 13, disc, DiscScale, fade);
  231. Rectangle locbox = new Rectangle
  232. {
  233. X = faceRect.Width + faceRect.X,
  234. Y = (int)(OffScreenBuffer.Height * 0.19496855345912f),
  235. Width = OffScreenBuffer.Width - faceRect.Width - faceRect.X,
  236. Height = (int)(OffScreenBuffer.Height * 0.138364779874214f),
  237. };
  238. locbox.Offset(offset);
  239. DrawBox(null, null, locbox, false, false, true);
  240. FF8String loc = Memory.Strings.Read(Strings.FileID.AREAMES, 0, d.LocationID).ReplaceRegion();
  241. locbox.Offset(0.0297619047619048f * OffScreenBuffer.Width, 0.0440251572327044f * OffScreenBuffer.Height);
  242. Memory.font.RenderBasicText(loc, locbox.Location, TextScale, 1, 0, fade, true);
  243. }
  244. dst.X = (int)(vpWidth * 0f);
  245. dst.Y = (int)(vpHeight * 0.220833333333333f * ((block - 1) % 3));
  246. dst.Width = (int)(vpWidth * 0.65625f);
  247. dst.Height = (int)(vpHeight * 0.220833333333333f);
  248. return new Tuple<Rectangle, Point>(dst, (dst.Location.ToVector2() + new Vector2(25f, dst.Height / 2)).ToPoint());
  249. }
  250. private static Tuple<Rectangle, Point> DrawBox(FF8String buffer, Icons.ID? title, Rectangle dst, bool indent = true, bool bottom = false, bool prescaled = false)
  251. {
  252. Point cursor = new Point(0);
  253. Vector2 scale = prescaled ? Vector2.One : Memory.Scale();
  254. dst.Size = (dst.Size.ToVector2() * scale).ToPoint();
  255. dst.Location = (dst.Location.ToVector2() * scale).ToPoint();
  256. Vector2 bgscale = 2f * scale;
  257. if (dst.Width > 256 * bgscale.X)
  258. Memory.Icons.Draw(Icons.ID.Menu_BG_368, 0, dst, bgscale, Fade);
  259. else
  260. Memory.Icons.Draw(Icons.ID.Menu_BG_256, 0, dst, bgscale, Fade);
  261. Rectangle hotspot = new Rectangle(dst.Location, dst.Size);
  262. dst.Offset(0.01171875f, 0);
  263. if (title != null)
  264. {
  265. //dst.Size = (Memory.Icons[title.Value].GetRectangle.Size.ToVector2() * scale * 2.823317308f).ToPoint();
  266. Memory.Icons.Draw(title.Value, 2, dst, bgscale + (.5f * scale), fade);
  267. }
  268. if (buffer != null && buffer.Length > 0)
  269. {
  270. if (indent)
  271. dst.Offset(0.0546875f * vpWidth * scale.X, 0.0291666666666667f * vpHeight * scale.Y);
  272. else if (bottom)
  273. dst.Offset(0.01953125f * vpWidth * scale.X, dst.Height - 0.066666667f * vpHeight * scale.Y);
  274. else
  275. dst.Offset(0.01953125f * vpWidth * scale.X, 0.0291666666666667f * vpHeight * scale.Y);
  276. Memory.font.RenderBasicText(buffer, dst.Location, new Vector2(2.545454545f, 3.0375f), 1, 0, fade, prescaled);
  277. cursor = dst.Location;
  278. cursor.Y += (int)(18.225f * scale.Y); // 12 * (3.0375/2) * scale.Y
  279. }
  280. return new Tuple<Rectangle, Point>(hotspot, cursor);
  281. }
  282. private static void DrawLGCheckSlot() => DrawLGSGCheckSlot(strLoadScreen[Litems.Load].Text);
  283. private static void DrawLGChooseGame() => DrawLGSGChooseGame(strLoadScreen[Litems.Load].Text, strLoadScreen[Litems.BlockToLoad].Text);
  284. /// <summary>
  285. /// Draw Loading Choose Slot Screen
  286. /// </summary>
  287. private static void DrawLGChooseSlot() => DrawLGSGChooseSlot(strLoadScreen[Litems.Load].Text, strLoadScreen[Litems.LoadFF8].Text);
  288. private static void DrawLGSGCheckSlot(byte[] topright)
  289. {
  290. Memory.SpriteBatchStartAlpha(SamplerState.PointClamp);
  291. DrawLGSGHeader(strLoadScreen[Litems.GameFolderSlot1 + SlotLoc].Text, topright, strLoadScreen[Litems.CheckGameFolder].Text);
  292. DrawLGSGLoadBar();
  293. Memory.SpriteBatchEnd();
  294. }
  295. private static void DrawLGSGChooseGame(byte[] topright, byte[] help)
  296. {
  297. Rectangle dst = new Rectangle
  298. {
  299. X = (int)(vpWidth * 0.171875f),
  300. Y = (int)(vpHeight * 0.266666666666667f),
  301. Width = (int)(vpWidth * 0.65625f),
  302. Height = (int)(vpHeight * 0.6625f),
  303. };
  304. if (OffScreenBuffer != null && !OffScreenBuffer.IsDisposed)
  305. {
  306. Memory.graphics.GraphicsDevice.SetRenderTarget(OffScreenBuffer);
  307. Memory.SpriteBatchStartAlpha(SamplerState.PointClamp);
  308. int bloc = 0;
  309. for (int block = 0 + 3 * (Blockpage); block < 3 + 3 * (Blockpage); block++)
  310. {
  311. Saves.Data d = Saves.FileList == null ? null : Saves.FileList[SlotLoc, block];
  312. Tuple<Rectangle, Point> b = DrawBlock(block, d);
  313. //cords returned by drawblock assume being in the offscreen buffer.
  314. //Which is the size of the 3 blocks. So we need to offset
  315. //everything by the draw location.
  316. Rectangle r = b.Item1;
  317. r.Offset(dst.Location);
  318. Point p = b.Item2;
  319. p.Offset(dst.Location);
  320. BlockLocs[bloc++] = new Tuple<Rectangle, Point>(r, p);
  321. }
  322. Memory.SpriteBatchEnd();
  323. Memory.graphics.GraphicsDevice.SetRenderTarget(null);
  324. }
  325. Memory.SpriteBatchStartAlpha(SamplerState.PointClamp);
  326. DrawLGSGHeader(strLoadScreen[Litems.GameFolderSlot1 + SlotLoc].Text, topright, help);
  327. if (LastPage == null || LastPage.IsDisposed)
  328. {
  329. Entry e = Memory.Icons.GetEntry(Icons.ID.Arrow_Left);
  330. Rectangle arrow = new Rectangle
  331. {
  332. X = (int)(dst.X * scale.X - ((e.Width - 2) * 3f)),
  333. Y = (int)((dst.Y + dst.Height / 2) * scale.Y)
  334. };
  335. Memory.Icons.Draw(Icons.ID.Arrow_Left, 1, arrow, new Vector2(3f), fade);
  336. Memory.Icons.Draw(Icons.ID.Arrow_Left, 2, arrow, new Vector2(3f), fade * blink);
  337. arrow = new Rectangle
  338. {
  339. X = (int)((dst.X + dst.Width) * scale.X + -2 * 3f),
  340. Y = arrow.Y
  341. };
  342. Memory.Icons.Draw(Icons.ID.Arrow_Right2, 1, arrow, new Vector2(3f), fade);
  343. Memory.Icons.Draw(Icons.ID.Arrow_Right2, 2, arrow, new Vector2(3f), fade * blink);
  344. }
  345. float speed = .17f;
  346. if (OffScreenBuffer != null && !OffScreenBuffer.IsDisposed)
  347. {
  348. dst.Location = (dst.Location.ToVector2() * scale).ToPoint();
  349. PageTarget = dst.Location.ToVector2();
  350. dst.Size = (dst.Size.ToVector2() * scale).ToPoint();
  351. PageSize = dst.Size.ToVector2();
  352. CurrentPageLoc = CurrentPageLoc == Vector2.Zero ? PageTarget : Vector2.SmoothStep(CurrentPageLoc, PageTarget, speed).FloorOrCeiling(PageTarget);
  353. dst.Location = CurrentPageLoc.RoundedPoint();
  354. Memory.spriteBatch.Draw(OffScreenBuffer, dst, Color.White * fade);
  355. }
  356. if (LastPage != null && !LastPage.IsDisposed)
  357. {
  358. CurrentLastPageLoc = CurrentLastPageLoc == Vector2.Zero ? PageTarget : Vector2.SmoothStep(CurrentLastPageLoc, LastPageTarget, speed).FloorOrCeiling(LastPageTarget);
  359. if (LastPageTarget == CurrentLastPageLoc)
  360. {
  361. LastPage.Dispose(); CurrentLastPageLoc = Vector2.Zero;
  362. }
  363. else
  364. {
  365. dst.Location = CurrentLastPageLoc.RoundedPoint();
  366. Memory.spriteBatch.Draw(LastPage, dst, Color.White * fade);
  367. }
  368. }
  369. else
  370. {
  371. Point ptr = BlockLocs[BlockLoc].Item2;
  372. ptr = ptr.Scale(scale);
  373. DrawPointer(ptr);
  374. }
  375. Memory.SpriteBatchEnd();
  376. }
  377. /// <summary>
  378. /// Draw Save or Loading Slot Screen
  379. /// </summary>
  380. /// <param name="topright">Text in top right box</param>
  381. /// <param name="help">Text in help box</param>
  382. private static void DrawLGSGChooseSlot(byte[] topright, byte[] help)
  383. {
  384. Memory.SpriteBatchStartAlpha(SamplerState.PointClamp);
  385. DrawLGSGHeader(strLoadScreen[Litems.GameFolder].Text, topright, help);
  386. SlotLocs[0] = DrawLGSGSlot(Vector2.Zero, strLoadScreen[Litems.Slot1].Text, strLoadScreen[Litems.FF8].Text);
  387. SlotLocs[1] = DrawLGSGSlot(new Vector2(0, vpHeight * 0.216666667f), strLoadScreen[Litems.Slot2].Text, strLoadScreen[Litems.FF8].Text);
  388. DrawPointer(SlotLocs[SlotLoc].Item2);
  389. Memory.SpriteBatchEnd();
  390. }
  391. private static Rectangle DrawLGSGHeader(byte[] info, byte[] name, byte[] help)
  392. {
  393. Rectangle dst = new Rectangle((int)(vpWidth * 0.82421875f), (int)(vpHeight * 0.0583333333333333f), (int)(vpWidth * 0.17578125f), (int)(vpHeight * 0.0916666666666667f));
  394. DrawBox(name, null, dst, false);
  395. dst = new Rectangle(0, dst.Y, (int)(vpWidth * 0.8203125f), dst.Height);
  396. DrawBox(info, Icons.ID.INFO, dst);
  397. dst = new Rectangle((int)(vpWidth * 0.0282101167315175f), (int)(dst.Height + dst.Y + vpHeight * 0.0041666666666667f), (int)(vpWidth * 0.943579766536965f), dst.Height);
  398. DrawBox(help, Icons.ID.HELP, dst, false);
  399. return dst;
  400. }
  401. private static void DrawLGSGLoadBar()
  402. {
  403. Rectangle dst = new Rectangle
  404. {
  405. X = (int)(vpWidth * 0.328125f),
  406. Y = (int)(vpHeight * 0.45f),
  407. Width = (int)(vpWidth * 0.34375f),
  408. Height = (int)(vpHeight * 0.1f),
  409. };
  410. dst = DrawBox(null, Icons.ID.INFO, dst).Item1;
  411. dst.Offset(new Vector2
  412. {
  413. X = (vpWidth * 0.01328125f),
  414. Y = (vpHeight * 0.0333333333333333f),
  415. } * scale);
  416. dst.Size = (new Point
  417. {
  418. X = (int)(vpWidth * 0.3171875f),
  419. Y = (int)(vpHeight * 0.0333333333333333f),
  420. }.ToVector2() * scale).ToPoint();
  421. Memory.Icons.Draw(Icons.ID.Bar_BG, -1, dst, Vector2.UnitY, fade);
  422. dst.Width = (int)(dst.Width * PercentLoaded);
  423. Memory.Icons.Draw(Icons.ID.Bar_Fill, -1, dst, Vector2.UnitY, fade);
  424. }
  425. private static Tuple<Rectangle, Point> DrawLGSGSlot(Vector2 offset, byte[] title, byte[] main)
  426. {
  427. Rectangle dst = new Rectangle((int)(vpWidth * 0.3703125f), (int)(vpHeight * 0.386111111f), (int)(vpWidth * 0.259375f), (int)(vpHeight * 0.141666667f));
  428. Rectangle slot = new Rectangle(dst.Location, new Point((int)(vpWidth * 0.1f), (int)(vpHeight * 0.0875f)));
  429. slot.Offset(vpWidth * -0.00859375f, vpHeight * -0.033333333f);
  430. slot.Offset(offset);
  431. dst.Offset(offset);
  432. Tuple<Rectangle, Point> location = DrawBox(main, null, dst, false, true);
  433. DrawBox(title, null, slot, false, false);
  434. return location;
  435. }
  436. private static void DrawLoadingGame() => throw new NotImplementedException();
  437. private static void DrawPointer(Point cursor, sbyte xoffset = -10)
  438. {
  439. Rectangle dst = new Rectangle(cursor, new Point((int)(24 * 2 * scale.X), (int)(16 * 2 * scale.Y)));
  440. dst.Offset(-(dst.Width) + xoffset, -(dst.Height * .25f));
  441. Memory.Icons.Draw(Icons.ID.Finger_Right, 2, dst, 2f * scale, fade);
  442. }
  443. private static void DrawSGCheckSlot() => DrawLGSGCheckSlot(strLoadScreen[Litems.Save].Text);
  444. private static void DrawSGChooseGame() => DrawLGSGChooseGame(strLoadScreen[Litems.Save].Text, strLoadScreen[Litems.BlockToSave].Text);
  445. /// <summary>
  446. /// Draw Save Choose Slot Screen
  447. /// </summary>
  448. private static void DrawSGChooseSlot() => DrawLGSGChooseSlot(strLoadScreen[Litems.Save].Text, strLoadScreen[Litems.SaveFF8].Text);
  449. private static void InitLoad()
  450. {
  451. strLoadScreen = new Dictionary<Enum, Item>()
  452. {
  453. { Litems.GameFolder, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,86) } },
  454. { Litems.Load, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,54) } },
  455. { Litems.LoadFF8, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,128) } },
  456. { Litems.Save, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,14) } },
  457. { Litems.SaveFF8, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,117) } },
  458. { Litems.FF8, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,127) } },
  459. { Litems.Loading, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,93) } },
  460. { Litems.Slot1, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,87) } },
  461. { Litems.Slot2, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,88) } },
  462. { Litems.GameFolderSlot1, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,121) } },
  463. { Litems.GameFolderSlot2, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,122) } },
  464. { Litems.CheckGameFolder, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,110) } },
  465. { Litems.BlockToLoad, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,114) } },
  466. { Litems.BlockToSave, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,89) } },
  467. };
  468. SlotLoc = 0;
  469. BlockLoc = 0;
  470. SlotLocs = new Tuple<Rectangle, Point>[2];
  471. BlockLocs = new Tuple<Rectangle, Point>[3];
  472. }
  473. private static bool UpdateLGChooseGame()
  474. {
  475. if (blinkstate)
  476. blink += Memory.gameTime.ElapsedGameTime.Milliseconds / 2000.0f * 3;
  477. else
  478. blink -= Memory.gameTime.ElapsedGameTime.Milliseconds / 2000.0f * 3;
  479. bool ret = false;
  480. Point ml = Input.MouseLocation;
  481. if (BlockLocs != null && BlockLocs.Length > 0 && BlockLocs[0] != null)
  482. {
  483. for (int i = 0; i < BlockLocs.Length && BlockLocs[i] != null; i++)
  484. {
  485. if (BlockLocs[i].Item1.Scale(scale).Contains(ml))
  486. {
  487. BlockLoc = (sbyte)i;
  488. ret = true;
  489. if (Input.Button(Buttons.MouseWheelup) || Input.Button(Buttons.MouseWheeldown))
  490. {
  491. return ret;
  492. }
  493. break;
  494. }
  495. }
  496. if (Input.Button(Buttons.Down))
  497. {
  498. Input.ResetInputLimit();
  499. init_debugger_Audio.PlaySound(0);
  500. BlockLoc++;
  501. ret = true;
  502. }
  503. else if (Input.Button(Buttons.Left))
  504. {
  505. Input.ResetInputLimit();
  506. init_debugger_Audio.PlaySound(0);
  507. if(LastPage!=null && !LastPage.IsDisposed)
  508. {
  509. LastPage.Dispose();
  510. CurrentLastPageLoc = Vector2.Zero;
  511. }
  512. if (OffScreenBuffer != null && !OffScreenBuffer.IsDisposed)
  513. {
  514. lock (OffScreenBuffer)
  515. {
  516. LastPage = new Texture2D(Memory.graphics.GraphicsDevice, OffScreenBuffer.Width, OffScreenBuffer.Height);
  517. lock (LastPage)
  518. {
  519. Color[] texdata = new Color[OffScreenBuffer.Width * OffScreenBuffer.Height];
  520. OffScreenBuffer.GetData(texdata);
  521. LastPage.SetData(texdata);
  522. LastPageTarget = new Vector2(vpWidth * scale.X, CurrentPageLoc.Y);
  523. CurrentPageLoc = new Vector2(-PageSize.X, CurrentPageLoc.Y);
  524. }
  525. }
  526. }
  527. Blockpage--;
  528. ret = true;
  529. }
  530. else if (Input.Button(Buttons.Right))
  531. {
  532. Input.ResetInputLimit();
  533. init_debugger_Audio.PlaySound(0);
  534. if (LastPage != null && !LastPage.IsDisposed)
  535. {
  536. LastPage.Dispose();
  537. CurrentLastPageLoc = Vector2.Zero;
  538. }
  539. if (OffScreenBuffer != null && !OffScreenBuffer.IsDisposed)
  540. {
  541. lock (OffScreenBuffer)
  542. {
  543. LastPage = new Texture2D(Memory.graphics.GraphicsDevice, OffScreenBuffer.Width, OffScreenBuffer.Height);
  544. lock (LastPage)
  545. {
  546. Color[] texdata = new Color[OffScreenBuffer.Width * OffScreenBuffer.Height];
  547. OffScreenBuffer.GetData(texdata);
  548. LastPage.SetData(texdata);
  549. LastPageTarget = new Vector2(-PageSize.X, CurrentPageLoc.Y);
  550. CurrentPageLoc = new Vector2(vpWidth * scale.X, CurrentPageLoc.Y);
  551. }
  552. }
  553. }
  554. Blockpage++;
  555. ret = true;
  556. }
  557. else if (Input.Button(Buttons.Up))
  558. {
  559. Input.ResetInputLimit();
  560. init_debugger_Audio.PlaySound(0);
  561. BlockLoc--;
  562. ret = true;
  563. }
  564. else if (Input.Button(Keys.PageDown))
  565. {
  566. Input.ResetInputLimit();
  567. init_debugger_Audio.PlaySound(0);
  568. SlotLoc++;
  569. ret = true;
  570. }
  571. else if (Input.Button(Keys.PageUp))
  572. {
  573. Input.ResetInputLimit();
  574. init_debugger_Audio.PlaySound(0);
  575. SlotLoc--;
  576. ret = true;
  577. }
  578. else if (Input.Button(Buttons.Cancel))
  579. {
  580. Input.ResetInputLimit();
  581. init_debugger_Audio.PlaySound(8);
  582. init_debugger_Audio.StopAudio();
  583. Dchoose = 0;
  584. Fade = 0.0f;
  585. State = MainMenuStates.LoadGameChooseSlot;
  586. ret = true;
  587. }
  588. else if (Input.Button(Buttons.Okay))
  589. {
  590. PercentLoaded = 0f;
  591. State = MainMenuStates.LoadGameCheckingSlot;
  592. }
  593. }
  594. if (scale != lastscale && OffScreenBuffer != null && !OffScreenBuffer.IsDisposed)
  595. OffScreenBuffer.Dispose();
  596. if (OffScreenBuffer == null || OffScreenBuffer.IsDisposed)
  597. //if you make these with out disposing enough times gfx driver crashes.
  598. //happened many times if i left this running and had this just ran every draw call. heh.
  599. OffScreenBuffer = new RenderTarget2D(Memory.graphics.GraphicsDevice, (int)(vpWidth * 0.65625f *scale.X), (int)(vpHeight * 0.6625f*scale.Y), false, SurfaceFormat.Color, DepthFormat.None);
  600. return ret;
  601. }
  602. private static bool UpdateLGChooseSlot()
  603. {
  604. bool ret = false;
  605. Point ml = Input.MouseLocation;
  606. for (int i = 0; i < SlotLocs.Length; i++)
  607. {
  608. if (SlotLocs[i].Item1.Contains(ml))
  609. {
  610. SlotLoc = (sbyte)i;
  611. ret = true;
  612. if (Input.Button(Buttons.MouseWheelup) || Input.Button(Buttons.MouseWheeldown))
  613. {
  614. return ret;
  615. }
  616. break;
  617. }
  618. }
  619. if (Input.Button(Buttons.Down))
  620. {
  621. Input.ResetInputLimit();
  622. init_debugger_Audio.PlaySound(0);
  623. SlotLoc++;
  624. ret = true;
  625. }
  626. else if (Input.Button(Buttons.Up))
  627. {
  628. Input.ResetInputLimit();
  629. init_debugger_Audio.PlaySound(0);
  630. SlotLoc--;
  631. ret = true;
  632. }
  633. if (Input.Button(Buttons.Cancel))
  634. {
  635. Input.ResetInputLimit();
  636. init_debugger_Audio.PlaySound(8);
  637. init_debugger_Audio.StopAudio();
  638. Dchoose = 0;
  639. Fade = 0.0f;
  640. State = MainMenuStates.MainLobby;
  641. ret = true;
  642. }
  643. else if (Input.Button(Buttons.Okay))
  644. {
  645. PercentLoaded = 0f;
  646. State = MainMenuStates.LoadGameCheckingSlot;
  647. }
  648. return ret;
  649. }
  650. private static void UpdateLoading() => throw new NotImplementedException();
  651. private static void UpdateLoadingSlot()
  652. {
  653. if (PercentLoaded < 1.0f)
  654. {
  655. PercentLoaded += Memory.gameTime.ElapsedGameTime.Milliseconds / 1000.0f * 3;
  656. }
  657. else
  658. {
  659. State = MainMenuStates.LoadGameChooseGame;
  660. init_debugger_Audio.PlaySound(35);
  661. }
  662. UpdateLGChooseGame();
  663. }
  664. #endregion Methods
  665. }
  666. }