VoiceIconData.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. namespace SceneEditWindow
  5. {
  6. public class VoiceIconData
  7. {
  8. public static Dictionary<int, VoiceIconData.ItemData> itemList { get; private set; }
  9. public static Dictionary<int, VoiceIconData.ItemData> itemSubList { get; private set; }
  10. public static VoiceIconData.ItemData GetItemData(Personal.Data data)
  11. {
  12. return VoiceIconData.itemList[data.id];
  13. }
  14. public static VoiceIconData.ItemData GetItemData(SubMaid.Data data)
  15. {
  16. return VoiceIconData.itemSubList[data.id];
  17. }
  18. public static VoiceIconData.ItemData.EmotionData GetEmotionData(Personal.Data data, VoiceIconData.ItemData.EmotionType type)
  19. {
  20. return VoiceIconData.GetItemData(data).emotionDatas[type];
  21. }
  22. public static VoiceIconData.ItemData.EmotionData GetEmotionData(SubMaid.Data data, VoiceIconData.ItemData.EmotionType type)
  23. {
  24. return VoiceIconData.GetItemData(data).emotionDatas[type];
  25. }
  26. public static VoiceIconData.ItemData.EmotionData GetEmotionData(Maid maid, VoiceIconData.ItemData.EmotionType type)
  27. {
  28. return (maid.status.subCharaData == null) ? VoiceIconData.GetEmotionData(maid.status.personal, type) : VoiceIconData.GetEmotionData(maid.status.subCharaData, type);
  29. }
  30. public static void Create()
  31. {
  32. if (VoiceIconData.itemList != null)
  33. {
  34. return;
  35. }
  36. VoiceIconData.itemList = new Dictionary<int, VoiceIconData.ItemData>();
  37. VoiceIconData.itemSubList = new Dictionary<int, VoiceIconData.ItemData>();
  38. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("edit_voice.nei"))
  39. {
  40. using (CsvParser csvParser = new CsvParser())
  41. {
  42. bool condition = csvParser.Open(afileBase);
  43. NDebug.Assert(condition, "edit_voice.nei\nopen failed.");
  44. for (int i = 1; i < csvParser.max_cell_y; i++)
  45. {
  46. if (csvParser.IsCellToExistData(0, i))
  47. {
  48. int num = 0;
  49. VoiceIconData.ItemData.EmotionData emotionData = new VoiceIconData.ItemData.EmotionData();
  50. string cellAsString = csvParser.GetCellAsString(num++, i);
  51. if (!string.IsNullOrEmpty(cellAsString))
  52. {
  53. try
  54. {
  55. emotionData.type = (VoiceIconData.ItemData.EmotionType)Enum.Parse(typeof(VoiceIconData.ItemData.EmotionType), cellAsString);
  56. }
  57. catch (Exception e)
  58. {
  59. NDebug.AssertParseError("VoiceIconData.ItemData.EmotionsType", e);
  60. }
  61. }
  62. string cellAsString2 = csvParser.GetCellAsString(num++, i);
  63. if (Personal.Contains(cellAsString2))
  64. {
  65. emotionData.personalData = Personal.GetData(cellAsString2);
  66. }
  67. else
  68. {
  69. emotionData.subMaidData = SubMaid.GetData(cellAsString2);
  70. }
  71. emotionData.voiceFileName = csvParser.GetCellAsString(num++, i);
  72. emotionData.facialExpressions = csvParser.GetCellAsString(num++, i);
  73. emotionData.addFacialExpressions = csvParser.GetCellAsString(num++, i);
  74. VoiceIconData.ItemData itemData = new VoiceIconData.ItemData();
  75. itemData.emotionDatas = new Dictionary<VoiceIconData.ItemData.EmotionType, VoiceIconData.ItemData.EmotionData>();
  76. if (emotionData.personalData != null)
  77. {
  78. if (VoiceIconData.itemList.ContainsKey(emotionData.personalData.id))
  79. {
  80. itemData = VoiceIconData.itemList[emotionData.personalData.id];
  81. }
  82. else
  83. {
  84. VoiceIconData.itemList.Add(emotionData.personalData.id, itemData);
  85. }
  86. if (itemData.emotionDatas.ContainsKey(emotionData.type))
  87. {
  88. NDebug.Assert("データが重複しています", false);
  89. }
  90. itemData.emotionDatas.Add(emotionData.type, emotionData);
  91. }
  92. else
  93. {
  94. if (VoiceIconData.itemSubList.ContainsKey(emotionData.subMaidData.id))
  95. {
  96. itemData = VoiceIconData.itemSubList[emotionData.subMaidData.id];
  97. }
  98. else
  99. {
  100. VoiceIconData.itemSubList.Add(emotionData.subMaidData.id, itemData);
  101. }
  102. if (itemData.emotionDatas.ContainsKey(emotionData.type))
  103. {
  104. NDebug.Assert("データが重複しています", false);
  105. }
  106. itemData.emotionDatas.Add(emotionData.type, emotionData);
  107. }
  108. }
  109. }
  110. }
  111. }
  112. }
  113. public class ItemData
  114. {
  115. public static readonly string[] EmotionTexFileNames = new string[]
  116. {
  117. "cm3d2_voiceicon_joy.tex",
  118. "cm3d2_voiceicon_anger.tex",
  119. "cm3d2_voiceicon_comfort.tex",
  120. "cm3d2_voiceicon_pity.tex"
  121. };
  122. public Dictionary<VoiceIconData.ItemData.EmotionType, VoiceIconData.ItemData.EmotionData> emotionDatas;
  123. public enum EmotionType
  124. {
  125. Joy,
  126. Anger,
  127. Sorrow,
  128. Fun
  129. }
  130. public class EmotionData
  131. {
  132. public void Apply(Maid maid)
  133. {
  134. if (maid == null)
  135. {
  136. return;
  137. }
  138. GameMain.Instance.SoundMgr.VoiceStopAll();
  139. maid.AudioMan.LoadPlay(this.voiceFileName, 0f, false, false);
  140. maid.FaceAnime(this.facialExpressions, 1f, 0);
  141. if (string.IsNullOrEmpty(this.addFacialExpressions))
  142. {
  143. maid.FaceBlend("無し");
  144. }
  145. else
  146. {
  147. maid.FaceBlend(this.addFacialExpressions);
  148. }
  149. }
  150. public Personal.Data personalData;
  151. public SubMaid.Data subMaidData;
  152. public string voiceFileName;
  153. public string facialExpressions;
  154. public string addFacialExpressions;
  155. public VoiceIconData.ItemData.EmotionType type;
  156. }
  157. }
  158. }
  159. }