Beispiel #1
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();
            }
        }
Beispiel #2
0
 private List <string> GetSelectedAssets()
 {
     return(vcMultiColumnAssetList.GetMasterSelection().Select(status => status.assetPath).Select(cstr => cstr.Compose()).ToList());
 }