123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using ET;
- using FairyGUI;
- using UnityEngine;
- namespace GFGGame
- {
- public class PoemPhotoDataManager : SingletonBase<PoemPhotoDataManager>
- {
- /// <summary>
- /// 个人相册
- /// </summary>
- /// <typeparam name="PoemPhotoData"></typeparam>
- /// <returns></returns>
- public List<PoemPhotoData> PersonalPhotoInfos = new List<PoemPhotoData>();
- /// <summary>
- /// 万水千山相册
- /// </summary>
- /// <typeparam name="PoemPhotoData"></typeparam>
- /// <returns></returns>
- public List<PoemPhotoData> WsqsPhotoInfos = new List<PoemPhotoData>();
- public void Clear()
- {
- PersonalPhotoInfos.Clear();
- WsqsPhotoInfos.Clear();
- }
- public void Add(PoemPhotoData photoData, int sourceType)
- {
- List<PoemPhotoData> 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<long> pictureIds, int sourceType)
- {
- List<PoemPhotoData> 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<PoemPhotoData> 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<PoemPhotoData> 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<PoemPhotoData> SortInfos(List<PoemPhotoData> 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);
- }
- }
- }
|