Ejemplo n.º 1
0
        private void SimpleLayout()
        {
            using (var scroll = new EditorGUILayout.ScrollViewScope(folderListScrollPos))
            {
                folderListScrollPos = scroll.scrollPosition;

                foreach (var folder in folderList.Where(x => x.ParentFolder is null).ToList())
                {
                    GatoGUILayout.FolderRowField(folder, langLibrary,
                                                 (f) => DropSubFolder(f),
                                                 () =>
                    {
                        foreach (var rootFolder in folderList.Where(x => x.ParentFolder is null))
                        {
                            MoveItem(folder, rootFolder);
                        }
                    },
Ejemplo n.º 2
0
        private void OnGUI()
        {
            if (editorWindowInfoList != null)
            {
                EditorGUILayout.Space();

                using (new EditorGUILayout.HorizontalScope())
                {
                    GUILayout.FlexibleSpace();

                    layoutType = (LayoutType)EditorGUILayout.EnumPopup(layoutType);

                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        lang = (Language)EditorGUILayout.EnumPopup(lang);

                        if (check.changed)
                        {
                            LoadLanguage(lang);
                        }
                    }

                    if (GUILayout.Button(langLibrary.allResetToDefault))
                    {
                        ReplaceMenuItem(editorWindowInfoList, true);
                    }
                }

                EditorGUILayout.Space();

                if (layoutType == LayoutType.Simple)
                {
                    SimpleLayout();
                }
                else
                {
                    AdvancedLayout();
                }

                EditorGUILayout.Space();

                if (GUILayout.Button(langLibrary.addFolder))
                {
                    folderListScrollPos.x = folderRect.width;

                    var newFolder = new EditorWindowFolder()
                    {
                        NameEdittable = true
                    };
                    folderList.Add(newFolder);
                }

                if (layoutType == LayoutType.Advanced)
                {
                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        if (GatoGUILayout.DropArea(langLibrary.dropSubFolder, langLibrary, EditorGUIUtility.singleLineHeight * 4f))
                        {
                            if (!(selectedItem is null) &&
                                !(selectedItem.ParentFolder is null) &&
                                selectedItem is EditorWindowFolder selectedFolder)
                            {
                                DropSubFolder(selectedFolder);
                                GUI.changed = true;
                            }
                        }

                        if (check.changed)
                        {
                            Repaint();
                        }
                    }
                }

                // ファイルだけの移動はできなくてもよいので一時削除
                //EditorGUILayout.Space();

                //EditorGUILayout.LabelField("Unallocated", EditorStyles.boldLabel);

                //using (var scroll = new EditorGUILayout.ScrollViewScope(unallocatedListScrollPos))
                //{
                //    unallocatedListScrollPos = scroll.scrollPosition;

                //    foreach (var editorWindowInfo in editorWindowInfoList)
                //    {
                //        if (!string.IsNullOrEmpty(editorWindowInfo.DestMenuItemPath)) continue;

                //        using (var check = new EditorGUI.ChangeCheckScope())
                //        {
                //            editorWindowInfo.Selected = GatoGUILayout.ToggleLabelArea(
                //                                            editorWindowInfo.Name,
                //                                            editorWindowInfo.Selected,
                //                                            Color.white, Color.grey);

                //            if (check.changed) Repaint();
                //        }
                //    }
                //}

                EditorGUILayout.Space();

                using (new EditorGUI.DisabledScope(!editorWindowInfoList.Any(x => x.HasChanged)))
                {
                    if (GUILayout.Button(langLibrary.showChanged))
                    {
                        foreach (var file in editorWindowInfoList.Where(x => x.HasChanged))
                        {
                            file.ParentFolder.ShowChildren();
                        }
                    }

                    if (GUILayout.Button(langLibrary.apply))
                    {
                        ReplaceMenuItem(editorWindowInfoList);
                    }

                    EditorGUILayout.Space();

                    if (GUILayout.Button(langLibrary.allRevert))
                    {
                        RevertAllMenuItem();
                    }
                }

                // マウスドラッグが終わったのですべて選択解除
                if (Event.current.type == EventType.MouseUp &&
                    !(selectedItem is null))
                {
                    selectedItem.Selected = false;
                    selectedItem          = null;
                }
            }
        }