IGMData_Abilities_CommandPool.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using Microsoft.Xna.Framework;
  2. using System.Collections.Generic;
  3. namespace OpenVIII
  4. {
  5. public partial class Junction
  6. {
  7. #region Classes
  8. private class IGMData_Abilities_CommandPool : IGMData.Pool.Base<IReadOnlyDictionary<Kernel.Abilities, Kernel.CommandAbility>, Kernel.Abilities>
  9. {
  10. #region Methods
  11. public static IGMData_Abilities_CommandPool Create()
  12. {
  13. IGMData_Abilities_CommandPool r = null;
  14. if (Memory.KernelBin.CommandAbilities != null)
  15. {
  16. r = Create<IGMData_Abilities_CommandPool>(11, 1, new IGMDataItem.Box { Pos = new Rectangle(435, 150, 405, 480), Title = Icons.ID.COMMAND }, 11, (Memory.KernelBin.CommandAbilities.Count / 11) + (Memory.KernelBin.CommandAbilities.Count % 11 > 0 ? 1 : 0));
  17. r.Source = Memory.KernelBin.CommandAbilities;
  18. }
  19. return r;
  20. }
  21. public override bool Inputs_CANCEL()
  22. {
  23. base.Inputs_CANCEL();
  24. Junction.SetMode(Mode.Abilities);
  25. return true;
  26. }
  27. public override bool Inputs_OKAY()
  28. {
  29. if (Contents[CURSOR_SELECT] != Kernel.Abilities.None && !BLANKS[CURSOR_SELECT] && Damageable.GetCharacterData(out var c))
  30. {
  31. skipsnd = true;
  32. AV.Sound.Play(31);
  33. base.Inputs_OKAY();
  34. var target = ((IGMData.Base)Junction.Data[SectionName.TopMenu_Abilities]).CURSOR_SELECT - 1;
  35. c.Commands[target] = Contents[CURSOR_SELECT];
  36. Junction.SetMode(Mode.Abilities);
  37. Junction.Data[SectionName.TopMenu_Abilities].Refresh();
  38. Junction.Data[SectionName.Commands].Refresh();
  39. return true;
  40. }
  41. return false;
  42. }
  43. public override bool Update()
  44. {
  45. if (Junction != null && !Junction.GetMode().Equals(Mode.Abilities_Commands))
  46. Cursor_Status &= ~Cursor_Status.Enabled;
  47. else
  48. {
  49. Cursor_Status |= Cursor_Status.Enabled;
  50. }
  51. var pos = 0;
  52. var skip = Page * Rows;
  53. if (Damageable != null && Damageable.GetCharacterData(out var c))
  54. for (var i = 0;
  55. Memory.State.Characters &&
  56. i < c.UnlockedGFAbilities.Count &&
  57. pos < Rows; i++)
  58. {
  59. if (c.UnlockedGFAbilities[i] == Kernel.Abilities.None) continue;
  60. var j = (c.UnlockedGFAbilities[i]);
  61. if (!Source.ContainsKey(j) || skip-- > 0) continue;
  62. Font.ColorID cid;
  63. if (c.Commands.Contains(j))
  64. {
  65. cid = Font.ColorID.Grey;
  66. BLANKS[pos] = true;
  67. }
  68. else
  69. {
  70. cid = Font.ColorID.White;
  71. BLANKS[pos] = false;
  72. }
  73. ((IGMDataItem.Text)ITEM[pos, 0]).Data = Source[j].Name;
  74. ((IGMDataItem.Text)ITEM[pos, 0]).FontColor = cid;
  75. ITEM[pos, 0].Show();
  76. Contents[pos] = j;
  77. pos++;
  78. }
  79. for (; pos < Rows; pos++)
  80. {
  81. ITEM[pos, 0].Hide();
  82. BLANKS[pos] = true;
  83. Contents[pos] = Kernel.Abilities.None;
  84. }
  85. if (Contents[CURSOR_SELECT] != Kernel.Abilities.None && Junction.GetMode().Equals(Mode.Abilities_Commands))
  86. Junction.ChangeHelp(Source[Contents[CURSOR_SELECT]].Description);
  87. UpdateTitle();
  88. if (Contents[CURSOR_SELECT] == Kernel.Abilities.None)
  89. CURSOR_NEXT();
  90. if (Pages > 1)
  91. {
  92. if (Contents[0] == Kernel.Abilities.None)
  93. {
  94. //Pages = Page;
  95. PAGE_NEXT();
  96. return Update();
  97. }
  98. //else if (Contents[Rows - 1] == Kernel_bin.Abilities.None)
  99. // Pages = Page + 1;
  100. }
  101. return base.Update();
  102. }
  103. public override void UpdateTitle()
  104. {
  105. base.UpdateTitle();
  106. if (Pages == 1)
  107. {
  108. ((IGMDataItem.Box)CONTAINER).Title = Icons.ID.COMMAND;
  109. ITEM[11, 0].Hide();
  110. ITEM[12, 0].Hide();
  111. }
  112. else
  113. {
  114. ((IGMDataItem.Box)CONTAINER).Title = Icons.ID.COMMAND_PG1 + checked((byte)Page);
  115. ITEM[11, 0].Show();
  116. ITEM[12, 0].Show();
  117. }
  118. }
  119. protected override void Init()
  120. {
  121. base.Init();
  122. for (var pos = 0; pos < Rows; pos++)
  123. ITEM[pos, 0] = new IGMDataItem.Text
  124. {
  125. Icon = Icons.ID.Ability_Command,
  126. Palette = 9,
  127. Pos = new Rectangle(SIZE[pos].X, SIZE[pos].Y, 0, 0)
  128. };
  129. }
  130. protected override void InitShift(int i, int col, int row)
  131. {
  132. base.InitShift(i, col, row);
  133. SIZE[i].Inflate(-22, -8);
  134. SIZE[i].Offset(60, 12 + (-4 * row));
  135. }
  136. #endregion Methods
  137. }
  138. #endregion Classes
  139. }
  140. }