Created unity project
This commit is contained in:
@@ -0,0 +1,194 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow.QueryViews.Branches;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.Progress;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Branches.Dialogs
|
||||
{
|
||||
class CreateBranchDialog : PlasticDialog
|
||||
{
|
||||
protected override Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var baseRect = base.DefaultRect;
|
||||
return new Rect(baseRect.x, baseRect.y, 710, 290);
|
||||
}
|
||||
}
|
||||
|
||||
protected override string GetTitle()
|
||||
{
|
||||
return PlasticLocalization.Name.CreateChildBranchTitle.GetString();
|
||||
}
|
||||
|
||||
protected override void OnModalGUI()
|
||||
{
|
||||
DoTitleArea();
|
||||
|
||||
DoFieldsArea();
|
||||
|
||||
DoButtonsArea();
|
||||
}
|
||||
|
||||
internal static BranchCreationData CreateBranchFromLastParentBranchChangeset(
|
||||
EditorWindow parentWindow,
|
||||
RepositorySpec repSpec,
|
||||
BranchInfo parentBranchInfo)
|
||||
{
|
||||
string changesetStr = PlasticLocalization.Name.LastChangeset.GetString();
|
||||
|
||||
string explanation = BranchCreationUserInfo.GetFromObjectString(
|
||||
repSpec, parentBranchInfo, changesetStr);
|
||||
|
||||
CreateBranchDialog dialog = Create(repSpec, parentBranchInfo, -1 , explanation);
|
||||
ResponseType dialogueResult = dialog.RunModal(parentWindow);
|
||||
|
||||
BranchCreationData result = dialog.BuildCreationData();
|
||||
result.Result = dialogueResult == ResponseType.Ok;
|
||||
return result;
|
||||
}
|
||||
|
||||
void DoTitleArea()
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
Title(PlasticLocalization.Name.CreateChildBranchTitle.GetString());
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
Paragraph(string.Format("{0} {1}",
|
||||
PlasticLocalization.Name.CreateChildBranchExplanation.GetString(), mExplanation));
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
void DoFieldsArea()
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.Name.BranchNameEntry.GetString(),
|
||||
GUILayout.Width(100));
|
||||
|
||||
GUI.SetNextControlName(NAME_FIELD_CONTROL_NAME);
|
||||
mNewBranchName = GUILayout.TextField(mNewBranchName);
|
||||
|
||||
if (!mWasNameFieldFocused)
|
||||
{
|
||||
EditorGUI.FocusTextInControl(NAME_FIELD_CONTROL_NAME);
|
||||
mWasNameFieldFocused = true;
|
||||
}
|
||||
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
using (new EditorGUILayout.VerticalScope(GUILayout.Width(100)))
|
||||
{
|
||||
GUILayout.Space(49);
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.Name.CommentsEntry.GetString(),
|
||||
GUILayout.Width(100));
|
||||
}
|
||||
mComment = GUILayout.TextArea(mComment, GUILayout.Height(100));
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
mSwitchToBranch = GUILayout.Toggle(mSwitchToBranch, PlasticLocalization.Name.SwitchToBranchCheckButton.GetString());
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
void DoButtonsArea()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope(GUILayout.MinWidth(500)))
|
||||
{
|
||||
GUILayout.Space(2);
|
||||
DrawProgressForDialogs.For(
|
||||
mProgressControls.ProgressData);
|
||||
GUILayout.Space(2);
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
DoCreateButton();
|
||||
DoCancelButton();
|
||||
}
|
||||
}
|
||||
|
||||
void DoCancelButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.Name.CancelButton.GetString()))
|
||||
return;
|
||||
|
||||
CancelButtonAction();
|
||||
}
|
||||
|
||||
void DoCreateButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.Name.CreateButton.GetString()))
|
||||
return;
|
||||
|
||||
BranchCreationValidation.AsyncValidation(
|
||||
BuildCreationData(), this, mProgressControls);
|
||||
}
|
||||
|
||||
static CreateBranchDialog Create(
|
||||
RepositorySpec repSpec, BranchInfo parentBranchInfo, long changesetId, string explanation)
|
||||
{
|
||||
var instance = CreateInstance<CreateBranchDialog>();
|
||||
instance.IsResizable = false;
|
||||
instance.mEscapeKeyAction = instance.CloseButtonAction;
|
||||
instance.mRepositorySpec = repSpec;
|
||||
instance.mParentBranchInfo = parentBranchInfo;
|
||||
instance.mNewBranchName = "";
|
||||
instance.mComment = "";
|
||||
instance.mSwitchToBranch = true;
|
||||
instance.mProgressControls = new ProgressControlsForDialogs();
|
||||
instance.mExplanation = explanation;
|
||||
instance.mChangesetId = changesetId;
|
||||
return instance;
|
||||
}
|
||||
|
||||
BranchCreationData BuildCreationData()
|
||||
{
|
||||
return new BranchCreationData(
|
||||
mRepositorySpec,
|
||||
mParentBranchInfo,
|
||||
mChangesetId,
|
||||
mNewBranchName,
|
||||
mComment,
|
||||
null,
|
||||
mSwitchToBranch);
|
||||
}
|
||||
|
||||
ProgressControlsForDialogs mProgressControls;
|
||||
|
||||
RepositorySpec mRepositorySpec;
|
||||
BranchInfo mParentBranchInfo;
|
||||
long mChangesetId;
|
||||
|
||||
string mNewBranchName;
|
||||
string mComment;
|
||||
bool mSwitchToBranch;
|
||||
string mExplanation;
|
||||
|
||||
bool mWasNameFieldFocused;
|
||||
const string NAME_FIELD_CONTROL_NAME = "CreateBranchNameField";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0fc5252a48d8b34f945b4ae3ad45030
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Branches.Dialogs
|
||||
{
|
||||
internal class DeleteBranchDialog : PlasticDialog
|
||||
{
|
||||
protected override Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var baseRect = base.DefaultRect;
|
||||
var increaseFactor = mNumberOfBranches <= MAX_ITEMS_TO_SHOW ?
|
||||
TEXT_LINE_HEIGHT * mNumberOfBranches :
|
||||
TEXT_LINE_HEIGHT * (MAX_ITEMS_TO_SHOW + 1);
|
||||
return new Rect(baseRect.x, baseRect.y, baseRect.width, baseRect.height + increaseFactor);
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool ConfirmDelete(IList<BranchInfo> branches)
|
||||
{
|
||||
DeleteBranchDialog dialog = Create(branches);
|
||||
|
||||
return dialog.RunModal(null) == ResponseType.Ok;
|
||||
}
|
||||
|
||||
protected override string GetTitle()
|
||||
{
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
protected override void OnModalGUI()
|
||||
{
|
||||
Paragraph(mMessage);
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
DoButtonsArea();
|
||||
}
|
||||
|
||||
void DoButtonsArea()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
mConfirmDelete = ToggleEntry(
|
||||
PlasticLocalization.Name.ConfirmationCheckBox.GetString(),
|
||||
mConfirmDelete);
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
DoDeleteButton();
|
||||
DoCancelButton();
|
||||
return;
|
||||
}
|
||||
|
||||
DoCancelButton();
|
||||
DoDeleteButton();
|
||||
}
|
||||
}
|
||||
|
||||
void DoCancelButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.Name.NoButton.GetString()))
|
||||
return;
|
||||
|
||||
CancelButtonAction();
|
||||
}
|
||||
|
||||
void DoDeleteButton()
|
||||
{
|
||||
GUI.enabled = mConfirmDelete;
|
||||
|
||||
if (NormalButton(PlasticLocalization.Name.DeleteButton.GetString()))
|
||||
{
|
||||
OkButtonAction();
|
||||
}
|
||||
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
static DeleteBranchDialog Create(IList<BranchInfo> branches)
|
||||
{
|
||||
var instance = CreateInstance<DeleteBranchDialog>();
|
||||
instance.mMessage = BuildDeleteBranchesConfirmationMessage(branches);
|
||||
instance.mNumberOfBranches = branches.Count;
|
||||
instance.mTitle = PlasticLocalization.Name.ConfirmDeleteTitle.GetString();
|
||||
return instance;
|
||||
}
|
||||
|
||||
static string BuildDeleteBranchesConfirmationMessage(IList<BranchInfo> branchToDelete)
|
||||
{
|
||||
string[] itemNames = branchToDelete.Select(x => x.Name).ToArray();
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.AppendLine(PlasticLocalization.Name.DeleteBranchesExplanation.GetString());
|
||||
stringBuilder.AppendLine();
|
||||
int num = Math.Min(itemNames.Length, MAX_ITEMS_TO_SHOW);
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
stringBuilder.AppendLine(" " + (i + 1) + ". " + itemNames[i]);
|
||||
}
|
||||
|
||||
if (itemNames.Length > MAX_ITEMS_TO_SHOW)
|
||||
{
|
||||
stringBuilder.AppendLine(PlasticLocalization.Name.DeleteOthersMessage.GetString(itemNames.Length - MAX_ITEMS_TO_SHOW));
|
||||
}
|
||||
|
||||
stringBuilder.AppendLine();
|
||||
stringBuilder.AppendLine(PlasticLocalization.Name.DeleteBranchesConfirmation.GetString());
|
||||
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
const int TEXT_LINE_HEIGHT = 15;
|
||||
const int MAX_ITEMS_TO_SHOW = 10;
|
||||
|
||||
string mMessage;
|
||||
string mTitle;
|
||||
int mNumberOfBranches;
|
||||
bool mConfirmDelete;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6780ea954e283bd4f82686f6e5ebafee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,164 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.CM.Common;
|
||||
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow.QueryViews.Branches;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.Progress;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Branches.Dialogs
|
||||
{
|
||||
internal class RenameBranchDialog : PlasticDialog
|
||||
{
|
||||
protected override Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var baseRect = base.DefaultRect;
|
||||
return new Rect(baseRect.x, baseRect.y, 500, 200);
|
||||
}
|
||||
}
|
||||
|
||||
internal static BranchRenameData GetBranchRenameData(
|
||||
RepositorySpec repSpec,
|
||||
BranchInfo branchInfo,
|
||||
EditorWindow parentWindow)
|
||||
{
|
||||
RenameBranchDialog dialog = Create(
|
||||
repSpec,
|
||||
branchInfo,
|
||||
new ProgressControlsForDialogs());
|
||||
|
||||
ResponseType dialogResult = dialog.RunModal(parentWindow);
|
||||
|
||||
BranchRenameData result = dialog.BuildRenameData();
|
||||
|
||||
result.Result = dialogResult == ResponseType.Ok;
|
||||
return result;
|
||||
}
|
||||
|
||||
static RenameBranchDialog Create(
|
||||
RepositorySpec repSpec,
|
||||
BranchInfo branchInfo,
|
||||
ProgressControlsForDialogs progressControls)
|
||||
{
|
||||
var instance = CreateInstance<RenameBranchDialog>();
|
||||
instance.mRepSpec = repSpec;
|
||||
instance.mBranchInfo = branchInfo;
|
||||
instance.mBranchName = BranchRenameUserInfo.GetShortBranchName(branchInfo.BranchName);
|
||||
instance.mTitle = PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.RenameBranchTitle);
|
||||
instance.mProgressControls = progressControls;
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected override string GetTitle()
|
||||
{
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
protected override void OnModalGUI()
|
||||
{
|
||||
Title(mTitle);
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
DoInputArea();
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
DrawProgressForDialogs.For(mProgressControls.ProgressData);
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
DoButtonsArea();
|
||||
}
|
||||
|
||||
void DoInputArea()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.NewName),
|
||||
GUILayout.ExpandWidth(false));
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
GUI.SetNextControlName(RENAME_BRANCH_TEXTAREA_NAME);
|
||||
|
||||
mBranchName = GUILayout.TextField(
|
||||
mBranchName,
|
||||
GUILayout.ExpandWidth(true));
|
||||
|
||||
if (!mTextAreaFocused)
|
||||
{
|
||||
EditorGUI.FocusTextInControl(RENAME_BRANCH_TEXTAREA_NAME);
|
||||
mTextAreaFocused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DoButtonsArea()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
DoOkButton();
|
||||
DoCancelButton();
|
||||
return;
|
||||
}
|
||||
|
||||
DoCancelButton();
|
||||
DoOkButton();
|
||||
}
|
||||
}
|
||||
|
||||
void DoOkButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.RenameButton)))
|
||||
return;
|
||||
|
||||
OkButtonWithValidationAction();
|
||||
}
|
||||
|
||||
void DoCancelButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.CancelButton)))
|
||||
return;
|
||||
|
||||
CancelButtonAction();
|
||||
}
|
||||
|
||||
void OkButtonWithValidationAction()
|
||||
{
|
||||
BranchRenameValidation.AsyncValidation(
|
||||
BuildRenameData(),
|
||||
this,
|
||||
mProgressControls);
|
||||
}
|
||||
|
||||
BranchRenameData BuildRenameData()
|
||||
{
|
||||
return new BranchRenameData(mRepSpec, mBranchInfo, mBranchName);
|
||||
}
|
||||
|
||||
string mTitle;
|
||||
string mBranchName;
|
||||
|
||||
bool mTextAreaFocused;
|
||||
|
||||
RepositorySpec mRepSpec;
|
||||
BranchInfo mBranchInfo;
|
||||
|
||||
ProgressControlsForDialogs mProgressControls;
|
||||
|
||||
const string RENAME_BRANCH_TEXTAREA_NAME = "rename_branch_textarea";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1de62e30afcba544e8e8da4b93a4fa39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user