| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 | 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;            isReturnView = 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("tjbg");        }        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_ListPhotoItemDetail item = UI_ListPhotoItemDetail.Proxy(obj);            item.m_comIcon.m_loaIcon.texture = photoData.Ntexture;            bool curSelect = photoData.PictureId == _showPictureId;            bool otherSelect = !curSelect && RoleDataManager.photoDatas.IndexOf(photoData.PictureId) >= 0;            if (curSelect)            {                item.m_c1.SetSelectedIndex(2);            }            else if (otherSelect)            {                item.m_c1.SetSelectedIndex(1);            }            else            {                item.m_c1.SetSelectedIndex(0);            }            string[] timeStr = TimeUtil.FormattingTime1(photoData.CreationTime, '/').Split(' ');            item.m_txtTime.text = timeStr[0];            item.target.data = photoData.PictureId;            UI_ListPhotoItemDetail.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;                // 将空位移动到后面                for (int i = _showIndex; i < RoleDataManager.photoDatas.Count - 1; i++)                {                    if (RoleDataManager.photoDatas[i + 1] == 0)                    {                        break;                    }                    else                    {                        RoleDataManager.photoDatas[i] = RoleDataManager.photoDatas[i + 1];                        RoleDataManager.photoDatas[i + 1] = 0;                    }                }            }            else            {                if (_showPictureId == 0)//添加:原来未展示图片                {                    if (RoleDataManager.photoDatas.IndexOf(selectPictureId) < 0)//选中的图片未被选中                    {                        // 找到第一个空位                        for(int i = 0; i < RoleDataManager.photoDatas.Count; i++)                        {                            if(RoleDataManager.photoDatas[i] == 0)                            {                                RoleDataManager.photoDatas[i] = selectPictureId;                                break;                            }                        }                    }                }                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)            {                Hide();            }        }    }}
 |