PoemPhotoDataManager.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using ET;
  5. using FairyGUI;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class PoemPhotoDataManager : SingletonBase<PoemPhotoDataManager>
  10. {
  11. /// <summary>
  12. /// 个人相册
  13. /// </summary>
  14. /// <typeparam name="PoemPhotoData"></typeparam>
  15. /// <returns></returns>
  16. public List<PoemPhotoData> PersonalPhotoInfos = new List<PoemPhotoData>();
  17. /// <summary>
  18. /// 万水千山相册
  19. /// </summary>
  20. /// <typeparam name="PoemPhotoData"></typeparam>
  21. /// <returns></returns>
  22. public List<PoemPhotoData> WsqsPhotoInfos = new List<PoemPhotoData>();
  23. public void Clear()
  24. {
  25. PersonalPhotoInfos.Clear();
  26. WsqsPhotoInfos.Clear();
  27. }
  28. public void Add(PoemPhotoData photoData, int sourceType)
  29. {
  30. List<PoemPhotoData> poemPhotoDatas = null;
  31. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  32. {
  33. poemPhotoDatas = PersonalPhotoInfos;
  34. }
  35. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  36. {
  37. poemPhotoDatas = WsqsPhotoInfos;
  38. }
  39. poemPhotoDatas.Add(photoData);
  40. poemPhotoDatas.SortInfos();
  41. }
  42. public void Remove(List<long> pictureIds, int sourceType)
  43. {
  44. List<PoemPhotoData> poemPhotoDatas = null;
  45. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  46. {
  47. poemPhotoDatas = PersonalPhotoInfos;
  48. }
  49. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  50. {
  51. poemPhotoDatas = WsqsPhotoInfos;
  52. }
  53. for (int i = 0; i < pictureIds.Count; i++)
  54. {
  55. for (int j = 0; j < poemPhotoDatas.Count; j++)
  56. {
  57. if (pictureIds[i] == poemPhotoDatas[j].PictureId)
  58. {
  59. poemPhotoDatas.RemoveAt(j);
  60. break;
  61. }
  62. }
  63. }
  64. poemPhotoDatas.SortInfos();
  65. }
  66. public void ChangeLockingState(long pictureId, bool state, int sourceType)
  67. {
  68. List<PoemPhotoData> poemPhotoDatas = null;
  69. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  70. {
  71. poemPhotoDatas = PersonalPhotoInfos;
  72. }
  73. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  74. {
  75. poemPhotoDatas = WsqsPhotoInfos;
  76. }
  77. for (int i = 0; i < poemPhotoDatas.Count; i++)
  78. {
  79. if (poemPhotoDatas[i].PictureId == pictureId)
  80. {
  81. poemPhotoDatas[i].LockingStatus = state;
  82. break;
  83. }
  84. }
  85. poemPhotoDatas.SortInfos();
  86. }
  87. public void ChangeToppingState(long pictureId, bool state, int sourceType)
  88. {
  89. List<PoemPhotoData> poemPhotoDatas = null;
  90. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  91. {
  92. poemPhotoDatas = PersonalPhotoInfos;
  93. }
  94. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  95. {
  96. poemPhotoDatas = WsqsPhotoInfos;
  97. }
  98. for (int i = 0; i < poemPhotoDatas.Count; i++)
  99. {
  100. if (poemPhotoDatas[i].PictureId == pictureId)
  101. {
  102. poemPhotoDatas[i].ToppingStatus = state;
  103. break;
  104. }
  105. }
  106. poemPhotoDatas.SortInfos();
  107. }
  108. public PoemPhotoData GetPersonalPhotoDataById(long pictureId)
  109. {
  110. for (int i = 0; i < PersonalPhotoInfos.Count; i++)
  111. {
  112. if (pictureId == PersonalPhotoInfos[i].PictureId)
  113. {
  114. return PersonalPhotoInfos[i];
  115. }
  116. }
  117. return null;
  118. }
  119. public NTexture BytesToTexture2D(byte[] bytes)
  120. {
  121. Texture2D texture2D = new Texture2D(UnityEngine.Screen.width, UnityEngine.Screen.height);
  122. texture2D.LoadImage(bytes);
  123. return new NTexture(texture2D);
  124. }
  125. }
  126. }