| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 | using UI.RoleInfo;using FairyGUI;namespace GFGGame{    public class PersonalPhotoView : BaseWindow    {        private UI_PersonalPhotoUI _ui;        private int _showIndex = 0;        private long _showPictureId = 0;        public override void Dispose()        {            if (_ui != null)            {                _ui.Dispose();                _ui = null;            }            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            packageName = UI_PersonalPhotoUI.PACKAGE_NAME;            _ui = UI_PersonalPhotoUI.Create();            this.viewCom = _ui.target;            isfullScreen = true;            _ui.m_btnback.onClick.Add(OnBtnBackClick);            _ui.m_list.SetVirtual();            _ui.m_list.itemRenderer = RenderListItem;            _ui.m_list.onClickItem.Add(OnListItemClick);            _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");        }        protected override void OnShown()        {            base.OnShown();            _showIndex = (int)this.viewData;            _showPictureId = RoleDataManager.photoDatas[_showIndex];            _ui.m_list.numItems = PoemPhotoDataManager.Instance.PersonalPhotoInfos.Count;            _ui.m_grpNothing.visible = _ui.m_list.numItems == 0;        }        protected override void OnHide()        {            base.OnHide();        }        private void OnBtnBackClick()        {            ViewManager.GoBackFrom(typeof(PersonalPhotoView).FullName);        }        private void RenderListItem(int index, GObject obj)        {            PoemPhotoData photoData = PoemPhotoDataManager.Instance.PersonalPhotoInfos[index];            UI_ListPhotoItem1 item = UI_ListPhotoItem1.Proxy(obj);            item.m_comIcon.m_loaIcon.texture = photoData.Ntexture;            bool curSelect = photoData.PictureId == _showPictureId;            bool otherSelect = !curSelect && RoleDataManager.photoDatas.IndexOf(photoData.PictureId) >= 0;            item.m_imgSelect.visible = curSelect;            item.m_imgOtherSelect.visible = otherSelect;            item.m_txtTime.text = TimeUtil.FormattingTime1(photoData.CreationTime);            item.target.data = photoData.PictureId;            UI_ListPhotoItem1.ProxyEnd();        }        private async void OnListItemClick(EventContext context)        {            GObject obj = context.data as GObject;            long selectPictureId = (long)obj.data;            if (selectPictureId == _showPictureId)//删除:点击相同id照片            {                RoleDataManager.photoDatas[_showIndex] = 0;            }            else            {                if (_showPictureId == 0)//添加:原来未展示图片                {                    if (RoleDataManager.photoDatas.IndexOf(selectPictureId) < 0)//选中的图片未被选中                    {                        RoleDataManager.photoDatas[_showIndex] = selectPictureId;                    }                }                else//原来有展示图片                {                    if (RoleDataManager.photoDatas.IndexOf(selectPictureId) < 0)//更换:选中的图片未被选中                    {                        RoleDataManager.photoDatas[_showIndex] = selectPictureId;                    }                    else                    {                        int selectPictureIndex = RoleDataManager.photoDatas.IndexOf(selectPictureId);                        RoleDataManager.photoDatas[_showIndex] = selectPictureId;                        RoleDataManager.photoDatas[selectPictureIndex] = _showPictureId;                    }                }            }            bool result = await RoleInfoSProxy.ReqModifyShowPhoto(RoleDataManager.photoDatas);            if (result)            {                ViewManager.GoBackFrom(typeof(PersonalPhotoView).FullName);            }        }    }}
 |