XianTuLogPanel.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
  7. using UnityEngine;
  8. namespace Fort23.Mono
  9. {
  10. [UIBinding(prefab = "XianTuLogPanel")]
  11. public partial class XianTuLogPanel : UIPanel, IScrollListContent
  12. {
  13. private int type = 1;
  14. List<XianTuLogConfig> xianTuLogConfigs = new List<XianTuLogConfig>();
  15. List<XianTuLogConfig> shoeXianTuLogConfigs = new List<XianTuLogConfig>();
  16. private void Init()
  17. {
  18. isAddStack = true;
  19. IsShowAppBar = false;
  20. }
  21. protected override void AddEvent()
  22. {
  23. }
  24. protected override void DelEvent()
  25. {
  26. }
  27. public override void AddButtonEvent()
  28. {
  29. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  30. Btn_Main.onClick.AddListener(() =>
  31. {
  32. if(this.type == 1)
  33. return;
  34. UIManager.Instance.DormancyAllGComponent<MainEventLogWidget>();
  35. UIManager.Instance.DormancyAllGComponent<EventLogWidget>();
  36. type = 1;
  37. shoeXianTuLogConfigs = GetTypeXiantuLogConfigs(type);
  38. Content.Init(this, shoeXianTuLogConfigs.Count);
  39. });
  40. Btn_Event.onClick.AddListener(() =>
  41. {
  42. if(this.type == 2)
  43. return;
  44. UIManager.Instance.DormancyAllGComponent<MainEventLogWidget>();
  45. UIManager.Instance.DormancyAllGComponent<EventLogWidget>();
  46. type = 2;
  47. shoeXianTuLogConfigs = GetTypeXiantuLogConfigs(type);
  48. Content.Init(this, shoeXianTuLogConfigs.Count);
  49. });
  50. }
  51. public override CTask<bool> AsyncInit(object[] uiData)
  52. {
  53. xianTuLogConfigs = ConfigComponent.Instance.GetAll<XianTuLogConfig>().ToList();
  54. shoeXianTuLogConfigs = GetTypeXiantuLogConfigs(type);
  55. Content.Init(this, shoeXianTuLogConfigs.Count);
  56. return base.AsyncInit(uiData);
  57. }
  58. private List<XianTuLogConfig> GetTypeXiantuLogConfigs(int type)
  59. {
  60. List<XianTuLogConfig> xiaNTYULogConfigs = new List<XianTuLogConfig>();
  61. foreach (var xianTuLogConfig in xianTuLogConfigs)
  62. {
  63. if (xianTuLogConfig.EventType == type)
  64. {
  65. xiaNTYULogConfigs.Add(xianTuLogConfig);
  66. }
  67. }
  68. return xiaNTYULogConfigs;
  69. }
  70. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  71. {
  72. if (index < 0 || index >= shoeXianTuLogConfigs.Count)
  73. {
  74. return null;
  75. }
  76. if (type == 1)
  77. {
  78. MainEventLogWidget mainEventLogWidget = await UIManager.Instance.CreateGComponent<MainEventLogWidget>(null, Content.GetComponent<RectTransform>());
  79. mainEventLogWidget.CustomInit(shoeXianTuLogConfigs[index]);
  80. return mainEventLogWidget;
  81. }
  82. else
  83. {
  84. EventLogWidget EventLogWidget = await UIManager.Instance.CreateGComponent<EventLogWidget>(null, Content.GetComponent<RectTransform>());
  85. await EventLogWidget.CustomInit(shoeXianTuLogConfigs[index]);
  86. return EventLogWidget;
  87. }
  88. }
  89. public void HindIScorllListWidget(IScorllListWidget widget)
  90. {
  91. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  92. }
  93. public async static CTask OpenPanel()
  94. {
  95. XianTuLogPanel xianTuLogPanel = await UIManager.Instance.LoadAndOpenPanel<XianTuLogPanel>(null);
  96. }
  97. public override void Close()
  98. {
  99. UIManager.Instance.DormancyAllGComponent<MainEventLogWidget>();
  100. UIManager.Instance.DormancyAllGComponent<EventLogWidget>();
  101. type = 2;
  102. base.Close();
  103. }
  104. }
  105. }