Esempio n. 1
0
        internal static void OnSubmitted(Task task)
        {
            WindowChange[] array = Resources.FindObjectsOfTypeAll(typeof(WindowChange)) as WindowChange[];
            if (array.Length == 0)
            {
                return;
            }
            WindowChange windowChange = array[0];

            windowChange.assetList          = task.assetList;
            windowChange.submitResultCode   = task.resultCode;
            windowChange.submitErrorMessage = null;
            if ((task.resultCode & 2) != 0)
            {
                string    empty    = string.Empty;
                Message[] messages = task.messages;
                for (int i = 0; i < messages.Length; i++)
                {
                    Message message = messages[i];
                    if (message.severity == Message.Severity.Error)
                    {
                        WindowChange expr_77 = windowChange;
                        expr_77.submitErrorMessage = expr_77.submitErrorMessage + empty + message.message;
                    }
                }
            }
            if ((task.resultCode & 3) != 0)
            {
                WindowPending.UpdateAllWindows();
            }
            windowChange.RefreshList();
        }
Esempio n. 2
0
        void OnErrorGUI()
        {
            GUILayout.Label("Submit failed", EditorStyles.boldLabel);

            string msg = "";

            if (!string.IsNullOrEmpty(submitErrorMessage))
            {
                msg = submitErrorMessage + "\n";
            }

            msg += "See console for details. You can get more details by increasing log level in EditorSettings.";

            GUILayout.Label(msg);

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Close"))
            {
                ResetAndClose();

                // The error message may be telling that the plugin is opening a window
                // to handle conflicts. After that has been handled and we close this window
                // we want to update our state.
                WindowPending.UpdateAllWindows();
            }
            GUILayout.EndHorizontal();
        }
 public void OnDisable()
 {
     if (!cancelled)
     {
         WindowPending.UpdateAllWindows();
     }
 }
Esempio n. 4
0
 public void OnDisable()
 {
     if (this.cancelled)
     {
         return;
     }
     WindowPending.UpdateAllWindows();
 }
Esempio n. 5
0
        void OnGUI()
        {
            GUILayout.Label("Revert Files", EditorStyles.boldLabel);
            GUILayout.FlexibleSpace();

            // I would use GUIUtility.GetLastRect() here after the box but that seems to have wierd side effects.
            Rect r1 = new Rect(6, 40, position.width - 12, position.height - 82);

            GUILayout.BeginArea(r1);
            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            GUILayout.EndArea();
            revertList.OnGUI(new Rect(r1.x + 2, r1.y + 2, r1.width - 4, r1.height - 4), true);

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Cancel"))
            {
                Close();
            }

            if (assetList.Count > 0 && GUILayout.Button("Revert"))
            {
                string openScenes = "";
                foreach (Asset a in assetList)
                {
                    Scene openScene = SceneManager.GetSceneByPath(a.path);
                    if ((openScene.IsValid()) && (openScene.isLoaded))
                    {
                        openScenes += openScene.path + "\n";
                    }
                }

                if (openScenes.Length > 0)
                {
                    bool continueRevert = EditorUtility.DisplayDialog("Revert open scene(s)?",
                                                                      "You are about to revert your currently open scene(s):\n\n" +
                                                                      openScenes + "\nContinuing will remove all unsaved changes.",
                                                                      "Continue", "Cancel");
                    if (!continueRevert)
                    {
                        Close();
                        return;
                    }
                }

                Provider.Revert(assetList, RevertMode.Normal).Wait();
                WindowPending.UpdateAllWindows();
                AssetDatabase.Refresh();
                InspectorWindow.RefreshInspectors();
                Close();
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(12);
        }
        public static void CloseAllWindows()
        {
            var           wins = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];
            WindowPending win  = wins.Length > 0 ? wins[0] : null;

            if (win != null)
            {
                win.Close();
            }
        }
Esempio n. 7
0
 public static void UpdateAllWindows()
 {
     WindowPending[] array  = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];
     WindowPending[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         WindowPending windowPending = array2[i];
         windowPending.UpdateWindow();
     }
 }
Esempio n. 8
0
 public static void ExpandLatestChangeSet()
 {
     WindowPending[] array  = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];
     WindowPending[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         WindowPending windowPending = array2[i];
         windowPending.pendingList.ExpandLastItem();
     }
 }
Esempio n. 9
0
        public static void CloseAllWindows()
        {
            WindowPending[] pendingArray = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];
            WindowPending   pending      = (pendingArray.Length <= 0) ? null : pendingArray[0];

            if (pending != null)
            {
                pending.Close();
            }
        }
Esempio n. 10
0
        private static void OnVCTaskCompletedEvent(Task task, CompletionAction completionAction)
        {
            WindowPending[] array  = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];
            WindowPending[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                WindowPending windowPending = array2[i];
                switch (completionAction)
                {
                case CompletionAction.UpdatePendingWindow:
                case CompletionAction.OnCheckoutCompleted:
                    windowPending.UpdateWindow();
                    break;

                case CompletionAction.OnChangeContentsPendingWindow:
                    windowPending.OnChangeContents(task);
                    break;

                case CompletionAction.OnIncomingPendingWindow:
                    windowPending.OnIncoming(task);
                    break;

                case CompletionAction.OnChangeSetsPendingWindow:
                    windowPending.OnChangeSets(task);
                    break;

                case CompletionAction.OnGotLatestPendingWindow:
                    windowPending.OnGotLatest(task);
                    break;
                }
            }
            if (completionAction != CompletionAction.OnSubmittedChangeWindow)
            {
                if (completionAction != CompletionAction.OnAddedChangeWindow)
                {
                    if (completionAction == CompletionAction.OnCheckoutCompleted)
                    {
                        if (EditorUserSettings.showFailedCheckout)
                        {
                            WindowCheckoutFailure.OpenIfCheckoutFailed(task.assetList);
                        }
                    }
                }
                else
                {
                    WindowChange.OnAdded(task);
                }
            }
            else
            {
                WindowChange.OnSubmitted(task);
            }
            task.Dispose();
        }
Esempio n. 11
0
        public static void CloseAllWindows()
        {
            WindowPending[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];
            WindowPending   windowPending    = objectsOfTypeAll.Length <= 0 ? (WindowPending)null : objectsOfTypeAll[0];

            if (!((UnityEngine.Object)windowPending != (UnityEngine.Object)null))
            {
                return;
            }
            windowPending.Close();
        }
Esempio n. 12
0
 private static void OnVCTaskCompletedEvent(Task task, CompletionAction completionAction)
 {
     WindowPending[] array  = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];
     WindowPending[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         WindowPending windowPending = array2[i];
         if (completionAction == CompletionAction.UpdatePendingWindow)
         {
             windowPending.UpdateWindow();
         }
         else
         {
             if (completionAction == CompletionAction.OnChangeContentsPendingWindow)
             {
                 windowPending.OnChangeContents(task);
             }
             else
             {
                 if (completionAction == CompletionAction.OnIncomingPendingWindow)
                 {
                     windowPending.OnIncoming(task);
                 }
                 else
                 {
                     if (completionAction == CompletionAction.OnChangeSetsPendingWindow)
                     {
                         windowPending.OnChangeSets(task);
                     }
                     else
                     {
                         if (completionAction == CompletionAction.OnGotLatestPendingWindow)
                         {
                             windowPending.OnGotLatest(task);
                         }
                     }
                 }
             }
         }
     }
     if (completionAction == CompletionAction.OnSubmittedChangeWindow)
     {
         WindowChange.OnSubmitted(task);
     }
     else
     {
         if (completionAction == CompletionAction.OnAddedChangeWindow)
         {
             WindowChange.OnAdded(task);
         }
     }
     task.Dispose();
 }
Esempio n. 13
0
        internal static void OnSubmitted(Task task)
        {
            var winsChange = Resources.FindObjectsOfTypeAll(typeof(WindowChange)) as WindowChange[];

            if (winsChange.Length == 0)
            {
                return; // user closed submit window before submit finished. Just ignore the status callback.
            }
            var win = winsChange[0];

            win.assetList          = task.assetList;
            win.submitResultCode   = task.resultCode;
            win.submitErrorMessage = null;

            if ((task.resultCode & (int)SubmitResult.Error) != 0)
            {
                string delim = "";
                foreach (Message msg in task.messages)
                {
                    if (msg.severity == Message.Severity.Error)
                    {
                        win.submitErrorMessage += delim + msg.message;
                    }
                }
            }

            if ((task.resultCode & ((int)SubmitResult.OK | (int)SubmitResult.Error)) != 0)
            {
                WindowPending.UpdateAllWindows();
                bool isNewChangeSet = win.changeSet == null;
                if (isNewChangeSet)
                {
                    // When change list becomes empty we open it to make "delete empty changessets" button visible
                    Task flushTask = Provider.Status(""); // Make a dummy task and wait for it since that will guarantee up to date lists
                    flushTask.Wait();
                    WindowPending.ExpandLatestChangeSet();
                }
            }

            if ((task.resultCode & (int)SubmitResult.OK) != 0)
            {
                win.ResetAndClose();
            }
            else
            {
                WindowResolve.Open(win.assetList);
                win.ResetAndClose();
            }
        }
Esempio n. 14
0
 internal static void OnAdded(Task task)
 {
     WindowChange[] array = Resources.FindObjectsOfTypeAll(typeof(WindowChange)) as WindowChange[];
     if (array.Length != 0)
     {
         WindowChange windowChange = array[0];
         windowChange.taskSubmit         = null;
         windowChange.submitResultCode   = 256;
         windowChange.submitErrorMessage = null;
         windowChange.taskAdd            = null;
         windowChange.taskStatus         = Provider.Status(windowChange.assetList, false);
         windowChange.assetList          = null;
         WindowPending.UpdateAllWindows();
     }
 }
Esempio n. 15
0
 internal static void OnAdded(Task task)
 {
     WindowChange[] changeArray = UnityEngine.Resources.FindObjectsOfTypeAll(typeof(WindowChange)) as WindowChange[];
     if (changeArray.Length != 0)
     {
         WindowChange change = changeArray[0];
         change.taskSubmit         = null;
         change.submitResultCode   = 0x100;
         change.submitErrorMessage = null;
         change.taskAdd            = null;
         change.taskStatus         = Provider.Status(change.assetList, false);
         change.assetList          = null;
         WindowPending.UpdateAllWindows();
     }
 }
Esempio n. 16
0
        private void OnGUI()
        {
            GUILayout.Label("Revert Files", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            Rect screenRect = new Rect(6f, 40f, this.position.width - 12f, this.position.height - 82f);

            GUILayout.BeginArea(screenRect);
            GUILayout.Box(string.Empty, new GUILayoutOption[2]
            {
                GUILayout.ExpandWidth(true),
                GUILayout.ExpandHeight(true)
            });
            GUILayout.EndArea();
            this.revertList.OnGUI(new Rect(screenRect.x + 2f, screenRect.y + 2f, screenRect.width - 4f, screenRect.height - 4f), true);
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel"))
            {
                this.Close();
            }
            if (this.assetList.Count > 0 && GUILayout.Button("Revert"))
            {
                string str = string.Empty;
                using (List <Asset> .Enumerator enumerator = this.assetList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Scene sceneByPath = SceneManager.GetSceneByPath(enumerator.Current.path);
                        if (sceneByPath.IsValid() && sceneByPath.isLoaded)
                        {
                            str = str + sceneByPath.path + "\n";
                        }
                    }
                }
                if (str.Length > 0 && !EditorUtility.DisplayDialog("Revert open scene(s)?", "You are about to revert your currently open scene(s):\n\n" + str + "\nContinuing will remove all unsaved changes.", "Continue", "Cancel"))
                {
                    this.Close();
                    return;
                }
                Provider.Revert(this.assetList, RevertMode.Normal).Wait();
                WindowPending.UpdateAllWindows();
                AssetDatabase.Refresh();
                this.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(12f);
        }
Esempio n. 17
0
        internal static void OnAdded(Task task)
        {
            WindowChange[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(typeof(WindowChange)) as WindowChange[];
            if (objectsOfTypeAll.Length == 0)
            {
                return;
            }
            WindowChange windowChange = objectsOfTypeAll[0];

            windowChange.taskSubmit         = (Task)null;
            windowChange.submitResultCode   = 256;
            windowChange.submitErrorMessage = (string)null;
            windowChange.taskAdd            = (Task)null;
            windowChange.taskStatus         = Provider.Status(windowChange.assetList, false);
            windowChange.assetList          = (AssetList)null;
            WindowPending.UpdateAllWindows();
        }
Esempio n. 18
0
        internal static void OnSubmitted(Task task)
        {
            WindowChange[] array = Resources.FindObjectsOfTypeAll(typeof(WindowChange)) as WindowChange[];
            if (array.Length == 0)
            {
                return;
            }
            WindowChange windowChange = array[0];

            windowChange.assetList          = task.assetList;
            windowChange.submitResultCode   = task.resultCode;
            windowChange.submitErrorMessage = null;
            if ((task.resultCode & 2) != 0)
            {
                string    empty    = string.Empty;
                Message[] messages = task.messages;
                for (int i = 0; i < messages.Length; i++)
                {
                    Message message = messages[i];
                    if (message.severity == Message.Severity.Error)
                    {
                        WindowChange expr_77 = windowChange;
                        expr_77.submitErrorMessage = expr_77.submitErrorMessage + empty + message.message;
                    }
                }
            }
            if ((task.resultCode & 3) != 0)
            {
                WindowPending.UpdateAllWindows();
                bool flag = windowChange.changeSet == null;
                if (flag)
                {
                    Task task2 = Provider.Status(string.Empty);
                    task2.Wait();
                    WindowPending.ExpandLatestChangeSet();
                }
            }
            if ((task.resultCode & 1) != 0)
            {
                windowChange.ResetAndClose();
            }
            else
            {
                windowChange.RefreshList();
            }
        }
Esempio n. 19
0
        private void OnGUI()
        {
            GUILayout.Label("Revert Files", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            Rect screenRect = new Rect(6f, 40f, base.position.width - 12f, base.position.height - 82f);

            GUILayout.BeginArea(screenRect);
            GUILayout.Box(string.Empty, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true),
                GUILayout.ExpandHeight(true)
            });
            GUILayout.EndArea();
            this.revertList.OnGUI(new Rect(screenRect.x + 2f, screenRect.y + 2f, screenRect.width - 4f, screenRect.height - 4f), true);
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel", new GUILayoutOption[0]))
            {
                base.Close();
            }
            if (this.assetList.Count > 0 && GUILayout.Button("Revert", new GUILayoutOption[0]))
            {
                foreach (Asset current in this.assetList)
                {
                    if (current.path == EditorApplication.currentScene)
                    {
                        if (!EditorUtility.DisplayDialog("Revert open scene?", "You are about to revert your currently open scene:\n\n" + EditorApplication.currentScene + "\n\nContinuing will remove all unsaved changes.", "Continue", "Cancel"))
                        {
                            base.Close();
                            return;
                        }
                        break;
                    }
                }
                Provider.Revert(this.assetList, RevertMode.Normal).Wait();
                WindowPending.UpdateAllWindows();
                AssetDatabase.Refresh();
                base.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(12f);
        }
Esempio n. 20
0
        internal static void OnSubmitted(Task task)
        {
            WindowChange[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(typeof(WindowChange)) as WindowChange[];
            if (objectsOfTypeAll.Length == 0)
            {
                return;
            }
            WindowChange windowChange1 = objectsOfTypeAll[0];

            windowChange1.assetList          = task.assetList;
            windowChange1.submitResultCode   = task.resultCode;
            windowChange1.submitErrorMessage = (string)null;
            if ((task.resultCode & 2) != 0)
            {
                string empty = string.Empty;
                foreach (Message message in task.messages)
                {
                    if (message.severity == Message.Severity.Error)
                    {
                        WindowChange windowChange2 = windowChange1;
                        string       str           = windowChange2.submitErrorMessage + empty + message.message;
                        windowChange2.submitErrorMessage = str;
                    }
                }
            }
            if ((task.resultCode & 3) != 0)
            {
                WindowPending.UpdateAllWindows();
                if (windowChange1.changeSet == null)
                {
                    Provider.Status(string.Empty).Wait();
                    WindowPending.ExpandLatestChangeSet();
                }
            }
            if ((task.resultCode & 1) != 0)
            {
                windowChange1.ResetAndClose();
            }
            else
            {
                windowChange1.RefreshList();
            }
        }
Esempio n. 21
0
        internal static void OnAdded(Task task)
        {
            var winsChange = Resources.FindObjectsOfTypeAll(typeof(WindowChange)) as WindowChange[];

            if (winsChange.Length == 0)
            {
                return; // user closed submit window before submit finished. Just ignore the status callback.
            }
            var win = winsChange[0];

            win.taskSubmit         = null;
            win.submitResultCode   = kSubmitNotStartedResultCode;
            win.submitErrorMessage = null;
            win.taskAdd            = null;

            // Refetch status
            win.taskStatus = Provider.Status(win.assetList, false);
            win.assetList  = null;
            WindowPending.UpdateAllWindows(); // reflect newly added assets in pending window
        }
Esempio n. 22
0
        private void OnErrorGUI()
        {
            GUILayout.Label("Submit failed", EditorStyles.boldLabel, new GUILayoutOption[0]);
            string str = string.Empty;

            if (!string.IsNullOrEmpty(this.submitErrorMessage))
            {
                str = this.submitErrorMessage + "\n";
            }
            GUILayout.Label(str + "See console for details. You can get more details by increasing log level in EditorSettings.");
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Close"))
            {
                this.ResetAndClose();
                WindowPending.UpdateAllWindows();
            }
            GUILayout.EndHorizontal();
        }
Esempio n. 23
0
 internal static void OnSubmitted(Task task)
 {
     WindowChange[] changeArray = UnityEngine.Resources.FindObjectsOfTypeAll(typeof(WindowChange)) as WindowChange[];
     if (changeArray.Length != 0)
     {
         WindowChange change = changeArray[0];
         change.assetList          = task.assetList;
         change.submitResultCode   = task.resultCode;
         change.submitErrorMessage = null;
         if ((task.resultCode & 2) != 0)
         {
             string str = "";
             foreach (Message message in task.messages)
             {
                 if (message.severity == Message.Severity.Error)
                 {
                     change.submitErrorMessage = change.submitErrorMessage + str + message.message;
                 }
             }
         }
         if ((task.resultCode & 3) != 0)
         {
             WindowPending.UpdateAllWindows();
             if (change.changeSet == null)
             {
                 Provider.Status("").Wait();
                 WindowPending.ExpandLatestChangeSet();
             }
         }
         if ((task.resultCode & 1) != 0)
         {
             change.ResetAndClose();
         }
         else
         {
             change.RefreshList();
         }
     }
 }
Esempio n. 24
0
        private void OnErrorGUI()
        {
            GUILayout.Label("Submit failed", EditorStyles.boldLabel, new GUILayoutOption[0]);
            string text = string.Empty;

            if (!string.IsNullOrEmpty(this.submitErrorMessage))
            {
                text = this.submitErrorMessage + "\n";
            }
            text += "See console for details. You can get more details by increasing log level in EditorSettings.";
            GUILayout.Label(text, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Close", new GUILayoutOption[0]))
            {
                this.taskSubmit         = null;
                this.submitResultCode   = 256;
                this.submitErrorMessage = null;
                base.Close();
                WindowPending.UpdateAllWindows();
            }
            GUILayout.EndHorizontal();
        }
Esempio n. 25
0
 public static void OnStatusUpdated()
 {
     WindowPending.UpdateAllWindows();
 }
Esempio n. 26
0
        private void OnGUI()
        {
            this.InitStyles();
            if (!WindowPending.s_DidReload)
            {
                WindowPending.s_DidReload = true;
                this.UpdateWindow();
            }
            this.CreateResources();
            Event current     = Event.current;
            float fixedHeight = EditorStyles.toolbar.fixedHeight;

            GUILayout.BeginArea(new Rect(0f, 0f, base.position.width, fixedHeight));
            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            int num = (this.incomingList.Root != null) ? this.incomingList.Root.ChildCount : 0;

            this.m_ShowIncoming = !GUILayout.Toggle(!this.m_ShowIncoming, "Outgoing", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            GUIContent content = GUIContent.Temp("Incoming" + ((num != 0) ? (" (" + num.ToString() + ")") : string.Empty));

            this.m_ShowIncoming = GUILayout.Toggle(this.m_ShowIncoming, content, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(Provider.activeTask != null);
            CustomCommand[] customCommands = Provider.customCommands;
            for (int i = 0; i < customCommands.Length; i++)
            {
                CustomCommand customCommand = customCommands[i];
                if (customCommand.context == CommandContext.Global && GUILayout.Button(customCommand.label, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    customCommand.StartTask();
                }
            }
            EditorGUI.EndDisabledGroup();
            bool flag = Mathf.FloorToInt(base.position.width - this.s_ToolbarButtonsWidth) > 0;

            if (flag && GUILayout.Button("Settings", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                EditorApplication.ExecuteMenuItem("Edit/Project Settings/Editor");
                EditorWindow.FocusWindowIfItsOpen <InspectorWindow>();
                GUIUtility.ExitGUI();
            }
            Color color = GUI.color;

            GUI.color = new Color(1f, 1f, 1f, 0.5f);
            bool flag2 = GUILayout.Button(this.refreshIcon, EditorStyles.toolbarButton, new GUILayoutOption[0]);

            GUI.color = color;
            if (current.isKey && GUIUtility.keyboardControl == 0 && current.type == EventType.KeyDown && current.keyCode == KeyCode.F5)
            {
                flag2 = true;
                current.Use();
            }
            if (flag2)
            {
                Provider.InvalidateCache();
                if (Provider.isActive && Provider.onlineState == OnlineState.Online)
                {
                    Task task = Provider.ChangeSets();
                    task.SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow);
                    Task task2 = Provider.Incoming();
                    task2.SetCompletionAction(CompletionAction.OnIncomingPendingWindow);
                }
                else
                {
                    Provider.UpdateSettings();
                }
            }
            GUILayout.EndArea();
            Rect rect  = new Rect(0f, fixedHeight, base.position.width, base.position.height - fixedHeight - 17f);
            bool flag3 = false;

            GUILayout.EndHorizontal();
            if (!Provider.isActive)
            {
                Color color2 = GUI.color;
                GUI.color   = new Color(0.8f, 0.5f, 0.5f);
                rect.height = fixedHeight;
                GUILayout.BeginArea(rect);
                GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                string text = "DISABLED";
                if (Provider.enabled)
                {
                    if (Provider.onlineState == OnlineState.Updating)
                    {
                        GUI.color = new Color(0.8f, 0.8f, 0.5f);
                        text      = "CONNECTING...";
                    }
                    else
                    {
                        text = "OFFLINE";
                    }
                }
                GUILayout.Label(text, EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
                rect.y += rect.height;
                if (!string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.Label(rect, Provider.offlineReason);
                }
                GUI.color = color2;
                flag3     = false;
            }
            else
            {
                if (this.m_ShowIncoming)
                {
                    flag3 |= this.incomingList.OnGUI(rect, base.hasFocus);
                }
                else
                {
                    flag3 |= this.pendingList.OnGUI(rect, base.hasFocus);
                }
                rect.y     += rect.height;
                rect.height = 17f;
                GUI.Label(rect, GUIContent.none, WindowPending.s_Styles.bottomBarBg);
                GUIContent content2 = new GUIContent("Apply All Incoming Changes");
                Vector2    vector   = EditorStyles.miniButton.CalcSize(content2);
                Rect       rect2    = new Rect(rect.x, rect.y - 2f, rect.width - vector.x - 5f, rect.height);
                WindowPending.ProgressGUI(rect2, Provider.activeTask, false);
                if (this.m_ShowIncoming)
                {
                    Rect position = rect;
                    position.width  = vector.x;
                    position.height = vector.y;
                    position.y      = rect.y + 2f;
                    position.x      = base.position.width - vector.x - 5f;
                    EditorGUI.BeginDisabledGroup(this.incomingList.Size == 0);
                    if (GUI.Button(position, content2, EditorStyles.miniButton))
                    {
                        Asset item   = new Asset(string.Empty);
                        Task  latest = Provider.GetLatest(new AssetList
                        {
                            item
                        });
                        latest.SetCompletionAction(CompletionAction.OnGotLatestPendingWindow);
                    }
                    EditorGUI.EndDisabledGroup();
                }
            }
            if (flag3)
            {
                base.Repaint();
            }
        }
Esempio n. 27
0
        private void OnGUI()
        {
            this.InitStyles();
            if (!WindowPending.s_DidReload)
            {
                WindowPending.s_DidReload = true;
                this.UpdateWindow();
            }
            this.CreateResources();
            Event current     = Event.current;
            float fixedHeight = EditorStyles.toolbar.fixedHeight;
            bool  flag1       = false;

            GUILayout.BeginArea(new Rect(0.0f, 0.0f, this.position.width, fixedHeight));
            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            EditorGUI.BeginChangeCheck();
            int num = this.incomingList.Root != null ? this.incomingList.Root.ChildCount : 0;

            this.m_ShowIncoming = !GUILayout.Toggle(!this.m_ShowIncoming, "Outgoing", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            this.m_ShowIncoming = GUILayout.Toggle(this.m_ShowIncoming, GUIContent.Temp("Incoming" + (num != 0 ? " (" + num.ToString() + ")" : string.Empty)), EditorStyles.toolbarButton, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                flag1 = true;
            }
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(Provider.activeTask != null);
            foreach (CustomCommand customCommand in Provider.customCommands)
            {
                if (customCommand.context == CommandContext.Global && GUILayout.Button(customCommand.label, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    customCommand.StartTask();
                }
            }
            EditorGUI.EndDisabledGroup();
            if (Mathf.FloorToInt(this.position.width - this.s_ToolbarButtonsWidth - this.s_SettingsButtonWidth - this.s_DeleteChangesetsButtonWidth) > 0 && this.HasEmptyPendingChangesets() && GUILayout.Button("Delete Empty Changesets", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                this.DeleteEmptyPendingChangesets();
            }
            if (Mathf.FloorToInt(this.position.width - this.s_ToolbarButtonsWidth - this.s_SettingsButtonWidth) > 0 && GUILayout.Button("Settings", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                EditorApplication.ExecuteMenuItem("Edit/Project Settings/Editor");
                EditorWindow.FocusWindowIfItsOpen <InspectorWindow>();
                GUIUtility.ExitGUI();
            }
            Color color1 = GUI.color;

            GUI.color = new Color(1f, 1f, 1f, 0.5f);
            bool flag2 = GUILayout.Button((Texture)this.refreshIcon, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            bool flag3 = flag1 || flag2;

            GUI.color = color1;
            if (current.isKey && GUIUtility.keyboardControl == 0 && (current.type == EventType.KeyDown && current.keyCode == KeyCode.F5))
            {
                flag3 = true;
                current.Use();
            }
            if (flag3)
            {
                if (flag2)
                {
                    Provider.InvalidateCache();
                }
                this.UpdateWindow();
            }
            GUILayout.EndArea();
            Rect rect  = new Rect(0.0f, fixedHeight, this.position.width, (float)((double)this.position.height - (double)fixedHeight - 17.0));
            bool flag4 = false;

            GUILayout.EndHorizontal();
            bool flag5;

            if (!Provider.isActive)
            {
                Color color2 = GUI.color;
                GUI.color   = new Color(0.8f, 0.5f, 0.5f);
                rect.height = fixedHeight;
                GUILayout.BeginArea(rect);
                GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                string text = "DISABLED";
                if (Provider.enabled)
                {
                    if (Provider.onlineState == OnlineState.Updating)
                    {
                        GUI.color = new Color(0.8f, 0.8f, 0.5f);
                        text      = "CONNECTING...";
                    }
                    else
                    {
                        text = "OFFLINE";
                    }
                }
                GUILayout.Label(text, EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
                rect.y += rect.height;
                if (!string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.Label(rect, Provider.offlineReason);
                }
                GUI.color = color2;
                flag5     = false;
            }
            else
            {
                flag5       = !this.m_ShowIncoming ? flag4 | this.pendingList.OnGUI(rect, this.hasFocus) : flag4 | this.incomingList.OnGUI(rect, this.hasFocus);
                rect.y     += rect.height;
                rect.height = 17f;
                GUI.Label(rect, GUIContent.none, WindowPending.s_Styles.bottomBarBg);
                GUIContent content = new GUIContent("Apply All Incoming Changes");
                Vector2    vector2 = EditorStyles.miniButton.CalcSize(content);
                WindowPending.ProgressGUI(new Rect(rect.x, rect.y - 2f, (float)((double)rect.width - (double)vector2.x - 5.0), rect.height), Provider.activeTask, false);
                if (this.m_ShowIncoming)
                {
                    Rect position = rect;
                    position.width  = vector2.x;
                    position.height = vector2.y;
                    position.y      = rect.y + 2f;
                    position.x      = (float)((double)this.position.width - (double)vector2.x - 5.0);
                    EditorGUI.BeginDisabledGroup(this.incomingList.Size == 0);
                    if (GUI.Button(position, content, EditorStyles.miniButton))
                    {
                        Asset     asset  = new Asset(string.Empty);
                        AssetList assets = new AssetList();
                        assets.Add(asset);
                        Provider.GetLatest(assets).SetCompletionAction(CompletionAction.OnGotLatestPendingWindow);
                    }
                    EditorGUI.EndDisabledGroup();
                }
            }
            if (!flag5)
            {
                return;
            }
            this.Repaint();
        }