Beispiel #1
0
        private void OnGUI()
        {
            using (GUILayoutHelper.Vertical())
            {
                username = EditorGUILayout.TextField("Username", username);
                Color passwordColor = Color.grey;
                if (hasVerified && !success)
                {
                    passwordColor = Color.red;
                }
                if (hasVerified && success)
                {
                    passwordColor = Color.green;
                }
                using (GUILayoutHelper.BackgroundColor(passwordColor))
                {
                    password = EditorGUILayout.PasswordField("Password", password);
                }

                allowCacheCredentials = GUILayout.Toggle(allowCacheCredentials, new GUIContent("Allow Credentials to be cached"));

                using (GUILayoutHelper.Horizontal())
                {
                    if (GUILayout.Button("Cancel"))
                    {
                        Close();
                    }
                    if (!success)
                    {
                        if (GUILayout.Button("Verify"))
                        {
                            hasVerified = true;
                            success     = VCCommands.Instance.SetUserCredentials(username, password, allowCacheCredentials);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Close"))
                        {
                            Close();
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void DrawButtons()
        {
            EditorGUILayout.BeginHorizontal();

            GUI.SetNextControlName("CommitMessage");
            using (GUILayoutHelper.BackgroundColor(CommitMessage.Length < 10 ? new Color(1, 0, 0) : new Color(0, 1, 0)))
            {
                statusScroll  = EditorGUILayout.BeginScrollView(statusScroll, false, false);
                CommitMessage = EditorGUILayout.TextArea(CommitMessage, GUILayout.MinWidth(100), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                EditorGUILayout.EndScrollView();
            }
            if (firstTime)
            {
                GUI.FocusControl("CommitMessage");
                firstTime = false;
            }

            using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
            {
                if (GUILayout.Button(Terminology.commit, GUILayout.Width(100)))
                {
                    var selection = VCSettings.SelectiveCommit ? vcMultiColumnAssetList.GetMasterSelection() : vcMultiColumnAssetList.GetSelection();
                    if (selection.Count() != 0)
                    {
                        var selectedAssets = selection.Select(status => status.assetPath).Select(cstr => cstr.Compose()).ToList();
                        VCCommands.Instance.ProgressInformation += s =>
                        {
                            commitProgress = commitProgress + s;
                            if (commitProgress.Length > maxProgressSize)
                            {
                                commitProgress = commitProgress.Substring(commitProgress.Length - maxProgressSize);
                            }
                            statusScroll.y = Mathf.Infinity;
                            Repaint();
                        };
                        var commitTask = VCCommands.Instance.CommitTask(selectedAssets, CommitMessage);
                        commitTask.ContinueWithOnNextUpdate(result =>
                        {
                            if (result)
                            {
                                commitedFiles = selectedAssets;
                                CommitMessage = "";
                                Repaint();
                                if (VCSettings.AutoCloseAfterSuccess)
                                {
                                    Close();
                                }
                            }
                            commitCompleted = true;
                        });
                        commitInProgress = true;
                    }
                    else
                    {
                        ShowNotification(new GUIContent("No files selected"));
                    }
                }
                if (GUILayout.Button("Cancel", GUILayout.Width(100)))
                {
                    Close();
                }
            }
            EditorGUILayout.EndHorizontal();
            if (vcMultiColumnAssetList.GetSelection().Any())
            {
                RemoveNotification();
            }
        }