PartnerEpiChangePanelCtrl.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using System.Collections.Generic;
  7. using FairyGUI;
  8. using FL.Data;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class PartnerEpiChangePanelCtrl : UIController<PartnerEpiChangePanelVM>
  17. {
  18. protected override void OnEnable(object intent)
  19. {
  20. sbId = (int)intent;
  21. AddUIListenres();
  22. InitView();
  23. UpView();
  24. }
  25. protected override void OnDisable()
  26. {
  27. RemoveUIListenres();
  28. }
  29. #region UI事件
  30. private void AddUIListenres()
  31. {
  32. EventSingle.Instance.AddListener(EventDefine.EpigraphChangeListClick, OnClickItem);
  33. }
  34. private void RemoveUIListenres()
  35. {
  36. EventSingle.Instance.RemoveListener(EventDefine.EpigraphChangeListClick, OnClickItem);
  37. }
  38. private void OnClickItem(int eventId, object args)
  39. {
  40. if (args is not int id)
  41. return;
  42. if (id == sbId)
  43. return;
  44. EpigraphService.Instance.RequestEpiInset(sbId, id);
  45. }
  46. #endregion
  47. #region 属性
  48. private bool isInit = false;
  49. /// <summary>
  50. /// 圣兵id
  51. /// </summary>
  52. private int sbId;
  53. #endregion
  54. #region 页面
  55. private void InitView()
  56. {
  57. if (isInit)
  58. return;
  59. isInit = true;
  60. VM.List.ListType = EGListType.Virtual;
  61. }
  62. private void UpView()
  63. {
  64. var epiList = EpigraphData.Instance.GetEpiList();
  65. var list = new List<EpiChangeListData>();
  66. foreach (var epi in epiList)
  67. {
  68. list.Add(new EpiChangeListData(sbId, epi));
  69. }
  70. VM.List.BindDatas(list);
  71. }
  72. #endregion
  73. }
  74. }