RoleInfoView.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using ET;
  2. using UI.Main;
  3. using static GFGGame.LauncherConfig;
  4. namespace GFGGame
  5. {
  6. public class RoleInfoView : BaseWindow
  7. {
  8. private UI_RoleInfoUI _ui;
  9. public override void Dispose()
  10. {
  11. if (_ui != null)
  12. {
  13. _ui.Dispose();
  14. }
  15. _ui = null;
  16. base.Dispose();
  17. }
  18. protected override void OnInit()
  19. {
  20. base.OnInit();
  21. _ui = UI_RoleInfoUI.Create();
  22. this.viewCom = _ui.target;
  23. this.viewCom.Center();
  24. this.modal = true;
  25. _ui.m_txtVersion.text = GameGlobal.version;
  26. _ui.m_txtSlogan.maxLength = GlobalCfgArray.globalCfg.maxSloganWordsCount;
  27. _ui.m_btnExit.onClick.Add(OnClickBtnExit);
  28. _ui.m_btnLogout.onClick.Add(OnClickBtnLogout);
  29. _ui.m_btnSound.onClick.Add(OnClickBtnSound);
  30. _ui.m_btnMusic.onClick.Add(OnClickBtnMusic);
  31. _ui.m_btnHelp.onClick.Add(OnClickBtnHelp);
  32. _ui.m_txtSlogan.onFocusOut.Add(OnFocuseOut);
  33. _ui.m_loaChangeName.onClick.Add(OnClickLoaChangeName);
  34. }
  35. protected override void AddEventListener()
  36. {
  37. base.AddEventListener();
  38. EventAgent.AddEventListener(ConstMessage.CHANGE_ROLE_NAME, UpdateRoleName);
  39. }
  40. protected override void OnShown()
  41. {
  42. base.OnShown();
  43. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  44. _ui.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  45. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  46. if (roleLevelCfg.exp > 0)
  47. {
  48. _ui.m_proBarExp.value = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  49. _ui.m_proBarExp.max = roleLevelCfg.exp;
  50. }
  51. else
  52. {
  53. _ui.m_proBarExp.text = "已满级";
  54. }
  55. _ui.m_btnSound.selected = SoundManager.Instance.isOn;
  56. _ui.m_btnMusic.selected = MusicManager.Instance.isOn;
  57. _ui.m_txtSlogan.text = RoleDataManager.slogan;
  58. }
  59. protected override void OnHide()
  60. {
  61. base.OnHide();
  62. }
  63. protected override void RemoveEventListener()
  64. {
  65. base.RemoveEventListener();
  66. EventAgent.RemoveEventListener(ConstMessage.CHANGE_ROLE_NAME, UpdateRoleName);
  67. }
  68. private void UpdateRoleName()
  69. {
  70. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  71. }
  72. private void OnClickBtnExit()
  73. {
  74. AlertSystem.Show("确认返回登录页吗?")
  75. .SetLeftButton(true)
  76. .SetRightButton(true, "确认", (object data) =>
  77. {
  78. GameController.QuitToLoginView(false);
  79. });
  80. }
  81. private void OnClickBtnLogout()
  82. {
  83. AlertSystem.Show("确认注销当前账号吗?")
  84. .SetLeftButton(true)
  85. .SetRightButton(true, "确认", (object data) =>
  86. {
  87. GameController.QuitToLoginView(true);
  88. });
  89. }
  90. private void OnClickBtnSound()
  91. {
  92. SoundManager.Instance.isOn = _ui.m_btnSound.selected;
  93. }
  94. private void OnClickBtnMusic()
  95. {
  96. MusicManager.Instance.isOn = _ui.m_btnMusic.selected;
  97. }
  98. private void OnClickBtnHelp()
  99. {
  100. if (GameConfig.showGM >= 1)
  101. {
  102. ViewManager.Show(ViewName.GM_PANEL_VIEW);
  103. }
  104. else
  105. {
  106. ViewManager.Show(ViewName.LOG_VIEW);
  107. }
  108. }
  109. private async void OnFocuseOut()
  110. {
  111. _ui.m_txtSlogan.text = await RoleInfoSProxy.ReqModifySlogan(_ui.m_txtSlogan.text);
  112. }
  113. private void OnClickLoaChangeName()
  114. {
  115. ViewManager.Show<ChangeNameView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  116. }
  117. }
  118. }