PoemGalleryPreviewView.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 = (long)(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 = TimeUtil.FormattingTime4(_galleryData.CreateTime / 1000);
  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_loaPicture.texture = _galleryData.Ntexture;
  56. _ui.m_btnCollect.selected = _galleryData.CollectOrNot;
  57. _ui.m_btnCollect.title = _galleryData.CollectCount.ToString();
  58. _ui.m_btnVote.selected = _galleryData.VoteOrNot;
  59. _ui.m_btnVote.title = _galleryData.VoteCount.ToString();
  60. _ui.m_btnAddFriend.visible = _galleryData.AuthorId != RoleDataManager.roleId && FriendDataManager.Instance.GetFriendDataById(_galleryData.AuthorId) == null;
  61. RoleInfoDetailData roleInfo = await RoleInfoSProxy.ReqOtherRoleDetailInfo(_galleryData.AuthorId);
  62. if (roleInfo != null)
  63. {
  64. _ui.m_comHead.m_txtLvl.text = roleInfo.RoleLvl.ToString();
  65. }
  66. }
  67. protected override void OnHide()
  68. {
  69. base.OnHide();
  70. _ui.m_btnAddFriend.selected = false;
  71. }
  72. protected override void RemoveEventListener()
  73. {
  74. base.RemoveEventListener();
  75. }
  76. private void OnBtnBackClick()
  77. {
  78. ViewManager.GoBackFrom(typeof(PoemGalleryPreviewView).FullName);
  79. }
  80. private async void OnBtnCollectClick(EventContext context)
  81. {
  82. if (_galleryData.CollectOrNot)
  83. {
  84. bool result = await PoemGallerySProxy.ReqCancelCollecteGalleryWorks(_galleryData.WorkId);
  85. if (result)
  86. {
  87. UpdateView();
  88. }
  89. }
  90. else
  91. {
  92. bool result = await PoemGallerySProxy.ReqCollecteGalleryWorks(_galleryData.WorkId);
  93. if (result)
  94. {
  95. UpdateView();
  96. }
  97. }
  98. }
  99. private async void OnBtnVoteClick(EventContext context)
  100. {
  101. if (_galleryData.VoteOrNot) return;
  102. bool result = await PoemGallerySProxy.ReqVoteGalleryWorks(_galleryData.WorkId);
  103. if (result)
  104. {
  105. UpdateView();
  106. int Count = GameGlobal.myNumericComponent.GetAsInt(NumericType.LikeGalleryWorksCountDaily);
  107. GalleryIntegralCfg integralCfg = GalleryIntegralCfgArray.Instance.GetCfg(Count);
  108. if (integralCfg != null)
  109. {
  110. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(integralCfg.itemId);
  111. PromptController.Instance.ShowFloatTextPrompt(string.Format("{0} +{1}", itemCfg.name, integralCfg.Count));
  112. }
  113. }
  114. }
  115. private async void OnBtnAddFriendClick(EventContext context)
  116. {
  117. if (_ui.m_btnAddFriend.selected == true) return;
  118. bool result = await FriendSProxy.ReqApplyForFriend(_galleryData.AuthorId);
  119. if (result)
  120. {
  121. _ui.m_btnAddFriend.selected = true;
  122. }
  123. }
  124. private void OnBtnDeleteClick(EventContext context)
  125. {
  126. AlertUI.Show("是否确认删除此照片?", "(删除的照片将清除点赞数)")
  127. .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
  128. {
  129. bool result = await PoemGallerySProxy.ReqDeleteMyWorks(_galleryData.WorkId);
  130. if (result)
  131. {
  132. this.Hide();
  133. }
  134. });
  135. }
  136. }
  137. }