123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344 |
- 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<string>(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<Menu.LastParam> list = new List<Menu.LastParam>();
- 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_1013;
- }
- if (stringCom == "アイテム")
- {
- Menu.SetMaidItemTemp(maid, stringList[1], f_bTemp);
- goto IL_1013;
- }
- 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_1013;
- }
- 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_1013;
- }
- 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<string, string> 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<string, string>();
- sortedDictionary.Add(key, value);
- Menu.m_dicResourceRef.Add(hashCode, sortedDictionary);
- goto IL_4B9;
- IL_4B9:
- goto IL_1013;
- }
- if (stringCom == "set")
- {
- goto IL_1013;
- }
- if (stringCom == "setname")
- {
- goto IL_1013;
- }
- if (stringCom == "setslotitem")
- {
- string tag = stringList[1];
- uint val = uint.Parse(stringList[2]);
- maid.SetProp(tag, (int)val, false);
- goto IL_1013;
- }
- 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_1013;
- }
- if (stringCom == "saveitem")
- {
- text3 = stringList[1];
- goto IL_1013;
- }
- if (stringCom == "category")
- {
- text7 = stringList[1];
- goto IL_1013;
- }
- if (stringCom == "maskitem")
- {
- if (stringList.Length > 1)
- {
- string maskslot = stringList[1];
- body.AddMask(text7, maskslot);
- goto IL_6A3;
- }
- goto IL_6A3;
- IL_6A3:
- goto IL_1013;
- }
- 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_1013;
- }
- if (stringCom == "node消去")
- {
- body.SetVisibleNodeSlot(text7, false, stringList[1]);
- goto IL_1013;
- }
- if (stringCom == "node表示")
- {
- body.SetVisibleNodeSlot(text7, true, stringList[1]);
- goto IL_1013;
- }
- if (stringCom == "パーツnode消去")
- {
- body.SetVisibleNodeSlotParts(text7, stringList[1], false, stringList[2]);
- goto IL_1013;
- }
- if (stringCom == "パーツnode表示")
- {
- body.SetVisibleNodeSlotParts(text7, stringList[1], true, stringList[2]);
- goto IL_1013;
- }
- 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_1013;
- }
- 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_1013;
- }
- 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_950;
- }
- goto IL_950;
- IL_950:
- goto IL_1013;
- }
- if (stringCom == "prop")
- {
- string tag2 = stringList[1];
- string s = stringList[2];
- maid.SetProp(tag2, int.Parse(s), false);
- goto IL_1013;
- }
- if (stringCom == "テクスチャ乗算")
- {
- goto IL_1013;
- }
- 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_AB3;
- }
- 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_AB3;
- IL_AB3:
- goto IL_1013;
- }
- 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_1013;
- }
- 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_1013;
- }
- 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_1013;
- }
- if (stringCom == "アタッチポイントの設定")
- {
- if (stringList.Length < 5)
- {
- Debug.LogError("アタッチポイントの設定引数の数が不正です。 " + text5 + " " + str);
- goto IL_C76;
- }
- 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_C76;
- IL_C76:
- goto IL_1013;
- }
- 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_1013;
- }
- if (stringCom == "paramset")
- {
- body.Face.NewParamSet(text5);
- goto IL_1013;
- }
- 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_1013;
- }
- 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_DCE;
- }
- goto IL_DCE;
- IL_DCE:
- goto IL_1013;
- }
- 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_1013;
- }
- 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_1013;
- }
- 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_1013;
- }
- if (stringCom == "param2")
- {
- if (stringList.Length == 4)
- {
- string slotname4 = stringList[1];
- body.GetSlot(slotname4).SetParam2(stringList[2], stringList[3]);
- goto IL_FCD;
- }
- Debug.LogError("param2の設定引数の数が不正です。 " + text5 + " " + str);
- goto IL_FCD;
- IL_FCD:
- goto IL_1013;
- }
- 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_1013;
- }
- goto IL_1013;
- IL_1013:
- goto IL_1096;
- }
- 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_1096;
- }
- IL_1096:
- 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" + 1130);
- 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<Menu.LastParam> list = new List<Menu.LastParam>();
- 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<string> list2 = new List<string>();
- 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<Transform>(true))
- {
- Renderer component = transform.GetComponent<Renderer>();
- 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<Transform>(true))
- {
- Renderer component2 = transform2.GetComponent<Renderer>();
- 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<string>(Menu.m_strAllTexInFileSys, (string i) => new Regex(strTexName).IsMatch(i));
- array = Array.FindAll<string>(array, (string i) => new Regex("^((?!_i_).)*$").IsMatch(i));
- IEnumerable<string> source = array;
- if (Menu.<>f__mg$cache0 == null)
- {
- Menu.<>f__mg$cache0 = new Func<string, string>(Path.GetFileName);
- }
- array = source.Select(Menu.<>f__mg$cache0).ToArray<string>();
- string strMatchGroup = strTexName.Replace(".*", "(?<WILD>.*)");
- array = array.Select(delegate(string i)
- {
- Match match = new Regex(strMatchGroup).Match(i);
- if (match.Success)
- {
- return match.Groups["WILD"].Value;
- }
- return i;
- }).ToArray<string>();
- }
- 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<string, byte[]> dictionary = new Dictionary<string, byte[]>();
- 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<Transform>(true))
- {
- Renderer component = transform.GetComponent<Renderer>();
- 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));
- }
- }
- }
- }
- }
- static Menu()
- {
- // Note: this type is marked as 'beforefieldinit'.
- 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<int, SortedDictionary<string, string>> m_dicResourceRef = new SortedDictionary<int, SortedDictionary<string, string>>();
- private static string[] m_strAllTexInFileSys = null;
- private static string[,] material_properties;
- [CompilerGenerated]
- private static Func<string, string> <>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
- }
- }
|