using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using UnityEngine; public class Menu : MonoBehaviour { public static string[] GetModFiles() { string fullPath = Path.GetFullPath(".\\"); string path = fullPath + "Mod"; if (!Directory.Exists(path)) { return null; } return Directory.GetFiles(path, "mod_*.mod", SearchOption.AllDirectories); } public static string GetModPathFileName(string f_strMenuFileName) { string[] modFiles = Menu.GetModFiles(); if (modFiles == null) { NDebug.MessageBox("MODエラー", "MODフォルダが無いか、MODフォルダにMODファイルが1つもありません。\n" + f_strMenuFileName); return string.Empty; } string text = Array.Find(modFiles, (string a) => Path.GetFileName(a).ToLower() == f_strMenuFileName.ToLower()); if (string.IsNullOrEmpty(text)) { NDebug.MessageBox("MODエラー", "MODフォルダにMODファイルが見つかりません。\n" + f_strMenuFileName); return string.Empty; } return text; } public static bool ProcScript(Maid maid, string filename, bool f_bTemp = false, SubProp f_SubProp = null) { bool flag = false; string text = string.Empty; byte[] array = null; if (filename.IndexOf("mod_") == 0) { flag = true; text = Menu.GetModPathFileName(filename); if (string.IsNullOrEmpty(text)) { return false; } filename = Menu.GetBaseItemFromMod(text); try { using (FileStream fileStream = new FileStream(text, FileMode.Open)) { if (fileStream == null) { Debug.LogWarning("MODアイテムメニューファイルが見つかりません。" + filename); return false; } array = new byte[fileStream.Length]; fileStream.Read(array, 0, (int)fileStream.Length); } } catch (Exception ex) { Debug.LogError("ProcScript MODアイテムメニューファイルが読み込めませんでした。 : " + filename + " : " + ex.Message); return false; } } byte[] cd = null; try { using (AFileBase afileBase = GameUty.FileOpen(filename, null)) { if (afileBase == null || !afileBase.IsValid()) { Debug.LogError("アイテムメニューファイルが見つかりません。" + filename); return false; } cd = afileBase.ReadAll(); } } catch (Exception ex2) { Debug.LogError("ProcScript アイテムメニューファイルが読み込めませんでした。 : " + filename + " : " + ex2.Message); return false; } Menu.ProcScriptBin(maid, cd, filename, f_bTemp, f_SubProp); if (flag) { Menu.ProcModScriptBin(maid, array, text, false); } return true; } private static void ProcScriptBin(Maid maid, byte[] cd, string filename, bool f_bTemp = false, SubProp f_SubProp = null) { TBody body = maid.body0; List list = new List(); BinaryReader binaryReader = new BinaryReader(new MemoryStream(cd), Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text); int num = binaryReader.ReadInt32(); string str = binaryReader.ReadString(); string text2 = binaryReader.ReadString(); string text3 = binaryReader.ReadString(); string text4 = binaryReader.ReadString(); long num2 = (long)binaryReader.ReadInt32(); bool flag = false; string text5 = string.Empty; string text6 = string.Empty; string text7 = string.Empty; string slotname = string.Empty; for (;;) { try { for (;;) { IL_90: int num3 = (int)binaryReader.ReadByte(); text6 = text5; text5 = string.Empty; if (num3 == 0) { break; } for (int i = 0; i < num3; i++) { text5 = text5 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text5 == string.Empty)) { goto IL_F5; } } break; IL_F5: string stringCom = UTY.GetStringCom(text5); string[] stringList = UTY.GetStringList(text5); if (stringCom == "end") { break; } if (stringCom == "name") { goto IL_1057; } if (stringCom == "アイテム") { Menu.SetMaidItemTemp(maid, stringList[1], f_bTemp); goto IL_1057; } if (stringCom == "アイテム条件") { string slotname2 = stringList[1]; if (stringList[2] == "に何か") { bool flag2 = false; TBodySkin slot = body.GetSlot(slotname2); if (stringList[3] == "有る") { if (slot.obj != null) { flag2 = true; } } else if (stringList[3] == "無い") { if (slot.obj == null) { flag2 = true; } } else { NDebug.Assert("アイテム条件が不正です。「有る」か「無い」かを指定してください。\n" + text5, false); } if (stringList[4] == "なら") { if (flag2) { Menu.SetMaidItemTemp(maid, stringList[5], f_bTemp); goto IL_222; } goto IL_222; IL_222: goto IL_239; } NDebug.Assert("アイテム条件が不正です。「なら」が必要です。\n" + text5, false); goto IL_239; IL_239: goto IL_36D; } if (stringList[2] == "が") { bool flag3 = false; TBodySkin slot2 = body.GetSlot(slotname2); if (slot2.m_strModelFileName == stringList[3]) { flag3 = true; } if (stringList[4] == "なら") { if (flag3) { Menu.SetMaidItemTemp(maid, stringList[5], f_bTemp); goto IL_29E; } goto IL_29E; IL_29E: goto IL_2B5; } NDebug.Assert("アイテム条件が不正です。「なら」が必要です。\n" + text5, false); goto IL_2B5; IL_2B5: goto IL_36D; } if (!(stringList[2] == "のアイテムパラメータの")) { goto IL_36D; } bool flag4 = false; TBodySkin slot3 = body.GetSlot(slotname2); string param = slot3.GetParam(stringList[3].ToLower()); if (stringList[4] == "が") { if (stringList[5].ToLower() == param) { flag4 = true; } } else { NDebug.Assert("アイテム条件が不正です。「が」が必要です。\n" + text5, false); } if (stringList[6] == "なら") { if (flag4) { Menu.SetMaidItemTemp(maid, stringList[7], f_bTemp); goto IL_356; } goto IL_356; IL_356: goto IL_36D; } NDebug.Assert("アイテム条件が不正です。「なら」が必要です。\n" + text5, false); goto IL_36D; IL_36D: goto IL_1057; } if (stringCom == "アイテムパラメータ") { if (stringList.Length == 4) { string text8 = stringList[1]; string text9 = stringList[2].ToLower(); string text10 = stringList[3].ToLower(); list.Add(new Menu.LastParam(0, stringCom, new string[] { text8, text9, text10 })); goto IL_3E2; } Debug.LogError("アイテムパラメータ 命令の引数が不正です。SlotNameを明示的に指定しする必要があります。アイテムパラメータ <スロット名> <変数名> <値> の順です。" + text5); goto IL_3E2; IL_3E2: goto IL_1057; } if (stringCom == "半脱ぎ" || stringCom == "リソース参照") { string key; string value; if (stringCom == "半脱ぎ") { key = "半脱ぎ"; value = stringList[1]; } else { key = stringList[1]; value = stringList[2]; } int hashCode = Path.GetFileName(filename.ToLower()).ToLower().GetHashCode(); SortedDictionary sortedDictionary; if (Menu.m_dicResourceRef.TryGetValue(hashCode, out sortedDictionary)) { string empty = string.Empty; if (sortedDictionary.TryGetValue(key, out empty)) { sortedDictionary[key] = value; goto IL_494; } sortedDictionary.Add(key, value); goto IL_494; IL_494: goto IL_4B9; } sortedDictionary = new SortedDictionary(); sortedDictionary.Add(key, value); Menu.m_dicResourceRef.Add(hashCode, sortedDictionary); goto IL_4B9; IL_4B9: goto IL_1057; } if (stringCom == "set") { goto IL_1057; } if (stringCom == "setname") { goto IL_1057; } if (stringCom == "setslotitem") { string tag = stringList[1]; uint val = uint.Parse(stringList[2]); maid.SetProp(tag, (int)val, false); goto IL_1057; } if (stringCom == "additem") { string text11 = text7; if (stringList.Length > 1) { text11 = stringList[2]; } slotname = text11; if (text11 == "body") { body.LoadBody_R(stringList[1], maid); } string attachSlot = string.Empty; string attachName = string.Empty; if (stringList.Length == 6) { if (stringList[3] == "アタッチ") { attachSlot = stringList[4]; attachName = stringList[5]; } } else if (stringList.Length == 5 && stringList[3] == "ボーンにアタッチ") { attachSlot = "ボーンにアタッチ"; attachName = stringList[4]; } if (text11 == "handitemr") { attachSlot = "ボーンにアタッチ"; attachName = "_IK_handR"; } if (text11 == "handiteml") { attachSlot = "ボーンにアタッチ"; attachName = "_IK_handL"; } body.AddItem((MPN)Enum.Parse(typeof(MPN), text7, true), text11, stringList[1], attachSlot, attachName, f_bTemp); body.SetVisibleNodeSlot(text11, true, "_ALL_"); goto IL_1057; } if (stringCom == "nofloory") { TBody.SlotID index = (TBody.SlotID)Enum.Parse(typeof(TBody.SlotID), stringList[1], true); body.goSlot[(int)index].m_bHitFloorY = false; goto IL_1057; } if (stringCom == "saveitem") { text3 = stringList[1]; goto IL_1057; } if (stringCom == "category") { text7 = stringList[1]; goto IL_1057; } if (stringCom == "maskitem") { if (stringList.Length > 1) { string maskslot = stringList[1]; body.AddMask(text7, maskslot); goto IL_6E7; } goto IL_6E7; IL_6E7: goto IL_1057; } if (stringCom == "delitem") { string slotname3 = text7; if (stringList.Length > 1) { slotname3 = stringList[1]; } body.DelItem((MPN)Enum.Parse(typeof(MPN), text7, true), slotname3); goto IL_1057; } if (stringCom == "node消去") { body.SetVisibleNodeSlot(text7, false, stringList[1]); goto IL_1057; } if (stringCom == "node表示") { body.SetVisibleNodeSlot(text7, true, stringList[1]); goto IL_1057; } if (stringCom == "パーツnode消去") { body.SetVisibleNodeSlotParts(text7, stringList[1], false, stringList[2]); goto IL_1057; } if (stringCom == "パーツnode表示") { body.SetVisibleNodeSlotParts(text7, stringList[1], true, stringList[2]); goto IL_1057; } if (stringCom == "color") { string name = stringList[1]; int matno = int.Parse(stringList[2]); string prop_name = stringList[3]; Color col = new Color(float.Parse(stringList[4]) / 255f, float.Parse(stringList[5]) / 255f, float.Parse(stringList[6]) / 255f, float.Parse(stringList[7]) / 255f); body.ChangeCol(name, matno, prop_name, col); goto IL_1057; } if (stringCom == "mancolor") { Color manColor = new Color(float.Parse(stringList[1]) / 255f, float.Parse(stringList[2]) / 255f, float.Parse(stringList[3]) / 255f, 1f); maid.ManColor = manColor; maid.ManColorUpdate(); goto IL_1057; } if (stringCom == "tex" || stringCom == "テクスチャ変更") { string text12 = stringList[1]; int matno2 = int.Parse(stringList[2]); string prop_name2 = stringList[3]; string filename2 = stringList[4]; MaidParts.PARTS_COLOR parts_COLOR = MaidParts.PARTS_COLOR.NONE; if (stringList.Length == 6) { string text13 = stringList[5]; try { parts_COLOR = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text13.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + text13, false); } } body.ChangeTex(text12, matno2, prop_name2, filename2, null, parts_COLOR); if (parts_COLOR != MaidParts.PARTS_COLOR.NONE) { maid.Parts.SetPartsColor(parts_COLOR, maid.Parts.GetPartsColor(parts_COLOR)); } if ((text7 == "skin" || text7 == "haircolor") && !flag) { body.RestoreShader(text12); goto IL_994; } goto IL_994; IL_994: goto IL_1057; } if (stringCom == "prop") { string tag2 = stringList[1]; string s = stringList[2]; maid.SetProp(tag2, int.Parse(s), false); goto IL_1057; } if (stringCom == "テクスチャ乗算") { goto IL_1057; } if (stringCom == "テクスチャ合成") { if (stringList.Length != 7) { NDebug.Assert("テクスチャ合成 の引数が不正です。" + stringList.Length, false); } if ((text7 == "accTatoo" || text7 == "hokuro") && !filename.Contains("_del")) { 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); goto IL_AF7; } 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); goto IL_AF7; IL_AF7: goto IL_1057; } if (stringCom == "テクスチャセット合成") { if (stringList.Length != 7) { NDebug.Assert("テクスチャセット合成 の引数が不正です。" + stringList.Length, false); } 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); goto IL_1057; } if (stringCom == "マテリアル変更") { string f_strSlotName = stringList[1]; int f_nMatNo = int.Parse(stringList[2]); string f_strFileName = stringList[3]; body.ChangeMaterial(f_strSlotName, f_nMatNo, f_strFileName); goto IL_1057; } if (stringCom == "shader") { string f_strSlotName2 = stringList[1]; int f_nMatNo2 = int.Parse(stringList[2]); string f_strShaderFileName = stringList[3]; body.ChangeShader(f_strSlotName2, f_nMatNo2, f_strShaderFileName); flag = true; goto IL_1057; } if (stringCom == "アタッチポイントの設定") { if (stringList.Length < 5) { Debug.LogError("アタッチポイントの設定引数の数が不正です。 " + text5 + " " + str); goto IL_CBA; } Vector3 v = new Vector3(float.Parse(stringList[2]), float.Parse(stringList[3]), float.Parse(stringList[4])); Quaternion q = Quaternion.identity; if (stringList.Length == 8) { q = Quaternion.Euler(float.Parse(stringList[5]), float.Parse(stringList[6]), float.Parse(stringList[7])); } else { Debug.LogError("アタッチポイントの設定引数に角度指定がありません。 " + text5 + " " + str); } body.SetAttachPoint(slotname, stringList[1], v, q, f_bTemp); goto IL_CBA; IL_CBA: goto IL_1057; } if (stringCom == "blendset") { string blendSetName = stringList[1]; int num4 = (stringList.Length - 2) / 2; body.Face.morph.NewBlendSet(blendSetName); for (int j = 0; j < num4; j++) { string tag3 = stringList[2 + j * 2].ToLower(); float val2 = float.Parse(stringList[3 + j * 2]); body.Face.morph.SetValueBlendSet(blendSetName, tag3, val2); } goto IL_1057; } if (stringCom == "paramset") { body.Face.NewParamSet(text5); goto IL_1057; } if (stringCom == "commenttype") { if (!maid.status.partsDic.ContainsKey(stringList[1])) { maid.status.partsDic.Add(stringList[1], string.Empty); } maid.status.partsDic[stringList[1]] = stringList[2]; goto IL_1057; } if (stringCom == "useredit") { if (stringList[2].ToLower() == "material") { body.SetMaterialProperty(text7, stringList[3], int.Parse(stringList[4]), stringList[5], stringList[6], stringList[7], false); goto IL_E12; } goto IL_E12; IL_E12: goto IL_1057; } if (stringCom == "bonemorph") { if (stringList.Length < 9) { Debug.LogError("BoneMorpの設定引数の数が不正です。 " + text5 + " " + str); } 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]))); goto IL_1057; } if (stringCom == "length") { if (stringList.Length != 11) { Debug.LogError("lengthの設定引数の数が不正です。 " + text5 + " " + str); } 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]))); goto IL_1057; } if (stringCom == "anime") { if (stringList.Length < 3) { Debug.LogError("animeの設定引数の数が不正です。 " + text5 + " " + str); } TBody.SlotID f_slot = (TBody.SlotID)Enum.Parse(typeof(TBody.SlotID), stringList[1], true); body.ItemAnimationLoad(f_slot, stringList[2]); bool f_bLoop = false; if (3 < stringList.Length) { f_bLoop = (stringList[3] == "loop"); } body.ItemAnimationPlay(f_slot, stringList[2], f_bLoop); goto IL_1057; } if (stringCom == "param2") { if (stringList.Length == 4) { string slotname4 = stringList[1]; body.GetSlot(slotname4).SetParam2(stringList[2], stringList[3]); goto IL_1011; } Debug.LogError("param2の設定引数の数が不正です。 " + text5 + " " + str); goto IL_1011; IL_1011: goto IL_1057; } if (stringCom == "animematerial") { TBody.SlotID f_slot2 = (TBody.SlotID)Enum.Parse(typeof(TBody.SlotID), stringList[1], true); string s2 = stringList[2]; body.MaterialAnimatorAdd(f_slot2, int.Parse(s2)); goto IL_1057; } goto IL_1057; IL_1057: goto IL_10DA; } catch (Exception ex) { Debug.LogError(string.Concat(new string[] { "Exception ", Path.GetFileName(filename), " 現在処理中だった行 = ", text5, " 以前の行 = ", text6, " ", ex.Message, "StackTrace:\n", ex.StackTrace })); NDebug.Assert("メニューファイル処理中にエラーが発生しました。" + Path.GetFileName(filename), true); goto IL_10DA; } IL_10DA: goto IL_90; } list.Sort((Menu.LastParam a, Menu.LastParam b) => a.nOrder - a.nOrder); for (int k = 0; k < list.Count; k++) { Menu.LastParam lastParam = list[k]; if (lastParam.strComm == "アイテムパラメータ") { TBodySkin slot4 = body.GetSlot(lastParam.aryArgs[0]); slot4.SetParam(lastParam.aryArgs[1], lastParam.aryArgs[2]); } } binaryReader.Close(); binaryReader = null; } public static void SetMaidItemTemp(Maid maid, string filename, bool f_bTemp = false) { byte[] buffer = null; try { using (AFileBase afileBase = GameUty.FileOpen(filename, null)) { if (!afileBase.IsValid()) { NDebug.Assert("メニューファイルが見つかりません。" + filename, false); } buffer = afileBase.ReadAll(); } } catch (Exception ex) { Debug.LogError("ProcScriptBin/SetMaidItemTemp アイテムメニューファイルが読み込めませんでした。 : " + filename + " : " + ex.Message); } BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer), Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MENU", "ProcScriptBin/SetMaidItemTemp 例外 : " + filename + " のヘッダーが不正です。" + text); int num = binaryReader.ReadInt32(); string text2 = binaryReader.ReadString(); string text3 = binaryReader.ReadString(); string text4 = binaryReader.ReadString(); if (text4 == "acctatoo") { maid.DelProp(MPN.acctatoo, false); maid.SetSubProp(MPN.acctatoo, 0, filename, 0); } else if (text4 == "hokuro") { maid.DelProp(MPN.hokuro, false); maid.SetSubProp(MPN.hokuro, 0, filename, 0); } else { maid.SetProp(text4, filename, 0, f_bTemp, false); } } public static bool ExportModScript(Maid maid, string filename, bool f_bTemp = false) { byte[] cd = null; try { using (AFileBase afileBase = GameUty.FileSystem.FileOpen(filename)) { if (!afileBase.IsValid()) { Debug.LogWarning("アイテムメニューファイルが見つかりません。" + filename); return false; } cd = afileBase.ReadAll(); } } catch (Exception ex) { Debug.LogError("ExportModScript アイテムメニューファイルが読み込めませんでした。 : " + filename + " : " + ex.Message); } string fullPath = Path.GetFullPath(".\\"); string text = fullPath + "ModExport"; if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } string text2 = "mod_" + Path.GetFileNameWithoutExtension(filename); text2 = text2.Trim(); text = text + "\\" + text2; if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } StreamWriter streamWriter = new StreamWriter(text + "\\" + text2 + ".txt", false, Encoding.UTF8); streamWriter.WriteLine("出力バージョン\t" + 1170); streamWriter.WriteLine("基本アイテム\t" + filename.Replace(" ", ":")); try { Menu.ExportModScript(maid, cd, streamWriter, text + "\\" + text2, f_bTemp); NUty.WinMessageBox(NUty.GetWindowHandle(), string.Concat(new string[] { "MODテンプレート出力完了\n", text, "\\", text2, ".txt" }), "MOD Compile Completed", 0); } catch (Exception ex2) { Debug.LogError("ExportModScript 例外 : " + filename + " : " + ex2.Message); } finally { streamWriter.Close(); streamWriter.Dispose(); streamWriter = null; } return true; } public static void ExportModScript(Maid maid, byte[] cd, StreamWriter sw, string filename, bool f_bTemp = false) { TBody body = maid.body0; List list = new List(); BinaryReader binaryReader = new BinaryReader(new MemoryStream(cd), Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MENU", "ExportModScript 例外 : ヘッダーファイルが不正です。" + text); int num = binaryReader.ReadInt32(); string path = binaryReader.ReadString(); string str = binaryReader.ReadString(); sw.WriteLine("アイテム名\t" + str); string str2 = binaryReader.ReadString(); sw.WriteLine("カテゴリ名\t" + str2); string text2 = binaryReader.ReadString(); sw.WriteLine("説明\t" + text2.Replace("\n", "《改行》")); sw.WriteLine("アイコン\t" + Path.GetFileName(filename + ".png")); long num2 = (long)binaryReader.ReadInt32(); bool flag = false; List list2 = new List(); string text3 = string.Empty; string text4 = string.Empty; string empty = string.Empty; string empty2 = string.Empty; try { for (;;) { int num3 = (int)binaryReader.ReadByte(); text4 = text3; text3 = string.Empty; if (num3 == 0) { break; } for (int i = 0; i < num3; i++) { text3 = text3 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text3 == string.Empty)) { string stringCom = UTY.GetStringCom(text3); string[] stringList = UTY.GetStringList(text3); if (stringCom == "end") { break; } if (!(stringCom == "name")) { if (stringCom == "icon" || stringCom == "icons") { string f_strFileName = stringList[1]; Texture2D texture2D = ImportCM.CreateTexture(f_strFileName); if (texture2D != null) { UTY.SaveImage(texture2D, filename + ".png"); } } else if (stringCom == "additem") { sw.WriteLine("アイテム変更"); string text5 = empty; if (stringList.Length > 1) { text5 = stringList[2]; } list2.Add(text5); sw.WriteLine("\tスロット名\t" + text5); TBodySkin slot = maid.body0.GetSlot(text5); foreach (Transform transform in slot.obj.GetComponentsInChildren(true)) { Renderer component = transform.GetComponent(); if (!(component == null) && component.materials != null) { Material[] materials = component.materials; for (int k = 0; k < materials.Length; k++) { Material f_mat = materials[k]; sw.WriteLine("\t\tマテリアル番号\t" + k); Menu.ModMaterial(f_mat, sw); } } } } else if (!(stringCom == "color")) { if (stringCom == "tex" || stringCom == "テクスチャ変更") { string text6 = stringList[1]; int num4 = int.Parse(stringList[2]); string str3 = stringList[3]; string text7 = stringList[4]; string text8 = (6 > stringList.Length) ? null : stringList[5]; if (!list2.Contains(text6)) { string text9 = "テクスチャ変更"; text9 = text9 + "\t" + text6; text9 = text9 + "\t" + num4; text9 = text9 + "\t" + str3; text9 = text9 + "\t" + text7; if (!string.IsNullOrEmpty(text8)) { text9 = text9 + "\t" + text8; } if (text7.Contains("*")) { string text10 = string.Empty; TBodySkin slot2 = maid.body0.GetSlot(text6); if (slot2 != null) { text10 += "参考)出力時のモデル名は "; text10 += Path.GetFileNameWithoutExtension(slot2.m_strModelFileName); text10 += " です。"; } sw.WriteLine("// * の部分は現在装着されているモデル名に置換されます。" + text10); } if (!string.IsNullOrEmpty(text8) && !flag) { string text11 = "// 無限色ID群 "; IEnumerator enumerator = Enum.GetValues(typeof(MaidParts.PARTS_COLOR)).GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; text11 = text11 + ((MaidParts.PARTS_COLOR)obj).ToString() + " "; } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } sw.WriteLine(text11); flag = true; } sw.WriteLine(text9); } } else if (stringCom == "テクスチャ合成") { string item = stringList[1]; int num5 = int.Parse(stringList[2]); string text12 = stringList[3]; string text13 = stringList[4]; if (!list2.Contains(item)) { } } else if (stringCom == "マテリアル変更") { string text14 = stringList[1]; int num6 = int.Parse(stringList[2]); string text15 = stringList[3]; if (!list2.Contains(text14)) { sw.WriteLine("マテリアル変更"); sw.WriteLine("\tスロット名\t" + text14); TBodySkin slot3 = maid.body0.GetSlot(text14); foreach (Transform transform2 in slot3.obj.GetComponentsInChildren(true)) { Renderer component2 = transform2.GetComponent(); if (!(component2 == null) && component2.materials != null) { Material[] materials2 = component2.materials; for (int m = 0; m < materials2.Length; m++) { Material f_mat2 = materials2[m]; sw.WriteLine("\t\tマテリアル番号\t" + m); Menu.ModMaterial(f_mat2, sw); } } } } } else if (stringCom == "color_set") { if (stringList.Length >= 3) { string text16 = stringList[2]; text16 = "mod_" + Path.GetFileNameWithoutExtension(text16) + ".mod"; sw.WriteLine("色セット\t" + stringList[1] + "\t" + text16); } else { sw.WriteLine("色セット\t" + stringList[1]); } MPN f_mpn = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); maid.ExportModBaseMenu(f_mpn); } } } } } } catch (Exception ex) { Debug.LogError(string.Concat(new string[] { "Exception ", Path.GetFileName(path), " 現在処理中だった行 = ", text3, " 以前の行 = ", text4, " ", ex.Message, "StackTrace:\n", ex.StackTrace })); NDebug.Assert("メニューファイル処理中にエラーが発生しました。" + Path.GetFileName(path), false); if (binaryReader != null) { binaryReader.Close(); binaryReader = null; } throw ex; } if (binaryReader != null) { binaryReader.Close(); binaryReader = null; } } public static string[] NeedTextureWildCard(string f_strTexName) { string[] array; if (f_strTexName.Contains("*")) { string strTexName = f_strTexName; strTexName = strTexName.Replace("*", ".*"); if (Menu.m_strAllTexInFileSys == null) { Menu.m_strAllTexInFileSys = GameUty.FileSystem.GetList(string.Empty, AFileSystemBase.ListType.AllFile); } array = Array.FindAll(Menu.m_strAllTexInFileSys, (string i) => new Regex(strTexName).IsMatch(i)); array = Array.FindAll(array, (string i) => new Regex("^((?!_i_).)*$").IsMatch(i)); IEnumerable source = array; if (Menu.<>f__mg$cache0 == null) { Menu.<>f__mg$cache0 = new Func(Path.GetFileName); } array = source.Select(Menu.<>f__mg$cache0).ToArray(); string strMatchGroup = strTexName.Replace(".*", "(?.*)"); array = array.Select(delegate(string i) { Match match = new Regex(strMatchGroup).Match(i); if (match.Success) { return match.Groups["WILD"].Value; } return i; }).ToArray(); } else { array = new string[] { Path.GetFileName(f_strTexName) }; } return array; } private static void ModMaterial(Material f_mat, StreamWriter f_sw) { for (int i = 0; i < Menu.material_properties.GetLength(0); i++) { if (f_mat.HasProperty(Menu.material_properties[i, 0])) { if (Menu.material_properties[i, 1] == "tex") { Texture texture = f_mat.GetTexture(Menu.material_properties[i, 0]); f_sw.WriteLine("\t\t\tテクスチャ設定\t" + Menu.material_properties[i, 0] + "\t" + texture.name); } else if (Menu.material_properties[i, 1] == "col") { Color color = f_mat.GetColor(Menu.material_properties[i, 0]); f_sw.WriteLine(string.Concat(new object[] { "\t\t\t色設定\t", Menu.material_properties[i, 0], "\t", (int)(255f * color.r), "\t", (int)(255f * color.g), "\t", (int)(255f * color.b), "\t", (int)(255f * color.a) })); } else if (Menu.material_properties[i, 1] == "f") { float @float = f_mat.GetFloat(Menu.material_properties[i, 0]); f_sw.WriteLine(string.Concat(new object[] { "\t\t\t数値設定\t", Menu.material_properties[i, 0], "\t", @float })); } } } } private static string GetBaseItemFromMod(string f_strModMenu) { string empty = string.Empty; FileStream fileStream = new FileStream(f_strModMenu, FileMode.Open); if (fileStream == null) { return string.Empty; } BinaryReader binaryReader = new BinaryReader(fileStream); string a = binaryReader.ReadString(); NDebug.Assert(a == "CM3D2_MOD", "セーブデータファイルのヘッダーが不正です。_MOD"); int num = binaryReader.ReadInt32(); string text = binaryReader.ReadString(); string text2 = binaryReader.ReadString(); text2 = text2.Replace(":", " "); string text3 = binaryReader.ReadString(); string text4 = binaryReader.ReadString(); string text5 = binaryReader.ReadString(); binaryReader.Close(); fileStream.Close(); fileStream.Dispose(); return text2; } private static void ProcModScriptBin(Maid maid, byte[] cd, string filename, bool f_bTemp = false) { BinaryReader binaryReader = new BinaryReader(new MemoryStream(cd), Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MOD", "ProcModScriptBin 例外 : ヘッダーファイルが不正です。" + text); int num = binaryReader.ReadInt32(); string text2 = binaryReader.ReadString(); string text3 = binaryReader.ReadString(); string text4 = binaryReader.ReadString(); string text5 = binaryReader.ReadString(); string text6 = binaryReader.ReadString(); string text7 = binaryReader.ReadString(); MPN mpn = MPN.null_mpn; try { mpn = (MPN)Enum.Parse(typeof(MPN), text7); } catch { NDebug.Assert("カテゴリがありません。" + text7, false); } string text8 = string.Empty; if (mpn != MPN.null_mpn) { text8 = binaryReader.ReadString(); } string s = binaryReader.ReadString(); int num2 = binaryReader.ReadInt32(); Dictionary dictionary = new Dictionary(); for (int i = 0; i < num2; i++) { string key = binaryReader.ReadString(); int count = binaryReader.ReadInt32(); byte[] value = binaryReader.ReadBytes(count); dictionary.Add(key, value); } binaryReader.Close(); binaryReader = null; using (StringReader stringReader = new StringReader(s)) { Menu.IMode mode = Menu.IMode.Non; string slotname = string.Empty; int num3 = 0; TBodySkin tbodySkin = null; Material material = null; string text9; while ((text9 = stringReader.ReadLine()) != null) { string[] array = text9.Split(new char[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array[0] == "アイテム変更" || array[0] == "マテリアル変更") { mode = Menu.IMode.ItemChange; } else if (array[0] == "テクスチャ変更") { mode = Menu.IMode.TexChange; } if (mode == Menu.IMode.ItemChange) { if (array[0] == "スロット名") { slotname = array[1]; tbodySkin = maid.body0.GetSlot(slotname); } if (tbodySkin != null) { if (array[0] == "マテリアル番号") { num3 = int.Parse(array[1]); foreach (Transform transform in tbodySkin.obj.GetComponentsInChildren(true)) { Renderer component = transform.GetComponent(); if (!(component == null) && component.materials != null) { Material[] materials = component.materials; for (int k = 0; k < materials.Length; k++) { if (k == num3) { material = materials[k]; break; } } } } } if (material != null) { if (array[0] == "テクスチャ設定") { maid.body0.ChangeTex(slotname, num3, array[1], array[2].ToLower(), dictionary, MaidParts.PARTS_COLOR.NONE); } else if (array[0] == "色設定") { 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)); } else if (array[0] == "数値設定") { material.SetFloat(array[1], float.Parse(array[2])); } } } } else if (mode == Menu.IMode.TexChange) { MaidParts.PARTS_COLOR parts_COLOR = MaidParts.PARTS_COLOR.NONE; if (array.Length == 6) { string text10 = array[5]; try { parts_COLOR = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + text10, false); } } maid.body0.ChangeTex(array[1], int.Parse(array[2]), array[3], array[4].ToLower(), dictionary, parts_COLOR); if (parts_COLOR != MaidParts.PARTS_COLOR.NONE) { maid.Parts.SetPartsColor(parts_COLOR, maid.Parts.GetPartsColor(parts_COLOR)); } } } } } // Note: this type is marked as 'beforefieldinit'. static Menu() { string[,] array = new string[31, 2]; array[0, 0] = "_MainTex"; array[0, 1] = "tex"; array[1, 0] = "_BumpMap"; array[1, 1] = "tex"; array[2, 0] = "_ToonRamp"; array[2, 1] = "tex"; array[3, 0] = "_ShadowTex"; array[3, 1] = "tex"; array[4, 0] = "_ShadowRateToon"; array[4, 1] = "tex"; array[5, 0] = "_SpecularTex"; array[5, 1] = "tex"; array[6, 0] = "_AnisoTex"; array[6, 1] = "tex"; array[7, 0] = "_RenderTex"; array[7, 1] = "tex"; array[8, 0] = "_HiTex"; array[8, 1] = "tex"; array[9, 0] = "_OutlineTex"; array[9, 1] = "tex"; array[10, 0] = "_OutlineToonRamp"; array[10, 1] = "tex"; array[11, 0] = "_Color"; array[11, 1] = "col"; array[12, 0] = "_ShadowColor"; array[12, 1] = "col"; array[13, 0] = "_RimColor"; array[13, 1] = "col"; array[14, 0] = "_SpecColor"; array[14, 1] = "col"; array[15, 0] = "_Emission"; array[15, 1] = "col"; array[16, 0] = "_ReflectColor"; array[16, 1] = "col"; array[17, 0] = "_OutlineColor"; array[17, 1] = "col"; array[18, 0] = "_MyLightColor0"; array[18, 1] = "col"; array[19, 0] = "_MyLightColor1"; array[19, 1] = "col"; array[20, 0] = "_TintColor"; array[20, 1] = "col"; array[21, 0] = "_ShadowColor"; array[21, 1] = "col"; array[22, 0] = "_Shininess"; array[22, 1] = "f"; array[23, 0] = "_FurLength"; array[23, 1] = "f"; array[24, 0] = "_OutlineWidth"; array[24, 1] = "f"; array[25, 0] = "_Cutoff"; array[25, 1] = "f"; array[26, 0] = "_AnisoOffset"; array[26, 1] = "f"; array[27, 0] = "_RimPower"; array[27, 1] = "f"; array[28, 0] = "_RimShift"; array[28, 1] = "f"; array[29, 0] = "_HiRate"; array[29, 1] = "f"; array[30, 0] = "_HiPow"; array[30, 1] = "f"; Menu.material_properties = array; } public static SortedDictionary> m_dicResourceRef = new SortedDictionary>(); private static string[] m_strAllTexInFileSys = null; private static string[,] material_properties; [CompilerGenerated] private static Func <>f__mg$cache0; private class LastParam { public LastParam(int f_nOrder, string f_strComm, params string[] f_argArgs) { this.nOrder = f_nOrder; this.strComm = f_strComm; this.aryArgs = new string[f_argArgs.Length]; f_argArgs.CopyTo(this.aryArgs, 0); } public int nOrder; public string strComm = string.Empty; public string[] aryArgs; } private enum IMode { Non, ItemChange, TexChange } }