| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 | using System.Collections.Generic;using ET;using FairyGUI;using UI.Poem;using UnityEngine;namespace GFGGame{    public class PoemPhotoPreView : BaseWindow    {        private UI_PoemPhotoPreviewUI _ui;        private GList _list;        private List<PoemPhotoData> _photoInfos;        private int _curIndex = 0;        private int _sourceType = 0;        private PoemPhotoData _curPhotoData;        public override void Dispose()        {            if (_ui != null)            {                _ui.Dispose();                _ui = null;            }            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            packageName = UI_PoemPhotoPreviewUI.PACKAGE_NAME;            _ui = UI_PoemPhotoPreviewUI.Create();            this.viewCom = _ui.target;            isfullScreen = true;            _ui.m_mask.onClick.Add(OnBtnBackClick);            _ui.m_list.SetVirtual();            _ui.m_list.itemRenderer = RenderListItem;            _ui.m_list.scrollPane.onScrollEnd.Add(OnListScrollEnd);            _ui.m_list.scrollPane.decelerationRate = 0.8f;            _ui.m_listTravel.SetVirtual();            _ui.m_listTravel.itemRenderer = RenderListTravelItem;            _ui.m_listTravel.scrollPane.onScrollEnd.Add(OnListScrollEnd);            _ui.m_listTravel.scrollPane.decelerationRate = 0.8f;            _ui.m_btnLeft.onClick.Add(OnBtnLeftClick);            _ui.m_btnRight.onClick.Add(OnBtnRightClick);            _ui.m_btnLock.target.onClick.Add(OnBtnLockClick);            _ui.m_btnUp.target.onClick.Add(OnBtnUpClick);            _ui.m_btnShare.onClick.Add(OnBtnShareClick);        }        protected override void AddEventListener()        {            base.AddEventListener();        }        protected override void OnShown()        {            base.OnShown();            _curIndex = (int)(this.viewData as object[])[0];            List<PoemPhotoData> photoInfos = (this.viewData as object[])[1] as List<PoemPhotoData>;            _photoInfos = new List<PoemPhotoData>(photoInfos.ToArray());            _sourceType = (int)(this.viewData as object[])[2];            _ui.m_c1.selectedIndex = _sourceType;            if (_sourceType == (int)PictureSourceType.PersonalAlbum)            {                _list = _ui.m_list;                _list.numItems = _photoInfos.Count;                // _list.height = _list.GetChildAt(0).height;            }            else if (_sourceType == (int)PictureSourceType.WanShuiQianShan)            {                _list = _ui.m_listTravel;                _list.numItems = _photoInfos.Count;            }            UpdateView();        }        protected override void OnHide()        {            base.OnHide();        }        protected override void RemoveEventListener()        {            base.RemoveEventListener();        }        private void OnBtnBackClick()        {            ViewManager.GoBackFrom(typeof(PoemPhotoPreView).FullName);        }        private void UpdateView(bool ani = false)        {            _ui.m_btnLeft.grayed = _curIndex <= 0;            _ui.m_btnRight.grayed = _curIndex >= _list.numItems - 1;            _ui.m_txtTime.text = TimeUtil.FormattingTime1(_photoInfos[_curIndex].CreationTime);            _ui.m_btnLock.m_c1.selectedIndex = _photoInfos[_curIndex].LockingStatus ? 1 : 0;            _ui.m_btnUp.m_c1.selectedIndex = _photoInfos[_curIndex].ToppingStatus ? 1 : 0;            if (_list.numItems > 0) _list.ScrollToView(_curIndex, ani);            if (_ui.m_btnLock.target.data == null)            {                _ui.m_btnLock.target.onClick.Add(OnBtnLockClick);            }            _ui.m_btnLock.target.data = _curIndex;            if (_ui.m_btnUp.target.data == null)            {                _ui.m_btnUp.target.onClick.Add(OnBtnUpClick);            }            _curPhotoData = _photoInfos[_curIndex];        }        private void RenderListItem(int index, GObject obj)        {            UI_ListPhotoPreviewItem item = UI_ListPhotoPreviewItem.Proxy(obj);            item.m_comPhoto.m_loaPhoto.texture = _photoInfos[index].Ntexture;            // item.target.SetSize(item.target.width, item.target.initHeight * _ui.target.height / _ui.target.initHeight);            UI_ListPhotoPreviewItem.ProxyEnd();        }        private void RenderListTravelItem(int index, GObject obj)        {            UI_ComPostcard item = UI_ComPostcard.Proxy(obj);            PoemPhotoData photoData = _photoInfos[index];            TravelLoactionCfg loactionCfg = TravelLoactionCfgArray.Instance.GetCfg(photoData.TravelLocationId);            item.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.res);            item.m_txtLocationName.text = loactionCfg.name;            item.m_txtTime.text = TimeUtil.FormattingTimeTo_yyyMMdd1(photoData.CreationTime);            item.m_comTravel.m_loaRole.url = "";            if (photoData.TravelSuitId > 0)            {                TravelSuitCfg travelSuitCfg = TravelSuitCfgArray.Instance.GetCfg(photoData.TravelSuitId);                item.m_comTravel.m_loaRole.url = ResPathUtil.GetTravelRolePath(travelSuitCfg.reourcesArr[photoData.SuitResIndex]);                item.m_comTravel.m_loaRole.SetXY(loactionCfg.positionsArr[photoData.PositionIndex][0], loactionCfg.positionsArr[photoData.PositionIndex][1]);            }            UI_ComPostcard.ProxyEnd();        }        private void OnBtnLeftClick()        {            _curIndex--;            _curIndex = Mathf.Max(0, _curIndex);            UpdateView(true);        }        private void OnBtnRightClick()        {            _curIndex++;            _curIndex = Mathf.Min(_list.numItems - 1, _curIndex);            UpdateView(true);        }        private void OnListScrollEnd()        {            _curIndex = _list.ChildIndexToItemIndex(0);            UpdateView();        }        private void OnBtnLockClick()        {            if (_curPhotoData.LockingStatus == false)            {                AlertUI.Show("是否确认锁定此照片?", "(锁住的照片无法被删除)")               .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>               {                   bool result = await PoemPhotoSProxy.ReqChangeLockingState(_curPhotoData.PictureId, true, _sourceType);                   if (result)                   {                       _photoInfos[_curIndex].LockingStatus = true;                       UpdateView();                   }               });            }            else            {                AlertUI.Show("是否确认解锁此照片?", "(解锁后的照片可随意删除)")               .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>               {                   bool result = await PoemPhotoSProxy.ReqChangeLockingState(_curPhotoData.PictureId, false, _sourceType);                   if (result)                   {                       _photoInfos[_curIndex].LockingStatus = false;                       UpdateView();                   }               });            }        }        private void OnBtnUpClick()        {            if (_curPhotoData.ToppingStatus == false)            {                AlertUI.Show("是否确认置顶此照片?")               .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>               {                   bool result = await PoemPhotoSProxy.ReqChangeToppingState(_curPhotoData.PictureId, true, _sourceType);                   if (result)                   {                       _photoInfos[_curIndex].ToppingStatus = true;                       UpdateView();                   }               });            }            else            {                AlertUI.Show("是否确认取消置顶此照片?")               .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>               {                   bool result = await PoemPhotoSProxy.ReqChangeToppingState(_curPhotoData.PictureId, false, _sourceType);                   if (result)                   {                       _photoInfos[_curIndex].ToppingStatus = false;                       UpdateView();                   }               });            }        }        private void OnBtnShareClick()        {            if (_sourceType == (int)PictureSourceType.WanShuiQianShan)            {                PromptController.Instance.ShowFloatTextPrompt("暂时没有可以分享的对象");                return;            }            ViewManager.Show<PoemPhotoShareView>(_curPhotoData);        }    }}
 |