//この保存用クラスに読込
        public void SetParam(bool linking, bool isMasterMaid, XtMasterSlave.MsLinks ms)
        {
            doMasterSlave     = linking;
            this.isMasterMaid = isMasterMaid;

            XtMasterSlave.ManInfo master = null;
            XtMasterSlave.ManInfo slave  = null;

            if (ms.mdMaster_No >= 0)
            {
                master = new XtMasterSlave.ManInfo(ms.mdMasters[ms.mdMaster_No].mem, ms.mdMaster_No);
            }
            if (ms.mdSlave_No >= 0)
            {
                slave = new XtMasterSlave.ManInfo(ms.mdSlaves[ms.mdSlave_No].mem, ms.mdSlave_No);
            }

            if (master != null)
            {
                if (master.mem.boMAN)
                {
                    Master_Name = XtMasterSlave.GetMaidName(master);
                }
                else
                {
                    Master_Name = XtMasterSlave.GetMaidName(master.mem);
                }
                Master_ID = master.mem_id;
            }
            else
            {
                Master_Name = string.Empty;
                Master_ID   = ms.mdMaster_No;
            }

            if (slave != null)
            {
                if (slave.mem.boMAN)
                {
                    Slave_Name = XtMasterSlave.GetMaidName(slave);
                }
                else
                {
                    Slave_Name = XtMasterSlave.GetMaidName(slave.mem);
                }
                Slave_ID = slave.mem_id;
            }
            else
            {
                Slave_Name = string.Empty;
                Slave_ID   = ms.mdSlave_No;
            }

            if (master != null)
            {
                Scale_Master = (master.mem.gameObject.transform.localScale.x + master.mem.gameObject.transform.localScale.y + master.mem.gameObject.transform.localScale.z) / 3;
            }
            if (slave != null)
            {
                Scale_Slave = (slave.mem.gameObject.transform.localScale.x + slave.mem.gameObject.transform.localScale.y + slave.mem.gameObject.transform.localScale.z) / 3;
            }

            if (master != null)
            {
                if (master.mem.boMAN)
                {
                    Master_Hide = !XtMasterSlave.GetManVisible(master.mem);

                    Cnk_Visible = XtMasterSlave.GetChinkoVisible(master.mem.body0);
                    Cnk_Scale   = XtMasterSlave.GetChinkoScale(master.mem.body0).x;
                    manAlpha    = XtMasterSlave.GetManAlpha(master.mem);

                    Cnk_OffsetPos = XtMasterSlave.v3Tofa(XtMasterSlave.GetChinkoPos(master.mem.body0));
                }
                else
                {
                    Master_Hide = XtMasterSlave.GetStateMaskItemsAll(master.mem);

                    if (slave.mem.boMAN)
                    {
                        Cnk_Visible = XtMasterSlave.GetChinkoVisible(slave.mem.body0);
                        Cnk_Scale   = XtMasterSlave.GetChinkoScale(slave.mem.body0).x;
                        manAlpha    = XtMasterSlave.GetManAlpha(slave.mem);

                        Cnk_OffsetPos = XtMasterSlave.v3Tofa(XtMasterSlave.GetChinkoPos(slave.mem.body0));
                    }
                }
            }

            if (slave != null)
            {
                if (!slave.mem.boMAN)
                {
                    Stgt_boHeadToCam = slave.mem.body0.boHeadToCam;
                    Stgt_boEyeToCam  = slave.mem.body0.boEyeToCam;
                    //Stgt_hashTarget = slave.mem.body0.trsLookTarget.GetHashCode();
                    Stgt_sBoneName = slave.mem.body0.trsLookTarget.name;

                    switch (Stgt_sBoneName)
                    {
                    case "Bip01 Head":
                        break;

                    case "_IK_vagina":
                        break;

                    case "ManBip Head":
                        break;

                    case "chinko2":
                        break;

                    default:
                        Stgt_sBoneName = string.Empty;
                        break;
                    }
                }
            }

            if (slave != null)
            {
                if (!slave.mem.boMAN)
                {
                    //アイテムマスク
                    if (ms.holdSlvMask && ms.holdSlvMaskMaid == slave.mem)
                    {
                        Hold_SlaveMaskItems = ms.holdSlvMaskItems.ToArray();
                    }
                    else
                    {
                        Hold_SlaveMaskItems = new string[0];
                    }
                }
            }
        }
        public static void SaveWindowCallback_proc(int id, XtMasterSlave XtMS, ref int showWndMode, ref int _pageNum, XtMasterSlave.MsLinks[] p_MSlinks, XtMasterSlave.MsLinkConfig[] cfgs, XtMasterSlave.v3Offsets[] v3ofs, out string _WinprocPhase)
        {
            //XtMasterSlave.MsLinks ms_ = p_MSlinks[_pageNum];
            //bool boChrCng = false;

            _WinprocPhase = "[init]";
            GUIStyle gsLabel = new GUIStyle("label");

            gsLabel.fontSize  = 12;
            gsLabel.alignment = TextAnchor.MiddleLeft;

            GUIStyle gsButton = new GUIStyle("button");

            gsButton.fontSize  = 12;
            gsButton.alignment = TextAnchor.MiddleCenter;

            GUIStyle gsToggle = new GUIStyle("toggle");

            gsToggle.fontSize  = 12;
            gsToggle.alignment = TextAnchor.MiddleLeft;

            GUIStyle gsText = new GUIStyle("textfield");

            gsText.fontSize  = 12;
            gsText.alignment = TextAnchor.UpperLeft;

            GUIStyle gsTextAr = new GUIStyle("textArea");

            gsTextAr.fontSize  = 12;
            gsTextAr.alignment = TextAnchor.UpperLeft;
            gsTextAr.wordWrap  = true;

            GUIStyle gsCombo = new GUIStyle("button");

            gsCombo.fontSize           = 12;
            gsCombo.alignment          = TextAnchor.MiddleLeft;
            gsCombo.hover.textColor    = Color.cyan;
            gsCombo.onHover.textColor  = Color.cyan;
            gsCombo.onActive.textColor = Color.cyan;

            //GUIStyle gsScView = new GUIStyle("scrollView");
            _WinprocPhase = "[ctrl-1]";

            //GUI.enabled = false; //セーブ画面では閉じない
            if (GUI.Button(new Rect(240, 0, 20, 20), "x", gsButton))
            {
                //GizmoVisible(false);
                //GizmoHsVisible(false);
                //GuiFlag = false;
                boShow = false;
            }
            GUI.enabled = true;

            if (showWndMode == 1)
            {
                GUI.enabled = false;
            }
            if (GUI.Button(new Rect(240 - 70, 0, 20, 20), "-", gsButton))
            {
                showWndMode = 1;
            }
            GUI.enabled = true;
            if (showWndMode == 2)
            {
                GUI.enabled = false;
            }
            if (GUI.Button(new Rect(240 - 50, 0, 20, 20), "=", gsButton))
            {
                showWndMode = 2;
            }
            GUI.enabled = true;
            if (showWndMode == 0)
            {
                GUI.enabled = false;
            }
            if (GUI.Button(new Rect(240 - 30, 0, 20, 20), "□", gsButton))
            {
                showWndMode = 0;
            }
            GUI.enabled = true;

            EditScroll_cfg = GUI.BeginScrollView(new Rect(0, 20, XtMasterSlave.GUI_WIDTH, XtMasterSlave.GUI_HIGHT - 30), EditScroll_cfg,
                                                 new Rect(0, 0, XtMasterSlave.GUI_WIDTH - 16, EditScroll_cfg_sizeY));
            try
            {
                //XtMasterSlave.MsLinkConfig p_mscfg = cfgs[_pageNum];
                //XtMasterSlave.v3Offsets p_v3of = v3ofs[_pageNum];
                int pos_y = 0;

                GUI.Label(new Rect(ItemX, pos_y, 200, ItemHeight), "【設定保存・読込】", gsLabel);
                pos_y += ItemHeight;
                if (GUI.Button(new Rect(ItemX, pos_y, ItemWidth, ItemHeight), "戻る", gsButton))
                {
                    boShow = false;
                    Init();
                }
                pos_y += ItemHeight;
                pos_y += ItemHeight / 2;

                GUI.Label(new Rect(ItemX, pos_y, 200, ItemHeight), "【デフォルト&一般設定】", gsLabel);

                if (GUI.Button(new Rect(ItemX, pos_y += ItemHeight, ItemWidth / 2, ItemHeight), "保存", gsButton))
                {
                    // Iniファイル書き出し
                    XtMS.SaveMyConfigs();
                }
                if (GUI.Button(new Rect(ItemX + ItemWidth / 2, pos_y, ItemWidth / 2, ItemHeight), "読込", gsButton))
                {
                    // Iniファイル読み出し
                    XtMS.LoadMyConfigs();
                }

                /*
                 * GUI.Label(new Rect(5 + ItemWidth - 25 - 35 - 35, pos_y, 25, ItemHeight), "設定", gsLabel);
                 *
                 * if (GUI.Button(new Rect(5 + ItemWidth - 35 - 35, pos_y, 35, 20), "保存", gsButton))
                 * {
                 *  // Iniファイル書き出し
                 *  XtMS.SaveMyConfigs();
                 * }
                 * if (GUI.Button(new Rect(5 + ItemWidth - 35, pos_y, 35, 20), "読込", gsButton))
                 * {
                 *  // Iniファイル読み出し
                 *  XtMS.LoadMyConfigs();
                 * }*/

                pos_y += ItemHeight;
                pos_y += ItemHeight / 2;
                // 男0でもプリセ保存できてもいいかな?v0025 if (XtMasterSlave._MensList.Count <= 0)
                //    GUI.enabled = false;
                try
                {
                    GUI.Label(new Rect(ItemX, pos_y, 200, ItemHeight), "【プリセットの保存】", gsLabel);
                    pos_y += ItemHeight;

                    GUI.Label(new Rect(ItemX, pos_y, ItemWidth - 110, ItemHeight), "ファイル名(Save)", gsLabel);
                    if (GUI.Button(new Rect(ItemWidth - 110, pos_y, 110, ItemHeight), "日時で付ける", gsButton))
                    {
                        _memo      = string.Empty;
                        _EditIniFN = "XtMS-" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".ini";
                    }
                    _EditIniFN = GUI.TextField(new Rect(5, pos_y += ItemHeight, ItemWidth, ItemHeight), _EditIniFN, gsText);

                    if (GUI.Button(new Rect(ItemX, pos_y += ItemHeight, ItemWidth, ItemHeight), "保存", gsButton))
                    {
                        // Iniファイル書き出し
                        _WinprocPhase = "[save-uIni]";

                        if (string.IsNullOrEmpty(_EditIniFN))
                        {
                            NUty.WinMessageBox(NUty.GetWindowHandle(), "ファイル名を入力して下さい", "( ! )", NUty.MSGBOX.MB_OK | NUty.MSGBOX.MB_ICONERROR);
                        }
                        else
                        {
                            if (Path.GetExtension(_EditIniFN) != ".ini")
                            {
                                _EditIniFN = _EditIniFN + ".ini";
                            }
                            UserConfig ucfg    = new UserConfig();
                            string     strmemo = "";


                            for (int i = 0; i < cfgs.Length; i++)
                            {
                                XtMasterSlave.v3OffsetsToIniCfgs(ref cfgs[i], v3ofs[i]);
                            }

                            for (int i = 0; i < XtMasterSlave.MAX_PAGENUM; i++)
                            {
                                var ms = p_MSlinks[i];

                                ucfg.cfgs_ms[i] = cfgs[i];
                                ucfg.cfgs_p[i]  = new UserConfigPage(ms.doMasterSlave, ms.Scc1_MasterMaid, ms);

                                /*ucfg.cfgs_p[i] = new UserConfigPage(ms.doMasterSlave, ms.Scc1_MasterMaid,
                                 *  new XtMasterSlave.ManInfo(ms.mdMasters[ms.mdMaster_No].mem, ms.mdMaster_No),
                                 *  new XtMasterSlave.ManInfo(ms.mdSlaves[ms.mdSlave_No].mem, ms.mdSlave_No));
                                 */
                                if (ms.doMasterSlave)
                                {
                                    strmemo = strmemo + i + "Master" + ": [" + maidorman(ms.mdMasters[0].mem) + ms.mdMaster_No + "]   " + XtMasterSlave.GetMaidName(ms.mdMasters[ms.mdMaster_No]) + "  [M⇔S]\r\n";
                                    strmemo = strmemo + "  Slave" + ": [" + maidorman(ms.mdSlaves[0].mem) + ms.mdSlave_No + "]   " + XtMasterSlave.GetMaidName(ms.mdSlaves[ms.mdSlave_No]) + "  [M⇔S]\r\n";
                                }
                                else if (XtMasterSlave._MensList.Count <= 0)
                                {
                                    // メイドのみモード
                                    strmemo = strmemo + i + "Master" + ": 不在" + "\r\n";

                                    if (ms.mdSlave_No < 0)
                                    {
                                        strmemo = strmemo + "  Slave" + ": [" + maidorman(ms.mdSlaves[0].mem) + "_]   " + "未選択" + "\r\n";
                                    }
                                    else
                                    {
                                        strmemo = strmemo + "  Slave" + ": [" + maidorman(ms.mdSlaves[0].mem) + ms.mdSlave_No + "]   " + XtMasterSlave.GetMaidName(ms.mdSlaves[ms.mdSlave_No]) + "\r\n";
                                    }
                                }
                                else
                                {
                                    if (ms.mdMaster_No < 0)
                                    {
                                        strmemo = strmemo + i + "Master" + ": [" + maidorman(ms.mdMasters[0].mem) + "_]   " + "未選択" + "\r\n";
                                    }
                                    else
                                    {
                                        strmemo = strmemo + i + "Master" + ": [" + maidorman(ms.mdMasters[0].mem) + ms.mdMaster_No + "]   " + XtMasterSlave.GetMaidName(ms.mdMasters[ms.mdMaster_No]) + "\r\n";
                                    }

                                    if (ms.mdSlave_No < 0)
                                    {
                                        strmemo = strmemo + "  Slave" + ": [" + maidorman(ms.mdSlaves[0].mem) + "_]   " + "未選択" + "\r\n";
                                    }
                                    else
                                    {
                                        strmemo = strmemo + "  Slave" + ": [" + maidorman(ms.mdSlaves[0].mem) + ms.mdSlave_No + "]   " + XtMasterSlave.GetMaidName(ms.mdSlaves[ms.mdSlave_No]) + "\r\n";
                                    }
                                }
                            }
                            if (strmemo.Length > 0)
                            {
                                //strmemo = "保存時のリンク状態\r\n" + strmemo;
                            }

                            _WinprocPhase         = "[save-uIni2]";
                            ucfg.cfg_h.CurPageNum = _pageNum;
                            ucfg.cfg_h.Memo       = strmemo;
                            // ジッサイに保存
                            SaveIni_UserCfg(_EditIniFN, ucfg);
                            GetUsersConfigs();
                        }
                    }
                }
                catch
                {
                    throw;
                }
                finally
                {
                    GUI.enabled = true;
                }

                pos_y += ItemHeight;
                pos_y += ItemHeight;
                GUI.Label(new Rect(ItemX, pos_y, 200, ItemHeight), "【プリセットの読込】", gsLabel);
                pos_y += ItemHeight;

                List <string> slist   = _UserIniFN;
                Rect          boxrect = new Rect(ItemX, pos_y, ItemWidth, ItemHeight * 5);
                pos_y += ItemHeight * 5;
                GUI.Box(boxrect, "");
                EditScroll_fn       = GUI.BeginScrollView(boxrect, EditScroll_fn, new Rect(0, 0, EditScroll_fn_sizeX, (ItemHeight * slist.Count())), false, true);
                EditScroll_fn_sizeX = (int)boxrect.width - 16;
                try
                {
                    int pos_sy = 0;
                    foreach (string str in slist)
                    {
                        bool chk    = (_LoadIniFN == str);
                        int  pos_sx = 2;

                        //ファイル名
                        Vector2 v2Toggle = gsToggle.CalcSize(new GUIContent(str));
                        v2Toggle.x += pos_sx + 10;
                        if (EditScroll_fn_sizeX < v2Toggle.x)
                        {
                            EditScroll_fn_sizeX = (int)v2Toggle.x;
                        }
                        bool chk2 = GUI.Toggle(new Rect(pos_sx, pos_sy, /*boxrect.width*/ v2Toggle.x, ItemHeight), chk, str, gsToggle);
                        if (chk != chk2)
                        {
                            if (chk2)
                            {
                                _LoadIniFN = str;
                                _UserCfg   = LoadIni_UserCfg(str);
                                _memo      = _UserCfg.cfg_h.Memo;
                            }/*
                              * else
                              * {
                              * _LoadIniFN = string.Empty;
                              * }*/
                        }
                        pos_sy += ItemHeight;
                    }
                }
                catch (Exception)
                {
                    _WinprocPhase = "スクロール1";
                    throw;
                }
                finally
                {
                    GUI.EndScrollView();
                }

                //pos_y += ItemHeight / 2;

                //ファイル名
                GUI.Label(new Rect(ItemX, pos_y, 200, ItemHeight), "ファイル名(Load)", gsLabel);
                GUI.TextField(new Rect(5, pos_y += ItemHeight, ItemWidth, ItemHeight), _LoadIniFN, gsText);

                GUI.Label(new Rect(ItemX, pos_y    += ItemHeight, ItemWidth, ItemHeight), "保存時の情報", gsLabel);
                GUI.TextArea(new Rect(ItemX, pos_y += ItemHeight, ItemWidth, ItemHeight * 8), _memo, gsTextAr);
                pos_y += ItemHeight * 8;
                //pos_y += ItemHeight / 2;

                if (GUI.Button(new Rect(ItemX, pos_y, ItemWidth, ItemHeight), "読込", gsButton))
                {
                    // 元のカーソルを保持
                    System.Windows.Forms.Cursor preCursor = System.Windows.Forms.Cursor.Current;
                    // カーソルを待機カーソルに変更
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                    try {
                        // Iniファイル読み出し
                        _UserCfg = LoadIni_UserCfg(_LoadIniFN);

                        //ページ選択の復元
                        _pageNum = _UserCfg.cfg_h.CurPageNum;

                        //プリセットデータの反映を行う
                        procUserCfg(p_MSlinks, cfgs, v3ofs);
                    }
                    catch
                    {
                        _WinprocPhase = "[load-uIni2]";
                        throw;
                    }
                    finally
                    {
                        // カーソルを元に戻す
                        System.Windows.Forms.Cursor.Current = preCursor;
                    }

                    //画面を閉じる
                    boShow = false;
                    Init();
                }//ボタン

                pos_y += ItemHeight;
                XtMasterSlave.cfg.boNameSelectAndLoad = GUI.Toggle(new Rect(ItemX, pos_y, ItemWidth, ItemHeight), XtMasterSlave.cfg.boNameSelectAndLoad, "キャラ名指定&呼び出し有効", gsToggle);
                pos_y += ItemHeight;

                GUI.Label(new Rect(ItemX, pos_y, ItemWidth, ItemHeight), "注:呼び出す人数が多いと時間が掛かります", gsLabel);
                pos_y += ItemHeight;
                GUI.Label(new Rect(ItemX, pos_y, ItemWidth, ItemHeight), "(※OFF時は表示キャラ順の番号指定)", gsLabel);
                pos_y += ItemHeight;

                pos_y += ItemHeight / 2;
                pos_y += ItemHeight * 2;
                EditScroll_cfg_sizeY = pos_y;
            }
            catch
            {
                throw;
            }
            finally
            {
                GUI.EndScrollView();
            }
        }