Example #1
0
        public void UpdateGUI()
        {
            SplitterGUILayout.BeginHorizontalSplit(this.horSplit);
            GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]);
            GUILayout.Label(this.totalUpdates, this.constants.title, new GUILayoutOption[0]);
            foreach (ListViewElement listViewElement in ListViewGUILayout.ListView(this.lv, GUIStyle.none))
            {
                Rect position = listViewElement.position;
                ++position.x;
                ++position.y;
                if (Event.current.type == EventType.Repaint)
                {
                    if (listViewElement.row % 2 == 0)
                    {
                        this.constants.entryEven.Draw(position, false, false, false, false);
                    }
                    else
                    {
                        this.constants.entryOdd.Draw(position, false, false, false, false);
                    }
                }
                GUILayout.BeginVertical(listViewElement.row != this.lv.row ? this.constants.entryNormal : this.constants.entrySelected, new GUILayoutOption[0]);
                GUILayout.Label(this.messageFirstLines[listViewElement.row], this.constants.serverUpdateLog, new GUILayoutOption[1]
                {
                    GUILayout.MinWidth(50f)
                });
                GUILayout.BeginHorizontal();
                GUILayout.Label(this.changesets[listViewElement.row].changeset.ToString() + " " + this.changesets[listViewElement.row].date, this.constants.serverUpdateInfo, new GUILayoutOption[1]
                {
                    GUILayout.MinWidth(100f)
                });
                GUILayout.Label(this.changesets[listViewElement.row].owner, this.constants.serverUpdateInfo, new GUILayoutOption[1]
                {
                    GUILayout.Width((float)this.maxNickLength)
                });
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }
            if (this.lv.selectionChanged)
            {
                this.SetSelectedRevisionLine(this.lv.row);
            }
            GUILayout.EndVertical();
            SplitterGUILayout.BeginVerticalSplit(this.vertSplit);
            GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]);
            GUILayout.Label("Changeset", this.constants.title, new GUILayoutOption[0]);
            int folder1 = -1;
            int file    = -1;

            foreach (ListViewElement listViewElement in ListViewGUILayout.ListView(this.pv.lv, GUIStyle.none))
            {
                if (folder1 == -1 && !this.pv.IndexToFolderAndFile(listViewElement.row, ref folder1, ref file))
                {
                    return;
                }
                ParentViewFolder folder2 = this.pv.folders[folder1];
                if (ListViewGUILayout.HasMouseDown(listViewElement.position))
                {
                    if (Event.current.clickCount == 2)
                    {
                        if (!this.isDirSelected && this.selectedGUID != string.Empty)
                        {
                            this.DoShowDiff(false);
                            GUIUtility.ExitGUI();
                        }
                    }
                    else
                    {
                        this.pv.lv.scrollPos = ListViewShared.ListViewScrollToRow((ListViewShared.InternalListViewState) this.pv.lv.ilvState, listViewElement.row);
                        this.DoSelect(folder1, file, listViewElement.row);
                    }
                }
                else if (ListViewGUILayout.HasMouseDown(listViewElement.position, 1))
                {
                    if (this.lv.row != listViewElement.row)
                    {
                        this.DoSelect(folder1, file, listViewElement.row);
                    }
                    if (!this.isDirSelected && this.selectedGUID != string.Empty)
                    {
                        GUIUtility.hotControl = 0;
                        EditorUtility.DisplayCustomMenu(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 1f, 1f), this.dropDownMenuItems, (int[])null, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), (object)null);
                        Event.current.Use();
                    }
                }
                if (listViewElement.row == this.pv.lv.row && Event.current.type == EventType.Repaint)
                {
                    this.constants.entrySelected.Draw(listViewElement.position, false, false, false, false);
                }
                ChangeFlags changeFlags;
                if (file != -1)
                {
                    Texture2D texture2D = AssetDatabase.GetCachedIcon(folder2.name + "/" + folder2.files[file].name) as Texture2D;
                    if ((UnityEngine.Object)texture2D == (UnityEngine.Object)null)
                    {
                        texture2D = InternalEditorUtility.GetIconForFile(folder2.files[file].name);
                    }
                    GUILayout.Label(new GUIContent(folder2.files[file].name, (Texture)texture2D), this.constants.element, new GUILayoutOption[0]);
                    changeFlags = folder2.files[file].changeFlags;
                }
                else
                {
                    GUILayout.Label(folder2.name, this.constants.header, new GUILayoutOption[0]);
                    changeFlags = folder2.changeFlags;
                }
                GUIContent content = (GUIContent)null;
                if (this.HasFlag(changeFlags, ChangeFlags.Undeleted) || this.HasFlag(changeFlags, ChangeFlags.Created))
                {
                    content = ASMainWindow.constants.badgeNew;
                }
                else if (this.HasFlag(changeFlags, ChangeFlags.Deleted))
                {
                    content = ASMainWindow.constants.badgeDelete;
                }
                else if (this.HasFlag(changeFlags, ChangeFlags.Renamed) || this.HasFlag(changeFlags, ChangeFlags.Moved))
                {
                    content = ASMainWindow.constants.badgeMove;
                }
                if (content != null && Event.current.type == EventType.Repaint)
                {
                    Rect position = new Rect((float)((double)listViewElement.position.x + (double)listViewElement.position.width - (double)content.image.width - 5.0), listViewElement.position.y + listViewElement.position.height / 2f - (float)(content.image.height / 2), (float)content.image.width, (float)content.image.height);
                    EditorGUIUtility.SetIconSize(Vector2.zero);
                    GUIStyle.none.Draw(position, content, false, false, false, false);
                    EditorGUIUtility.SetIconSize(this.iconSize);
                }
                this.pv.NextFileFolder(ref folder1, ref file);
            }
            if (this.pv.lv.selectionChanged && this.selectedGUID != string.Empty)
            {
                if (this.selectedGUID != AssetServer.GetRootGUID())
                {
                    AssetServer.SetSelectionFromGUID(this.selectedGUID);
                }
                else
                {
                    AssetServer.SetSelectionFromGUID(string.Empty);
                }
            }
            if (GUIUtility.keyboardControl == this.pv.lv.ID && Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Return && !this.isDirSelected) && this.selectedGUID != string.Empty)
            {
                this.DoShowDiff(false);
                GUIUtility.ExitGUI();
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]);
            GUILayout.Label("Update Message", this.constants.title, new GUILayoutOption[0]);
            GUILayout.TextArea(this.lv.row < 0 ? string.Empty : this.changesets[this.lv.row].message, this.constants.wwText, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            SplitterGUILayout.EndVerticalSplit();
            SplitterGUILayout.EndHorizontalSplit();
        }
        public void UpdateGUI()
        {
            SplitterGUILayout.BeginHorizontalSplit(this.horSplit, new GUILayoutOption[0]);
            GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]);
            GUILayout.Label(this.totalUpdates, this.constants.title, new GUILayoutOption[0]);
            IEnumerator enumerator = ListViewGUILayout.ListView(this.lv, GUIStyle.none, new GUILayoutOption[0]).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    ListViewElement listViewElement = (ListViewElement)enumerator.Current;
                    Rect            position        = listViewElement.position;
                    position.x += 1f;
                    position.y += 1f;
                    if (Event.current.type == EventType.Repaint)
                    {
                        if (listViewElement.row % 2 == 0)
                        {
                            this.constants.entryEven.Draw(position, false, false, false, false);
                        }
                        else
                        {
                            this.constants.entryOdd.Draw(position, false, false, false, false);
                        }
                    }
                    GUILayout.BeginVertical((listViewElement.row != this.lv.row) ? this.constants.entryNormal : this.constants.entrySelected, new GUILayoutOption[0]);
                    GUILayout.Label(this.messageFirstLines[listViewElement.row], this.constants.serverUpdateLog, new GUILayoutOption[]
                    {
                        GUILayout.MinWidth(50f)
                    });
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    GUILayout.Label(this.changesets[listViewElement.row].changeset.ToString() + " " + this.changesets[listViewElement.row].date, this.constants.serverUpdateInfo, new GUILayoutOption[]
                    {
                        GUILayout.MinWidth(100f)
                    });
                    GUILayout.Label(this.changesets[listViewElement.row].owner, this.constants.serverUpdateInfo, new GUILayoutOption[]
                    {
                        GUILayout.Width((float)this.maxNickLength)
                    });
                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            if (this.lv.selectionChanged)
            {
                this.SetSelectedRevisionLine(this.lv.row);
            }
            GUILayout.EndVertical();
            SplitterGUILayout.BeginVerticalSplit(this.vertSplit, new GUILayoutOption[0]);
            GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]);
            GUILayout.Label("Changeset", this.constants.title, new GUILayoutOption[0]);
            int         num         = -1;
            int         num2        = -1;
            IEnumerator enumerator2 = ListViewGUILayout.ListView(this.pv.lv, GUIStyle.none, new GUILayoutOption[0]).GetEnumerator();

            try
            {
                while (enumerator2.MoveNext())
                {
                    ListViewElement listViewElement2 = (ListViewElement)enumerator2.Current;
                    if (num == -1 && !this.pv.IndexToFolderAndFile(listViewElement2.row, ref num, ref num2))
                    {
                        return;
                    }
                    ParentViewFolder parentViewFolder = this.pv.folders[num];
                    if (ListViewGUILayout.HasMouseDown(listViewElement2.position))
                    {
                        if (Event.current.clickCount == 2)
                        {
                            if (!this.isDirSelected && this.selectedGUID != string.Empty)
                            {
                                this.DoShowDiff(false);
                                GUIUtility.ExitGUI();
                            }
                        }
                        else
                        {
                            this.pv.lv.scrollPos = ListViewShared.ListViewScrollToRow(this.pv.lv.ilvState, listViewElement2.row);
                            this.DoSelect(num, num2, listViewElement2.row);
                        }
                    }
                    else if (ListViewGUILayout.HasMouseDown(listViewElement2.position, 1))
                    {
                        if (this.lv.row != listViewElement2.row)
                        {
                            this.DoSelect(num, num2, listViewElement2.row);
                        }
                        if (!this.isDirSelected && this.selectedGUID != string.Empty)
                        {
                            GUIUtility.hotControl = 0;
                            Rect position2 = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 1f, 1f);
                            EditorUtility.DisplayCustomMenu(position2, this.dropDownMenuItems, null, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null);
                            Event.current.Use();
                        }
                    }
                    if (listViewElement2.row == this.pv.lv.row && Event.current.type == EventType.Repaint)
                    {
                        this.constants.entrySelected.Draw(listViewElement2.position, false, false, false, false);
                    }
                    ChangeFlags changeFlags;
                    if (num2 != -1)
                    {
                        Texture2D texture2D = AssetDatabase.GetCachedIcon(parentViewFolder.name + "/" + parentViewFolder.files[num2].name) as Texture2D;
                        if (texture2D == null)
                        {
                            texture2D = InternalEditorUtility.GetIconForFile(parentViewFolder.files[num2].name);
                        }
                        GUILayout.Label(new GUIContent(parentViewFolder.files[num2].name, texture2D), this.constants.element, new GUILayoutOption[0]);
                        changeFlags = parentViewFolder.files[num2].changeFlags;
                    }
                    else
                    {
                        GUILayout.Label(parentViewFolder.name, this.constants.header, new GUILayoutOption[0]);
                        changeFlags = parentViewFolder.changeFlags;
                    }
                    GUIContent gUIContent = null;
                    if (this.HasFlag(changeFlags, ChangeFlags.Undeleted) || this.HasFlag(changeFlags, ChangeFlags.Created))
                    {
                        gUIContent = ASMainWindow.constants.badgeNew;
                    }
                    else if (this.HasFlag(changeFlags, ChangeFlags.Deleted))
                    {
                        gUIContent = ASMainWindow.constants.badgeDelete;
                    }
                    else if (this.HasFlag(changeFlags, ChangeFlags.Renamed) || this.HasFlag(changeFlags, ChangeFlags.Moved))
                    {
                        gUIContent = ASMainWindow.constants.badgeMove;
                    }
                    if (gUIContent != null && Event.current.type == EventType.Repaint)
                    {
                        Rect position3 = new Rect(listViewElement2.position.x + listViewElement2.position.width - (float)gUIContent.image.width - 5f, listViewElement2.position.y + listViewElement2.position.height / 2f - (float)(gUIContent.image.height / 2), (float)gUIContent.image.width, (float)gUIContent.image.height);
                        EditorGUIUtility.SetIconSize(Vector2.zero);
                        GUIStyle.none.Draw(position3, gUIContent, false, false, false, false);
                        EditorGUIUtility.SetIconSize(this.iconSize);
                    }
                    this.pv.NextFileFolder(ref num, ref num2);
                }
            }
            finally
            {
                IDisposable disposable2;
                if ((disposable2 = (enumerator2 as IDisposable)) != null)
                {
                    disposable2.Dispose();
                }
            }
            if (this.pv.lv.selectionChanged && this.selectedGUID != string.Empty)
            {
                if (this.selectedGUID != AssetServer.GetRootGUID())
                {
                    AssetServer.SetSelectionFromGUID(this.selectedGUID);
                }
                else
                {
                    AssetServer.SetSelectionFromGUID(string.Empty);
                }
            }
            if (GUIUtility.keyboardControl == this.pv.lv.ID)
            {
                if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return && !this.isDirSelected && this.selectedGUID != string.Empty)
                {
                    this.DoShowDiff(false);
                    GUIUtility.ExitGUI();
                }
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]);
            GUILayout.Label("Update Message", this.constants.title, new GUILayoutOption[0]);
            GUILayout.TextArea((this.lv.row < 0) ? "" : this.changesets[this.lv.row].message, this.constants.wwText, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            SplitterGUILayout.EndVerticalSplit();
            SplitterGUILayout.EndHorizontalSplit();
        }
Example #3
0
        public static ReorderableList GetList(SerializedProperty property, ReorderableAttribute attrib, int id, string arrayPropertyName)
        {
            if (property == null)
            {
                return(null);
            }

            ReorderableList    list  = null;
            SerializedProperty array = property.FindPropertyRelative(arrayPropertyName);

            if (array != null && array.isArray)
            {
                if (!lists.TryGetValue(id, out list))
                {
                    if (attrib != null)
                    {
                        Texture icon = !string.IsNullOrEmpty(attrib.elementIconPath) ? AssetDatabase.GetCachedIcon(attrib.elementIconPath) : null;

                        ReorderableList.ElementDisplayType displayType = attrib.singleLine ? ReorderableList.ElementDisplayType.SingleLine : ReorderableList.ElementDisplayType.Auto;

                        list          = new ReorderableList(array, attrib.add, attrib.remove, attrib.draggable, displayType, attrib.elementNameProperty, attrib.elementNameOverride, icon);
                        list.paginate = attrib.paginate;
                        list.pageSize = attrib.pageSize;
                        list.sortable = attrib.sortable;

                        //handle surrogate if any

                        if (attrib.surrogateType != null)
                        {
                            SurrogateCallback callback = new SurrogateCallback(attrib.surrogateProperty);

                            list.surrogate = new ReorderableList.Surrogate(attrib.surrogateType, callback.SetReference);
                        }
                    }
                    else
                    {
                        list = new ReorderableList(array, true, true, true);
                    }

                    lists.Add(id, list);
                }
                else
                {
                    list.List = array;
                }
            }

            return(list);
        }
Example #4
0
 public void OnGUI()
 {
     if (PackageExport.ms_Constants == null)
     {
         PackageExport.ms_Constants = new PackageExport.Constants();
     }
     if (this.m_assets == null)
     {
         return;
     }
     if (this.m_LeastIndent == 999999)
     {
         int num = this.m_LeastIndent;
         for (int i = 0; i < this.m_assets.Length; i++)
         {
             int num2 = PackageExport.CountOccurencesOfChar(this.m_assets[i].pathName, '/');
             if (num > num2)
             {
                 num = num2;
             }
         }
         this.m_LeastIndent = num - 1;
     }
     if (this.m_assets != null)
     {
         this.SetupListView();
         bool flag = Event.current.type == EventType.Repaint;
         GUILayout.BeginVertical(new GUILayoutOption[0]);
         GUILayout.Label("Items to Export", PackageExport.ms_Constants.title, new GUILayoutOption[0]);
         GUILayout.Space(1f);
         EditorGUIUtility.SetIconSize(new Vector2(16f, 16f));
         foreach (ListViewElement listViewElement in ListViewGUI.ListView(this.m_ListView, GUIStyle.none, new GUILayoutOption[0]))
         {
             AssetsItem assetsItem = this.m_assets[listViewElement.row];
             Rect       position   = listViewElement.position;
             position = new Rect(position.x + 1f, position.y, position.width - 2f, position.height);
             int num3 = PackageExport.CountOccurencesOfChar(assetsItem.pathName, '/') - this.m_LeastIndent;
             if (flag && this.m_ListView.row == listViewElement.row)
             {
                 PackageExport.ms_Constants.ConsoleEntryBackEven.Draw(position, false, false, true, false);
             }
             float y = listViewElement.position.y;
             position.x += 3f;
             int enabled = assetsItem.enabled;
             assetsItem.enabled = ((!GUI.Toggle(new Rect(position.x, position.y, 16f, 16f), assetsItem.enabled != 0, string.Empty)) ? 0 : 1);
             if (enabled != assetsItem.enabled)
             {
                 this.m_ListView.row        = listViewElement.row;
                 GUIUtility.keyboardControl = this.m_ListView.ID;
                 this.CheckChildren(assetsItem);
             }
             if (flag)
             {
                 Rect    position2  = new Rect(position.x + (float)(15 * num3), y + 1f, 16f, 16f);
                 Texture cachedIcon = AssetDatabase.GetCachedIcon(assetsItem.pathName);
                 if (cachedIcon != null)
                 {
                     GUI.DrawTexture(position2, cachedIcon);
                 }
             }
             position = new Rect(position.x + 20f + (float)(15 * num3), listViewElement.position.y, position.width - (float)(20 + 15 * num3), position.height);
             GUI.Label(position, assetsItem.pathName);
         }
         this.FrameLastGUIRect();
         GUILayout.EndVertical();
         if (this.m_ListView.row != -1 && GUIUtility.keyboardControl == this.m_ListView.ID && Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Space)
         {
             this.m_assets[this.m_ListView.row].enabled = ((this.m_assets[this.m_ListView.row].enabled != 0) ? 0 : 1);
             this.CheckChildren(this.m_assets[this.m_ListView.row]);
             Event.current.Use();
         }
         EditorGUIUtility.SetIconSize(Vector2.zero);
         GUILayout.Space(5f);
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         GUILayout.Space(10f);
         if (GUILayout.Button(EditorGUIUtility.TextContent("All"), new GUILayoutOption[]
         {
             GUILayout.Width(50f)
         }))
         {
             for (int j = 0; j < this.m_assets.Length; j++)
             {
                 this.m_assets[j].enabled = 1;
             }
         }
         if (GUILayout.Button(EditorGUIUtility.TextContent("None"), new GUILayoutOption[]
         {
             GUILayout.Width(50f)
         }))
         {
             for (int k = 0; k < this.m_assets.Length; k++)
             {
                 this.m_assets[k].enabled = 0;
             }
         }
         GUILayout.Space(10f);
         bool flag2 = GUILayout.Toggle(this.m_bIncludeDependencies, "Include dependencies", new GUILayoutOption[0]);
         if (flag2 != this.m_bIncludeDependencies)
         {
             this.m_bIncludeDependencies = flag2;
             this.BuildAssetList();
         }
         GUILayout.FlexibleSpace();
         if (GUILayout.Button(EditorGUIUtility.TextContent("Export..."), new GUILayoutOption[0]))
         {
             this.Export();
             GUIUtility.ExitGUI();
         }
         GUILayout.Space(10f);
         GUILayout.EndHorizontal();
         GUILayout.Space(10f);
     }
 }