PartnerEpiItemCtrl.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.Framework.UI;
  9. namespace FL.FGUI
  10. {
  11. /// <summary>
  12. /// UI逻辑处理类
  13. /// </summary>
  14. /// <typeparam name=""></typeparam>
  15. public partial class PartnerEpiItemCtrl : UIController<PartnerEpiItemVM>
  16. {
  17. protected override void OnEnable(object intent)
  18. {
  19. AddUIListenres();
  20. }
  21. protected override void OnDisable()
  22. {
  23. RemoveUIListenres();
  24. }
  25. #region UI事件
  26. private void AddUIListenres() { }
  27. private void RemoveUIListenres() { }
  28. #endregion
  29. public void ShowUI(int id, int planId = -1, int slotId = -1)
  30. {
  31. bool isEmpty = id <= 0;
  32. if (isEmpty)
  33. {
  34. isEmpty = true;
  35. VM.EpiSetBase.Disable();
  36. }
  37. else
  38. {
  39. isEmpty = false;
  40. VM.EpiSetBase.Enable(null);
  41. }
  42. VM.IsEmpty.selectedIndex = isEmpty ? 1 : 0;
  43. VM.PartnerBase.Ctrl.ShowUI(id, false);
  44. if (isEmpty)
  45. return;
  46. if (planId >= 0 && slotId >= 0)
  47. {
  48. var slot = PartnersData.Instance.GetPlanSlot(planId, slotId);
  49. VM.EpiSetBase.Ctrl.SetData(slot?.MwId ?? 0, id, true);
  50. }
  51. else
  52. {
  53. var info = PartnersData.Instance.GetPartnerAttrByTableId(id);
  54. VM.EpiSetBase.Ctrl.SetData(info?.EpigraphId ?? 0, id, true);
  55. }
  56. }
  57. }
  58. }