public static PropSnapShot Clone(PropSnapShot s) { PropSnapShot newObj = new PropSnapShot(); foreach (MPN mpn in Enum.GetValues(typeof(MPN))) { MaidProp srcMaidProp = s.maidProps[mpn]; MaidProp newMaidProp = new MaidProp(); using (MemoryStream ms = new MemoryStream()) { BinaryWriter bw = new BinaryWriter(ms); srcMaidProp.Serialize(bw); bw.Flush(); ms.Position = 0; using (BinaryReader br = new BinaryReader(ms)) { newMaidProp.Deserialize(br); } } newObj.maidProps[mpn] = newMaidProp; } for (int i = 0; i < (int)MaidParts.PARTS_COLOR.MAX; i++) { MaidParts.PARTS_COLOR col = (MaidParts.PARTS_COLOR)i; var c = s.GetColor(col); newObj.SetColor(col, c); } return(newObj); }
PropSnapShot CapturePropSnapShot() { PropSnapShot s = new PropSnapShot(); int maidNumber = 0; Maid maid = GameMain.Instance.CharacterMgr.GetMaid(maidNumber); if (maid == null) { return(s); } foreach (MPN mpn in Enum.GetValues(typeof(MPN))) { try { MaidProp maidProp = maid.GetProp(mpn); if (maidProp != null) { s[mpn] = maidProp; } } catch (Exception) { } } MaidParts maidParts = maid.Parts; MaidParts.PartsColor[] newMaidParts = null; using (MemoryStream ms = new MemoryStream()) { BinaryWriter bw = new BinaryWriter(ms); maidParts.Serialize(bw); bw.Flush(); ms.Position = 0; using (BinaryReader br = new BinaryReader(ms)) { newMaidParts = MaidParts.DeserializePre(br); } } for (int i = 0; i < (int)MaidParts.PARTS_COLOR.MAX; i++) { MaidParts.PARTS_COLOR col = (MaidParts.PARTS_COLOR)i; s.SetColor(col, newMaidParts[i]); } return(s); }
public static bool InitMenuItemScript(SceneEdit.SMenuItem mi, string f_strMenuFileName, out string IconTex) { IconTex = null; if (f_strMenuFileName.IndexOf("mod_") == 0) { string modPathFileName = Menu.GetModPathFileName(f_strMenuFileName); return(!string.IsNullOrEmpty(modPathFileName) && SceneEdit.InitModMenuItemScript(mi, modPathFileName)); } if (MenuCache.ContainsKey(f_strMenuFileName)) { try { MenuStub tempStub = MenuCache[f_strMenuFileName]; if (tempStub.DateModified == File.GetLastWriteTimeUtc(FilesDictionary[f_strMenuFileName])) { if (tempStub.Name != null) { mi.m_strMenuName = tempStub.Name; } if (tempStub.Description != null) { mi.m_strInfo = tempStub.Description; } if (tempStub.Category != null) { mi.m_strCateName = tempStub.Category; mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), tempStub.Category); } else { mi.m_mpn = MPN.null_mpn; } if (tempStub.ColorSetMPN != null) { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), tempStub.ColorSetMPN); } if (tempStub.ColorSetMenu != null) { mi.m_strMenuNameInColorSet = tempStub.ColorSetMenu; } if (tempStub.MultiColorID == null) { mi.m_pcMultiColorID = MaidParts.PARTS_COLOR.NONE; } else if (tempStub.MultiColorID != null) { mi.m_pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), tempStub.MultiColorID); } mi.m_boDelOnly = tempStub.DelMenu; mi.m_fPriority = tempStub.Priority; mi.m_bMan = tempStub.ManMenu; IconTex = tempStub.Icon; return(true); } else { Main.logger.LogWarning($"A cache entry was found outdated. This should be automatically fixed and the cache reloaded."); } } catch (Exception ex) { Main.logger.LogError(string.Concat(new string[] { $"Encountered an issue while trying to load menu {f_strMenuFileName} from cache. This should be automatically fixed and the cache reloaded.", "\n\n", ex.Message, "\n", ex.StackTrace })); } } try { if (FilesToRead[f_strMenuFileName] == null) { FilesToRead[f_strMenuFileName] = new MemoryStream(File.ReadAllBytes(FilesDictionary[f_strMenuFileName])); } } catch (Exception ex) { Main.logger.LogError(string.Concat(new string[] { "The following menu file could not be read! (メニューファイルがが読み込めませんでした。): ", f_strMenuFileName, "\n\n", ex.Message, "\n", ex.StackTrace })); return(false); } string text6 = string.Empty; string text7 = string.Empty; string path = ""; MenuStub cacheEntry = new MenuStub(); try { cacheEntry.DateModified = File.GetLastWriteTimeUtc(FilesDictionary[f_strMenuFileName]); BinaryReader binaryReader = new BinaryReader(FilesToRead[f_strMenuFileName], Encoding.UTF8); string text = binaryReader.ReadString(); if (text != "CM3D2_MENU") { Main.logger.LogError("ProcScriptBin (例外 : ヘッダーファイルが不正です。) The header indicates a file type that is not a menu file!" + text + " @ " + f_strMenuFileName); return(false); } binaryReader.ReadInt32(); path = binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadInt32(); string text5 = null; while (true) { int num4 = binaryReader.ReadByte(); text7 = text6; text6 = string.Empty; if (num4 == 0) { break; } for (int i = 0; i < num4; i++) { text6 = text6 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text6 == string.Empty)) { string stringCom = UTY.GetStringCom(text6); string[] stringList = UTY.GetStringList(text6); if (stringCom == "name") { if (stringList.Length > 1) { string text8 = stringList[1]; string text9 = string.Empty; string arg = string.Empty; int j = 0; while (j < text8.Length && text8[j] != '\u3000' && text8[j] != ' ') { text9 += text8[j]; j++; } while (j < text8.Length) { arg += text8[j]; j++; } mi.m_strMenuName = text9; cacheEntry.Name = mi.m_strMenuName; } else { Main.logger.LogWarning("Menu file has no name and an empty description will be used instead." + " @ " + f_strMenuFileName); mi.m_strMenuName = ""; cacheEntry.Name = mi.m_strMenuName; } } else if (stringCom == "setumei") { if (stringList.Length > 1) { mi.m_strInfo = stringList[1]; mi.m_strInfo = mi.m_strInfo.Replace("《改行》", "\n"); cacheEntry.Description = mi.m_strInfo; } else { Main.logger.LogWarning("Menu file has no description (setumei) and an empty description will be used instead." + " @ " + f_strMenuFileName); mi.m_strInfo = ""; cacheEntry.Description = mi.m_strInfo; } } else if (stringCom == "category") { if (stringList.Length > 1) { string strCateName = stringList[1].ToLower(); mi.m_strCateName = strCateName; cacheEntry.Category = mi.m_strCateName; try { mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), mi.m_strCateName); cacheEntry.Category = mi.m_mpn.ToString(); } catch { Main.logger.LogWarning("There is no category called (カテゴリがありません。): " + mi.m_strCateName + " @ " + f_strMenuFileName); return(false); } } else { Main.logger.LogWarning("The following menu file has a category parent with no category: " + f_strMenuFileName); return(false); } } else if (stringCom == "color_set") { if (stringList.Length > 1) { try { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); cacheEntry.ColorSetMPN = mi.m_eColorSetMPN.ToString(); } catch { Main.logger.LogWarning("There is no category called(カテゴリがありません。): " + mi.m_strCateName + " @ " + f_strMenuFileName); return(false); } if (stringList.Length >= 3) { mi.m_strMenuNameInColorSet = stringList[2].ToLower(); cacheEntry.ColorSetMenu = mi.m_strMenuNameInColorSet; } } else { Main.logger.LogWarning("A color_set entry exists but is otherwise empty" + " @ " + f_strMenuFileName); } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { MaidParts.PARTS_COLOR pcMultiColorID = MaidParts.PARTS_COLOR.NONE; if (stringList.Length == 6) { string text10 = stringList[5]; try { pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper()); } catch { Main.logger.LogError("無限色IDがありません。(The following free color ID does not exist: )" + text10 + " @ " + f_strMenuFileName); return(false); } mi.m_pcMultiColorID = pcMultiColorID; cacheEntry.MultiColorID = mi.m_pcMultiColorID.ToString(); } } else if (stringCom == "icon" || stringCom == "icons") { if (stringList.Length > 1) { text5 = stringList[1]; } else { Main.logger.LogError("The following menu file has an icon entry but no field set: " + f_strMenuFileName); return(false); } } else if (stringCom == "saveitem") { if (stringList.Length > 1) { string text11 = stringList[1]; if (String.IsNullOrEmpty(text11)) { Main.logger.LogWarning("SaveItem is either null or empty." + " @ " + f_strMenuFileName); } } else { Main.logger.LogWarning("A saveitem entry exists with nothing set in the field @ " + f_strMenuFileName); } } else if (stringCom == "unsetitem") { mi.m_boDelOnly = true; cacheEntry.DelMenu = mi.m_boDelOnly; } else if (stringCom == "priority") { if (stringList.Length > 1) { mi.m_fPriority = float.Parse(stringList[1]); cacheEntry.Priority = mi.m_fPriority; } else { Main.logger.LogError("The following menu file has a priority entry but no field set. A default value of 10000 will be used: " + f_strMenuFileName); mi.m_fPriority = 10000f; cacheEntry.Priority = mi.m_fPriority; } } else if (stringCom == "メニューフォルダ") { if (stringList.Length > 1) { if (stringList[1].ToLower() == "man") { mi.m_bMan = true; cacheEntry.ManMenu = mi.m_bMan; } } else { Main.logger.LogError("A a menu with a menu folder setting (メニューフォルダ) has an entry but no field set: " + f_strMenuFileName); return(false); } } } } if (!String.IsNullOrEmpty(text5)) { try { IconTex = text5; cacheEntry.Icon = text5; //mi.m_texIcon = ImportCM.CreateTexture(text5); } catch (Exception) { Main.logger.LogError("Error setting some icon tex from a normal mod." + " @ " + f_strMenuFileName); return(false); } } binaryReader.Close(); } catch (Exception ex2) { Main.logger.LogError(string.Concat(new string[] { "Exception when reading: ", f_strMenuFileName, "\nThe line currently being processed, likely the issue (現在処理中だった行): ", text6, "\nPrevious line (以前の行): ", text7, "\n\n", ex2.Message, "\n", ex2.StackTrace })); return(false); } MenuCache[f_strMenuFileName] = cacheEntry; return(true); }
public static bool InitMenuItemScript(SceneEdit.SMenuItem mi, string f_strMenuFileName, bool f_bMan, out string IconTex) { var fetchedField = AccessTools.DeclaredField(typeof(SceneEdit), "m_byItemFileBuffer"); var fetchedVal = fetchedField.GetValue(@this) as byte[]; IconTex = null; if (f_strMenuFileName.IndexOf("mod_") == 0) { string modPathFileName = Menu.GetModPathFileName(f_strMenuFileName); return(!string.IsNullOrEmpty(modPathFileName) && SceneEdit.InitModMenuItemScript(mi, modPathFileName)); } try { using (AFileBase afileBase = GameUty.FileOpen(f_strMenuFileName, null)) { NDebug.Assert(afileBase.IsValid(), "メニューファイルが存在しません。 :" + f_strMenuFileName); if (fetchedVal == null) { fetchedVal = new byte[System.Math.Max(500000, afileBase.GetSize())]; } else if (fetchedVal.Length < afileBase.GetSize()) { fetchedVal = new byte[afileBase.GetSize()]; } afileBase.Read(ref fetchedVal, afileBase.GetSize()); } } catch (Exception ex) { Main.logger.LogError(string.Concat(new string[] { "メニューファイルがが読み込めませんでした。 : ", f_strMenuFileName, " : ", ex.Message, " : StackTrace :\n", ex.StackTrace })); throw ex; } BinaryReader binaryReader = new BinaryReader(new MemoryStream(fetchedVal), Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text); int num = binaryReader.ReadInt32(); string path = binaryReader.ReadString(); string text2 = binaryReader.ReadString(); string text3 = binaryReader.ReadString(); string text4 = binaryReader.ReadString(); long num2 = (long)binaryReader.ReadInt32(); int num3 = 0; string text5 = null; string text6 = string.Empty; string text7 = string.Empty; try { for (; ;) { int num4 = (int)binaryReader.ReadByte(); text7 = text6; text6 = string.Empty; if (num4 == 0) { break; } for (int i = 0; i < num4; i++) { text6 = text6 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text6 == string.Empty)) { string stringCom = UTY.GetStringCom(text6); string[] stringList = UTY.GetStringList(text6); if (stringCom == "name") { string text8 = stringList[1]; string text9 = string.Empty; string arg = string.Empty; int j = 0; while (j < text8.Length && text8[j] != '\u3000' && text8[j] != ' ') { text9 += text8[j]; j++; } while (j < text8.Length) { arg += text8[j]; j++; } mi.m_strMenuName = text9; } else if (stringCom == "setumei") { mi.m_strInfo = stringList[1]; mi.m_strInfo = mi.m_strInfo.Replace("《改行》", "\n"); } else if (stringCom == "category") { string strCateName = stringList[1].ToLower(); mi.m_strCateName = strCateName; try { mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), mi.m_strCateName); } catch { Main.logger.LogWarning("カテゴリがありません。" + mi.m_strCateName); mi.m_mpn = MPN.null_mpn; } } else if (stringCom == "color_set") { try { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); } catch { Main.logger.LogWarning("カテゴリがありません。" + mi.m_strCateName); } if (stringList.Length >= 3) { mi.m_strMenuNameInColorSet = stringList[2].ToLower(); } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { MaidParts.PARTS_COLOR pcMultiColorID = MaidParts.PARTS_COLOR.NONE; if (stringList.Length == 6) { string text10 = stringList[5]; try { pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + text10, false); } mi.m_pcMultiColorID = pcMultiColorID; } } else if (stringCom == "icon" || stringCom == "icons") { text5 = stringList[1]; } else if (!(stringCom == "iconl")) { if (!(stringCom == "setstr")) { if (!(stringCom == "アイテムパラメータ")) { if (stringCom == "saveitem") { string text11 = stringList[1]; if (text11 == string.Empty) { Main.logger.LogError("err SaveItem \"" + text11); } if (text11 == null) { Main.logger.LogError("err SaveItem null=\"" + text11); } if (text11 != string.Empty) { } } else if (!(stringCom == "catno")) { if (stringCom == "additem") { num3++; } else if (stringCom == "unsetitem") { mi.m_boDelOnly = true; } else if (stringCom == "priority") { mi.m_fPriority = float.Parse(stringList[1]); } else if (stringCom == "メニューフォルダ" && stringList[1].ToLower() == "man") { mi.m_bMan = true; } } } } } } } } catch (Exception ex2) { Main.logger.LogError(string.Concat(new string[] { "Exception ", Path.GetFileName(path), " 現在処理中だった行 = ", text6, " 以前の行 = ", text7, " ", ex2.Message, "StackTrace:\n", ex2.StackTrace })); throw ex2; } if (text5 != null && text5 != string.Empty) { try { IconTex = text5; //mi.m_texIcon = ImportCM.CreateTexture(text5); } catch (Exception) { Main.logger.LogError("Error:"); } } binaryReader.Close(); return(true); }
// Token: 0x0600034D RID: 845 RVA: 0x0001B72C File Offset: 0x0001992C public void Show() { GUILayout.BeginVertical(new GUILayoutOption[0]); try { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("パーツカラー", this.uiParams.lStyleB, new GUILayoutOption[] { this.titleWidth, this.titleHeight }); GUILayout.EndHorizontal(); Maid currentMaid = BaseView.holder.CurrentMaid; if (!(currentMaid == null)) { if (currentMaid.IsBusy) { GUILayout.Space(100f); GUILayout.Label("変更中...", this.uiParams.lStyleB, new GUILayoutOption[0]); GUILayout.Space(this.uiParams.colorRect.height - 105f); } else { this.scrollViewPosition = GUILayout.BeginScrollView(this.scrollViewPosition, new GUILayoutOption[] { GUILayout.Width(this.uiParams.colorRect.width), GUILayout.Height(this.viewHeight) }); try { if (!this.editPartColors.Any <ACCPartsColorView.EditParts>()) { for (MaidParts.PARTS_COLOR parts_COLOR = MaidParts.PARTS_COLOR.EYE_L; parts_COLOR < MaidParts.PARTS_COLOR.MATSUGE_UP; parts_COLOR++) { MaidParts.PartsColor partsColor = currentMaid.Parts.GetPartsColor(parts_COLOR); this.editPartColors.Add(new ACCPartsColorView.EditParts(ref partsColor, this.presetMgr)); } } for (MaidParts.PARTS_COLOR parts_COLOR2 = MaidParts.PARTS_COLOR.EYE_L; parts_COLOR2 < MaidParts.PARTS_COLOR.MATSUGE_UP; parts_COLOR2++) { MaidParts.PartsColor partsColor2 = currentMaid.Parts.GetPartsColor(parts_COLOR2); int index = (int)parts_COLOR2; ACCPartsColorView.EditParts editParts = this.editPartColors[index]; GUILayout.BeginHorizontal(new GUILayoutOption[0]); try { if (GUILayout.Button(parts_COLOR2.ToString(), this.uiParams.lStyleB, new GUILayoutOption[0])) { editParts.expand = !editParts.expand; } string text = partsColor2.m_bUse ? "未使用" : "使用中"; GUILayout.Label(text, this.uiParams.lStyleRS, new GUILayoutOption[0]); } finally { GUILayout.EndHorizontal(); } if (editParts.expand) { if (partsColor2.m_nShadowRate != editParts.shadowRate.val) { editParts.shadowRate.Set(partsColor2.m_nShadowRate); } if (this.sliderHelper.DrawValueSlider("影率", editParts.shadowRate)) { partsColor2.m_nShadowRate = editParts.shadowRate.val; currentMaid.Parts.SetPartsColor(parts_COLOR2, partsColor2); editParts.SetParts(partsColor2); } if (editParts.HasMainChanged(ref partsColor2)) { editParts.SetMain(partsColor2); } if (editParts.HasShadowChanged(ref partsColor2)) { editParts.SetShadow(partsColor2); } if (partsColor2.m_nMainContrast != editParts.c.val) { editParts.c.Set(partsColor2.m_nMainContrast); } if (this.sliderHelper.DrawValueSlider("主C", editParts.c)) { partsColor2.m_nMainContrast = editParts.c.val; currentMaid.Parts.SetPartsColor(parts_COLOR2, partsColor2); editParts.SetParts(partsColor2); } if (partsColor2.m_nShadowContrast != editParts.shadowC.val) { editParts.shadowC.Set(partsColor2.m_nShadowContrast); } if (this.sliderHelper.DrawValueSlider("影C", editParts.shadowC)) { partsColor2.m_nShadowContrast = editParts.shadowC.val; currentMaid.Parts.SetPartsColor(parts_COLOR2, partsColor2); editParts.SetParts(partsColor2); } if (this.sliderHelper.DrawColorSlider("主色", ref editParts.main, SliderHelper.DEFAULT_PRESET, ref editParts.mainExpand, editParts.mainPicker)) { editParts.ReflectMain(); currentMaid.Parts.SetPartsColor(parts_COLOR2, editParts.parts); } if (this.sliderHelper.DrawColorSlider("影色", ref editParts.shadow, SliderHelper.DEFAULT_PRESET, ref editParts.shadowExpand, editParts.shadowPicker)) { editParts.ReflectShadow(); currentMaid.Parts.SetPartsColor(parts_COLOR2, editParts.parts); } } } } finally { GUI.EndScrollView(); } } } } finally { GUILayout.EndVertical(); } }
// Token: 0x06000066 RID: 102 RVA: 0x00007270 File Offset: 0x00005470 public void Save(string fileName, string presetName, Dictionary <string, bool> dDelNodes) { Maid currentMaid = this._holder.CurrentMaid; PresetData presetData = new PresetData { name = presetName }; foreach (SlotInfo slotInfo in ACConstants.SlotNames.Values) { if (slotInfo.enable) { TBodySkin slot = currentMaid.body0.GetSlot((int)slotInfo.Id); SlotState mask; if (slot.obj == null) { mask = SlotState.NotLoaded; } else if (!slot.boVisible) { mask = SlotState.Masked; } else { mask = SlotState.Displayed; } Material[] materials = this._holder.GetMaterials(slot); if (materials.Length != 0) { CCSlot ccslot = new CCSlot(slotInfo.Id) { mask = mask }; foreach (Material material in materials) { ShaderType shaderType = ShaderType.Resolve(material.shader.name); if (shaderType != ShaderType.UNKNOWN) { CCMaterial ccmaterial = new CCMaterial(material, shaderType); ccslot.Add(ccmaterial); foreach (ShaderPropTex shaderPropTex in shaderType.texProps) { Texture2D texture2D = material.GetTexture(shaderPropTex.propId) as Texture2D; if (!(texture2D == null) && !string.IsNullOrEmpty(texture2D.name)) { TextureInfo textureInfo = new TextureInfo(); ccmaterial.Add(textureInfo); textureInfo.propName = shaderPropTex.keyName; textureInfo.texFile = texture2D.name; TextureModifier.FilterParam filter = this._texModifier.GetFilter(currentMaid, slotInfo.Id.ToString(), material.name, texture2D.name); if (filter != null && !filter.HasNotChanged()) { textureInfo.filter = new TexFilter(filter); } Vector2 textureOffset = material.GetTextureOffset(shaderPropTex.propId); if (Math.Abs(textureOffset.x) > 0.001f) { textureInfo.offsetX = new float?(textureOffset.x); } if (Math.Abs(textureOffset.y) > 0.001f) { textureInfo.offsetY = new float?(textureOffset.y); } Vector2 textureScale = material.GetTextureScale(shaderPropTex.propId); if (Math.Abs(textureScale.x) > 0.001f) { textureInfo.scaleX = new float?(textureScale.x); } if (Math.Abs(textureScale.y) > 0.001f) { textureInfo.scaleY = new float?(textureScale.y); } } } } } presetData.slots.Add(ccslot); } } } for (int k = TypeUtil.BODY_START; k <= TypeUtil.BODY_END; k++) { MPN mpn = (MPN)Enum.ToObject(typeof(MPN), k); MaidProp prop = currentMaid.GetProp(mpn); if (prop != null) { if (prop.type == 1 || prop.type == 2) { presetData.mpnvals.Add(new CCMPNValue(mpn, prop.value, prop.min, prop.max)); } else if (prop.type == 3 && prop.nFileNameRID != 0) { presetData.mpns.Add(new CCMPN(mpn, prop.strFileName)); } } } for (int l = TypeUtil.WEAR_START; l <= TypeUtil.WEAR_END; l++) { MPN mpn2 = (MPN)Enum.ToObject(typeof(MPN), l); MaidProp prop2 = currentMaid.GetProp(mpn2); if (prop2 != null && prop2.nFileNameRID != 0) { presetData.mpns.Add(new CCMPN(mpn2, prop2.strFileName)); } } for (MaidParts.PARTS_COLOR parts_COLOR = TypeUtil.PARTS_COLOR_START; parts_COLOR <= TypeUtil.PARTS_COLOR_END; parts_COLOR++) { MaidParts.PartsColor partsColor = currentMaid.Parts.GetPartsColor(parts_COLOR); presetData.partsColors[parts_COLOR.ToString()] = new CCPartsColor(partsColor); } presetData.delNodes = new Dictionary <string, bool>(dDelNodes); LogUtil.Debug(new object[] { "create preset...", fileName }); this.SavePreset(fileName, presetData); }
public static void FaceTypeHook(TBody self, ref string slotname, ref int matno, ref string prop_name, ref string filename, ref Dictionary <string, byte[]> dicModTexData, ref MaidParts.PARTS_COLOR f_ePartsColorId) { int num = (int)TBody.hashSlotName[slotname]; TBodySkin tBodySkin = self.goSlot[num]; string modelname = (Path.GetFileNameWithoutExtension(tBodySkin.m_strModelFileName)); int start = modelname.IndexOf("facetype"); if (slotname == "head" && start != -1 && filename.IndexOf("*") != -1) { if (!GameUty.FileSystemMod.IsExistentFile(filename.Replace("*", tBodySkin.m_strModelFileName))) { string type = modelname.Substring(start + 8, 3); filename = filename.Replace("*", "face" + type); } } }
public static MenuInfo LoadMenu(string menuFileName) { AFileBase file = GameUty.FileOpen(menuFileName); if (!file.IsValid() || file.GetSize() == 0) { string name = menuFileName.Replace(@"menu\", ""); file = GameUty.FileOpen(name); if (file.GetSize() == 0 || !file.IsValid()) { name = menuFileName.Replace(@"menu\man\", ""); file = GameUty.FileOpen(name); if (file.GetSize() == 0 || !file.IsValid()) { throw new FileNotFoundException(name); } } } MenuInfo mi = new MenuInfo(); mi.menuFileName = menuFileName; BinaryReader binaryReader = new BinaryReader(new MemoryStream(file.ReadAll()), System.Text.Encoding.UTF8); string str1 = binaryReader.ReadString(); NDebug.Assert(str1 == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + str1); binaryReader.ReadInt32(); string path = binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); long num1 = (long)binaryReader.ReadInt32(); string sss = string.Empty; string str2 = string.Empty; string empty1 = string.Empty; try { while (true) { string stringCom; string[] stringList; do { do { do { MaidParts.PARTS_COLOR partsColor = MaidParts.PARTS_COLOR.NONE; do { sss = readCom(binaryReader); if (sss == null) { goto label_61; } stringCom = UTY.GetStringCom(sss); stringList = UTY.GetStringList(sss); if (readMenuProp(stringCom, stringList, ref partsColor, ref mi) == true) { goto label_40; } }while (stringList.Length != 6); string str4 = stringList[5]; try { partsColor = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), str4.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + str4); } mi.partsColor = partsColor; continue; label_40: if (stringCom == "icon" || stringCom == "icons") { mi.iconTextureName = stringList[1]; } }while (stringCom == "iconl" || stringCom == "setstr" || stringCom == "アイテムパラメータ"); if (stringCom == "saveitem") { string str3 = stringList[1]; if (str3 == string.Empty) { UnityEngine.Debug.LogError("err SaveItem \"" + str3); } if (str3 == null) { UnityEngine.Debug.LogError("err SaveItem null=\"" + str3); } } }while (stringCom == "catno"); if (stringCom == "additem") { mi.modelName = stringList[1]; } else if (stringCom == "delitem" || stringCom == "unsetitem") { mi.delOnly = true; } else if (stringCom == "priority") { mi.priority = float.Parse(stringList[1]); } }while (!(stringCom == "メニューフォルダ") || !(stringList[1].ToLower() == "man")); mi.isMan = true; } } catch { UnityEngine.Debug.LogError("Failed to parse menu file " + Path.GetFileName(path)); // UnityEngine.Debug.LogError(("Exception " + Path.GetFileName(path) + " 現在処理中だった行 = " + sss + " 以前の行 = " + str2 + " " + ex.Message + "StackTrace:\n" + ex.StackTrace)); throw; } label_61: binaryReader.Close(); return(mi); }
private static bool readMenuProp(string stringCom, string[] stringList, ref MaidParts.PARTS_COLOR partsColor, ref MenuInfo mi) { if (stringCom == "name") { string str3 = stringList[1]; string empty2 = string.Empty; string empty3 = string.Empty; int index; for (index = 0; index < str3.Length && (int)str3[index] != 12288 && (int)str3[index] != 32; ++index) { empty2 += str3[index]; } for (; index < str3.Length; ++index) { empty3 += str3[index]; } mi.menuName = empty2; } else if (stringCom == "setumei") { mi.menuInfo = stringList[1]; mi.menuInfo = mi.menuInfo.Replace("《改行》", "\n"); } else if (stringCom == "category") { string lower = stringList[1].ToLower(); try { mi.partCategory = (MPN)Enum.Parse(typeof(MPN), lower); } catch { UnityEngine.Debug.LogWarning("カテゴリがありません。" + stringList[1]); mi.partCategory = MPN.null_mpn; } } else if (stringCom == "color_set") { try { mi.colorSetCategory = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); } catch { UnityEngine.Debug.LogWarning((object)("カテゴリがありません。" + stringList[1].ToLower())); } if (stringList.Length >= 3) { mi.menuNameInColorSet = stringList[2].ToLower(); } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { string slotname2 = stringList[1]; int matno = int.Parse(stringList[2]); string prop_name = stringList[3]; string filename1 = stringList[4]; partsColor = MaidParts.PARTS_COLOR.NONE; if (stringList.Length == 6) { string str5 = stringList[5]; try { partsColor = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), str5.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + str5); } } mi.textureChanges.Add(new TextureChangeInfo(slotname2, matno, prop_name, filename1, partsColor)); // partsColor = MaidParts.PARTS_COLOR.NONE; // body0.ChangeTex(slotname2, matno, prop_name, filename1, (Dictionary<string, byte[]>) null, partsColor); } else if (stringCom == "マテリアル変更") { string strSlotName = stringList[1]; int nMatNo = int.Parse(stringList[2]); string strFileName = stringList[3]; mi.materialChanges.Add(new MaterialChangeInfo(strSlotName, nMatNo, strFileName)); } else { return(true); } return(false); }
public TextureChangeInfo(string slotName, int materialNo, string propName, string filename, MaidParts.PARTS_COLOR partsColor) { this.slotName = slotName; this.materialNo = materialNo; this.propName = propName; this.filename = filename; this.partsColor = partsColor; }
public override bool Equals(object obj) { if (obj == null) { return(false); } var s = obj as PropSnapShot; if (s == null) { return(false); } if (maidProps.Count != s.maidProps.Count) { return(false); } foreach (KeyValuePair <MPN, MaidProp> kv in maidProps) { MPN mpn = kv.Key; MaidProp maidProp = kv.Value; MaidProp p; if (!s.maidProps.TryGetValue(mpn, out p)) { return(false); } if (maidProp.strFileName != p.strFileName || maidProp.strTempFileName != p.strTempFileName || maidProp.idx != p.idx || maidProp.name != p.name || maidProp.type != p.type || maidProp.value_Default != p.value_Default || maidProp.value != p.value || maidProp.temp_value != p.temp_value || maidProp.value_LinkMAX != p.value_LinkMAX || maidProp.nFileNameRID != p.nFileNameRID || maidProp.nTempFileNameRID != p.nTempFileNameRID || maidProp.max != p.max || maidProp.min != p.min // maidProp.boDut != p.boDut || // 内部処理用なので無視すること // maidProp.boTempDut != p.boTempDut || ) { return(false); } } for (int i = 0; i < (int)MaidParts.PARTS_COLOR.MAX; i++) { MaidParts.PARTS_COLOR col = (MaidParts.PARTS_COLOR)i; MaidParts.PartsColor lhs = maidPartsColors[col]; MaidParts.PartsColor rhs = s.maidPartsColors[col]; if ( lhs.m_bUse != rhs.m_bUse || lhs.m_nMainHue != rhs.m_nMainHue || lhs.m_nMainChroma != rhs.m_nMainChroma || lhs.m_nMainBrightness != rhs.m_nMainBrightness || lhs.m_nMainContrast != rhs.m_nMainContrast || lhs.m_nShadowRate != rhs.m_nShadowRate || lhs.m_nShadowHue != rhs.m_nShadowHue || lhs.m_nShadowChroma != rhs.m_nShadowChroma || lhs.m_nShadowBrightness != rhs.m_nShadowBrightness || lhs.m_nShadowContrast != rhs.m_nShadowContrast ) { return(false); } } return(true); }
public void SetColor(MaidParts.PARTS_COLOR partsColor, MaidParts.PartsColor val) { maidPartsColors[partsColor] = val; }
public MaidParts.PartsColor GetColor(MaidParts.PARTS_COLOR partsColor) { return(maidPartsColors[partsColor]); }
public unsafe static MaidParts.PartsColor[] DeserializePre(BinaryReader f_brRead) { MaidParts.PartsColor[] array = new MaidParts.PartsColor[13]; for (int i = 0; i < 13; i++) { array[i] = MaidParts.m_aryPartsColorDefault[i]; } string a = f_brRead.ReadString(); if (a != "CM3D2_MULTI_COL") { MyLog.Log("無限色のヘッダーが不正です。"); return(null); } //NDebug.Assert(a == "CM3D2_MULTI_COL", "無限色のヘッダーが不正です。"); int num = f_brRead.ReadInt32(); int num2 = f_brRead.ReadInt32(); if (num <= 1200 && ((200 > num) ? (7 != num2) : (9 != num2))) { //NDebug.Assert("無限色数が異なります。セーブデータが破損しています。", false); return(null); } if (num <= 1200) { string[] array2 = new string[] { "EYE_L", "EYE_R", "HAIR", "EYE_BROW", "UNDER_HAIR", "SKIN", "NIPPLE", "HAIR_OUTLINE", "SKIN_OUTLINE" }; for (int j = 0; j < num2; j++) { MaidParts.PartsColor partsColor = default(MaidParts.PartsColor); partsColor.m_bUse = f_brRead.ReadBoolean(); partsColor.m_nMainHue = f_brRead.ReadInt32(); partsColor.m_nMainChroma = f_brRead.ReadInt32(); partsColor.m_nMainBrightness = f_brRead.ReadInt32(); partsColor.m_nMainContrast = f_brRead.ReadInt32(); partsColor.m_nShadowRate = f_brRead.ReadInt32(); partsColor.m_nShadowHue = f_brRead.ReadInt32(); partsColor.m_nShadowChroma = f_brRead.ReadInt32(); partsColor.m_nShadowBrightness = f_brRead.ReadInt32(); partsColor.m_nShadowContrast = f_brRead.ReadInt32(); MaidParts.PARTS_COLOR parts_COLOR = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), array2[j], true); array[(int)parts_COLOR] = partsColor; } } else { string value; while ((value = f_brRead.ReadString()) != MaidParts.PARTS_COLOR.MAX.ToString()) { PARTS_COLOR parts_COLOR2 = (PARTS_COLOR)Enum.Parse(typeof(PARTS_COLOR), value, true); fixed(MaidParts.PartsColor *ptr = &array[(int)parts_COLOR2]) { ptr->m_bUse = f_brRead.ReadBoolean(); ptr->m_nMainHue = f_brRead.ReadInt32(); ptr->m_nMainChroma = f_brRead.ReadInt32(); ptr->m_nMainBrightness = f_brRead.ReadInt32(); ptr->m_nMainContrast = f_brRead.ReadInt32(); ptr->m_nShadowRate = f_brRead.ReadInt32(); ptr->m_nShadowHue = f_brRead.ReadInt32(); ptr->m_nShadowChroma = f_brRead.ReadInt32(); ptr->m_nShadowBrightness = f_brRead.ReadInt32(); ptr->m_nShadowContrast = f_brRead.ReadInt32(); } } } return(array); }
public static bool InitMenuItemScript(SceneEdit.SMenuItem mi, string f_strMenuFileName, out string IconTex) { IconTex = null; if (f_strMenuFileName.IndexOf("mod_") == 0) { string modPathFileName = Menu.GetModPathFileName(f_strMenuFileName); return(!string.IsNullOrEmpty(modPathFileName) && SceneEdit.InitModMenuItemScript(mi, modPathFileName)); } try { if (MenuCache.ContainsKey(f_strMenuFileName)) { MenuStub tempStub = MenuCache[f_strMenuFileName]; if (tempStub.DateModified == File.GetLastWriteTimeUtc(FilesDictionary[f_strMenuFileName])) { if (tempStub.Name != null) { mi.m_strMenuName = tempStub.Name; } if (tempStub.Description != null) { mi.m_strInfo = tempStub.Description; } if (tempStub.Category != null) { mi.m_strCateName = tempStub.Category; mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), tempStub.Category); } else { mi.m_mpn = MPN.null_mpn; } if (tempStub.ColorSetMPN != null) { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), tempStub.ColorSetMPN); } if (tempStub.ColorSetMenu != null) { mi.m_strMenuNameInColorSet = tempStub.ColorSetMenu; } if (tempStub.MultiColorID == "null") { mi.m_pcMultiColorID = MaidParts.PARTS_COLOR.NONE; } else if (tempStub.MultiColorID != null) { mi.m_pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), tempStub.MultiColorID); } mi.m_boDelOnly = tempStub.DelMenu; mi.m_fPriority = tempStub.Priority; mi.m_bMan = tempStub.ManMenu; IconTex = tempStub.Icon; return(true); } else { Debug.Log($"A cache entry was found outdated. This should be automatically fixed and the cache reloaded."); } } if (FilesToRead[f_strMenuFileName] == null) { FilesToRead[f_strMenuFileName] = new MemoryStream(File.ReadAllBytes(FilesDictionary[f_strMenuFileName])); } } catch (Exception ex) { Debug.LogError(string.Concat(new string[] { "メニューファイルがが読み込めませんでした。 : ", f_strMenuFileName, " : ", ex.Message, " : StackTrace :\n", ex.StackTrace })); throw ex; } string text6 = string.Empty; string text7 = string.Empty; string path = ""; MenuStub cacheEntry = new MenuStub(); try { cacheEntry.DateModified = File.GetLastWriteTimeUtc(FilesDictionary[f_strMenuFileName]); BinaryReader binaryReader = new BinaryReader(FilesToRead[f_strMenuFileName], Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text); binaryReader.ReadInt32(); path = binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadInt32(); string text5 = null; while (true) { int num4 = binaryReader.ReadByte(); text7 = text6; text6 = string.Empty; if (num4 == 0) { break; } for (int i = 0; i < num4; i++) { text6 = text6 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text6 == string.Empty)) { string stringCom = UTY.GetStringCom(text6); string[] stringList = UTY.GetStringList(text6); if (stringCom == "name") { string text8 = stringList[1]; string text9 = string.Empty; string arg = string.Empty; int j = 0; while (j < text8.Length && text8[j] != '\u3000' && text8[j] != ' ') { text9 += text8[j]; j++; } while (j < text8.Length) { arg += text8[j]; j++; } mi.m_strMenuName = text9; cacheEntry.Name = mi.m_strMenuName; } else if (stringCom == "setumei") { mi.m_strInfo = stringList[1]; mi.m_strInfo = mi.m_strInfo.Replace("《改行》", "\n"); cacheEntry.Description = mi.m_strInfo; } else if (stringCom == "category") { string strCateName = stringList[1].ToLower(); mi.m_strCateName = strCateName; cacheEntry.Category = mi.m_strCateName; try { mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), mi.m_strCateName); cacheEntry.Category = mi.m_mpn.ToString(); } catch { Debug.LogWarning("カテゴリがありません。" + mi.m_strCateName); mi.m_mpn = MPN.null_mpn; } } else if (stringCom == "color_set") { try { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); cacheEntry.ColorSetMPN = mi.m_eColorSetMPN.ToString(); } catch { Debug.LogWarning("カテゴリがありません。" + mi.m_strCateName); } if (stringList.Length >= 3) { mi.m_strMenuNameInColorSet = stringList[2].ToLower(); cacheEntry.ColorSetMenu = mi.m_strMenuNameInColorSet; } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { MaidParts.PARTS_COLOR pcMultiColorID = MaidParts.PARTS_COLOR.NONE; cacheEntry.MultiColorID = "null"; if (stringList.Length == 6) { string text10 = stringList[5]; try { pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + text10, false); } mi.m_pcMultiColorID = pcMultiColorID; cacheEntry.MultiColorID = mi.m_pcMultiColorID.ToString(); } } else if (stringCom == "icon" || stringCom == "icons") { text5 = stringList[1]; } else if (!(stringCom == "iconl")) { if (!(stringCom == "setstr")) { if (!(stringCom == "アイテムパラメータ")) { if (stringCom == "saveitem") { string text11 = stringList[1]; if (text11 == string.Empty) { Debug.LogError("err SaveItem \"" + text11); } if (text11 == null) { Debug.LogError("err SaveItem null=\"" + text11); } } else if (!(stringCom == "catno")) { if (stringCom == "unsetitem") { mi.m_boDelOnly = true; cacheEntry.DelMenu = mi.m_boDelOnly; } else if (stringCom == "priority") { mi.m_fPriority = float.Parse(stringList[1]); cacheEntry.Priority = mi.m_fPriority; } else if (stringCom == "メニューフォルダ" && stringList[1].ToLower() == "man") { mi.m_bMan = true; cacheEntry.ManMenu = mi.m_bMan; } } } } } } } if (text5 != null && text5 != string.Empty) { try { IconTex = text5; cacheEntry.Icon = text5; //mi.m_texIcon = ImportCM.CreateTexture(text5); } catch (Exception) { Debug.LogError("Error:"); } } binaryReader.Close(); } catch (Exception ex2) { Debug.LogError(string.Concat(new string[] { "Exception ", Path.GetFileName(path), " 現在処理中だった行 = ", text6, " 以前の行 = ", text7, " ", ex2.Message, "StackTrace:\n", ex2.StackTrace })); throw ex2; } MenuCache[f_strMenuFileName] = cacheEntry; return(true); }