IGMData_Abilities_Group.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using Microsoft.Xna.Framework;
  2. using System.Collections;
  3. namespace OpenVIII
  4. {
  5. public partial class Junction
  6. {
  7. #region Classes
  8. private class IGMData_Abilities_Group : IGMData.Group.Base
  9. {
  10. #region Properties
  11. private IGMData.Slots.Abilities Ability => ((IGMData.Slots.Abilities)ITEM[1, 0]);
  12. private IGMData_Abilities_AbilityPool AbilityPool => ((IGMData_Abilities_AbilityPool)ITEM[3, 0]);
  13. private IGMData.Slots.Command Commands => ((IGMData.Slots.Command)ITEM[0, 0]);
  14. private IGMData_Abilities_CommandPool CommandsPool => ((IGMData_Abilities_CommandPool)ITEM[2, 0]);
  15. #endregion Properties
  16. #region Methods
  17. public static new IGMData_Abilities_Group Create(params Menu_Base[] d) => Create<IGMData_Abilities_Group>(d);
  18. public override bool Inputs()
  19. {
  20. skipdata = true;
  21. var ret = base.Inputs();
  22. skipdata = false;
  23. if (Commands != null)
  24. {
  25. if (CURSOR_SELECT >= Commands.Count)
  26. {
  27. AbilityPool?.Show();
  28. CommandsPool?.Hide();
  29. }
  30. else
  31. {
  32. AbilityPool?.Hide();
  33. CommandsPool?.Show();
  34. }
  35. }
  36. return ret;
  37. }
  38. public override bool Inputs_CANCEL()
  39. {
  40. skipdata = true;
  41. base.Inputs_CANCEL();
  42. skipdata = false;
  43. Junction.Data[SectionName.TopMenu_Abilities].Hide();
  44. Junction.SetMode(Mode.TopMenu);
  45. return true;
  46. }
  47. public override void Inputs_Menu()
  48. {
  49. skipdata = true;
  50. base.Inputs_Menu();
  51. skipdata = false;
  52. if (Commands != null && Damageable.GetCharacterData(out var c))
  53. {
  54. if (CURSOR_SELECT < Commands.Count)
  55. {
  56. c.Commands[CURSOR_SELECT - 1] = Kernel.Abilities.None;
  57. Junction.Data[SectionName.TopMenu_Abilities].Refresh();
  58. Junction.Data[SectionName.Commands].Refresh();
  59. }
  60. else
  61. {
  62. c.Abilities[CURSOR_SELECT - Commands.Count] = Kernel.Abilities.None;
  63. Junction.Refresh();
  64. }
  65. }
  66. }
  67. public override bool Inputs_OKAY()
  68. {
  69. base.Inputs_OKAY();
  70. if (Commands != null)
  71. {
  72. if (CURSOR_SELECT >= Commands.Count)
  73. Junction.SetMode(Mode.Abilities_Abilities);
  74. else
  75. Junction.SetMode(Mode.Abilities_Commands);
  76. return true;
  77. }
  78. return false;
  79. }
  80. public override void Refresh()
  81. {
  82. base.Refresh();
  83. var total_Count = (Commands?.Count ?? 0) + (Ability?.Count ?? 0);
  84. if (Memory.State?.Characters != null)
  85. {//TODO fix this. these values should be set in init() not refresh...
  86. SIZE = new Rectangle[total_Count];
  87. CURSOR = new Point[total_Count];
  88. BLANKS = new BitArray(total_Count,false);
  89. var i = 0;
  90. test(Commands, ref i);
  91. test(Ability, ref i);
  92. }
  93. void test(IGMData.Base t, ref int i)
  94. {
  95. var pos = 0;
  96. for (; t != null && pos < t.Count && i < total_Count; i++)
  97. {
  98. SIZE[i] = t.SIZE[pos];
  99. CURSOR[i] = t.CURSOR[pos];
  100. BLANKS[i] = t.BLANKS[pos];
  101. pos++;
  102. }
  103. }
  104. if (CURSOR_SELECT == 0)
  105. CURSOR_SELECT = 1;
  106. }
  107. public override bool Update()
  108. {
  109. var ret = base.Update();
  110. if (Junction != null && Junction.GetMode().Equals(Mode.Abilities))
  111. {
  112. Cursor_Status &= ~Cursor_Status.Blinking;
  113. if (Commands != null && Ability != null)
  114. {
  115. if (CURSOR_SELECT >= Commands.Count)
  116. {
  117. if (Ability.Descriptions != null && Ability.Descriptions.TryGetValue(CURSOR_SELECT - Commands.Count, out var v))
  118. {
  119. Junction.ChangeHelp(v);
  120. }
  121. }
  122. else
  123. {
  124. if (Commands.Descriptions != null && Commands.Descriptions.TryGetValue(CURSOR_SELECT, out var v))
  125. {
  126. Junction.ChangeHelp(v);
  127. }
  128. }
  129. }
  130. }
  131. else
  132. Cursor_Status |= Cursor_Status.Blinking;
  133. return ret;
  134. }
  135. protected override void Init()
  136. {
  137. base.Init();
  138. Cursor_Status |= Cursor_Status.Enabled;
  139. Hide();
  140. }
  141. #endregion Methods
  142. }
  143. #endregion Classes
  144. }
  145. }