IGMData_PartyGroup.cs 3.8 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 IGMData_PartyGroup : IGMData.Group.Base
  11. {
  12. #region Fields
  13. private Items Choice;
  14. private Damageable[] Contents;
  15. private bool eventSet = false;
  16. #endregion Fields
  17. #region Properties
  18. private IGMData_NonParty Non_Party => ((IGMData_NonParty)(((IGMData.Base)ITEM[1, 0])));
  19. private IGMData_Party Party => ((IGMData_Party)(((IGMData.Base)ITEM[0, 0])));
  20. #endregion Properties
  21. #region Methods
  22. public static new IGMData_PartyGroup Create(params Menu_Base[] d)
  23. {
  24. IGMData_PartyGroup r = Create<IGMData_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. bool ret = base.Inputs_OKAY();
  43. FadeIn();
  44. switch (Choice)
  45. {
  46. case Items.Junction:
  47. Menu.Module.State = MenuModule.Mode.IGM_Junction;
  48. IGM_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. int total_Count = (Party?.Count ?? 0) + (Non_Party?.Count ?? 0);
  70. if (Memory.State.Characters != null && Memory.State.Characters.Count > 0 && Party != null && Non_Party != null)
  71. {
  72. //TODO fix this... should be set in Init not Refresh
  73. SIZE = new Rectangle[total_Count];
  74. CURSOR = new Point[total_Count];
  75. BLANKS = new BitArray(total_Count,false);
  76. Contents = new Damageable[total_Count];
  77. int i = 0;
  78. test(Party, ref i, Party.Contents);
  79. test(Non_Party, ref i, Non_Party.Contents);
  80. }
  81. void test(IGMData.Base t, ref int i, Damageable[] contents)
  82. {
  83. int pos = 0;
  84. for (; pos < t.Count && i < total_Count; 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. }