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; } else if (sourceType == 2) { poemPhotoDatas = MatchingCompetitionDataManager.Instance.MatchingPhotoInfos; } poemPhotoDatas.Add(photoData); poemPhotoDatas.SortInfos(); } 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; } else if (sourceType == 2) { poemPhotoDatas = MatchingCompetitionDataManager.Instance.MatchingPhotoInfos; } 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; } } } poemPhotoDatas.SortInfos(); } 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; } else if(sourceType == 2) { poemPhotoDatas = MatchingCompetitionDataManager.Instance.MatchingPhotoInfos; } for (int i = 0; i < poemPhotoDatas.Count; i++) { if (poemPhotoDatas[i].PictureId == pictureId) { poemPhotoDatas[i].LockingStatus = state; break; } } poemPhotoDatas.SortInfos(); } 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; } else if (sourceType == 2) { poemPhotoDatas = MatchingCompetitionDataManager.Instance.MatchingPhotoInfos; } for (int i = 0; i < poemPhotoDatas.Count; i++) { if (poemPhotoDatas[i].PictureId == pictureId) { poemPhotoDatas[i].ToppingStatus = state; break; } } poemPhotoDatas.SortInfos(); } 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); } } }