//プリセット用INIファイル読み書き
        public static bool SaveIni_UserCfg(string inifn, UserConfig uc)
        {
#if COM3D2
            string saveDirPath = Path.Combine(getPlginDir(), @"Config\");
            //ファイル名
            string fileIni = saveDirPath + @"XtMasterSlave\User_SaveData\" + inifn;
#else
            string fullpath    = Path.GetFullPath(".\\");
            string saveDirPath = Path.Combine(fullpath, @"Sybaris\Plugins\UnityInjector\Config\");
            //ファイル名
            //string fileIni = @"UnityInjector\Config\XtMsterSlave\User_SaveData\" + inifn;
            string fileIni = saveDirPath + @"XtMsterSlave\User_SaveData\" + inifn;
#endif
            string xfn       = extpath(fileIni);
            bool   isSuccess = false;
            string strfn_d   = null;
            try
            {
                if (File.Exists(fileIni))
                {
                    var msgo = "上書きしますか?\r\nファイル名: " + inifn;
                    var reto = NUty.WinMessageBox(NUty.GetWindowHandle(), msgo, "( ! )", NUty.MSGBOX.MB_OKCANCEL | NUty.MSGBOX.MB_ICONQUESTION);
                    if (reto != (int)System.Windows.Forms.DialogResult.OK)
                    {
                        msgo = "保存はキャンセルされました";
                        NUty.WinMessageBox(NUty.GetWindowHandle(), msgo, "( ! )", NUty.MSGBOX.MB_OK);
                        return(false);
                    }
                    else
                    {
                        strfn_d = fileIni + ".bak";
                        File.Move(fileIni, strfn_d);
                    }
                }

                if (!File.Exists(fileIni))
                {
                    Console.WriteLine("ユーザーセーブini設定書き込み :" + xfn);

                    uc.cfg_h.Memo = uc.cfg_h.Memo.Replace("\n", "<改行>");
                    uc.cfg_h.Memo = uc.cfg_h.Memo.Replace("\r", "");
                    SharedConfig.SaveConfig("Config", xfn, uc.cfg_h);

                    for (int i = 0; i < XtMasterSlave.MAX_PAGENUM; i++)
                    {
                        //前後のスペースがトリムされるようなので""でエスケープする
                        uc.cfgs_p[i].Master_Name = uc.cfgs_p[i].Master_Name.dq_();
                        uc.cfgs_p[i].Slave_Name  = uc.cfgs_p[i].Slave_Name.dq_();

                        SharedConfig.SaveConfig("Page-" + (i + 1).ToString(), xfn, uc.cfgs_p[i]);
                    }

                    for (int i = 0; i < uc.cfgs_ms.Length; i++)
                    {
                        SharedConfig.SaveConfig("Config-" + (i + 1).ToString(), xfn, uc.cfgs_ms[i]);
                    }
                }
                if (strfn_d != null && File.Exists(strfn_d))
                {
                    File.Delete(strfn_d);
                }
            }
            catch (Exception e)
            {
                UnityEngine.Debug.Log("api+INI SaveError:" + e);

                var msg = "ファイル保存に失敗しました\r\nファイル名:" + inifn + "\r\n" + e.Message;
                NUty.WinMessageBox(NUty.GetWindowHandle(), msg, "( ! )", NUty.MSGBOX.MB_OK | NUty.MSGBOX.MB_ICONERROR);
            }
            return(isSuccess);
        }
Ejemplo n.º 2
0
        //public bool CheckData() {
        //    return true;
        //}

        // TODO 複数のマテリアルのmateファイルが同一の場合
        //        設定、textureが同じであるかを判定して、同一にしてよいかを判定⇒変更前のファイルが同一であれば一緒。
        // 複数のスロットで同一のmodelファイルを指定している場合、
        //   現状は、他方へリンクを張り、同一modelとして出力
        //   シェーダが異なる場合は別modelとして出力する必要がある(TODO)

        // TODO 汚すぎるため、要リファクタ
        public void Show()
        {
            if (trgtMenu == null)
            {
                return;
            }

            scrollViewPosition = GUILayout.BeginScrollView(scrollViewPosition, _optScrlWidth, _optScrlHeight);

            GUILayout.BeginVertical();
            GUILayout.Space(uiParams.unitHeight);
            var txtColr = uiParams.textStyle.normal.textColor;
            var errColr = Color.red;

            try {
                GUILayout.BeginHorizontal();
                GUILayout.Label("メニュー", uiParams.lStyle, _optLabelWidth);
                var before = trgtMenu.editfile;
                if (trgtMenu.editfileExist)
                {
                    uiParams.textStyle.normal.textColor = errColr;
                }
                trgtMenu.editfile = GUILayout.TextField(trgtMenu.editfile, uiParams.textStyle);
                if (trgtMenu.editfileExist)
                {
                    uiParams.textStyle.normal.textColor = txtColr;
                }
                nameChanged |= (trgtMenu.editfile != before);
                GUILayout.Label(FileConst.EXT_MENU, uiParams.lStyleS, _optExtLabelWidth);

                var src = nameInterlocked;
                nameInterlocked = GUILayout.Toggle(nameInterlocked, "名前連動", uiParams.tStyleS, uiParams.optToggleSWidth);
                if (nameInterlocked && src != nameInterlocked)
                {
                    nameChanged = true;
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("内部パス", uiParams.lStyle, _optLabelWidth);
                trgtMenu.txtpath = GUILayout.TextField(trgtMenu.txtpath, uiParams.textStyle);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("優先度", uiParams.lStyle, _optLabelWidth);
                var editedPriority = GUILayout.TextField(trgtMenu.priority, 10, uiParams.textStyle, _modalHalfWidth);
                if (trgtMenu.priority != editedPriority)
                {
                    // float?
                    int v;
                    if (int.TryParse(editedPriority, out v))
                    {
                        if (v >= 0)
                        {
                            trgtMenu.priority = v.ToString();
                        }
                    }
                }
                GUILayout.Space(_indentWidth);
                GUILayout.Label("カテゴリ", uiParams.lStyleS);
                GUILayout.Label(trgtMenu.category, uiParams.lStyleS);

                if (GUILayout.Button("↑ パス自動設定", uiParams.bStyle))
                {
                    trgtMenu.txtpath = settings.txtPrefixTex + trgtMenu.editfile;
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("アイコン", uiParams.lStyle, _optLabelWidth);
                GUI.enabled = !nameInterlocked;
                if (nameInterlocked && nameChanged)
                {
                    if (!trgtMenu.editfile.ToLower().EndsWith(settings.iconSuffix, StringComparison.Ordinal))
                    {
                        trgtMenu.editicon = trgtMenu.editfile + settings.iconSuffix;
                    }
                    else
                    {
                        trgtMenu.editicon = trgtMenu.editfile;
                    }
                }
                if (trgtMenu.editfileExist)
                {
                    uiParams.textStyle.normal.textColor = errColr;
                }
                trgtMenu.editicon = GUILayout.TextField(trgtMenu.editicon, uiParams.textStyle);
                if (trgtMenu.editfileExist)
                {
                    uiParams.textStyle.normal.textColor = txtColr;
                }
                GUI.enabled = true;

                GUILayout.Label(FileConst.EXT_TEXTURE, uiParams.lStyleS, _optExtLabelWidth);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("名前", uiParams.lStyle, _optLabelWidth);
                trgtMenu.name = GUILayout.TextField(trgtMenu.name, uiParams.textStyle);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal(_optTwoLineHeight);
                GUILayout.Label("説明", uiParams.lStyle, _optLabelWidth);
                trgtMenu.desc = GUILayout.TextArea(trgtMenu.desc, uiParams.textAreaStyleS, _optTwoLineHeight);
                GUILayout.EndHorizontal();

                try {
                    foreach (var pair in trgtMenu.slotMaterials)
                    {
                        GUILayout.Label("マテリアル情報 (" + pair.Key + ")", uiParams.lStyle);
                        foreach (var trgtMat in pair.Value.materials)
                        {
                            if (trgtMat == null)
                            {
                                continue;
                            }

                            GUILayout.BeginHorizontal();
                            try {
                                GUILayout.Space(_indentWidth);
                                if (trgtMat.onlyModel)
                                {
                                    uiParams.lStyleS.normal.textColor = Color.cyan;
                                }
                                GUILayout.Label("マテリアル" + trgtMat.matNo, uiParams.lStyleS, _optSubLabelWidth);
                                if (trgtMat.onlyModel)
                                {
                                    uiParams.lStyleS.normal.textColor = txtColr;
                                }

                                // マテリアルファイル名
                                if (trgtMat.onlyModel)
                                {
                                    GUILayout.Label("(.mateファイル無し)", uiParams.lStyleS);
                                }
                                else
                                {
                                    if (trgtMat.editfileExist)
                                    {
                                        uiParams.textStyle.normal.textColor = errColr;
                                    }
                                    GUI.enabled = !nameInterlocked;
                                    if (nameInterlocked && nameChanged)
                                    {
                                        trgtMat.editfile = trgtMenu.editfile + trgtMat.matNo;
                                    }
                                    trgtMat.editfile = GUILayout.TextField(trgtMat.editfile, uiParams.textStyle);
                                    if (trgtMat.editfileExist)
                                    {
                                        uiParams.textStyle.normal.textColor = txtColr;
                                    }
                                    GUI.enabled = true;
                                    GUILayout.Label(FileConst.EXT_MATERIAL, uiParams.lStyleS, _optExtLabelWidth);
                                    if (trgtMat.needPmat && trgtMat.needPmatChange)
                                    {
                                        GUILayout.Label("|" + FileConst.EXT_PMAT, uiParams.lStyleS, _optExtLabelWidth);
                                    }
                                }

                                // マテリアル名
                                if (!trgtMat.needPmat)
                                {
                                    // 名前は任意
                                    trgtMat.editname = GUILayout.TextField(trgtMat.editname, uiParams.textStyle);
                                }
                                else
                                {
                                    if (trgtMat.needPmatChange)
                                    {
                                        // pmat出力する場合
                                        trgtMat.editname = trgtMat.editfile;
                                        trgtMat.editname = GUILayout.TextField(trgtMat.editname, uiParams.textStyle);
                                    }
                                    else
                                    {
                                        GUI.enabled      = false;
                                        trgtMat.editname = GUILayout.TextField(trgtMat.editname, uiParams.textStyle);
                                        GUI.enabled      = true;
                                    }
                                }
                            } catch (Exception e) {
                                LogUtil.Debug("failed to display material name:", trgtMat.editname, e);
                            } finally {
                                GUILayout.EndHorizontal();
                            }

                            GUILayout.BeginHorizontal();
                            try {
                                GUILayout.Space(_indentWidth * 2);
                                var blabel = trgtMat.uiTexViewed? "-": "+";
                                if (GUILayout.Button(blabel, uiParams.optBtnWidth))
                                {
                                    trgtMat.uiTexViewed = !trgtMat.uiTexViewed;
                                }
                                var shaderName = trgtMat.ShaderNameOrDefault("不明");

                                GUILayout.Label("シェーダ : " + shaderName, uiParams.lStyleS, _optShaderWidth);
                                GUILayout.Space(_indentWidth);
                                uiParams.lStyleS.normal.textColor = changedColor;
                                GUILayout.Label(trgtMat.shaderChanged? "変更有":"", uiParams.lStyleS);
                                uiParams.lStyleS.normal.textColor = txtColr;
                                // TODO pmat出力の有無指定
                                if (!trgtMat.needPmat)
                                {
                                    GUILayout.Label("pmat不要(透過無)", uiParams.lStyleS, _optLabelWidth);
                                }
                                else
                                {
                                    if (trgtMat.needPmatChange)
                                    {
                                        GUI.enabled        = false;
                                        trgtMat.pmatExport = GUILayout.Toggle(trgtMat.pmatExport, "pmat出力", uiParams.lStyleS, _optLabelWidth);
                                        GUI.enabled        = true;
                                    }
                                    else
                                    {
                                        GUILayout.Label("既存pmat利用", uiParams.lStyleS, _optLabelWidth);
                                    }
                                }
                            } catch (Exception e) {
                                LogUtil.Debug("failed to display shader info:", trgtMat.editname, e);
                            } finally {
                                GUILayout.EndHorizontal();
                            }

                            if (trgtMat.uiTexViewed)
                            {
                                GUILayout.BeginVertical();
                                try {
                                    // 現在のマテリアルからテクスチャ取得
                                    // var mat = trgtMat.editedMat.material;
                                    //foreach (var propName in trgtMat.editedMat.type.texPropNames) {
                                    foreach (var texProp in trgtMat.editedMat.type.texProps)
                                    {
                                        TargetTexture trgtTex;
                                        if (!trgtMat.texDic.TryGetValue(texProp.key, out trgtTex))
                                        {
                                            continue;
                                        }
                                        if (trgtTex.tex == null)
                                        {
                                            continue;
                                        }

                                        GUILayout.BeginHorizontal(_optSubItemHeight);
                                        GUILayout.Space(_indentWidth * 4);
                                        var propName = texProp.keyName;
                                        GUILayout.Label(propName, uiParams.lStyleS, _optPropNameWidth);
                                        if (trgtTex.needOutput)
                                        {
                                            GUI.enabled = !nameInterlocked;
                                            if (nameInterlocked && nameChanged)
                                            {
                                                trgtTex.editname = trgtMat.editfile + FileConst.GetTexSuffix(propName);
                                            }
                                        }
                                        else
                                        {
                                            GUI.enabled = false;
                                        }
                                        if (!trgtMat.onlyModel)
                                        {
                                            if (trgtTex.editnameExist)
                                            {
                                                uiParams.textStyle.normal.textColor = errColr;
                                            }
                                            trgtTex.editname = GUILayout.TextField(trgtTex.editname, uiParams.textStyle);
                                            if (trgtTex.editnameExist)
                                            {
                                                uiParams.textStyle.normal.textColor = txtColr;
                                            }
                                            GUI.enabled = true;

                                            if (trgtTex.colorChanged)
                                            {
                                                uiParams.lStyleS.normal.textColor = changedColor;
                                                GUILayout.Label("色変更", uiParams.lStyleS, _optExtLabelWidth);
                                                uiParams.lStyleS.normal.textColor = txtColr;
                                            }
                                            else
                                            {
                                                if (trgtTex.fileChanged)
                                                {
                                                    uiParams.lStyleS.normal.textColor = changedColor;
                                                    GUILayout.Label("変更有", uiParams.lStyleS, _optExtLabelWidth);
                                                    uiParams.lStyleS.normal.textColor = txtColr;
                                                }
                                            }
                                            // texは色変更があった場合にのみ出力
                                        }
                                        else
                                        {
                                            // modelファイルのマテリアルを使用している場合
                                            if (trgtTex.editnameExist)
                                            {
                                                uiParams.lStyle.normal.textColor = errColr;
                                            }
                                            GUILayout.Label(trgtTex.editname, uiParams.lStyleS);
                                            if (trgtTex.editnameExist)
                                            {
                                                uiParams.lStyle.normal.textColor = txtColr;
                                            }
                                        }
                                        GUI.enabled = true;

                                        GUILayout.EndHorizontal();
                                    }
                                } catch (Exception e) {
                                    LogUtil.Debug("failed to display tex info.", e);
                                } finally {
                                    GUI.enabled = true;
                                    GUILayout.EndVertical();
                                }
                            }
                            else if (nameInterlocked && nameChanged)
                            {
                                // 非表示でもデータは更新
                                //foreach (var propName in trgtMat.editedMat.type1.texPropNames) {
                                foreach (var texProp in trgtMat.editedMat.type.texProps)
                                {
                                    TargetTexture trgtTex;
                                    if (!trgtMat.texDic.TryGetValue(texProp.key, out trgtTex))
                                    {
                                        continue;
                                    }
                                    if (trgtTex.tex == null)
                                    {
                                        continue;
                                    }

                                    if (trgtTex.needOutput)
                                    {
                                        trgtTex.editname = trgtMat.editfile + FileConst.GetTexSuffix(texProp.keyName);
                                    }
                                }
                            }
                            // GUILayout.EndHorizontal();
                        }
                    }
                } catch (Exception e) {
                    LogUtil.Error("failed to display material", e);
                }

                if (trgtMenu.addItems.Any())
                {
                    GUILayout.Label("additem (model)", uiParams.lStyle);
                    foreach (var item in trgtMenu.addItems)
                    {
                        try {
                            if (!item.HasSlot())
                            {
                                continue;
                            }
                            GUILayout.BeginHorizontal();
                            GUILayout.Space(_indentWidth);
                            GUILayout.Label(item.slot, uiParams.lStyleS, _optLabelWidth);

                            if (item.editnameExist)
                            {
                                uiParams.textStyle.normal.textColor = errColr;
                                uiParams.lStyleS.normal.textColor   = errColr;
                            }
                            // 同一ファイル名のモデルを参照するリンクがあった場合は変更できないラベルとする
                            if (item.HasLink())
                            {
                                GUILayout.Label(item.link.EditFileName(), uiParams.lStyleS);
                            }
                            else if (!item.needUpdate)
                            {
                                GUILayout.Label(item.EditFileName(), uiParams.lStyleS);
                            }
                            else
                            {
                                GUI.enabled = !nameInterlocked;
                                if (nameInterlocked && nameChanged)
                                {
                                    var suffix = FileConst.GetModelSuffix(item.slot);
                                    if (trgtMenu.editfile.Contains(suffix))
                                    {
                                        item.editname = trgtMenu.editfile;
                                    }
                                    else
                                    {
                                        item.editname = trgtMenu.editfile + suffix;
                                    }
                                }
                                item.editname = GUILayout.TextField(item.editname, uiParams.textStyle);
                                GUI.enabled   = true;

                                GUILayout.Label(FileConst.EXT_MODEL, uiParams.lStyleS, _optExtLabelWidth);
                            }
                            if (item.editnameExist)
                            {
                                uiParams.textStyle.normal.textColor = txtColr;
                                uiParams.lStyleS.normal.textColor   = txtColr;
                            }
                            GUILayout.EndHorizontal();

                            if (item.info.Length < 3)
                            {
                                continue;
                            }
                            GUILayout.BeginHorizontal();
                            GUILayout.Space(_indentWidth);
                            GUILayout.Label("追加情報", uiParams.lStyleS, _optLabelWidth);
                            var sb = new StringBuilder();
                            for (var i = 2; i < item.info.Length; i++)
                            {
                                sb.Append(item.info[i]).Append(", ");
                            }
                            GUILayout.Label(sb.ToString(), uiParams.lStyleS);
                            GUILayout.EndHorizontal();
                        } catch (Exception e) {
                            LogUtil.Debug("failed to display item info:", item.slot, e);
                        }
                    }
                }
                if (trgtMenu.resources.Any())
                {
                    try {
                        GUILayout.Label("リソース参照", uiParams.lStyle);
                        foreach (var resRef in trgtMenu.resources)
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.Space(_indentWidth);
                            GUILayout.Label(resRef.key, uiParams.lStyleS, _optSubLabelWidth);
                            if (nameInterlocked && nameChanged)
                            {
                                resRef.editname = trgtMenu.editfile + resRef.suffix;
                            }
                            GUI.enabled = !nameInterlocked;
                            if (resRef.editfileExist)
                            {
                                uiParams.textStyle.normal.textColor = errColr;
                            }
                            resRef.editname = GUILayout.TextField(resRef.editname, uiParams.textStyle);
                            if (resRef.editfileExist)
                            {
                                uiParams.textStyle.normal.textColor = txtColr;
                            }
                            GUI.enabled = true;
                            GUILayout.Label(FileConst.EXT_MENU, uiParams.lStyleS, _optExtLabelWidth);
                            GUILayout.EndHorizontal();
                        }
                    } catch (Exception e) {
                        LogUtil.Debug("failed to display resource info.", e);
                    }
                }

                nameChanged = false;
            } finally {
                GUILayout.EndVertical();
                GUILayout.EndScrollView();
            }


            GUILayout.BeginHorizontal();
            GUILayout.Space(uiParams.marginL);
            ignoreExist = !GUILayout.Toggle(!ignoreExist, "登録済確認", uiParams.tStyleS, uiParams.optToggleSWidth);
            if (GUILayout.Button("保存", uiParams.bStyle))
            {
                if (IsWritable(trgtMenu, ignoreExist))
                {
                    if (SaveFiles(trgtMenu))
                    {
                        var logmsg = "エクスポートが完了しました。出力先=" + fileUtil.GetACCDirectory(trgtMenu.editfile);
                        NUty.WinMessageBox(NUty.GetWindowHandle(), logmsg, "情報", NUty.MSGBOX.MB_OK);
                        //showDialog = false;
                    }
                }
                else
                {
                    const string logmsg = "出力ファイルが登録済みか重複が存在するため、保存処理を行いませんでした。";
                    NUty.WinMessageBox(NUty.GetWindowHandle(), logmsg, "エラー", NUty.MSGBOX.MB_OK);
                }
            }
            if (GUILayout.Button("閉じる", uiParams.bStyle))
            {
                showDialog = false;
            }
            GUILayout.Space(uiParams.marginL);
            GUILayout.EndHorizontal();
        }
        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();
            }
        }