PartnerSbBagListItemCtrl.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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;
  9. using XGame.Database;
  10. using XGame.Framework.UI;
  11. namespace FL.FGUI
  12. {
  13. /// <summary>
  14. /// UI逻辑处理类
  15. /// </summary>
  16. /// <typeparam name=""></typeparam>
  17. public partial class PartnerSbBagListItemCtrl : UIController<PartnerSbBagListItemVM>
  18. {
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. }
  23. protected override void OnDisable()
  24. {
  25. RemoveUIListenres();
  26. }
  27. #region UI事件
  28. private void AddUIListenres()
  29. {
  30. VM.PanelEvent.Add(OnClickBagItem);
  31. }
  32. private void RemoveUIListenres()
  33. {
  34. VM.PanelEvent.Remove(OnClickBagItem);
  35. }
  36. private void OnClickBagItem()
  37. {
  38. Context.UI.OpenAsync(UIKeys.PartnerSbStrengthPanel, _id);
  39. }
  40. #endregion
  41. private int _id;
  42. public void OnRefresh(int index, int sbId)
  43. {
  44. _id = sbId;
  45. var table = PartnerTableRepo.Get(sbId);
  46. if (table == null)
  47. {
  48. Log.Error($"圣兵表不存在,id:{_id}");
  49. return;
  50. }
  51. VM.NameLabel.text = table.Name;
  52. VM.SbItem.Ctrl.ShowUI(_id);
  53. var pos = PartnersData.Instance.GetPartnerUpPosById(_id);
  54. VM.IsUP.selectedIndex = pos < 0 ? 0 : 1;
  55. }
  56. }
  57. }