PoemGalleryPreviewView.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using ET;
  2. using FairyGUI;
  3. using UI.Poem;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class PoemGalleryPreviewView : BaseWindow
  8. {
  9. private UI_PoemGalleryPreviewUI _ui;
  10. private int _sortType = 0;//由 GallerySortType 定义
  11. private PoemGalleryData _galleryData;
  12. public override void Dispose()
  13. {
  14. if (_ui != null)
  15. {
  16. _ui.Dispose();
  17. _ui = null;
  18. }
  19. base.Dispose();
  20. }
  21. protected override void OnInit()
  22. {
  23. base.OnInit();
  24. packageName = UI_PoemGalleryPreviewUI.PACKAGE_NAME;
  25. _ui = UI_PoemGalleryPreviewUI.Create();
  26. this.viewCom = _ui.target;
  27. isfullScreen = true;
  28. // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
  29. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  30. _ui.m_btnCollect.onClick.Add(OnBtnCollectClick);
  31. _ui.m_btnVote.onClick.Add(OnBtnVoteClick);
  32. _ui.m_btnAddFriend.onClick.Add(OnBtnAddFriendClick);
  33. _ui.m_btnDelete.onClick.Add(OnBtnDeleteClick);
  34. }
  35. protected override void AddEventListener()
  36. {
  37. base.AddEventListener();
  38. }
  39. protected override void OnShown()
  40. {
  41. base.OnShown();
  42. _sortType = (int)(this.viewData as object[])[0];
  43. long workId = (int)(this.viewData as object[])[1];
  44. _galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
  45. UpdateView();
  46. }
  47. private async void UpdateView()
  48. {
  49. _ui.m_c1.selectedIndex = _sortType;
  50. _ui.m_txtName.text = _galleryData.AuthorName;
  51. string themeTime = PoemGalleryDataManager.Instance.GetThemeTime();
  52. GalleryThemeCfg themeCfg = GalleryThemeCfgArray.Instance.GetCfg((int)PoemGalleryDataManager.Instance.ThemeId);
  53. string themeName = themeCfg.theme;
  54. _ui.m_txtTheme.text = string.Format("{0} {1}", themeTime, themeName);// PoemGalleryDataManager.Instance.GetThemeTime();
  55. _ui.m_btnCollect.selected = _galleryData.CollectOrNot;
  56. _ui.m_btnCollect.title = _galleryData.CollectCount.ToString();
  57. _ui.m_btnVote.selected = _galleryData.VoteOrNot;
  58. _ui.m_btnVote.title = _galleryData.VoteCount.ToString();
  59. _ui.m_btnAddFriend.visible = FriendDataManager.Instance.GetFriendDataById(_galleryData.AuthorId) == null;
  60. RoleInfoDetailData roleInfo = await FriendSProxy.ReqOtherRoleDetailInfo(_galleryData.AuthorId);
  61. if (roleInfo != null)
  62. {
  63. _ui.m_comHead.m_txtLvl.text = roleInfo.RoleLvl.ToString();
  64. }
  65. }
  66. protected override void OnHide()
  67. {
  68. base.OnHide();
  69. _ui.m_btnAddFriend.selected = false;
  70. }
  71. protected override void RemoveEventListener()
  72. {
  73. base.RemoveEventListener();
  74. }
  75. private void OnBtnBackClick()
  76. {
  77. ViewManager.GoBackFrom(typeof(PoemGalleryPreviewView).FullName);
  78. }
  79. private async void OnBtnCollectClick(EventContext context)
  80. {
  81. if (_galleryData.CollectOrNot)
  82. {
  83. bool result = await PoemGallerySProxy.ReqCancelCollecteGalleryWorks(_galleryData.WorkId);
  84. if (result)
  85. {
  86. UpdateView();
  87. }
  88. }
  89. else
  90. {
  91. bool result = await PoemGallerySProxy.ReqCollecteGalleryWorks(_galleryData.WorkId);
  92. if (result)
  93. {
  94. UpdateView();
  95. }
  96. }
  97. }
  98. private async void OnBtnVoteClick(EventContext context)
  99. {
  100. if (_galleryData.VoteOrNot) return;
  101. bool result = await PoemGallerySProxy.ReqVoteGalleryWorks(_galleryData.WorkId);
  102. if (result)
  103. {
  104. UpdateView();
  105. int Count = GameGlobal.myNumericComponent.GetAsInt(NumericType.LikeGalleryWorksCountDaily);
  106. GalleryIntegralCfg integralCfg = GalleryIntegralCfgArray.Instance.GetCfg(Count);
  107. if (integralCfg != null)
  108. {
  109. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(integralCfg.itemId);
  110. PromptController.Instance.ShowFloatTextPrompt(string.Format("{0} +{1}", itemCfg.name, integralCfg.Count));
  111. }
  112. }
  113. }
  114. private async void OnBtnAddFriendClick(EventContext context)
  115. {
  116. if (_ui.m_btnAddFriend.selected == true) return;
  117. bool result = await FriendSProxy.ReqApplyForFriend(_galleryData.AuthorId);
  118. if (result)
  119. {
  120. _ui.m_btnAddFriend.selected = true;
  121. }
  122. }
  123. private async void OnBtnDeleteClick(EventContext context)
  124. {
  125. bool result = await PoemGallerySProxy.ReqDeleteMyWorks(_galleryData.WorkId);
  126. if (result)
  127. {
  128. this.Hide();
  129. }
  130. }
  131. }
  132. }