Exemplo n.º 1
0
 public ListControl()
 {
     this.uniqueID = s_uniqueIDCount++;
     s_uniqueIDList.Add(this.uniqueID, this);
     this.active = this.root;
     this.Clear();
 }
Exemplo n.º 2
0
 public ListItem Add(ListItem parent, string name, ChangeSet change)
 {
     ListItem item = (parent == null) ? this.root : parent;
     ListItem listItem = new ListItem {
         Name = name
     };
     if (change == null)
     {
     }
     listItem.Change = new ChangeSet(name);
     item.Add(listItem);
     this.pathSearch["_chkeyprfx_" + change.id.ToString()] = listItem;
     return listItem;
 }
Exemplo n.º 3
0
 public void Clear()
 {
     this.parent = null;
     this.firstChild = null;
     this.lastChild = null;
     this.prev = null;
     this.next = null;
     this.icon = null;
     this.name = string.Empty;
     this.indent = 0;
     this.expanded = false;
     this.exclusive = false;
     this.dummy = false;
     this.accept = false;
     this.item = null;
 }
Exemplo n.º 4
0
 public void Add(ListItem listItem)
 {
     listItem.parent = this;
     listItem.next = null;
     listItem.prev = this.lastChild;
     listItem.Indent = this.indent + 1;
     if (this.firstChild == null)
     {
         this.firstChild = listItem;
     }
     if (this.lastChild != null)
     {
         this.lastChild.next = listItem;
     }
     this.lastChild = listItem;
 }
Exemplo n.º 5
0
 public ListItem Add(ListItem parent, string name, Asset asset)
 {
     ListItem item = (parent == null) ? this.root : parent;
     ListItem listItem = new ListItem {
         Name = name,
         Asset = asset
     };
     item.Add(listItem);
     ListItem twinAsset = this.GetTwinAsset(listItem);
     if (((twinAsset != null) && (listItem.Asset != null)) && (twinAsset.Asset.state == (listItem.Asset.state & ~Asset.States.MetaFile)))
     {
         listItem.Hidden = true;
     }
     if ((listItem.Asset != null) && (listItem.Asset.path.Length > 0))
     {
         this.pathSearch[listItem.Asset.path.ToLower()] = listItem;
     }
     return listItem;
 }
Exemplo n.º 6
0
 private void LoadExpanded(ListItem item)
 {
     if (item.Change != null)
     {
         item.Expanded = this.listState.Expanded.Contains(item.Change.id);
     }
     for (ListItem item2 = item.FirstChild; item2 != null; item2 = item2.Next)
     {
         this.LoadExpanded(item2);
     }
 }
Exemplo n.º 7
0
 private void PathSearchUpdate(ListItem item)
 {
     if ((item.Asset != null) && (item.Asset.path.Length > 0))
     {
         this.pathSearch.Add(item.Asset.path.ToLower(), item);
     }
     else if (item.Change != null)
     {
         this.pathSearch.Add("_chkeyprfx_" + item.Change.id.ToString(), item);
         return;
     }
     for (ListItem item2 = item.FirstChild; item2 != null; item2 = item2.Next)
     {
         this.PathSearchUpdate(item2);
     }
 }
Exemplo n.º 8
0
 public void RemoveAll()
 {
   for (ListItem listItem = this.firstChild; listItem != null; listItem = listItem.next)
     listItem.parent = (ListItem) null;
   this.firstChild = (ListItem) null;
   this.lastChild = (ListItem) null;
 }
Exemplo n.º 9
0
        private bool HandleMouse(Rect area)
        {
            Event e       = Event.current;
            bool  repaint = false;

            // Handle mouse down clicks
            bool mouseInArea = area.Contains(e.mousePosition);

            if (e.type == EventType.MouseDown && mouseInArea)
            {
                repaint   = true;
                dragCount = 0;
                GUIUtility.keyboardControl = 0;
                singleSelect = GetItemAt(area, e.mousePosition);

                // Ensure a valid selection
                if (singleSelect != null && !singleSelect.Dummy)
                {
                    // Double click handling
                    if (e.button == 0 && e.clickCount > 1 && singleSelect.Asset != null)
                    {
                        singleSelect.Asset.Edit();
                    }

                    // Expand/Contract
                    if (e.button < 2)
                    {
                        float x = area.x + ((singleSelect.Indent - 1) * 18);
                        if (e.mousePosition.x >= x && e.mousePosition.x < x + 16 && singleSelect.CanExpand)
                        {
                            singleSelect.Expanded = !singleSelect.Expanded;
                            CallExpandedEvent(singleSelect, true);
                            singleSelect = null;
                        }
                        else if (e.control || e.command)
                        {
                            // Right clicking can never de-toggle something
                            if (e.button == 1)
                            {
                                SelectedAdd(singleSelect);
                            }
                            else
                            {
                                SelectedToggle(singleSelect);
                            }
                            singleSelect = null;
                        }
                        else if (e.shift)
                        {
                            SelectionFlow(singleSelect);
                            singleSelect = null;
                        }
                        else
                        {
                            if (!IsSelected(singleSelect))
                            {
                                SelectedSet(singleSelect);
                                // Do not set singleSelect to null in order for drag to
                                // know what is dragged
                                singleSelect = null;
                            }
                        }
                    }
                }
                else if (e.button == 0)
                {
                    // Clear selection when a click was made on nothing
                    SelectedClear();
                    singleSelect = null;
                }
            }
            // Handle mouse up clicks
            else if ((e.type == EventType.MouseUp || e.type == EventType.ContextClick) && mouseInArea)
            {
                GUIUtility.keyboardControl = 0;
                singleSelect = GetItemAt(area, e.mousePosition);
                dragCount    = 0;
                repaint      = true;

                if (singleSelect != null && !singleSelect.Dummy)
                {
                    // right click menus - we pass the static index of the list so the menu can find what is selected
                    if (e.type == EventType.ContextClick)
                    {
                        singleSelect = null;

                        if (!IsSelectedAsset() && !string.IsNullOrEmpty(menuFolder))
                        {
                            s_uniqueIDList[uniqueID] = this;
                            EditorUtility.DisplayPopupMenu(new Rect(e.mousePosition.x, e.mousePosition.y, 0, 0), menuFolder, new MenuCommand(null, uniqueID));
                        }
                        else if (!string.IsNullOrEmpty(menuDefault))
                        {
                            s_uniqueIDList[uniqueID] = this;
                            EditorUtility.DisplayPopupMenu(new Rect(e.mousePosition.x, e.mousePosition.y, 0, 0), menuDefault, new MenuCommand(null, uniqueID));
                        }
                    }
                    // Left click up should set selection if singleSelect is in selection since
                    // this is the case where the user has clicked and hold on a selection (which may start a drag or not)
                    // and then released it.
                    else if (e.type != EventType.ContextClick && e.button == 0 && !(e.control || e.command || e.shift))
                    {
                        if (IsSelected(singleSelect))
                        {
                            SelectedSet(singleSelect);
                            singleSelect = null;
                        }
                    }
                }
            }

            if (e.type == EventType.MouseDrag && mouseInArea)
            {
                // Ive added this to stop the accidental drag messages that pop up
                // you only seem to get one when its not intentional so this should
                // give a better effect.
                ++dragCount;

                if (dragCount > 2 && Selection.objects.Length > 0)
                {
                    DragAndDrop.PrepareStartDrag();
                    if (singleSelect != null)
                    {
                        DragAndDrop.objectReferences = new UnityEngine.Object[] { singleSelect.Asset.Load() };
                    }
                    else
                    {
                        DragAndDrop.objectReferences = Selection.objects;
                    }
                    DragAndDrop.StartDrag("Move");
                }
            }

            // Drag has been updated
            if (e.type == EventType.DragUpdated)
            {
                repaint = true;
                DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                dragTarget             = GetItemAt(area, e.mousePosition);

                // Dont target selected items
                if (dragTarget != null)
                {
                    if (IsSelected(dragTarget))
                    {
                        dragTarget = null;
                    }
                    else
                    {
                        if (dragAcceptOnly)
                        {
                            if (!dragTarget.CanAccept)
                            {
                                dragTarget = null;
                            }
                        }
                        else
                        {
                            bool  canPrev = !dragTarget.CanAccept || dragTarget.PrevOpenVisible != dragTarget.Parent;
                            bool  canNext = !dragTarget.CanAccept || dragTarget.NextOpenVisible != dragTarget.FirstChild;
                            float size    = dragTarget.CanAccept ? 2 : c_lineHeight / 2;
                            int   index   = (int)((e.mousePosition.y - area.y) / c_lineHeight);
                            float pos     = area.y + (index * c_lineHeight);
                            dragAdjust = SelectDirection.Current;

                            if (canPrev && e.mousePosition.y <= pos + size)
                            {
                                dragAdjust = SelectDirection.Up;
                            }
                            else if (canNext && e.mousePosition.y >= pos + c_lineHeight - size)
                            {
                                dragAdjust = SelectDirection.Down;
                            }
                        }
                    }
                }
            }

            // Drag and drop completion
            if (e.type == EventType.DragPerform)
            {
                if (dragTarget != null)
                {
                    ListItem drag = dragAdjust == SelectDirection.Current ? dragTarget : dragTarget.Parent;
                    if (dragDelegate != null && drag != null && drag.CanAccept)
                    {
                        dragDelegate(drag.Change);
                    }

                    dragTarget = null;
                }
            }

            if (e.type == EventType.DragExited)
            {
                dragTarget = null;
            }
            return(repaint);
        }
Exemplo n.º 10
0
 private void SelectedAllHelper(ListItem _root)
 {
     for (ListItem item = _root.FirstChild; item != null; item = item.Next)
     {
         if (item.HasChildren)
         {
             this.SelectedAllHelper(item);
         }
         if (item.Asset != null)
         {
             this.SelectedAdd(item);
         }
     }
 }
Exemplo n.º 11
0
 private ListItem SelectedLastIn(ListItem root)
 {
     ListItem item = this.SelectedCurrentIn(root);
     for (ListItem item2 = item; item2 != null; item2 = item2.NextOpenVisible)
     {
         if (this.IsSelected(item2))
         {
             item = item2;
         }
     }
     return item;
 }
Exemplo n.º 12
0
 private ListItem GetTwinMeta(ListItem item)
 {
     ListItem next = item.Next;
     if ((!item.Name.EndsWith(".meta") && (next != null)) && ((next.Asset != null) && (next.Asset.path.ToLower() == AssetDatabase.GetTextMetaFilePathFromAssetPath(item.Asset.path).ToLower())))
     {
         return next;
     }
     return null;
 }
Exemplo n.º 13
0
 private bool ScrollUpTo(ListItem item)
 {
     int scroll = (int) this.listState.Scroll;
     for (ListItem item2 = (this.visibleList.Count <= 0) ? null : this.visibleList[0]; (item2 != null) && (scroll >= 0); item2 = item2.PrevOpenVisible)
     {
         if (item2 == item)
         {
             this.listState.Scroll = scroll;
             return true;
         }
         scroll--;
     }
     return false;
 }
Exemplo n.º 14
0
 private ListItem GetTwin(ListItem item)
 {
     ListItem twinAsset = this.GetTwinAsset(item);
     if (twinAsset != null)
     {
         return twinAsset;
     }
     return this.GetTwinMeta(item);
 }
Exemplo n.º 15
0
 private ListItem GetTwinAsset(ListItem item)
 {
     ListItem prev = item.Prev;
     if ((item.Name.EndsWith(".meta") && (prev != null)) && ((prev.Asset != null) && (AssetDatabase.GetTextMetaFilePathFromAssetPath(prev.Asset.path).ToLower() == item.Asset.path.ToLower())))
     {
         return prev;
     }
     return null;
 }
Exemplo n.º 16
0
 private void DrawItem(ListItem item, Rect area, float x, float y, bool focus, bool selected)
 {
     bool flag = item == this.dragTarget;
     bool flag2 = selected;
     if (selected)
     {
         Texture2D image = !focus ? this.greyTex : this.blueTex;
         GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), image, ScaleMode.StretchToFill, false);
     }
     else if (!flag)
     {
         if (((this.dragTarget != null) && (item == this.dragTarget.Parent)) && (this.dragAdjust != SelectDirection.Current))
         {
             GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), this.yellowTex, ScaleMode.StretchToFill, false);
             flag2 = true;
         }
     }
     else
     {
         SelectDirection dragAdjust = this.dragAdjust;
         if (dragAdjust == SelectDirection.Up)
         {
             if (item.PrevOpenVisible != item.Parent)
             {
                 GUI.DrawTexture(new Rect(x, y - 1f, area.width, 2f), this.yellowTex, ScaleMode.StretchToFill, false);
             }
         }
         else if (dragAdjust == SelectDirection.Down)
         {
             GUI.DrawTexture(new Rect(x, (y + 16f) - 1f, area.width, 2f), this.yellowTex, ScaleMode.StretchToFill, false);
         }
         else if (item.CanAccept)
         {
             GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), this.yellowTex, ScaleMode.StretchToFill, false);
             flag2 = true;
         }
     }
     if (item.HasActions)
     {
         for (int i = 0; i < item.Actions.Length; i++)
         {
             this.calcSizeTmpContent.text = item.Actions[i];
             Vector2 vector = GUI.skin.button.CalcSize(this.calcSizeTmpContent);
             if (GUI.Button(new Rect(x, y, vector.x, 16f), item.Actions[i]))
             {
                 this.actionDelegate(item, i);
             }
             x += vector.x + 4f;
         }
     }
     if (item.CanExpand)
     {
         EditorGUI.Foldout(new Rect(x, y, 16f, 16f), item.Expanded, GUIContent.none);
     }
     Texture icon = item.Icon;
     Color color = GUI.color;
     Color contentColor = GUI.contentColor;
     if (item.Dummy)
     {
         GUI.color = new Color(0.65f, 0.65f, 0.65f);
     }
     if (!item.Dummy)
     {
         if (icon == null)
         {
             icon = InternalEditorUtility.GetIconForFile(item.Name);
         }
         Rect position = new Rect(x + 14f, y, 16f, 16f);
         if (icon != null)
         {
             GUI.DrawTexture(position, icon);
         }
         if (item.Asset != null)
         {
             Rect itemRect = position;
             itemRect.width += 12f;
             itemRect.x -= 6f;
             Overlay.DrawOverlay(item.Asset, itemRect);
         }
     }
     string t = this.DisplayName(item);
     Vector2 vector2 = EditorStyles.label.CalcSize(EditorGUIUtility.TempContent(t));
     float num2 = x + 32f;
     if (flag2)
     {
         GUI.contentColor = new Color(3f, 3f, 3f);
         GUI.Label(new Rect(num2, y, area.width - num2, 18f), t);
     }
     else
     {
         GUI.Label(new Rect(num2, y, area.width - num2, 18f), t);
     }
     if (this.HasHiddenMetaFile(item))
     {
         GUI.color = new Color(0.55f, 0.55f, 0.55f);
         float num3 = (num2 + vector2.x) + 2f;
         GUI.Label(new Rect(num3, y, area.width - num3, 18f), "+meta");
     }
     GUI.contentColor = contentColor;
     GUI.color = color;
 }
Exemplo n.º 17
0
 private string DisplayName(ListItem item)
 {
     string name = item.Name;
     string str2 = "";
     while (str2 == "")
     {
         int index = name.IndexOf('\n');
         if (index < 0)
         {
             break;
         }
         str2 = name.Substring(0, index).Trim();
         name = name.Substring(index + 1);
     }
     if (str2 != "")
     {
         name = str2;
     }
     name = name.Trim();
     if ((name == "") && (item.Change != null))
     {
         name = item.Change.id.ToString() + " " + item.Change.description;
     }
     return name;
 }
Exemplo n.º 18
0
 private void SetIntent(ListItem listItem, int indent)
 {
   listItem.indent = indent;
   for (ListItem listItem1 = listItem.FirstChild; listItem1 != null; listItem1 = listItem1.Next)
     this.SetIntent(listItem1, indent + 1);
 }
Exemplo n.º 19
0
        // Parse all key input supported by the list here
        void HandleKeyInput(Event e)
        {
            // Only handle blip events in here on
            if (e.type != EventType.KeyDown)
            {
                return;
            }

            // Nothing selected?
            if (selectList.Count == 0)
            {
                return;
            }

            //  Arrow key up
            if (e.keyCode == KeyCode.UpArrow || e.keyCode == KeyCode.DownArrow)
            {
                ListItem sel = null;

                if (e.keyCode == KeyCode.UpArrow)
                {
                    sel = SelectedFirstIn(active);
                    if (sel != null)
                    {
                        sel = sel.PrevOpenSkip;
                    }
                }
                else
                {
                    sel = SelectedLastIn(active);
                    if (sel != null)
                    {
                        sel = sel.NextOpenSkip;
                    }
                }

                if (sel != null)
                {
                    // Ensure that the item is in view - linear search but handles all the corner cases
                    if (!ScrollUpTo(sel))
                    {
                        ScrollDownTo(sel);
                    }

                    if (e.shift)
                    {
                        SelectionFlow(sel);
                    }
                    else
                    {
                        SelectedSet(sel);
                    }
                }
            }

            // Expand/contract on left/right arrow keys
            if (e.keyCode == KeyCode.LeftArrow || e.keyCode == KeyCode.RightArrow)
            {
                ListItem sel = SelectedCurrentIn(active);
                sel.Expanded = (e.keyCode == KeyCode.RightArrow);
                CallExpandedEvent(sel, true);
            }

            // Edit on return key
            if (e.keyCode == KeyCode.Return && GUIUtility.keyboardControl == 0)
            {
                ListItem sel = SelectedCurrentIn(active);
                sel.Asset.Edit();
            }
        }
Exemplo n.º 20
0
 private bool HandleMouse(Rect area)
 {
     Event current = Event.current;
     bool flag = false;
     bool flag2 = area.Contains(current.mousePosition);
     if ((current.type == EventType.MouseDown) && flag2)
     {
         flag = true;
         this.dragCount = 0;
         GUIUtility.keyboardControl = 0;
         this.singleSelect = this.GetItemAt(area, current.mousePosition);
         if ((this.singleSelect != null) && !this.singleSelect.Dummy)
         {
             if (((current.button == 0) && (current.clickCount > 1)) && (this.singleSelect.Asset != null))
             {
                 this.singleSelect.Asset.Edit();
             }
             if (current.button < 2)
             {
                 float num = area.x + ((this.singleSelect.Indent - 1) * 0x12);
                 if (((current.mousePosition.x >= num) && (current.mousePosition.x < (num + 16f))) && this.singleSelect.CanExpand)
                 {
                     this.singleSelect.Expanded = !this.singleSelect.Expanded;
                     this.CallExpandedEvent(this.singleSelect, true);
                     this.singleSelect = null;
                 }
                 else if (current.control || current.command)
                 {
                     if (current.button == 1)
                     {
                         this.SelectedAdd(this.singleSelect);
                     }
                     else
                     {
                         this.SelectedToggle(this.singleSelect);
                     }
                     this.singleSelect = null;
                 }
                 else if (current.shift)
                 {
                     this.SelectionFlow(this.singleSelect);
                     this.singleSelect = null;
                 }
                 else if (!this.IsSelected(this.singleSelect))
                 {
                     this.SelectedSet(this.singleSelect);
                     this.singleSelect = null;
                 }
             }
         }
         else if (current.button == 0)
         {
             this.SelectedClear();
             this.singleSelect = null;
         }
     }
     else if (((current.type == EventType.MouseUp) || (current.type == EventType.ContextClick)) && flag2)
     {
         GUIUtility.keyboardControl = 0;
         this.singleSelect = this.GetItemAt(area, current.mousePosition);
         this.dragCount = 0;
         flag = true;
         if ((this.singleSelect != null) && !this.singleSelect.Dummy)
         {
             if (current.type == EventType.ContextClick)
             {
                 this.singleSelect = null;
                 if (!this.IsSelectedAsset() && !string.IsNullOrEmpty(this.menuFolder))
                 {
                     s_uniqueIDList[this.uniqueID] = this;
                     EditorUtility.DisplayPopupMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), this.menuFolder, new MenuCommand(null, this.uniqueID));
                 }
                 else if (!string.IsNullOrEmpty(this.menuDefault))
                 {
                     s_uniqueIDList[this.uniqueID] = this;
                     EditorUtility.DisplayPopupMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), this.menuDefault, new MenuCommand(null, this.uniqueID));
                 }
             }
             else if (((((current.type != EventType.ContextClick) && (current.button == 0)) && (!current.control && !current.command)) && !current.shift) && this.IsSelected(this.singleSelect))
             {
                 this.SelectedSet(this.singleSelect);
                 this.singleSelect = null;
             }
         }
     }
     if ((current.type == EventType.MouseDrag) && flag2)
     {
         this.dragCount++;
         if ((this.dragCount > 2) && (Selection.objects.Length > 0))
         {
             DragAndDrop.PrepareStartDrag();
             if (this.singleSelect != null)
             {
                 DragAndDrop.objectReferences = new Object[] { this.singleSelect.Asset.Load() };
             }
             else
             {
                 DragAndDrop.objectReferences = Selection.objects;
             }
             DragAndDrop.StartDrag("Move");
         }
     }
     if (current.type == EventType.DragUpdated)
     {
         flag = true;
         DragAndDrop.visualMode = DragAndDropVisualMode.Move;
         this.dragTarget = this.GetItemAt(area, current.mousePosition);
         if (this.dragTarget != null)
         {
             if (this.IsSelected(this.dragTarget))
             {
                 this.dragTarget = null;
             }
             else if (this.dragAcceptOnly)
             {
                 if (!this.dragTarget.CanAccept)
                 {
                     this.dragTarget = null;
                 }
             }
             else
             {
                 bool flag3 = !this.dragTarget.CanAccept || (this.dragTarget.PrevOpenVisible != this.dragTarget.Parent);
                 bool flag4 = !this.dragTarget.CanAccept || (this.dragTarget.NextOpenVisible != this.dragTarget.FirstChild);
                 float num2 = !this.dragTarget.CanAccept ? 8f : 2f;
                 int num3 = (int) ((current.mousePosition.y - area.y) / 16f);
                 float num4 = area.y + (num3 * 16f);
                 this.dragAdjust = SelectDirection.Current;
                 if (flag3 && (current.mousePosition.y <= (num4 + num2)))
                 {
                     this.dragAdjust = SelectDirection.Up;
                 }
                 else if (flag4 && (current.mousePosition.y >= ((num4 + 16f) - num2)))
                 {
                     this.dragAdjust = SelectDirection.Down;
                 }
             }
         }
     }
     if ((current.type == EventType.DragPerform) && (this.dragTarget != null))
     {
         ListItem item = (this.dragAdjust != SelectDirection.Current) ? this.dragTarget.Parent : this.dragTarget;
         if (((this.dragDelegate != null) && (item != null)) && item.CanAccept)
         {
             this.dragDelegate(item.Change);
         }
         this.dragTarget = null;
     }
     if (current.type == EventType.DragExited)
     {
         this.dragTarget = null;
     }
     return flag;
 }
Exemplo n.º 21
0
 private bool ScrollDownTo(ListItem item)
 {
     int scroll = (int) this.listState.Scroll;
     for (ListItem item2 = (this.visibleList.Count <= 0) ? null : this.visibleList[this.visibleList.Count - 1]; (item2 != null) && (scroll >= 0); item2 = item2.NextOpenVisible)
     {
         if (item2 == item)
         {
             this.listState.Scroll = scroll;
             return true;
         }
         scroll++;
     }
     return false;
 }
Exemplo n.º 22
0
 private void CallExpandedEvent(ListItem item, bool remove)
 {
     if (item.Change != null)
     {
         if (item.Expanded)
         {
             if (this.expandDelegate != null)
             {
                 this.expandDelegate(item.Change, item);
             }
             this.listState.Expanded.Add(item.Change.id);
         }
         else if (remove)
         {
             this.listState.Expanded.Remove(item.Change.id);
         }
     }
     for (ListItem item2 = item.FirstChild; item2 != null; item2 = item2.Next)
     {
         this.CallExpandedEvent(item2, remove);
     }
 }
Exemplo n.º 23
0
 public void SelectedAdd(ListItem item)
 {
     if (!item.Dummy)
     {
         ListItem item2 = this.SelectedCurrentIn(this.active);
         if (item.Exclusive || ((item2 != null) && item2.Exclusive))
         {
             this.SelectedSet(item);
         }
         else
         {
             string str = item.Asset.path.ToLower();
             int count = this.selectList.Count;
             this.selectList[str] = item;
             ListItem twin = this.GetTwin(item);
             if (twin != null)
             {
                 this.selectList[twin.Asset.path.ToLower()] = twin;
             }
             if (count != this.selectList.Count)
             {
                 int[] instanceIDs = Selection.instanceIDs;
                 int index = 0;
                 if (instanceIDs != null)
                 {
                     index = instanceIDs.Length;
                 }
                 str = !str.EndsWith(".meta") ? str : str.Substring(0, str.Length - 5);
                 char[] trimChars = new char[] { '/' };
                 int mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(str.TrimEnd(trimChars));
                 if (mainAssetInstanceID != 0)
                 {
                     int[] destinationArray = new int[index + 1];
                     destinationArray[index] = mainAssetInstanceID;
                     Array.Copy(instanceIDs, destinationArray, index);
                     Selection.instanceIDs = destinationArray;
                 }
             }
         }
     }
 }
Exemplo n.º 24
0
 private void SelectedToggle(ListItem item)
 {
     if (this.IsSelected(item))
     {
         this.SelectedRemove(item);
     }
     else
     {
         this.SelectedAdd(item);
     }
 }
Exemplo n.º 25
0
 private ListItem SelectedCurrentIn(ListItem root)
 {
     foreach (KeyValuePair<string, ListItem> pair in this.selectList)
     {
         if (pair.Value.IsChildOf(root))
         {
             return pair.Value;
         }
     }
     return null;
 }
Exemplo n.º 26
0
 private bool SelectionFlowUp(ListItem item)
 {
     ListItem item2;
     ListItem item3 = item;
     for (item2 = item; item2 != null; item2 = item2.PrevOpenVisible)
     {
         if (this.IsSelected(item2))
         {
             item3 = item2;
         }
     }
     if (item == item3)
     {
         return false;
     }
     this.SelectedClear();
     this.SelectedAdd(item3);
     for (item2 = item; item2 != item3; item2 = item2.PrevOpenVisible)
     {
         this.SelectedAdd(item2);
     }
     return true;
 }
Exemplo n.º 27
0
 private void SelectedRemove(ListItem item)
 {
     string key = item.Asset.path.ToLower();
     this.selectList.Remove(key);
     this.selectList.Remove(!key.EndsWith(".meta") ? (key + ".meta") : key.Substring(0, key.Length - 5));
     key = !key.EndsWith(".meta") ? key : key.Substring(0, key.Length - 5);
     char[] trimChars = new char[] { '/' };
     int mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(key.TrimEnd(trimChars));
     int[] instanceIDs = Selection.instanceIDs;
     if ((mainAssetInstanceID != 0) && (instanceIDs.Length > 0))
     {
         int index = Array.IndexOf<int>(instanceIDs, mainAssetInstanceID);
         if (index >= 0)
         {
             int[] destinationArray = new int[instanceIDs.Length - 1];
             Array.Copy(instanceIDs, destinationArray, index);
             if (index < (instanceIDs.Length - 1))
             {
                 Array.Copy(instanceIDs, index + 1, destinationArray, index, (instanceIDs.Length - index) - 1);
             }
             Selection.instanceIDs = destinationArray;
         }
     }
 }
Exemplo n.º 28
0
        // Draw a list item.  A few too many magic numbers in here so will need to tidy this a bit
        void DrawItem(ListItem item, Rect area, float x, float y, bool focus, bool selected)
        {
            bool drag      = (item == dragTarget);
            bool highlight = selected;

            if (selected)
            {
                Texture2D selectTex = focus ? blueTex : greyTex;
                GUI.DrawTexture(new Rect(area.x, y, area.width, c_lineHeight), selectTex, ScaleMode.StretchToFill, false);
            }
            else if (drag)
            {
                switch (dragAdjust)
                {
                case SelectDirection.Up:
                    if (item.PrevOpenVisible != item.Parent)
                    {
                        GUI.DrawTexture(new Rect(x, y - 1, area.width, 2), yellowTex, ScaleMode.StretchToFill, false);
                    }
                    break;

                case SelectDirection.Down:
                    GUI.DrawTexture(new Rect(x, y + c_lineHeight - 1, area.width, 2), yellowTex, ScaleMode.StretchToFill, false);
                    break;

                default:
                    if (item.CanAccept)
                    {
                        GUI.DrawTexture(new Rect(area.x, y, area.width, c_lineHeight), yellowTex, ScaleMode.StretchToFill, false);
                        highlight = true;
                    }
                    break;
                }
            }
            else if (dragTarget != null && item == dragTarget.Parent && dragAdjust != SelectDirection.Current)
            {
                GUI.DrawTexture(new Rect(area.x, y, area.width, c_lineHeight), yellowTex, ScaleMode.StretchToFill, false);
                highlight = true;
            }

            if (item.HasActions)
            {
                // Draw any actions available
                for (int i = 0; i < item.Actions.Length; ++i)
                {
                    calcSizeTmpContent.text = item.Actions[i];
                    Vector2 sz = GUI.skin.button.CalcSize(calcSizeTmpContent);
                    if (GUI.Button(new Rect(x, y, sz.x, c_lineHeight), item.Actions[i]))
                    {
                        // Action performed. Callback delegate
                        actionDelegate(item, i);
                    }
                    x += sz.x + 4; // offset by 4 px
                }
            }

            if (item.CanExpand)
            {
                EditorGUI.Foldout(new Rect(x, y, 16, c_lineHeight), item.Expanded, GUIContent.none);
            }

            Texture icon            = item.Icon;
            Color   tmpColor        = GUI.color;
            Color   tmpContentColor = GUI.contentColor;

            // We grey the items when we dont know the state or its a dummy item
            if (/*item.Asset.State == Asset.States.Local ||*/ item.Dummy) //< Locals shown with icon for now
            {
                GUI.color = new Color(0.65f, 0.65f, 0.65f);
            }

            // This should not be an else statement as the previous if can set icon
            if (!item.Dummy)
            {
                // If there is no icon set then we look for cached items
                if (icon == null)
                {
                    icon = InternalEditorUtility.GetIconForFile(item.Name);
                    //                  icon = defaultIcon;
                }

                var iconRect = new Rect(x + 14, y, 16, c_lineHeight);

                if (icon != null)
                {
                    GUI.DrawTexture(iconRect, icon);
                }

                if (item.Asset != null)
                {
                    bool   drawOverlay = true;
                    string vcsType     = EditorSettings.externalVersionControl;
                    if (vcsType == ExternalVersionControl.Disabled ||
                        vcsType == ExternalVersionControl.AutoDetect ||
                        vcsType == ExternalVersionControl.Generic)
                    {
                        drawOverlay = false; // no overlays for these version control systems
                    }
                    if (drawOverlay)
                    {
                        Rect overlayRect = iconRect;
                        overlayRect.width += 12;
                        overlayRect.x     -= 6;
                        Overlay.DrawOverlay(item.Asset, overlayRect);
                    }
                }
            }

            string  displayName     = DisplayName(item);
            Vector2 displayNameSize = EditorStyles.label.CalcSize(EditorGUIUtility.TempContent(displayName));
            float   labelOffsetX    = x + 32;

            if (highlight)
            {
                GUI.contentColor = new Color(3, 3, 3);
                GUI.Label(new Rect(labelOffsetX, y, area.width - labelOffsetX, c_lineHeight + 2), displayName);
            }
            else
            {
                GUI.Label(new Rect(labelOffsetX, y, area.width - labelOffsetX, c_lineHeight + 2), displayName);
            }

            if (HasHiddenMetaFile(item))
            {
                GUI.color = new Color(0.55f, 0.55f, 0.55f);
                float spaceBefore = labelOffsetX + displayNameSize.x + 2;
                GUI.Label(new Rect(spaceBefore, y, area.width - spaceBefore, c_lineHeight + 2), "+meta");
            }
            GUI.contentColor = tmpContentColor;
            GUI.color        = tmpColor;
        }
Exemplo n.º 29
0
 public void SelectedSet(ListItem item)
 {
     if (!item.Dummy)
     {
         this.SelectedClear();
         if (item.Asset != null)
         {
             this.SelectedAdd(item);
         }
         else if (item.Change != null)
         {
             this.selectList["_chkeyprfx_" + item.Change.id.ToString()] = item;
         }
     }
 }
Exemplo n.º 30
0
 private bool HasHiddenMetaFile(ListItem item)
 {
     ListItem twinMeta = this.GetTwinMeta(item);
     return ((twinMeta != null) && twinMeta.Hidden);
 }
Exemplo n.º 31
0
 private void SelectionFlow(ListItem item)
 {
     if (this.selectList.Count == 0)
     {
         this.SelectedSet(item);
     }
     else if (!this.SelectionFlowDown(item))
     {
         this.SelectionFlowUp(item);
     }
 }
Exemplo n.º 32
0
 private bool IsSelected(ListItem item)
 {
     if (item.Asset != null)
     {
         return this.selectList.ContainsKey(item.Asset.path.ToLower());
     }
     return ((item.Change != null) && this.selectList.ContainsKey("_chkeyprfx_" + item.Change.id.ToString()));
 }
Exemplo n.º 33
0
		private void OnExpand(ChangeSet change, ListItem item)
		{
			if (!Provider.isActive)
			{
				return;
			}
			Task task = Provider.ChangeSetStatus(change);
			task.userIdentifier = item.Identifier;
			task.SetCompletionAction(CompletionAction.OnChangeContentsPendingWindow);
			if (!item.HasChildren)
			{
				Asset asset = new Asset("Updating...");
				ListItem listItem = this.pendingList.Add(item, asset.prettyPath, asset);
				listItem.Dummy = true;
				this.pendingList.Refresh(false);
				base.Repaint();
			}
		}
Exemplo n.º 34
0
        private bool HasHiddenMetaFile(ListItem item)
        {
            ListItem twinMeta = GetTwinMeta(item);

            return(twinMeta != null && twinMeta.Hidden);
        }