PlayerImprintItemNestedCtrl.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using System;
  8. using XGame.Database;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class PlayerImprintItemNestedCtrl : UIController<PlayerImprintItemNestedVM>
  17. {
  18. private int _imprintIndex;
  19. private Action<int> _onClickCallback;
  20. protected override void OnEnable(object intent)
  21. {
  22. AddUIListenres();
  23. }
  24. protected override void OnDisable()
  25. {
  26. RemoveUIListenres();
  27. }
  28. #region UI事件
  29. private void AddUIListenres()
  30. {
  31. VM.ImprintBtn.onClick.Add(OnClickImprintBtn);
  32. }
  33. private void RemoveUIListenres()
  34. {
  35. VM.ImprintBtn.onClick.Remove(OnClickImprintBtn);
  36. }
  37. private void OnClickImprintBtn(EventContext context)
  38. {
  39. if (_onClickCallback != null)
  40. {
  41. _onClickCallback(_imprintIndex);
  42. }
  43. }
  44. #endregion
  45. public void ShowUI(int index, int runeId, Action<int> callback)
  46. {
  47. _imprintIndex = index;
  48. _onClickCallback = callback;
  49. ShowSelectUI(false);
  50. int selectIndex = 0;
  51. var runeInfo = rune_levelTableRepo.Get(runeId);
  52. if (runeInfo != null)
  53. {
  54. selectIndex = 1;
  55. VM.ImprintBtn.title = $"LV.{runeInfo.Level}";
  56. }
  57. VM.ImprintBtn.GetController("UnlockCtrl").selectedIndex = selectIndex;
  58. }
  59. public void ShowSelectUI(bool bSelect)
  60. {
  61. VM.ImprintBtn.GetChild("SelectImg").visible = bSelect;
  62. }
  63. }
  64. }