BattleFunctionJumpItemCtrl.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class BattleFunctionJumpItemCtrl : UIController<BattleFunctionJumpItemVM>
  17. {
  18. private int _jumpId = 0;
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. }
  23. protected override void OnDisable()
  24. {
  25. RemoveUIListenres();
  26. _jumpId = 0;
  27. }
  28. #region UI事件
  29. private void AddUIListenres()
  30. {
  31. VM.PanelEvent.Add(OnClickJump);
  32. }
  33. private void RemoveUIListenres()
  34. {
  35. VM.PanelEvent.Remove(OnClickJump);
  36. }
  37. private void OnClickJump(EventContext context)
  38. {
  39. Context.JumpUI(_jumpId);
  40. Context.ClosePanel();
  41. }
  42. #endregion
  43. public void OnRefresh(int index, int jumpId)
  44. {
  45. var table = JumpTableRepo.Get(jumpId);
  46. Assert.IsNotNull(table, $"功能跳转表id错误: 找不到配置信息. Id:{jumpId}");
  47. VM.FunIcon.icon = table.Icon;
  48. VM.FunNameLabel.text = table.Name;
  49. _jumpId = jumpId;
  50. }
  51. }
  52. }