/// <summary>
        /// メニューファイルを読み込む
        /// </summary>
        /// <returns></returns>
        bool loadMenu()
        {
            nodes = new Dictionary<string, int>();
            foreach (var nodekey in Params.Nodenames.Keys)
            {
                if (menuFile.delNodes.Contains(nodekey))
                {
                    nodes.Add(nodekey, 1);
                }
                else if (menuFile.showNodes.Contains(nodekey))
                {
                    nodes.Add(nodekey, 2);
                }
                else
                {
                    nodes.Add(nodekey, 0);
                }
            }
            masks = new Dictionary<string, bool>();
            foreach (var slotkey in Params.Slotnames.Keys)
            {
                if (menuFile.maskItems.Contains(slotkey))
                {
                    masks.Add(slotkey, true);
                }
                else
                {
                    masks.Add(slotkey, false);
                }
            }

            addItems = new List<ModelFile>();
            foreach (var target in menuFile.addItems)
            {
                if (Params.Slotnames.Keys.Contains(target[1]))
                {
                    ModelFile model = new ModelFile();
                    if (model.LoadFile(target[0]))
                    {
                        model.category = menuFile.category;
                        model.slotname = target[1];
                        if (Params.AttachPoints.ContainsKey(target[1]))
                        {
                            //手持ちアイテム
                            model.addItemType = ModelFile.AddItemType.handItem;
                            model.attachSlot = MenuFile.AttachBoneString;
                            model.attachName = Params.AttachPoints[target[1]];
                        }
                        else if (target.Length == 4 && target[2] == MenuFile.AttachBoneString)
                        {
                            //ボーンにアタッチ
                            model.addItemType = ModelFile.AddItemType.attachBone;
                            model.attachSlot = MenuFile.AttachBoneString;
                            model.attachName = target[3];
                        }
                        else if (target.Length == 5 && target[2] == MenuFile.AttachString)
                        {
                            //アタッチ
                            model.addItemType = ModelFile.AddItemType.attach;
                            model.attachSlot = target[3];
                            model.attachName = target[4];
                        }
                        addItems.Add(model);
                    }
                }
            }

            mateFiles = new List<MateFile>();
            foreach (var target in menuFile.materials)
            {
                if (Params.Slotnames.Keys.Contains(target[0]))
                {
                    int matno;
                    if (int.TryParse(target[1], out matno))
                    {
                        MateFile mate = new MateFile();
                        if (mate.LoadFile(target[2]))
                        {
                            mate.matno = matno;
                            mate.category = menuFile.category;
                            mate.slotname = target[0];
                            mateFiles.Add(mate);
                        }
                    }
                }
            }

            resourceFiles = new List<MenuFile>();
            foreach (var target in menuFile.resources)
            {
                MenuFile menu = new MenuFile();
                if (menu.LoadFile(target[1]))
                {
                    menu.resourceName = target[0];
                    resourceFiles.Add(menu);
                }
            }


            delItems = new Dictionary<string, bool>();
            foreach (var slot in Params.Slotnames.Keys)
            {
                // 削除アイテムのチェック
                bool exists = false;
                foreach (var target in menuFile.items)
                {
                    if (target.Contains(slot) && target.Contains("_del"))
                    {
                        exists = true;
                        break;
                    }
                }
                delItems.Add(slot, exists);
            }
            scrollPos = Vector2.zero;
            wearMpnsCombo.SelectedItemIndex = 0;
            foreach (var category in wearMpns)
            {
                if (category.text == menuFile.category)
                {
                    break;
                }
                wearMpnsCombo.SelectedItemIndex++;
            }
            return true;
        }
        public bool LoadFile(string filename)
        {
            reset();
            if (String.IsNullOrEmpty(Path.GetExtension(filename)) || Path.GetExtension(filename) != Params.ExtentionOfMenu)
            {
                filename += Params.ExtentionOfMenu;
            }
            this.baseMenuFile = new MenuFile();
            this.filename = Path.GetFileNameWithoutExtension(filename);
            this.baseMenuFile.filename = Path.GetFileNameWithoutExtension(filename);

            byte[] cd = null;
            try
            {
                using (AFileBase aFileBase = global::GameUty.FileOpen(filename))
                {
                    if (!aFileBase.IsValid())
                    {
                        logger.ErrorLog("アイテムメニューファイルが見つかりません。", filename);
                        return false;
                    }
                    cd = aFileBase.ReadAll();
                }
            }
            catch (Exception ex2)
            {
                logger.ErrorLog("アイテムメニューファイルが読み込めませんでした。", filename, ex2.Message);
                return false;
            }
            try
            {
                using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(cd), Encoding.UTF8))
                {
                    string text = binaryReader.ReadString();
                    if (text != menuHeaderString)
                    {
                        logger.ErrorLog("例外: ヘッダーファイルが不正です。" + text);
                        return false;
                    }
                    version = binaryReader.ReadInt32();

                    assetPath = binaryReader.ReadString();

                    headerName = binaryReader.ReadString();

                    headerCategory = binaryReader.ReadString();

                    headerSetumei = binaryReader.ReadString().Replace(Params.ReturnString, "\n");

                    int num2 = (int)binaryReader.ReadInt32();
                    while (true)
                    {
                        byte b = binaryReader.ReadByte();
                        int size = (int)b;
                        if (size == 0)
                        {
                            break;
                        }
                        string[] param = new string[size];
                        for (int i = 0; i < size; i++)
                        {
                            param[i] = binaryReader.ReadString();
                        }
                        string[] p1 = new string[size - 1];
                        string[] p2 = new string[size - 1];
                        for (int i = 0; i < size - 1; i++)
                        {
                            p1[i] = param[i + 1];
                            p2[i] = param[i + 1];
                        }
                        switch (param[0])
                        {
                            case menuFolderString:
                                baseMenuFile.menuFolder = param[1];
                                menuFolder = param[1];
                                break;
                            case categoryString:
                                baseMenuFile.category = param[1].ToLower();
                                category = param[1].ToLower();
                                break;
                            case catnoString:
                                baseMenuFile.catno = param[1];
                                catno = param[1];
                                break;
                            case addAttributeString:
                                baseMenuFile.addAttributes.Add(p1);
                                addAttributes.Add(p2);
                                break;
                            case priorityString:
                                baseMenuFile.priority = param[1];
                                priority = param[1];
                                break;
                            case nameString:
                                baseMenuFile.name = param[1];
                                name = param[1];
                                break;
                            case setumeiString:
                                baseMenuFile.setumei = param[1].Replace(Params.ReturnString, "\n");
                                setumei = param[1].Replace(Params.ReturnString, "\n");
                                break;
                            case iconsString:
                                baseMenuFile.icons = param[1];
                                icons = param[1];
                                iconFile = new TexFile();
                                iconFile.LoadFile(icons);
                                baseMenuFile.iconFile = new TexFile();
                                baseMenuFile.iconFile.LoadFile(icons);
                                break;
                            case itemParameterString:
                                baseMenuFile.itemParams.Add(p1);
                                itemParams.Add(p2);
                                break;
                            case itemString:
                                baseMenuFile.items.Add(param[1]);
                                items.Add(param[1]);
                                break;
                            case additemString:
                                baseMenuFile.addItems.Add(p1);
                                addItems.Add(p2);
                                break;
                            case maskitemString:
                                baseMenuFile.maskItems.Add(param[1]);
                                maskItems.Add(param[1]);
                                break;
                            case changeMaterialString:
                                baseMenuFile.materials.Add(p1);
                                materials.Add(p2);
                                break;
                            case delNodeString:
                                baseMenuFile.delNodes.Add(param[1]);
                                delNodes.Add(param[1]);
                                break;
                            case showNodeString:
                                baseMenuFile.showNodes.Add(param[1]);
                                showNodes.Add(param[1]);
                                break;
                            case delPartsNodeString:
                                baseMenuFile.delPartsNodes.Add(p1);
                                delPartsNodes.Add(p2);
                                break;
                            case showPartsNodeString:
                                baseMenuFile.showPartsNodes.Add(p1);
                                showPartsNodes.Add(p2);
                                break;
                            case resourceReferenceString:
                                baseMenuFile.resources.Add(p1);
                                resources.Add(p2);
                                break;
                            case texString:
                            case changeTextureString:
                                baseMenuFile.texs.Add(p1);
                                texs.Add(p2);
                                break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                return false;
            }
            return true;
        }
 void onSelectMPN(int winId)
 {
     GUILayout.BeginVertical(GUI.skin.box);
     GUILayout.Label("MOD Assist", labelStyle);
     mpnScrollPos = GUILayout.BeginScrollView(mpnScrollPos);
     foreach (var mpnkey in Params.WearMPNs.Keys)
     {
         if (GUILayout.Button(Params.WearMPNs[mpnkey], buttonStyle))
         {
             MaidProp prop = maid.GetProp(mpnkey);
             menuFile = new MenuFile();
             if (!menuFile.LoadFile(prop.strFileName))
             {
                 return;
             }
             if (loadMenu())
             {
                 showMainWindow = true;
             }
         }
     }
     GUILayout.EndScrollView();
     GUILayout.EndVertical();
     GUI.DragWindow();
 }