PartnerSbBagPanelCtrl.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using XGame.Framework.UI;
  7. namespace FL.FGUI
  8. {
  9. /// <summary>
  10. /// UI逻辑处理类
  11. /// </summary>
  12. /// <typeparam name=""></typeparam>
  13. public partial class PartnerSbBagPanelCtrl : UIController<PartnerSbBagPanelVM>
  14. {
  15. protected override void OnDisable()
  16. {
  17. RemoveUIListenres();
  18. VM.SbBagNested.Disable();
  19. VM.MwBagNested.Disable();
  20. }
  21. protected override void OnEnable(object intent)
  22. {
  23. AddUIListenres();
  24. _page = (int)intent;
  25. ShowUI();
  26. }
  27. private void AddUIListenres()
  28. {
  29. VM.SbBagBtn.onClick.Add(OnClickSbBagBtn);
  30. VM.MwBagBtn.onClick.Add(OnClickMwBagBtn);
  31. }
  32. private void RemoveUIListenres()
  33. {
  34. VM.SbBagBtn.onClick.Remove(OnClickSbBagBtn);
  35. VM.MwBagBtn.onClick.Remove(OnClickMwBagBtn);
  36. }
  37. private void OnClickSbBagBtn()
  38. {
  39. _page = 0;
  40. ShowUI();
  41. }
  42. private void OnClickMwBagBtn()
  43. {
  44. _page = 1;
  45. ShowUI();
  46. }
  47. private int _page;
  48. private void ShowUI()
  49. {
  50. VM.Page.selectedIndex = _page;
  51. if (_page == 0)
  52. {
  53. VM.SbBagNested.Enable(null);
  54. VM.MwBagNested.Disable();
  55. }
  56. else
  57. {
  58. VM.MwBagNested.Enable(null);
  59. VM.SbBagNested.Disable();
  60. }
  61. }
  62. }
  63. }