RoleInfoView.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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.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. }
  46. protected override void OnShown()
  47. {
  48. base.OnShown();
  49. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  50. _ui.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  51. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  52. if (roleLevelCfg.exp > 0)
  53. {
  54. _ui.m_txtExp.text = string.Format("{0}/{1}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp), roleLevelCfg.exp);
  55. }
  56. else
  57. {
  58. _ui.m_txtExp.text = "已满级";
  59. }
  60. _ui.m_txtSlogan.text = RoleDataManager.slogan;
  61. _ui.m_btnFieldGuide.title = string.Format("套装收集度:{0}%", RoleInfoManager.Instance.GetGuideProgress());
  62. _ui.m_list.numItems = RoleDataManager.photoDatas.Count;
  63. UpdateHead();
  64. }
  65. protected override void OnHide()
  66. {
  67. base.OnHide();
  68. }
  69. private void OnBtnBackClick()
  70. {
  71. ViewManager.GoBackFrom(typeof(RoleInfoView).FullName);
  72. }
  73. protected override void RemoveEventListener()
  74. {
  75. base.RemoveEventListener();
  76. EventAgent.RemoveEventListener(ConstMessage.CHANGE_ROLE_NAME, UpdateRoleName);
  77. EventAgent.AddEventListener(ConstMessage.CHANGE_ROLE_HEAD, UpdateHead);
  78. }
  79. private void UpdateRoleName()
  80. {
  81. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  82. }
  83. private void UpdateHead()
  84. {
  85. ItemCfg headCfg = ItemCfgArray.Instance.GetCfg(RoleDataManager.headId);
  86. ItemCfg headBorderCfg = ItemCfgArray.Instance.GetCfg(RoleDataManager.headBorderId);
  87. UI_ComHead comHead = UI_ComHead.Proxy(_ui.m_comHead);
  88. comHead.m_loaIcon.url = ResPathUtil.GetHeadPath(headCfg.res);
  89. comHead.m_loaBorder.url = ResPathUtil.GetHeadBorderPath(headBorderCfg.res);
  90. UI_ComHead.ProxyEnd();
  91. }
  92. private void RenderListItem(int index, GObject obj)
  93. {
  94. long pictureId = RoleDataManager.photoDatas[index];
  95. PoemPhotoData poemPhotoData = pictureId == 0 ? null : PoemPhotoDataManager.Instance.GetPersonalPhotoDataById(pictureId);
  96. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  97. item.m_comPhoto.m_loaPhoto.texture = poemPhotoData == null ? null : poemPhotoData.Ntexture;
  98. item.target.data = index;
  99. UI_ListPhotoItem.ProxyEnd();
  100. }
  101. private void OnListItemClick(EventContext context)
  102. {
  103. GObject obj = context.data as GObject;
  104. int index = (int)obj.data;
  105. ViewManager.Show<PersonalPhotoView>(null, new object[] { typeof(RoleInfoView).FullName, index });
  106. this.Hide();
  107. }
  108. private void OnClickBtnHelp()
  109. {
  110. if (GameConfig.showGM >= 1)
  111. {
  112. ViewManager.Show(ViewName.GM_PANEL_VIEW);
  113. }
  114. else
  115. {
  116. ViewManager.Show(ViewName.LOG_VIEW);
  117. }
  118. }
  119. private async void OnFocuseOut()
  120. {
  121. _ui.m_txtSlogan.text = await RoleInfoSProxy.ReqModifySlogan(_ui.m_txtSlogan.text);
  122. }
  123. private void OnClickLoaChangeName()
  124. {
  125. ViewManager.Show<ChangeNameView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  126. }
  127. private void OnBtnFieldGuideClick()
  128. {
  129. this.Hide();
  130. ViewManager.Show<FieldGuideView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  131. }
  132. private void OnBtnSkillClick()
  133. {
  134. ViewManager.Show<PersonalSkillView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  135. }
  136. private void OnBtnSettingClick()
  137. {
  138. ViewManager.Show<SettingView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  139. }
  140. private void OnComHeadClick()
  141. {
  142. ViewManager.Show<ChangeHeadView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  143. }
  144. }
  145. }