PhotoBGData.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. HashSet<string> hashSet2 = new HashSet<string>();
  65. List<PhotoBGData> data = PhotoBGData.data;
  66. for (int j = 0; j < data.Count; j++)
  67. {
  68. if (!PhotoBGData.category_list_.ContainsKey(data[j].category))
  69. {
  70. PhotoBGData.category_list_.Add(data[j].category, new List<PhotoBGData>());
  71. }
  72. PhotoBGData.category_list_[data[j].category].Add(data[j]);
  73. if (!hashSet2.Contains(data[j].category))
  74. {
  75. PhotoBGData.popup_menu_list_.Add(new KeyValuePair<string, UnityEngine.Object>(data[j].category, null));
  76. hashSet2.Add(data[j].category);
  77. }
  78. }
  79. }
  80. public void Apply()
  81. {
  82. if (!string.IsNullOrEmpty(this.create_prefab_name))
  83. {
  84. GameMain.Instance.BgMgr.ChangeBg(this.create_prefab_name);
  85. }
  86. else if (CreativeRoomManager.IsExistSaveData(this.id))
  87. {
  88. GameMain.Instance.BgMgr.ChangeBgMyRoom(this.id);
  89. }
  90. }
  91. public static List<PhotoBGData> data
  92. {
  93. get
  94. {
  95. return PhotoBGData.bg_data_;
  96. }
  97. }
  98. public static PhotoBGData init_data
  99. {
  100. get
  101. {
  102. return PhotoBGData.init_data_;
  103. }
  104. }
  105. public static Dictionary<string, List<PhotoBGData>> category_list
  106. {
  107. get
  108. {
  109. return PhotoBGData.category_list_;
  110. }
  111. }
  112. public static List<KeyValuePair<string, UnityEngine.Object>> popup_category_list
  113. {
  114. get
  115. {
  116. return PhotoBGData.popup_menu_list_;
  117. }
  118. }
  119. public static PhotoBGData Get(string id)
  120. {
  121. for (int i = 0; i < PhotoBGData.bg_data_.Count; i++)
  122. {
  123. if (PhotoBGData.bg_data_[i].id == id)
  124. {
  125. return PhotoBGData.bg_data_[i];
  126. }
  127. }
  128. return null;
  129. }
  130. public string id;
  131. public string category;
  132. public string name;
  133. public string create_prefab_name;
  134. private static PhotoBGData init_data_;
  135. private static List<PhotoBGData> bg_data_;
  136. private static Dictionary<string, List<PhotoBGData>> category_list_;
  137. private static List<KeyValuePair<string, UnityEngine.Object>> popup_menu_list_;
  138. }