PartnerEpiChangeListItemCtrl.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using FL.Data;
  8. using XGame;
  9. using XGame.Database;
  10. using XGame.Framework.UI;
  11. namespace FL.FGUI
  12. {
  13. /// <summary>
  14. /// UI逻辑处理类
  15. /// </summary>
  16. /// <typeparam name=""></typeparam>
  17. public partial class PartnerEpiChangeListItemCtrl : UIController<PartnerEpiChangeListItemVM>
  18. {
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. }
  23. protected override void OnDisable()
  24. {
  25. RemoveUIListenres();
  26. }
  27. #region UI事件
  28. private void AddUIListenres()
  29. {
  30. VM.EpiLabel.VM.PanelEvent.Add(OnClick);
  31. }
  32. private void RemoveUIListenres()
  33. {
  34. VM.EpiLabel.VM.PanelEvent.Remove(OnClick);
  35. }
  36. private void OnClick(EventContext eventContext)
  37. {
  38. EventSingle.Instance.Notify(EventDefine.EpigraphChangeSelect, _mwId);
  39. }
  40. #endregion
  41. #region 属性
  42. private int _sbId;
  43. private int _mwId;
  44. private int _planId;
  45. private int _curSelectId;
  46. #endregion
  47. #region 页面
  48. public void OnRefresh(int index, EpiChangeListData data)
  49. {
  50. _sbId = data.SbId;
  51. _mwId = data.MwId;
  52. _planId = data.PlanId;
  53. _curSelectId = data.CurSelectId;
  54. UpEpiInfo();
  55. }
  56. private void UpEpiInfo()
  57. {
  58. var table = EpigraphTableRepo.Get(_mwId);
  59. if (table == null)
  60. {
  61. Log.Error($"铭文表不存在id:{_mwId}");
  62. return;
  63. }
  64. VM.EpiLabel.Ctrl.SetEpiIcon(_mwId, true);
  65. VM.NameLabel.text = table.Name;
  66. VM.IsSelect.selectedIndex = _mwId == _curSelectId ? 1 : 0;
  67. var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_mwId);
  68. if (info == null)
  69. {
  70. Log.Error($"铭文数据不存在,id:{_mwId}");
  71. return;
  72. }
  73. if (_planId != PartnersData.Instance.UsePlanId)
  74. {
  75. if (!PartnersData.Instance.TryGetPlan(_planId, out var plan))
  76. {
  77. Log.Error($"方案信息不存在,planid:{_planId}");
  78. return;
  79. }
  80. var isUP = false;
  81. foreach (var slot in plan.Slots)
  82. {
  83. if (slot.MwId == _mwId)
  84. {
  85. isUP = true;
  86. break;
  87. }
  88. }
  89. VM.IsUp.selectedIndex = isUP ? 1 : 0;
  90. }
  91. else
  92. {
  93. VM.IsUp.selectedIndex = info.PartnerId > 0 ? 1 : 0;
  94. }
  95. }
  96. #endregion
  97. }
  98. }