PartnerMwBagListItemCtrl.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 PartnerMwBagListItemCtrl : UIController<PartnerMwBagListItemVM>
  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.PartnerMwStrengthPanel, _id);
  39. }
  40. #endregion
  41. private int _id;
  42. public void OnRefresh(int index, int mwID)
  43. {
  44. _id = mwID;
  45. var table = EpigraphTableRepo.Get(mwID);
  46. XGame.Framework.Assert.IsNotNull(table, $"铭文表不存在,id:{_id}");
  47. //VM.NameLabel.text = table.Name;
  48. VM.EpiLabel.Ctrl.SetEpiIcon(_id);
  49. if (EpigraphData.Instance.TryGetEpigraphAttrByTableId(_id, out var data))
  50. {
  51. VM.Have.selectedIndex = 0;
  52. if (data.PartnerId > 0)
  53. {
  54. VM.IsSet.selectedIndex = 0;
  55. VM.PzLoader.url = AddressableDefine.EpigraphTypePz(table.Quality);
  56. var sbTable = PartnerTableRepo.Get(data.PartnerId);
  57. VM.SbIconLoader.url = sbTable.Icon2;
  58. }
  59. else
  60. {
  61. VM.IsSet.selectedIndex = 1;
  62. }
  63. }
  64. else
  65. {
  66. VM.Have.selectedIndex = 1;
  67. }
  68. }
  69. }
  70. }