PoemGalleryPreviewView.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using ET;
  2. using FairyGUI;
  3. using UI.CommonGame;
  4. using UI.Poem;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. public class PoemGalleryPreviewView : BaseWindow
  9. {
  10. private UI_PoemGalleryPreviewUI _ui;
  11. private int _sortType = 0;//由 GallerySortType 定义
  12. private PoemGalleryData _galleryData;
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. _ui = null;
  19. }
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_PoemGalleryPreviewUI.PACKAGE_NAME;
  26. _ui = UI_PoemGalleryPreviewUI.Create();
  27. this.viewCom = _ui.target;
  28. isfullScreen = true;
  29. // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
  30. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  31. _ui.m_btnCollect.onClick.Add(OnBtnCollectClick);
  32. _ui.m_btnVote.onClick.Add(OnBtnVoteClick);
  33. _ui.m_btnAddFriend.onClick.Add(OnBtnAddFriendClick);
  34. _ui.m_btnDelete.onClick.Add(OnBtnDeleteClick);
  35. }
  36. protected override void AddEventListener()
  37. {
  38. base.AddEventListener();
  39. }
  40. protected override void OnShown()
  41. {
  42. base.OnShown();
  43. _sortType = (int)(this.viewData as object[])[0];
  44. long workId = (long)(this.viewData as object[])[1];
  45. _galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
  46. UpdateView();
  47. }
  48. private async void UpdateView()
  49. {
  50. _ui.m_c1.selectedIndex = _sortType;
  51. _ui.m_txtName.text = _galleryData.AuthorName;
  52. string themeTime = TimeUtil.FormattingTime4(_galleryData.CreateTime);
  53. GalleryThemeCfg themeCfg = GalleryThemeCfgArray.Instance.GetCfg((int)PoemGalleryDataManager.Instance.ThemeId);
  54. string themeName = themeCfg.theme;
  55. _ui.m_txtTheme.text = string.Format("{0} 主题:{1}", themeTime, themeName);// PoemGalleryDataManager.Instance.GetThemeTime();
  56. _ui.m_loaPicture.texture = _galleryData.Ntexture;
  57. _ui.m_btnCollect.selected = _galleryData.CollectOrNot;
  58. _ui.m_btnCollect.title = _galleryData.CollectCount.ToString();
  59. _ui.m_btnVote.selected = _galleryData.VoteOrNot;
  60. _ui.m_btnVote.title = _galleryData.VoteCount.ToString();
  61. _ui.m_btnAddFriend.visible = _galleryData.AuthorId != RoleDataManager.roleId && FriendDataManager.Instance.GetFriendDataById(_galleryData.AuthorId) == null;
  62. OtherRoleInfoDetailData roleInfo = await RoleInfoSProxy.ReqOtherRoleDetailInfo(_galleryData.AuthorId);
  63. if (roleInfo != null)
  64. {
  65. _ui.m_txtLvl.text = roleInfo.roleInfo.roleLv.ToString();
  66. RoleInfoManager.Instance.UpdateHead(_ui.m_comHead, roleInfo.roleInfo.roleHead, roleInfo.roleInfo.roleHeadBorder);
  67. }
  68. }
  69. protected override void OnHide()
  70. {
  71. base.OnHide();
  72. _ui.m_btnAddFriend.selected = false;
  73. }
  74. protected override void RemoveEventListener()
  75. {
  76. base.RemoveEventListener();
  77. }
  78. private void OnBtnBackClick()
  79. {
  80. ViewManager.GoBackFrom(typeof(PoemGalleryPreviewView).FullName);
  81. }
  82. private async void OnBtnCollectClick(EventContext context)
  83. {
  84. if (_galleryData.CollectOrNot)
  85. {
  86. bool result = await PoemGallerySProxy.ReqCancelCollecteGalleryWorks(_galleryData.WorkId);
  87. if (result)
  88. {
  89. UpdateView();
  90. }
  91. }
  92. else
  93. {
  94. bool result = await PoemGallerySProxy.ReqCollecteGalleryWorks(_galleryData.WorkId);
  95. if (result)
  96. {
  97. UpdateView();
  98. }
  99. }
  100. }
  101. private async void OnBtnVoteClick(EventContext context)
  102. {
  103. if (_galleryData.VoteOrNot) return;
  104. if (PoemGalleryDataManager.Instance.IsResulting())
  105. {
  106. _ui.m_btnVote.selected = _galleryData.VoteOrNot;
  107. PromptController.Instance.ShowFloatTextPrompt("排行榜数据正在结算,无法操作");
  108. return;
  109. }
  110. if (!PoemGalleryDataManager.Instance.IsCurThemeWork(_galleryData.CreateTime))
  111. {
  112. _ui.m_btnVote.selected = _galleryData.VoteOrNot;
  113. PromptController.Instance.ShowFloatTextPrompt("往期作品,无法操作");
  114. return;
  115. }
  116. bool result = await PoemGallerySProxy.ReqVoteGalleryWorks(_galleryData.WorkId);
  117. if (result)
  118. {
  119. UpdateView();
  120. int Count = GameGlobal.myNumericComponent.GetAsInt(NumericType.LikeGalleryWorksCountDaily);
  121. GalleryIntegralCfg integralCfg = GalleryIntegralCfgArray.Instance.GetCfg(Count);
  122. if (integralCfg != null)
  123. {
  124. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(integralCfg.itemId);
  125. PromptController.Instance.ShowFloatTextPrompt(string.Format("{0} +{1}", itemCfg.name, integralCfg.Count));
  126. }
  127. }
  128. }
  129. private async void OnBtnAddFriendClick(EventContext context)
  130. {
  131. if (_ui.m_btnAddFriend.selected == true) return;
  132. bool result = await FriendSProxy.ReqApplyForFriend(_galleryData.AuthorId);
  133. if (result)
  134. {
  135. _ui.m_btnAddFriend.selected = true;
  136. }
  137. }
  138. private void OnBtnDeleteClick(EventContext context)
  139. {
  140. AlertUI.Show("是否确认删除此照片?", "(删除的照片将清除点赞数)")
  141. .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
  142. {
  143. bool result = await PoemGallerySProxy.ReqDeleteMyWorks(_galleryData.WorkId);
  144. if (result)
  145. {
  146. this.Hide();
  147. }
  148. });
  149. }
  150. }
  151. }