PoseIconData.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using wf;
  5. namespace SceneEditWindow
  6. {
  7. public class PoseIconData
  8. {
  9. public static List<PoseIconData.ItemData> itemList { get; private set; }
  10. public static PoseIconData.ItemData GetItemData(int id)
  11. {
  12. PoseIconData.ItemData result = default(PoseIconData.ItemData);
  13. foreach (PoseIconData.ItemData itemData in PoseIconData.itemList)
  14. {
  15. if (itemData.id == id)
  16. {
  17. result = itemData;
  18. break;
  19. }
  20. }
  21. return result;
  22. }
  23. public static void Create()
  24. {
  25. if (PoseIconData.itemList != null)
  26. {
  27. return;
  28. }
  29. HashSet<int> hashSet = new HashSet<int>();
  30. CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "edit_pose_enabled_list", ref hashSet);
  31. HashSet<int> idHash = new HashSet<int>();
  32. HashSet<string> texNameHash = new HashSet<string>();
  33. PoseIconData.itemList = new List<PoseIconData.ItemData>();
  34. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("edit_pose.nei"))
  35. {
  36. using (CsvParser csvParser = new CsvParser())
  37. {
  38. bool condition = csvParser.Open(afileBase);
  39. NDebug.Assert(condition, "edit_pose.nei\nopen failed.");
  40. for (int i = 1; i < csvParser.max_cell_y; i++)
  41. {
  42. if (csvParser.IsCellToExistData(0, i))
  43. {
  44. int num = 0;
  45. PoseIconData.ItemData item = default(PoseIconData.ItemData);
  46. item.id = csvParser.GetCellAsInteger(num++, i);
  47. if (hashSet.Contains(item.id))
  48. {
  49. if (!idHash.Contains(item.id))
  50. {
  51. idHash.Add(item.id);
  52. item.iconTexName = Path.ChangeExtension(csvParser.GetCellAsString(num++, i).ToString(), "tex");
  53. if (!texNameHash.Contains(item.iconTexName))
  54. {
  55. texNameHash.Add(item.iconTexName);
  56. item.targetBoneName = csvParser.GetCellAsString(num++, i);
  57. item.callScriptFileName = Path.ChangeExtension(csvParser.GetCellAsString(num++, i).ToString(), "ks");
  58. item.callLabelName = csvParser.GetCellAsString(num++, i);
  59. item.fileSystem = GameUty.FileSystem;
  60. PoseIconData.itemList.Add(item);
  61. }
  62. }
  63. }
  64. }
  65. }
  66. }
  67. }
  68. int poseCount = 0;
  69. Action<string> action = delegate(string fileName)
  70. {
  71. if (!GameUty.FileSystemOld.IsExistentFile(fileName))
  72. {
  73. return;
  74. }
  75. using (AFileBase afileBase2 = GameUty.FileSystemOld.FileOpen(fileName))
  76. {
  77. using (CsvParser csvParser2 = new CsvParser())
  78. {
  79. bool condition2 = csvParser2.Open(afileBase2);
  80. NDebug.Assert(condition2, fileName + "\nopen failed.");
  81. for (int j = 1; j < csvParser2.max_cell_y; j++)
  82. {
  83. if (csvParser2.IsCellToExistData(0, j))
  84. {
  85. int cell_x = 0;
  86. PoseIconData.ItemData item2 = default(PoseIconData.ItemData);
  87. item2.iconTexName = Path.ChangeExtension(csvParser2.GetCellAsString(cell_x++, j).ToString(), "tex");
  88. if (!texNameHash.Contains(item2.iconTexName))
  89. {
  90. texNameHash.Add(item2.iconTexName);
  91. item2.targetBoneName = csvParser2.GetCellAsString(cell_x++, j);
  92. item2.callScriptFileName = Path.ChangeExtension(csvParser2.GetCellAsString(cell_x++, j).ToString(), "ks");
  93. item2.callLabelName = csvParser2.GetCellAsString(cell_x++, j);
  94. if (csvParser2.IsCellToExistData(cell_x, j))
  95. {
  96. item2.id = csvParser2.GetCellAsInteger(cell_x, j) + 910000;
  97. }
  98. else
  99. {
  100. item2.id = 900000 + poseCount++;
  101. }
  102. if (!idHash.Contains(item2.id))
  103. {
  104. idHash.Add(item2.id);
  105. item2.fileSystem = GameUty.FileSystemOld;
  106. bool flag = false;
  107. foreach (PoseIconData.ItemData itemData in PoseIconData.itemList)
  108. {
  109. if (itemData.iconTexName.ToLower() == item2.iconTexName.ToLower())
  110. {
  111. flag = true;
  112. break;
  113. }
  114. }
  115. if (!flag)
  116. {
  117. PoseIconData.itemList.Add(item2);
  118. }
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. };
  126. foreach (string str in GameUty.PathListOld)
  127. {
  128. action("edit_pose_" + str + ".nei");
  129. }
  130. PoseIconData.itemList.Sort((PoseIconData.ItemData a, PoseIconData.ItemData b) => a.id - b.id);
  131. }
  132. public struct ItemData
  133. {
  134. public bool ExecScript()
  135. {
  136. if (GameMain.Instance == null || GameMain.Instance.ScriptMgr == null || string.IsNullOrEmpty(this.callScriptFileName))
  137. {
  138. return false;
  139. }
  140. ScriptManager scriptMgr = GameMain.Instance.ScriptMgr;
  141. if (this.fileSystem != GameUty.FileSystem)
  142. {
  143. scriptMgr.compatibilityMode = true;
  144. }
  145. scriptMgr.is_motion_blend = false;
  146. scriptMgr.LoadMotionScript(0, false, this.callScriptFileName, this.callLabelName, string.Empty, string.Empty, false, true, false, false);
  147. scriptMgr.is_motion_blend = true;
  148. if (scriptMgr.compatibilityMode)
  149. {
  150. scriptMgr.compatibilityMode = false;
  151. }
  152. return true;
  153. }
  154. public int id;
  155. public string iconTexName;
  156. public string targetBoneName;
  157. public string callScriptFileName;
  158. public string callLabelName;
  159. public AFileSystemBase fileSystem;
  160. }
  161. }
  162. }