TopMenu.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using Microsoft.Xna.Framework;
  2. using System.Diagnostics.CodeAnalysis;
  3. using System.Linq;
  4. namespace OpenVIII
  5. {
  6. public partial class Junction
  7. {
  8. #region Classes
  9. private class TopMenu : IGMData.Base
  10. {
  11. #region Methods
  12. [SuppressMessage("ReSharper", "MemberHidesStaticFromOuterClass")]
  13. public static TopMenu Create() => Create<TopMenu>(4, 1, new IGMDataItem.Box { Pos = new Rectangle(0, 12, 610, 54) }, 4, 1);
  14. public override bool Inputs_CANCEL()
  15. {
  16. if (Memory.PrevState != null &&
  17. Damageable.GetCharacterData(out var c) && (
  18. Memory.PrevState[c.ID].CurrentHP() > c.CurrentHP() ||
  19. Memory.PrevState[c.ID].MaxHP() > c.MaxHP()))
  20. {
  21. Junction.Data[SectionName.ConfirmChanges].Show();
  22. Junction.SetMode(Mode.ConfirmChanges);
  23. }
  24. else
  25. {
  26. base.Inputs_CANCEL();
  27. if (Menu.Module.State != MenuModule.Mode.IGM_Junction) return true;
  28. Menu.Module.State = MenuModule.Mode.IGM;
  29. IGM.Refresh();
  30. FadeIn();
  31. }
  32. return true;
  33. }
  34. public override bool Inputs_OKAY()
  35. {
  36. switch (CURSOR_SELECT)
  37. {
  38. case 0:
  39. Junction.Data[SectionName.TopMenu_Junction].Show();
  40. Cursor_Status |= Cursor_Status.Blinking;
  41. Junction.SetMode(Mode.TopMenu_Junction);
  42. break;
  43. case 1:
  44. Junction.Data[SectionName.TopMenu_Off].Show();
  45. Cursor_Status |= Cursor_Status.Blinking;
  46. Junction.SetMode(Mode.TopMenu_Off);
  47. break;
  48. case 2:
  49. Junction.Data[SectionName.TopMenu_Auto].Show();
  50. Cursor_Status |= Cursor_Status.Blinking;
  51. Junction.SetMode(Mode.TopMenu_Auto);
  52. break;
  53. case 3:
  54. Junction.Data[SectionName.TopMenu_Abilities].Show();
  55. Cursor_Status |= Cursor_Status.Blinking;
  56. Junction.SetMode(Mode.Abilities);
  57. break;
  58. default:
  59. return false;
  60. }
  61. base.Inputs_OKAY();
  62. return true;
  63. }
  64. public override void Refresh()
  65. {
  66. if (Memory.State?.Characters != null && Damageable != null && Damageable.GetCharacterData(out var c))
  67. {
  68. (from i in Enumerable.Range(1, 3)
  69. select new { Key = i, Junctioned = c.JunctionedGFs?.Any() ?? false }).ForEach(x =>
  70. {
  71. BLANKS[x.Key] = !x.Junctioned;
  72. ((IGMDataItem.Text)ITEM[x.Key, 0]).FontColor = x.Junctioned ? Font.ColorID.White : Font.ColorID.Grey;
  73. });
  74. }
  75. base.Refresh();
  76. }
  77. public override bool Update()
  78. {
  79. var ret = base.Update();
  80. if (Junction == null || !Junction.GetMode().Equals(Mode.TopMenu) || !Enabled) return ret;
  81. FF8String changed = null;
  82. switch (CURSOR_SELECT)
  83. {
  84. case 0:
  85. changed = Strings.Description.Junction;
  86. break;
  87. case 1:
  88. changed = Strings.Description.Off;
  89. break;
  90. case 2:
  91. changed = Strings.Description.Auto;
  92. break;
  93. case 3:
  94. changed = Strings.Description.Ability;
  95. break;
  96. }
  97. if (changed != null)
  98. Junction.ChangeHelp(changed);
  99. return ret;
  100. }
  101. protected override void Init()
  102. {
  103. base.Init();
  104. ITEM[0, 0] = new IGMDataItem.Text { Data = Strings.Name.Junction, Pos = SIZE[0] };
  105. ITEM[1, 0] = new IGMDataItem.Text { Data = Strings.Name.Off, Pos = SIZE[1] };
  106. ITEM[2, 0] = new IGMDataItem.Text { Data = Strings.Name.Auto, Pos = SIZE[2] };
  107. ITEM[3, 0] = new IGMDataItem.Text { Data = Strings.Name.Ability, Pos = SIZE[3] };
  108. Cursor_Status |= Cursor_Status.Enabled;
  109. Cursor_Status |= Cursor_Status.Horizontal;
  110. Cursor_Status |= Cursor_Status.Vertical;
  111. }
  112. protected override void InitShift(int i, int col, int row)
  113. {
  114. base.InitShift(i, col, row);
  115. SIZE[i].Inflate(-40, -12);
  116. SIZE[i].Offset(20 + (-20 * (col > 1 ? col : 0)), 0);
  117. }
  118. #endregion Methods
  119. }
  120. #endregion Classes
  121. }
  122. }