IGM.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using Microsoft.Xna.Framework;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics.CodeAnalysis;
  5. using System.Linq;
  6. #pragma warning disable 67
  7. namespace OpenVIII
  8. {
  9. public partial class IGM : Menu
  10. {
  11. #region Fields
  12. protected Dictionary<Mode, Func<bool>> InputDict;
  13. #endregion Fields
  14. #region Events
  15. public event EventHandler<KeyValuePair<Items, FF8String>> ChoiceChangeHandler;
  16. #endregion Events
  17. #region Enums
  18. [SuppressMessage("ReSharper", "UnusedMember.Global")]
  19. public enum Items
  20. {
  21. Junction,
  22. Item,
  23. Magic,
  24. Status,
  25. GF,
  26. Ability,
  27. Switch,
  28. Card,
  29. Config,
  30. Tutorial,
  31. Save,
  32. Battle,
  33. CurrentExp,
  34. NextLevel,
  35. }
  36. //private Mode _mode = 0;
  37. public enum Mode
  38. {
  39. ChooseItem,
  40. ChooseChar,
  41. }
  42. public enum SectionName
  43. {
  44. Header,
  45. Footer,
  46. Clock,
  47. PartyGroup,
  48. SideMenu,
  49. }
  50. #endregion Enums
  51. #region Methods
  52. public static IGM Create() => Create<IGM>();
  53. public override bool Inputs() => InputDict[(Mode)GetMode()]();
  54. protected override void Init()
  55. {
  56. Size = new Vector2 { X = 843, Y = 630 };
  57. base.Init();
  58. var actions = new Action[]
  59. {
  60. () => Data.TryAdd(SectionName.Header, Header.Create()),
  61. () => Data.TryAdd(SectionName.Footer, Footer.Create()),
  62. () => Data.TryAdd(SectionName.Clock, Clock.Create()),
  63. () => Data.TryAdd(SectionName.PartyGroup, PartyGroup.Create(Party.Create(), NonParty.Create())),
  64. () => {
  65. var keys = new[] {
  66. Strings.Name.SideMenu.Junction,
  67. Strings.Name.SideMenu.Item,
  68. Strings.Name.SideMenu.Magic,
  69. Strings.Name.SideMenu.GF,
  70. Strings.Name.SideMenu.Status,
  71. Strings.Name.SideMenu.Ability,
  72. Strings.Name.SideMenu.Switch,
  73. Strings.Name.SideMenu.Card,
  74. Strings.Name.SideMenu.Config,
  75. Strings.Name.SideMenu.Tutorial,
  76. Strings.Name.SideMenu.Save,
  77. Strings.Name.SideMenu.Battle};
  78. var values = new[] {
  79. Strings.Description.SideMenu.Junction,
  80. Strings.Description.SideMenu.Item,
  81. Strings.Description.SideMenu.Magic,
  82. Strings.Description.SideMenu.GF,
  83. Strings.Description.SideMenu.Status,
  84. Strings.Description.SideMenu.Ability,
  85. Strings.Description.SideMenu.Switch,
  86. Strings.Description.SideMenu.Card,
  87. Strings.Description.SideMenu.Config,
  88. Strings.Description.SideMenu.Tutorial,
  89. Strings.Description.SideMenu.Save,
  90. Strings.Description.SideMenu.Battle};
  91. if(keys.Distinct().Count() == keys.Length && values.Length == keys.Length)
  92. Data.TryAdd(SectionName.SideMenu, SideMenu.Create((from i in Enumerable.Range(0,keys.Length)
  93. select i).ToDictionary(x=>keys[x],x=>values[x])));
  94. else Data.TryAdd(SectionName.SideMenu,null);
  95. }
  96. };
  97. Memory.ProcessActions(actions);
  98. Func<bool> sideMenuInputs = null;
  99. if (Data[SectionName.SideMenu] != null) sideMenuInputs = Data[SectionName.SideMenu].Inputs;
  100. InputDict = new Dictionary<Mode, Func<bool>>
  101. {
  102. { Mode.ChooseItem, sideMenuInputs },
  103. { Mode.ChooseChar, Data[SectionName.PartyGroup].Inputs },
  104. };
  105. SetMode((Mode)0);
  106. }
  107. #endregion Methods
  108. /*
  109. protected virtual void OnChoiceChangeHandler(KeyValuePair<Items, FF8String> e)
  110. {
  111. ChoiceChangeHandler?.Invoke(this, e);
  112. }
  113. */
  114. }
  115. }