PartnerReplacePartnerListItemCtrl.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 XGame.Database;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. public class ReplacePartnerItemParam
  13. {
  14. public bool IsShowMask;
  15. public PartnerAttributes partnerAttr;
  16. }
  17. /// <summary>
  18. /// UI逻辑处理类
  19. /// </summary>
  20. /// <typeparam name=""></typeparam>
  21. public partial class PartnerReplacePartnerListItemCtrl : UIController<PartnerReplacePartnerListItemVM>
  22. {
  23. public long _partnerId; // 圣兵的uid
  24. protected override void OnEnable(object intent)
  25. {
  26. AddUIListenres();
  27. }
  28. protected override void OnDisable()
  29. {
  30. RemoveUIListenres();
  31. }
  32. #region UI事件
  33. private void AddUIListenres()
  34. {
  35. VM.ClickBtn.onClick.Add(OnClickClickBtn);
  36. }
  37. private void RemoveUIListenres()
  38. {
  39. VM.ClickBtn.onClick.Remove(OnClickClickBtn);
  40. }
  41. private void OnClickClickBtn(EventContext context)
  42. {
  43. if (!VM.SelectImg.visible)
  44. {
  45. //ShowSelectState(true);
  46. EventSingle.Instance.Notify(EventDefine.SelectReplacePartner, this);
  47. }
  48. }
  49. #endregion
  50. public void OnRefresh(int index, ReplacePartnerItemParam param)
  51. {
  52. _partnerId = param.partnerAttr.UID;
  53. ShowSelectState(false);
  54. VM.StateCtrl.selectedIndex = param.IsShowMask ? 1 : 0;
  55. var parterInfo = PartnerTableRepo.Get(param.partnerAttr.TableId);
  56. VM.NameLabel.text = parterInfo?.Name;
  57. VM.PartnerItem.Ctrl.ShowUI(param.partnerAttr.TableId);
  58. }
  59. public void ShowSelectState(bool bSelect)
  60. {
  61. if (VM.SelectImg != null)
  62. {
  63. VM.SelectImg.visible = bSelect;
  64. }
  65. }
  66. }
  67. }