PhotoBGData.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using System;
  2. using System.Collections.Generic;
  3. using MyRoomCustom;
  4. using UnityEngine;
  5. using wf;
  6. public class PhotoBGData
  7. {
  8. private PhotoBGData()
  9. {
  10. }
  11. public static void Create()
  12. {
  13. PhotoBGData.bg_data_ = new List<PhotoBGData>();
  14. PhotoBGData.init_data_ = null;
  15. PhotoBGData.bg_data_ = new List<PhotoBGData>();
  16. PhotoBGData.category_list_ = new Dictionary<string, List<PhotoBGData>>();
  17. PhotoBGData.popup_menu_list_ = new List<KeyValuePair<string, UnityEngine.Object>>();
  18. HashSet<int> hashSet = new HashSet<int>();
  19. CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "phot_bg_enabled_list", ref hashSet);
  20. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("phot_bg_list.nei"))
  21. {
  22. using (CsvParser csvParser = new CsvParser())
  23. {
  24. bool condition = csvParser.Open(afileBase);
  25. NDebug.Assert(condition, "phot_bg_list.nei\nopen failed.");
  26. for (int i = 1; i < csvParser.max_cell_y; i++)
  27. {
  28. if (csvParser.IsCellToExistData(0, i) && hashSet.Contains(csvParser.GetCellAsInteger(0, i)))
  29. {
  30. int num = 0;
  31. PhotoBGData photoBGData = new PhotoBGData();
  32. photoBGData.id = csvParser.GetCellAsInteger(num++, i).ToString();
  33. photoBGData.category = csvParser.GetCellAsString(num++, i);
  34. photoBGData.name = csvParser.GetCellAsString(num++, i);
  35. photoBGData.create_prefab_name = csvParser.GetCellAsString(num++, i);
  36. string cellAsString = csvParser.GetCellAsString(num++, i);
  37. if (string.IsNullOrEmpty(cellAsString) || PluginData.IsEnabled(cellAsString))
  38. {
  39. PhotoBGData.bg_data_.Add(photoBGData);
  40. if (PhotoBGData.init_data_ == null)
  41. {
  42. PhotoBGData.init_data_ = photoBGData;
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. Dictionary<string, string> saveDataDic = CreativeRoomManager.GetSaveDataDic();
  50. if (saveDataDic != null)
  51. {
  52. foreach (KeyValuePair<string, string> keyValuePair in saveDataDic)
  53. {
  54. PhotoBGData photoBGData2 = new PhotoBGData();
  55. photoBGData2.id = keyValuePair.Key;
  56. photoBGData2.category = "マイルーム";
  57. photoBGData2.name = keyValuePair.Value;
  58. photoBGData2.create_prefab_name = string.Empty;
  59. PhotoBGData.bg_data_.Add(photoBGData2);
  60. }
  61. }
  62. PhotoBGData.category_list_ = new Dictionary<string, List<PhotoBGData>>();
  63. PhotoBGData.popup_menu_list_ = new List<KeyValuePair<string, UnityEngine.Object>>();
  64. PhotoBGData.popup_category_term_list = new List<string>();
  65. HashSet<string> hashSet2 = new HashSet<string>();
  66. List<PhotoBGData> data = PhotoBGData.data;
  67. for (int j = 0; j < data.Count; j++)
  68. {
  69. if (!PhotoBGData.category_list_.ContainsKey(data[j].category))
  70. {
  71. PhotoBGData.category_list_.Add(data[j].category, new List<PhotoBGData>());
  72. }
  73. PhotoBGData.category_list_[data[j].category].Add(data[j]);
  74. if (!hashSet2.Contains(data[j].category))
  75. {
  76. PhotoBGData.popup_menu_list_.Add(new KeyValuePair<string, UnityEngine.Object>(data[j].category, null));
  77. PhotoBGData.popup_category_term_list.Add("ScenePhotoMode/BG/カテゴリー/" + data[j].category);
  78. hashSet2.Add(data[j].category);
  79. }
  80. }
  81. }
  82. public string nameTerm
  83. {
  84. get
  85. {
  86. return (!(this.category == "マイルーム")) ? ("ScenePhotoMode/BG/" + this.id.ToString() + "/名前") : string.Empty;
  87. }
  88. }
  89. public void Apply()
  90. {
  91. if (!string.IsNullOrEmpty(this.create_prefab_name))
  92. {
  93. GameMain.Instance.BgMgr.ChangeBg(this.create_prefab_name);
  94. }
  95. else if (CreativeRoomManager.IsExistSaveData(this.id))
  96. {
  97. GameMain.Instance.BgMgr.ChangeBgMyRoom(this.id);
  98. }
  99. }
  100. public static List<PhotoBGData> data
  101. {
  102. get
  103. {
  104. return PhotoBGData.bg_data_;
  105. }
  106. }
  107. public static PhotoBGData init_data
  108. {
  109. get
  110. {
  111. return PhotoBGData.init_data_;
  112. }
  113. }
  114. public static Dictionary<string, List<PhotoBGData>> category_list
  115. {
  116. get
  117. {
  118. return PhotoBGData.category_list_;
  119. }
  120. }
  121. public static List<string> popup_category_term_list { get; private set; }
  122. public static List<KeyValuePair<string, UnityEngine.Object>> popup_category_list
  123. {
  124. get
  125. {
  126. return PhotoBGData.popup_menu_list_;
  127. }
  128. }
  129. public static PhotoBGData Get(string id)
  130. {
  131. for (int i = 0; i < PhotoBGData.bg_data_.Count; i++)
  132. {
  133. if (PhotoBGData.bg_data_[i].id == id)
  134. {
  135. return PhotoBGData.bg_data_[i];
  136. }
  137. }
  138. return null;
  139. }
  140. public string id;
  141. public string category;
  142. public string name;
  143. public string create_prefab_name;
  144. private static PhotoBGData init_data_;
  145. private static List<PhotoBGData> bg_data_;
  146. private static Dictionary<string, List<PhotoBGData>> category_list_;
  147. private static List<KeyValuePair<string, UnityEngine.Object>> popup_menu_list_;
  148. }