BagJumpListItemCtrl.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using XGame.Database;
  8. using XGame.Framework.UI;
  9. namespace FL.FGUI
  10. {
  11. /// <summary>
  12. /// UI逻辑处理类
  13. /// </summary>
  14. /// <typeparam name=""></typeparam>
  15. public partial class BagJumpListItemCtrl : UIController<BagJumpListItemVM>
  16. {
  17. private JumpTable _jumpInfo;
  18. protected override void OnEnable(object intent)
  19. {
  20. AddUIListenres();
  21. }
  22. protected override void OnDisable()
  23. {
  24. RemoveUIListenres();
  25. }
  26. #region UI事件
  27. private void AddUIListenres()
  28. {
  29. VM.GoBtn.onClick.Add(OnClickGoBtn);
  30. }
  31. private void RemoveUIListenres()
  32. {
  33. VM.GoBtn.onClick.Remove(OnClickGoBtn);
  34. }
  35. private void OnClickGoBtn(EventContext context)
  36. {
  37. if (!string.IsNullOrEmpty(_jumpInfo?.UI))
  38. {
  39. Context.UI.OpenAsync(UIKeys.NameToKey(_jumpInfo.UI), _jumpInfo.Param);
  40. Context.ClosePanel();
  41. //Context.UI.Close(UIKeys.BagBackpackPanel);
  42. }
  43. }
  44. #endregion
  45. public void OnRefresh(int index, int jumpId)
  46. {
  47. _jumpInfo = JumpTableRepo.Get(jumpId);
  48. if (_jumpInfo != null)
  49. {
  50. VM.NameLabel.text = _jumpInfo.Name;
  51. VM.DescLabel.text = _jumpInfo.Desc;
  52. }
  53. }
  54. }
  55. }