Ejemplo n.º 1
0
        /// <summary>
        /// Creates the context menu used by project library window. New context menu must be created when a new instance
        /// of the project library window is created.
        /// </summary>
        /// <param name="win">Instance of the project library window.</param>
        /// <returns>Context menu bound to the specified instance of the project library window.</returns>
        internal static ContextMenu CreateContextMenu(LibraryWindow win)
        {
            ContextMenu entryContextMenu = new ContextMenu();

            entryContextMenu.AddItem("Create", null);
            entryContextMenu.AddItem("Create/Folder", CreateFolder);
            entryContextMenu.AddItem("Create/Material", CreateEmptyMaterial);
            entryContextMenu.AddItem("Create/Physics material", CreateEmptyPhysicsMaterial);
            entryContextMenu.AddItem("Create/Shader", CreateEmptyShader);
            entryContextMenu.AddItem("Create/C# script", CreateEmptyCSScript);
            entryContextMenu.AddItem("Create/Sprite texture", CreateEmptySpriteTexture);
            entryContextMenu.AddItem("Create/GUI skin", CreateEmptyGUISkin);
            entryContextMenu.AddItem("Create/String table", CreateEmptyStringTable);
            entryContextMenu.AddSeparator("");
            entryContextMenu.AddItem("Rename", win.RenameSelection, new ShortcutKey(ButtonModifier.None, ButtonCode.F2));
            entryContextMenu.AddSeparator("");
            entryContextMenu.AddItem("Cut", win.CutSelection, new ShortcutKey(ButtonModifier.Ctrl, ButtonCode.X));
            entryContextMenu.AddItem("Copy", win.CopySelection, new ShortcutKey(ButtonModifier.Ctrl, ButtonCode.C));
            entryContextMenu.AddItem("Duplicate", win.DuplicateSelection, new ShortcutKey(ButtonModifier.Ctrl, ButtonCode.D));
            entryContextMenu.AddItem("Paste", win.PasteToSelection, new ShortcutKey(ButtonModifier.Ctrl, ButtonCode.V));
            entryContextMenu.AddSeparator("");
            entryContextMenu.AddItem("Delete", win.DeleteSelection, new ShortcutKey(ButtonModifier.None, ButtonCode.Delete));
            entryContextMenu.AddSeparator("");
            entryContextMenu.AddItem("Open externally", OpenExternally);
            entryContextMenu.AddItem("Explore location", ExploreLocation);

            entryContextMenu.SetLocalizedName("Rename", new LocEdString("Rename"));
            entryContextMenu.SetLocalizedName("Cut", new LocEdString("Cut"));
            entryContextMenu.SetLocalizedName("Copy", new LocEdString("Copy"));
            entryContextMenu.SetLocalizedName("Duplicate", new LocEdString("Duplicate"));
            entryContextMenu.SetLocalizedName("Paste", new LocEdString("Paste"));
            entryContextMenu.SetLocalizedName("Delete", new LocEdString("Delete"));

            return(entryContextMenu);
        }
Ejemplo n.º 2
0
        internal static void CreateEmptyMaterial()
        {
            LibraryWindow win = EditorWindow.GetWindow <LibraryWindow>();

            if (win == null)
            {
                return;
            }

            LibraryUtility.CreateEmptyMaterial(win.SelectedFolder);
        }
Ejemplo n.º 3
0
        internal static void ExploreLocation()
        {
            LibraryWindow win = EditorWindow.GetWindow <LibraryWindow>();

            if (win == null)
            {
                return;
            }

            EditorApplication.OpenExternally(Path.Combine(ProjectLibrary.ResourceFolder, win.CurrentFolder));
        }
Ejemplo n.º 4
0
        internal static void OpenExternally()
        {
            LibraryWindow win = EditorWindow.GetWindow <LibraryWindow>();

            if (win == null)
            {
                return;
            }

            EditorApplication.OpenExternally(Path.Combine(ProjectLibrary.ResourceFolder, win.SelectedEntry));
        }
Ejemplo n.º 5
0
        internal static void CreateFolder()
        {
            LibraryWindow win = EditorWindow.GetWindow <LibraryWindow>();

            if (win == null)
            {
                return;
            }

            string path = LibraryUtility.CreateFolder(win.SelectedFolder);

            StartRename(path, win);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Scrolls to and selects the specified resource path then start a rename operation.
        /// </summary>
        /// <param name="path">Path to the resource to rename</param>
        /// <param name="window">Reference to the library window</param>
        private static void StartRename(string path, LibraryWindow window)
        {
            if (window == null)
            {
                return;
            }

            window.Refresh();
            window.HasFocus = true;
            window.GoToEntry(path);
            window.Select(path);
            window.RenameSelection();
        }
 /// <summary>
 /// Executes when the mouse left button is up on the saved page button
 /// </summary>
 /// <param name="sender">Event sender</param>
 /// <param name="e">Event args</param>
 private void SavedPagesBtn_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     // In case Library window is not running
     if (!LibraryWindow.IsRunning)
     {
         var window = new LibraryWindow();
         window.Show();
         System.Windows.Threading.Dispatcher.Run();
     }
     // In case preference window is already running
     else
     {
         LibraryWindow.CurrentRunningWindow.Focus();
     }
 }
Ejemplo n.º 8
0
        public LibraryLocation(LibraryWindow window, MediaRepository repository)
        {
            InitializeComponent();
            Controller = new LibraryLocationController(this);
            MediaRepository = repository;
            Window = window;

            LocationLabel.Content = repository.Location;

            var size = repository.MediaFiles.Sum(x => x.Size);
            SizeLabel.Content = size.FormatBytes();

            CountLabel.Content = repository.MediaFiles.Count.ToString("N");

            RemoveLocationButton.Click += RemoveLocationButtonClick;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Unloads the currently loaded project. Offers the user a chance to save the current scene if it is modified.
        /// Automatically saves all project data before unloading.
        /// </summary>
        private static void UnloadProject()
        {
            Action continueUnload =
                () =>
            {
                Scene.Clear();

                if (monitor != null)
                {
                    monitor.Destroy();
                    monitor = null;
                }

                LibraryWindow window = EditorWindow.GetWindow <LibraryWindow>();
                if (window != null)
                {
                    window.Reset();
                }

                SetSceneDirty(false);
                Internal_UnloadProject();
                SetStatusProject(false);
            };

            Action <DialogBox.ResultType> dialogCallback =
                (result) =>
            {
                if (result == DialogBox.ResultType.Yes)
                {
                    SaveScene();
                }

                continueUnload();
            };

            if (IsSceneModified())
            {
                DialogBox.Open("Warning", "You current scene has modifications. Do you wish to save them first?",
                               DialogBox.Type.YesNoCancel, dialogCallback);
            }
            else
            {
                continueUnload();
            }
        }
Ejemplo n.º 10
0
 public static void Duplicate()
 {
     if (Selection.SceneObjects != null && Selection.SceneObjects.Length > 0)
     {
         HierarchyWindow win = EditorWindow.GetWindow <HierarchyWindow>();
         if (win != null)
         {
             win.DuplicateSelection();
         }
     }
     else if (Selection.ResourcePaths != null && Selection.ResourcePaths.Length > 0)
     {
         LibraryWindow win = EditorWindow.GetWindow <LibraryWindow>();
         if (win != null)
         {
             win.DuplicateSelection();
         }
     }
 }
Ejemplo n.º 11
0
        public static void Paste()
        {
            // TODO - This is slightly wrong in case both windows have something in their paste buffer (unify them?)

            {
                HierarchyWindow win = EditorWindow.GetWindow <HierarchyWindow>();
                if (win != null)
                {
                    win.PasteToSelection();
                }
            }

            {
                LibraryWindow win = EditorWindow.GetWindow <LibraryWindow>();
                if (win != null)
                {
                    win.PasteToSelection();
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Unloads the currently loaded project, without making any checks or requiring confirmation.
        /// </summary>
        private static void UnloadProject()
        {
            Scene.Clear();

            if (monitor != null)
            {
                monitor.Destroy();
                monitor = null;
            }

            LibraryWindow window = EditorWindow.GetWindow <LibraryWindow>();

            if (window != null)
            {
                window.Reset();
            }

            SetSceneDirty(false);
            Internal_UnloadProject();
            SetStatusProject(false);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Manually triggers a global shortcut.
        /// </summary>
        /// <param name="btn">Button for the shortcut. If this doesn't correspond to any shortcut, it is ignored.</param>
        internal static void TriggerGlobalShortcut(VirtualButton btn)
        {
            IGlobalShortcuts window = null;

            if (btn != PasteKey)
            {
                // The system ensures elsewhere that only either a resource or a scene object is selected, but not both
                if (Selection.ResourcePaths.Length > 0)
                {
                    window = EditorWindow.GetWindow <LibraryWindow>();
                }
                else if (Selection.SceneObjects.Length > 0)
                {
                    window = EditorWindow.GetWindow <HierarchyWindow>();
                    if (window == null)
                    {
                        window = EditorWindow.GetWindow <SceneWindow>();
                    }
                }

                if (window != null)
                {
                    if (btn == CopyKey)
                    {
                        window.OnCopyPressed();
                    }
                    else if (btn == CutKey)
                    {
                        window.OnCutPressed();
                    }
                    else if (btn == PasteKey)
                    {
                        window.OnPastePressed();
                    }
                    else if (btn == DuplicateKey)
                    {
                        window.OnDuplicatePressed();
                    }
                    else if (btn == RenameKey)
                    {
                        window.OnRenamePressed();
                    }
                    else if (btn == DeleteKey)
                    {
                        window.OnDeletePressed();
                    }
                }
            }
            else
            {
                HierarchyWindow hierarchy = EditorWindow.GetWindow <HierarchyWindow>();
                if (hierarchy != null && hierarchy.HasFocus)
                {
                    window = hierarchy;
                }
                else
                {
                    LibraryWindow library = EditorWindow.GetWindow <LibraryWindow>();
                    if (library != null && library.HasFocus)
                    {
                        window = library;
                    }
                }

                if (window != null)
                {
                    window.OnPastePressed();
                }
            }
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Constructs a new GUI library content object.
 /// </summary>
 /// <param name="window">Parent window the content area is part of.</param>
 /// <param name="parent">Scroll area the content area is part of.</param>
 public LibraryGUIContent(LibraryWindow window, GUIScrollArea parent)
 {
     this.window = window;
     this.parent = parent;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before
        /// use.
        /// </summary>
        /// <param name="parent">Libary window that this drop down window is a part of.</param>
        internal void Initialize(LibraryWindow parent)
        {
            this.parent = parent;

            GUIToggleGroup group = new GUIToggleGroup();

            GUIToggle list16 = new GUIToggle(new LocEdString("16"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
            GUIToggle grid32 = new GUIToggle(new LocEdString("32"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
            GUIToggle grid48 = new GUIToggle(new LocEdString("48"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
            GUIToggle grid64 = new GUIToggle(new LocEdString("64"), group, EditorStyles.Button, GUIOption.FixedWidth(30));

            ProjectViewType activeType = parent.ViewType;

            switch (activeType)
            {
            case ProjectViewType.List16:
                list16.Value = true;
                break;

            case ProjectViewType.Grid32:
                grid32.Value = true;
                break;

            case ProjectViewType.Grid48:
                grid48.Value = true;
                break;

            case ProjectViewType.Grid64:
                grid64.Value = true;
                break;
            }

            list16.OnToggled += (active) =>
            {
                if (active)
                {
                    ChangeViewType(ProjectViewType.List16);
                }
            };

            grid32.OnToggled += (active) =>
            {
                if (active)
                {
                    ChangeViewType(ProjectViewType.Grid32);
                }
            };

            grid48.OnToggled += (active) =>
            {
                if (active)
                {
                    ChangeViewType(ProjectViewType.Grid48);
                }
            };

            grid64.OnToggled += (active) =>
            {
                if (active)
                {
                    ChangeViewType(ProjectViewType.Grid64);
                }
            };

            GUILayoutY vertLayout = GUI.AddLayoutY();

            vertLayout.AddFlexibleSpace();
            GUILayoutX contentLayout = vertLayout.AddLayoutX();

            contentLayout.AddFlexibleSpace();
            contentLayout.AddElement(list16);
            contentLayout.AddElement(grid32);
            contentLayout.AddElement(grid48);
            contentLayout.AddElement(grid64);
            contentLayout.AddFlexibleSpace();
            vertLayout.AddFlexibleSpace();
        }