Kaynağa Gözat

Project window rename works

Marko Pintera 10 yıl önce
ebeveyn
işleme
402b8f9953
2 değiştirilmiş dosya ile 24 ekleme ve 12 silme
  1. 20 7
      MBansheeEditor/ProjectWindow.cs
  2. 4 5
      TODO.txt

+ 20 - 7
MBansheeEditor/ProjectWindow.cs

@@ -229,6 +229,9 @@ namespace BansheeEditor
                 renameTextBox.Bounds = label.Bounds;
                 renameTextBox.Bounds = label.Bounds;
                 info.overlay.AddElement(renameTextBox);
                 info.overlay.AddElement(renameTextBox);
 
 
+                string name = Path.GetFileNameWithoutExtension(PathEx.GetTail(path));
+                renameTextBox.Text = name;
+
                 label.Visible = false;
                 label.Visible = false;
             }
             }
 
 
@@ -696,9 +699,13 @@ namespace BansheeEditor
             }
             }
             else
             else
             {
             {
-                SetSelection(new List<string>() { path });
-                selectionAnchorStart = entry.index;
-                selectionAnchorEnd = entry.index;
+                if (!selectionPaths.Contains(path))
+                {
+                    SetSelection(new List<string>() {path});
+
+                    selectionAnchorStart = entry.index;
+                    selectionAnchorEnd = entry.index;
+                }
             }
             }
         }
         }
 
 
@@ -975,8 +982,10 @@ namespace BansheeEditor
                         string newName = inProgressRenameElement.GetRenamedName();
                         string newName = inProgressRenameElement.GetRenamedName();
 
 
                         string originalPath = inProgressRenameElement.path;
                         string originalPath = inProgressRenameElement.path;
-                            string newPath = Path.GetDirectoryName(originalPath);
-                            newPath = Path.Combine(newPath, newName + Path.GetExtension(originalPath));
+                        originalPath = originalPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
+
+                        string newPath = Path.GetDirectoryName(originalPath);
+                        newPath = Path.Combine(newPath, newName + Path.GetExtension(originalPath));
 
 
                         bool renameOK = true;
                         bool renameOK = true;
                         if (!PathEx.IsValidFileName(newName))
                         if (!PathEx.IsValidFileName(newName))
@@ -987,7 +996,11 @@ namespace BansheeEditor
 
 
                         if (renameOK)
                         if (renameOK)
                         {
                         {
-                            if (ProjectLibrary.Exists(newPath))
+                            // Windows sees paths with dot at the end as if they didn't have it
+                            // so remove the dot to ensure the project library does the same
+                            string trimmedNewPath = newPath.TrimEnd('.');
+
+                            if (originalPath != trimmedNewPath && ProjectLibrary.Exists(trimmedNewPath))
                             {
                             {
                                 DialogBox.Open("Error", "File/folder with that name already exists in this folder.", DialogBox.Type.OK);
                                 DialogBox.Open("Error", "File/folder with that name already exists in this folder.", DialogBox.Type.OK);
                                 renameOK = false;
                                 renameOK = false;
@@ -1484,7 +1497,7 @@ namespace BansheeEditor
             }
             }
 
 
             ElementEntry entry;
             ElementEntry entry;
-            if (entryLookup.TryGetValue(pingPath, out entry))
+            if (entryLookup.TryGetValue(selectionPaths[0], out entry))
             {
             {
                 entry.StartRename();
                 entry.StartRename();
                 inProgressRenameElement = entry;
                 inProgressRenameElement = entry;

+ 4 - 5
TODO.txt

@@ -27,14 +27,14 @@ return them in checkForModifications?
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 Project window
 Project window
 
 
-Test rename & delete
+Test rename
 
 
 Later:
 Later:
  - Hook up ping effect so it triggers when I select a resource or sceneobject
  - Hook up ping effect so it triggers when I select a resource or sceneobject
   - Add ping to SceneTreeView
   - Add ping to SceneTreeView
  - Consider delaying search until user stops pressing keys (so not to have thousands of search results in the initial stages)
  - Consider delaying search until user stops pressing keys (so not to have thousands of search results in the initial stages)
  - Save & restore scroll position when Refresh happens
  - Save & restore scroll position when Refresh happens
- - Center labels and add a couple of pixels border from the selection rectangle
+ - Center labels and add a couple of pixels border from the selection rectangle (add special style since MultiLineLabel is used by other code)
 
 
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 Resources
 Resources
@@ -57,9 +57,6 @@ Resources
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 Simple stuff
 Simple stuff
 
 
-When cursor moves from input box to title bar it remains an input cursor (assuming this is because the non-client area)
-
-Other simple stuff:
  - Inject an icon into an .exe (Win32 specific)
  - Inject an icon into an .exe (Win32 specific)
  - C# wrapper for GUISkin (and a way to assign the current skin to a window)
  - C# wrapper for GUISkin (and a way to assign the current skin to a window)
  - Move all the code files into subfolders so their hierarchy is similar to VS filters
  - Move all the code files into subfolders so their hierarchy is similar to VS filters
@@ -118,6 +115,8 @@ Issue happened when I closed the app via the X button (if that's relevant). It d
 Create a stack allocatable custom vector implementation and make getResourceDependencies and getCoreDependencies use it.
 Create a stack allocatable custom vector implementation and make getResourceDependencies and getCoreDependencies use it.
  - These methods are called often and cause allocations whenever they are.
  - These methods are called often and cause allocations whenever they are.
 
 
+I shouldn't crash the app when a managed exception happens
+
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 Multi-resource saving
 Multi-resource saving
  - Modify Font so it doesn't contain a texture, but instead keeps a handle to it
  - Modify Font so it doesn't contain a texture, but instead keeps a handle to it