RoleInfoView.cs 6.1 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. }
  83. private void UpdateRoleName()
  84. {
  85. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  86. }
  87. private void UpdateHead()
  88. {
  89. RoleInfoManager.Instance.UpdateHead(_ui.m_comHead, RoleDataManager.headId, RoleDataManager.headBorderId);
  90. }
  91. private void UpdateList()
  92. {
  93. _ui.m_list.numItems = RoleDataManager.photoDatas.Count;
  94. }
  95. private void RenderListItem(int index, GObject obj)
  96. {
  97. long pictureId = RoleDataManager.photoDatas[index];
  98. PoemPhotoData poemPhotoData = pictureId == 0 ? null : PoemPhotoDataManager.Instance.GetPersonalPhotoDataById(pictureId);
  99. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  100. item.m_comPhoto.m_loaPhoto.texture = poemPhotoData == null ? null : poemPhotoData.Ntexture;
  101. item.target.data = index;
  102. UI_ListPhotoItem.ProxyEnd();
  103. }
  104. private void OnListItemClick(EventContext context)
  105. {
  106. GObject obj = context.data as GObject;
  107. int index = (int)obj.data;
  108. ViewManager.Show<PersonalPhotoView>(index, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  109. this.Hide();
  110. }
  111. private void OnClickBtnHelp()
  112. {
  113. if (GameConfig.showGM >= 1)
  114. {
  115. ViewManager.Show(ViewName.GM_PANEL_VIEW);
  116. }
  117. else
  118. {
  119. ViewManager.Show(ViewName.LOG_VIEW);
  120. }
  121. }
  122. private async void OnFocuseOut()
  123. {
  124. _ui.m_txtSlogan.text = await RoleInfoSProxy.ReqModifySlogan(_ui.m_txtSlogan.text);
  125. }
  126. private void OnClickLoaChangeName()
  127. {
  128. ViewManager.Show<ChangeNameView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  129. }
  130. private void OnBtnFieldGuideClick()
  131. {
  132. this.Hide();
  133. ViewManager.Show<FieldGuideView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  134. }
  135. private void OnBtnSkillClick()
  136. {
  137. ViewManager.Show<PersonalSkillView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  138. }
  139. private void OnBtnSettingClick()
  140. {
  141. ViewManager.Show<SettingView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  142. }
  143. private void OnComHeadClick()
  144. {
  145. ViewManager.Show<ChangeHeadView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  146. }
  147. private void UpdateRedDot()
  148. {
  149. RedDotController.Instance.SetComRedDot(_ui.m_comHead, RedDotDataManager.Instance.GetHeadRed() || RedDotDataManager.Instance.GetHeadBorderRed(), "", -44, 47);
  150. }
  151. }
  152. }