Menu.cs 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  7. using System.Text;
  8. using System.Text.RegularExpressions;
  9. using UnityEngine;
  10. public class Menu : MonoBehaviour
  11. {
  12. public static string[] GetModFiles()
  13. {
  14. string fullPath = Path.GetFullPath(".\\");
  15. string path = fullPath + "Mod";
  16. if (!Directory.Exists(path))
  17. {
  18. return null;
  19. }
  20. return Directory.GetFiles(path, "mod_*.mod", SearchOption.AllDirectories);
  21. }
  22. public static string GetModPathFileName(string f_strMenuFileName)
  23. {
  24. string[] modFiles = Menu.GetModFiles();
  25. if (modFiles == null)
  26. {
  27. NDebug.MessageBox("MODエラー", "MODフォルダが無いか、MODフォルダにMODファイルが1つもありません。\n" + f_strMenuFileName);
  28. return string.Empty;
  29. }
  30. string text = Array.Find<string>(modFiles, (string a) => Path.GetFileName(a).ToLower() == f_strMenuFileName.ToLower());
  31. if (string.IsNullOrEmpty(text))
  32. {
  33. NDebug.MessageBox("MODエラー", "MODフォルダにMODファイルが見つかりません。\n" + f_strMenuFileName);
  34. return string.Empty;
  35. }
  36. return text;
  37. }
  38. public static bool ProcScript(Maid maid, string filename, bool f_bTemp = false, SubProp f_SubProp = null)
  39. {
  40. return Menu.ProcScript(maid, new MaidProp
  41. {
  42. strFileName = filename,
  43. strTempFileName = filename
  44. }, f_bTemp, f_SubProp);
  45. }
  46. public static bool ProcScript(Maid maid, MaidProp mp, bool f_bTemp = false, SubProp f_SubProp = null)
  47. {
  48. string text;
  49. if (f_bTemp)
  50. {
  51. text = mp.strTempFileName;
  52. }
  53. else
  54. {
  55. text = mp.strFileName;
  56. }
  57. bool flag = false;
  58. string text2 = string.Empty;
  59. byte[] array = null;
  60. if (text.IndexOf("mod_") == 0)
  61. {
  62. flag = true;
  63. text2 = Menu.GetModPathFileName(text);
  64. if (string.IsNullOrEmpty(text2))
  65. {
  66. return false;
  67. }
  68. text = Menu.GetBaseItemFromMod(text2);
  69. try
  70. {
  71. using (FileStream fileStream = new FileStream(text2, FileMode.Open))
  72. {
  73. if (fileStream == null)
  74. {
  75. Debug.LogWarning("MODアイテムメニューファイルが見つかりません。" + text);
  76. return false;
  77. }
  78. array = new byte[fileStream.Length];
  79. fileStream.Read(array, 0, (int)fileStream.Length);
  80. }
  81. }
  82. catch (Exception ex)
  83. {
  84. Debug.LogError("ProcScript MODアイテムメニューファイルが読み込めませんでした。 : " + text + " : " + ex.Message);
  85. return false;
  86. }
  87. }
  88. byte[] cd = null;
  89. try
  90. {
  91. using (AFileBase afileBase = GameUty.FileOpen(text, null))
  92. {
  93. if (afileBase == null || !afileBase.IsValid())
  94. {
  95. Debug.LogError("アイテムメニューファイルが見つかりません。" + text);
  96. return false;
  97. }
  98. cd = afileBase.ReadAll();
  99. }
  100. }
  101. catch (Exception ex2)
  102. {
  103. Debug.LogError("ProcScript アイテムメニューファイルが読み込めませんでした。 : " + text + " : " + ex2.Message);
  104. return false;
  105. }
  106. Menu.ProcScriptBin(maid, cd, mp, f_bTemp, f_SubProp);
  107. if (flag)
  108. {
  109. Menu.ProcModScriptBin(maid, array, text2, mp, false);
  110. }
  111. return true;
  112. }
  113. private static void ProcScriptBin(Maid maid, byte[] cd, string filename, bool f_bTemp = false, SubProp f_SubProp = null)
  114. {
  115. Menu.ProcScriptBin(maid, cd, new MaidProp
  116. {
  117. strFileName = filename,
  118. strTempFileName = filename
  119. }, f_bTemp, f_SubProp);
  120. }
  121. private static void ProcScriptBin(Maid maid, byte[] cd, MaidProp mp, bool f_bTemp = false, SubProp f_SubProp = null)
  122. {
  123. string text;
  124. if (f_bTemp)
  125. {
  126. text = mp.strTempFileName;
  127. }
  128. else
  129. {
  130. text = mp.strFileName;
  131. }
  132. TBody body = maid.body0;
  133. if (mp.idx == 61 || mp.idx == 64 || mp.idx == 65 || mp.idx == 66)
  134. {
  135. TBodySkin slot = body.GetSlot(1);
  136. if (slot.PartsVersion < 110)
  137. {
  138. return;
  139. }
  140. }
  141. List<Menu.LastParam> list = new List<Menu.LastParam>();
  142. BinaryReader binaryReader = new BinaryReader(new MemoryStream(cd), Encoding.UTF8);
  143. string text2 = binaryReader.ReadString();
  144. NDebug.Assert(text2 == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text2);
  145. int num = binaryReader.ReadInt32();
  146. string text3 = binaryReader.ReadString();
  147. string text4 = binaryReader.ReadString();
  148. string text5 = binaryReader.ReadString();
  149. string text6 = binaryReader.ReadString();
  150. long num2 = (long)binaryReader.ReadInt32();
  151. bool flag = false;
  152. string text7 = string.Empty;
  153. string text8 = string.Empty;
  154. string text9 = string.Empty;
  155. string slotname = string.Empty;
  156. int version = 100;
  157. bool flag2 = false;
  158. bool flag3 = false;
  159. for (;;)
  160. {
  161. try
  162. {
  163. for (;;)
  164. {
  165. IL_108:
  166. int num3 = (int)binaryReader.ReadByte();
  167. text8 = text7;
  168. text7 = string.Empty;
  169. if (num3 == 0)
  170. {
  171. break;
  172. }
  173. for (int i = 0; i < num3; i++)
  174. {
  175. text7 = text7 + "\"" + binaryReader.ReadString() + "\" ";
  176. }
  177. if (!(text7 == string.Empty))
  178. {
  179. goto IL_16F;
  180. }
  181. }
  182. break;
  183. IL_16F:
  184. string stringCom = UTY.GetStringCom(text7);
  185. string[] stringList = UTY.GetStringList(text7);
  186. if (stringCom == "end")
  187. {
  188. break;
  189. }
  190. if (stringCom == "name")
  191. {
  192. goto IL_14B9;
  193. }
  194. if (stringCom == "ver")
  195. {
  196. TBodySkin slot2 = body.GetSlot(stringList[1]);
  197. version = int.Parse(stringList[2]);
  198. goto IL_14B9;
  199. }
  200. if (stringCom == "アイテム")
  201. {
  202. Menu.SetMaidItemTemp(maid, stringList[1], f_bTemp);
  203. goto IL_14B9;
  204. }
  205. if (stringCom == "アイテム条件")
  206. {
  207. string slotname2 = stringList[1];
  208. if (stringList[2] == "に何か")
  209. {
  210. bool flag4 = false;
  211. TBodySkin slot3 = body.GetSlot(slotname2);
  212. if (stringList[3] == "有る")
  213. {
  214. if (slot3.obj != null)
  215. {
  216. flag4 = true;
  217. }
  218. }
  219. else if (stringList[3] == "無い")
  220. {
  221. if (slot3.obj == null)
  222. {
  223. flag4 = true;
  224. }
  225. }
  226. else
  227. {
  228. NDebug.Assert("アイテム条件が不正です。「有る」か「無い」かを指定してください。\n" + text7, false);
  229. }
  230. if (stringList[4] == "なら")
  231. {
  232. if (flag4)
  233. {
  234. Menu.SetMaidItemTemp(maid, stringList[5], f_bTemp);
  235. goto IL_2C9;
  236. }
  237. goto IL_2C9;
  238. IL_2C9:
  239. goto IL_2E0;
  240. }
  241. NDebug.Assert("アイテム条件が不正です。「なら」が必要です。\n" + text7, false);
  242. goto IL_2E0;
  243. IL_2E0:
  244. goto IL_414;
  245. }
  246. if (stringList[2] == "が")
  247. {
  248. bool flag5 = false;
  249. TBodySkin slot4 = body.GetSlot(slotname2);
  250. if (slot4.m_strModelFileName == stringList[3])
  251. {
  252. flag5 = true;
  253. }
  254. if (stringList[4] == "なら")
  255. {
  256. if (flag5)
  257. {
  258. Menu.SetMaidItemTemp(maid, stringList[5], f_bTemp);
  259. goto IL_345;
  260. }
  261. goto IL_345;
  262. IL_345:
  263. goto IL_35C;
  264. }
  265. NDebug.Assert("アイテム条件が不正です。「なら」が必要です。\n" + text7, false);
  266. goto IL_35C;
  267. IL_35C:
  268. goto IL_414;
  269. }
  270. if (!(stringList[2] == "のアイテムパラメータの"))
  271. {
  272. goto IL_414;
  273. }
  274. bool flag6 = false;
  275. TBodySkin slot5 = body.GetSlot(slotname2);
  276. string param = slot5.GetParam(stringList[3].ToLower());
  277. if (stringList[4] == "が")
  278. {
  279. if (stringList[5].ToLower() == param)
  280. {
  281. flag6 = true;
  282. }
  283. }
  284. else
  285. {
  286. NDebug.Assert("アイテム条件が不正です。「が」が必要です。\n" + text7, false);
  287. }
  288. if (stringList[6] == "なら")
  289. {
  290. if (flag6)
  291. {
  292. Menu.SetMaidItemTemp(maid, stringList[7], f_bTemp);
  293. goto IL_3FD;
  294. }
  295. goto IL_3FD;
  296. IL_3FD:
  297. goto IL_414;
  298. }
  299. NDebug.Assert("アイテム条件が不正です。「なら」が必要です。\n" + text7, false);
  300. goto IL_414;
  301. IL_414:
  302. goto IL_14B9;
  303. }
  304. if (stringCom == "if")
  305. {
  306. if (stringList[1].IndexOf("maidprop[") != 0)
  307. {
  308. goto IL_594;
  309. }
  310. string value = stringList[1].Substring(9, stringList[1].Length - 9 - 1);
  311. MPN mpn = (MPN)Enum.Parse(typeof(MPN), value, false);
  312. MaidProp prop = maid.GetProp(mpn);
  313. if (!(stringList[2] == "==") || !(stringList[3] == "nothing") || prop.nFileNameRID != 0 || !(stringList[4] == "?") || stringList[5].IndexOf("setprop[") != 0)
  314. {
  315. goto IL_594;
  316. }
  317. string value2 = stringList[5].Substring(8, stringList[5].Length - 8 - 1);
  318. MPN idx = (MPN)Enum.Parse(typeof(MPN), value2, false);
  319. if (!(stringList[6] == "="))
  320. {
  321. goto IL_594;
  322. }
  323. string text10;
  324. if (stringList[7].IndexOf("getprop[") == 0)
  325. {
  326. string value3 = stringList[7].Substring(8, stringList[7].Length - 8 - 1);
  327. MPN mpn2 = (MPN)Enum.Parse(typeof(MPN), value3, false);
  328. MaidProp prop2 = maid.GetProp(mpn2);
  329. text10 = prop2.strFileName;
  330. }
  331. else
  332. {
  333. text10 = stringList[7];
  334. }
  335. if (!string.IsNullOrEmpty(text10))
  336. {
  337. maid.SetProp(idx, text10, 0, false, false);
  338. goto IL_594;
  339. }
  340. goto IL_594;
  341. IL_594:
  342. goto IL_14B9;
  343. }
  344. if (stringCom == "アイテムパラメータ")
  345. {
  346. if (stringList.Length == 4)
  347. {
  348. string text11 = stringList[1];
  349. string text12 = stringList[2].ToLower();
  350. string text13 = stringList[3].ToLower();
  351. list.Add(new Menu.LastParam(0, stringCom, new string[]
  352. {
  353. text11,
  354. text12,
  355. text13
  356. }));
  357. goto IL_609;
  358. }
  359. Debug.LogError("アイテムパラメータ 命令の引数が不正です。SlotNameを明示的に指定しする必要があります。アイテムパラメータ <スロット名> <変数名> <値> の順です。" + text7);
  360. goto IL_609;
  361. IL_609:
  362. goto IL_14B9;
  363. }
  364. if (stringCom == "半脱ぎ" || stringCom == "リソース参照")
  365. {
  366. string key;
  367. string value4;
  368. if (stringCom == "半脱ぎ")
  369. {
  370. key = "半脱ぎ";
  371. value4 = stringList[1];
  372. }
  373. else
  374. {
  375. key = stringList[1];
  376. value4 = stringList[2];
  377. }
  378. int hashCode = Path.GetFileName(text.ToLower()).ToLower().GetHashCode();
  379. SortedDictionary<string, string> sortedDictionary;
  380. if (Menu.m_dicResourceRef.TryGetValue(hashCode, out sortedDictionary))
  381. {
  382. string empty = string.Empty;
  383. if (sortedDictionary.TryGetValue(key, out empty))
  384. {
  385. sortedDictionary[key] = value4;
  386. goto IL_6BB;
  387. }
  388. sortedDictionary.Add(key, value4);
  389. goto IL_6BB;
  390. IL_6BB:
  391. goto IL_6E0;
  392. }
  393. sortedDictionary = new SortedDictionary<string, string>();
  394. sortedDictionary.Add(key, value4);
  395. Menu.m_dicResourceRef.Add(hashCode, sortedDictionary);
  396. goto IL_6E0;
  397. IL_6E0:
  398. goto IL_14B9;
  399. }
  400. if (stringCom == "set")
  401. {
  402. goto IL_14B9;
  403. }
  404. if (stringCom == "setname")
  405. {
  406. goto IL_14B9;
  407. }
  408. if (stringCom == "setslotitem")
  409. {
  410. string tag = stringList[1];
  411. uint val = uint.Parse(stringList[2]);
  412. maid.SetProp(tag, (int)val, false);
  413. goto IL_14B9;
  414. }
  415. if (stringCom == "additem")
  416. {
  417. string text14 = text9;
  418. if (stringList.Length > 1)
  419. {
  420. text14 = stringList[2];
  421. }
  422. slotname = text14;
  423. if (text14 == "body")
  424. {
  425. body.LoadBody_R(stringList[1], maid);
  426. }
  427. string attachSlot = string.Empty;
  428. string attachName = string.Empty;
  429. if (stringList.Length == 6)
  430. {
  431. if (stringList[3] == "アタッチ")
  432. {
  433. attachSlot = stringList[4];
  434. attachName = stringList[5];
  435. }
  436. }
  437. else if (stringList.Length == 5 && stringList[3] == "ボーンにアタッチ")
  438. {
  439. attachSlot = "ボーンにアタッチ";
  440. attachName = stringList[4];
  441. }
  442. if (text14 == "handitemr")
  443. {
  444. attachSlot = "ボーンにアタッチ";
  445. attachName = "_IK_handR";
  446. }
  447. if (text14 == "handiteml")
  448. {
  449. attachSlot = "ボーンにアタッチ";
  450. attachName = "_IK_handL";
  451. }
  452. body.AddItem((MPN)Enum.Parse(typeof(MPN), text9, true), text14, stringList[1], attachSlot, attachName, f_bTemp, version);
  453. body.SetVisibleNodeSlot(text14, true, "_ALL_");
  454. goto IL_14B9;
  455. }
  456. if (stringCom == "nofloory")
  457. {
  458. TBody.SlotID index = (TBody.SlotID)Enum.Parse(typeof(TBody.SlotID), stringList[1], true);
  459. body.goSlot[(int)index].m_bHitFloorY = false;
  460. goto IL_14B9;
  461. }
  462. if (stringCom == "saveitem")
  463. {
  464. text5 = stringList[1];
  465. goto IL_14B9;
  466. }
  467. if (stringCom == "category")
  468. {
  469. text9 = stringList[1];
  470. flag2 = (text9 == "skin");
  471. flag3 = (text9 == "haircolor");
  472. goto IL_14B9;
  473. }
  474. if (stringCom == "maskitem")
  475. {
  476. if (stringList.Length > 1)
  477. {
  478. string maskslot = stringList[1];
  479. body.AddMask(text9, maskslot);
  480. goto IL_92C;
  481. }
  482. goto IL_92C;
  483. IL_92C:
  484. goto IL_14B9;
  485. }
  486. if (stringCom == "delitem")
  487. {
  488. string slotname3 = text9;
  489. if (stringList.Length > 1)
  490. {
  491. slotname3 = stringList[1];
  492. }
  493. body.DelItem((MPN)Enum.Parse(typeof(MPN), text9, true), slotname3);
  494. goto IL_14B9;
  495. }
  496. if (stringCom == "node消去")
  497. {
  498. body.SetVisibleNodeSlot(text9, false, stringList[1]);
  499. goto IL_14B9;
  500. }
  501. if (stringCom == "node表示")
  502. {
  503. body.SetVisibleNodeSlot(text9, true, stringList[1]);
  504. goto IL_14B9;
  505. }
  506. if (stringCom == "パーツnode消去")
  507. {
  508. body.SetVisibleNodeSlotParts(text9, stringList[1], false, stringList[2]);
  509. goto IL_14B9;
  510. }
  511. if (stringCom == "パーツnode表示")
  512. {
  513. body.SetVisibleNodeSlotParts(text9, stringList[1], true, stringList[2]);
  514. goto IL_14B9;
  515. }
  516. if (stringCom == "color")
  517. {
  518. string name = stringList[1];
  519. int matno = int.Parse(stringList[2]);
  520. string prop_name = stringList[3];
  521. Color col = new Color(float.Parse(stringList[4]) / 255f, float.Parse(stringList[5]) / 255f, float.Parse(stringList[6]) / 255f, float.Parse(stringList[7]) / 255f);
  522. body.ChangeCol(name, matno, prop_name, col);
  523. goto IL_14B9;
  524. }
  525. if (stringCom == "mancolor")
  526. {
  527. Color manColor = new Color(float.Parse(stringList[1]) / 255f, float.Parse(stringList[2]) / 255f, float.Parse(stringList[3]) / 255f, 1f);
  528. maid.ManColor = manColor;
  529. maid.ManColorUpdate();
  530. goto IL_14B9;
  531. }
  532. if (stringCom == "tex" || stringCom == "テクスチャ変更")
  533. {
  534. string text15 = stringList[1];
  535. int num4 = int.Parse(stringList[2]);
  536. string text16 = stringList[3];
  537. string filename = stringList[4];
  538. MaidParts.PARTS_COLOR parts_COLOR = MaidParts.PARTS_COLOR.NONE;
  539. if (stringList.Length == 6)
  540. {
  541. string text17 = stringList[5];
  542. try
  543. {
  544. parts_COLOR = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text17.ToUpper());
  545. }
  546. catch
  547. {
  548. NDebug.Assert("無限色IDがありません。" + text17, false);
  549. }
  550. }
  551. if (mp.idx == 61)
  552. {
  553. num4 = 7;
  554. }
  555. if (flag2 && parts_COLOR == MaidParts.PARTS_COLOR.SKIN)
  556. {
  557. if (text15 == "body" && num4 == 0 && text16.ToLower() == "_maintex")
  558. {
  559. body.ChangeShader(text15, num4, "CM3D2_Toony_Lighted_Outline_Tex");
  560. flag = true;
  561. body.ChangeTex(text15, num4, "_OutlineTex", filename, null, MaidParts.PARTS_COLOR.SKIN_OUTLINE);
  562. body.ChangeTex(text15, num4, "_OutlineToonRamp", "toonBlackA1.tex", null, MaidParts.PARTS_COLOR.SKIN_OUTLINE);
  563. }
  564. else if (text15 == "head" && num4 == 5 && text16.ToLower() == "_maintex")
  565. {
  566. body.ChangeShader(text15, num4, "CM3D2_Toony_Lighted_Outline_Tex");
  567. flag = true;
  568. body.ChangeTex(text15, num4, "_OutlineTex", filename, null, MaidParts.PARTS_COLOR.SKIN_OUTLINE);
  569. body.ChangeTex(text15, num4, "_OutlineToonRamp", "toonBlackA1.tex", null, MaidParts.PARTS_COLOR.SKIN_OUTLINE);
  570. }
  571. }
  572. body.ChangeTex(text15, num4, text16, filename, null, parts_COLOR);
  573. if (parts_COLOR != MaidParts.PARTS_COLOR.NONE)
  574. {
  575. maid.Parts.SetPartsColor(parts_COLOR, maid.Parts.GetPartsColor(parts_COLOR));
  576. }
  577. if ((flag2 || flag3) && !flag)
  578. {
  579. body.RestoreShader(text15);
  580. goto IL_CBC;
  581. }
  582. goto IL_CBC;
  583. IL_CBC:
  584. goto IL_14B9;
  585. }
  586. if (stringCom == "prop")
  587. {
  588. string tag2 = stringList[1];
  589. string s = stringList[2];
  590. maid.SetProp(tag2, int.Parse(s), false);
  591. goto IL_14B9;
  592. }
  593. if (stringCom == "テクスチャ乗算")
  594. {
  595. goto IL_14B9;
  596. }
  597. if (stringCom == "テクスチャ合成")
  598. {
  599. if (stringList.Length != 7)
  600. {
  601. NDebug.Assert("テクスチャ合成 の引数が不正です。" + stringList.Length, false);
  602. }
  603. if ((text9 == "accTatoo" || text9 == "hokuro") && !text.Contains("_del"))
  604. {
  605. body.MulTexSet(stringList[1], int.Parse(stringList[2]), stringList[3], int.Parse(stringList[4]), stringList[5], (GameUty.SystemMaterial)Enum.Parse(typeof(GameUty.SystemMaterial), stringList[6]), true, 0, 0, 0f, 0f, true, f_SubProp, 1f, 1024);
  606. goto IL_E1F;
  607. }
  608. body.MulTexSet(stringList[1], int.Parse(stringList[2]), stringList[3], int.Parse(stringList[4]), stringList[5], (GameUty.SystemMaterial)Enum.Parse(typeof(GameUty.SystemMaterial), stringList[6]), false, 0, 0, 0f, 0f, false, null, 1f, 1024);
  609. goto IL_E1F;
  610. IL_E1F:
  611. goto IL_14B9;
  612. }
  613. if (stringCom == "テクスチャセット合成")
  614. {
  615. if (stringList.Length != 7)
  616. {
  617. NDebug.Assert("テクスチャセット合成 の引数が不正です。" + stringList.Length, false);
  618. }
  619. body.MulTexSet(stringList[1], int.Parse(stringList[2]), stringList[3], int.Parse(stringList[4]), stringList[5], (GameUty.SystemMaterial)Enum.Parse(typeof(GameUty.SystemMaterial), stringList[6]), true, 0, 0, 0f, 0f, true, null, 1f, 1024);
  620. goto IL_14B9;
  621. }
  622. if (stringCom == "マテリアル変更")
  623. {
  624. string f_strSlotName = stringList[1];
  625. int f_nMatNo = int.Parse(stringList[2]);
  626. string f_strFileName = stringList[3];
  627. body.ChangeMaterial(f_strSlotName, f_nMatNo, f_strFileName);
  628. goto IL_14B9;
  629. }
  630. if (stringCom == "shader")
  631. {
  632. string f_strSlotName2 = stringList[1];
  633. int f_nMatNo2 = int.Parse(stringList[2]);
  634. string f_strShaderFileName = stringList[3];
  635. body.ChangeShader(f_strSlotName2, f_nMatNo2, f_strShaderFileName);
  636. flag = true;
  637. goto IL_14B9;
  638. }
  639. if (stringCom == "アタッチポイントの設定")
  640. {
  641. if (stringList.Length < 5)
  642. {
  643. Debug.LogError("アタッチポイントの設定引数の数が不正です。 " + text7 + " " + text3);
  644. goto IL_FE2;
  645. }
  646. Vector3 v = new Vector3(float.Parse(stringList[2]), float.Parse(stringList[3]), float.Parse(stringList[4]));
  647. Quaternion q = Quaternion.identity;
  648. if (stringList.Length == 8)
  649. {
  650. q = Quaternion.Euler(float.Parse(stringList[5]), float.Parse(stringList[6]), float.Parse(stringList[7]));
  651. }
  652. else
  653. {
  654. Debug.LogError("アタッチポイントの設定引数に角度指定がありません。 " + text7 + " " + text3);
  655. }
  656. body.SetAttachPoint(slotname, stringList[1], v, q, f_bTemp);
  657. goto IL_FE2;
  658. IL_FE2:
  659. goto IL_14B9;
  660. }
  661. if (stringCom == "blendset")
  662. {
  663. string blendSetName = stringList[1];
  664. int num5 = (stringList.Length - 2) / 2;
  665. body.Face.morph.NewBlendSet(blendSetName);
  666. for (int j = 0; j < num5; j++)
  667. {
  668. string tag3 = stringList[2 + j * 2].ToLower();
  669. float val2 = float.Parse(stringList[3 + j * 2]);
  670. body.Face.morph.SetValueBlendSet(blendSetName, tag3, val2);
  671. }
  672. goto IL_14B9;
  673. }
  674. if (stringCom == "paramset")
  675. {
  676. body.Face.NewParamSet(text7);
  677. goto IL_14B9;
  678. }
  679. if (stringCom == "commenttype")
  680. {
  681. if (!maid.status.partsDic.ContainsKey(stringList[1]))
  682. {
  683. maid.status.partsDic.Add(stringList[1], string.Empty);
  684. }
  685. maid.status.partsDic[stringList[1]] = stringList[2];
  686. goto IL_14B9;
  687. }
  688. if (stringCom == "useredit")
  689. {
  690. if (stringList[2].ToLower() == "material")
  691. {
  692. body.SetMaterialProperty(text9, stringList[3], int.Parse(stringList[4]), stringList[5], stringList[6], stringList[7], false);
  693. goto IL_113A;
  694. }
  695. goto IL_113A;
  696. IL_113A:
  697. goto IL_14B9;
  698. }
  699. if (stringCom == "bonemorph")
  700. {
  701. if (9 > stringList.Length || stringList.Length > 10)
  702. {
  703. Debug.LogError("BoneMorpの設定引数の数が不正です。 " + text7 + " " + text3);
  704. }
  705. if (stringList.Length == 9)
  706. {
  707. body.bonemorph.ChangeMorphPosValue(stringList[1], stringList[2], new Vector3(float.Parse(stringList[3]), float.Parse(stringList[4]), float.Parse(stringList[5])), new Vector3(float.Parse(stringList[6]), float.Parse(stringList[7]), float.Parse(stringList[8])));
  708. goto IL_1300;
  709. }
  710. string text18 = stringList[1].ToLower();
  711. string strPropName = stringList[2];
  712. string f_strBoneName = stringList[3];
  713. Vector3 f_fAddMin = new Vector3(float.Parse(stringList[4]), float.Parse(stringList[5]), float.Parse(stringList[6]));
  714. Vector3 f_fAddMax = new Vector3(float.Parse(stringList[7]), float.Parse(stringList[8]), float.Parse(stringList[9]));
  715. if (text18 != null)
  716. {
  717. if (text18 == "pos")
  718. {
  719. body.bonemorph.ChangeMorphPosValue(strPropName, f_strBoneName, f_fAddMin, f_fAddMax);
  720. goto IL_1300;
  721. }
  722. if (text18 == "rot")
  723. {
  724. body.bonemorph.ChangeMorphRotatioValue(strPropName, f_strBoneName, f_fAddMin, f_fAddMax);
  725. goto IL_1300;
  726. }
  727. if (text18 == "scl")
  728. {
  729. body.bonemorph.ChangeMorphSclValue(strPropName, f_strBoneName, f_fAddMin, f_fAddMax);
  730. goto IL_1300;
  731. }
  732. }
  733. Debug.LogError(string.Concat(new string[]
  734. {
  735. "BoneMorpのタイプ指定が不正です[",
  736. text18,
  737. "]\n",
  738. text7,
  739. " ",
  740. text3
  741. }));
  742. goto IL_1300;
  743. IL_1300:
  744. goto IL_14B9;
  745. }
  746. if (stringCom == "length")
  747. {
  748. if (stringList.Length != 11)
  749. {
  750. Debug.LogError("lengthの設定引数の数が不正です。 " + text7 + " " + text3);
  751. }
  752. body.SetHairLengthDataList(stringList[1], stringList[2], stringList[3], stringList[4], new Vector3(float.Parse(stringList[5]), float.Parse(stringList[6]), float.Parse(stringList[7])), new Vector3(float.Parse(stringList[8]), float.Parse(stringList[9]), float.Parse(stringList[10])));
  753. goto IL_14B9;
  754. }
  755. if (stringCom == "anime")
  756. {
  757. if (stringList.Length < 3)
  758. {
  759. Debug.LogError("animeの設定引数の数が不正です。 " + text7 + " " + text3);
  760. }
  761. TBody.SlotID f_slot = (TBody.SlotID)Enum.Parse(typeof(TBody.SlotID), stringList[1], true);
  762. body.ItemAnimationLoad(f_slot, stringList[2]);
  763. bool f_bLoop = false;
  764. if (3 < stringList.Length)
  765. {
  766. f_bLoop = (stringList[3] == "loop");
  767. }
  768. body.ItemAnimationPlay(f_slot, stringList[2], f_bLoop);
  769. goto IL_14B9;
  770. }
  771. if (stringCom == "param2")
  772. {
  773. if (stringList.Length == 4)
  774. {
  775. string slotname4 = stringList[1];
  776. body.GetSlot(slotname4).SetParam2(stringList[2], stringList[3]);
  777. goto IL_1473;
  778. }
  779. Debug.LogError("param2の設定引数の数が不正です。 " + text7 + " " + text3);
  780. goto IL_1473;
  781. IL_1473:
  782. goto IL_14B9;
  783. }
  784. if (stringCom == "animematerial")
  785. {
  786. TBody.SlotID f_slot2 = (TBody.SlotID)Enum.Parse(typeof(TBody.SlotID), stringList[1], true);
  787. string s2 = stringList[2];
  788. body.MaterialAnimatorAdd(f_slot2, int.Parse(s2));
  789. goto IL_14B9;
  790. }
  791. goto IL_14B9;
  792. IL_14B9:
  793. goto IL_153C;
  794. }
  795. catch (Exception ex)
  796. {
  797. Debug.LogError(string.Concat(new string[]
  798. {
  799. "Exception ",
  800. Path.GetFileName(text),
  801. " 現在処理中だった行 = ",
  802. text7,
  803. " 以前の行 = ",
  804. text8,
  805. " ",
  806. ex.Message,
  807. "StackTrace:\n",
  808. ex.StackTrace
  809. }));
  810. NDebug.Assert("メニューファイル処理中にエラーが発生しました。" + Path.GetFileName(text), true);
  811. goto IL_153C;
  812. }
  813. IL_153C:
  814. goto IL_108;
  815. }
  816. list.Sort((Menu.LastParam a, Menu.LastParam b) => a.nOrder - a.nOrder);
  817. for (int k = 0; k < list.Count; k++)
  818. {
  819. Menu.LastParam lastParam = list[k];
  820. if (lastParam.strComm == "アイテムパラメータ")
  821. {
  822. TBodySkin slot6 = body.GetSlot(lastParam.aryArgs[0]);
  823. slot6.SetParam(lastParam.aryArgs[1], lastParam.aryArgs[2]);
  824. }
  825. }
  826. binaryReader.Close();
  827. binaryReader = null;
  828. }
  829. public static void SetMaidItemTemp(Maid maid, string filename, bool f_bTemp = false)
  830. {
  831. byte[] buffer = null;
  832. try
  833. {
  834. using (AFileBase afileBase = GameUty.FileOpen(filename, null))
  835. {
  836. if (!afileBase.IsValid())
  837. {
  838. NDebug.Assert("メニューファイルが見つかりません。" + filename, false);
  839. }
  840. buffer = afileBase.ReadAll();
  841. }
  842. }
  843. catch (Exception ex)
  844. {
  845. Debug.LogError("ProcScriptBin/SetMaidItemTemp アイテムメニューファイルが読み込めませんでした。 : " + filename + " : " + ex.Message);
  846. }
  847. BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer), Encoding.UTF8);
  848. string text = binaryReader.ReadString();
  849. NDebug.Assert(text == "CM3D2_MENU", "ProcScriptBin/SetMaidItemTemp 例外 : " + filename + " のヘッダーが不正です。" + text);
  850. int num = binaryReader.ReadInt32();
  851. string text2 = binaryReader.ReadString();
  852. string text3 = binaryReader.ReadString();
  853. string text4 = binaryReader.ReadString();
  854. if (text4 == "acctatoo")
  855. {
  856. maid.DelProp(MPN.acctatoo, false);
  857. maid.SetSubProp(MPN.acctatoo, 0, filename, 0);
  858. }
  859. else if (text4 == "hokuro")
  860. {
  861. maid.DelProp(MPN.hokuro, false);
  862. maid.SetSubProp(MPN.hokuro, 0, filename, 0);
  863. }
  864. else
  865. {
  866. maid.SetProp(text4, filename, 0, f_bTemp, false);
  867. }
  868. }
  869. public static bool ExportModScript(Maid maid, string filename, bool f_bTemp = false)
  870. {
  871. byte[] cd = null;
  872. try
  873. {
  874. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(filename))
  875. {
  876. if (!afileBase.IsValid())
  877. {
  878. Debug.LogWarning("アイテムメニューファイルが見つかりません。" + filename);
  879. return false;
  880. }
  881. cd = afileBase.ReadAll();
  882. }
  883. }
  884. catch (Exception ex)
  885. {
  886. Debug.LogError("ExportModScript アイテムメニューファイルが読み込めませんでした。 : " + filename + " : " + ex.Message);
  887. }
  888. string fullPath = Path.GetFullPath(".\\");
  889. string text = fullPath + "ModExport";
  890. if (!Directory.Exists(text))
  891. {
  892. Directory.CreateDirectory(text);
  893. }
  894. string text2 = "mod_" + Path.GetFileNameWithoutExtension(filename);
  895. text2 = text2.Trim();
  896. text = text + "\\" + text2;
  897. if (!Directory.Exists(text))
  898. {
  899. Directory.CreateDirectory(text);
  900. }
  901. StreamWriter streamWriter = new StreamWriter(text + "\\" + text2 + ".txt", false, Encoding.UTF8);
  902. streamWriter.WriteLine("出力バージョン\t" + 1260);
  903. streamWriter.WriteLine("基本アイテム\t" + filename.Replace(" ", ":"));
  904. try
  905. {
  906. Menu.ExportModScript(maid, cd, streamWriter, text + "\\" + text2, f_bTemp);
  907. NUty.WinMessageBox(NUty.GetWindowHandle(), string.Concat(new string[]
  908. {
  909. "MODテンプレート出力完了\n",
  910. text,
  911. "\\",
  912. text2,
  913. ".txt"
  914. }), "MOD Compile Completed", 0);
  915. }
  916. catch (Exception ex2)
  917. {
  918. Debug.LogError("ExportModScript 例外 : " + filename + " : " + ex2.Message);
  919. }
  920. finally
  921. {
  922. streamWriter.Close();
  923. streamWriter.Dispose();
  924. streamWriter = null;
  925. }
  926. return true;
  927. }
  928. public static void ExportModScript(Maid maid, byte[] cd, StreamWriter sw, string filename, bool f_bTemp = false)
  929. {
  930. TBody body = maid.body0;
  931. List<Menu.LastParam> list = new List<Menu.LastParam>();
  932. BinaryReader binaryReader = new BinaryReader(new MemoryStream(cd), Encoding.UTF8);
  933. string text = binaryReader.ReadString();
  934. NDebug.Assert(text == "CM3D2_MENU", "ExportModScript 例外 : ヘッダーファイルが不正です。" + text);
  935. int num = binaryReader.ReadInt32();
  936. string path = binaryReader.ReadString();
  937. string str = binaryReader.ReadString();
  938. sw.WriteLine("アイテム名\t" + str);
  939. string str2 = binaryReader.ReadString();
  940. sw.WriteLine("カテゴリ名\t" + str2);
  941. string text2 = binaryReader.ReadString();
  942. sw.WriteLine("説明\t" + text2.Replace("\n", "《改行》"));
  943. sw.WriteLine("アイコン\t" + Path.GetFileName(filename + ".png"));
  944. long num2 = (long)binaryReader.ReadInt32();
  945. bool flag = false;
  946. List<string> list2 = new List<string>();
  947. string text3 = string.Empty;
  948. string text4 = string.Empty;
  949. string empty = string.Empty;
  950. string empty2 = string.Empty;
  951. try
  952. {
  953. for (;;)
  954. {
  955. int num3 = (int)binaryReader.ReadByte();
  956. text4 = text3;
  957. text3 = string.Empty;
  958. if (num3 == 0)
  959. {
  960. break;
  961. }
  962. for (int i = 0; i < num3; i++)
  963. {
  964. text3 = text3 + "\"" + binaryReader.ReadString() + "\" ";
  965. }
  966. if (!(text3 == string.Empty))
  967. {
  968. string stringCom = UTY.GetStringCom(text3);
  969. string[] stringList = UTY.GetStringList(text3);
  970. if (stringCom == "end")
  971. {
  972. break;
  973. }
  974. if (!(stringCom == "name"))
  975. {
  976. if (stringCom == "icon" || stringCom == "icons")
  977. {
  978. string f_strFileName = stringList[1];
  979. Texture2D texture2D = ImportCM.CreateTexture(f_strFileName);
  980. if (texture2D != null)
  981. {
  982. UTY.SaveImage(texture2D, filename + ".png");
  983. }
  984. }
  985. else if (stringCom == "additem")
  986. {
  987. sw.WriteLine("アイテム変更");
  988. string text5 = empty;
  989. if (stringList.Length > 1)
  990. {
  991. text5 = stringList[2];
  992. }
  993. list2.Add(text5);
  994. sw.WriteLine("\tスロット名\t" + text5);
  995. TBodySkin slot = maid.body0.GetSlot(text5);
  996. foreach (Transform transform in slot.obj.GetComponentsInChildren<Transform>(true))
  997. {
  998. Renderer component = transform.GetComponent<Renderer>();
  999. if (!(component == null) && component.materials != null)
  1000. {
  1001. Material[] materials = component.materials;
  1002. for (int k = 0; k < materials.Length; k++)
  1003. {
  1004. Material f_mat = materials[k];
  1005. sw.WriteLine("\t\tマテリアル番号\t" + k);
  1006. Menu.ModMaterial(f_mat, sw);
  1007. }
  1008. }
  1009. }
  1010. }
  1011. else if (!(stringCom == "color"))
  1012. {
  1013. if (stringCom == "tex" || stringCom == "テクスチャ変更")
  1014. {
  1015. string text6 = stringList[1];
  1016. int num4 = int.Parse(stringList[2]);
  1017. string str3 = stringList[3];
  1018. string text7 = stringList[4];
  1019. string text8 = (6 > stringList.Length) ? null : stringList[5];
  1020. if (!list2.Contains(text6))
  1021. {
  1022. string text9 = "テクスチャ変更";
  1023. text9 = text9 + "\t" + text6;
  1024. text9 = text9 + "\t" + num4;
  1025. text9 = text9 + "\t" + str3;
  1026. text9 = text9 + "\t" + text7;
  1027. if (!string.IsNullOrEmpty(text8))
  1028. {
  1029. text9 = text9 + "\t" + text8;
  1030. }
  1031. if (text7.Contains("*"))
  1032. {
  1033. string text10 = string.Empty;
  1034. TBodySkin slot2 = maid.body0.GetSlot(text6);
  1035. if (slot2 != null)
  1036. {
  1037. text10 += "参考)出力時のモデル名は ";
  1038. text10 += Path.GetFileNameWithoutExtension(slot2.m_strModelFileName);
  1039. text10 += " です。";
  1040. }
  1041. sw.WriteLine("// * の部分は現在装着されているモデル名に置換されます。" + text10);
  1042. }
  1043. if (!string.IsNullOrEmpty(text8) && !flag)
  1044. {
  1045. string text11 = "// 無限色ID群 ";
  1046. IEnumerator enumerator = Enum.GetValues(typeof(MaidParts.PARTS_COLOR)).GetEnumerator();
  1047. try
  1048. {
  1049. while (enumerator.MoveNext())
  1050. {
  1051. object obj = enumerator.Current;
  1052. text11 = text11 + ((MaidParts.PARTS_COLOR)obj).ToString() + " ";
  1053. }
  1054. }
  1055. finally
  1056. {
  1057. IDisposable disposable;
  1058. if ((disposable = (enumerator as IDisposable)) != null)
  1059. {
  1060. disposable.Dispose();
  1061. }
  1062. }
  1063. sw.WriteLine(text11);
  1064. flag = true;
  1065. }
  1066. sw.WriteLine(text9);
  1067. }
  1068. }
  1069. else if (stringCom == "テクスチャ合成")
  1070. {
  1071. string item = stringList[1];
  1072. int num5 = int.Parse(stringList[2]);
  1073. string text12 = stringList[3];
  1074. string text13 = stringList[4];
  1075. if (!list2.Contains(item))
  1076. {
  1077. }
  1078. }
  1079. else if (stringCom == "マテリアル変更")
  1080. {
  1081. string text14 = stringList[1];
  1082. int num6 = int.Parse(stringList[2]);
  1083. string text15 = stringList[3];
  1084. if (!list2.Contains(text14))
  1085. {
  1086. sw.WriteLine("マテリアル変更");
  1087. sw.WriteLine("\tスロット名\t" + text14);
  1088. TBodySkin slot3 = maid.body0.GetSlot(text14);
  1089. foreach (Transform transform2 in slot3.obj.GetComponentsInChildren<Transform>(true))
  1090. {
  1091. Renderer component2 = transform2.GetComponent<Renderer>();
  1092. if (!(component2 == null) && component2.materials != null)
  1093. {
  1094. Material[] materials2 = component2.materials;
  1095. for (int m = 0; m < materials2.Length; m++)
  1096. {
  1097. Material f_mat2 = materials2[m];
  1098. sw.WriteLine("\t\tマテリアル番号\t" + m);
  1099. Menu.ModMaterial(f_mat2, sw);
  1100. }
  1101. }
  1102. }
  1103. }
  1104. }
  1105. else if (stringCom == "color_set")
  1106. {
  1107. if (stringList.Length >= 3)
  1108. {
  1109. string text16 = stringList[2];
  1110. text16 = "mod_" + Path.GetFileNameWithoutExtension(text16) + ".mod";
  1111. sw.WriteLine("色セット\t" + stringList[1] + "\t" + text16);
  1112. }
  1113. else
  1114. {
  1115. sw.WriteLine("色セット\t" + stringList[1]);
  1116. }
  1117. MPN f_mpn = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower());
  1118. maid.ExportModBaseMenu(f_mpn);
  1119. }
  1120. }
  1121. }
  1122. }
  1123. }
  1124. }
  1125. catch (Exception ex)
  1126. {
  1127. Debug.LogError(string.Concat(new string[]
  1128. {
  1129. "Exception ",
  1130. Path.GetFileName(path),
  1131. " 現在処理中だった行 = ",
  1132. text3,
  1133. " 以前の行 = ",
  1134. text4,
  1135. " ",
  1136. ex.Message,
  1137. "StackTrace:\n",
  1138. ex.StackTrace
  1139. }));
  1140. NDebug.Assert("メニューファイル処理中にエラーが発生しました。" + Path.GetFileName(path), false);
  1141. if (binaryReader != null)
  1142. {
  1143. binaryReader.Close();
  1144. binaryReader = null;
  1145. }
  1146. throw ex;
  1147. }
  1148. if (binaryReader != null)
  1149. {
  1150. binaryReader.Close();
  1151. binaryReader = null;
  1152. }
  1153. }
  1154. public static string[] NeedTextureWildCard(string f_strTexName)
  1155. {
  1156. string[] array;
  1157. if (f_strTexName.Contains("*"))
  1158. {
  1159. string strTexName = f_strTexName;
  1160. strTexName = strTexName.Replace("*", ".*");
  1161. if (Menu.m_strAllTexInFileSys == null)
  1162. {
  1163. Menu.m_strAllTexInFileSys = GameUty.FileSystem.GetList(string.Empty, AFileSystemBase.ListType.AllFile);
  1164. }
  1165. array = Array.FindAll<string>(Menu.m_strAllTexInFileSys, (string i) => new Regex(strTexName).IsMatch(i));
  1166. array = Array.FindAll<string>(array, (string i) => new Regex("^((?!_i_).)*$").IsMatch(i));
  1167. IEnumerable<string> source = array;
  1168. if (Menu.<>f__mg$cache0 == null)
  1169. {
  1170. Menu.<>f__mg$cache0 = new Func<string, string>(Path.GetFileName);
  1171. }
  1172. array = source.Select(Menu.<>f__mg$cache0).ToArray<string>();
  1173. string strMatchGroup = strTexName.Replace(".*", "(?<WILD>.*)");
  1174. array = array.Select(delegate(string i)
  1175. {
  1176. Match match = new Regex(strMatchGroup).Match(i);
  1177. if (match.Success)
  1178. {
  1179. return match.Groups["WILD"].Value;
  1180. }
  1181. return i;
  1182. }).ToArray<string>();
  1183. }
  1184. else
  1185. {
  1186. array = new string[]
  1187. {
  1188. Path.GetFileName(f_strTexName)
  1189. };
  1190. }
  1191. return array;
  1192. }
  1193. private static void ModMaterial(Material f_mat, StreamWriter f_sw)
  1194. {
  1195. for (int i = 0; i < Menu.material_properties.GetLength(0); i++)
  1196. {
  1197. if (f_mat.HasProperty(Menu.material_properties[i, 0]))
  1198. {
  1199. if (Menu.material_properties[i, 1] == "tex")
  1200. {
  1201. Texture texture = f_mat.GetTexture(Menu.material_properties[i, 0]);
  1202. f_sw.WriteLine("\t\t\tテクスチャ設定\t" + Menu.material_properties[i, 0] + "\t" + texture.name);
  1203. }
  1204. else if (Menu.material_properties[i, 1] == "col")
  1205. {
  1206. Color color = f_mat.GetColor(Menu.material_properties[i, 0]);
  1207. f_sw.WriteLine(string.Concat(new object[]
  1208. {
  1209. "\t\t\t色設定\t",
  1210. Menu.material_properties[i, 0],
  1211. "\t",
  1212. (int)(255f * color.r),
  1213. "\t",
  1214. (int)(255f * color.g),
  1215. "\t",
  1216. (int)(255f * color.b),
  1217. "\t",
  1218. (int)(255f * color.a)
  1219. }));
  1220. }
  1221. else if (Menu.material_properties[i, 1] == "f")
  1222. {
  1223. float @float = f_mat.GetFloat(Menu.material_properties[i, 0]);
  1224. f_sw.WriteLine(string.Concat(new object[]
  1225. {
  1226. "\t\t\t数値設定\t",
  1227. Menu.material_properties[i, 0],
  1228. "\t",
  1229. @float
  1230. }));
  1231. }
  1232. }
  1233. }
  1234. }
  1235. private static string GetBaseItemFromMod(string f_strModMenu)
  1236. {
  1237. string empty = string.Empty;
  1238. FileStream fileStream = new FileStream(f_strModMenu, FileMode.Open);
  1239. if (fileStream == null)
  1240. {
  1241. return string.Empty;
  1242. }
  1243. BinaryReader binaryReader = new BinaryReader(fileStream);
  1244. string a = binaryReader.ReadString();
  1245. NDebug.Assert(a == "CM3D2_MOD", "セーブデータファイルのヘッダーが不正です。_MOD");
  1246. int num = binaryReader.ReadInt32();
  1247. string text = binaryReader.ReadString();
  1248. string text2 = binaryReader.ReadString();
  1249. text2 = text2.Replace(":", " ");
  1250. string text3 = binaryReader.ReadString();
  1251. string text4 = binaryReader.ReadString();
  1252. string text5 = binaryReader.ReadString();
  1253. binaryReader.Close();
  1254. fileStream.Close();
  1255. fileStream.Dispose();
  1256. return text2;
  1257. }
  1258. private static void ProcModScriptBin(Maid maid, byte[] cd, string filename, bool f_bTemp = false)
  1259. {
  1260. Menu.ProcModScriptBin(maid, cd, filename, null, f_bTemp);
  1261. }
  1262. private static void ProcModScriptBin(Maid maid, byte[] cd, string filename, MaidProp mp, bool f_bTemp = false)
  1263. {
  1264. if (mp != null && maid.body0 != null && (mp.idx == 61 || mp.idx == 64 || mp.idx == 65 || mp.idx == 66))
  1265. {
  1266. TBodySkin slot = maid.body0.GetSlot(1);
  1267. if (slot.PartsVersion < 110)
  1268. {
  1269. return;
  1270. }
  1271. }
  1272. BinaryReader binaryReader = new BinaryReader(new MemoryStream(cd), Encoding.UTF8);
  1273. string text = binaryReader.ReadString();
  1274. NDebug.Assert(text == "CM3D2_MOD", "ProcModScriptBin 例外 : ヘッダーファイルが不正です。" + text);
  1275. int num = binaryReader.ReadInt32();
  1276. string text2 = binaryReader.ReadString();
  1277. string text3 = binaryReader.ReadString();
  1278. string text4 = binaryReader.ReadString();
  1279. string text5 = binaryReader.ReadString();
  1280. string text6 = binaryReader.ReadString();
  1281. string text7 = binaryReader.ReadString();
  1282. MPN mpn = MPN.null_mpn;
  1283. try
  1284. {
  1285. mpn = (MPN)Enum.Parse(typeof(MPN), text7);
  1286. }
  1287. catch
  1288. {
  1289. NDebug.Assert("カテゴリがありません。" + text7, false);
  1290. }
  1291. string text8 = string.Empty;
  1292. if (mpn != MPN.null_mpn)
  1293. {
  1294. text8 = binaryReader.ReadString();
  1295. }
  1296. string s = binaryReader.ReadString();
  1297. int num2 = binaryReader.ReadInt32();
  1298. Dictionary<string, byte[]> dictionary = new Dictionary<string, byte[]>();
  1299. for (int i = 0; i < num2; i++)
  1300. {
  1301. string key = binaryReader.ReadString();
  1302. int count = binaryReader.ReadInt32();
  1303. byte[] value = binaryReader.ReadBytes(count);
  1304. dictionary.Add(key, value);
  1305. }
  1306. binaryReader.Close();
  1307. binaryReader = null;
  1308. using (StringReader stringReader = new StringReader(s))
  1309. {
  1310. Menu.IMode mode = Menu.IMode.Non;
  1311. string slotname = string.Empty;
  1312. TBodySkin tbodySkin = null;
  1313. Material material = null;
  1314. int num3 = 0;
  1315. string text9;
  1316. while ((text9 = stringReader.ReadLine()) != null)
  1317. {
  1318. string[] array = text9.Split(new char[]
  1319. {
  1320. '\t',
  1321. ' '
  1322. }, StringSplitOptions.RemoveEmptyEntries);
  1323. if (array[0] == "アイテム変更" || array[0] == "マテリアル変更")
  1324. {
  1325. mode = Menu.IMode.ItemChange;
  1326. }
  1327. else if (array[0] == "テクスチャ変更")
  1328. {
  1329. mode = Menu.IMode.TexChange;
  1330. }
  1331. if (mode == Menu.IMode.ItemChange)
  1332. {
  1333. if (array[0] == "スロット名")
  1334. {
  1335. slotname = array[1];
  1336. tbodySkin = maid.body0.GetSlot(slotname);
  1337. }
  1338. if (tbodySkin != null)
  1339. {
  1340. if (array[0] == "マテリアル番号")
  1341. {
  1342. num3 = int.Parse(array[1]);
  1343. foreach (Transform transform in tbodySkin.obj.GetComponentsInChildren<Transform>(true))
  1344. {
  1345. Renderer component = transform.GetComponent<Renderer>();
  1346. if (!(component == null) && component.materials != null)
  1347. {
  1348. Material[] materials = component.materials;
  1349. for (int k = 0; k < materials.Length; k++)
  1350. {
  1351. if (k == num3)
  1352. {
  1353. material = materials[k];
  1354. break;
  1355. }
  1356. }
  1357. }
  1358. }
  1359. }
  1360. if (material != null)
  1361. {
  1362. if (array[0] == "テクスチャ設定")
  1363. {
  1364. maid.body0.ChangeTex(slotname, num3, array[1], array[2].ToLower(), dictionary, MaidParts.PARTS_COLOR.NONE);
  1365. }
  1366. else if (array[0] == "色設定")
  1367. {
  1368. material.SetColor(array[1], new Color(float.Parse(array[2]) / 255f, float.Parse(array[3]) / 255f, float.Parse(array[4]) / 255f, float.Parse(array[5]) / 255f));
  1369. }
  1370. else if (array[0] == "数値設定")
  1371. {
  1372. material.SetFloat(array[1], float.Parse(array[2]));
  1373. }
  1374. }
  1375. }
  1376. }
  1377. else if (mode == Menu.IMode.TexChange)
  1378. {
  1379. MaidParts.PARTS_COLOR parts_COLOR = MaidParts.PARTS_COLOR.NONE;
  1380. if (array.Length == 6)
  1381. {
  1382. string text10 = array[5];
  1383. try
  1384. {
  1385. parts_COLOR = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper());
  1386. }
  1387. catch
  1388. {
  1389. NDebug.Assert("無限色IDがありません。" + text10, false);
  1390. }
  1391. }
  1392. int matno = int.Parse(array[2]);
  1393. if (mp != null && mp.idx == 61)
  1394. {
  1395. matno = 7;
  1396. }
  1397. maid.body0.ChangeTex(array[1], matno, array[3], array[4].ToLower(), dictionary, parts_COLOR);
  1398. if (parts_COLOR != MaidParts.PARTS_COLOR.NONE)
  1399. {
  1400. maid.Parts.SetPartsColor(parts_COLOR, maid.Parts.GetPartsColor(parts_COLOR));
  1401. }
  1402. }
  1403. }
  1404. }
  1405. }
  1406. // Note: this type is marked as 'beforefieldinit'.
  1407. static Menu()
  1408. {
  1409. string[,] array = new string[31, 2];
  1410. array[0, 0] = "_MainTex";
  1411. array[0, 1] = "tex";
  1412. array[1, 0] = "_BumpMap";
  1413. array[1, 1] = "tex";
  1414. array[2, 0] = "_ToonRamp";
  1415. array[2, 1] = "tex";
  1416. array[3, 0] = "_ShadowTex";
  1417. array[3, 1] = "tex";
  1418. array[4, 0] = "_ShadowRateToon";
  1419. array[4, 1] = "tex";
  1420. array[5, 0] = "_SpecularTex";
  1421. array[5, 1] = "tex";
  1422. array[6, 0] = "_AnisoTex";
  1423. array[6, 1] = "tex";
  1424. array[7, 0] = "_RenderTex";
  1425. array[7, 1] = "tex";
  1426. array[8, 0] = "_HiTex";
  1427. array[8, 1] = "tex";
  1428. array[9, 0] = "_OutlineTex";
  1429. array[9, 1] = "tex";
  1430. array[10, 0] = "_OutlineToonRamp";
  1431. array[10, 1] = "tex";
  1432. array[11, 0] = "_Color";
  1433. array[11, 1] = "col";
  1434. array[12, 0] = "_ShadowColor";
  1435. array[12, 1] = "col";
  1436. array[13, 0] = "_RimColor";
  1437. array[13, 1] = "col";
  1438. array[14, 0] = "_SpecColor";
  1439. array[14, 1] = "col";
  1440. array[15, 0] = "_Emission";
  1441. array[15, 1] = "col";
  1442. array[16, 0] = "_ReflectColor";
  1443. array[16, 1] = "col";
  1444. array[17, 0] = "_OutlineColor";
  1445. array[17, 1] = "col";
  1446. array[18, 0] = "_MyLightColor0";
  1447. array[18, 1] = "col";
  1448. array[19, 0] = "_MyLightColor1";
  1449. array[19, 1] = "col";
  1450. array[20, 0] = "_TintColor";
  1451. array[20, 1] = "col";
  1452. array[21, 0] = "_ShadowColor";
  1453. array[21, 1] = "col";
  1454. array[22, 0] = "_Shininess";
  1455. array[22, 1] = "f";
  1456. array[23, 0] = "_FurLength";
  1457. array[23, 1] = "f";
  1458. array[24, 0] = "_OutlineWidth";
  1459. array[24, 1] = "f";
  1460. array[25, 0] = "_Cutoff";
  1461. array[25, 1] = "f";
  1462. array[26, 0] = "_AnisoOffset";
  1463. array[26, 1] = "f";
  1464. array[27, 0] = "_RimPower";
  1465. array[27, 1] = "f";
  1466. array[28, 0] = "_RimShift";
  1467. array[28, 1] = "f";
  1468. array[29, 0] = "_HiRate";
  1469. array[29, 1] = "f";
  1470. array[30, 0] = "_HiPow";
  1471. array[30, 1] = "f";
  1472. Menu.material_properties = array;
  1473. }
  1474. public static SortedDictionary<int, SortedDictionary<string, string>> m_dicResourceRef = new SortedDictionary<int, SortedDictionary<string, string>>();
  1475. private static string[] m_strAllTexInFileSys = null;
  1476. private static string[,] material_properties;
  1477. [CompilerGenerated]
  1478. private static Func<string, string> <>f__mg$cache0;
  1479. private class LastParam
  1480. {
  1481. public LastParam(int f_nOrder, string f_strComm, params string[] f_argArgs)
  1482. {
  1483. this.nOrder = f_nOrder;
  1484. this.strComm = f_strComm;
  1485. this.aryArgs = new string[f_argArgs.Length];
  1486. f_argArgs.CopyTo(this.aryArgs, 0);
  1487. }
  1488. public int nOrder;
  1489. public string strComm = string.Empty;
  1490. public string[] aryArgs;
  1491. }
  1492. private enum IMode
  1493. {
  1494. Non,
  1495. ItemChange,
  1496. TexChange
  1497. }
  1498. }