PlayerPlansNameNestedCtrl.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class PlayerPlansNameNestedCtrl : UIController<PlayerPlansNameNestedVM>
  17. {
  18. private Action<int> _selectCallback;
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. }
  23. protected override void OnDisable()
  24. {
  25. RemoveUIListenres();
  26. if (_selectCallback != null) _selectCallback = null;
  27. }
  28. #region UI事件
  29. private void AddUIListenres()
  30. {
  31. VM.HideBtn.onClick.Add(OnClickHideBtn);
  32. VM.PlanNameList.ItemClickEvent += OnClickPlanNameListItem;
  33. }
  34. private void RemoveUIListenres()
  35. {
  36. VM.HideBtn.onClick.Remove(OnClickHideBtn);
  37. VM.PlanNameList.ItemClickEvent -= OnClickPlanNameListItem;
  38. }
  39. private void OnClickHideBtn(EventContext context)
  40. {
  41. _selectCallback(0);
  42. }
  43. private void OnClickPlanNameListItem(int index)
  44. {
  45. _selectCallback(index+1);
  46. }
  47. #endregion
  48. public void ShowUI(Action<int> selectCallback)
  49. {
  50. _selectCallback = selectCallback;
  51. VM.PlanNameList.BindDatas(PlayerData.Instance.RunePlanNamesArray);
  52. }
  53. }
  54. }