RoleInfoView.cs 5.7 KB

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