PartyAP.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using Microsoft.Xna.Framework;
  2. using OpenVIII.Encoding.Tags;
  3. using System.Collections.Concurrent;
  4. using System.Collections.Generic;
  5. namespace OpenVIII.IGMData
  6. {
  7. public class PartyAP : IGMData.Base
  8. {
  9. #region Fields
  10. private readonly FF8String DialogSelectedAbility;
  11. private readonly FF8String DialogSelectedGF;
  12. private readonly FF8String DialogSelectedIcon;
  13. private readonly FF8String DialogSelectedNum;
  14. private readonly FF8String str_GF_AP;
  15. private readonly FF8String str_Learn;
  16. private readonly FF8String str_Levelup;
  17. private ConcurrentQueue<KeyValuePair<GFs, Kernel_bin.Abilities>> _abilities;
  18. private uint _ap;
  19. private GFs _gf;
  20. #endregion Fields
  21. #region Constructors
  22. private PartyAP()
  23. {
  24. DialogSelectedGF = new byte[] { (byte)FF8TextTagCode.Dialog, (byte)FF8TextTagDialog.SelectedGF };
  25. DialogSelectedNum = new byte[] { (byte)FF8TextTagCode.Dialog, (byte)FF8TextTagDialog.Number };
  26. DialogSelectedAbility = new byte[] { (byte)FF8TextTagCode.Dialog, (byte)FF8TextTagDialog.SelectedGFAbility };
  27. DialogSelectedIcon = new byte[] { (byte)FF8TextTagCode.Dialog, (byte)FF8TextTagDialog.CustomICON };
  28. str_Levelup =
  29. Memory.Strings.Read(Strings.FileID.KERNEL, 30, 121) +
  30. DialogSelectedGF + " " +
  31. Memory.Strings.Read(Strings.FileID.KERNEL, 30, 32);
  32. str_Learn =
  33. Memory.Strings.Read(Strings.FileID.KERNEL, 30, 121) +
  34. DialogSelectedGF + "\n " +
  35. Memory.Strings.Read(Strings.FileID.KERNEL, 30, 120) + "\n " +
  36. DialogSelectedIcon + " " +
  37. DialogSelectedAbility +
  38. Memory.Strings.Read(Strings.FileID.KERNEL, 30, 118);
  39. str_GF_AP = Memory.Strings.Read(Strings.FileID.KERNEL, 30, 109);
  40. Leveled = new ConcurrentQueue<GFs>();
  41. }
  42. #endregion Constructors
  43. #region Properties
  44. public ConcurrentQueue<KeyValuePair<GFs, Kernel_bin.Abilities>> Abilities { get => _abilities; set => _abilities = value; }
  45. public uint AP
  46. {
  47. get => _ap; set
  48. {
  49. _ap = value;
  50. ((IGMData.Dialog.Small)ITEM[0, 1]).Data = str_GF_AP.Clone().Replace(DialogSelectedNum, _ap.ToString());
  51. Leveled = Memory.State.EarnAP(_ap, out _abilities);
  52. }
  53. }
  54. public GFs GF { get => _gf; private set => _gf = value; }
  55. public ConcurrentQueue<GFs> Leveled { get; set; }
  56. #endregion Properties
  57. #region Methods
  58. public static PartyAP Create(Rectangle pos)
  59. {
  60. PartyAP r = new PartyAP();
  61. r.Init(1, 7, new IGMDataItem.Empty { Pos = pos }, 1, 1);
  62. return r;
  63. }
  64. public void Earn()
  65. {
  66. skipsnd = true;
  67. init_debugger_Audio.PlaySound(17);
  68. }
  69. public override bool Inputs_CANCEL() => false;
  70. public override bool Inputs_OKAY()
  71. {
  72. base.Inputs_OKAY();
  73. if (ITEM[0, 1].Enabled)
  74. {
  75. ITEM[0, 1].Hide();
  76. ITEM[0, 2].Show();
  77. }
  78. if (Leveled != null && Leveled.Count > 0)
  79. {
  80. Refresh();
  81. return true;
  82. }
  83. else
  84. {
  85. if (Abilities != null && Abilities.Count > 0)
  86. {
  87. if (!ITEM[0, 3].Enabled)
  88. {
  89. ITEM[0, 2].Hide();
  90. ITEM[0, 3].Show();
  91. }
  92. Refresh();
  93. return true;
  94. }
  95. ITEM[0, 1].Show();
  96. ITEM[0, 2].Hide();
  97. ITEM[0, 3].Hide();
  98. }
  99. return false;
  100. }
  101. public void Learn()
  102. {
  103. if (Abilities.TryDequeue(out KeyValuePair<GFs, Kernel_bin.Abilities> Ability))
  104. {
  105. GF = Ability.Key;
  106. ((IGMData.Dialog.Small)ITEM[0, 3]).Data =
  107. str_Learn.Clone()
  108. .Replace(DialogSelectedGF, Memory.Strings.GetName(GF))
  109. .Replace(DialogSelectedIcon, DialogSelectedIcon.Clone() + new byte[] {
  110. (byte)((short)Kernel_bin.AllAbilities[Ability.Value].Icon & 0xFF),
  111. (byte)(((short)Kernel_bin.AllAbilities[Ability.Value].Icon & 0xFF00)>>8),
  112. (Kernel_bin.AllAbilities[Ability.Value].Palette)
  113. })
  114. .Replace(DialogSelectedAbility, Kernel_bin.AllAbilities[Ability.Value].Name);
  115. skipsnd = true;
  116. init_debugger_Audio.PlaySound(0x28);
  117. }
  118. }
  119. public void Level()
  120. {
  121. if (Leveled.TryDequeue(out _gf))
  122. {
  123. ((IGMData.Dialog.Small)ITEM[0, 2]).Data = str_Levelup.Clone().Replace(DialogSelectedGF, Memory.Strings.GetName(GF));
  124. skipsnd = true;
  125. init_debugger_Audio.PlaySound(0x28);
  126. }
  127. }
  128. public override void Refresh()
  129. {
  130. base.Refresh();
  131. if (Enabled)
  132. {
  133. if (ITEM[0, 1].Enabled)
  134. Earn();
  135. else if (ITEM[0, 2].Enabled && Leveled != null && Leveled.Count > 0)
  136. Level();
  137. else if (ITEM[0, 3].Enabled && Abilities != null && Abilities.Count > 0)
  138. Learn();
  139. }
  140. }
  141. protected override void Init()
  142. {
  143. base.Init();
  144. Hide();
  145. ITEM[0, 0] = new IGMDataItem.Box { Data = Memory.Strings.Read(Strings.FileID.KERNEL, 30, 111), Pos = new Rectangle(SIZE[0].X, SIZE[0].Y, SIZE[0].Width, 78), Title = Icons.ID.INFO, Options = Box_Options.Middle };
  146. ITEM[0, 1] = IGMData.Dialog.Small.Create(str_GF_AP, SIZE[0].X + 232, SIZE[0].Y + 315, Icons.ID.NOTICE, Box_Options.Center | Box_Options.Middle, SIZE[0]); // GF recieved ### AP!
  147. ITEM[0, 2] = IGMData.Dialog.Small.Create(null, SIZE[0].X + 232, SIZE[0].Y + 315, Icons.ID.NOTICE, Box_Options.Center | Box_Options.Middle, SIZE[0]); // GF Leveled up!
  148. ITEM[0, 3] = IGMData.Dialog.Small.Create(null, SIZE[0].X + 232, SIZE[0].Y + 315, Icons.ID.NOTICE, Box_Options.Center | Box_Options.Middle, SIZE[0]); // GF Leveled up!
  149. ITEM[0, 1].Show();
  150. ITEM[0, 2].Hide();
  151. ITEM[0, 3].Hide();
  152. Cursor_Status |= (Cursor_Status.Hidden | (Cursor_Status.Enabled | Cursor_Status.Static));
  153. }
  154. #endregion Methods
  155. }
  156. }