Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,56 +123,6 @@ public List<GitBranch> RemoteBranches
}
}

[Location("views/branches.yaml", LocationAttribute.Location.LibraryFolder)]
sealed class Favorites : ScriptObjectSingleton<Favorites>
{
[SerializeField] private List<string> favoriteBranches;
public List<string> FavoriteBranches
{
get
{
if (favoriteBranches == null)
FavoriteBranches = new List<string>();
return favoriteBranches;
}
set
{
favoriteBranches = value;
Save(true);
}
}

public void SetFavorite(string branchName)
{
if (FavoriteBranches.Contains(branchName))
return;
FavoriteBranches.Add(branchName);
Save(true);
}

public void UnsetFavorite(string branchName)
{
if (!FavoriteBranches.Contains(branchName))
return;
FavoriteBranches.Remove(branchName);
Save(true);
}

public void ToggleFavorite(string branchName)
{
if (FavoriteBranches.Contains(branchName))
FavoriteBranches.Remove(branchName);
else
FavoriteBranches.Add(branchName);
Save(true);
}

public bool IsFavorite(string branchName)
{
return FavoriteBranches.Contains(branchName);
}
}

[Location("cache/gitlog.yaml", LocationAttribute.Location.LibraryFolder)]
sealed class GitLogCache : ScriptObjectSingleton<GitLogCache>
{
Expand Down
103 changes: 0 additions & 103 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class BranchesView : Subview
private const string WarningCheckoutBranchExistsOK = "Ok";
private const string NewBranchCancelButton = "x";
private const string NewBranchConfirmButton = "Create";
private const string FavoritesSetting = "Favorites";
private const string FavoritesTitle = "Favorites";
private const string CreateBranchTitle = "Create Branch";
private const string LocalTitle = "Local branches";
private const string RemoteTitle = "Remote branches";
Expand All @@ -38,11 +36,9 @@ class BranchesView : Subview
private bool showLocalBranches = true;
private bool showRemoteBranches = true;

[NonSerialized] private List<BranchTreeNode> favorites = new List<BranchTreeNode>();
[NonSerialized] private int listID = -1;
[NonSerialized] private BranchTreeNode newNodeSelection;
[NonSerialized] private BranchesMode targetMode;
[NonSerialized] private bool favoritesHasChanged;

[SerializeField] private BranchTreeNode activeBranchNode;
[SerializeField] private BranchTreeNode localRoot;
Expand All @@ -51,7 +47,6 @@ class BranchesView : Subview
[SerializeField] private List<Remote> remotes = new List<Remote>();
[SerializeField] private Vector2 scroll;
[SerializeField] private BranchTreeNode selectedNode;
[SerializeField] private List<string> favoritesList = new List<string>();

public override void InitializeView(IView parent)
{
Expand All @@ -63,7 +58,6 @@ public override void OnEnable()
{
base.OnEnable();
AttachHandlers(Repository);
favoritesHasChanged = true;
Refresh();
}

Expand All @@ -81,11 +75,6 @@ public override void OnDataUpdate()

private void MaybeUpdateData()
{
if (favoritesHasChanged)
{
favoritesList = Manager.LocalSettings.Get(FavoritesSetting, new List<string>());
favoritesHasChanged = false;
}
}

public override void OnRepositoryChanged(IRepository oldRepository)
Expand Down Expand Up @@ -158,28 +147,6 @@ public void OnEmbeddedGUI()

GUILayout.BeginVertical(Styles.CommitFileAreaStyle);
{
// Favorites list
if (favorites.Count > 0)
{
GUILayout.Label(FavoritesTitle);
GUILayout.BeginHorizontal();
{
GUILayout.BeginVertical();
{
for (var index = 0; index < favorites.Count; ++index)
{
OnTreeNodeGUI(favorites[index]);
}
}

GUILayout.EndVertical();
}

GUILayout.EndHorizontal();

GUILayout.Space(Styles.BranchListSeperation);
}

// Local branches and "create branch" button
showLocalBranches = EditorGUILayout.Foldout(showLocalBranches, LocalTitle);
if (showLocalBranches)
Expand Down Expand Up @@ -262,16 +229,6 @@ public void OnEmbeddedGUI()

private int CompareBranches(GitBranch a, GitBranch b)
{
if (IsFavorite(a.Name))
{
return -1;
}

if (IsFavorite(b.Name))
{
return 1;
}

if (a.Name.Equals("master"))
{
return -1;
Expand All @@ -285,11 +242,6 @@ private int CompareBranches(GitBranch a, GitBranch b)
return 0;
}

private bool IsFavorite(string branchName)
{
return !String.IsNullOrEmpty(branchName) && favoritesList.Contains(branchName);
}

private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remote)
{
//Clear the selected node
Expand All @@ -305,9 +257,6 @@ private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remo
var tracking = new List<KeyValuePair<int, int>>();
var localBranchNodes = new List<BranchTreeNode>();

// Prepare for updated favorites listing
favorites.Clear();

// Just build directly on the local root, keep track of active branch
localRoot = new BranchTreeNode("", NodeType.Folder, false);
for (var index = 0; index < localBranches.Count; ++index)
Expand Down Expand Up @@ -335,12 +284,6 @@ private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remo
}
}

// Add to favorites
if (favoritesList.Contains(branch.Name))
{
favorites.Add(node);
}

// Build into tree
BuildTree(localRoot, node);
}
Expand Down Expand Up @@ -379,12 +322,6 @@ private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remo
}
}

// Add to favorites
if (favoritesList.Contains(branch.Name))
{
favorites.Add(node);
}

// Build on the root of the remote, just like with locals
BuildTree(remotes[remoteIndex].Root, node);
}
Expand Down Expand Up @@ -417,26 +354,6 @@ private void BuildTree(BranchTreeNode parent, BranchTreeNode child)
BuildTree(folder, child);
}

private void SetFavorite(BranchTreeNode branch, bool favorite)
{
if (string.IsNullOrEmpty(branch.Name))
{
return;
}

if (!favorite)
{
favorites.Remove(branch);
Manager.LocalSettings.Set(FavoritesSetting, favorites.Select(x => x.Name).ToList());
}
else
{
favorites.Remove(branch);
favorites.Add(branch);
Manager.LocalSettings.Set(FavoritesSetting, favorites.Select(x => x.Name).ToList());
}
}

private void OnButtonBarGUI()
{
if (mode == BranchesMode.Default)
Expand Down Expand Up @@ -576,7 +493,6 @@ private void OnTreeNodeGUI(BranchTreeNode node)
var style = node.Active ? Styles.BoldLabel : Styles.Label;
var rect = GUILayoutUtility.GetRect(content, style, GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight));
var clickRect = new Rect(0f, rect.y, Position.width, rect.height);
var favoriteRect = new Rect(clickRect.xMax - clickRect.height * 2f, clickRect.y, clickRect.height, clickRect.height);

var selected = selectedNode == node;
var keyboardFocus = GUIUtility.keyboardControl == listID;
Expand All @@ -588,25 +504,6 @@ private void OnTreeNodeGUI(BranchTreeNode node)
{
style.Draw(clickRect, GUIContent.none, false, false, true, keyboardFocus);
}

if (node.Type != NodeType.Folder)
{
var favorite = IsFavorite(node.Name);
if (Event.current.type == EventType.Repaint)
{
GUI.DrawTexture(favoriteRect, favorite ? Styles.FavoriteIconOn : Styles.FavoriteIconOff);
}
else if (Event.current.type == EventType.MouseDown && favoriteRect.Contains(Event.current.mousePosition))
{
SetFavorite(node, !favorite);
Event.current.Use();
}
}
}
// Favorite status
else if (Event.current.type == EventType.Repaint && node.Type != NodeType.Folder && IsFavorite(node.Name))
{
GUI.DrawTexture(favoriteRect, Styles.FavoriteIconOn);
}

// The actual icon and label
Expand Down