Przeglądaj źródła

Fixes for ProjectWindow search bar and directory bar

Marko Pintera 10 lat temu
rodzic
commit
370bb06e76

+ 23 - 15
MBansheeEditor/ProjectWindow.cs

@@ -316,6 +316,7 @@ namespace BansheeEditor
         private GUIButton optionsButton;
         private GUIButton optionsButton;
         private GUILayout folderBarLayout;
         private GUILayout folderBarLayout;
         private GUILayout folderListLayout;
         private GUILayout folderListLayout;
+        private GUITextField searchField;
 
 
         private ContextMenu entryContextMenu;
         private ContextMenu entryContextMenu;
         private ProjectDropTarget dropTarget;
         private ProjectDropTarget dropTarget;
@@ -349,7 +350,7 @@ namespace BansheeEditor
             GUILayoutY contentLayout = GUI.AddLayoutY();
             GUILayoutY contentLayout = GUI.AddLayoutY();
 
 
             searchBarLayout = contentLayout.AddLayoutX();
             searchBarLayout = contentLayout.AddLayoutX();
-            GUITextField searchField = new GUITextField();
+            searchField = new GUITextField();
             searchField.OnChanged += OnSearchChanged;
             searchField.OnChanged += OnSearchChanged;
             GUIButton clearSearchBtn = new GUIButton("C");
             GUIButton clearSearchBtn = new GUIButton("C");
             clearSearchBtn.OnClick += ClearSearch;
             clearSearchBtn.OnClick += ClearSearch;
@@ -369,6 +370,7 @@ namespace BansheeEditor
 
 
             folderBarLayout.AddElement(homeButton);
             folderBarLayout.AddElement(homeButton);
             folderBarLayout.AddElement(upButton);
             folderBarLayout.AddElement(upButton);
+            folderBarLayout.AddSpace(10);
 
 
             contentScrollArea = new GUIScrollArea(GUIOption.FlexibleWidth(), GUIOption.FlexibleHeight());
             contentScrollArea = new GUIScrollArea(GUIOption.FlexibleWidth(), GUIOption.FlexibleHeight());
             contentLayout.AddElement(contentScrollArea);
             contentLayout.AddElement(contentScrollArea);
@@ -922,6 +924,8 @@ namespace BansheeEditor
             entryLookup.Clear();
             entryLookup.Clear();
             scrollAreaPanel = contentScrollArea.Layout.AddPanel();
             scrollAreaPanel = contentScrollArea.Layout.AddPanel();
 
 
+            RefreshDirectoryBar();
+
             if (entriesToDisplay.Length == 0)
             if (entriesToDisplay.Length == 0)
                 return;
                 return;
 
 
@@ -1013,8 +1017,6 @@ namespace BansheeEditor
             catchAll.OnFocusChanged += OnContentsFocusChanged;
             catchAll.OnFocusChanged += OnContentsFocusChanged;
 
 
             contentInfo.underlay.AddElement(catchAll);
             contentInfo.underlay.AddElement(catchAll);
-
-            RefreshDirectoryBar();
         }
         }
 
 
         private void RefreshDirectoryBar()
         private void RefreshDirectoryBar()
@@ -1033,21 +1035,23 @@ namespace BansheeEditor
             if (IsSearchActive)
             if (IsSearchActive)
             {
             {
                 folders = new[] {searchQuery};
                 folders = new[] {searchQuery};
-                fullPaths = new[] {""};
+                fullPaths = new[] { searchQuery };
             }
             }
             else
             else
             {
             {
-                folders = currentDirectory.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar },
+                string currentDir = Path.Combine("Resources", currentDirectory);
+
+                folders = currentDir.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar },
                     StringSplitOptions.RemoveEmptyEntries);
                     StringSplitOptions.RemoveEmptyEntries);
-                fullPaths = new string[folders.Length];
-            }
 
 
-            for (int i = 0; i < folders.Length; i++)
-            {
-                if (i == 0)
-                    fullPaths[i] = folders[i];
-                else
-                    fullPaths[i] = Path.Combine(fullPaths[i - 1], folders[i]);
+                fullPaths = new string[folders.Length];
+                for (int i = 0; i < folders.Length; i++)
+                {
+                    if (i == 0)
+                        fullPaths[i] = "";
+                    else
+                        fullPaths[i] = Path.Combine(fullPaths[i - 1], folders[i]);
+                }
             }
             }
 
 
             int availableWidth = folderBarLayout.Bounds.width - FOLDER_BUTTON_WIDTH * 2;
             int availableWidth = folderBarLayout.Bounds.width - FOLDER_BUTTON_WIDTH * 2;
@@ -1118,9 +1122,12 @@ namespace BansheeEditor
 
 
         private void OnUpClicked()
         private void OnUpClicked()
         {
         {
-            string parent = Path.GetDirectoryName(currentDirectory);
-            if (!string.IsNullOrEmpty(parent))
+            currentDirectory = currentDirectory.Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
+
+            if (!string.IsNullOrEmpty(currentDirectory))
             {
             {
+                string parent = Path.GetDirectoryName(currentDirectory);
+
                 currentDirectory = parent;
                 currentDirectory = parent;
                 Refresh();
                 Refresh();
             }
             }
@@ -1168,6 +1175,7 @@ namespace BansheeEditor
 
 
         private void ClearSearch()
         private void ClearSearch()
         {
         {
+            searchField.Value = "";
             searchQuery = "";
             searchQuery = "";
             Refresh();
             Refresh();
         }
         }

+ 7 - 4
SBansheeEditor/Source/BsScriptProjectLibrary.cpp

@@ -142,12 +142,15 @@ namespace BansheeEngine
 	{
 	{
 		WString strPattern = MonoUtil::monoToWString(pattern);
 		WString strPattern = MonoUtil::monoToWString(pattern);
 
 
-		ScriptArray typeArray(types);
 		Vector<UINT32> typeIds;
 		Vector<UINT32> typeIds;
-		for (UINT32 i = 0; i < typeArray.size(); i++)
+		if (types != nullptr)
 		{
 		{
-			UINT32 typeId = ScriptResource::getTypeIdFromType((ScriptResourceType)typeArray.get<UINT32>(i));
-			typeIds.push_back(typeId);
+			ScriptArray typeArray(types);
+			for (UINT32 i = 0; i < typeArray.size(); i++)
+			{
+				UINT32 typeId = ScriptResource::getTypeIdFromType((ScriptResourceType)typeArray.get<UINT32>(i));
+				typeIds.push_back(typeId);
+			}
 		}
 		}
 
 
 		Vector<ProjectLibrary::LibraryEntry*> foundEntries = ProjectLibrary::instance().search(strPattern, typeIds);
 		Vector<ProjectLibrary::LibraryEntry*> foundEntries = ProjectLibrary::instance().search(strPattern, typeIds);

+ 3 - 3
TODO.txt

@@ -29,11 +29,11 @@ TODO - Might need to handle overwritting better when importing/moving
 
 
 Simple tasks:
 Simple tasks:
  - Hook up scene view drag and drop instantiation
  - Hook up scene view drag and drop instantiation
- - Fix scroll to element
+ - Search should be case insensitive
+ - Search breaks when I type in *
+ - Search only works with exact matches but it should be more robust (append * to start/end automatically?)
 
 
 Test:
 Test:
- - Test search
- - Test directory bar
  - See how are elements and search results ordered (should be by name)
  - See how are elements and search results ordered (should be by name)
  - Cut/Copy/Paste/Duplicate
  - Cut/Copy/Paste/Duplicate
  - Ping scroll and effect
  - Ping scroll and effect