PartnerLineupPlanListItemCtrl.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 System.Collections.Generic;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class PartnerLineupPlanListItemCtrl : UIController<PartnerLineupPlanListItemVM>
  17. {
  18. private int _planId; // 方案索引
  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.ChangeLineupPlanBtn.onClick.Add(OnClickChangeLineupPlanBtn);
  31. VM.EditBtn.onClick.Add(OnClickEdit);
  32. }
  33. private void RemoveUIListenres()
  34. {
  35. VM.ChangeLineupPlanBtn.onClick.Remove(OnClickChangeLineupPlanBtn);
  36. VM.EditBtn.onClick.Remove(OnClickEdit);
  37. }
  38. private void OnClickEdit(EventContext context)
  39. {
  40. Context.UI.OpenAsync(UIKeys.PartnerPlanRenamePanel, _planId);
  41. }
  42. private void OnClickChangeLineupPlanBtn(EventContext context)
  43. {
  44. PartnersService.Instance.RequestChangePlan(_planId);
  45. }
  46. #endregion
  47. public void OnRefresh(int index, PartnerPlan plan)
  48. {
  49. VM.ShowLine.selectedIndex = index > 0 ? 0 : 1;
  50. VM.CurPlan.selectedIndex = plan.Id == PartnersData.Instance.UsePlanId ? 1 : 0;
  51. _planId = plan.Id;
  52. VM.NameLabel.text = plan.Name.Length > 0 ? plan.Name : string.Format(StringDefine.partnerInitPlanName, _planId);
  53. var dataList = new List<PartnerPlanParam>();
  54. for (int i = 0; i < PartnersData.GoneUpLimit; i++)
  55. {
  56. var param = new PartnerPlanParam()
  57. {
  58. planId = plan.Id,
  59. slotId = i,
  60. };
  61. dataList.Add(param);
  62. }
  63. VM.PartnerList.BindDatas(dataList);
  64. }
  65. }
  66. }