public void UpdateMenusBackground() { buttons.Clear(); foreach (var bg in ConstantValues.Background.Skip(2)) { Texture2D iconTexture = new Texture2D(1, 1); iconTexture.SetPixel(0, 0, new Color32(1, 1, 1, 1)); iconTexture.Apply(); CustomTextureButton button = new CustomTextureButton(iconTexture); string modelName = String.Copy(bg.Key); button.Text = modelName; MenuInfo menuCopy = MenuInfo.MakeBackgroundMenu(bg.Value); button.Click += (o, e) => func(menuCopy); buttons.Add(button); } }
public MenuInfo(MenuInfo other) : this() { this.modelType = other.modelType; this.menuFileName = other.menuFileName; this.menuName = other.menuName; this.menuNameInColorSet = other.menuNameInColorSet; this.menuInfo = other.menuInfo; this.modelName = other.modelName; this.delOnly = other.delOnly; this.isMan = other.isMan; this.priority = other.priority; this.iconTextureName = other.iconTextureName; this.partCategory = other.partCategory; this.colorSetCategory = other.colorSetCategory; foreach (TextureChangeInfo tex in other.textureChanges) { this.textureChanges.Add(tex); } foreach (MaterialChangeInfo mat in other.materialChanges) { this.materialChanges.Add(mat); } }
public void UpdateMenusBGObject() { buttons.Clear(); if (PhotoBGObjectData.data == null) { PhotoBGObjectData.Create(); } foreach (PhotoBGObjectData data in PhotoBGObjectData.data) { Texture2D iconTexture = new Texture2D(1, 1); iconTexture.SetPixel(0, 0, new Color32(1, 1, 1, 1)); iconTexture.Apply(); CustomTextureButton button = new CustomTextureButton(iconTexture); string modelName = String.Copy(data.name); button.Text = modelName; MenuInfo menuCopy = MenuInfo.MakeBGObjectMenu(data); button.Click += (o, e) => func(menuCopy); buttons.Add(button); } }
public void UpdateMenus(MPN category) { buttons.Clear(); List <MenuInfo> existing; if (!Menus.TryGetValue(category, out existing)) { return; } foreach (MenuInfo menu in existing) { try{ if (menu != null) { if (menu.delOnly) { continue; } if (menu.partCategory == category) { Texture2D iconTexture = AssetLoader.LoadTexture(menu.iconTextureName); if (iconTexture == null) { iconTexture = new Texture2D(1, 1); iconTexture.SetPixel(0, 0, new Color32(1, 1, 1, 1)); iconTexture.Apply(); } CustomTextureButton button = new CustomTextureButton(iconTexture); if (menu.modelName == null) { continue; } string modelName = String.Copy(menu.modelName); button.Text = modelName; string modelIconName; if (menu.iconTextureName != null) { modelIconName = String.Copy(menu.iconTextureName); } else { modelIconName = ""; } MenuInfo menuCopy = new MenuInfo(menu); button.Click += (o, e) => func(menuCopy); buttons.Add(button); } } else { Debug.LogError("Null MenuInfo"); } } catch { // Debug.LogError( e ); } } }
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); }