using ET; using FairyGUI; using UI.CommonGame; using UI.Poem; using UnityEngine; namespace GFGGame { public class PoemGalleryPreviewView : BaseWindow { private UI_PoemGalleryPreviewUI _ui; private int _sortType = 0;//由 GallerySortType 定义 private PoemGalleryData _galleryData; public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_PoemGalleryPreviewUI.PACKAGE_NAME; _ui = UI_PoemGalleryPreviewUI.Create(); this.viewCom = _ui.target; isfullScreen = true; // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj"); _ui.m_btnback.onClick.Add(OnBtnBackClick); _ui.m_btnCollect.onClick.Add(OnBtnCollectClick); _ui.m_btnVote.onClick.Add(OnBtnVoteClick); _ui.m_btnAddFriend.onClick.Add(OnBtnAddFriendClick); _ui.m_btnDelete.onClick.Add(OnBtnDeleteClick); } protected override void AddEventListener() { base.AddEventListener(); } protected override void OnShown() { base.OnShown(); _sortType = (int)(this.viewData as object[])[0]; long workId = (long)(this.viewData as object[])[1]; _galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId); UpdateView(); } private async void UpdateView() { _ui.m_c1.selectedIndex = _sortType; _ui.m_txtName.text = _galleryData.AuthorName; string themeTime = TimeUtil.FormattingTime4(_galleryData.CreateTime); GalleryThemeCfg themeCfg = GalleryThemeCfgArray.Instance.GetCfg((int)PoemGalleryDataManager.Instance.ThemeId); string themeName = themeCfg.theme; _ui.m_txtTheme.text = string.Format("{0} 主题:{1}", themeTime, themeName);// PoemGalleryDataManager.Instance.GetThemeTime(); _ui.m_loaPicture.texture = _galleryData.Ntexture; _ui.m_btnCollect.selected = _galleryData.CollectOrNot; _ui.m_btnCollect.title = _galleryData.CollectCount.ToString(); _ui.m_btnVote.selected = _galleryData.VoteOrNot; _ui.m_btnVote.title = _galleryData.VoteCount.ToString(); _ui.m_btnAddFriend.visible = _galleryData.AuthorId != RoleDataManager.roleId && FriendDataManager.Instance.GetFriendDataById(_galleryData.AuthorId) == null; OtherRoleInfoDetailData roleInfo = await RoleInfoSProxy.ReqOtherRoleDetailInfo(_galleryData.AuthorId); if (roleInfo != null) { _ui.m_txtLvl.text = roleInfo.roleInfo.roleLv.ToString(); RoleInfoManager.Instance.UpdateHead(_ui.m_comHead, roleInfo.roleInfo.roleHead, roleInfo.roleInfo.roleHeadBorder); } } protected override void OnHide() { base.OnHide(); _ui.m_btnAddFriend.selected = false; } protected override void RemoveEventListener() { base.RemoveEventListener(); } private void OnBtnBackClick() { ViewManager.GoBackFrom(typeof(PoemGalleryPreviewView).FullName); } private async void OnBtnCollectClick(EventContext context) { if (_galleryData.CollectOrNot) { bool result = await PoemGallerySProxy.ReqCancelCollecteGalleryWorks(_galleryData.WorkId); if (result) { UpdateView(); } } else { bool result = await PoemGallerySProxy.ReqCollecteGalleryWorks(_galleryData.WorkId); if (result) { UpdateView(); } } } private async void OnBtnVoteClick(EventContext context) { if (_galleryData.VoteOrNot) return; if (PoemGalleryDataManager.Instance.IsResulting()) { _ui.m_btnVote.selected = _galleryData.VoteOrNot; PromptController.Instance.ShowFloatTextPrompt("排行榜数据正在结算,无法操作"); return; } if (!PoemGalleryDataManager.Instance.IsCurThemeWork(_galleryData.CreateTime)) { _ui.m_btnVote.selected = _galleryData.VoteOrNot; PromptController.Instance.ShowFloatTextPrompt("往期作品,无法操作"); return; } bool result = await PoemGallerySProxy.ReqVoteGalleryWorks(_galleryData.WorkId); if (result) { UpdateView(); int Count = GameGlobal.myNumericComponent.GetAsInt(NumericType.LikeGalleryWorksCountDaily); GalleryIntegralCfg integralCfg = GalleryIntegralCfgArray.Instance.GetCfg(Count); if (integralCfg != null) { ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(integralCfg.itemId); PromptController.Instance.ShowFloatTextPrompt(string.Format("{0} +{1}", itemCfg.name, integralCfg.Count)); } } } private async void OnBtnAddFriendClick(EventContext context) { if (_ui.m_btnAddFriend.selected == true) return; bool result = await FriendSProxy.ReqApplyForFriend(_galleryData.AuthorId); if (result) { _ui.m_btnAddFriend.selected = true; } } private void OnBtnDeleteClick(EventContext context) { AlertUI.Show("是否确认删除此照片?", "(删除的照片将清除点赞数)") .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) => { bool result = await PoemGallerySProxy.ReqDeleteMyWorks(_galleryData.WorkId); if (result) { this.Hide(); } }); } } }