123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- using ET;
- using FairyGUI;
- 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 = (int)(this.viewData as object[])[1];
- _galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
- }
- private void UpdateView()
- {
- _ui.m_c1.selectedIndex = _sortType;
- _ui.m_txtName.text = _galleryData.AuthorName;
- string themeTime = PoemGalleryDataManager.Instance.GetThemeTime();
- 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_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 = FriendDataManager.Instance.GetFriendDataById(_galleryData.AuthorId) == null;
- }
- 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;
- 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 async void OnBtnDeleteClick(EventContext context)
- {
- bool result = await PoemGallerySProxy.ReqDeleteMyWorks(_galleryData.WorkId);
- if (result)
- {
- this.Hide();
- }
- }
- }
- }
|