| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 | using System.Collections.Generic;using ET;using FairyGUI;using UI.Poem;namespace GFGGame{    public class PoemPhotoView : BaseWindow    {        private UI_PoemPhotoUI _ui;        private List<long> _listDelete = new List<long>();        private List<PoemPhotoData> _photoInfos;        private int _sourceType = 0;        public override void Dispose()        {            if (_ui != null)            {                _ui.Dispose();                _ui = null;            }            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            packageName = UI_PoemPhotoUI.PACKAGE_NAME;            _ui = UI_PoemPhotoUI.Create();            this.viewCom = _ui.target;            isfullScreen = true;            _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");            _ui.m_list.SetVirtual();            _ui.m_list.itemRenderer = RenderListItem;            _ui.m_listTravel.SetVirtual();            _ui.m_listTravel.itemRenderer = RenderListTravelItem;            _ui.m_btnback.onClick.Add(OnBtnBackClick);            _ui.m_btnDelete.onClick.Add(OnBtnDeleteClick);            _ui.m_btnConfirmDelete.target.onClick.Add(OnBtnConfirmDeleteClick);            _ui.m_c1.onChanged.Add(OnBtnTabChange);        }        protected override void AddEventListener()        {            base.AddEventListener();            EventAgent.AddEventListener(ConstMessage.POEM_PHOTO_INFOS_CHANGE, OnBtnTabChange);        }        protected override void OnShown()        {            base.OnShown();            _ui.m_c1.selectedIndex = (this.viewData == null) ? (int)PictureSourceType.PersonalAlbum : (int)this.viewData;            OnBtnTabChange();            // UpdateView();            Timers.inst.AddUpdate(CheckGuide);        }        protected override void OnHide()        {            base.OnHide();            _ui.m_c2.selectedIndex = 0;            _listDelete.Clear();            Timers.inst.Remove(CheckGuide);        }        protected override void RemoveEventListener()        {            base.RemoveEventListener();            EventAgent.RemoveEventListener(ConstMessage.POEM_PHOTO_INFOS_CHANGE, OnBtnTabChange);        }        private void OnBtnBackClick()        {            if (_ui.m_c2.selectedIndex == 1)            {                _ui.m_c2.selectedIndex = 0;            }            else            {                ViewManager.GoBackFrom(typeof(PoemPhotoView).FullName);                if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);                _ui.m_c1.selectedIndex = 0;            }            _ui.m_c2.selectedIndex = 0;        }        private void OnBtnDeleteClick()        {            if (_ui.m_c1.selectedIndex == 0 && _ui.m_list.numItems == 0)            {                PromptController.Instance.ShowFloatTextPrompt("暂无照片可删除");                return;            }            if (_ui.m_c1.selectedIndex == 1 && _ui.m_listTravel.numItems == 0)            {                PromptController.Instance.ShowFloatTextPrompt("暂无明信片可删除");                return;            }            _ui.m_c2.selectedIndex = 1;        }        private void OnBtnTabChange()        {            _ui.m_c2.selectedIndex = 0;            _listDelete.Clear();            UpdateView();        }        private void UpdateView()        {            if (_ui.m_c1.selectedIndex == 0)            {                _ui.m_listTravel.numItems = 0;                _photoInfos = PoemPhotoDataManager.Instance.PersonalPhotoInfos;                _sourceType = (int)PictureSourceType.PersonalAlbum;                _ui.m_list.numItems = _photoInfos.Count;            }            else            {                _ui.m_list.numItems = 0;                _photoInfos = PoemPhotoDataManager.Instance.WsqsPhotoInfos;                _sourceType = (int)PictureSourceType.WanShuiQianShan;                _ui.m_listTravel.numItems = _photoInfos.Count;            }            _ui.m_txtCount.text = string.Format("({0}/{1})", _photoInfos.Count, GlobalCfgArray.globalCfg.maxPhotoCount);            _ui.m_btnConfirmDelete.m_txtTitle.text = string.Format("删除({0}/{1})", _listDelete.Count, _photoInfos.Count);        }        private void RenderListItem(int index, GObject obj)        {            UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);            item.m_imgSelect.visible = _ui.m_c2.selectedIndex == 1 && _listDelete.IndexOf(_photoInfos[index].PictureId) >= 0;            GLoader loaIcon = item.m_comIcon.m_loaIcon;            loaIcon.visible = true;            if (_photoInfos[index].Ntexture == null)            {                loaIcon.visible = false;            }            loaIcon.texture = _photoInfos[index].Ntexture;            item.m_txtTime.text = TimeUtil.FormattingTime1(_photoInfos[index].CreationTime);            item.m_txtTime.visible = false;            item.m_btnLock.m_c1.selectedIndex = _photoInfos[index].LockingStatus ? 1 : 0;            item.m_btnUp.m_c1.selectedIndex = _photoInfos[index].ToppingStatus ? 1 : 0;            if (item.m_btnLock.target.data == null)            {                item.m_btnLock.target.onClick.Add(OnBtnLockClick);            }            item.m_btnLock.target.data = index;            if (item.m_btnUp.target.data == null)            {                item.m_btnUp.target.onClick.Add(OnBtnUpClick);            }            item.m_btnUp.target.data = index;            if (item.m_comIcon.target.data == null)            {                item.m_comIcon.target.onClick.Add(OnLoaIconClick);            }            item.m_comIcon.target.data = index;            UI_ListPhotoItem.ProxyEnd();        }        private void RenderListTravelItem(int index, GObject obj)        {            PoemPhotoData poemPhotoData = _photoInfos[index];            TravelLoactionCfg loactionCfg = TravelLoactionCfgArray.Instance.GetCfg(poemPhotoData.TravelLocationId);            UI_ComPhotoPostcard item = UI_ComPhotoPostcard.Proxy(obj);            item.m_imgSelect.visible = _ui.m_c2.selectedIndex == 1 && _listDelete.IndexOf(_photoInfos[index].PictureId) >= 0;            item.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.res);            item.m_comTravel.m_loaRole.url = "";            if (poemPhotoData.TravelSuitId > 0)            {                TravelSuitCfg travelSuitCfg = TravelSuitCfgArray.Instance.GetCfg(poemPhotoData.TravelSuitId);                item.m_comTravel.m_loaRole.url = ResPathUtil.GetTravelRolePath(travelSuitCfg.reourcesArr[poemPhotoData.SuitResIndex]);                item.m_comTravel.m_loaRole.SetXY(loactionCfg.positionsArr[poemPhotoData.PositionIndex][0], loactionCfg.positionsArr[poemPhotoData.PositionIndex][1]);            }            item.m_btnLock.m_c1.selectedIndex = _photoInfos[index].LockingStatus ? 1 : 0;            item.m_btnUp.m_c1.selectedIndex = _photoInfos[index].ToppingStatus ? 1 : 0;            if (item.m_btnLock.target.data == null)            {                item.m_btnLock.target.onClick.Add(OnBtnLockClick);            }            item.m_btnLock.target.data = index;            if (item.m_btnUp.target.data == null)            {                item.m_btnUp.target.onClick.Add(OnBtnUpClick);            }            item.m_btnUp.target.data = index;            if (item.m_comTravel.target.data == null)            {                item.m_comTravel.target.onClick.Add(OnLoaIconClick);            }            item.m_comTravel.target.data = index;            UI_ComPhotoPostcard.ProxyEnd();        }        private void OnLoaIconClick(EventContext context)        {            GObject obj = context.sender as GObject;            int index = (int)obj.data;            PoemPhotoData photoData = _photoInfos[index];            if (_ui.m_c2.selectedIndex == 0)            {                ViewManager.Show<PoemPhotoPreView>(new object[] { index, _photoInfos, _sourceType }, new object[] { typeof(PoemPhotoView).FullName, _sourceType });            }            else if (_ui.m_c2.selectedIndex == 1)            {                if (photoData.LockingStatus)                {                    PromptController.Instance.ShowFloatTextPrompt("锁定的照片无法删除");                    return;                }                if (photoData.ToppingStatus)                {                    PromptController.Instance.ShowFloatTextPrompt("置顶的照片无法删除");                    return;                }                UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj.parent);                item.m_imgSelect.visible = !item.m_imgSelect.visible;                if (item.m_imgSelect.visible)                {                    _listDelete.Add(photoData.PictureId);                }                else                {                    _listDelete.Remove(photoData.PictureId);                }                UI_ListPhotoItem.ProxyEnd();                _ui.m_btnConfirmDelete.m_txtTitle.text = string.Format("删除({0}/{1})", _listDelete.Count, _photoInfos.Count);            }        }        private void OnBtnConfirmDeleteClick()        {            if (_listDelete.Count == 0)            {                PromptController.Instance.ShowFloatTextPrompt("请选择要删除的照片");                return;            }            AlertUI.Show("删除后的照片无法恢复,是否确认删除?")            .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>            {                bool result = await PoemPhotoSProxy.ReqRemovedPhoto(_listDelete, _sourceType);                if (result)                {                    _listDelete.Clear();                    OnBtnTabChange();                }            });        }        private void OnBtnLockClick(EventContext context)        {            if (_ui.m_c2.selectedIndex == 1)            {                PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");                return;            }            GObject item = context.sender as GObject;            int index = (int)item.data;            PoemPhotoData photoData = _photoInfos[index];            if (photoData.LockingStatus == false)            {                AlertUI.Show("是否确认锁定此照片?", "(锁定的照片无法被删除)")               .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>               {                   PoemPhotoSProxy.ReqChangeLockingState(photoData.PictureId, true, _sourceType).Coroutine();               });            }            else            {                AlertUI.Show("是否确认解锁此照片?", "(解锁后的照片可随意删除)")               .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>               {                   PoemPhotoSProxy.ReqChangeLockingState(photoData.PictureId, false, _sourceType).Coroutine();               });            }        }        private void OnBtnUpClick(EventContext context)        {            if (_ui.m_c2.selectedIndex == 1)            {                PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");                return;            }            GObject item = context.sender as GObject;            int index = (int)item.data;            PoemPhotoData photoData = _photoInfos[index];            if (photoData.ToppingStatus == false)            {                AlertUI.Show("是否确认置顶此照片?")               .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>               {                   PoemPhotoSProxy.ReqChangeToppingState(photoData.PictureId, true, _sourceType).Coroutine();               });            }            else            {                AlertUI.Show("是否确认取消置顶此照片?")               .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>               {                   PoemPhotoSProxy.ReqChangeToppingState(photoData.PictureId, false, _sourceType).Coroutine();               });            }        }        private void CheckGuide(object param)        {            if (GuideDataManager.IsGuideFinish(ConstGuideId.POEM) <= 0)            {                UpdateToCheckGuide(null);            }            else            {                Timers.inst.Remove(CheckGuide);            }        }        protected override void UpdateToCheckGuide(object param)        {            if (!ViewManager.CheckIsTopView(this.viewCom)) return;            GuideController.TryGuide(_ui.m_btnback, ConstGuideId.POEM, 2, "");        }    }}
 |