Exemple #1
0
    void OnGUI()
    {
        if (browser != null)
        {
            GUILayout.Label("Commit Message:");

            commitMessage = EditorGUILayout.TextArea(commitMessage, GUILayout.ExpandHeight(true));

            oldCommits[0] = commitMessage;

            GUI.SetNextControlName("Selection");
            int selection = EditorGUILayout.Popup(oldCommitSelection, oldCommits, GUILayout.ExpandWidth(true));

            if (selection != oldCommitSelection)
            {
                oldCommitSelection = selection;
                commitMessage      = oldCommits[oldCommitSelection];
                GUI.FocusControl("Selection");
            }

            GUILayout.Space(6);

            amend      = GUILayout.Toggle(amend, "Amend previous commit");
            showOutput = GUILayout.Toggle(showOutput, "Show output");

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("OK", GUILayout.Width(100)))
            {
                if (oldCommits.Length > oldCommitsMaxLength)
                {
                    string[] temp = new string[30];
                    System.Array.ConstrainedCopy(oldCommits, 0, temp, 0, 30);
                    string str = string.Join(System.Convert.ToChar(0x0).ToString(), temp);
                    EditorPrefs.SetString("UnityVersionControl.OldCommitMessages", StringHelpers.UnicodeToHexString(str));
                }
                else
                {
                    string str = string.Join(System.Convert.ToChar(0x0).ToString(), oldCommits);
                    EditorPrefs.SetString("UnityVersionControl.OldCommitMessages", StringHelpers.UnicodeToHexString(str));
                }

                this.Close();

                if (amend)
                {
                    if (EditorUtility.DisplayDialog(
                            "Warning - changing history",
                            "You have chosen to amend the previous commit - this alters history and will cause problems if you have already pushed the previous commit to a remote. Are you sure you want to continue?", "Ok", "Cancel"))
                    {
                        UVCProcessPopup.Init(VersionControl.Commit(CommandLine.EmptyHandler, commitMessage.ToLiteral(), true, BrowserUtility.selectedFileCache), !showOutput, true, browser.OnProcessStop, true);
                    }
                }
                else
                {
                    UVCProcessPopup.Init(VersionControl.Commit(CommandLine.EmptyHandler, commitMessage.ToLiteral(), false, BrowserUtility.selectedFileCache), !showOutput, true, browser.OnProcessStop, true);
                }
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Cancel", GUILayout.Width(100)))
            {
                this.Close();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else
        {
            this.Close();
        }
    }