Explorar el Código

Current library folder now persists assembly refresh

BearishSun hace 10 años
padre
commit
d13799bfd9

+ 1 - 1
MBansheeEditor/GameWindow.cs

@@ -59,7 +59,7 @@ namespace BansheeEditor
         /// Moves the execution of the game by one frame forward.
         /// Moves the execution of the game by one frame forward.
         /// </summary>
         /// </summary>
         [MenuItem("Tools/Step", 9298)]
         [MenuItem("Tools/Step", 9298)]
-        [ToolbarItem("Step", ToolbarIcon.Step, "Framestep", 1798)]
+        [ToolbarItem("Step", ToolbarIcon.Step, "Frame step", 1798)]
         private static void Step()
         private static void Step()
         {
         {
             EditorApplication.FrameStep();
             EditorApplication.FrameStep();

+ 4 - 4
MBansheeEditor/Library/LibraryMenu.cs

@@ -74,7 +74,7 @@ namespace BansheeEditor
         /// Creates a new material with the default shader in the currently selected project library folder.
         /// Creates a new material with the default shader in the currently selected project library folder.
         /// </summary>
         /// </summary>
         [MenuItem("Resources/Create/Material", 9050, false, "IsLibraryWindowActive")]
         [MenuItem("Resources/Create/Material", 9050, false, "IsLibraryWindowActive")]
-        [ToolbarItem("Material", ToolbarIcon.NewMat, "New material.", 1498)]
+        [ToolbarItem("Material", ToolbarIcon.NewMat, "New material", 1498)]
         internal static void CreateEmptyMaterial()
         internal static void CreateEmptyMaterial()
         {
         {
             LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
             LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
@@ -88,7 +88,7 @@ namespace BansheeEditor
         /// Creates a new shader containing a rough code outline in the currently selected project library folder.
         /// Creates a new shader containing a rough code outline in the currently selected project library folder.
         /// </summary>
         /// </summary>
         [MenuItem("Resources/Create/Shader", 9049, false, "IsLibraryWindowActive")]
         [MenuItem("Resources/Create/Shader", 9049, false, "IsLibraryWindowActive")]
-        [ToolbarItem("Shader", ToolbarIcon.NewShader, "New shader.", 1499)]
+        [ToolbarItem("Shader", ToolbarIcon.NewShader, "New shader", 1499)]
         internal static void CreateEmptyShader()
         internal static void CreateEmptyShader()
         {
         {
             LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
             LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
@@ -102,7 +102,7 @@ namespace BansheeEditor
         /// Creates a new C# script containing a rough code outline in the currently selected project library folder.
         /// Creates a new C# script containing a rough code outline in the currently selected project library folder.
         /// </summary>
         /// </summary>
         [MenuItem("Resources/Create/C# script", 9048, false, "IsLibraryWindowActive")]
         [MenuItem("Resources/Create/C# script", 9048, false, "IsLibraryWindowActive")]
-        [ToolbarItem("C# script", ToolbarIcon.NewCSScript, "New C# script.", 1500, true)]
+        [ToolbarItem("C# script", ToolbarIcon.NewCSScript, "New C# script", 1500, true)]
         internal static void CreateEmptyCSScript()
         internal static void CreateEmptyCSScript()
         {
         {
             LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
             LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
@@ -116,7 +116,7 @@ namespace BansheeEditor
         /// Creates a new empty sprite texture in the currently selected project library folder.
         /// Creates a new empty sprite texture in the currently selected project library folder.
         /// </summary>
         /// </summary>
         [MenuItem("Resources/Create/Sprite texture", 9047, false, "IsLibraryWindowActive")]
         [MenuItem("Resources/Create/Sprite texture", 9047, false, "IsLibraryWindowActive")]
-        [ToolbarItem("Sprite texture", ToolbarIcon.NewSpriteTex, "New sprite texture.", 1497)]
+        [ToolbarItem("Sprite texture", ToolbarIcon.NewSpriteTex, "New sprite texture", 1497)]
         internal static void CreateEmptySpriteTexture()
         internal static void CreateEmptySpriteTexture()
         {
         {
             LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
             LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();

+ 23 - 21
MBansheeEditor/Library/LibraryWindow.cs

@@ -32,7 +32,8 @@ namespace BansheeEditor
         private const int DRAG_SCROLL_AMOUNT_PER_SECOND = 100;
         private const int DRAG_SCROLL_AMOUNT_PER_SECOND = 100;
         private const int FOLDER_BUTTON_WIDTH = 30;
         private const int FOLDER_BUTTON_WIDTH = 30;
         private const int FOLDER_SEPARATOR_WIDTH = 10;
         private const int FOLDER_SEPARATOR_WIDTH = 10;
-        
+        private const string CURRENT_LIBRARY_DIRECTORY_KEY = "__CurrentLibDir";
+
         private bool hasContentFocus = false;
         private bool hasContentFocus = false;
         private bool HasContentFocus { get { return HasFocus && hasContentFocus; } }
         private bool HasContentFocus { get { return HasFocus && hasContentFocus; } }
 
 
@@ -42,7 +43,6 @@ namespace BansheeEditor
         private ProjectViewType viewType = ProjectViewType.Grid32;
         private ProjectViewType viewType = ProjectViewType.Grid32;
 
 
         private bool requiresRefresh;
         private bool requiresRefresh;
-        private string currentDirectory = "";
         private List<string> selectionPaths = new List<string>();
         private List<string> selectionPaths = new List<string>();
         private int selectionAnchorStart = -1;
         private int selectionAnchorStart = -1;
         private int selectionAnchorEnd = -1;
         private int selectionAnchorEnd = -1;
@@ -96,7 +96,7 @@ namespace BansheeEditor
                         return entry.Path;
                         return entry.Path;
                 }
                 }
 
 
-                return currentDirectory;
+                return CurrentFolder;
             }
             }
         }
         }
 
 
@@ -119,7 +119,7 @@ namespace BansheeEditor
                 if (selectedDirectory != null)
                 if (selectedDirectory != null)
                     return selectedDirectory.Path;
                     return selectedDirectory.Path;
                 
                 
-                return currentDirectory;
+                return CurrentFolder;
             }
             }
         }
         }
 
 
@@ -129,7 +129,8 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         public string CurrentFolder
         public string CurrentFolder
         {
         {
-            get { return currentDirectory; }
+            get { return ProjectSettings.GetString(CURRENT_LIBRARY_DIRECTORY_KEY); }
+            set { ProjectSettings.SetString(CURRENT_LIBRARY_DIRECTORY_KEY, value); }
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -197,8 +198,8 @@ namespace BansheeEditor
 
 
             entryContextMenu = LibraryMenu.CreateContextMenu(this);
             entryContextMenu = LibraryMenu.CreateContextMenu(this);
             content = new LibraryGUIContent(this, contentScrollArea);
             content = new LibraryGUIContent(this, contentScrollArea);
-            
-            Reset();
+
+            Refresh();
 
 
             dropTarget = new LibraryDropTarget(this);
             dropTarget = new LibraryDropTarget(this);
             dropTarget.Bounds = GetScrollAreaBounds();
             dropTarget.Bounds = GetScrollAreaBounds();
@@ -262,7 +263,7 @@ namespace BansheeEditor
                     }
                     }
                     else if (Input.IsButtonDown(ButtonCode.Back))
                     else if (Input.IsButtonDown(ButtonCode.Back))
                     {
                     {
-                        LibraryEntry entry = ProjectLibrary.GetEntry(currentDirectory);
+                        LibraryEntry entry = ProjectLibrary.GetEntry(CurrentFolder);
                         if (entry != null && entry.Parent != null)
                         if (entry != null && entry.Parent != null)
                         {
                         {
                             EnterDirectory(entry.Parent.Path);
                             EnterDirectory(entry.Parent.Path);
@@ -412,7 +413,7 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         public void Reset()
         public void Reset()
         {
         {
-            currentDirectory = ProjectLibrary.Root.Path;
+            CurrentFolder = ProjectLibrary.Root.Path;
             selectionAnchorStart = -1;
             selectionAnchorStart = -1;
             selectionAnchorEnd = -1;
             selectionAnchorEnd = -1;
             selectionPaths.Clear();
             selectionPaths.Clear();
@@ -616,7 +617,7 @@ namespace BansheeEditor
         /// <param name="directory">Project library path to the directory.</param>
         /// <param name="directory">Project library path to the directory.</param>
         internal void EnterDirectory(string directory)
         internal void EnterDirectory(string directory)
         {
         {
-            currentDirectory = directory;
+            CurrentFolder = directory;
             DeselectAll(true);
             DeselectAll(true);
 
 
             Refresh();
             Refresh();
@@ -756,11 +757,11 @@ namespace BansheeEditor
             }
             }
             else
             else
             {
             {
-                DirectoryEntry entry = ProjectLibrary.GetEntry(currentDirectory) as DirectoryEntry;
+                DirectoryEntry entry = ProjectLibrary.GetEntry(CurrentFolder) as DirectoryEntry;
                 if (entry == null)
                 if (entry == null)
                 {
                 {
-                    currentDirectory = ProjectLibrary.Root.Path;
-                    entry = ProjectLibrary.GetEntry(currentDirectory) as DirectoryEntry;
+                    CurrentFolder = ProjectLibrary.Root.Path;
+                    entry = ProjectLibrary.GetEntry(CurrentFolder) as DirectoryEntry;
                 }
                 }
 
 
                 if(entry != null)
                 if(entry != null)
@@ -975,7 +976,7 @@ namespace BansheeEditor
             }
             }
             else
             else
             {
             {
-                string currentDir = Path.Combine("Resources", currentDirectory);
+                string currentDir = Path.Combine("Resources", CurrentFolder);
 
 
                 folders = currentDir.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar },
                 folders = currentDir.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar },
                     StringSplitOptions.RemoveEmptyEntries);
                     StringSplitOptions.RemoveEmptyEntries);
@@ -1277,7 +1278,7 @@ namespace BansheeEditor
                 return;
                 return;
 
 
             string resourceDir = ProjectLibrary.ResourceFolder;
             string resourceDir = ProjectLibrary.ResourceFolder;
-            string destinationFolder = Path.Combine(resourceDir, currentDirectory);
+            string destinationFolder = Path.Combine(resourceDir, CurrentFolder);
 
 
             LibraryGUIEntry underCursorElement = FindElementAt(windowPos);
             LibraryGUIEntry underCursorElement = FindElementAt(windowPos);
             if (underCursorElement != null)
             if (underCursorElement != null)
@@ -1352,7 +1353,7 @@ namespace BansheeEditor
             if (EndDragSelection())
             if (EndDragSelection())
                 return;
                 return;
 
 
-            string destinationFolder = currentDirectory;
+            string destinationFolder = CurrentFolder;
 
 
             LibraryGUIEntry underCursorElement = FindElementAt(windowPos);
             LibraryGUIEntry underCursorElement = FindElementAt(windowPos);
             if (underCursorElement != null)
             if (underCursorElement != null)
@@ -1438,7 +1439,7 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         private void OnHomeClicked()
         private void OnHomeClicked()
         {
         {
-            currentDirectory = ProjectLibrary.Root.Path;
+            CurrentFolder = ProjectLibrary.Root.Path;
             Refresh();
             Refresh();
         }
         }
 
 
@@ -1448,13 +1449,14 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         private void OnUpClicked()
         private void OnUpClicked()
         {
         {
-            currentDirectory = currentDirectory.Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
+            string currentDir = CurrentFolder;
+            currentDir = currentDir.Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
 
 
-            if (!string.IsNullOrEmpty(currentDirectory))
+            if (!string.IsNullOrEmpty(currentDir))
             {
             {
-                string parent = Path.GetDirectoryName(currentDirectory);
+                string parent = Path.GetDirectoryName(currentDir);
 
 
-                currentDirectory = parent;
+                CurrentFolder = parent;
                 Refresh();
                 Refresh();
             }
             }
         }
         }

+ 6 - 6
MBansheeEditor/MenuItems.cs

@@ -96,7 +96,7 @@ namespace BansheeEditor
         /// Creates a new empty scene object.
         /// Creates a new empty scene object.
         /// </summary>
         /// </summary>
         [MenuItem("Scene Objects/Scene Object", 8051)]
         [MenuItem("Scene Objects/Scene Object", 8051)]
-        [ToolbarItem("SceneObject", ToolbarIcon.NewSceneObject, "Creates a new empty scene object.", 1601, true)]
+        [ToolbarItem("SceneObject", ToolbarIcon.NewSceneObject, "Creates a new empty scene object", 1601, true)]
         private static void AddEmptySO()
         private static void AddEmptySO()
         {
         {
             SceneObject so = UndoRedo.CreateSO("SceneObject", "New scene object");
             SceneObject so = UndoRedo.CreateSO("SceneObject", "New scene object");
@@ -168,7 +168,7 @@ namespace BansheeEditor
         /// Creates a new scene object with a directional light component.
         /// Creates a new scene object with a directional light component.
         /// </summary>
         /// </summary>
         [MenuItem("Scene Objects/Directional light", 8046)]
         [MenuItem("Scene Objects/Directional light", 8046)]
-        [ToolbarItem("Directional light", ToolbarIcon.NewDirLight, "New directional light.", 1596)]
+        [ToolbarItem("Directional light", ToolbarIcon.NewDirLight, "New directional light", 1596)]
         private static void AddDirectionalLightSO()
         private static void AddDirectionalLightSO()
         {
         {
             SceneObject so = UndoRedo.CreateSO("Directional light", "Created a Light");
             SceneObject so = UndoRedo.CreateSO("Directional light", "Created a Light");
@@ -183,7 +183,7 @@ namespace BansheeEditor
         /// Creates a new scene object with a box primitive.
         /// Creates a new scene object with a box primitive.
         /// </summary>
         /// </summary>
         [MenuItem("Scene Objects/3D primitives/Box", 8100)]
         [MenuItem("Scene Objects/3D primitives/Box", 8100)]
-        [ToolbarItem("Cube", ToolbarIcon.NewCube, "Creates a scene object with a box primitive.", 1700, true)]
+        [ToolbarItem("Cube", ToolbarIcon.NewCube, "Creates a scene object with a box primitive", 1700, true)]
         private static void Add3DBox()
         private static void Add3DBox()
         {
         {
             SceneObject so = UndoRedo.CreateSO("Box", "Created a box");
             SceneObject so = UndoRedo.CreateSO("Box", "Created a box");
@@ -198,7 +198,7 @@ namespace BansheeEditor
         /// Creates a new scene object with a sphere primitive.
         /// Creates a new scene object with a sphere primitive.
         /// </summary>
         /// </summary>
         [MenuItem("Scene Objects/3D primitives/Sphere", 8099)]
         [MenuItem("Scene Objects/3D primitives/Sphere", 8099)]
-        [ToolbarItem("Sphere", ToolbarIcon.NewSphere, "Creates a scene object with a sphere primitive.", 1699)]
+        [ToolbarItem("Sphere", ToolbarIcon.NewSphere, "Creates a scene object with a sphere primitive", 1699)]
         private static void Add3DSphere()
         private static void Add3DSphere()
         {
         {
             SceneObject so = UndoRedo.CreateSO("Sphere", "Created a sphere");
             SceneObject so = UndoRedo.CreateSO("Sphere", "Created a sphere");
@@ -213,7 +213,7 @@ namespace BansheeEditor
         /// Creates a new scene object with a cone primitive.
         /// Creates a new scene object with a cone primitive.
         /// </summary>
         /// </summary>
         [MenuItem("Scene Objects/3D primitives/Cone", 8098)]
         [MenuItem("Scene Objects/3D primitives/Cone", 8098)]
-        [ToolbarItem("Cone", ToolbarIcon.NewCone, "Creates a scene object with a cone primitive.", 1698)]
+        [ToolbarItem("Cone", ToolbarIcon.NewCone, "Creates a scene object with a cone primitive", 1698)]
         private static void Add3DCone()
         private static void Add3DCone()
         {
         {
             SceneObject so = UndoRedo.CreateSO("Cone", "Created a cone");
             SceneObject so = UndoRedo.CreateSO("Cone", "Created a cone");
@@ -228,7 +228,7 @@ namespace BansheeEditor
         /// Creates a new scene object with a quad primitive.
         /// Creates a new scene object with a quad primitive.
         /// </summary>
         /// </summary>
         [MenuItem("Scene Objects/3D primitives/Quad", 8097)]
         [MenuItem("Scene Objects/3D primitives/Quad", 8097)]
-        [ToolbarItem("Quad", ToolbarIcon.NewQuad, "Creates a scene object with a quad primitive.", 1697)]
+        [ToolbarItem("Quad", ToolbarIcon.NewQuad, "Creates a scene object with a quad primitive", 1697)]
         private static void Add3DQuad()
         private static void Add3DQuad()
         {
         {
             SceneObject so = UndoRedo.CreateSO("Quad", "Created a quad");
             SceneObject so = UndoRedo.CreateSO("Quad", "Created a quad");