private SelectionId CreateSelectionId(StatusListEntry entry) { string projectPath = gitManager.ToProjectPath(entry.LocalPath); string guid = UniGitPathHelper.IsPathInAssetFolder(projectPath) ? AssetDatabase.AssetPathToGUID(projectPath) : projectPath; return(string.IsNullOrEmpty(guid) ? new SelectionId(projectPath, true) : new SelectionId(guid, false)); }
internal void AddSelected(StatusListEntry entry) { if (!IsSelected(entry)) { selections.Add(CreateSelectionId(entry)); } }
private bool SelectionPredicate(SelectionId id, StatusListEntry entry) { if (id.isPath) { return(gitManager.ToProjectPath(entry.LocalPath) == id.id); } return(entry.GetGuid(gitManager) == id.id); }
private bool IsVisible(StatusListEntry entry) { if (IsGrouping()) { if ((settings.MinimizedFileStatus & GetMergedStatus(entry.State)) == FileStatus.Unaltered) { return(false); } } return(entry.Name == null || string.IsNullOrEmpty(filter) || entry.Name.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) >= 0); }
private void SeeDifferencePrevAuto(StatusListEntry entry) { if (entry.MetaChange.IsFlagSet(MetaChangeEnum.Object)) { SeeDifferencePrevObject(entry); } else { SeeDifferencePrevMeta(entry); } }
private void BlameAuto(StatusListEntry entry) { if (entry.MetaChange.IsFlagSet(MetaChangeEnum.Object)) { gitManager.ShowBlameWizard(entry.LocalPath, externalManager); } else { gitManager.ShowBlameWizard(GitManager.MetaPathFromAsset(entry.LocalPath), externalManager); } }
internal void RemoveSelected(StatusListEntry entry) { for (int i = selections.Count - 1; i >= 0; i--) { var selection = selections[i]; if (SelectionPredicate(selection, entry)) { selections.RemoveAt(i); break; } } }
internal bool IsSelected(StatusListEntry entry) { int selectionsCount = selections.Count; for (int i = 0; i < selectionsCount; i++) { if (SelectionPredicate(selections[i], entry)) { return(true); } } return(false); }
private void DoFileDiffSelection(Rect elementRect, StatusListEntry info, int index) { Event current = Event.current; if (elementRect.Contains(current.mousePosition)) { if (current.type == EventType.ContextClick) { GenericMenu editMenu = new GenericMenu(); DoDiffElementContex(editMenu); editMenu.ShowAsContext(); current.Use(); } else if (current.type == EventType.MouseDown) { if (current.button == 0) { if (current.modifiers == EventModifiers.Control) { lastSelectedIndex = index; info.Selected = !info.Selected; GUI.FocusControl(info.Path); } else if (current.shift) { if (!current.control) { statusList.SelectAll(false); } int tmpIndex = 0; foreach (var selectInfo in statusList.Where(i => settings.showFileStatusTypeFilter.IsFlagSet(i.State))) { if (tmpIndex >= Mathf.Min(lastSelectedIndex, index) && tmpIndex <= Mathf.Max(lastSelectedIndex, index)) { selectInfo.Selected = true; } tmpIndex++; } if (current.control) { lastSelectedIndex = index; } GUI.FocusControl(info.Path); } else { lastSelectedIndex = index; statusList.SelectAll(false); info.Selected = !info.Selected; GUI.FocusControl(info.Path); } current.Use(); Repaint(); } else if (current.button == 1) { if (!info.Selected) { statusList.SelectAll(false); info.Selected = true; current.Use(); Repaint(); } } } } }
private void DoFileDiff(Rect rect, StatusListEntry info) { Event current = Event.current; if (rect.y > DiffRect.height + diffScroll.y || rect.y + rect.height < diffScroll.y) { return; } Rect stageToggleRect = new Rect(rect.x + rect.width - rect.height, rect.y + 14, rect.height, rect.height); if (current.type == EventType.Repaint) { string filePath = info.Path; string fileName = Path.GetFileName(filePath); Object asset = null; if (filePath.EndsWith(".meta")) { asset = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPathFromTextMetaFilePath(filePath), typeof(Object)); } else { asset = AssetDatabase.LoadAssetAtPath(filePath, typeof(Object)); } GUI.SetNextControlName(info.Path); GUI.Box(rect, GUIContent.none, info.Selected ? "TL LogicBar 1" : styles.diffElement); bool canUnstage = GitManager.CanUnstage(info.State); bool canStage = GitManager.CanStage(info.State); if (canUnstage) { GUIContent content = EditorGUIUtility.IconContent("toggle on act@2x"); GUI.Box(new Rect(rect.x + rect.width - rect.height, rect.y + 14, rect.height, rect.height), content, GUIStyle.none); } else if (canStage) { GUIContent content = EditorGUIUtility.IconContent("toggle act@2x"); GUI.Box(stageToggleRect, content, GUIStyle.none); } GUIContent iconContent = null; string extension = Path.GetExtension(filePath); if (string.IsNullOrEmpty(extension)) { iconContent = EditorGUIUtility.IconContent("Folder Icon"); } if (iconContent == null) { if (asset != null) { iconContent = new GUIContent(AssetPreview.GetMiniThumbnail(asset)); iconContent.tooltip = asset.GetType().Name; } else { iconContent = EditorGUIUtility.IconContent("DefaultAsset Icon"); iconContent.tooltip = "Unknown Type"; } } float x = rect.x + elementSideMargin; GUI.Box(new Rect(x, rect.y + elementTopBottomMargin, iconSize, iconSize), iconContent, styles.assetIcon); x += iconSize + 8; styles.diffElementName.Draw(new Rect(x, rect.y + elementTopBottomMargin + 2, rect.width - elementSideMargin - iconSize - rect.height, EditorGUIUtility.singleLineHeight), new GUIContent(fileName), false, info.Selected, info.Selected, false); x = rect.x + elementSideMargin + iconSize + 8; GUI.Box(new Rect(x, rect.y + elementTopBottomMargin + EditorGUIUtility.singleLineHeight + 4, 21, 21), GitManager.GetDiffTypeIcon(info.State, false), GUIStyle.none); x += 25; if (info.MetaChange.IsFlagSet(MetaChangeEnum.Meta)) { GUIContent metaIconContent = EditorGUIUtility.IconContent("UniGit/meta"); metaIconContent.tooltip = ".meta file changed"; GUI.Box(new Rect(x, rect.y + elementTopBottomMargin + EditorGUIUtility.singleLineHeight + 4, 21, 21), metaIconContent, GUIStyle.none); x += 25; } styles.diffElementPath.Draw(new Rect(x, rect.y + elementTopBottomMargin + EditorGUIUtility.singleLineHeight + 7, rect.width - elementSideMargin - iconSize - rect.height * 2, EditorGUIUtility.singleLineHeight), new GUIContent(filePath), false, info.Selected, info.Selected, false); } else if (current.type == EventType.MouseDown) { if (current.button == 0 && stageToggleRect.Contains(current.mousePosition)) { bool updateFlag = false; if (GitManager.CanStage(info.State)) { GitManager.Repository.Stage(info.Path); updateFlag = true; } else if (GitManager.CanUnstage(info.State)) { GitManager.Repository.Unstage(info.Path); updateFlag = true; } if (updateFlag) { Repaint(); current.Use(); UpdateStatusList(); } } } }
private void DoFileDiffSelection(Rect elementRect, StatusListEntry info, int index, bool enabled, bool selected) { Event current = Event.current; if (elementRect.Contains(current.mousePosition) && enabled) { if (current.type == EventType.MouseDown) { if (current.button == 0) { if (current.modifiers == EventModifiers.Control) { lastSelectedIndex = index; if (selected) { RemoveSelected(info); } else { AddSelected(info); } GUI.FocusControl(info.LocalPath); } else if (current.shift) { if (!current.control) { ClearSelection(); } int tmpIndex = 0; foreach (var selectInfo in diffWindowStatusList) { FileStatus mergedStatus = GetMergedStatus(selectInfo.State); bool isExpanded = settings.MinimizedFileStatus.IsFlagSet(mergedStatus); if (!isExpanded) { continue; } if (tmpIndex >= Mathf.Min(lastSelectedIndex, index) && tmpIndex <= Mathf.Max(lastSelectedIndex, index)) { AddSelected(selectInfo); } tmpIndex++; } if (current.control) { lastSelectedIndex = index; } GUI.FocusControl(info.LocalPath); } else { if (current.clickCount == 2) { Selection.activeObject = AssetDatabase.LoadAssetAtPath(gitManager.ToProjectPath(info.LocalPath), typeof(Object)); } else { lastSelectedIndex = index; ClearSelection(); AddSelected(info); GUI.FocusControl(info.LocalPath); } } current.Use(); Repaint(); } else if (current.button == 1) { if (!selected) { ClearSelection(); AddSelected(info); current.Use(); Repaint(); } } } } }
private void SeeDifferencePrevMeta(StatusListEntry entry) { gitManager.ShowDiffPrev(GitManager.MetaPathFromAsset(entry.LocalPath), externalManager); }
private void SeeDifferencePrevObject(StatusListEntry entry) { gitManager.ShowDiffPrev(entry.LocalPath, externalManager); }
private void BlameObject(StatusListEntry entry) { gitManager.ShowBlameWizard(entry.LocalPath, externalManager); }
private void BlameMeta(StatusListEntry entry) { gitManager.ShowBlameWizard(GitManager.MetaPathFromAsset(entry.LocalPath), externalManager); }