Module_main_menu_InGameMenu.cs 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540
  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 partial class Module_main_menu_debug
  9. {
  10. private class IGM : Menu
  11. {
  12. #region Fields
  13. private Items choSideBar;
  14. private int _choChar;
  15. protected new Mode mode=0;
  16. public int choChar
  17. {
  18. get
  19. {
  20. if (_choChar >= 0 && _choChar < Data[SectionName.Party].Count)
  21. {
  22. if (Data[SectionName.Party].BLANKS[_choChar])
  23. return choCharSet(_choChar + 1);
  24. }
  25. else if (_choChar < Data[SectionName.Non_Party].Count + Data[SectionName.Party].Count && _choChar >= Data[SectionName.Non_Party].Count)
  26. {
  27. if (Data[SectionName.Non_Party].BLANKS[_choChar - Data[SectionName.Party].Count])
  28. return choCharSet(_choChar + 1);
  29. }
  30. return _choChar;
  31. }
  32. set => choCharSet(value);
  33. }
  34. private int choCharSet(int value)
  35. {
  36. while (true)
  37. {
  38. if (value >= 0 && value < Data[SectionName.Party].Count)
  39. {
  40. if (Data[SectionName.Party].BLANKS[value])
  41. {
  42. if (_choChar > value) value--;
  43. else if (_choChar < value) value++;
  44. }
  45. else
  46. {
  47. break;
  48. }
  49. }
  50. else if (value < Data[SectionName.Non_Party].Count + Data[SectionName.Party].Count && value >= Data[SectionName.Party].Count)
  51. {
  52. if (Data[SectionName.Non_Party].BLANKS[value - Data[SectionName.Party].Count])
  53. {
  54. if (_choChar > value) value--;
  55. else if (_choChar < value) value++;
  56. }
  57. else
  58. {
  59. break;
  60. }
  61. }
  62. if (value < 0)
  63. {
  64. value = Data[SectionName.Non_Party].Count + Data[SectionName.Party].Count - 1;
  65. _choChar = int.MaxValue;
  66. }
  67. else if (value >= Data[SectionName.Non_Party].Count + Data[SectionName.Party].Count)
  68. {
  69. value = 0;
  70. _choChar = int.MinValue;
  71. }
  72. }
  73. _choChar = value;
  74. return value;
  75. }
  76. #endregion Fields
  77. #region Enums
  78. public enum Items
  79. {
  80. Junction,
  81. Item,
  82. Magic,
  83. Status,
  84. GF,
  85. Ability,
  86. Switch,
  87. Card,
  88. Config,
  89. Tutorial,
  90. Save,
  91. CurrentEXP,
  92. NextLEVEL
  93. }
  94. protected new enum Mode
  95. {
  96. ChooseItem,
  97. ChooseChar,
  98. }
  99. #endregion Enums
  100. #region Methods
  101. public override void Draw()
  102. {
  103. Memory.SpriteBatchStartAlpha(ss: SamplerState.PointClamp, tm: Focus);
  104. switch (mode)
  105. {
  106. case Mode.ChooseChar:
  107. case Mode.ChooseItem:
  108. default:
  109. base.Draw();
  110. break;
  111. }
  112. switch (mode)
  113. {
  114. case Mode.ChooseChar:
  115. DrawPointer(Data[SectionName.SideMenu].CURSOR[(int)choSideBar], blink: true);
  116. if (choChar < Data[SectionName.Party].Count && choChar >= 0)
  117. DrawPointer(Data[SectionName.Party].CURSOR[choChar]);
  118. else if (choChar < Data[SectionName.Non_Party].Count + Data[SectionName.Party].Count && choChar >= Data[SectionName.Party].Count)
  119. DrawPointer(Data[SectionName.Non_Party].CURSOR[choChar - Data[SectionName.Party].Count]);
  120. break;
  121. default:
  122. DrawPointer(Data[SectionName.SideMenu].CURSOR[(int)choSideBar]);
  123. break;
  124. }
  125. Memory.SpriteBatchEnd();
  126. }
  127. public enum SectionName
  128. {
  129. Header,
  130. Footer,
  131. SideMenu,
  132. Clock,
  133. Party,
  134. Non_Party
  135. }
  136. protected override void Init()
  137. {
  138. Size = new Vector2 { X = 843, Y = 630 };
  139. TextScale = new Vector2(2.545455f, 3.0375f);
  140. IGMData Header = new IGMData_Header();
  141. IGMData Footer = new IGMData_Footer();
  142. IGMData Clock = new IGMData_Clock();
  143. IGMData SideMenu = new IGMData_SideMenu();
  144. IGMData Non_Party = new IGMData_NonParty();
  145. IGMData Party = new IGMData_Party();
  146. Data.Add(SectionName.Header, Header);
  147. Data.Add(SectionName.Footer, Footer);
  148. Data.Add(SectionName.Clock, Clock);
  149. Data.Add(SectionName.SideMenu, SideMenu);
  150. Data.Add(SectionName.Party, Party);
  151. Data.Add(SectionName.Non_Party, Non_Party);
  152. base.Init();
  153. }
  154. public override bool Update()
  155. {
  156. base.Update();
  157. ((IGMData_Header)Data[SectionName.Header]).Update(choSideBar);
  158. return Inputs();
  159. }
  160. protected override bool Inputs()
  161. {
  162. bool ret = false;
  163. foreach (KeyValuePair<Enum, IGMData> i in Data)
  164. {
  165. i.Value.Inputs();
  166. }
  167. ml = Input.MouseLocation.Transform(Focus);
  168. if (mode == Mode.ChooseItem)
  169. {
  170. if (Data[SectionName.SideMenu] != null && Data[SectionName.SideMenu].Count > 0)
  171. {
  172. for (int pos = 0; pos < Data[SectionName.SideMenu].Count; pos++)
  173. {
  174. Rectangle r = Data[SectionName.SideMenu].ITEM[pos, 0];
  175. if (r.Contains(ml))
  176. {
  177. choSideBar = (Items)pos;
  178. ret = true;
  179. if (Input.Button(Buttons.MouseWheelup) || Input.Button(Buttons.MouseWheeldown))
  180. {
  181. return ret;
  182. }
  183. break;
  184. }
  185. }
  186. if (Input.Button(Buttons.Down))
  187. {
  188. Input.ResetInputLimit();
  189. init_debugger_Audio.PlaySound(0);
  190. if ((int)++choSideBar >= ((IGMData_SideMenu)Data[SectionName.SideMenu]).Count)
  191. choSideBar = 0;
  192. ret = true;
  193. }
  194. else if (Input.Button(Buttons.Up))
  195. {
  196. Input.ResetInputLimit();
  197. init_debugger_Audio.PlaySound(0);
  198. if (--choSideBar < 0)
  199. choSideBar = (Items)((IGMData_SideMenu)Data[SectionName.SideMenu]).Count-1;
  200. ret = true;
  201. }
  202. else if (Input.Button(Buttons.Cancel))
  203. {
  204. Input.ResetInputLimit();
  205. init_debugger_Audio.PlaySound(8);
  206. Fade = 0.0f;
  207. State = MainMenuStates.LoadGameChooseGame;
  208. ret = true;
  209. }
  210. else if (Input.Button(Buttons.Okay))
  211. {
  212. Input.ResetInputLimit();
  213. init_debugger_Audio.PlaySound(0);
  214. ret = true;
  215. switch (choSideBar)
  216. {
  217. //Select Char Mode
  218. case Items.Junction:
  219. case Items.Magic:
  220. case Items.Status:
  221. mode = Mode.ChooseChar;
  222. break;
  223. }
  224. }
  225. }
  226. }
  227. else if (mode == Mode.ChooseChar)
  228. {
  229. for (int i = 0; i < Data[SectionName.Party].Count; i++)
  230. {
  231. if (Data[SectionName.Party].BLANKS[i]) continue;
  232. Rectangle r = Data[SectionName.Party].SIZE[i];
  233. if (r.Contains(ml))
  234. {
  235. choChar = i;
  236. ret = true;
  237. if (Input.Button(Buttons.MouseWheelup) || Input.Button(Buttons.MouseWheeldown))
  238. {
  239. return ret;
  240. }
  241. break;
  242. }
  243. }
  244. for (int i = Data[SectionName.Party].Count; i < Data[SectionName.Non_Party].Count + Data[SectionName.Party].Count; i++)
  245. {
  246. if (Data[SectionName.Non_Party].BLANKS[i - Data[SectionName.Party].Count]) continue;
  247. Rectangle r = Data[SectionName.Non_Party].SIZE[i - Data[SectionName.Party].Count];
  248. //r.Offset(focus.Translation.X, focus.Translation.Y);
  249. if (r.Contains(ml))
  250. {
  251. choChar = i;
  252. ret = true;
  253. if (Input.Button(Buttons.MouseWheelup) || Input.Button(Buttons.MouseWheeldown))
  254. {
  255. return ret;
  256. }
  257. break;
  258. }
  259. }
  260. if (Input.Button(Buttons.Down))
  261. {
  262. Input.ResetInputLimit();
  263. init_debugger_Audio.PlaySound(0);
  264. choChar++;
  265. ret = true;
  266. }
  267. else if (Input.Button(Buttons.Up))
  268. {
  269. Input.ResetInputLimit();
  270. init_debugger_Audio.PlaySound(0);
  271. choChar--;
  272. ret = true;
  273. }
  274. else if (Input.Button(Buttons.Cancel))
  275. {
  276. Input.ResetInputLimit();
  277. ret = true;
  278. init_debugger_Audio.PlaySound(8);
  279. mode = Mode.ChooseItem;
  280. }
  281. else if (Input.Button(Buttons.Okay))
  282. {
  283. Input.ResetInputLimit();
  284. init_debugger_Audio.PlaySound(0);
  285. ret = true;
  286. switch (choSideBar)
  287. {
  288. //Select Char Mode
  289. case Items.Junction:
  290. //case Items.Magic:
  291. //case Items.Status:
  292. State = MainMenuStates.IGM_Junction;
  293. if (choChar < 3)
  294. InGameMenu_Junction.ReInit(Memory.State.PartyData[choChar], Memory.State.Party[choChar]);
  295. else
  296. {
  297. int pos = 0;
  298. if (!Memory.State.TeamLaguna && !Memory.State.SmallTeam)
  299. {
  300. for (byte i = 0; Memory.State.Party != null && i < Memory.State.Characters.Count; i++)
  301. {
  302. if (!Memory.State.PartyData.Contains((Characters)i) && Memory.State.Characters[(Characters)i].VisibleInMenu)
  303. {
  304. if (pos++ + 3 == choChar)
  305. {
  306. InGameMenu_Junction.ReInit((Characters)i, (Characters)i);
  307. break;
  308. }
  309. }
  310. }
  311. }
  312. }
  313. break;
  314. }
  315. }
  316. }
  317. return ret;
  318. }
  319. protected class IGMData_Header : IGMData
  320. {
  321. private Dictionary<Enum, Item> strHeaderText;
  322. public IGMData_Header() : this(0, 0, new IGMDataItem_Box(pos: new Rectangle { Width = 610, Height = 75 }, title: Icons.ID.HELP))
  323. { }
  324. public IGMData_Header(int count, int depth, IGMDataItem container = null) : base(count, depth, container)
  325. {
  326. }
  327. protected override void Init()
  328. {
  329. strHeaderText = new Dictionary<Enum, Item>()
  330. {
  331. { Items.Junction, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,1) } },
  332. { Items.Item, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,3) } },
  333. { Items.Magic, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,5) } },
  334. { Items.Status, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,9) } },
  335. { Items.GF, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,7) } },
  336. { Items.Ability, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,63) } },
  337. { Items.Switch, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,65) } },
  338. { Items.Card, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,11) } },
  339. { Items.Config, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,17) } },
  340. { Items.Tutorial, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,68) } },
  341. { Items.Save, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,15) } },
  342. };
  343. base.Init();
  344. }
  345. public bool Update(IGM.Items selection)
  346. {
  347. ((IGMDataItem_Box)CONTAINER).Data = strHeaderText[selection];
  348. return true;
  349. }
  350. private new bool Update() => base.Update();
  351. }
  352. private class IGMData_Footer : IGMData
  353. {
  354. public IGMData_Footer() : this(0, 0, new IGMDataItem_Box(pos: new Rectangle { Width = 610, Height = 75, Y = 630 - 75 }))
  355. {
  356. }
  357. public IGMData_Footer(int count, int depth, IGMDataItem container = null) : base(count, depth, container)
  358. {
  359. }
  360. public override bool Update()
  361. {
  362. base.Update();
  363. ((IGMDataItem_Box)CONTAINER).Data = Memory.Strings.Read(Strings.FileID.AREAMES, 0, Memory.State.LocationID).ReplaceRegion();
  364. return true;
  365. }
  366. }
  367. private class IGMData_Clock : IGMData
  368. {
  369. public IGMData_Clock() : this(1, 8, new IGMDataItem_Box(pos: new Rectangle { Width = 226, Height = 114, Y = 630 - 114, X = 843 - 226 }))
  370. {
  371. }
  372. public IGMData_Clock(int count, int depth, IGMDataItem container = null) : base(count, depth, container)
  373. {
  374. }
  375. protected override void Init()
  376. {
  377. Rectangle r;
  378. r = CONTAINER;
  379. r.Offset(25, 14);
  380. ITEM[0, 0] = new IGMDataItem_Icon(Icons.ID.PLAY, r, 13);
  381. r = CONTAINER;
  382. r.Offset(145, 14);
  383. ITEM[0, 2] = new IGMDataItem_Icon(Icons.ID.Colon, r, 13, 2, .5f);
  384. r = CONTAINER;
  385. r.Offset(185, 81);
  386. ITEM[0, 7] = new IGMDataItem_Icon(Icons.ID.G, r, 2);
  387. base.Init();
  388. }
  389. public override void ReInit()
  390. {
  391. base.ReInit();
  392. Rectangle r;
  393. r = CONTAINER;
  394. r.Offset(105, 14);
  395. ITEM[0, 1] = new IGMDataItem_Int(Memory.State.Timeplayed.TotalHours < 99 ? (int)(Memory.State.Timeplayed.TotalHours) : 99, r, 2, 0, 1, 2);
  396. r = CONTAINER;
  397. r.Offset(165, 14);
  398. ITEM[0, 3] = new IGMDataItem_Int(Memory.State.Timeplayed.TotalHours < 99 ? Memory.State.Timeplayed.Minutes : 99, r, 2, 0, 2, 2);
  399. if (!Memory.State.TeamLaguna)
  400. {
  401. r = CONTAINER;
  402. r.Offset(25, 48);
  403. ITEM[0, 4] = new IGMDataItem_Icon(Icons.ID.SeeD, r, 13);
  404. r = CONTAINER;
  405. r.Offset(105, 48);
  406. ITEM[0, 5] = Memory.State.Fieldvars != null
  407. ? new IGMDataItem_Int(Memory.State.Fieldvars.SeedRankPts / 100 < 99999 ? Memory.State.Fieldvars.SeedRankPts / 100 : 99999, r, 2, 0, 1, 5)
  408. : null;
  409. }
  410. else
  411. {
  412. ITEM[0, 4] = null;
  413. ITEM[0, 5] = null;
  414. }
  415. r = CONTAINER;
  416. r.Offset(25, 81);
  417. ITEM[0, 6] = new IGMDataItem_Int(Memory.State.AmountofGil < 99999999 ? (int)(Memory.State.AmountofGil) : 99999999, r, 2, 0, 1,8);
  418. }
  419. public override bool Update()
  420. {
  421. bool ret = base.Update();
  422. return ret;
  423. }
  424. }
  425. private class IGMData_NonParty : IGMData
  426. {
  427. private Texture2D _red_pixel;
  428. public IGMData_NonParty() : base(6, 9, new IGMDataItem_Box(pos: new Rectangle { Width = 580, Height = 231, X = 20, Y = 318 }),2,3)
  429. {
  430. }
  431. public override void Draw()
  432. {
  433. if (!Memory.State.TeamLaguna && !Memory.State.SmallTeam)
  434. base.Draw();
  435. }
  436. protected override void InitShift(int i, int col, int row)
  437. {
  438. base.InitShift(i, col, row);
  439. SIZE[i].Inflate(-26, -8);
  440. if (row >= 1) SIZE[i].Y -= 4;
  441. if (row >= 2) SIZE[i].Y -= 4;
  442. }
  443. protected override void Init()
  444. {
  445. Table_Options |= Table_Options.FillRows;
  446. _red_pixel = new Texture2D(Memory.graphics.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
  447. Color[] color = new Color[] { new Color(74.5f / 100, 12.5f / 100, 11.8f / 100, 100) };
  448. _red_pixel.SetData<Color>(color, 0, _red_pixel.Width * _red_pixel.Height);
  449. base.Init();
  450. }
  451. public override bool Update()
  452. {
  453. sbyte pos = 0;
  454. bool ret = base.Update();
  455. if (!Memory.State.TeamLaguna && !Memory.State.SmallTeam)
  456. {
  457. for (byte i = 0; Memory.State.Party != null && i < Memory.State.Characters.Count && SIZE != null && pos < SIZE.Length; i++)
  458. {
  459. if (!Memory.State.Party.Contains((Characters)i) && Memory.State.Characters[(Characters)i].VisibleInMenu)
  460. {
  461. BLANKS[pos] = false;
  462. Update(pos++, (Characters)i);
  463. }
  464. }
  465. }
  466. for (; pos < Count; pos++)
  467. {
  468. for (int i = 0; i < Depth; i++)
  469. {
  470. BLANKS[pos] = true;
  471. ITEM[pos, i] = null;
  472. }
  473. }
  474. return true;
  475. }
  476. private void Update(sbyte pos, Characters character)
  477. {
  478. float yoff = 39;
  479. Rectangle rbak = SIZE[pos];
  480. Rectangle r = rbak;
  481. Color color = new Color(74.5f / 100, 12.5f / 100, 11.8f / 100, .9f);
  482. ITEM[pos, 0] = new IGMDataItem_String(Memory.Strings.GetName(character), rbak);
  483. CURSOR[pos] = new Point(rbak.X, (int)(rbak.Y + (6 * TextScale.Y)));
  484. r.Offset(7, yoff);
  485. ITEM[pos, 1] = new IGMDataItem_Icon(Icons.ID.Lv, r, 13);
  486. r = rbak;
  487. r.Offset((49), yoff);
  488. ITEM[pos, 2] = new IGMDataItem_Int(Memory.State.Characters[character].Level, r, 2, 0, 1,3);
  489. r = rbak;
  490. r.Offset(126, yoff);
  491. ITEM[pos, 3] = new IGMDataItem_Icon(Icons.ID.HP2, r, 13);
  492. r.Offset(0, 28);
  493. r.Width = 118;
  494. r.Height = 1;
  495. ITEM[pos, 4] = new IGMDataItem_Texture(_red_pixel, r) { Color = Color.Black };
  496. r.Width = (int)(r.Width * Memory.State.Characters[character].PercentFullHP());
  497. ITEM[pos, 5] = new IGMDataItem_Texture(_red_pixel, r) { Color = color };
  498. r.Width = 118;
  499. r.Offset(0, 2);
  500. ITEM[pos, 6] = new IGMDataItem_Texture(_red_pixel, r) { Color = Color.Black };
  501. r.Width = (int)(r.Width * Memory.State.Characters[character].PercentFullHP());
  502. ITEM[pos, 7] = new IGMDataItem_Texture(_red_pixel, r) { Color = color };
  503. //TODO red bar resizes based on current/max hp
  504. r = rbak;
  505. r.Offset((166), yoff);
  506. ITEM[pos, 8] = new IGMDataItem_Int(Memory.State.Characters[character].CurrentHP(), r, 2, 0, 1,4);
  507. }
  508. }
  509. private class IGMData_Party : IGMData
  510. {
  511. private int vSpace;
  512. private Dictionary<Enum, FF8String> strings;
  513. public IGMData_Party() : base(3, 12)
  514. {
  515. }
  516. public IGMData_Party(int count, int depth, IGMDataItem container = null) : base(count, depth, container)
  517. {
  518. }
  519. public override void ReInit()
  520. {
  521. base.ReInit();
  522. if (!Memory.State.TeamLaguna && !Memory.State.SmallTeam)
  523. {
  524. CONTAINER = new IGMDataItem_Empty(pos: new Rectangle { Width = 580, Height = 234, X = 20, Y = 84 });
  525. vSpace = 0;
  526. }
  527. else
  528. {
  529. CONTAINER = new IGMDataItem_Empty(pos: new Rectangle { Width = 580, Height = 462, X = 20, Y = 84 });
  530. vSpace = 6;
  531. }
  532. for (int i = 0; i < 3; i++)
  533. SIZE[i] = new Rectangle { Width = Width, Height = (Height / 3) - vSpace, X = X, Y = Y + (Height / 3 * i) };
  534. }
  535. public override bool Update()
  536. {
  537. bool ret = base.Update();
  538. for (sbyte i = 0; Memory.State.PartyData != null && i < SIZE.Length; i++)
  539. Update(i, Memory.State.PartyData[i], Memory.State.Party[i]);
  540. return true;
  541. }
  542. protected override void Init()
  543. {
  544. strings = new Dictionary<Enum, FF8String>()
  545. {
  546. { Items.CurrentEXP, Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,23) },
  547. { Items.NextLEVEL, Memory.Strings.Read(Strings.FileID.MNGRP, 0 ,24) },
  548. };
  549. base.Init();
  550. }
  551. private void Update(sbyte pos, Characters character, Characters visableCharacter)
  552. {
  553. if (SIZE != null)
  554. {
  555. if (character != Characters.Blank)
  556. {
  557. float yoff = 6;
  558. ITEM[pos, 0] = new IGMDataItem_Box(Memory.Strings.GetName(visableCharacter), title: Icons.ID.STATUS);
  559. Tuple<Rectangle, Point, Rectangle> dims = DrawBox(SIZE[pos], ((IGMDataItem_Box)ITEM[pos, 0]).Data, options: Box_Options.SkipDraw);
  560. Rectangle r = dims.Item3;
  561. ITEM[pos, 0].Pos = dims.Item1;
  562. CURSOR[pos] = dims.Item2;
  563. r = dims.Item3;
  564. r.Offset(184, yoff);
  565. ITEM[pos, 1] = new IGMDataItem_Icon(Icons.ID.Lv, r, 13);
  566. r = dims.Item3;
  567. r.Offset((229), yoff);
  568. ITEM[pos, 2] = new IGMDataItem_Int(Memory.State.Characters[character].Level, r, 2, 0, 1,3);
  569. r = dims.Item3;
  570. r.Offset(304, yoff);
  571. ITEM[pos, 3] = new IGMDataItem_Icon(Icons.ID.HP2, r, 13);
  572. r = dims.Item3;
  573. r.Offset((354), yoff);
  574. ITEM[pos, 4] = new IGMDataItem_Int(Memory.State.Characters[character].CurrentHP(visableCharacter), r, 2, 0, 1,4);
  575. r = dims.Item3;
  576. r.Offset(437, yoff);
  577. ITEM[pos, 5] = new IGMDataItem_Icon(Icons.ID.Slash_Forward, r, 13);
  578. r = dims.Item3;
  579. r.Offset((459), yoff);
  580. ITEM[pos, 6] = new IGMDataItem_Int(Memory.State.Characters[character].MaxHP(visableCharacter), r, 2, 0,1,4);
  581. if (Memory.State.TeamLaguna || Memory.State.SmallTeam)
  582. {
  583. BLANKS[pos] = false;
  584. r = dims.Item3;
  585. r.Offset(145, 36);
  586. ITEM[pos, 7] = new IGMDataItem_String(strings[Items.CurrentEXP] + new FF8String("\n") + strings[Items.NextLEVEL], r);
  587. r = dims.Item3;
  588. r.Offset((340), 42);
  589. ITEM[pos, 8] = new IGMDataItem_Int((int)Memory.State.Characters[character].Experience, r, 2, 0, 1,9);
  590. r = dims.Item3;
  591. r.Offset(520, 42);
  592. ITEM[pos, 9] = new IGMDataItem_Icon(Icons.ID.P, r, 2);
  593. r = dims.Item3;
  594. r.Offset((340), 75);
  595. ITEM[pos, 10] = new IGMDataItem_Int(Memory.State.Characters[character].ExperienceToNextLevel, r, 2, 0, 1,9);
  596. r = dims.Item3;
  597. r.Offset(520, 75);
  598. ITEM[pos, 11] = new IGMDataItem_Icon(Icons.ID.P, r, 2);
  599. }
  600. else
  601. for (int i = 7; i < Depth; i++)
  602. ITEM[pos, i] = null;
  603. }
  604. else
  605. {
  606. ITEM[pos, 0] = new IGMDataItem_Box(pos: SIZE[pos]);
  607. BLANKS[pos] = true;
  608. for (int i = 1; i < Depth; i++)
  609. {
  610. ITEM[pos, i] = null;
  611. }
  612. }
  613. }
  614. }
  615. }
  616. private class IGMData_SideMenu : IGMData
  617. {
  618. public IGMData_SideMenu() : base(11, 1, new IGMDataItem_Box(pos: new Rectangle { Width = 226, Height = 492, X = 843 - 226 }),1,11)
  619. {
  620. }
  621. protected override void InitShift(int i, int col, int row)
  622. {
  623. base.InitShift(i, col, row);
  624. SIZE[i].Inflate(-26, -12);
  625. ITEM[i, 0].Pos = SIZE[i];
  626. }
  627. protected override void Init()
  628. {
  629. ITEM[0, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 0));
  630. ITEM[1, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 2));
  631. ITEM[2, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 4));
  632. ITEM[3, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 8));
  633. ITEM[4, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 6));
  634. ITEM[5, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 62));
  635. ITEM[6, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 64));
  636. ITEM[7, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 10));
  637. ITEM[8, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 16));
  638. ITEM[9, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 67));
  639. ITEM[10, 0] = new IGMDataItem_String(Memory.Strings.Read(Strings.FileID.MNGRP, 0, 14));
  640. base.Init();
  641. }
  642. public override bool Inputs() => base.Inputs();
  643. public override bool Update() => base.Update();
  644. }
  645. #endregion Methods
  646. }
  647. #region Classes
  648. /// <summary>
  649. /// Flags for cursor behavior
  650. /// </summary>
  651. /// <remarks>Defaults to disabled.</remarks>
  652. [Flags]
  653. public enum Cursor_Status
  654. {
  655. /// <summary>
  656. /// Hide Cursor and disable all code that uses it.
  657. /// </summary>
  658. Disabled = 0x0,
  659. /// <summary>
  660. /// Show Cursor
  661. /// </summary>
  662. Enabled = 0x1,
  663. /// <summary>
  664. /// Triggers blinking
  665. /// </summary>
  666. Blinking = 0x2,
  667. /// <summary>
  668. /// Makes it react to left and right instead of up and down.
  669. /// </summary>
  670. Horizontal = 0x4,
  671. /// <summary>
  672. /// This is the default but if you want both directions you need to set the flag.
  673. /// </summary>
  674. Vertical = 0x8,
  675. /// <summary>
  676. /// Just draw.
  677. /// </summary>
  678. Draw = 0x10,
  679. }
  680. [Flags]
  681. public enum Table_Options
  682. {
  683. /// <summary>
  684. /// No flags set.
  685. /// </summary>
  686. Default = 0x0,
  687. /// <summary>
  688. /// Default fills 1 col at a time. This will make it fill 1 row at a time.
  689. /// </summary>
  690. FillRows = 0x1,
  691. }
  692. public class IGMData
  693. {
  694. #region Fields
  695. public Dictionary<int, FF8String> Descriptions { get; protected set; }
  696. protected bool skipdata = false;
  697. /// <summary>
  698. /// location of where pointer finger will point.
  699. /// </summary>
  700. public Point[] CURSOR;
  701. public bool Enabled
  702. {
  703. get => _enabled;
  704. set
  705. {
  706. _enabled = value;
  707. }
  708. }
  709. public Table_Options Table_Options { get; set; } = Table_Options.Default;
  710. public Cursor_Status Cursor_Status { get; set; } = Cursor_Status.Disabled;
  711. public int CURSOR_SELECT
  712. {
  713. get => _cursor_select; set
  714. {
  715. if ((Cursor_Status & Cursor_Status.Enabled) != 0 && value >= 0 && value < CURSOR.Length && CURSOR[value] != Point.Zero)
  716. _cursor_select = value;
  717. }
  718. }
  719. public virtual int CURSOR_NEXT()
  720. {
  721. if ((Cursor_Status & Cursor_Status.Enabled) != 0)
  722. {
  723. int value = _cursor_select;
  724. int loop = 0;
  725. while (true)
  726. {
  727. if (++value >= CURSOR.Length)
  728. {
  729. value = 0;
  730. if (loop++ > 1) break;
  731. }
  732. if ((CURSOR[value] != Point.Zero && !BLANKS[value])) break;
  733. }
  734. _cursor_select = value;
  735. }
  736. return _cursor_select;
  737. }
  738. public virtual int CURSOR_PREV()
  739. {
  740. if ((Cursor_Status & Cursor_Status.Enabled) != 0)
  741. {
  742. int value = _cursor_select;
  743. int loop = 0;
  744. while (true)
  745. {
  746. if (--value < 0)
  747. {
  748. value = CURSOR.Length - 1;
  749. if (loop++ > 1) break;
  750. }
  751. if ((CURSOR[value] != Point.Zero && !BLANKS[value])) break;
  752. }
  753. _cursor_select = value;
  754. }
  755. return _cursor_select;
  756. }
  757. public IGMDataItem[,] ITEM;
  758. /// <summary>
  759. /// Size of the entire area
  760. /// </summary>
  761. public Rectangle[] SIZE;
  762. public bool[] BLANKS;
  763. private int _cursor_select;
  764. private bool _enabled = true;
  765. protected bool skipsnd = false;
  766. public IGMDataItem CONTAINER { get; protected set; }
  767. #endregion Fields
  768. #region Constructors
  769. public IGMData(int count, int depth, IGMDataItem container = null, int? cols = null, int? rows = null)
  770. {
  771. SIZE = new Rectangle[count];
  772. ITEM = new IGMDataItem[count, depth];
  773. CURSOR = new Point[count];
  774. Count = (byte)count;
  775. Depth = (byte)depth;
  776. BLANKS = new bool[count];
  777. if (container != null)
  778. CONTAINER = container;
  779. CURSOR_SELECT = 0;
  780. this.cols = cols ?? 1;
  781. this.rows = rows ?? 1;
  782. Descriptions = new Dictionary<int, FF8String>(count);
  783. Init();
  784. ReInit();
  785. Update();
  786. }
  787. public IGMDataItem this[int pos, int i] { get => ITEM[pos, i]; set => ITEM[pos, i] = value; }
  788. /// <summary>
  789. /// Draw all items
  790. /// </summary>
  791. public virtual void Draw()
  792. {
  793. if (Enabled)
  794. {
  795. if (CONTAINER != null)
  796. CONTAINER.Draw();
  797. if(!skipdata)
  798. foreach (IGMDataItem i in ITEM)
  799. {
  800. if (i != null)
  801. i.Draw();
  802. }
  803. if ((Cursor_Status & (Cursor_Status.Enabled | Cursor_Status.Draw)) != 0)
  804. {
  805. DrawPointer(CURSOR[CURSOR_SELECT], blink: ((Cursor_Status & Cursor_Status.Blinking) != 0));
  806. }
  807. }
  808. }
  809. #endregion Constructors
  810. #region Properties
  811. /// <summary>
  812. /// Total number of items
  813. /// </summary>
  814. public byte Count { get; private set; }
  815. /// <summary>
  816. /// How many Peices per Item. Example 1 box could have 9 things to draw in it.
  817. /// </summary>
  818. public byte Depth { get; private set; }
  819. /// <summary>
  820. /// Container's Width
  821. /// </summary>
  822. public int Width => CONTAINER != null ? CONTAINER.Pos.Width : 0;
  823. /// <summary>
  824. /// Container's Height
  825. /// </summary>
  826. public int Height => CONTAINER != null ? CONTAINER.Pos.Height : 0;
  827. /// <summary>
  828. /// Container's X Position
  829. /// </summary>
  830. public int X => CONTAINER != null ? CONTAINER.Pos.X : 0;
  831. /// <summary>
  832. /// Container's Y Position
  833. /// </summary>
  834. public int Y => CONTAINER != null ? CONTAINER.Pos.Y : 0;
  835. public int rows { get; private set; }
  836. public int cols { get; private set; }
  837. /// <summary>
  838. /// Convert to rectangle based on container.
  839. /// </summary>
  840. /// <param name="v">Input data</param>
  841. public static implicit operator Rectangle(IGMData v) => v.CONTAINER ?? Rectangle.Empty;
  842. /// <summary>
  843. /// Things that change on every update.
  844. /// </summary>
  845. /// <returns>True = signifigant change</returns>
  846. public virtual bool Update() => false;
  847. /// <summary>
  848. /// Check inputs
  849. /// </summary>
  850. /// <returns>True = input detected</returns>
  851. public virtual bool Inputs()
  852. {
  853. bool ret = false;
  854. bool mouse = false;
  855. if ((Cursor_Status & Cursor_Status.Enabled) != 0)
  856. {
  857. Cursor_Status &= ~Cursor_Status.Blinking;
  858. ml = Input.MouseLocation.Transform(Menu.Focus);
  859. for (int i = 0; i < SIZE.Length; i++)
  860. {
  861. if (SIZE[i].Contains(ml) && !SIZE[i].IsEmpty && CURSOR[i] != Point.Zero && !BLANKS[i])
  862. {
  863. CURSOR_SELECT = i;
  864. ret = true;
  865. mouse = true;
  866. }
  867. }
  868. if (!ret && (Cursor_Status & Cursor_Status.Horizontal) != 0)
  869. {
  870. if (Input.Button(Buttons.Left))
  871. {
  872. CURSOR_PREV();
  873. ret = true;
  874. }
  875. else if (Input.Button(Buttons.Right))
  876. {
  877. CURSOR_NEXT();
  878. ret = true;
  879. }
  880. }
  881. if (!ret && (Cursor_Status & Cursor_Status.Horizontal) == 0 || (Cursor_Status & Cursor_Status.Vertical) != 0)
  882. {
  883. if (Input.Button(Buttons.Up))
  884. {
  885. CURSOR_PREV();
  886. ret = true;
  887. }
  888. else if (Input.Button(Buttons.Down))
  889. {
  890. CURSOR_NEXT();
  891. ret = true;
  892. }
  893. }
  894. if (!ret || mouse)
  895. {
  896. if (Input.Button(Buttons.Okay))
  897. {
  898. Inputs_OKAY();
  899. return true;
  900. }
  901. else if (Input.Button(Buttons.Cancel))
  902. {
  903. Inputs_CANCEL();
  904. return true;
  905. }
  906. else if (Input.Button(Buttons.Triangle))
  907. {
  908. Inputs_Triangle();
  909. return true;
  910. }
  911. else if (Input.Button(Buttons.Square))
  912. {
  913. Inputs_Triangle();
  914. return true;
  915. }
  916. }
  917. if (ret && !mouse)
  918. {
  919. Input.ResetInputLimit();
  920. if (!skipsnd)
  921. init_debugger_Audio.PlaySound(0);
  922. }
  923. }
  924. skipsnd = false;
  925. return ret;
  926. }
  927. public virtual void Inputs_Triangle()
  928. {
  929. Input.ResetInputLimit();
  930. if (!skipsnd)
  931. init_debugger_Audio.PlaySound(0);
  932. }
  933. public virtual void Inputs_Square()
  934. {
  935. Input.ResetInputLimit();
  936. if (!skipsnd)
  937. init_debugger_Audio.PlaySound(31);
  938. }
  939. public virtual void Inputs_OKAY()
  940. {
  941. Input.ResetInputLimit();
  942. if (!skipsnd)
  943. init_debugger_Audio.PlaySound(0);
  944. }
  945. public virtual void Inputs_CANCEL()
  946. {
  947. Input.ResetInputLimit();
  948. if (!skipsnd)
  949. init_debugger_Audio.PlaySound(8);
  950. }
  951. protected virtual void InitShift(int i, int col, int row)
  952. {
  953. }
  954. /// <summary>
  955. /// Things that are fixed values at startup.
  956. /// </summary>
  957. protected virtual void Init()
  958. {
  959. if (SIZE.Length > 0)
  960. {
  961. for (int i = 0; i < SIZE.Length; i++)
  962. {
  963. int col = (Table_Options & Table_Options.FillRows) != 0 ? i % cols : i / rows;
  964. int row = (Table_Options & Table_Options.FillRows) != 0 ? i / cols : i % rows;
  965. if (col < cols && row < rows)
  966. {
  967. if (SIZE[i].IsEmpty) //allows for override a size value before the loop.
  968. {
  969. SIZE[i] = new Rectangle
  970. {
  971. X = X + (Width * col) / cols,
  972. Y = Y + (Height * row) / rows,
  973. Width = Width / cols,
  974. Height = Height / rows,
  975. };
  976. }
  977. InitShift(i, col, row);
  978. CURSOR[i].Y += (int)(SIZE[i].Y + SIZE[i].Height / 2 - 6 * TextScale.Y);
  979. CURSOR[i].X += SIZE[i].X;
  980. }
  981. }
  982. }
  983. if (SIZE.Length == 0 || SIZE[0].IsEmpty)
  984. {
  985. if (CURSOR.Length == 0 || SIZE.Length == 0)
  986. {
  987. CURSOR = new Point[1];
  988. SIZE = new Rectangle[1];
  989. }
  990. CURSOR[0].Y = (int)(Y + Height / 2 - 6 * TextScale.Y);
  991. CURSOR[0].X = X;
  992. SIZE[0] = new Rectangle(X, Y, Width, Height);
  993. }
  994. }
  995. /// <summary>
  996. /// Things that change rarely. Like a party member changes or Laguna dream happens.
  997. /// </summary>
  998. public virtual void ReInit()
  999. {
  1000. }
  1001. #endregion Properties
  1002. }
  1003. public abstract class IGMDataItem//<T>
  1004. {
  1005. //protected T _data;
  1006. protected Rectangle _pos;
  1007. public Vector2 Scale { get; set; }
  1008. public IGMDataItem(Rectangle? pos = null, Vector2? scale = null)
  1009. {
  1010. _pos = pos ?? Rectangle.Empty;
  1011. Scale = scale ?? Menu.TextScale;
  1012. }
  1013. /// <summary>
  1014. /// Where to draw this item.
  1015. /// </summary>
  1016. public virtual Rectangle Pos { get => _pos; set => _pos = value; }
  1017. public Color Color { get; set; } = Color.White;
  1018. //public virtual object Data { get; public set; }
  1019. //public virtual FF8String Data { get; public set; }
  1020. public abstract void Draw();
  1021. public static implicit operator Rectangle(IGMDataItem v) => v.Pos;
  1022. public static implicit operator Color(IGMDataItem v) => v.Color;
  1023. public static implicit operator IGMDataItem(IGMData v)
  1024. {
  1025. return new IGMDataItem_IGMData(v);
  1026. }
  1027. public virtual void ReInit()
  1028. { }
  1029. public virtual bool Update()
  1030. { return false; }
  1031. public virtual bool Inputs()
  1032. { return false; }
  1033. }
  1034. public class IGMDataItem_IGMData : IGMDataItem
  1035. {
  1036. public IGMData Data { get; set; }
  1037. public IGMDataItem_IGMData(IGMData data, Rectangle? pos = null) : base(pos)
  1038. {
  1039. Data = data;
  1040. }
  1041. public override void Draw()
  1042. {
  1043. Data.Draw();
  1044. }
  1045. public override bool Update()
  1046. {
  1047. bool ret = base.Update();
  1048. return ret || Data.Update();
  1049. }
  1050. public override bool Inputs()
  1051. {
  1052. bool ret = base.Inputs();
  1053. return ret || Data.Inputs();
  1054. }
  1055. public override void ReInit()
  1056. {
  1057. base.ReInit();
  1058. Data.ReInit();
  1059. }
  1060. }
  1061. public class IGMDataItem_Empty : IGMDataItem
  1062. {
  1063. public IGMDataItem_Empty(Rectangle? pos = null) : base(pos)
  1064. {
  1065. }
  1066. public override void Draw()
  1067. {
  1068. }
  1069. }
  1070. public class IGMDataItem_Icon : IGMDataItem//<Icons.ID>
  1071. {
  1072. private byte _pallet;
  1073. private byte _faded_pallet;
  1074. public Icons.ID Data { get; set; }
  1075. public byte Pallet
  1076. {
  1077. get => _pallet; set
  1078. {
  1079. if (value >= 16) value = 2;
  1080. _pallet = value;
  1081. }
  1082. }
  1083. public byte Faded_Pallet
  1084. {
  1085. get => _faded_pallet; set
  1086. {
  1087. if (value >= 16) value = 2;
  1088. _faded_pallet = value;
  1089. }
  1090. }
  1091. public bool Blink => Faded_Pallet != Pallet;
  1092. public float Blink_Adjustment { get; set; }
  1093. public IGMDataItem_Icon(Icons.ID data, Rectangle? pos = null, byte? pallet = null, byte? faded_pallet = null, float blink_adjustment = 1f,Vector2? scale = null) : base(pos,scale)
  1094. {
  1095. Data = data;
  1096. Pallet = pallet ?? 2;
  1097. Faded_Pallet = faded_pallet ?? Pallet;
  1098. Blink_Adjustment = blink_adjustment;
  1099. }
  1100. public override void Draw()
  1101. {
  1102. Memory.Icons.Draw(Data, Pallet, Pos, Scale, fade);
  1103. if (Blink)
  1104. Memory.Icons.Draw(Data, Faded_Pallet, Pos, Scale, fade * blink_Amount * Blink_Adjustment);
  1105. }
  1106. }
  1107. /// <summary>
  1108. /// Contains only one IGMDataItem.
  1109. /// </summary>
  1110. public class IGMData_Container : IGMData
  1111. {
  1112. public IGMData_Container(IGMDataItem container) : base(0, 0, container)
  1113. {
  1114. }
  1115. }
  1116. public class IGMDataItem_Face : IGMDataItem
  1117. {
  1118. private byte _pallet;
  1119. public Faces.ID Data { get; set; }
  1120. public byte Pallet
  1121. {
  1122. get => _pallet; set
  1123. {
  1124. if (value >= 16) value = 2;
  1125. _pallet = value;
  1126. }
  1127. }
  1128. public bool Blink { get; private set; }
  1129. public float Blink_Adjustment { get; set; }
  1130. public IGMDataItem_Face(Faces.ID data, Rectangle? pos = null, bool blink=false, float blink_adjustment = 1f) : base(pos)
  1131. {
  1132. Data = data;
  1133. Blink = blink;
  1134. Blink_Adjustment = blink_adjustment;
  1135. }
  1136. public override void Draw()
  1137. {
  1138. Memory.Faces.Draw(Data, Pos, Vector2.UnitY, fade);
  1139. if (Blink)
  1140. Memory.Faces.Draw(Data, Pos, Vector2.UnitY, fade * blink_Amount * Blink_Adjustment);
  1141. }
  1142. }
  1143. public class IGMDataItem_Int : IGMDataItem//<Int>
  1144. {
  1145. private byte _pallet;
  1146. private int Spaces;
  1147. private int SpaceWidth;
  1148. public int Data { get; set; }
  1149. public byte Padding { get; set; }
  1150. public byte Pallet
  1151. {
  1152. get => _pallet; set
  1153. {
  1154. if (value >= 16) value = 2;
  1155. _pallet = value;
  1156. }
  1157. }
  1158. public Icons.NumType NumType { get; set; }
  1159. private int Digits;
  1160. public IGMDataItem_Int(int data, Rectangle? pos = null, byte? pallet = null, Icons.NumType? numtype = null, byte? padding = null, int? spaces = null, int? spacewidth = null) : base(pos)
  1161. {
  1162. Data = data;
  1163. Padding = padding ?? 1;
  1164. Pallet = pallet ?? 2;
  1165. NumType = numtype ?? 0;
  1166. Digits = data.ToString().Length;
  1167. if (Digits < padding) Digits = (int)padding;
  1168. Spaces = spaces??1;
  1169. SpaceWidth = spacewidth??20;
  1170. _pos.Offset(SpaceWidth * (Spaces - Digits), 0);
  1171. }
  1172. public override void Draw() => Memory.Icons.Draw(Data, NumType, Pallet, $"D{Padding}", Pos.Location.ToVector2(), Scale, fade);
  1173. }
  1174. private class IGMDataItem_String : IGMDataItem
  1175. {
  1176. public FF8String Data { get; set; }
  1177. public Font.ColorID Colorid { get; set; }
  1178. public Icons.ID? Icon { get; set; }
  1179. public int Pallet { get; set; }
  1180. public IGMDataItem_String(FF8String data, Rectangle? pos = null,Font.ColorID? color = null): base(pos)
  1181. {
  1182. Data = data;
  1183. Colorid = color??Font.ColorID.White;
  1184. }
  1185. public IGMDataItem_String(Icons.ID? icon, int pallet, FF8String data, Rectangle? pos = null, Font.ColorID? color = null) : base(pos)
  1186. {
  1187. Icon = icon;
  1188. Pallet = pallet;
  1189. Data = data;
  1190. Colorid = color ?? Font.ColorID.White;
  1191. }
  1192. public override void Draw()
  1193. {
  1194. Rectangle r = Pos;
  1195. if (Icon != null && Icon != Icons.ID.None)
  1196. {
  1197. Rectangle r2 = r;
  1198. r2.Size = Point.Zero;
  1199. Memory.Icons.Draw(Icon, Pallet, r2, new Vector2(Scale.X), fade);
  1200. r.Offset(Memory.Icons.GetEntryGroup(Icon).Width*Scale.X, 0);
  1201. }
  1202. Memory.font.RenderBasicText(Data, r.Location, Scale, Fade: fade, color: Colorid);
  1203. }
  1204. }
  1205. private class IGMDataItem_Box : IGMDataItem
  1206. {
  1207. public FF8String Data { get; set; }
  1208. public Icons.ID? Title { get; set; }
  1209. public Box_Options Options { get; set; }
  1210. public Tuple<Rectangle, Point, Rectangle> Dims { get; private set; }
  1211. public IGMDataItem_Box(FF8String data = null, Rectangle? pos = null, Icons.ID? title = null, Box_Options options = Box_Options.Default) : base(pos)
  1212. {
  1213. Data = data;
  1214. Title = title;
  1215. Options = options;
  1216. }
  1217. public override void Draw() =>
  1218. Dims = DrawBox(Pos, Data, Title, options: Options);
  1219. }
  1220. private class IGMDataItem_Texture : IGMDataItem
  1221. {
  1222. public Texture2D Data { get; set; }
  1223. public IGMDataItem_Texture(Texture2D data, Rectangle? pos = null) : base(pos) => this.Data = data;
  1224. public override void Draw() => Memory.spriteBatch.Draw(Data, Pos, null, base.Color * fade);//4
  1225. }
  1226. #endregion Classes
  1227. private abstract class Menu
  1228. {
  1229. /// <summary>
  1230. /// replace me with new keyword
  1231. /// </summary>
  1232. protected enum Mode
  1233. {
  1234. UNDEFINDED
  1235. }
  1236. public Dictionary<Enum, IGMData> Data;
  1237. /// <summary>
  1238. /// replace me with new keyword or cast me to your new enum.
  1239. /// </summary>
  1240. protected Enum mode=(Mode)0;
  1241. private Vector2 _size;
  1242. static public Vector2 TextScale { get; protected set; }
  1243. static public Matrix Focus;
  1244. private bool skipdata;
  1245. public Vector2 Size { get => _size; protected set => _size = value; }
  1246. public Menu()
  1247. {
  1248. Data = new Dictionary<Enum, IGMData>();
  1249. Init();
  1250. skipdata = true;
  1251. ReInit();
  1252. skipdata = false;
  1253. }
  1254. protected virtual void Init()
  1255. {
  1256. }
  1257. public virtual void ReInit()
  1258. {
  1259. if(!skipdata)
  1260. foreach (KeyValuePair<Enum, IGMData> i in Data)
  1261. i.Value.ReInit();
  1262. //Update();
  1263. }
  1264. public virtual void StartDraw()
  1265. {
  1266. Memory.SpriteBatchStartAlpha(ss: SamplerState.PointClamp, tm: Focus);
  1267. }
  1268. public virtual void Draw()
  1269. {
  1270. if (!skipdata)
  1271. foreach (KeyValuePair<Enum, IGMData> i in Data)
  1272. i.Value.Draw();
  1273. }
  1274. public virtual void EndDraw()
  1275. {
  1276. Memory.SpriteBatchEnd();
  1277. }
  1278. public virtual bool Update()
  1279. {
  1280. Vector2 Zoom = Memory.Scale(Size.X, Size.Y, Memory.ScaleMode.FitBoth);
  1281. Focus = Matrix.CreateTranslation((Size.X / -2), (Size.Y / -2), 0) *
  1282. Matrix.CreateScale(new Vector3(Zoom.X, Zoom.Y, 1)) *
  1283. Matrix.CreateTranslation(vp.X / 2, vp.Y / 2, 0);
  1284. //todo detect when there is no saves detected.
  1285. //check for null
  1286. if(!skipdata)
  1287. foreach (KeyValuePair<Enum, IGMData> i in Data)
  1288. {
  1289. i.Value.Update();
  1290. }
  1291. return false;
  1292. }
  1293. public class IGMData_Group : IGMData
  1294. {
  1295. public IGMData_Group(params IGMData[] d) : base(d.Length, 1)
  1296. {
  1297. for (int i = 0; i < d.Length; i++)
  1298. {
  1299. ITEM[i, 0] = d[i];
  1300. }
  1301. }
  1302. public override bool Inputs()
  1303. {
  1304. bool ret = base.Inputs();
  1305. if (!skipdata)
  1306. foreach (var i in ITEM)
  1307. {
  1308. ret = ret || i.Inputs();
  1309. }
  1310. return ret;
  1311. }
  1312. public override void ReInit()
  1313. {
  1314. base.ReInit();
  1315. if (!skipdata)
  1316. foreach (var i in ITEM)
  1317. {
  1318. if (i != null)
  1319. i.ReInit();
  1320. }
  1321. }
  1322. public override bool Update()
  1323. {
  1324. bool ret = base.Update();
  1325. if (!skipdata)
  1326. foreach (var i in ITEM)
  1327. {
  1328. if (i != null)
  1329. ret = ret || i.Update();
  1330. }
  1331. return ret;
  1332. }
  1333. }
  1334. protected abstract bool Inputs();
  1335. }
  1336. }
  1337. }