Ejemplo n.º 1
0
            public override void OnGUI(Rect rect)
            {
                EditorGUILayout.Space();
                resetMode = (ResetMode)EditorGUILayout.EnumPopup(GitGUI.GetTempContent("Reset Type"), resetMode);
                switch (resetMode)
                {
                case ResetMode.Soft:
                    EditorGUILayout.HelpBox("Leave working tree and index untouched", MessageType.Info);
                    break;

                case ResetMode.Mixed:
                    EditorGUILayout.HelpBox("Leave working tree untouched,reset index (Default)", MessageType.Info);
                    break;

                case ResetMode.Hard:
                    EditorGUILayout.HelpBox("Reset working tree and index (Will delete all files)", MessageType.Error);
                    break;
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Reset"))
                {
                    if (EditorUtility.DisplayDialog("Reset", "Are you sure you want to reset to the selected commit", "Reset", "Cancel"))
                    {
                        GitProfilerProxy.BeginSample("Git Reset Popup", editorWindow);
                        GitManager.Repository.Reset(resetMode, commit, checkoutOptions);
                        GitManager.MarkDirty(true);
                        editorWindow.Close();
                        GitProfilerProxy.EndSample();
                        AssetDatabase.Refresh();
                    }
                }
                EditorGUILayout.Space();
            }
Ejemplo n.º 2
0
        private static bool AutoFetchChanges()
        {
            if (repository == null || !IsValidRepo || !Settings.AutoFetch)
            {
                return(false);
            }
            Remote remote = repository.Network.Remotes.FirstOrDefault();

            if (remote == null)
            {
                return(false);
            }
            GitProfilerProxy.BeginSample("Git automatic fetching");
            try
            {
                repository.Network.Fetch(remote, new FetchOptions()
                {
                    CredentialsProvider = GitCredentialsManager.FetchChangesAutoCredentialHandler, OnTransferProgress = FetchTransferProgressHandler
                });
            }
            catch (Exception e)
            {
                Debug.LogErrorFormat("Automatic Fetching from remote: {0} with URL: {1} Failed!", remote.Name, remote.Url);
                Debug.LogException(e);
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
            GitProfilerProxy.EndSample();
            return(false);
        }
Ejemplo n.º 3
0
 private static void RetreiveStatus(string[] paths)
 {
     GitProfilerProxy.BeginSample("Git Repository Status Retrieval");
     RebuildStatus(paths);
     GitProfilerProxy.EndSample();
     GitCallbacks.IssueUpdateRepository(status, paths);
     ThreadPool.QueueUserWorkItem(UpdateStatusTreeThreaded, status);
 }
Ejemplo n.º 4
0
 private static void RetreiveStatus(string[] paths)
 {
     GitProfilerProxy.BeginSample("Git Repository Status Retrieval");
     RebuildStatus(paths);
     GitProfilerProxy.EndSample();
     if (updateRepository != null)
     {
         updateRepository.Invoke(status, paths);
     }
     ThreadPool.QueueUserWorkItem(UpdateStatusTreeThreaded, status);
 }
Ejemplo n.º 5
0
 private void OnEditorUpdate()
 {
     if (isDirty && !isUpdating && ((projectWindows != null && projectWindows.Any(reflectionHelper.HasFocusFucntion.Invoke)) | prefs.GetBool(ForceUpdateKey, false)))
     {
         if (data.Initialized)
         {
             if (gitSettings.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Status))
             {
                 isUpdating = true;
                 gitManager.ActionQueue.Enqueue(() =>
                 {
                     try
                     {
                         UpdateStatusTreeThreaded(data.RepositoryStatus);
                     }
                     finally
                     {
                         isUpdating = false;
                     }
                 });
                 isDirty = false;
             }
             else
             {
                 if (!Monitor.TryEnter(data.RepositoryStatus.LockObj))
                 {
                     return;
                 }
                 isUpdating = true;
                 GitProfilerProxy.BeginSample("Git Project Window status tree building");
                 try
                 {
                     try
                     {
                         UpdateStatusTree(data.RepositoryStatus);
                     }
                     finally
                     {
                         isUpdating = false;
                     }
                 }
                 finally
                 {
                     Monitor.Exit(data.RepositoryStatus.LockObj);
                     GitProfilerProxy.EndSample();
                 }
                 isDirty = false;
             }
         }
     }
 }
Ejemplo n.º 6
0
 private void RetreiveStatus(string[] paths)
 {
     //reset force single thread as we are going to update on main thread
     forceSingleThread = false;
     GitProfilerProxy.BeginSample("UniGit Status Retrieval");
     try
     {
         RetreiveStatus(paths, false);
     }
     finally
     {
         GitProfilerProxy.EndSample();
     }
 }
Ejemplo n.º 7
0
        private void DoHistoryScrollRect(Rect rect, RepositoryInformation info)
        {
            Event current = Event.current;

            GUI.Box(new Rect(14, rect.y + 2, 2, rect.height), GUIContent.none, "AppToolbar");

            //behind,ahead and merge checking

            bool displayWarnningBox = DoWarningBoxValidate(info);

            //commit layout
            if (current.type == EventType.Layout)
            {
                GitProfilerProxy.BeginSample("Git History Window Scroll Rect GUI Layout", this);
                Rect lastCommitRect = new Rect(32, commitSpacing, Mathf.Max(rect.width - 24, 512) - 32, 0);

                if (displayWarnningBox)
                {
                    warningBoxRect    = new Rect(lastCommitRect.x, lastCommitRect.y, lastCommitRect.width, helpBoxHeight);
                    lastCommitRect.y += helpBoxHeight + commitSpacing;
                }

                for (int i = 0; i < cachedCommits.Length; i++)
                {
                    lastCommitRect = LayoutCommit(lastCommitRect, cachedCommits[i]);
                    commitRects[i] = lastCommitRect;
                }

                historyScrollContentsRect = new Rect(0, 0, lastCommitRect.width + 32, lastCommitRect.y + lastCommitRect.height + commitSpacing * 2);
                GitProfilerProxy.EndSample();
            }
            else
            {
                GitProfilerProxy.BeginSample("Git History Window Scroll Rect GUI Other", this);
                historyScroll = GUI.BeginScrollView(rect, historyScroll, historyScrollContentsRect);

                if (displayWarnningBox)
                {
                    DoWarningBox(warningBoxRect, info);
                }

                for (int i = 0; i < cachedCommits.Length; i++)
                {
                    DoCommit(commitRects[i], rect, cachedCommits[i]);
                }

                GUI.EndScrollView();
                GitProfilerProxy.EndSample();
            }
        }
Ejemplo n.º 8
0
 private void OnUpdateRepository(GitRepoStatus status, string[] paths)
 {
     if (gitSettings.Threading.IsFlagSet(GitSettingsJson.ThreadingType.StatusList))
     {
         gitManager.ActionQueue.Enqueue(() =>
         {
             UpdateStatusTreeThreaded(status);
         });
     }
     else
     {
         GitProfilerProxy.BeginSample("Git Project Window status tree building");
         UpdateStatusTree(status);
         GitProfilerProxy.EndSample();
     }
 }
Ejemplo n.º 9
0
        public bool Commit()
        {
            Signature signature = gitManager.Signature;

            try
            {
                string commitMessage = GetActiveCommitMessage(true);
                if (!externalManager.TakeCommit(commitMessage))
                {
                    GitProfilerProxy.BeginSample("Git Commit");
                    try
                    {
                        var commit = gitManager.Repository.Commit(commitMessage, signature, signature, new CommitOptions()
                        {
                            AllowEmptyCommit = settings.emptyCommit, AmendPreviousCommit = settings.amendCommit, PrettifyMessage = settings.prettify
                        });
                        FocusWindowIfItsOpen <GitHistoryWindow>();
                        logger.LogFormat(LogType.Log, "Commit {0} Successful.", commit.Sha);
                    }
                    catch (Exception e)
                    {
                        logger.Log(LogType.Error, "There was a problem while trying to commit");
                        logger.LogException(e);
                        return(false);
                    }
                    finally
                    {
                        GitProfilerProxy.EndSample();
                    }
                }
                gitManager.MarkDirty();
                return(true);
            }
            catch (Exception e)
            {
                logger.LogException(e);
            }
            finally
            {
                GUI.FocusControl("");
                ClearCommitMessage();
                //reset amend commit so the user will have to enable it again to load the last commit message
                settings.amendCommit = false;
            }
            return(false);
        }
Ejemplo n.º 10
0
 private static void RetreiveStatus(string[] paths)
 {
     try
     {
         GitProfilerProxy.BeginSample("Git Repository Status Retrieval");
         RebuildStatus(paths);
         GitProfilerProxy.EndSample();
         GitCallbacks.IssueUpdateRepository(status, paths);
         ThreadPool.QueueUserWorkItem(UpdateStatusTreeThreaded, status);
     }
     catch (Exception e)
     {
         FinishUpdating();
         Debug.LogError("Could not retrive Git Status");
         Debug.LogException(e);
     }
 }
Ejemplo n.º 11
0
        private void RetreiveStatus(string[] paths, bool threaded)
        {
            if (!threaded)
            {
                GitProfilerProxy.BeginSample("Git Repository Status Retrieval");
            }
            try
            {
                RebuildStatus(paths, threaded);
                FinishUpdating(threaded, paths);
            }
            catch (ThreadAbortException)
            {
                //run status retrieval on main thread if this thread was aborted
                actionQueue.Enqueue(() =>
                {
                    RetreiveStatus(paths);
                });
                //handle thread abort gracefully
                Thread.ResetAbort();
                logger.Log(LogType.Warning, "Git status threaded retrieval aborted, executing on main thread.");
            }
            catch (Exception e)
            {
                //mark dirty if thread failed
                if (threaded)
                {
                    MarkDirty();
                }
                FinishUpdating(threaded, paths);

                //logger.Log(LogType.Error,"Could not retrive Git Status");
                logger.LogException(e);
            }
            finally
            {
                if (!threaded)
                {
                    GitProfilerProxy.EndSample();
                }
            }
        }
Ejemplo n.º 12
0
        private bool AutoFetchChanges()
        {
            if (gitManager.Repository == null || !gitManager.IsValidRepo || !gitManager.Settings.AutoFetch)
            {
                return(false);
            }
            Remote remote = gitManager.Repository.Network.Remotes.FirstOrDefault();

            if (remote == null)
            {
                return(false);
            }
            GitProfilerProxy.BeginSample("Git automatic fetching");
            try
            {
                gitManager.Repository.Network.Fetch(remote, new FetchOptions()
                {
                    CredentialsProvider         = credentialsManager.FetchChangesAutoCredentialHandler,
                    OnTransferProgress          = GitManager.FetchTransferProgressHandler,
                    RepositoryOperationStarting = (context) =>
                    {
                        Debug.Log("Repository Operation Starting");
                        return(true);
                    }
                });
                //Debug.LogFormat("Auto Fetch From remote: {0} - ({1}) successful.", remote.Name, remote.Url);
            }
            catch (Exception e)
            {
                Debug.LogErrorFormat("Automatic Fetching from remote: {0} with URL: {1} Failed!", remote.Name, remote.Url);
                Debug.LogException(e);
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
            GitProfilerProxy.EndSample();
            return(false);
        }
Ejemplo n.º 13
0
 private void CreateStyles()
 {
     if (styles == null)
     {
         GitProfilerProxy.BeginSample("Git Diff Window Style Creation", this);
         try
         {
             styles = new Styles()
             {
                 diffScrollHeader = new GUIStyle("CurveEditorBackground")
                 {
                     contentOffset = new Vector2(48, 0), alignment = TextAnchor.MiddleLeft, fontSize = 18, fontStyle = FontStyle.Bold, normal = { textColor = Color.white * 0.9f }, padding = new RectOffset(12, 12, 12, 12), imagePosition = ImagePosition.ImageLeft
                 },
             };
             toolbarRenderer.LoadStyles();
             gitDiffWindowCommitRenderer.LoadStyles();
             diffElementRenderer.LoadStyles();
         }
         finally
         {
             GitProfilerProxy.EndSample();
         }
     }
 }
Ejemplo n.º 14
0
        static UniGitLoader()
        {
            HandlePaths();

            GitProfilerProxy.BeginSample("UniGit Initialization");
            try
            {
                GitWindows.OnWindowAddedEvent += OnWindowAdded;
                EditorApplication.update      += OnEditorUpdate;

                injectionHelper = new InjectionHelper();

                GitWindows.Init();

                uniGitData = CreateUniGitData();                 //data must be created manually to not call unity methods from constructors

                string projectPath = UniGitPathHelper.FixUnityPath(
                    Application.dataPath.Replace(UniGitPathHelper.UnityDeirectorySeparatorChar + "Assets", ""));
                string repoPath = projectPath;
                if (EditorPrefs.HasKey(RepoPathKey))
                {
                    repoPath = UniGitPathHelper.FixUnityPath(UniGitPathHelper.Combine(repoPath, EditorPrefs.GetString(RepoPathKey)));
                }

                injectionHelper.Bind <UniGitPaths>().FromInstance(new UniGitPaths(repoPath, projectPath));
                injectionHelper.Bind <GitInitializer>().NonLazy();
                injectionHelper.Bind <UniGitData>().FromMethod(c => uniGitData);                //must have a getter so that it can be injected
                injectionHelper.Bind <GitCallbacks>().FromMethod(GetGitCallbacks);
                injectionHelper.Bind <IGitPrefs>().To <UnityEditorGitPrefs>();
                injectionHelper.Bind <GitManager>().NonLazy();
                injectionHelper.Bind <GitSettingsJson>();
                injectionHelper.Bind <GitSettingsManager>();
                injectionHelper.Bind <GitAsyncManager>();
                injectionHelper.Bind <GitFileWatcher>().NonLazy();
                injectionHelper.Bind <GitReflectionHelper>();
                injectionHelper.Bind <IGitResourceManager>().To <GitResourceManager>();
                injectionHelper.Bind <GitOverlay>();
                injectionHelper.Bind <GitAutoFetcher>().NonLazy();
                injectionHelper.Bind <GitLog>();
                injectionHelper.Bind <ILogger>().FromMethod(c => new Logger(c.injectionHelper.GetInstance <GitLog>()));
                injectionHelper.Bind <GitAnimation>();
                injectionHelper.Bind <ICredentialsAdapter>().To <WincredCredentialsAdapter>();
                injectionHelper.Bind <GitCredentialsManager>().NonLazy();
                injectionHelper.Bind <IExternalAdapter>().To <GitExtensionsAdapter>();
                injectionHelper.Bind <IExternalAdapter>().To <TortoiseGitAdapter>();
                injectionHelper.Bind <GitExternalManager>();
                injectionHelper.Bind <GitLfsManager>().NonLazy();                //must be non lazy as it add itself as a filter
                injectionHelper.Bind <GitPushHookBase>().To <GitLfsPrePushHook>();
                injectionHelper.Bind <GitHookManager>().NonLazy();
                injectionHelper.Bind <GitLfsHelper>();
                injectionHelper.Bind <FileLinesReader>();
                injectionHelper.Bind <GitProjectOverlay>().NonLazy();
                injectionHelper.Bind <GitConflictsHandler>();

                //diff window
                injectionHelper.Bind <GitDiffWindowToolbarRenderer>().AsTransient();
                injectionHelper.Bind <GitDiffElementContextFactory>().AsTransient();
                injectionHelper.Bind <GitDiffWindowCommitRenderer>().AsTransient();
                injectionHelper.Bind <GitDiffWindowDiffElementRenderer>().AsTransient();

                Rebuild(injectionHelper);
            }
            finally
            {
                GitProfilerProxy.EndSample();
            }
        }
Ejemplo n.º 15
0
        private void DoToolbar(Rect rect, RepositoryInformation info)
        {
            Branch branch = selectedBranch.LoadBranch(gitManager);

            if (branch == null)
            {
                EditorGUILayout.HelpBox(string.Format("Invalid Branch: '{0}'", selectedBranch.CanonicalName), MessageType.Warning, true);
                return;
            }

            GitGUI.StartEnable();
            GitProfilerProxy.BeginSample("Git History Window Toolbar GUI", this);
            GUI.Box(rect, GUIContent.none, EditorStyles.toolbar);
            Rect       btRect            = new Rect(rect.x, rect.y, 64, rect.height);
            GUIContent pushButtonContent = GitGUI.GetTempContent("Push", GitGUI.Textures.CollabPush, "Push local changes to a remote repository.");

            if (info.CurrentOperation == CurrentOperation.Merge)
            {
                GUI.enabled = false;
                pushButtonContent.tooltip = "Do a Merge commit before pushing.";
            }
            else if (hasConflicts)
            {
                GUI.enabled = false;
                pushButtonContent.tooltip = "Resolve conflicts before pushing.";
            }
            else if (selectedBranch == null)
            {
                GUI.enabled = false;
                pushButtonContent.tooltip = "No Selected branch. Create a new branch or create atleast one commit.";
            }
            if (GUI.Button(btRect, pushButtonContent, EditorStyles.toolbarButton))
            {
                GoToPush();
            }
            btRect      = new Rect(btRect.x + 64, btRect.y, 64, btRect.height);
            GUI.enabled = !hasConflicts;
            if (GUI.Button(btRect, GitGUI.IconContent("CollabPull", "Pull", hasConflicts ? "Must resolve conflicts before pulling" : "Pull changes from remote repository by fetching them and then merging them. This is the same as calling Fetch then Merge."), EditorStyles.toolbarButton))
            {
                GoToPull();
            }
            btRect = new Rect(btRect.x + 70, btRect.y, 64, btRect.height);
            GUIContent fetchContent = GitGUI.GetTempContent("Fetch", GitOverlay.icons.fetch.image, "Get changes from remote repository but do not merge them.");

            if (branch.Remote != null)
            {
                fetchContent.tooltip = "Branch does not have a remote.";
                GUI.enabled          = false;
            }
            if (GUI.Button(btRect, fetchContent, EditorStyles.toolbarButton))
            {
                GoToFetch();
            }
            GUI.enabled = true;
            btRect      = new Rect(btRect.x + 64, btRect.y, 64, btRect.height);
            if (GUI.Button(btRect, GitGUI.GetTempContent("Merge", GitOverlay.icons.merge.image, hasConflicts ? "Must Resolve conflict before merging" : "Merge fetched changes from remote repository. Changes from the latest fetch will be merged."), EditorStyles.toolbarButton))
            {
                GoToMerge();
            }
            GUI.enabled = gitManager.IsValidRepo;
            btRect      = new Rect(btRect.x + 64, btRect.y, 64, btRect.height);
            if (GUI.Button(btRect, GitGUI.GetTempContent("Stash", GitOverlay.icons.stashIcon.image), EditorStyles.toolbarButton))
            {
                PopupWindow.Show(btRect, new GitStashWindow(gitManager));
            }
            GUI.enabled = true;

            GUIContent branchNameContent = GitGUI.GetTempContent(string.IsNullOrEmpty(selectedBranchName) ? "Branch" : selectedBranch.FriendlyName);

            if (selectedBranch.IsRemote)
            {
                branchNameContent.image = GitGUI.IconContentTex("ToolHandleGlobal");
            }
            else if (!selectedBranch.IsCurrentRepositoryHead)
            {
                branchNameContent.image = GitGUI.IconContentTex("IN LockButton on");
            }

            float branchNameWidth = EditorStyles.toolbarDropDown.CalcSize(branchNameContent).x;

            btRect = new Rect(rect.x + rect.width - branchNameWidth, btRect.y, branchNameWidth, btRect.height);
            if (GUI.Button(btRect, branchNameContent, EditorStyles.toolbarDropDown))
            {
                GenericMenu selectBranchMenu = new GenericMenu();
                foreach (var cachedBranch in cachedBranches)
                {
                    selectBranchMenu.AddItem(new GUIContent(cachedBranch.FriendlyName), selectedBranchName == cachedBranch.CanonicalName, (b) =>
                    {
                        SetSelectedBranch((string)b);
                        StartUpdateChaches(cachedStatus);
                    }, cachedBranch.CanonicalName);
                }
                selectBranchMenu.ShowAsContext();
            }
            GitGUI.EndEnable();
            btRect = new Rect(btRect.x - 64, btRect.y, 64, btRect.height);
            GitGUI.StartEnable(gitManager.Settings.ExternalsType.IsFlagSet(GitSettingsJson.ExternalsTypeEnum.Switch) || (!selectedBranch.IsRemote && !selectedBranch.IsCurrentRepositoryHead));
            if (GUI.Button(btRect, GitGUI.GetTempContent("Switch", GitOverlay.icons.checkout.image, selectedBranch.IsRemote ? "Cannot switch to remote branches." : selectedBranch.IsCurrentRepositoryHead ? "This branch is the active one" : "Switch to another branch"), EditorStyles.toolbarButton))
            {
                if (externalManager.TakeSwitch())
                {
                    gitManager.Callbacks.IssueAssetDatabaseRefresh();
                    gitManager.MarkDirty();
                }
                else
                {
                    PopupWindow.Show(btRect, new GitCheckoutWindowPopup(gitManager, selectedBranch.LoadBranch(gitManager)));
                }
            }
            GitGUI.EndEnable();
            btRect = new Rect(btRect.x - 21, btRect.y + 1, 21, btRect.height);
            EditorGUIUtility.AddCursorRect(btRect, MouseCursor.Link);
            if (GUI.Button(btRect, GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.HistoryWindowHelp);
            }
            GitProfilerProxy.EndSample();
        }
Ejemplo n.º 16
0
        private void CreateStyles()
        {
            if (styles == null)
            {
                GitProfilerProxy.BeginSample("Git History Window Style Creation", this);
                Texture2D blueTexture = new Texture2D(1, 1)
                {
                    hideFlags = HideFlags.HideAndDontSave
                };
                blueTexture.SetPixel(0, 0, new Color32(72, 123, 207, 255));
                blueTexture.Apply();

                Texture2D orangeTexture = new Texture2D(1, 1)
                {
                    hideFlags = HideFlags.HideAndDontSave
                };
                orangeTexture.SetPixel(0, 0, new Color32(234, 141, 43, 255));
                orangeTexture.Apply();

                styles = new Styles();
                styles.historyKnobNormal             = new GUIStyle("CN CountBadge");
                styles.historyKnobNormal.border      = new RectOffset(8, 8, 8, 8);
                styles.historyKnobNormal.margin      = new RectOffset(0, 0, 0, 0);
                styles.historyKnobNormal.fixedHeight = 0;
                styles.historyKnobHead = new GUIStyle()
                {
                    border = new RectOffset(6, 6, 6, 6), fixedHeight = 0, normal = new GUIStyleState()
                    {
                        background = EditorGUIUtility.FindTexture("sv_label_1")
                    }
                };
                styles.historyKnobRemote = new GUIStyle()
                {
                    border = new RectOffset(6, 6, 6, 6), fixedHeight = 0, normal = new GUIStyleState()
                    {
                        background = EditorGUIUtility.FindTexture("sv_label_5")
                    }
                };
                styles.historyKnobOther = new GUIStyle()
                {
                    border = new RectOffset(6, 6, 6, 6), fixedHeight = 0, normal = new GUIStyleState()
                    {
                        background = EditorGUIUtility.FindTexture("sv_label_2")
                    }
                };
                styles.headCommitTag = new GUIStyle("AssetLabel");
                styles.headCommitTag.normal.background = EditorGUIUtility.FindTexture("sv_label_1");
                styles.remoteCommitTag = new GUIStyle("AssetLabel");
                styles.remoteCommitTag.normal.background = EditorGUIUtility.FindTexture("sv_label_5");
                styles.otherCommitTag = new GUIStyle("AssetLabel");
                styles.otherCommitTag.normal.background = EditorGUIUtility.FindTexture("sv_label_2");
                styles.commitLineHead = new GUIStyle()
                {
                    normal = new GUIStyleState()
                    {
                        background = blueTexture
                    }
                };
                styles.commitLineRemote = new GUIStyle()
                {
                    normal = new GUIStyleState()
                    {
                        background = orangeTexture
                    }
                };
                styles.historyHelpBox = new GUIStyle(EditorStyles.helpBox)
                {
                    richText = true, padding = new RectOffset(8, 8, 8, 8), alignment = TextAnchor.MiddleLeft, contentOffset = new Vector2(24, -2)
                };
                styles.historyHelpBoxLabel = new GUIStyle("CN EntryWarn");
                styles.commitMessage       = new GUIStyle("TL SelectionButton")
                {
                    alignment = TextAnchor.UpperLeft, padding = new RectOffset(6, 4, 4, 4), clipping = TextClipping.Clip
                };
                styles.avatar = new GUIStyle("ShurikenEffectBg")
                {
                    contentOffset = Vector3.zero, alignment = TextAnchor.MiddleCenter, clipping = TextClipping.Clip, imagePosition = ImagePosition.ImageOnly
                };
                styles.avatarName = new GUIStyle("ShurikenEffectBg")
                {
                    contentOffset = Vector3.zero, alignment = TextAnchor.MiddleCenter, clipping = TextClipping.Clip, imagePosition = ImagePosition.TextOnly, fontSize = 28, fontStyle = FontStyle.Bold, normal = { textColor = Color.white }
                };
                GitProfilerProxy.EndSample();
            }
        }
Ejemplo n.º 17
0
        private void DoCommit(Rect rect, Rect scrollRect, CommitInfo commit)
        {
            GitProfilerProxy.BeginSample("Git History Window Commit GUI", this);
            Event current = Event.current;

            if (rect.y > scrollRect.height + historyScroll.y || rect.y + scrollRect.height < historyScroll.y)
            {
                return;
            }

            BranchInfo[] branches = commit.Branches;
            bool         isHead   = commit.IsHead;
            bool         isRemote = commit.IsRemote;

            GUI.Box(new Rect(8, rect.y + 6, 16, 16), GUIContent.none, "AC LeftArrow");
            GUI.Box(new Rect(8, rect.y + 6, 16, 16), GUIContent.none, branches != null && branches.Length > 0 ? isHead ? styles.historyKnobHead : isRemote ? styles.historyKnobRemote : styles.historyKnobOther : styles.historyKnobNormal);

            float y = 8;
            float x = 12;

            if (isHead)
            {
                //GUI.Box(new Rect(commitRect.x + 4, commitRect.y, commitRect.width - 8, commitRect.height - 8), GUIContent.none, "TL SelectionButton PreDropGlow");
            }
            GUI.Box(rect, GUIContent.none, "RegionBg");
            if (isHead || isRemote)
            {
                GUI.Box(new Rect(rect.x + 4, rect.y, rect.width - 8, 5), GUIContent.none, isHead ? styles.commitLineHead : styles.commitLineRemote);
                y += 4;
            }

            if (GitManager.Settings.UseGavatar && Application.internetReachability != NetworkReachability.NotReachable)
            {
                Texture2D avatar = GetProfilePixture(commit.Committer.Email);
                if (avatar != null)
                {
                    GUI.Box(new Rect(rect.x + x, rect.y + y, 32, 32), GitGUI.GetTempContent(avatar), styles.avatar);
                }
                else
                {
                    GUI.Box(new Rect(rect.x + x, rect.y + y, 32, 32), GitManager.icons.loadingIconSmall, styles.avatar);
                }
            }
            else
            {
                UnityEngine.Random.InitState(commit.Committer.Name.GetHashCode());
                GUI.contentColor = UnityEngine.Random.ColorHSV(0, 1, 0.6f, 0.6f, 0.8f, 1, 1, 1);
                GUI.Box(new Rect(rect.x + x, rect.y + y, 32, 32), GitGUI.GetTempContent(commit.Committer.Name.Substring(0, 1).ToUpper()), styles.avatarName);
                GUI.contentColor = Color.white;
            }


            //if (avatar != null)
            //{
            //GUI.DrawTexture(new Rect(rect.x + x, rect.y + y, 32, 32), avatar);
            //}
            x += 38;
            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x, EditorGUIUtility.singleLineHeight), GitGUI.GetTempContent(commit.Committer.Name), EditorStyles.boldLabel);
            y += 16;
            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x, EditorGUIUtility.singleLineHeight), GitGUI.GetTempContent(FormatRemainningTime(commit.Committer.When.UtcDateTime)));
            y += EditorGUIUtility.singleLineHeight + 3;
            int firstNewLineIndex = commit.Message.IndexOf(Environment.NewLine);

            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x - 10, EditorGUIUtility.singleLineHeight + 4), GitGUI.GetTempContent(firstNewLineIndex > 0 ? commit.Message.Substring(0, firstNewLineIndex) : commit.Message), styles.commitMessage);
            y += 8;
            if (branches != null)
            {
                if (branches.Length > 0)
                {
                    y += EditorGUIUtility.singleLineHeight;
                }
                foreach (var branch in branches)
                {
                    GUIStyle   style        = branch.IsRemote ? styles.remoteCommitTag : branch.IsCurrentRepositoryHead ? styles.headCommitTag : styles.otherCommitTag;
                    GUIContent labelContent = GitGUI.GetTempContent(branch.FriendlyName);
                    float      labelWidth   = style.CalcSize(labelContent).x;
                    GUI.Label(new Rect(rect.x + x, rect.y + y, labelWidth, EditorGUIUtility.singleLineHeight), labelContent, style);
                    x += labelWidth + 4;
                }
            }

            x  = 12;
            y += EditorGUIUtility.singleLineHeight * 1.5f;
            GUI.Box(new Rect(rect.x + x, rect.y + y, rect.width - x - x, EditorGUIUtility.singleLineHeight), GUIContent.none, "EyeDropperHorizontalLine");
            y += EditorGUIUtility.singleLineHeight / 3;
            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x, EditorGUIUtility.singleLineHeight), GitGUI.GetTempContent(commit.Id.Sha));
            x += GUI.skin.label.CalcSize(GitGUI.GetTempContent(commit.Id.Sha)).x + 8;
            Rect buttonRect = new Rect(rect.x + x, rect.y + y, 64, EditorGUIUtility.singleLineHeight);

            x          += 64;
            GUI.enabled = selectedBranch.IsCurrentRepositoryHead && !isHead;
            if (GUI.Button(buttonRect, GitGUI.GetTempContent("Reset", "Reset changes made up to this commit"), "minibuttonleft"))
            {
                if (GitExternalManager.TakeReset(GitManager.Repository.Lookup <Commit>(commit.Id)))
                {
                    AssetDatabase.Refresh();
                    GitManager.MarkDirty();
                }
                else
                {
                    PopupWindow.Show(buttonRect, new ResetPopupWindow(GitManager.Repository.Lookup <Commit>(commit.Id)));
                }
            }
            GUI.enabled = true;
            buttonRect  = new Rect(rect.x + x, rect.y + y, 64, EditorGUIUtility.singleLineHeight);
            if (GUI.Button(buttonRect, GitGUI.GetTempContent("Details"), "minibuttonright"))
            {
                PopupWindow.Show(buttonRect, new GitCommitDetailsWindow(GitManager.Repository.Lookup <Commit>(commit.Id)));
            }

            if (rect.Contains(current.mousePosition))
            {
                if (current.type == EventType.ContextClick)
                {
                    //GenericMenu commitContexMenu = new GenericMenu();

                    //commitContexMenu.ShowAsContext();
                    current.Use();
                }
            }
            GitProfilerProxy.EndSample();
        }
Ejemplo n.º 18
0
        private void DoHistoryScrollRect(Rect rect, RepositoryInformation info)
        {
            if (loadingCommits != null && !loadingCommits.IsDone)
            {
                Repaint();
                GitGUI.DrawLoading(rect, GitGUI.GetTempContent("Loading Commit History"));
                return;
            }

            Event current = Event.current;

            GUI.Box(new Rect(14, rect.y + 2, 2, rect.height), GUIContent.none, styles.historyLine);

            //behind,ahead and merge checking

            bool displayWarnningBox = DoWarningBoxValidate(info, selectedBranch);

            //commit layout
            if (current.type == EventType.Layout)
            {
                GitProfilerProxy.BeginSample("Git History Window Scroll Rect GUI Layout", this);
                Rect lastCommitRect = new Rect(32, commitSpacing, Mathf.Max(rect.width - 24, 512) - 32, 0);

                if (displayWarnningBox)
                {
                    warningBoxRect    = new Rect(lastCommitRect.x, lastCommitRect.y, lastCommitRect.width, helpBoxHeight);
                    lastCommitRect.y += helpBoxHeight + commitSpacing;
                }

                for (int i = 0; i < cachedCommits.Length; i++)
                {
                    lastCommitRect = LayoutCommit(lastCommitRect, cachedCommits[i]);
                    if (i < commitRects.Length)
                    {
                        commitRects[i] = lastCommitRect;
                    }
                }

                historyScrollContentsRect         = new Rect(0, 0, lastCommitRect.width + 32, lastCommitRect.y + lastCommitRect.height + commitSpacing * 2);
                historyScrollContentsRect.height += EditorGUIUtility.singleLineHeight * 3;
                GitProfilerProxy.EndSample();
            }
            else
            {
                GitProfilerProxy.BeginSample("Git History Window Scroll Rect GUI Other", this);
                historyScroll = GUI.BeginScrollView(rect, historyScroll, historyScrollContentsRect);

                if (displayWarnningBox)
                {
                    DoWarningBox(warningBoxRect, info, selectedBranch);
                }

                for (int i = 0; i < cachedCommits.Length; i++)
                {
                    if (i < commitRects.Length)
                    {
                        DoCommit(commitRects[i], rect, cachedCommits[i]);
                    }
                }

                Rect commitsCountRect = new Rect(32, historyScrollContentsRect.height - EditorGUIUtility.singleLineHeight * 4, historyScrollContentsRect.width - 64, EditorGUIUtility.singleLineHeight);

                GUI.Label(commitsCountRect, GitGUI.GetTempContent(cachedCommits.Length + " / " + maxCommitsCount), EditorStyles.centeredGreyMiniLabel);

                Rect resetRect    = new Rect(historyScrollContentsRect.width / 2, historyScrollContentsRect.height - EditorGUIUtility.singleLineHeight * 3, 64, EditorGUIUtility.singleLineHeight);
                Rect loadMoreRect = new Rect(historyScrollContentsRect.width / 2 - 64, historyScrollContentsRect.height - EditorGUIUtility.singleLineHeight * 3, 64, EditorGUIUtility.singleLineHeight);
                if (GUI.Button(loadMoreRect, GitGUI.IconContent("ol plus", "More", "Show more commits."), styles.loadMoreCommitsBtn))
                {
                    maxCommitsCount += CommitsPerExpand;
                    StartUpdateChaches(cachedStatus);
                }
                GitGUI.StartEnable(maxCommitsCount != MaxFirstCommitCount);
                if (GUI.Button(resetRect, GitGUI.GetTempContent("Reset", "Reset the number of commits show."), styles.resetCommitsBtn))
                {
                    if (MaxFirstCommitCount < maxCommitsCount)
                    {
                        maxCommitsCount = MaxFirstCommitCount;
                        Array.Resize(ref cachedCommits, maxCommitsCount);
                    }
                    else
                    {
                        maxCommitsCount = MaxFirstCommitCount;
                        StartUpdateChaches(cachedStatus);
                    }
                }
                GitGUI.EndEnable();
                GUI.EndScrollView();
                GitProfilerProxy.EndSample();
            }
        }
Ejemplo n.º 19
0
        private void DoToolbar(Rect rect, RepositoryInformation info)
        {
            GitProfilerProxy.BeginSample("Git History Window Toolbar GUI", this);
            GUI.Box(rect, GUIContent.none, "Toolbar");
            Rect       btRect            = new Rect(rect.x, rect.y, 64, rect.height);
            GUIContent pushButtonContent = GitGUI.GetTempContent(EditorGUIUtility.FindTexture("CollabPush"), "Push", "Push local changes to a remote repository.");

            if (info.CurrentOperation == CurrentOperation.Merge)
            {
                GUI.enabled = false;
                pushButtonContent.tooltip = "Do a Merge commit before pushing.";
            }
            else if (hasConflicts)
            {
                GUI.enabled = false;
                pushButtonContent.tooltip = "Resolve conflicts before pushing.";
            }
            if (GUI.Button(btRect, pushButtonContent, "toolbarbutton"))
            {
                if (GitExternalManager.TakePush())
                {
                    GitManager.MarkDirty();
                }
                else
                {
                    ScriptableWizard.DisplayWizard <GitPushWizard>("Push", "Push").Init(selectedBranch.LoadBranch());
                }
            }
            btRect      = new Rect(btRect.x + 64, btRect.y, 64, btRect.height);
            GUI.enabled = !hasConflicts;
            if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("CollabPull").image, "Pull", hasConflicts ? "Must resolve conflicts before pulling" : "Pull changes from remote repository by fetching them and then merging them. This is the same as calling Fetch then Merge."), "toolbarbutton"))
            {
                Branch branch = selectedBranch.LoadBranch();
                if (branch != null)
                {
                    if (GitExternalManager.TakePull())
                    {
                        AssetDatabase.Refresh();
                        GitManager.MarkDirty();
                    }
                    else
                    {
                        ScriptableWizard.DisplayWizard <GitPullWizard>("Pull", "Pull").Init(branch);
                    }
                }
                else
                {
                    Debug.LogError("Could Not Load Branch");
                }
            }
            btRect = new Rect(btRect.x + 70, btRect.y, 64, btRect.height);
            if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("UniGit/GitFetch").image, "Fetch", "Get changes from remote repository but do not merge them."), "toolbarbutton"))
            {
                Branch branch = selectedBranch.LoadBranch();
                if (branch != null)
                {
                    if (branch.Remote != null)
                    {
                        if (GitExternalManager.TakeFetch(branch.Remote.Name))
                        {
                            GitManager.MarkDirty();
                        }
                        else
                        {
                            ScriptableWizard.DisplayWizard <GitFetchWizard>("Fetch", "Fetch").Init(branch);
                        }
                    }
                    else
                    {
                        Debug.LogError("Branch does not have a remote");
                    }
                }
                else
                {
                    Debug.LogError("Could not Load Branch");
                }
            }
            btRect = new Rect(btRect.x + 64, btRect.y, 64, btRect.height);
            if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("UniGit/GitMerge").image, "Merge", hasConflicts ? "Must Resolve conflict before merging" : "Merge fetched changes from remote repository. Changes from the latest fetch will be merged."), "toolbarbutton"))
            {
                if (GitExternalManager.TakeMerge())
                {
                    GitManager.MarkDirty();
                }
                else
                {
                    ScriptableWizard.DisplayWizard <GitMergeWizard>("Merge", "Merge");
                }
            }
            GUI.enabled = true;
            btRect      = new Rect(rect.x + rect.width - 64, btRect.y, 64, btRect.height);
            if (GUI.Button(btRect, GitGUI.GetTempContent(string.IsNullOrEmpty(selectedBranchName) ? "Branch" : selectedBranch.FriendlyName), "ToolbarDropDown"))
            {
                GenericMenu selectBranchMenu = new GenericMenu();
                foreach (var branch in cachedBranches)
                {
                    selectBranchMenu.AddItem(new GUIContent(branch.FriendlyName), false, (b) =>
                    {
                        selectedBranchName = (string)b;
                        UpdateSelectedBranch();
                    }, branch.FriendlyName);
                }
                selectBranchMenu.ShowAsContext();
            }
            btRect      = new Rect(btRect.x - 64, btRect.y, 64, btRect.height);
            GUI.enabled = GitManager.Settings.ExternalsType.HasFlag(GitSettings.ExternalsTypeEnum.Switch) || (!selectedBranch.IsRemote && !selectedBranch.IsCurrentRepositoryHead);
            if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("UniGit/GitCheckout").image, "Switch", selectedBranch.IsRemote ? "Cannot switch to remote branches." : selectedBranch.IsCurrentRepositoryHead ? "This branch is the active one" : "Switch to another branch"), "toolbarbutton"))
            {
                if (GitExternalManager.TakeSwitch())
                {
                    AssetDatabase.Refresh();
                    GitManager.MarkDirty();
                }

                //todo Implement native switching
            }
            GUI.enabled = true;
            GitProfilerProxy.EndSample();
        }
Ejemplo n.º 20
0
        private void DoCommit(Rect rect, Rect scrollRect, CommitInfo commit)
        {
            GitProfilerProxy.BeginSample("Git History Window Commit GUI", this);
            Event current = Event.current;

            if (rect.y > scrollRect.height + historyScroll.y || rect.y + scrollRect.height < historyScroll.y)
            {
                return;
            }

            BranchInfo[] branches = commit.Branches;
            bool         isHead   = commit.IsHead;
            bool         isRemote = commit.IsRemote;

            Color branchColor = Color.white;

            if (branches != null)
            {
                foreach (var branch in branches)
                {
                    if (branch.IsRemote)
                    {
                        branchColor = remoteColor;
                        break;
                    }
                    if (branch.IsCurrentRepositoryHead)
                    {
                        branchColor = headColor;
                        break;
                    }
                    UnityEngine.Random.InitState(branch.CanonicalName.GetHashCode());
                    branchColor = UnityEngine.Random.ColorHSV(0, 1, 0, 1);
                }
            }

            GUI.backgroundColor = new Color(1, 1, 1, 0.4f);
            GUI.Box(new Rect(24, rect.y + 5, 16, 16), GUIContent.none, styles.commitArrow);
            GUI.backgroundColor = branchColor;
            GUI.Box(new Rect(9, rect.y + 6, 12, 12), GUIContent.none, styles.historyKnobNormal);
            GUI.backgroundColor = Color.white;

            float y = 8;
            float x = 12;

            if (isHead)
            {
                //GUI.Box(new Rect(commitRect.x + 4, commitRect.y, commitRect.width - 8, commitRect.height - 8), GUIContent.none, "TL SelectionButton PreDropGlow");
            }
            GUI.Box(rect, GUIContent.none, styles.commitBg);
            if (isHead || isRemote)
            {
                GUI.color = branchColor;
                GUI.DrawTexture(new Rect(rect.x + 4, rect.y, rect.width - 8, 5), Texture2D.whiteTexture);
                GUI.color = Color.white;
                y        += 4;
            }

            if (gitManager.Settings.UseGavatar && Application.internetReachability != NetworkReachability.NotReachable)
            {
                Texture2D avatar = GetProfilePixture(commit.Committer.Email);
                GUI.Box(new Rect(rect.x + x, rect.y + y, 32, 32), avatar != null ? GitGUI.GetTempContent(avatar) : GitOverlay.icons.loadingIconSmall, styles.avatar);
            }
            else
            {
                UnityEngine.Random.InitState(commit.Committer.Name.GetHashCode());
                GUI.contentColor = UnityEngine.Random.ColorHSV(0, 1, 0.6f, 0.6f, 0.8f, 1, 1, 1);
                GUI.Box(new Rect(rect.x + x, rect.y + y, 32, 32), GitGUI.GetTempContent(commit.Committer.Name.Substring(0, 1).ToUpper()), styles.avatarName);
                GUI.contentColor = Color.white;
            }


            x += 38;
            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x, EditorGUIUtility.singleLineHeight), GitGUI.GetTempContent(commit.Committer.Name), EditorStyles.boldLabel);
            y += 16;
            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x, EditorGUIUtility.singleLineHeight), GitGUI.GetTempContent(FormatRemainningTime(commit.Committer.When.UtcDateTime)));
            y += EditorGUIUtility.singleLineHeight + 3;
            int firstNewLineIndex = commit.Message.IndexOf(Environment.NewLine);

            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x - 10, EditorGUIUtility.singleLineHeight + 4), GitGUI.GetTempContent(firstNewLineIndex > 0 ? commit.Message.Substring(0, firstNewLineIndex) : commit.Message), styles.commitMessage);
            y += 8;
            if (branches != null)
            {
                if (branches.Length > 0)
                {
                    y += EditorGUIUtility.singleLineHeight;
                }
                foreach (var branch in branches)
                {
                    GUIStyle style = styles.otherCommitTag;
                    if (branch.IsRemote)
                    {
                        GUI.backgroundColor = remoteColor;
                    }
                    else if (branch.IsCurrentRepositoryHead)
                    {
                        GUI.backgroundColor = headColor;
                    }
                    else
                    {
                        UnityEngine.Random.InitState(branch.CanonicalName.GetHashCode());
                        GUI.backgroundColor = UnityEngine.Random.ColorHSV(0, 1, 0, 1);
                    }
                    GUIContent labelContent   = GitGUI.GetTempContent(branch.FriendlyName, branch.CanonicalName);
                    float      labelWidth     = style.CalcSize(labelContent).x;
                    Rect       branchIconRect = new Rect(rect.x + x, rect.y + y, labelWidth, EditorGUIUtility.singleLineHeight);
                    GUI.Label(branchIconRect, labelContent, style);
                    x += labelWidth + 4;
                    GUI.backgroundColor = Color.white;

                    if (Event.current.type == EventType.ContextClick && branchIconRect.Contains(Event.current.mousePosition))
                    {
                        GenericMenu branchContextMenu = new GenericMenu();
                        BranchInfo  b = branch;
                        branchContextMenu.AddItem(new GUIContent("View branch"), false, () => { ViewBranchCallback(b); });
                        if (!b.IsRemote && !b.IsCurrentRepositoryHead)
                        {
                            branchContextMenu.AddItem(new GUIContent("Switch To Branch"), false, () => { SwitchToBranchCallback(b, new Rect(branchIconRect.x - historyScroll.x, branchIconRect.y - historyScroll.y, branchIconRect.width, branchIconRect.height)); });
                        }
                        else
                        {
                            branchContextMenu.AddDisabledItem(new GUIContent("Switch To Branch"));
                        }
                        branchContextMenu.ShowAsContext();
                    }
                }
            }

            x  = 12;
            y += EditorGUIUtility.singleLineHeight * 1.5f;
            GUI.Box(new Rect(rect.x + x, rect.y + y, rect.width - x - x, EditorGUIUtility.singleLineHeight), GUIContent.none, styles.commitHashSeparator);
            y += EditorGUIUtility.singleLineHeight / 3;
            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x, EditorGUIUtility.singleLineHeight), GitGUI.GetTempContent(commit.Id.Sha));
            x += GUI.skin.label.CalcSize(GitGUI.GetTempContent(commit.Id.Sha)).x + 8;
            Rect buttonRect = new Rect(rect.x + x, rect.y + y, 64, EditorGUIUtility.singleLineHeight);

            x += 64;
            if (GUI.Button(buttonRect, GitGUI.GetTempContent("Options"), EditorStyles.miniButtonLeft))
            {
                GenericMenu menu = new GenericMenu();

                if (selectedBranch.IsCurrentRepositoryHead && !isHead)
                {
                    var rect1 = buttonRect;
                    menu.AddItem(new GUIContent("Reset"), false, () =>
                    {
                        if (externalManager.TakeReset(gitManager.Repository.Lookup <Commit>(commit.Id)))
                        {
                            gitManager.Callbacks.IssueAssetDatabaseRefresh();
                            gitManager.MarkDirty();
                        }
                        else
                        {
                            popupsQueue.Enqueue(new KeyValuePair <Rect, PopupWindowContent>(rect1, new ResetPopupWindow(gitManager, gitManager.Repository.Lookup <Commit>(commit.Id))));
                        }
                    });
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Reset"));
                }
                var rect2 = buttonRect;
                menu.AddItem(new GUIContent("Branch Out"), false, () =>
                {
                    popupsQueue.Enqueue(new KeyValuePair <Rect, PopupWindowContent>(rect2, new GitCreateBranchWindow(gitManager.Repository.Lookup <Commit>(commit.Id), null, gitManager)));
                });
                menu.DropDown(buttonRect);
            }
            GUI.enabled = true;
            buttonRect  = new Rect(rect.x + x, rect.y + y, 64, EditorGUIUtility.singleLineHeight);
            if (GUI.Button(buttonRect, GitGUI.GetTempContent("Details"), EditorStyles.miniButtonRight))
            {
                PopupWindow.Show(buttonRect, new GitCommitDetailsWindow(gitManager, externalManager, gitManager.Repository.Lookup <Commit>(commit.Id)));
            }

            if (rect.Contains(current.mousePosition))
            {
                if (current.type == EventType.ContextClick)
                {
                    current.Use();
                }
            }
            GitProfilerProxy.EndSample();
        }
Ejemplo n.º 21
0
        private void CreateStyles()
        {
            if (styles == null)
            {
                GitProfilerProxy.BeginSample("Git History Window Style Creation", this);

                styles = new Styles
                {
                    historyKnobNormal = new GUIStyle("sv_iconselector_labelselection")
                    {
                        border      = new RectOffset(6, 6, 6, 6),
                        margin      = new RectOffset(0, 0, 0, 0),
                        fixedHeight = 0
                    },
                    historyKnobHead = new GUIStyle()
                    {
                        border = new RectOffset(6, 6, 6, 6), fixedHeight = 0, normal = new GUIStyleState()
                        {
                            background = EditorGUIUtility.FindTexture("sv_label_1")
                        }
                    },
                    historyKnobRemote = new GUIStyle()
                    {
                        border = new RectOffset(6, 6, 6, 6), fixedHeight = 0, normal = new GUIStyleState()
                        {
                            background = EditorGUIUtility.FindTexture("sv_label_5")
                        }
                    },
                    historyKnobOther = new GUIStyle()
                    {
                        border = new RectOffset(6, 6, 6, 6), fixedHeight = 0, normal = new GUIStyleState()
                        {
                            background = EditorGUIUtility.FindTexture("sv_label_2")
                        }
                    },
                    headCommitTag = new GUIStyle("AssetLabel")
                    {
                        normal = { background = EditorGUIUtility.FindTexture("sv_label_1") }
                    },
                    remoteCommitTag = new GUIStyle("AssetLabel")
                    {
                        normal = { background = EditorGUIUtility.FindTexture("sv_label_5") }
                    },
                    otherCommitTag = new GUIStyle("AssetLabel")
                    {
                        normal = { background = ((GUIStyle)"sv_iconselector_labelselection").normal.background }
                    },
                    historyHelpBox = new GUIStyle(EditorStyles.helpBox)
                    {
                        richText = true, padding = new RectOffset(8, 8, 8, 8), alignment = TextAnchor.MiddleLeft, contentOffset = new Vector2(24, -2)
                    },
                    historyHelpBoxLabel = new GUIStyle("CN EntryWarn"),
                    commitMessage       = new GUIStyle("TL SelectionButton")
                    {
                        alignment = TextAnchor.UpperLeft, padding = new RectOffset(6, 4, 4, 4), clipping = TextClipping.Clip
                    },
                    avatar = new GUIStyle("ShurikenEffectBg")
                    {
                        contentOffset = Vector3.zero, alignment = TextAnchor.MiddleCenter, clipping = TextClipping.Clip, imagePosition = ImagePosition.ImageOnly
                    },
                    avatarName = new GUIStyle("ShurikenEffectBg")
                    {
                        contentOffset = Vector3.zero, alignment = TextAnchor.MiddleCenter, clipping = TextClipping.Clip, imagePosition = ImagePosition.TextOnly, fontSize = 28, fontStyle = FontStyle.Bold, normal = { textColor = Color.white }
                    },
                    historyLine         = "AppToolbar",
                    loadMoreCommitsBtn  = "ButtonLeft",
                    resetCommitsBtn     = "ButtonRight",
                    commitArrow         = "AC LeftArrow",
                    commitBg            = "RegionBg",
                    commitHashSeparator = "EyeDropperHorizontalLine"
                };
                GitProfilerProxy.EndSample();
            }
        }