ThreePieceHeader.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using Microsoft.Xna.Framework;
  2. using System;
  3. namespace OpenVIII.IGMData
  4. {
  5. public class ThreePieceHeader : Base
  6. {
  7. #region Properties
  8. public bool Save { get; private set; }
  9. protected IGMDataItem.Box Help { get => (IGMDataItem.Box)ITEM[2, 0]; set => ITEM[2, 0] = value; }
  10. protected IGMDataItem.Box TopLeft { get => (IGMDataItem.Box)ITEM[0, 0]; set => ITEM[0, 0] = value; }
  11. protected IGMDataItem.Box TopRight { get => (IGMDataItem.Box)ITEM[1, 0]; set => ITEM[1, 0] = value; }
  12. #endregion Properties
  13. #region Methods
  14. public static ThreePieceHeader Create(Rectangle pos) => Create(null, null, null, pos);
  15. public static ThreePieceHeader Create(FF8String topLeft, FF8String topRight, FF8String help, Rectangle pos)
  16. {
  17. var r = Create<ThreePieceHeader>(3, 1, new IGMDataItem.Empty { Pos = pos });
  18. r.TopLeft.Data = topLeft;
  19. r.TopRight.Data = topRight;
  20. r.Help.Data = help;
  21. r.TopLeft.Show();
  22. r.TopRight.Show();
  23. r.Help.Show();
  24. return r;
  25. }
  26. public override void ModeChangeEvent(object sender, Enum e)
  27. {
  28. base.ModeChangeEvent(sender, e);
  29. if (e.GetType() == typeof(IGMLoadSaveGame.Mode))
  30. {
  31. Save = e.HasFlag(IGMLoadSaveGame.Mode.Save);
  32. TopRight.Data = Save ? Strings.Name.Save : Strings.Name.Load;
  33. if (e.HasFlag(IGMLoadSaveGame.Mode.Slot1))
  34. TopLeft.Data = Strings.Name.GameFolderSlot1;
  35. else if (e.HasFlag(IGMLoadSaveGame.Mode.Slot2))
  36. TopLeft.Data = Strings.Name.GameFolderSlot2;
  37. else
  38. TopLeft.Data = Strings.Name.GameFolder;
  39. if (e.HasFlag(IGMLoadSaveGame.Mode.Slot) && e.HasFlag(IGMLoadSaveGame.Mode.Choose))
  40. {
  41. Help.Data = Save ? Strings.Name.SaveFF8 : Strings.Name.LoadFF8;
  42. }
  43. else if (e.HasFlag(IGMLoadSaveGame.Mode.Slot) && e.HasFlag(IGMLoadSaveGame.Mode.Checking))
  44. {
  45. Help.Data = Strings.Name.CheckGameFolder;
  46. }
  47. else if (e.HasFlag(IGMLoadSaveGame.Mode.Game) && e.HasFlag(IGMLoadSaveGame.Mode.Choose))
  48. {
  49. Help.Data = Save ? Strings.Name.BlockToSave : Strings.Name.BlockToLoad;
  50. }
  51. else if (e.HasFlag(IGMLoadSaveGame.Mode.Game) && e.HasFlag(IGMLoadSaveGame.Mode.Checking))
  52. {
  53. Help.Data = Save ? Strings.Name.Saving : Strings.Name.Loading;
  54. }
  55. }
  56. }
  57. public void Refresh(FF8String topLeft, FF8String topRight, FF8String help)
  58. {
  59. TopLeft.Data = topLeft;
  60. TopRight.Data = topRight;
  61. Help.Data = help;
  62. Refresh();
  63. }
  64. public override bool Update()
  65. {
  66. var r = base.Update();
  67. r = r || UpdateSize();
  68. return r;
  69. }
  70. protected override void Init()
  71. {
  72. SkipSIZE = true;
  73. base.Init();
  74. TopRight = new IGMDataItem.Box();
  75. TopLeft = new IGMDataItem.Box { Title = Icons.ID.INFO, Options = Box_Options.Indent };
  76. Help = new IGMDataItem.Box { Title = Icons.ID.HELP };
  77. }
  78. private bool UpdateSize()
  79. {
  80. if (CONTAINER.X == ScreenTopLeft.X && !TopRight.Pos.Equals(Rectangle.Empty)) return false;
  81. CONTAINER.X = ScreenTopLeft.X;
  82. CONTAINER.Width = ScreenTopRight.X - ScreenTopLeft.X;
  83. InitSize(true);
  84. const int space = IGMLoadSaveGame.Space;
  85. var widthRight = (int)(base.Width * 0.18f) - space;
  86. widthRight -= widthRight % 4;
  87. var widthLeft = Width - widthRight - space;
  88. TopRight.Pos = new Rectangle(widthLeft + space + X, 0, widthRight, (base.Height - space) / 2);
  89. TopLeft.Pos = new Rectangle(X, 0, widthLeft, TopRight.Height);
  90. Help.Pos = new Rectangle((int)(Width * 0.03f) + X, TopLeft.Height + space, (int)(Width * 0.94f), TopLeft.Height);
  91. return true;
  92. }
  93. #endregion Methods
  94. }
  95. }