using System; using System.Collections.Generic; using System.IO; using ET; using FairyGUI; using UnityEngine; namespace GFGGame { public class PoemPhotoDataManager : SingletonBase { /// /// 个人相册 /// /// /// public List PersonalPhotoInfos = new List(); /// /// 万水千山相册 /// /// /// public List WsqsPhotoInfos = new List(); public void Clear() { PersonalPhotoInfos.Clear(); WsqsPhotoInfos.Clear(); } public void Add(PoemPhotoData photoData, int sourceType) { List poemPhotoDatas = null; if (sourceType == (int)PictureSourceType.PersonalAlbum) { poemPhotoDatas = PersonalPhotoInfos; } else if (sourceType == (int)PictureSourceType.WanShuiQianShan) { poemPhotoDatas = WsqsPhotoInfos; } poemPhotoDatas.Add(photoData); SortInfos(poemPhotoDatas); } public void Remove(List pictureIds, int sourceType) { List poemPhotoDatas = null; if (sourceType == (int)PictureSourceType.PersonalAlbum) { poemPhotoDatas = PersonalPhotoInfos; } else if (sourceType == (int)PictureSourceType.WanShuiQianShan) { poemPhotoDatas = WsqsPhotoInfos; } for (int i = 0; i < pictureIds.Count; i++) { for (int j = 0; j < poemPhotoDatas.Count; j++) { if (pictureIds[i] == poemPhotoDatas[j].PictureId) { poemPhotoDatas.RemoveAt(j); break; } } } SortInfos(poemPhotoDatas); } public void ChangeLockingState(long pictureId, bool state, int sourceType) { List poemPhotoDatas = null; if (sourceType == (int)PictureSourceType.PersonalAlbum) { poemPhotoDatas = PersonalPhotoInfos; } else if (sourceType == (int)PictureSourceType.WanShuiQianShan) { poemPhotoDatas = WsqsPhotoInfos; } for (int i = 0; i < poemPhotoDatas.Count; i++) { if (poemPhotoDatas[i].PictureId == pictureId) { poemPhotoDatas[i].LockingStatus = state; break; } } SortInfos(poemPhotoDatas); } public void ChangeToppingState(long pictureId, bool state, int sourceType) { List poemPhotoDatas = null; if (sourceType == (int)PictureSourceType.PersonalAlbum) { poemPhotoDatas = PersonalPhotoInfos; } else if (sourceType == (int)PictureSourceType.WanShuiQianShan) { poemPhotoDatas = WsqsPhotoInfos; } for (int i = 0; i < poemPhotoDatas.Count; i++) { if (poemPhotoDatas[i].PictureId == pictureId) { poemPhotoDatas[i].ToppingStatus = state; break; } } SortInfos(poemPhotoDatas); } private List SortInfos(List photoInfos) { photoInfos.Sort((PoemPhotoData a, PoemPhotoData b) => { if (a.ToppingStatus && !b.ToppingStatus) return -1; if (b.ToppingStatus && !a.ToppingStatus) return 1; if (a.CreationTime < b.CreationTime) return 1; if (a.CreationTime > b.CreationTime) return -1; return 0; }); return photoInfos; } public PoemPhotoData GetPersonalPhotoDataById(long pictureId) { for (int i = 0; i < PersonalPhotoInfos.Count; i++) { if (pictureId == PersonalPhotoInfos[i].PictureId) { return PersonalPhotoInfos[i]; } } return null; } public NTexture BytesToTexture2D(byte[] bytes) { Texture2D texture2D = new Texture2D(UnityEngine.Screen.width, UnityEngine.Screen.height); texture2D.LoadImage(bytes); return new NTexture(texture2D); } } }