PartyGroup.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using Microsoft.Xna.Framework;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. namespace OpenVIII
  6. {
  7. public partial class IGM
  8. {
  9. #region Classes
  10. private class PartyGroup : IGMData.Group.Base
  11. {
  12. #region Fields
  13. private Items _choice;
  14. private Damageable[] _contents;
  15. private bool _eventSet;
  16. #endregion Fields
  17. #region Properties
  18. private NonParty NonParty => ((NonParty)(((IGMData.Base)ITEM[1, 0])));
  19. private Party Party => ((Party)(((IGMData.Base)ITEM[0, 0])));
  20. #endregion Properties
  21. #region Methods
  22. public static new PartyGroup Create(params Menu_Base[] d)
  23. {
  24. var r = Create<PartyGroup>(d);
  25. r.Cursor_Status &= ~(Cursor_Status.Enabled | Cursor_Status.Horizontal | Cursor_Status.Blinking);
  26. r.Cursor_Status |= Cursor_Status.Vertical;
  27. return r;
  28. }
  29. public override bool Inputs()
  30. {
  31. Cursor_Status |= Cursor_Status.Enabled;
  32. return base.Inputs();
  33. }
  34. public override bool Inputs_CANCEL()
  35. {
  36. base.Inputs_CANCEL();
  37. IGM.SetMode(Mode.ChooseItem);
  38. return true;
  39. }
  40. public override bool Inputs_OKAY()
  41. {
  42. var ret = base.Inputs_OKAY();
  43. FadeIn();
  44. switch (_choice)
  45. {
  46. case Items.Junction:
  47. Menu.Module.State = MenuModule.Mode.IGM_Junction;
  48. Junction.Refresh(_contents[CURSOR_SELECT], true);
  49. return true;
  50. }
  51. return ret;
  52. }
  53. public override void ModeChangeEvent(object sender, Enum e)
  54. {
  55. if (!e.Equals(Mode.ChooseChar))
  56. {
  57. Cursor_Status &= ~Cursor_Status.Enabled;
  58. }
  59. }
  60. public override void Refresh()
  61. {
  62. if (!_eventSet && IGM != null)
  63. {
  64. IGM.ModeChangeHandler += ModeChangeEvent;
  65. IGM.ChoiceChangeHandler += ChoiceChangeEvent;
  66. _eventSet = true;
  67. }
  68. base.Refresh();
  69. var totalCount = (Party?.Count ?? 0) + (NonParty?.Count ?? 0);
  70. if (Memory.State?.Characters != null && Memory.State.CharactersCount > 0 && Party != null && NonParty != null)
  71. {
  72. //TODO fix this... should be set in Init not Refresh
  73. SIZE = new Rectangle[totalCount];
  74. CURSOR = new Point[totalCount];
  75. BLANKS = new BitArray(totalCount, false);
  76. _contents = new Damageable[totalCount];
  77. var i = 0;
  78. test(Party, ref i, Party.Contents);
  79. test(NonParty, ref i, NonParty.Contents);
  80. }
  81. void test(IGMData.Base t, ref int i, Damageable[] contents)
  82. {
  83. var pos = 0;
  84. for (; pos < t.Count && i < totalCount; i++)
  85. {
  86. SIZE[i] = t.SIZE[pos];
  87. CURSOR[i] = t.CURSOR[pos];
  88. BLANKS[i] = t.BLANKS[pos];
  89. _contents[i] = contents[pos];
  90. pos++;
  91. }
  92. }
  93. }
  94. private void ChoiceChangeEvent(object sender, KeyValuePair<Items, FF8String> e) => _choice = e.Key;
  95. #endregion Methods
  96. }
  97. #endregion Classes
  98. }
  99. }