private void UpdateWindow() { if (!Provider.isActive) { this.pendingList.Clear(); Provider.UpdateSettings(); base.Repaint(); } else if (Provider.onlineState == OnlineState.Online) { Task task = Provider.ChangeSets(); task.SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow); Task task2 = Provider.Incoming(); task2.SetCompletionAction(CompletionAction.OnIncomingPendingWindow); } }
private void UpdateWindow() { if (!Provider.isActive) { this.pendingList.Clear(); Provider.UpdateSettings(); this.Repaint(); } else { if (Provider.onlineState != OnlineState.Online) { return; } Provider.ChangeSets().SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow); Provider.Incoming().SetCompletionAction(CompletionAction.OnIncomingPendingWindow); } }
// called to update the status void UpdateWindow() { if (!Provider.isActive) { pendingList.Clear(); Provider.UpdateSettings(); // Try to resend the settings if we by chance has become online again Repaint(); return; } if (Provider.onlineState == OnlineState.Online) { Task changesTask = Provider.ChangeSets(); changesTask.SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow); Task incomingTask = Provider.Incoming(); incomingTask.SetCompletionAction(CompletionAction.OnIncomingPendingWindow); } }
// Editor window GUI paint void OnGUI() { InitStyles(); if (!s_DidReload) { s_DidReload = true; UpdateWindow(); } CreateResources(); float toolBarHeight = EditorStyles.toolbar.fixedHeight; bool refresh = false; GUILayout.BeginArea(new Rect(0, 0, position.width, toolBarHeight)); GUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginChangeCheck(); int incomingChangesetCount = incomingList.Root == null ? 0 : incomingList.Root.ChildCount; m_ShowIncoming = !GUILayout.Toggle(!m_ShowIncoming, "Outgoing", EditorStyles.toolbarButton); GUIContent cont = GUIContent.Temp("Incoming" + (incomingChangesetCount == 0 ? "" : " (" + incomingChangesetCount + ")")); m_ShowIncoming = GUILayout.Toggle(m_ShowIncoming, cont, EditorStyles.toolbarButton); if (EditorGUI.EndChangeCheck()) { refresh = true; } GUILayout.FlexibleSpace(); Event e = Event.current; SearchField(e, m_ShowIncoming ? incomingList : pendingList); // Global context custom commands goes here using (new EditorGUI.DisabledScope(Provider.activeTask != null)) { foreach (CustomCommand c in Provider.customCommands) { if (c.context == CommandContext.Global && GUILayout.Button(c.label, EditorStyles.toolbarButton)) { c.StartTask(); } } } bool showDeleteEmptyChangesetsButton = Mathf.FloorToInt(position.width - s_ToolbarButtonsWidth - s_SettingsButtonWidth - s_DeleteChangesetsButtonWidth) > 0 && HasEmptyPendingChangesets(); if (showDeleteEmptyChangesetsButton && GUILayout.Button("Delete Empty Changesets", EditorStyles.toolbarButton)) { DeleteEmptyPendingChangesets(); } bool showSettingsButton = Mathf.FloorToInt(position.width - s_ToolbarButtonsWidth - s_SettingsButtonWidth) > 0; if (showSettingsButton && GUILayout.Button(Styles.editorSettingsLabel, EditorStyles.toolbarButton)) { SettingsService.OpenProjectSettings("Project/Version Control"); EditorWindow.FocusWindowIfItsOpen <InspectorWindow>(); GUIUtility.ExitGUI(); } bool refreshButtonClicked = GUILayout.Button(refreshIcon, EditorStyles.toolbarButton); refresh = refresh || refreshButtonClicked || scheduleRefresh; bool repaint = false; if (refresh) { if (refreshButtonClicked) { m_SearchText = string.Empty; GUI.FocusControl(null); Provider.InvalidateCache(); Provider.UpdateSettings(); } repaint = true; scheduleRefresh = false; UpdateWindow(); } GUILayout.EndArea(); Rect rect = new Rect(0, toolBarHeight, position.width, position.height - toolBarHeight - k_BottomBarHeight); GUILayout.EndHorizontal(); if (EditorUserSettings.WorkOffline) { GUI.color = new Color(0.8f, 0.5f, 0.5f); rect.height = toolBarHeight; GUILayout.BeginArea(rect); GUILayout.BeginHorizontal(EditorStyles.toolbar); GUILayout.FlexibleSpace(); GUILayout.Label(Styles.workOfflineLabel, EditorStyles.miniLabel); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); } // Disabled Window view else if (!Provider.isActive) { Color tmpColor = GUI.color; GUI.color = new Color(0.8f, 0.5f, 0.5f); rect.height = toolBarHeight; GUILayout.BeginArea(rect); GUILayout.BeginHorizontal(EditorStyles.toolbar); GUILayout.FlexibleSpace(); if (Provider.enabled) { if (Provider.onlineState == OnlineState.Updating) { GUI.color = new Color(0.8f, 0.8f, 0.5f); GUILayout.Label(Styles.connectingLabel, EditorStyles.miniLabel); } else { GUILayout.Label(Styles.offlineLabel, EditorStyles.miniLabel); } } else { GUILayout.Label(Styles.disabledLabel, EditorStyles.miniLabel); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); rect.y += rect.height; if (!string.IsNullOrEmpty(Provider.offlineReason)) { GUI.Label(rect, Provider.offlineReason); } GUI.color = tmpColor; repaint = false; } else { if (m_ShowIncoming) { repaint |= incomingList.OnGUI(rect, hasFocus); } else { repaint |= pendingList.OnGUI(rect, hasFocus); } rect.y += rect.height; rect.height = k_BottomBarHeight; // Draw separation line over the button GUI.Label(rect, GUIContent.none, s_Styles.bottomBarBg); var content = EditorGUIUtility.TrTextContent("Apply All Incoming Changes"); var buttonSize = EditorStyles.miniButton.CalcSize(content); Rect progressRect = new Rect(rect.x, rect.y - 2, rect.width - buttonSize.x - 5f, rect.height); ProgressGUI(progressRect, Provider.activeTask, false); if (m_ShowIncoming) { // Draw "apply incoming" button var buttonRect = rect; buttonRect.width = buttonSize.x; buttonRect.height = buttonSize.y; buttonRect.y = rect.y + 2f; buttonRect.x = position.width - buttonSize.x - 5f; using (new EditorGUI.DisabledScope(incomingList?.Root?.VisibleChildCount == 0)) { if (GUI.Button(buttonRect, content, EditorStyles.miniButton)) { Asset root = new Asset(""); Task t = Provider.GetLatest(new AssetList() { root }); t.SetCompletionAction(CompletionAction.OnGotLatestPendingWindow); } } } } if (m_ShowIncoming != m_ShowIncomingPrevious) { (m_ShowIncoming ? incomingList : pendingList).Filter = m_SearchText; m_ShowIncomingPrevious = m_ShowIncoming; } if (repaint) { Repaint(); } }
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(); } }