RoleInfoView.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. using ET;
  2. using FairyGUI;
  3. using UI.CommonGame;
  4. using UI.RoleInfo;
  5. namespace GFGGame
  6. {
  7. public class RoleInfoView : BaseWindow
  8. {
  9. private UI_RoleInfoUI _ui;
  10. public override void Dispose()
  11. {
  12. if (_ui != null)
  13. {
  14. _ui.Dispose();
  15. }
  16. _ui = null;
  17. base.Dispose();
  18. }
  19. protected override void OnInit()
  20. {
  21. base.OnInit();
  22. packageName = UI_RoleInfoUI.PACKAGE_NAME;
  23. _ui = UI_RoleInfoUI.Create();
  24. this.viewCom = _ui.target;
  25. isfullScreen = true;
  26. _ui.m_txtVersion.text = GameGlobal.version;
  27. _ui.m_txtSlogan.maxLength = GlobalCfgArray.globalCfg.maxSloganWordsCount;
  28. _ui.m_btnHelp.onClick.Add(OnClickBtnHelp);
  29. _ui.m_txtSlogan.onFocusOut.Add(OnFocuseOut);
  30. _ui.m_loaChangeName.onClick.Add(OnClickLoaChangeName);
  31. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  32. _ui.m_btnFieldGuide.onClick.Add(OnBtnFieldGuideClick);
  33. _ui.m_btnSkill.onClick.Add(OnBtnSkillClick);
  34. _ui.m_btnSetting.onClick.Add(OnBtnSettingClick);
  35. _ui.m_comHead.GetChild("loaIcon").asLoader.onClick.Add(OnComHeadClick);
  36. _ui.m_list.itemRenderer = RenderListItem;
  37. _ui.m_list.onClickItem.Add(OnListItemClick);
  38. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");
  39. }
  40. protected override void AddEventListener()
  41. {
  42. base.AddEventListener();
  43. EventAgent.AddEventListener(ConstMessage.CHANGE_ROLE_NAME, UpdateRoleName);
  44. EventAgent.AddEventListener(ConstMessage.CHANGE_ROLE_HEAD, UpdateHead);
  45. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  46. EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateList);
  47. }
  48. protected override void OnShown()
  49. {
  50. base.OnShown();
  51. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  52. _ui.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  53. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  54. if (roleLevelCfg.exp > 0)
  55. {
  56. _ui.m_txtExp.text = string.Format("{0}/{1}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp), roleLevelCfg.exp);
  57. }
  58. else
  59. {
  60. _ui.m_txtExp.text = "已满级";
  61. }
  62. _ui.m_txtSlogan.text = RoleDataManager.slogan;
  63. _ui.m_btnFieldGuide.title = string.Format("套装收集度:{0}%", RoleInfoManager.Instance.GetGuideProgress());
  64. UpdateHead();
  65. UpdateList();
  66. UpdateRedDot();
  67. }
  68. protected override void OnHide()
  69. {
  70. base.OnHide();
  71. }
  72. private void OnBtnBackClick()
  73. {
  74. ViewManager.GoBackFrom(typeof(RoleInfoView).FullName);
  75. }
  76. protected override void RemoveEventListener()
  77. {
  78. base.RemoveEventListener();
  79. EventAgent.RemoveEventListener(ConstMessage.CHANGE_ROLE_NAME, UpdateRoleName);
  80. EventAgent.RemoveEventListener(ConstMessage.CHANGE_ROLE_HEAD, UpdateHead);
  81. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  82. EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateList);
  83. }
  84. private void UpdateRoleName()
  85. {
  86. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  87. }
  88. private void UpdateHead()
  89. {
  90. RoleInfoManager.Instance.UpdateHead(_ui.m_comHead, RoleDataManager.headId, RoleDataManager.headBorderId);
  91. }
  92. private void UpdateList()
  93. {
  94. _ui.m_list.numItems = RoleDataManager.photoDatas.Count;
  95. }
  96. private void RenderListItem(int index, GObject obj)
  97. {
  98. long pictureId = RoleDataManager.photoDatas[index];
  99. PoemPhotoData poemPhotoData = pictureId == 0 ? null : PoemPhotoDataManager.Instance.GetPersonalPhotoDataById(pictureId);
  100. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  101. item.m_comPhoto.m_loaPhoto.texture = poemPhotoData == null ? null : poemPhotoData.Ntexture;
  102. item.target.data = index;
  103. UI_ListPhotoItem.ProxyEnd();
  104. }
  105. private void OnListItemClick(EventContext context)
  106. {
  107. GObject obj = context.data as GObject;
  108. int index = (int)obj.data;
  109. ViewManager.Show<PersonalPhotoView>(index, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  110. this.Hide();
  111. }
  112. private void OnClickBtnHelp()
  113. {
  114. if (GameConfig.showGM >= 1)
  115. {
  116. ViewManager.Show(ViewName.GM_PANEL_VIEW);
  117. }
  118. else
  119. {
  120. ViewManager.Show(ViewName.LOG_VIEW);
  121. }
  122. }
  123. private async void OnFocuseOut()
  124. {
  125. _ui.m_txtSlogan.text = await RoleInfoSProxy.ReqModifySlogan(_ui.m_txtSlogan.text);
  126. }
  127. private void OnClickLoaChangeName()
  128. {
  129. ViewManager.Show<ChangeNameView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  130. }
  131. private void OnBtnFieldGuideClick()
  132. {
  133. this.Hide();
  134. ViewManager.Show<FieldGuideView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  135. }
  136. private void OnBtnSkillClick()
  137. {
  138. ViewManager.Show<PersonalSkillView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  139. }
  140. private void OnBtnSettingClick()
  141. {
  142. ViewManager.Show<SettingView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  143. }
  144. private void OnComHeadClick()
  145. {
  146. ViewManager.Show<ChangeHeadView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  147. }
  148. private void UpdateRedDot()
  149. {
  150. RedDotController.Instance.SetComRedDot(_ui.m_comHead, RedDotDataManager.Instance.GetHeadRed() || RedDotDataManager.Instance.GetHeadBorderRed(), "", -44, 47);
  151. }
  152. }
  153. }