AppealData.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using System;
  2. using System.Collections.Generic;
  3. using I2.Loc;
  4. using UnityEngine;
  5. using wf;
  6. namespace Kasizuki
  7. {
  8. public static class AppealData
  9. {
  10. public static int Count
  11. {
  12. get
  13. {
  14. AppealData.CreateData();
  15. return AppealData.commonIdManager.idMap.Count;
  16. }
  17. }
  18. public static bool Contains(int id)
  19. {
  20. AppealData.CreateData();
  21. return AppealData.commonIdManager.idMap.ContainsKey(id);
  22. }
  23. public static AppealData.Data GetData(int id)
  24. {
  25. AppealData.CreateData();
  26. NDebug.Assert(AppealData.basicDatas.ContainsKey(id), "傅き.アピール欄\nID[" + id + "]のデータは存在しません");
  27. return AppealData.basicDatas[id];
  28. }
  29. public static bool IsEnabled(int id)
  30. {
  31. AppealData.CreateData();
  32. return AppealData.commonIdManager.enabledIdList.Contains(id);
  33. }
  34. public static List<AppealData.Data> GetAllDatas(bool onlyEnabled)
  35. {
  36. AppealData.CreateData();
  37. List<AppealData.Data> list = new List<AppealData.Data>();
  38. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in AppealData.commonIdManager.idMap)
  39. {
  40. if (!onlyEnabled || AppealData.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  41. {
  42. list.Add(AppealData.basicDatas[keyValuePair.Key]);
  43. }
  44. }
  45. return list;
  46. }
  47. public static List<AppealData.Data> GetDatas(Func<AppealData.Data, bool> customCheckFunction)
  48. {
  49. AppealData.CreateData();
  50. List<AppealData.Data> list = new List<AppealData.Data>();
  51. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in AppealData.commonIdManager.idMap)
  52. {
  53. AppealData.Data data = AppealData.basicDatas[keyValuePair.Key];
  54. if (customCheckFunction(data))
  55. {
  56. list.Add(data);
  57. }
  58. }
  59. return list;
  60. }
  61. public static List<AppealData.Data> GetDatas(Maid maid)
  62. {
  63. Func<AppealData.Data, bool> customCheckFunction = (AppealData.Data data) => data.personalUniqueName == maid.status.personal.uniqueName;
  64. return AppealData.GetDatas(customCheckFunction);
  65. }
  66. public static void CreateData()
  67. {
  68. if (AppealData.commonIdManager != null)
  69. {
  70. return;
  71. }
  72. AppealData.commonIdManager = new CsvCommonIdManager("kasizuki_appeal", "傅き.アピール欄", CsvCommonIdManager.Type.IdOnly, null);
  73. AppealData.basicDatas = new Dictionary<int, AppealData.Data>();
  74. string[] array = new string[]
  75. {
  76. "list"
  77. };
  78. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  79. for (int i = 0; i < array2.Length; i++)
  80. {
  81. string text = "kasizuki_appeal_" + array[i] + ".nei";
  82. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  83. CsvParser csvParser = new CsvParser();
  84. bool condition = csvParser.Open(afileBase);
  85. NDebug.Assert(condition, text + "\nopen failed.");
  86. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  87. }
  88. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in AppealData.commonIdManager.idMap)
  89. {
  90. int key = keyValuePair.Key;
  91. AppealData.Data value = new AppealData.Data(key, array2[0].Value);
  92. AppealData.basicDatas.Add(key, value);
  93. }
  94. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  95. {
  96. keyValuePair2.Value.Dispose();
  97. keyValuePair2.Key.Dispose();
  98. }
  99. }
  100. private const string csvTopCommonName = "kasizuki_appeal";
  101. private const string typeNameForErrorLog = "傅き.アピール欄";
  102. private static CsvCommonIdManager commonIdManager;
  103. private static Dictionary<int, AppealData.Data> basicDatas;
  104. public class Data
  105. {
  106. public Data(int uniqueID, CsvParser csv)
  107. {
  108. for (int i = 1; i < csv.max_cell_y; i++)
  109. {
  110. if (csv.IsCellToExistData(0, i) && csv.GetCellAsInteger(0, i) == uniqueID)
  111. {
  112. int num = 1;
  113. this.ID = uniqueID;
  114. this.personalUniqueName = csv.GetCellAsString(num++, i);
  115. this.texName = csv.GetCellAsString(num++, i);
  116. }
  117. }
  118. }
  119. public string texNameTerm
  120. {
  121. get
  122. {
  123. return "SceneKasizukiMainMenu/アピールイメージ/" + this.ID;
  124. }
  125. }
  126. public Texture2D GetTexture()
  127. {
  128. if (!string.IsNullOrEmpty(this.texName))
  129. {
  130. string f_strFileName = this.texName + ".tex";
  131. if (GameUty.FileSystem.IsExistentFile(f_strFileName))
  132. {
  133. return ImportCM.CreateTexture(f_strFileName);
  134. }
  135. Debug.LogWarningFormat("テクスチャ「{0}」がない", new object[]
  136. {
  137. this.texName
  138. });
  139. }
  140. else
  141. {
  142. Debug.LogWarning("テクスチャ名が空でした");
  143. }
  144. return null;
  145. }
  146. public Texture2D GetTexture(string language)
  147. {
  148. string termTranslation = LocalizationManager.GetTermTranslation(this.texNameTerm, true, 0, true, false, null, language);
  149. if (!string.IsNullOrEmpty(termTranslation))
  150. {
  151. string f_strFileName = termTranslation + ".tex";
  152. if (GameUty.FileSystem.IsExistentFile(f_strFileName))
  153. {
  154. return ImportCM.CreateTexture(f_strFileName);
  155. }
  156. Debug.LogWarningFormat("テクスチャ「{0}」がない", new object[]
  157. {
  158. termTranslation
  159. });
  160. }
  161. else
  162. {
  163. Debug.LogWarning("テクスチャ名が空でした");
  164. }
  165. return null;
  166. }
  167. public readonly int ID;
  168. public readonly string personalUniqueName;
  169. public readonly string texName;
  170. }
  171. }
  172. }