|
@@ -12,312 +12,6 @@ namespace BansheeEditor
|
|
|
|
|
|
|
|
internal sealed class ProjectWindow : EditorWindow
|
|
internal sealed class ProjectWindow : EditorWindow
|
|
|
{
|
|
{
|
|
|
- private class ContentInfo
|
|
|
|
|
- {
|
|
|
|
|
- public ContentInfo(ProjectWindow window, ProjectViewType viewType, int numEntries)
|
|
|
|
|
- {
|
|
|
|
|
- GUIPanel parentPanel = window.scrollAreaPanel;
|
|
|
|
|
-
|
|
|
|
|
- GUIPanel contentPanel = parentPanel.AddPanel(1);
|
|
|
|
|
- overlay = parentPanel.AddPanel(0);
|
|
|
|
|
- underlay = parentPanel.AddPanel(2);
|
|
|
|
|
- inputOverlay = parentPanel.AddPanel(-1);
|
|
|
|
|
-
|
|
|
|
|
- main = contentPanel.AddLayoutY();
|
|
|
|
|
-
|
|
|
|
|
- if (viewType == ProjectViewType.List16)
|
|
|
|
|
- {
|
|
|
|
|
- tileSize = 16;
|
|
|
|
|
- gridLayout = false;
|
|
|
|
|
- elementsPerRow = 1;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- switch (viewType)
|
|
|
|
|
- {
|
|
|
|
|
- case ProjectViewType.Grid64:
|
|
|
|
|
- tileSize = 64;
|
|
|
|
|
- break;
|
|
|
|
|
- case ProjectViewType.Grid48:
|
|
|
|
|
- tileSize = 48;
|
|
|
|
|
- break;
|
|
|
|
|
- case ProjectViewType.Grid32:
|
|
|
|
|
- tileSize = 32;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- gridLayout = true;
|
|
|
|
|
-
|
|
|
|
|
- Rect2I scrollBounds = window.contentScrollArea.Bounds;
|
|
|
|
|
- int availableWidth = scrollBounds.width;
|
|
|
|
|
-
|
|
|
|
|
- int elemSize = tileSize + GRID_ENTRY_SPACING;
|
|
|
|
|
- elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize;
|
|
|
|
|
- int numRows = MathEx.CeilToInt(numEntries / (float)elementsPerRow);
|
|
|
|
|
- int neededHeight = numRows * (elemSize);
|
|
|
|
|
-
|
|
|
|
|
- bool requiresScrollbar = neededHeight > scrollBounds.height;
|
|
|
|
|
- if (requiresScrollbar)
|
|
|
|
|
- {
|
|
|
|
|
- availableWidth -= window.contentScrollArea.ScrollBarWidth;
|
|
|
|
|
- elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- labelWidth = (availableWidth - (elementsPerRow + 1)*MIN_HORZ_SPACING) / elementsPerRow;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- this.window = window;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public GUILayout main;
|
|
|
|
|
- public GUIPanel overlay;
|
|
|
|
|
- public GUIPanel underlay;
|
|
|
|
|
- public GUIPanel inputOverlay;
|
|
|
|
|
-
|
|
|
|
|
- public ProjectWindow window;
|
|
|
|
|
- public int tileSize;
|
|
|
|
|
- public bool gridLayout;
|
|
|
|
|
-
|
|
|
|
|
- public int elementsPerRow;
|
|
|
|
|
- public int labelWidth;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private class ElementEntry
|
|
|
|
|
- {
|
|
|
|
|
- // Note: Order of these is relevant
|
|
|
|
|
- enum UnderlayState
|
|
|
|
|
- {
|
|
|
|
|
- None, Hovered, Selected, Pinged
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public int index;
|
|
|
|
|
- public string path;
|
|
|
|
|
- public GUITexture icon;
|
|
|
|
|
- public GUILabel label;
|
|
|
|
|
- public Rect2I bounds;
|
|
|
|
|
-
|
|
|
|
|
- private GUITexture underlay;
|
|
|
|
|
- private ContentInfo info;
|
|
|
|
|
- private UnderlayState underlayState;
|
|
|
|
|
- private GUITextBox renameTextBox;
|
|
|
|
|
-
|
|
|
|
|
- public ElementEntry(ContentInfo info, GUILayout parent, LibraryEntry entry, int index)
|
|
|
|
|
- {
|
|
|
|
|
- GUILayout entryLayout;
|
|
|
|
|
-
|
|
|
|
|
- if (info.gridLayout)
|
|
|
|
|
- entryLayout = parent.AddLayoutY();
|
|
|
|
|
- else
|
|
|
|
|
- entryLayout = parent.AddLayoutX();
|
|
|
|
|
-
|
|
|
|
|
- SpriteTexture iconTexture = GetIcon(entry);
|
|
|
|
|
-
|
|
|
|
|
- icon = new GUITexture(iconTexture, GUIImageScaleMode.ScaleToFit,
|
|
|
|
|
- true, GUIOption.FixedHeight(info.tileSize), GUIOption.FixedWidth(info.tileSize));
|
|
|
|
|
-
|
|
|
|
|
- label = null;
|
|
|
|
|
-
|
|
|
|
|
- if (info.gridLayout)
|
|
|
|
|
- {
|
|
|
|
|
- label = new GUILabel(entry.Name, EditorStyles.MultiLineLabelCentered,
|
|
|
|
|
- GUIOption.FixedWidth(info.labelWidth), GUIOption.FlexibleHeight(0, MAX_LABEL_HEIGHT));
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- label = new GUILabel(entry.Name);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- entryLayout.AddElement(icon);
|
|
|
|
|
- entryLayout.AddElement(label);
|
|
|
|
|
-
|
|
|
|
|
- this.info = info;
|
|
|
|
|
- this.index = index;
|
|
|
|
|
- this.path = entry.Path;
|
|
|
|
|
- this.bounds = new Rect2I();
|
|
|
|
|
- this.underlay = null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void Initialize()
|
|
|
|
|
- {
|
|
|
|
|
- bounds = icon.Bounds;
|
|
|
|
|
- Rect2I labelBounds = label.Bounds;
|
|
|
|
|
-
|
|
|
|
|
- bounds.x = MathEx.Min(bounds.x, labelBounds.x - SELECTION_EXTRA_WIDTH);
|
|
|
|
|
- bounds.y = MathEx.Min(bounds.y, labelBounds.y) - 5; // 5 - Just padding for better look
|
|
|
|
|
- bounds.width = MathEx.Max(bounds.x + bounds.width,
|
|
|
|
|
- labelBounds.x + labelBounds.width) - bounds.x + SELECTION_EXTRA_WIDTH;
|
|
|
|
|
- bounds.height = MathEx.Max(bounds.y + bounds.height,
|
|
|
|
|
- labelBounds.y + labelBounds.height) - bounds.y;
|
|
|
|
|
-
|
|
|
|
|
- ProjectWindow hoistedWindow = info.window;
|
|
|
|
|
- string hoistedPath = path;
|
|
|
|
|
-
|
|
|
|
|
- GUIButton overlayBtn = new GUIButton("", EditorStyles.Blank);
|
|
|
|
|
- overlayBtn.Bounds = bounds;
|
|
|
|
|
- overlayBtn.OnClick += () => hoistedWindow.OnEntryClicked(hoistedPath);
|
|
|
|
|
- overlayBtn.OnDoubleClick += () => hoistedWindow.OnEntryDoubleClicked(hoistedPath);
|
|
|
|
|
- overlayBtn.SetContextMenu(info.window.entryContextMenu);
|
|
|
|
|
-
|
|
|
|
|
- info.overlay.AddElement(overlayBtn);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public Rect2I Bounds
|
|
|
|
|
- {
|
|
|
|
|
- get { return bounds; }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void MarkAsCut(bool enable)
|
|
|
|
|
- {
|
|
|
|
|
- if (enable)
|
|
|
|
|
- icon.SetTint(CUT_COLOR);
|
|
|
|
|
- else
|
|
|
|
|
- icon.SetTint(Color.White);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void MarkAsSelected(bool enable)
|
|
|
|
|
- {
|
|
|
|
|
- if ((int)underlayState > (int) UnderlayState.Selected)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- if (enable)
|
|
|
|
|
- {
|
|
|
|
|
- CreateUnderlay();
|
|
|
|
|
- underlay.SetTint(SELECTION_COLOR);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- ClearUnderlay();
|
|
|
|
|
-
|
|
|
|
|
- underlayState = UnderlayState.Selected;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void MarkAsPinged(bool enable)
|
|
|
|
|
- {
|
|
|
|
|
- if ((int)underlayState > (int)UnderlayState.Pinged)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- if (enable)
|
|
|
|
|
- {
|
|
|
|
|
- CreateUnderlay();
|
|
|
|
|
- underlay.SetTint(PING_COLOR);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- ClearUnderlay();
|
|
|
|
|
-
|
|
|
|
|
- underlayState = UnderlayState.Pinged;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void MarkAsHovered(bool enable)
|
|
|
|
|
- {
|
|
|
|
|
- if ((int)underlayState > (int)UnderlayState.Hovered)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- if (enable)
|
|
|
|
|
- {
|
|
|
|
|
- CreateUnderlay();
|
|
|
|
|
- underlay.SetTint(HOVER_COLOR);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- ClearUnderlay();
|
|
|
|
|
-
|
|
|
|
|
- underlayState = UnderlayState.Hovered;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void StartRename()
|
|
|
|
|
- {
|
|
|
|
|
- if (renameTextBox != null)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- renameTextBox = new GUITextBox(false);
|
|
|
|
|
- renameTextBox.Bounds = label.Bounds;
|
|
|
|
|
- info.inputOverlay.AddElement(renameTextBox);
|
|
|
|
|
-
|
|
|
|
|
- string name = Path.GetFileNameWithoutExtension(PathEx.GetTail(path));
|
|
|
|
|
- renameTextBox.Text = name;
|
|
|
|
|
- renameTextBox.Focus = true;
|
|
|
|
|
-
|
|
|
|
|
- label.Visible = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void StopRename()
|
|
|
|
|
- {
|
|
|
|
|
- if (renameTextBox != null)
|
|
|
|
|
- {
|
|
|
|
|
- renameTextBox.Destroy();
|
|
|
|
|
- renameTextBox = null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- label.Visible = true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public string GetRenamedName()
|
|
|
|
|
- {
|
|
|
|
|
- if (renameTextBox != null)
|
|
|
|
|
- return renameTextBox.Text;
|
|
|
|
|
-
|
|
|
|
|
- return "";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void ClearUnderlay()
|
|
|
|
|
- {
|
|
|
|
|
- if (underlay != null)
|
|
|
|
|
- {
|
|
|
|
|
- underlay.Destroy();
|
|
|
|
|
- underlay = null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- underlayState = UnderlayState.None;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void CreateUnderlay()
|
|
|
|
|
- {
|
|
|
|
|
- if (underlay == null)
|
|
|
|
|
- {
|
|
|
|
|
- underlay = new GUITexture(Builtin.WhiteTexture);
|
|
|
|
|
- underlay.Bounds = Bounds;
|
|
|
|
|
-
|
|
|
|
|
- info.underlay.AddElement(underlay);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static SpriteTexture GetIcon(LibraryEntry entry)
|
|
|
|
|
- {
|
|
|
|
|
- if (entry.Type == LibraryEntryType.Directory)
|
|
|
|
|
- {
|
|
|
|
|
- return EditorBuiltin.FolderIcon;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- FileEntry fileEntry = (FileEntry)entry;
|
|
|
|
|
- switch (fileEntry.ResType)
|
|
|
|
|
- {
|
|
|
|
|
- case ResourceType.Font:
|
|
|
|
|
- return EditorBuiltin.FontIcon;
|
|
|
|
|
- case ResourceType.Mesh:
|
|
|
|
|
- return EditorBuiltin.MeshIcon;
|
|
|
|
|
- case ResourceType.Texture:
|
|
|
|
|
- return EditorBuiltin.TextureIcon;
|
|
|
|
|
- case ResourceType.PlainText:
|
|
|
|
|
- return EditorBuiltin.PlainTextIcon;
|
|
|
|
|
- case ResourceType.ScriptCode:
|
|
|
|
|
- return EditorBuiltin.ScriptCodeIcon;
|
|
|
|
|
- case ResourceType.SpriteTexture:
|
|
|
|
|
- return EditorBuiltin.SpriteTextureIcon;
|
|
|
|
|
- case ResourceType.Shader:
|
|
|
|
|
- return EditorBuiltin.ShaderIcon;
|
|
|
|
|
- case ResourceType.Material:
|
|
|
|
|
- return EditorBuiltin.MaterialIcon;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- enum MoveDirection
|
|
|
|
|
- {
|
|
|
|
|
- Up, Down, Left, Right
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private const int GRID_ENTRY_SPACING = 15;
|
|
private const int GRID_ENTRY_SPACING = 15;
|
|
|
private const int LIST_ENTRY_SPACING = 7;
|
|
private const int LIST_ENTRY_SPACING = 7;
|
|
|
private const int MAX_LABEL_HEIGHT = 50;
|
|
private const int MAX_LABEL_HEIGHT = 50;
|
|
@@ -438,7 +132,8 @@ namespace BansheeEditor
|
|
|
dropTarget.OnStart += DoOnDragStart;
|
|
dropTarget.OnStart += DoOnDragStart;
|
|
|
dropTarget.OnDrag += DoOnDragMove;
|
|
dropTarget.OnDrag += DoOnDragMove;
|
|
|
dropTarget.OnLeave += DoOnDragLeave;
|
|
dropTarget.OnLeave += DoOnDragLeave;
|
|
|
- dropTarget.OnDrop += DoOnDragDropped;
|
|
|
|
|
|
|
+ dropTarget.OnDropResource += DoOnResourceDragDropped;
|
|
|
|
|
+ dropTarget.OnDropSceneObject += DoOnSceneObjectDragDropped;
|
|
|
dropTarget.OnEnd += DoOnDragEnd;
|
|
dropTarget.OnEnd += DoOnDragEnd;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -523,7 +218,7 @@ namespace BansheeEditor
|
|
|
autoScrollAmount = 0;
|
|
autoScrollAmount = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void DoOnDragDropped(Vector2I windowPos, string[] paths)
|
|
|
|
|
|
|
+ private void DoOnResourceDragDropped(Vector2I windowPos, string[] paths)
|
|
|
{
|
|
{
|
|
|
ClearHoverHighlight();
|
|
ClearHoverHighlight();
|
|
|
autoScrollAmount = 0;
|
|
autoScrollAmount = 0;
|
|
@@ -559,25 +254,61 @@ namespace BansheeEditor
|
|
|
if (PathEx.IsPartOf(destinationFolder, absolutePath) || PathEx.Compare(absolutePath, destinationFolder))
|
|
if (PathEx.IsPartOf(destinationFolder, absolutePath) || PathEx.Compare(absolutePath, destinationFolder))
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
- string pathTail = PathEx.GetTail(absolutePath);
|
|
|
|
|
- string destination = Path.Combine(destinationFolder, pathTail);
|
|
|
|
|
|
|
+ string pathTail = PathEx.GetTail(absolutePath);
|
|
|
|
|
+ string destination = Path.Combine(destinationFolder, pathTail);
|
|
|
|
|
+
|
|
|
|
|
+ bool doCopy = !ProjectLibrary.Exists(path);
|
|
|
|
|
+
|
|
|
|
|
+ if (Directory.Exists(path))
|
|
|
|
|
+ {
|
|
|
|
|
+ if (doCopy)
|
|
|
|
|
+ DirectoryEx.Copy(path, GetUniquePath(destination));
|
|
|
|
|
+ else
|
|
|
|
|
+ DirectoryEx.Move(path, GetUniquePath(destination));
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (File.Exists(path))
|
|
|
|
|
+ {
|
|
|
|
|
+ if (doCopy)
|
|
|
|
|
+ FileEx.Copy(path, GetUniquePath(destination));
|
|
|
|
|
+ else
|
|
|
|
|
+ FileEx.Move(path, GetUniquePath(destination));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ProjectLibrary.Refresh();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void DoOnSceneObjectDragDropped(Vector2I windowPos, SceneObject[] objects)
|
|
|
|
|
+ {
|
|
|
|
|
+ ClearHoverHighlight();
|
|
|
|
|
+ autoScrollAmount = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (EndDragSelection())
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ string resourceDir = ProjectLibrary.ResourceFolder;
|
|
|
|
|
+ string destinationFolder = Path.Combine(resourceDir, currentDirectory);
|
|
|
|
|
+
|
|
|
|
|
+ ElementEntry underCursorElement = FindElementAt(windowPos);
|
|
|
|
|
+ if (underCursorElement != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ LibraryEntry entry = ProjectLibrary.GetEntry(underCursorElement.path);
|
|
|
|
|
+ if (entry != null && entry.Type == LibraryEntryType.Directory)
|
|
|
|
|
+ destinationFolder = Path.Combine(resourceDir, entry.Path);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (objects != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach (var so in objects)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (so == null)
|
|
|
|
|
+ continue;
|
|
|
|
|
|
|
|
- bool doCopy = !ProjectLibrary.Exists(path);
|
|
|
|
|
|
|
+ Prefab newPrefab = new Prefab(so);
|
|
|
|
|
|
|
|
- if (Directory.Exists(path))
|
|
|
|
|
- {
|
|
|
|
|
- if (doCopy)
|
|
|
|
|
- DirectoryEx.Copy(path, GetUniquePath(destination));
|
|
|
|
|
- else
|
|
|
|
|
- DirectoryEx.Move(path, GetUniquePath(destination));
|
|
|
|
|
- }
|
|
|
|
|
- else if (File.Exists(path))
|
|
|
|
|
- {
|
|
|
|
|
- if (doCopy)
|
|
|
|
|
- FileEx.Copy(path, GetUniquePath(destination));
|
|
|
|
|
- else
|
|
|
|
|
- FileEx.Move(path, GetUniquePath(destination));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ string destination = GetUniquePath(Path.Combine(destinationFolder, so.Name + ".prefab"));
|
|
|
|
|
+ ProjectLibrary.Create(newPrefab, destination);
|
|
|
|
|
|
|
|
ProjectLibrary.Refresh();
|
|
ProjectLibrary.Refresh();
|
|
|
}
|
|
}
|
|
@@ -1125,473 +856,790 @@ namespace BansheeEditor
|
|
|
|
|
|
|
|
contentInfo.main.AddFlexibleSpace();
|
|
contentInfo.main.AddFlexibleSpace();
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ int tileSize = 64;
|
|
|
|
|
+ switch (viewType)
|
|
|
|
|
+ {
|
|
|
|
|
+ case ProjectViewType.Grid64: tileSize = 64; break;
|
|
|
|
|
+ case ProjectViewType.Grid48: tileSize = 48; break;
|
|
|
|
|
+ case ProjectViewType.Grid32: tileSize = 32; break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ contentInfo.main.AddSpace(GRID_ENTRY_SPACING / 2);
|
|
|
|
|
+ GUILayoutX rowLayout = contentInfo.main.AddLayoutX();
|
|
|
|
|
+ contentInfo.main.AddSpace(GRID_ENTRY_SPACING);
|
|
|
|
|
+ rowLayout.AddFlexibleSpace();
|
|
|
|
|
+
|
|
|
|
|
+ int elemsInRow = 0;
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < entriesToDisplay.Length; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (elemsInRow == contentInfo.elementsPerRow && elemsInRow > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ rowLayout = contentInfo.main.AddLayoutX();
|
|
|
|
|
+ contentInfo.main.AddSpace(GRID_ENTRY_SPACING);
|
|
|
|
|
+
|
|
|
|
|
+ rowLayout.AddFlexibleSpace();
|
|
|
|
|
+ elemsInRow = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ElementEntry guiEntry = new ElementEntry(contentInfo, rowLayout, entriesToDisplay[i], i);
|
|
|
|
|
+ entries.Add(guiEntry);
|
|
|
|
|
+ entryLookup[guiEntry.path] = guiEntry;
|
|
|
|
|
+
|
|
|
|
|
+ rowLayout.AddFlexibleSpace();
|
|
|
|
|
+
|
|
|
|
|
+ elemsInRow++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int extraElements = contentInfo.elementsPerRow - elemsInRow;
|
|
|
|
|
+ for (int i = 0; i < extraElements; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ rowLayout.AddSpace(contentInfo.labelWidth);
|
|
|
|
|
+ rowLayout.AddFlexibleSpace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ contentInfo.main.AddFlexibleSpace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < entries.Count; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ ElementEntry guiEntry = entries[i];
|
|
|
|
|
+ guiEntry.Initialize();
|
|
|
|
|
+
|
|
|
|
|
+ if (cutPaths.Contains(guiEntry.path))
|
|
|
|
|
+ guiEntry.MarkAsCut(true);
|
|
|
|
|
+
|
|
|
|
|
+ if (selectionPaths.Contains(guiEntry.path))
|
|
|
|
|
+ guiEntry.MarkAsSelected(true);
|
|
|
|
|
+ else if (pingPath == guiEntry.path)
|
|
|
|
|
+ guiEntry.MarkAsPinged(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Rect2I contentBounds = contentInfo.main.Bounds;
|
|
|
|
|
+ Rect2I minimalBounds = GetScrollAreaBounds();
|
|
|
|
|
+ contentBounds.height = Math.Max(contentBounds.height, minimalBounds.height);
|
|
|
|
|
+
|
|
|
|
|
+ GUIButton catchAll = new GUIButton("", EditorStyles.Blank);
|
|
|
|
|
+ catchAll.Bounds = contentBounds;
|
|
|
|
|
+ catchAll.OnClick += OnCatchAllClicked;
|
|
|
|
|
+ catchAll.SetContextMenu(entryContextMenu);
|
|
|
|
|
+
|
|
|
|
|
+ contentInfo.underlay.AddElement(catchAll);
|
|
|
|
|
+
|
|
|
|
|
+ Rect2I focusBounds = contentBounds; // Contents + Folder bar
|
|
|
|
|
+ Rect2I scrollBounds = contentScrollArea.Bounds;
|
|
|
|
|
+ focusBounds.x += scrollBounds.x;
|
|
|
|
|
+ focusBounds.y += scrollBounds.y;
|
|
|
|
|
+
|
|
|
|
|
+ Rect2I folderBarBounds = folderListLayout.Bounds;
|
|
|
|
|
+ focusBounds.y -= folderBarBounds.height;
|
|
|
|
|
+ focusBounds.height += folderBarBounds.height;
|
|
|
|
|
+
|
|
|
|
|
+ GUIButton focusCatcher = new GUIButton("", EditorStyles.Blank);
|
|
|
|
|
+ focusCatcher.OnFocusChanged += OnContentsFocusChanged;
|
|
|
|
|
+ focusCatcher.Bounds = focusBounds;
|
|
|
|
|
+
|
|
|
|
|
+ GUIPanel focusPanel = GUI.AddPanel(3);
|
|
|
|
|
+ focusPanel.AddElement(focusCatcher);
|
|
|
|
|
+
|
|
|
|
|
+ UpdateDragSelection(dragSelectionEnd);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Vector2I WindowToScrollAreaCoords(Vector2I windowPos)
|
|
|
|
|
+ {
|
|
|
|
|
+ Rect2I scrollBounds = contentScrollArea.Layout.Bounds;
|
|
|
|
|
+ Vector2I scrollPos = windowPos;
|
|
|
|
|
+ scrollPos.x -= scrollBounds.x;
|
|
|
|
|
+ scrollPos.y -= scrollBounds.y;
|
|
|
|
|
+
|
|
|
|
|
+ return scrollPos;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void StartDragSelection(Vector2I windowPos)
|
|
|
|
|
+ {
|
|
|
|
|
+ isDraggingSelection = true;
|
|
|
|
|
+ dragSelectionStart = WindowToScrollAreaCoords(windowPos);
|
|
|
|
|
+ dragSelectionEnd = dragSelectionStart;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private bool UpdateDragSelection(Vector2I windowPos)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!isDraggingSelection)
|
|
|
|
|
+ return false;
|
|
|
|
|
+
|
|
|
|
|
+ if (dragSelection == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ dragSelection = new GUITexture(null, true, EditorStyles.SelectionArea);
|
|
|
|
|
+ contentInfo.overlay.AddElement(dragSelection);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ dragSelectionEnd = WindowToScrollAreaCoords(windowPos);
|
|
|
|
|
+
|
|
|
|
|
+ Rect2I selectionArea = CalculateSelectionArea();
|
|
|
|
|
+ SelectInArea(selectionArea);
|
|
|
|
|
+ dragSelection.Bounds = selectionArea;
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private bool EndDragSelection()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!isDraggingSelection)
|
|
|
|
|
+ return false;
|
|
|
|
|
+
|
|
|
|
|
+ if (dragSelection != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ dragSelection.Destroy();
|
|
|
|
|
+ dragSelection = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Rect2I selectionArea = CalculateSelectionArea();
|
|
|
|
|
+ SelectInArea(selectionArea);
|
|
|
|
|
+
|
|
|
|
|
+ isDraggingSelection = false;
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Rect2I CalculateSelectionArea()
|
|
|
|
|
+ {
|
|
|
|
|
+ Rect2I selectionArea = new Rect2I();
|
|
|
|
|
+ if (dragSelectionStart.x < dragSelectionEnd.x)
|
|
|
|
|
+ {
|
|
|
|
|
+ selectionArea.x = dragSelectionStart.x;
|
|
|
|
|
+ selectionArea.width = dragSelectionEnd.x - dragSelectionStart.x;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ selectionArea.x = dragSelectionEnd.x;
|
|
|
|
|
+ selectionArea.width = dragSelectionStart.x - dragSelectionEnd.x;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (dragSelectionStart.y < dragSelectionEnd.y)
|
|
|
|
|
+ {
|
|
|
|
|
+ selectionArea.y = dragSelectionStart.y;
|
|
|
|
|
+ selectionArea.height = dragSelectionEnd.y - dragSelectionStart.y;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ selectionArea.y = dragSelectionEnd.y;
|
|
|
|
|
+ selectionArea.height = dragSelectionStart.y - dragSelectionEnd.y;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Rect2I maxBounds = contentScrollArea.Layout.Bounds;
|
|
|
|
|
+ maxBounds.x = 0;
|
|
|
|
|
+ maxBounds.y = 0;
|
|
|
|
|
+
|
|
|
|
|
+ selectionArea.Clip(maxBounds);
|
|
|
|
|
+
|
|
|
|
|
+ return selectionArea;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void SelectInArea(Rect2I scrollBounds)
|
|
|
|
|
+ {
|
|
|
|
|
+ ElementEntry[] foundElements = FindElementsOverlapping(scrollBounds);
|
|
|
|
|
+
|
|
|
|
|
+ if (foundElements.Length > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ selectionAnchorStart = foundElements[0].index;
|
|
|
|
|
+ selectionAnchorEnd = foundElements[foundElements.Length - 1].index;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ selectionAnchorStart = -1;
|
|
|
|
|
+ selectionAnchorEnd = -1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<string> elementPaths = new List<string>();
|
|
|
|
|
+ foreach (var elem in foundElements)
|
|
|
|
|
+ elementPaths.Add(elem.path);
|
|
|
|
|
+
|
|
|
|
|
+ SetSelection(elementPaths);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void RefreshDirectoryBar()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (folderListLayout != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ folderListLayout.Destroy();
|
|
|
|
|
+ folderListLayout = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ folderListLayout = folderBarLayout.AddLayoutX();
|
|
|
|
|
+
|
|
|
|
|
+ string[] folders = null;
|
|
|
|
|
+ string[] fullPaths = null;
|
|
|
|
|
+
|
|
|
|
|
+ if (IsSearchActive)
|
|
|
|
|
+ {
|
|
|
|
|
+ folders = new[] {searchQuery};
|
|
|
|
|
+ fullPaths = new[] { searchQuery };
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ string currentDir = Path.Combine("Resources", currentDirectory);
|
|
|
|
|
+
|
|
|
|
|
+ folders = currentDir.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar },
|
|
|
|
|
+ StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
+
|
|
|
|
|
+ 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 numFolders = 0;
|
|
|
|
|
+ for (int i = folders.Length - 1; i >= 0; i--)
|
|
|
{
|
|
{
|
|
|
- int tileSize = 64;
|
|
|
|
|
- switch (viewType)
|
|
|
|
|
|
|
+ GUIButton folderButton = new GUIButton(folders[i]);
|
|
|
|
|
+
|
|
|
|
|
+ if (!IsSearchActive)
|
|
|
{
|
|
{
|
|
|
- case ProjectViewType.Grid64: tileSize = 64; break;
|
|
|
|
|
- case ProjectViewType.Grid48: tileSize = 48; break;
|
|
|
|
|
- case ProjectViewType.Grid32: tileSize = 32; break;
|
|
|
|
|
|
|
+ string fullPath = fullPaths[i];
|
|
|
|
|
+ folderButton.OnClick += () => OnFolderButtonClicked(fullPath);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- contentInfo.main.AddSpace(GRID_ENTRY_SPACING / 2);
|
|
|
|
|
- GUILayoutX rowLayout = contentInfo.main.AddLayoutX();
|
|
|
|
|
- contentInfo.main.AddSpace(GRID_ENTRY_SPACING);
|
|
|
|
|
- rowLayout.AddFlexibleSpace();
|
|
|
|
|
|
|
+ GUILabel separator = new GUILabel("/", GUIOption.FixedWidth(FOLDER_SEPARATOR_WIDTH));
|
|
|
|
|
|
|
|
- int elemsInRow = 0;
|
|
|
|
|
|
|
+ folderListLayout.InsertElement(0, separator);
|
|
|
|
|
+ folderListLayout.InsertElement(0, folderButton);
|
|
|
|
|
+ numFolders++;
|
|
|
|
|
|
|
|
- for (int i = 0; i < entriesToDisplay.Length; i++)
|
|
|
|
|
|
|
+ Rect2I folderListBounds = folderListLayout.Bounds;
|
|
|
|
|
+ if (folderListBounds.width > availableWidth)
|
|
|
{
|
|
{
|
|
|
- if (elemsInRow == contentInfo.elementsPerRow && elemsInRow > 0)
|
|
|
|
|
|
|
+ if (numFolders > 2)
|
|
|
{
|
|
{
|
|
|
- rowLayout = contentInfo.main.AddLayoutX();
|
|
|
|
|
- contentInfo.main.AddSpace(GRID_ENTRY_SPACING);
|
|
|
|
|
-
|
|
|
|
|
- rowLayout.AddFlexibleSpace();
|
|
|
|
|
- elemsInRow = 0;
|
|
|
|
|
|
|
+ separator.Destroy();
|
|
|
|
|
+ folderButton.Destroy();
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- ElementEntry guiEntry = new ElementEntry(contentInfo, rowLayout, entriesToDisplay[i], i);
|
|
|
|
|
- entries.Add(guiEntry);
|
|
|
|
|
- entryLookup[guiEntry.path] = guiEntry;
|
|
|
|
|
|
|
+ private void SortEntries(LibraryEntry[] input)
|
|
|
|
|
+ {
|
|
|
|
|
+ Array.Sort(input, (x, y) =>
|
|
|
|
|
+ {
|
|
|
|
|
+ if (x.Type == y.Type)
|
|
|
|
|
+ return x.Name.CompareTo(y.Name);
|
|
|
|
|
+ else
|
|
|
|
|
+ return x.Type == LibraryEntryType.File ? 1 : -1;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- rowLayout.AddFlexibleSpace();
|
|
|
|
|
|
|
+ private void OnFolderButtonClicked(string path)
|
|
|
|
|
+ {
|
|
|
|
|
+ EnterDirectory(path);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- elemsInRow++;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ private void OnContentsFocusChanged(bool focus)
|
|
|
|
|
+ {
|
|
|
|
|
+ hasContentFocus = focus;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- int extraElements = contentInfo.elementsPerRow - elemsInRow;
|
|
|
|
|
- for (int i = 0; i < extraElements; i++)
|
|
|
|
|
|
|
+ private void OnEntryClicked(string path)
|
|
|
|
|
+ {
|
|
|
|
|
+ Select(path);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void OnEntryDoubleClicked(string path)
|
|
|
|
|
+ {
|
|
|
|
|
+ LibraryEntry entry = ProjectLibrary.GetEntry(path);
|
|
|
|
|
+ if (entry != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (entry.Type == LibraryEntryType.Directory)
|
|
|
|
|
+ EnterDirectory(path);
|
|
|
|
|
+ else
|
|
|
{
|
|
{
|
|
|
- rowLayout.AddSpace(contentInfo.labelWidth);
|
|
|
|
|
- rowLayout.AddFlexibleSpace();
|
|
|
|
|
|
|
+ FileEntry resEntry = (FileEntry) entry;
|
|
|
|
|
+ if (resEntry.ResType == ResourceType.Prefab)
|
|
|
|
|
+ {
|
|
|
|
|
+ Scene.Load(resEntry.Path);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- contentInfo.main.AddFlexibleSpace();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- for (int i = 0; i < entries.Count; i++)
|
|
|
|
|
|
|
+ private void OnCatchAllClicked()
|
|
|
|
|
+ {
|
|
|
|
|
+ DeselectAll();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void OnHomeClicked()
|
|
|
|
|
+ {
|
|
|
|
|
+ currentDirectory = ProjectLibrary.Root.Path;
|
|
|
|
|
+ Refresh();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void OnUpClicked()
|
|
|
|
|
+ {
|
|
|
|
|
+ currentDirectory = currentDirectory.Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
|
|
|
|
+
|
|
|
|
|
+ if (!string.IsNullOrEmpty(currentDirectory))
|
|
|
{
|
|
{
|
|
|
- ElementEntry guiEntry = entries[i];
|
|
|
|
|
- guiEntry.Initialize();
|
|
|
|
|
|
|
+ string parent = Path.GetDirectoryName(currentDirectory);
|
|
|
|
|
|
|
|
- if (cutPaths.Contains(guiEntry.path))
|
|
|
|
|
- guiEntry.MarkAsCut(true);
|
|
|
|
|
|
|
+ currentDirectory = parent;
|
|
|
|
|
+ Refresh();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (selectionPaths.Contains(guiEntry.path))
|
|
|
|
|
- guiEntry.MarkAsSelected(true);
|
|
|
|
|
- else if (pingPath == guiEntry.path)
|
|
|
|
|
- guiEntry.MarkAsPinged(true);
|
|
|
|
|
|
|
+ private void CutSelection()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (selectionPaths.Count > 0)
|
|
|
|
|
+ Cut(selectionPaths);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void CopySelection()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (selectionPaths.Count > 0)
|
|
|
|
|
+ Copy(selectionPaths);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void DuplicateSelection()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (selectionPaths.Count > 0)
|
|
|
|
|
+ Duplicate(selectionPaths);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void PasteToSelection()
|
|
|
|
|
+ {
|
|
|
|
|
+ DirectoryEntry selectedDirectory = null;
|
|
|
|
|
+ if (selectionPaths.Count == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ LibraryEntry entry = ProjectLibrary.GetEntry(selectionPaths[0]);
|
|
|
|
|
+ if (entry != null && entry.Type == LibraryEntryType.Directory)
|
|
|
|
|
+ selectedDirectory = (DirectoryEntry) entry;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Rect2I contentBounds = contentInfo.main.Bounds;
|
|
|
|
|
- Rect2I minimalBounds = GetScrollAreaBounds();
|
|
|
|
|
- contentBounds.height = Math.Max(contentBounds.height, minimalBounds.height);
|
|
|
|
|
|
|
+ if(selectedDirectory != null)
|
|
|
|
|
+ Paste(selectedDirectory.Path);
|
|
|
|
|
+ else
|
|
|
|
|
+ Paste(currentDirectory);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- GUIButton catchAll = new GUIButton("", EditorStyles.Blank);
|
|
|
|
|
- catchAll.Bounds = contentBounds;
|
|
|
|
|
- catchAll.OnClick += OnCatchAllClicked;
|
|
|
|
|
- catchAll.SetContextMenu(entryContextMenu);
|
|
|
|
|
|
|
+ private void RenameSelection()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (selectionPaths.Count == 0)
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
- contentInfo.underlay.AddElement(catchAll);
|
|
|
|
|
|
|
+ if (selectionPaths.Count > 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ DeselectAll();
|
|
|
|
|
+ Select(selectionPaths[0]);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Rect2I focusBounds = contentBounds; // Contents + Folder bar
|
|
|
|
|
- Rect2I scrollBounds = contentScrollArea.Bounds;
|
|
|
|
|
- focusBounds.x += scrollBounds.x;
|
|
|
|
|
- focusBounds.y += scrollBounds.y;
|
|
|
|
|
|
|
+ ElementEntry entry;
|
|
|
|
|
+ if (entryLookup.TryGetValue(selectionPaths[0], out entry))
|
|
|
|
|
+ {
|
|
|
|
|
+ entry.StartRename();
|
|
|
|
|
+ inProgressRenameElement = entry;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Rect2I folderBarBounds = folderListLayout.Bounds;
|
|
|
|
|
- focusBounds.y -= folderBarBounds.height;
|
|
|
|
|
- focusBounds.height += folderBarBounds.height;
|
|
|
|
|
|
|
+ private void StopRename()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (inProgressRenameElement != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ inProgressRenameElement.StopRename();
|
|
|
|
|
+ inProgressRenameElement = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- GUIButton focusCatcher = new GUIButton("", EditorStyles.Blank);
|
|
|
|
|
- focusCatcher.OnFocusChanged += OnContentsFocusChanged;
|
|
|
|
|
- focusCatcher.Bounds = focusBounds;
|
|
|
|
|
|
|
+ private void DeleteSelection()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (selectionPaths.Count == 0)
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
- GUIPanel focusPanel = GUI.AddPanel(3);
|
|
|
|
|
- focusPanel.AddElement(focusCatcher);
|
|
|
|
|
|
|
+ DialogBox.Open("Confirm deletion", "Are you sure you want to delete the selected object(s)?",
|
|
|
|
|
+ DialogBox.Type.YesNo,
|
|
|
|
|
+ type =>
|
|
|
|
|
+ {
|
|
|
|
|
+ if (type == DialogBox.ResultType.Yes)
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach (var path in selectionPaths)
|
|
|
|
|
+ {
|
|
|
|
|
+ ProjectLibrary.Delete(path);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- UpdateDragSelection(dragSelectionEnd);
|
|
|
|
|
|
|
+ DeselectAll();
|
|
|
|
|
+ Refresh();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private Vector2I WindowToScrollAreaCoords(Vector2I windowPos)
|
|
|
|
|
|
|
+ private void OnSearchChanged(string newValue)
|
|
|
{
|
|
{
|
|
|
- Rect2I scrollBounds = contentScrollArea.Layout.Bounds;
|
|
|
|
|
- Vector2I scrollPos = windowPos;
|
|
|
|
|
- scrollPos.x -= scrollBounds.x;
|
|
|
|
|
- scrollPos.y -= scrollBounds.y;
|
|
|
|
|
|
|
+ searchQuery = newValue;
|
|
|
|
|
+ Refresh();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return scrollPos;
|
|
|
|
|
|
|
+ private void ClearSearch()
|
|
|
|
|
+ {
|
|
|
|
|
+ searchField.Value = "";
|
|
|
|
|
+ searchQuery = "";
|
|
|
|
|
+ Refresh();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void StartDragSelection(Vector2I windowPos)
|
|
|
|
|
|
|
+ private void OpenOptionsWindow()
|
|
|
{
|
|
{
|
|
|
- isDraggingSelection = true;
|
|
|
|
|
- dragSelectionStart = WindowToScrollAreaCoords(windowPos);
|
|
|
|
|
- dragSelectionEnd = dragSelectionStart;
|
|
|
|
|
|
|
+ Vector2I openPosition;
|
|
|
|
|
+ Rect2I buttonBounds = GUILayoutUtility.CalculateBounds(optionsButton, GUI);
|
|
|
|
|
+
|
|
|
|
|
+ openPosition.x = buttonBounds.x + buttonBounds.width / 2;
|
|
|
|
|
+ openPosition.y = buttonBounds.y + buttonBounds.height / 2;
|
|
|
|
|
+
|
|
|
|
|
+ ProjectDropDown dropDown = DropDownWindow.Open<ProjectDropDown>(this, openPosition);
|
|
|
|
|
+ dropDown.SetParent(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private bool UpdateDragSelection(Vector2I windowPos)
|
|
|
|
|
|
|
+ private void Reset()
|
|
|
{
|
|
{
|
|
|
- if (!isDraggingSelection)
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ currentDirectory = ProjectLibrary.Root.Path;
|
|
|
|
|
+ selectionAnchorStart = -1;
|
|
|
|
|
+ selectionAnchorEnd = -1;
|
|
|
|
|
+ selectionPaths.Clear();
|
|
|
|
|
+ pingPath = "";
|
|
|
|
|
+ hoverHighlightPath = "";
|
|
|
|
|
|
|
|
- if (dragSelection == null)
|
|
|
|
|
- {
|
|
|
|
|
- dragSelection = new GUITexture(null, true, EditorStyles.SelectionArea);
|
|
|
|
|
- contentInfo.overlay.AddElement(dragSelection);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Refresh();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- dragSelectionEnd = WindowToScrollAreaCoords(windowPos);
|
|
|
|
|
|
|
+ private Rect2I GetScrollAreaBounds()
|
|
|
|
|
+ {
|
|
|
|
|
+ Rect2I bounds = GUI.Bounds;
|
|
|
|
|
+ Rect2I folderListBounds = folderListLayout.Bounds;
|
|
|
|
|
+ Rect2I searchBarBounds = searchBarLayout.Bounds;
|
|
|
|
|
|
|
|
- Rect2I selectionArea = CalculateSelectionArea();
|
|
|
|
|
- SelectInArea(selectionArea);
|
|
|
|
|
- dragSelection.Bounds = selectionArea;
|
|
|
|
|
|
|
+ bounds.y += folderListBounds.height + searchBarBounds.height;
|
|
|
|
|
+ bounds.height -= folderListBounds.height + searchBarBounds.height;
|
|
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+ return bounds;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private bool EndDragSelection()
|
|
|
|
|
|
|
+ protected override void WindowResized(int width, int height)
|
|
|
{
|
|
{
|
|
|
- if (!isDraggingSelection)
|
|
|
|
|
- return false;
|
|
|
|
|
-
|
|
|
|
|
- if (dragSelection != null)
|
|
|
|
|
- {
|
|
|
|
|
- dragSelection.Destroy();
|
|
|
|
|
- dragSelection = null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ base.WindowResized(width, height);
|
|
|
|
|
|
|
|
- Rect2I selectionArea = CalculateSelectionArea();
|
|
|
|
|
- SelectInArea(selectionArea);
|
|
|
|
|
|
|
+ Refresh();
|
|
|
|
|
|
|
|
- isDraggingSelection = false;
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ dropTarget.Bounds = contentScrollArea.Bounds;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private Rect2I CalculateSelectionArea()
|
|
|
|
|
|
|
+ private class ContentInfo
|
|
|
{
|
|
{
|
|
|
- Rect2I selectionArea = new Rect2I();
|
|
|
|
|
- if (dragSelectionStart.x < dragSelectionEnd.x)
|
|
|
|
|
- {
|
|
|
|
|
- selectionArea.x = dragSelectionStart.x;
|
|
|
|
|
- selectionArea.width = dragSelectionEnd.x - dragSelectionStart.x;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
|
|
+ public ContentInfo(ProjectWindow window, ProjectViewType viewType, int numEntries)
|
|
|
{
|
|
{
|
|
|
- selectionArea.x = dragSelectionEnd.x;
|
|
|
|
|
- selectionArea.width = dragSelectionStart.x - dragSelectionEnd.x;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ GUIPanel parentPanel = window.scrollAreaPanel;
|
|
|
|
|
|
|
|
- if (dragSelectionStart.y < dragSelectionEnd.y)
|
|
|
|
|
- {
|
|
|
|
|
- selectionArea.y = dragSelectionStart.y;
|
|
|
|
|
- selectionArea.height = dragSelectionEnd.y - dragSelectionStart.y;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- selectionArea.y = dragSelectionEnd.y;
|
|
|
|
|
- selectionArea.height = dragSelectionStart.y - dragSelectionEnd.y;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ GUIPanel contentPanel = parentPanel.AddPanel(1);
|
|
|
|
|
+ overlay = parentPanel.AddPanel(0);
|
|
|
|
|
+ underlay = parentPanel.AddPanel(2);
|
|
|
|
|
+ inputOverlay = parentPanel.AddPanel(-1);
|
|
|
|
|
|
|
|
- Rect2I maxBounds = contentScrollArea.Layout.Bounds;
|
|
|
|
|
- maxBounds.x = 0;
|
|
|
|
|
- maxBounds.y = 0;
|
|
|
|
|
|
|
+ main = contentPanel.AddLayoutY();
|
|
|
|
|
|
|
|
- selectionArea.Clip(maxBounds);
|
|
|
|
|
|
|
+ if (viewType == ProjectViewType.List16)
|
|
|
|
|
+ {
|
|
|
|
|
+ tileSize = 16;
|
|
|
|
|
+ gridLayout = false;
|
|
|
|
|
+ elementsPerRow = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (viewType)
|
|
|
|
|
+ {
|
|
|
|
|
+ case ProjectViewType.Grid64:
|
|
|
|
|
+ tileSize = 64;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ProjectViewType.Grid48:
|
|
|
|
|
+ tileSize = 48;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ProjectViewType.Grid32:
|
|
|
|
|
+ tileSize = 32;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return selectionArea;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ gridLayout = true;
|
|
|
|
|
|
|
|
- private void SelectInArea(Rect2I scrollBounds)
|
|
|
|
|
- {
|
|
|
|
|
- ElementEntry[] foundElements = FindElementsOverlapping(scrollBounds);
|
|
|
|
|
|
|
+ Rect2I scrollBounds = window.contentScrollArea.Bounds;
|
|
|
|
|
+ int availableWidth = scrollBounds.width;
|
|
|
|
|
|
|
|
- if (foundElements.Length > 0)
|
|
|
|
|
- {
|
|
|
|
|
- selectionAnchorStart = foundElements[0].index;
|
|
|
|
|
- selectionAnchorEnd = foundElements[foundElements.Length - 1].index;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- selectionAnchorStart = -1;
|
|
|
|
|
- selectionAnchorEnd = -1;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ int elemSize = tileSize + GRID_ENTRY_SPACING;
|
|
|
|
|
+ elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize;
|
|
|
|
|
+ int numRows = MathEx.CeilToInt(numEntries / (float)elementsPerRow);
|
|
|
|
|
+ int neededHeight = numRows * (elemSize);
|
|
|
|
|
|
|
|
- List<string> elementPaths = new List<string>();
|
|
|
|
|
- foreach (var elem in foundElements)
|
|
|
|
|
- elementPaths.Add(elem.path);
|
|
|
|
|
|
|
+ bool requiresScrollbar = neededHeight > scrollBounds.height;
|
|
|
|
|
+ if (requiresScrollbar)
|
|
|
|
|
+ {
|
|
|
|
|
+ availableWidth -= window.contentScrollArea.ScrollBarWidth;
|
|
|
|
|
+ elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- SetSelection(elementPaths);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ labelWidth = (availableWidth - (elementsPerRow + 1) * MIN_HORZ_SPACING) / elementsPerRow;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private void RefreshDirectoryBar()
|
|
|
|
|
- {
|
|
|
|
|
- if (folderListLayout != null)
|
|
|
|
|
- {
|
|
|
|
|
- folderListLayout.Destroy();
|
|
|
|
|
- folderListLayout = null;
|
|
|
|
|
|
|
+ this.window = window;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- folderListLayout = folderBarLayout.AddLayoutX();
|
|
|
|
|
|
|
+ public GUILayout main;
|
|
|
|
|
+ public GUIPanel overlay;
|
|
|
|
|
+ public GUIPanel underlay;
|
|
|
|
|
+ public GUIPanel inputOverlay;
|
|
|
|
|
|
|
|
- string[] folders = null;
|
|
|
|
|
- string[] fullPaths = null;
|
|
|
|
|
|
|
+ public ProjectWindow window;
|
|
|
|
|
+ public int tileSize;
|
|
|
|
|
+ public bool gridLayout;
|
|
|
|
|
|
|
|
- if (IsSearchActive)
|
|
|
|
|
|
|
+ public int elementsPerRow;
|
|
|
|
|
+ public int labelWidth;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private class ElementEntry
|
|
|
|
|
+ {
|
|
|
|
|
+ // Note: Order of these is relevant
|
|
|
|
|
+ enum UnderlayState
|
|
|
{
|
|
{
|
|
|
- folders = new[] {searchQuery};
|
|
|
|
|
- fullPaths = new[] { searchQuery };
|
|
|
|
|
|
|
+ None, Hovered, Selected, Pinged
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- string currentDir = Path.Combine("Resources", currentDirectory);
|
|
|
|
|
|
|
|
|
|
- folders = currentDir.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar },
|
|
|
|
|
- StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
+ public int index;
|
|
|
|
|
+ public string path;
|
|
|
|
|
+ public GUITexture icon;
|
|
|
|
|
+ public GUILabel label;
|
|
|
|
|
+ public Rect2I bounds;
|
|
|
|
|
|
|
|
- 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]);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ private GUITexture underlay;
|
|
|
|
|
+ private ContentInfo info;
|
|
|
|
|
+ private UnderlayState underlayState;
|
|
|
|
|
+ private GUITextBox renameTextBox;
|
|
|
|
|
|
|
|
- int availableWidth = folderBarLayout.Bounds.width - FOLDER_BUTTON_WIDTH * 2;
|
|
|
|
|
- int numFolders = 0;
|
|
|
|
|
- for (int i = folders.Length - 1; i >= 0; i--)
|
|
|
|
|
|
|
+ public ElementEntry(ContentInfo info, GUILayout parent, LibraryEntry entry, int index)
|
|
|
{
|
|
{
|
|
|
- GUIButton folderButton = new GUIButton(folders[i]);
|
|
|
|
|
|
|
+ GUILayout entryLayout;
|
|
|
|
|
|
|
|
- if (!IsSearchActive)
|
|
|
|
|
- {
|
|
|
|
|
- string fullPath = fullPaths[i];
|
|
|
|
|
- folderButton.OnClick += () => OnFolderButtonClicked(fullPath);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (info.gridLayout)
|
|
|
|
|
+ entryLayout = parent.AddLayoutY();
|
|
|
|
|
+ else
|
|
|
|
|
+ entryLayout = parent.AddLayoutX();
|
|
|
|
|
|
|
|
- GUILabel separator = new GUILabel("/", GUIOption.FixedWidth(FOLDER_SEPARATOR_WIDTH));
|
|
|
|
|
|
|
+ SpriteTexture iconTexture = GetIcon(entry);
|
|
|
|
|
|
|
|
- folderListLayout.InsertElement(0, separator);
|
|
|
|
|
- folderListLayout.InsertElement(0, folderButton);
|
|
|
|
|
- numFolders++;
|
|
|
|
|
|
|
+ icon = new GUITexture(iconTexture, GUIImageScaleMode.ScaleToFit,
|
|
|
|
|
+ true, GUIOption.FixedHeight(info.tileSize), GUIOption.FixedWidth(info.tileSize));
|
|
|
|
|
|
|
|
- Rect2I folderListBounds = folderListLayout.Bounds;
|
|
|
|
|
- if (folderListBounds.width > availableWidth)
|
|
|
|
|
|
|
+ label = null;
|
|
|
|
|
+
|
|
|
|
|
+ if (info.gridLayout)
|
|
|
{
|
|
{
|
|
|
- if (numFolders > 2)
|
|
|
|
|
- {
|
|
|
|
|
- separator.Destroy();
|
|
|
|
|
- folderButton.Destroy();
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ label = new GUILabel(entry.Name, EditorStyles.MultiLineLabelCentered,
|
|
|
|
|
+ GUIOption.FixedWidth(info.labelWidth), GUIOption.FlexibleHeight(0, MAX_LABEL_HEIGHT));
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void SortEntries(LibraryEntry[] input)
|
|
|
|
|
- {
|
|
|
|
|
- Array.Sort(input, (x, y) =>
|
|
|
|
|
- {
|
|
|
|
|
- if (x.Type == y.Type)
|
|
|
|
|
- return x.Name.CompareTo(y.Name);
|
|
|
|
|
else
|
|
else
|
|
|
- return x.Type == LibraryEntryType.File ? 1 : -1;
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void OnFolderButtonClicked(string path)
|
|
|
|
|
- {
|
|
|
|
|
- EnterDirectory(path);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ label = new GUILabel(entry.Name);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private void OnContentsFocusChanged(bool focus)
|
|
|
|
|
- {
|
|
|
|
|
- hasContentFocus = focus;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ entryLayout.AddElement(icon);
|
|
|
|
|
+ entryLayout.AddElement(label);
|
|
|
|
|
|
|
|
- private void OnEntryClicked(string path)
|
|
|
|
|
- {
|
|
|
|
|
- Select(path);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.info = info;
|
|
|
|
|
+ this.index = index;
|
|
|
|
|
+ this.path = entry.Path;
|
|
|
|
|
+ this.bounds = new Rect2I();
|
|
|
|
|
+ this.underlay = null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private void OnEntryDoubleClicked(string path)
|
|
|
|
|
- {
|
|
|
|
|
- LibraryEntry entry = ProjectLibrary.GetEntry(path);
|
|
|
|
|
- if (entry != null && entry.Type == LibraryEntryType.Directory)
|
|
|
|
|
|
|
+ public void Initialize()
|
|
|
{
|
|
{
|
|
|
- EnterDirectory(path);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ bounds = icon.Bounds;
|
|
|
|
|
+ Rect2I labelBounds = label.Bounds;
|
|
|
|
|
|
|
|
- private void OnCatchAllClicked()
|
|
|
|
|
- {
|
|
|
|
|
- DeselectAll();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ bounds.x = MathEx.Min(bounds.x, labelBounds.x - SELECTION_EXTRA_WIDTH);
|
|
|
|
|
+ bounds.y = MathEx.Min(bounds.y, labelBounds.y) - 5; // 5 - Just padding for better look
|
|
|
|
|
+ bounds.width = MathEx.Max(bounds.x + bounds.width,
|
|
|
|
|
+ labelBounds.x + labelBounds.width) - bounds.x + SELECTION_EXTRA_WIDTH;
|
|
|
|
|
+ bounds.height = MathEx.Max(bounds.y + bounds.height,
|
|
|
|
|
+ labelBounds.y + labelBounds.height) - bounds.y;
|
|
|
|
|
+
|
|
|
|
|
+ ProjectWindow hoistedWindow = info.window;
|
|
|
|
|
+ string hoistedPath = path;
|
|
|
|
|
|
|
|
- private void OnHomeClicked()
|
|
|
|
|
- {
|
|
|
|
|
- currentDirectory = ProjectLibrary.Root.Path;
|
|
|
|
|
- Refresh();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ GUIButton overlayBtn = new GUIButton("", EditorStyles.Blank);
|
|
|
|
|
+ overlayBtn.Bounds = bounds;
|
|
|
|
|
+ overlayBtn.OnClick += () => hoistedWindow.OnEntryClicked(hoistedPath);
|
|
|
|
|
+ overlayBtn.OnDoubleClick += () => hoistedWindow.OnEntryDoubleClicked(hoistedPath);
|
|
|
|
|
+ overlayBtn.SetContextMenu(info.window.entryContextMenu);
|
|
|
|
|
|
|
|
- private void OnUpClicked()
|
|
|
|
|
- {
|
|
|
|
|
- currentDirectory = currentDirectory.Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
|
|
|
|
|
|
+ info.overlay.AddElement(overlayBtn);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(currentDirectory))
|
|
|
|
|
|
|
+ public Rect2I Bounds
|
|
|
{
|
|
{
|
|
|
- string parent = Path.GetDirectoryName(currentDirectory);
|
|
|
|
|
-
|
|
|
|
|
- currentDirectory = parent;
|
|
|
|
|
- Refresh();
|
|
|
|
|
|
|
+ get { return bounds; }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- private void CutSelection()
|
|
|
|
|
- {
|
|
|
|
|
- if (selectionPaths.Count > 0)
|
|
|
|
|
- Cut(selectionPaths);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public void MarkAsCut(bool enable)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (enable)
|
|
|
|
|
+ icon.SetTint(CUT_COLOR);
|
|
|
|
|
+ else
|
|
|
|
|
+ icon.SetTint(Color.White);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private void CopySelection()
|
|
|
|
|
- {
|
|
|
|
|
- if (selectionPaths.Count > 0)
|
|
|
|
|
- Copy(selectionPaths);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public void MarkAsSelected(bool enable)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ((int)underlayState > (int)UnderlayState.Selected)
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
- private void DuplicateSelection()
|
|
|
|
|
- {
|
|
|
|
|
- if (selectionPaths.Count > 0)
|
|
|
|
|
- Duplicate(selectionPaths);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (enable)
|
|
|
|
|
+ {
|
|
|
|
|
+ CreateUnderlay();
|
|
|
|
|
+ underlay.SetTint(SELECTION_COLOR);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ ClearUnderlay();
|
|
|
|
|
|
|
|
- private void PasteToSelection()
|
|
|
|
|
- {
|
|
|
|
|
- DirectoryEntry selectedDirectory = null;
|
|
|
|
|
- if (selectionPaths.Count == 1)
|
|
|
|
|
- {
|
|
|
|
|
- LibraryEntry entry = ProjectLibrary.GetEntry(selectionPaths[0]);
|
|
|
|
|
- if (entry != null && entry.Type == LibraryEntryType.Directory)
|
|
|
|
|
- selectedDirectory = (DirectoryEntry) entry;
|
|
|
|
|
|
|
+ underlayState = UnderlayState.Selected;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(selectedDirectory != null)
|
|
|
|
|
- Paste(selectedDirectory.Path);
|
|
|
|
|
- else
|
|
|
|
|
- Paste(currentDirectory);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public void MarkAsPinged(bool enable)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ((int)underlayState > (int)UnderlayState.Pinged)
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
- private void RenameSelection()
|
|
|
|
|
- {
|
|
|
|
|
- if (selectionPaths.Count == 0)
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ if (enable)
|
|
|
|
|
+ {
|
|
|
|
|
+ CreateUnderlay();
|
|
|
|
|
+ underlay.SetTint(PING_COLOR);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ ClearUnderlay();
|
|
|
|
|
|
|
|
- if (selectionPaths.Count > 1)
|
|
|
|
|
- {
|
|
|
|
|
- DeselectAll();
|
|
|
|
|
- Select(selectionPaths[0]);
|
|
|
|
|
|
|
+ underlayState = UnderlayState.Pinged;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ElementEntry entry;
|
|
|
|
|
- if (entryLookup.TryGetValue(selectionPaths[0], out entry))
|
|
|
|
|
|
|
+ public void MarkAsHovered(bool enable)
|
|
|
{
|
|
{
|
|
|
- entry.StartRename();
|
|
|
|
|
- inProgressRenameElement = entry;
|
|
|
|
|
|
|
+ if ((int)underlayState > (int)UnderlayState.Hovered)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ if (enable)
|
|
|
|
|
+ {
|
|
|
|
|
+ CreateUnderlay();
|
|
|
|
|
+ underlay.SetTint(HOVER_COLOR);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ ClearUnderlay();
|
|
|
|
|
+
|
|
|
|
|
+ underlayState = UnderlayState.Hovered;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- private void StopRename()
|
|
|
|
|
- {
|
|
|
|
|
- if (inProgressRenameElement != null)
|
|
|
|
|
|
|
+ public void StartRename()
|
|
|
{
|
|
{
|
|
|
- inProgressRenameElement.StopRename();
|
|
|
|
|
- inProgressRenameElement = null;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (renameTextBox != null)
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
- private void DeleteSelection()
|
|
|
|
|
- {
|
|
|
|
|
- if (selectionPaths.Count == 0)
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ renameTextBox = new GUITextBox(false);
|
|
|
|
|
+ renameTextBox.Bounds = label.Bounds;
|
|
|
|
|
+ info.inputOverlay.AddElement(renameTextBox);
|
|
|
|
|
|
|
|
- DialogBox.Open("Confirm deletion", "Are you sure you want to delete the selected object(s)?",
|
|
|
|
|
- DialogBox.Type.YesNo,
|
|
|
|
|
- type =>
|
|
|
|
|
- {
|
|
|
|
|
- if (type == DialogBox.ResultType.Yes)
|
|
|
|
|
- {
|
|
|
|
|
- foreach (var path in selectionPaths)
|
|
|
|
|
- {
|
|
|
|
|
- ProjectLibrary.Delete(path);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ string name = Path.GetFileNameWithoutExtension(PathEx.GetTail(path));
|
|
|
|
|
+ renameTextBox.Text = name;
|
|
|
|
|
+ renameTextBox.Focus = true;
|
|
|
|
|
|
|
|
- DeselectAll();
|
|
|
|
|
- Refresh();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ label.Visible = false;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private void OnSearchChanged(string newValue)
|
|
|
|
|
- {
|
|
|
|
|
- searchQuery = newValue;
|
|
|
|
|
- Refresh();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public void StopRename()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (renameTextBox != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ renameTextBox.Destroy();
|
|
|
|
|
+ renameTextBox = null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private void ClearSearch()
|
|
|
|
|
- {
|
|
|
|
|
- searchField.Value = "";
|
|
|
|
|
- searchQuery = "";
|
|
|
|
|
- Refresh();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ label.Visible = true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private void OpenOptionsWindow()
|
|
|
|
|
- {
|
|
|
|
|
- Vector2I openPosition;
|
|
|
|
|
- Rect2I buttonBounds = GUILayoutUtility.CalculateBounds(optionsButton, GUI);
|
|
|
|
|
|
|
+ public string GetRenamedName()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (renameTextBox != null)
|
|
|
|
|
+ return renameTextBox.Text;
|
|
|
|
|
|
|
|
- openPosition.x = buttonBounds.x + buttonBounds.width / 2;
|
|
|
|
|
- openPosition.y = buttonBounds.y + buttonBounds.height / 2;
|
|
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- ProjectDropDown dropDown = DropDownWindow.Open<ProjectDropDown>(this, openPosition);
|
|
|
|
|
- dropDown.SetParent(this);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ private void ClearUnderlay()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (underlay != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ underlay.Destroy();
|
|
|
|
|
+ underlay = null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private void Reset()
|
|
|
|
|
- {
|
|
|
|
|
- currentDirectory = ProjectLibrary.Root.Path;
|
|
|
|
|
- selectionAnchorStart = -1;
|
|
|
|
|
- selectionAnchorEnd = -1;
|
|
|
|
|
- selectionPaths.Clear();
|
|
|
|
|
- pingPath = "";
|
|
|
|
|
- hoverHighlightPath = "";
|
|
|
|
|
|
|
+ underlayState = UnderlayState.None;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Refresh();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ private void CreateUnderlay()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (underlay == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ underlay = new GUITexture(Builtin.WhiteTexture);
|
|
|
|
|
+ underlay.Bounds = Bounds;
|
|
|
|
|
|
|
|
- private Rect2I GetScrollAreaBounds()
|
|
|
|
|
- {
|
|
|
|
|
- Rect2I bounds = GUI.Bounds;
|
|
|
|
|
- Rect2I folderListBounds = folderListLayout.Bounds;
|
|
|
|
|
- Rect2I searchBarBounds = searchBarLayout.Bounds;
|
|
|
|
|
|
|
+ info.underlay.AddElement(underlay);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- bounds.y += folderListBounds.height + searchBarBounds.height;
|
|
|
|
|
- bounds.height -= folderListBounds.height + searchBarBounds.height;
|
|
|
|
|
|
|
+ private static SpriteTexture GetIcon(LibraryEntry entry)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (entry.Type == LibraryEntryType.Directory)
|
|
|
|
|
+ {
|
|
|
|
|
+ return EditorBuiltin.FolderIcon;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ FileEntry fileEntry = (FileEntry)entry;
|
|
|
|
|
+ switch (fileEntry.ResType)
|
|
|
|
|
+ {
|
|
|
|
|
+ case ResourceType.Font:
|
|
|
|
|
+ return EditorBuiltin.FontIcon;
|
|
|
|
|
+ case ResourceType.Mesh:
|
|
|
|
|
+ return EditorBuiltin.MeshIcon;
|
|
|
|
|
+ case ResourceType.Texture:
|
|
|
|
|
+ return EditorBuiltin.TextureIcon;
|
|
|
|
|
+ case ResourceType.PlainText:
|
|
|
|
|
+ return EditorBuiltin.PlainTextIcon;
|
|
|
|
|
+ case ResourceType.ScriptCode:
|
|
|
|
|
+ return EditorBuiltin.ScriptCodeIcon;
|
|
|
|
|
+ case ResourceType.SpriteTexture:
|
|
|
|
|
+ return EditorBuiltin.SpriteTextureIcon;
|
|
|
|
|
+ case ResourceType.Shader:
|
|
|
|
|
+ return EditorBuiltin.ShaderIcon;
|
|
|
|
|
+ case ResourceType.Material:
|
|
|
|
|
+ return EditorBuiltin.MaterialIcon;
|
|
|
|
|
+ case ResourceType.Prefab:
|
|
|
|
|
+ return EditorBuiltin.PrefabIcon;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return bounds;
|
|
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- protected override void WindowResized(int width, int height)
|
|
|
|
|
|
|
+ enum MoveDirection
|
|
|
{
|
|
{
|
|
|
- base.WindowResized(width, height);
|
|
|
|
|
-
|
|
|
|
|
- Refresh();
|
|
|
|
|
-
|
|
|
|
|
- dropTarget.Bounds = contentScrollArea.Bounds;
|
|
|
|
|
|
|
+ Up, Down, Left, Right
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|