Adaug proiectul Unity

This commit is contained in:
2026-11-01 23:39:55 +02:00
parent cb14d9d37d
commit 863eac8f2c
23463 changed files with 5412601 additions and 0 deletions
@@ -0,0 +1,226 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.QueryViews.Labels;
using Unity.PlasticSCM.Editor.UI.UIElements;
using Unity.PlasticSCM.Editor.Views.Changesets;
using ImguiProgressControls = Unity.PlasticSCM.Editor.UI.Progress.ProgressControlsForDialogs;
namespace Unity.PlasticSCM.Editor.Views.Labels.Dialogs
{
internal class CreateLabelDialog : EditorWindow
{
internal const string CHANGESET_SELECT_BUTTON = "create-label-changeset-select-button";
internal const string CHANGESET_BACK_BUTTON = "create-label-changeset-back-button";
internal static LabelCreationData CreateLabel(
EditorWindow parentWindow,
WorkspaceInfo wkInfo)
{
RepositorySpec repSpec = PlasticGui.Plastic.API.GetRepositorySpec(wkInfo);
long currentChangesetId =
PlasticGui.Plastic.API.GetCurrentChangesetOnWorkspace(wkInfo);
CreateLabelDialog dialog = CreateInstance<CreateLabelDialog>();
dialog.mWkInfo = wkInfo;
dialog.mRepSpec = repSpec;
dialog.mInitialChangesetId = currentChangesetId;
dialog.titleContent = new GUIContent(
PlasticLocalization.Name.CreateLabelTitle.GetString());
dialog.SetFixedSize(FORM_HEIGHT);
dialog.CenterOnMainWindow(FORM_HEIGHT);
dialog.ShowModalUtility();
return dialog.mResult ?? new LabelCreationData();
}
internal void OkButtonAction()
{
ChangesetInfo changesetInfo =
ChangesetsSelection.GetSelectedChangeset(mChangesetExplorerView.Table);
if (changesetInfo == null)
return;
mCreateLabelView.SetChangesetId(changesetInfo.ChangesetId);
ShowForm();
}
void CreateGUI()
{
VisualElement root = rootVisualElement;
root.style.paddingTop = MARGIN;
root.style.paddingBottom = MARGIN;
root.style.paddingLeft = MARGIN;
root.style.paddingRight = MARGIN;
mExplanationLabel = new Label(
PlasticLocalization.Name.CreateLabelExplanation.GetString());
mExplanationLabel.style.marginBottom = MARGIN;
mExplanationLabel.style.whiteSpace = WhiteSpace.Normal;
root.Add(mExplanationLabel);
mCreateLabelView = new CreateLabelViewUIToolkit(mRepSpec, mInitialChangesetId);
mCreateLabelView.Confirmed += OnFormConfirmed;
mCreateLabelView.Cancelled += OnFormCancelled;
mCreateLabelView.ChooseChangesetRequested += ShowChangesetExplorer;
root.Add(mCreateLabelView);
mExplorerProgressControls = new ImguiProgressControls();
mChangesetExplorerView = new ChangesetExplorerView(
this, mWkInfo, mExplorerProgressControls);
mExplorerContainer = BuildExplorerContainer();
mExplorerContainer.style.display = DisplayStyle.None;
root.Add(mExplorerContainer);
}
VisualElement BuildExplorerContainer()
{
VisualElement container = new VisualElement();
container.style.flexGrow = 1;
Label explanation = new Label(
PlasticLocalization.Name.SelectChangesetBelow.GetString());
explanation.style.marginBottom = MARGIN;
explanation.style.whiteSpace = WhiteSpace.Normal;
IMGUIContainer explorer = new IMGUIContainer(OnExplorerGUI);
explorer.style.flexGrow = 1;
VisualElement buttons = new VisualElement();
buttons.style.flexDirection = FlexDirection.Row;
buttons.style.justifyContent = Justify.FlexEnd;
buttons.style.marginTop = ROW_SPACING;
Button selectButton = ControlBuilder.Button.CreateButton(
PlasticLocalization.Name.OkButton.GetString(), OkButtonAction);
selectButton.name = CHANGESET_SELECT_BUTTON;
selectButton.style.minWidth = BUTTON_WIDTH;
Button backButton = ControlBuilder.Button.CreateButton(
PlasticLocalization.Name.BackButton.GetString(), ShowForm);
backButton.name = CHANGESET_BACK_BUTTON;
backButton.style.minWidth = BUTTON_WIDTH;
if (Application.platform == RuntimePlatform.WindowsEditor)
{
buttons.Add(selectButton);
buttons.Add(backButton);
}
else
{
buttons.Add(backButton);
buttons.Add(selectButton);
}
container.Add(explanation);
container.Add(explorer);
container.Add(buttons);
container.RegisterCallback<KeyDownEvent>(
OnExplorerKeyDown, TrickleDown.TrickleDown);
return container;
}
void OnExplorerKeyDown(KeyDownEvent e)
{
if (e.keyCode == KeyCode.Return ||
e.keyCode == KeyCode.KeypadEnter)
{
OkButtonAction();
e.StopPropagation();
return;
}
if (e.keyCode == KeyCode.Escape)
{
ShowForm();
e.StopPropagation();
}
}
void OnExplorerGUI()
{
mChangesetExplorerView.OnGUI();
mExplorerProgressControls.UpdateProgress(this);
}
void ShowChangesetExplorer()
{
mExplanationLabel.style.display = DisplayStyle.None;
mCreateLabelView.style.display = DisplayStyle.None;
mExplorerContainer.style.display = DisplayStyle.Flex;
SetFixedSize(EXPLORER_HEIGHT);
titleContent.text = PlasticLocalization.Name.AvailableChangesets.GetString();
}
void SetFixedSize(float height)
{
Vector2 size = new Vector2(DIALOG_WIDTH, height);
minSize = size;
maxSize = size;
}
void CenterOnMainWindow(float height)
{
Rect mainWindow = EditorGUIUtility.GetMainWindowPosition();
position = new Rect(
mainWindow.x + (mainWindow.width - DIALOG_WIDTH) / 2f,
mainWindow.y + (mainWindow.height - height) / 2f,
DIALOG_WIDTH,
height);
}
void ShowForm()
{
mExplorerContainer.style.display = DisplayStyle.None;
mExplanationLabel.style.display = DisplayStyle.Flex;
mCreateLabelView.style.display = DisplayStyle.Flex;
SetFixedSize(FORM_HEIGHT);
titleContent.text = PlasticLocalization.Name.CreateLabelTitle.GetString();
}
void OnFormConfirmed()
{
mResult = mCreateLabelView.BuildCreationData();
mResult.Result = true;
Close();
}
void OnFormCancelled()
{
Close();
}
CreateLabelViewUIToolkit mCreateLabelView;
ChangesetExplorerView mChangesetExplorerView;
ImguiProgressControls mExplorerProgressControls;
VisualElement mExplorerContainer;
Label mExplanationLabel;
LabelCreationData mResult;
WorkspaceInfo mWkInfo;
RepositorySpec mRepSpec;
long mInitialChangesetId;
const float DIALOG_WIDTH = 710f;
const float FORM_HEIGHT = 340f;
const float EXPLORER_HEIGHT = 480f;
const float MARGIN = 12f;
const float ROW_SPACING = 5f;
const float BUTTON_WIDTH = 80f;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4a34e3ce3dbf5594ba28a57fa297a72c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,260 @@
using System;
using UnityEngine;
using UnityEngine.UIElements;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.QueryViews.Labels;
using Unity.PlasticSCM.Editor.UI.UIElements;
namespace Unity.PlasticSCM.Editor.Views.Labels.Dialogs
{
internal class CreateLabelViewUIToolkit : VisualElement, IPlasticDialogCloser
{
internal const string NAME_FIELD = "create-label-name-field";
internal const string COMMENT_FIELD = "create-label-comment-field";
internal const string CHANGESET_ID_LABEL = "create-label-changeset-id-label";
internal const string CHOOSE_BUTTON = "create-label-choose-button";
internal const string LABEL_ALL_XLINKS_TOGGLE = "create-label-all-xlinks-toggle";
internal const string SWITCH_TO_LABEL_TOGGLE = "create-label-switch-to-label-toggle";
internal const string OK_BUTTON = "create-label-ok-button";
internal const string CANCEL_BUTTON = "create-label-cancel-button";
internal string LabelName { get { return mNameField.value; } }
internal string Comment { get { return mCommentField.value; } }
internal long ChangesetId { get { return mChangesetId; } }
internal bool LabelAllXlinks { get { return mLabelAllXlinksToggle.value; } }
internal bool SwitchToLabel { get { return mSwitchToLabelToggle.value; } }
internal bool WasConfirmed { get { return mbConfirmed; } }
internal CreateLabelViewUIToolkit(RepositorySpec repSpec, long changesetId)
{
mRepSpec = repSpec;
mChangesetId = changesetId;
BuildComponents();
RegisterCallback<KeyDownEvent>(OnKeyDown, TrickleDown.TrickleDown);
schedule.Execute(() =>
{
mNameField.Focus();
mNameField.SelectAll();
});
}
internal LabelCreationData BuildCreationData()
{
mResultData = new LabelCreationData(
mRepSpec,
mChangesetId,
mNameField.value,
mCommentField.value,
mSwitchToLabelToggle.value,
mLabelAllXlinksToggle.value,
(mResultData != null) ? mResultData.XlinksToLabel : null);
return mResultData;
}
internal void SetChangesetId(long changesetId)
{
mChangesetId = changesetId;
mChangesetIdLabel.text = changesetId.ToString();
}
void IPlasticDialogCloser.CloseDialog()
{
mbConfirmed = true;
Confirmed?.Invoke();
}
void BuildComponents()
{
mNameField = new TextField();
mNameField.name = NAME_FIELD;
mCommentField = new TextField();
mCommentField.name = COMMENT_FIELD;
mCommentField.multiline = true;
mCommentField.style.height = COMMENT_HEIGHT;
mChangesetIdLabel = new Label(mChangesetId.ToString());
mChangesetIdLabel.name = CHANGESET_ID_LABEL;
mChooseButton = ControlBuilder.Button.CreateButton(
PlasticLocalization.Name.ChooseMessage.GetString(), OnChooseClicked);
mChooseButton.name = CHOOSE_BUTTON;
mLabelAllXlinksToggle = new Toggle(
PlasticLocalization.Name.LabelAllXlinksCheckButton.GetString());
mLabelAllXlinksToggle.name = LABEL_ALL_XLINKS_TOGGLE;
mLabelAllXlinksToggle.style.marginLeft = 0;
mLabelAllXlinksToggle.focusable = false;
mSwitchToLabelToggle = new Toggle(
PlasticLocalization.Name.SwitchToLabelCheckButton.GetString());
mSwitchToLabelToggle.name = SWITCH_TO_LABEL_TOGGLE;
mSwitchToLabelToggle.style.marginLeft = 0;
mSwitchToLabelToggle.focusable = false;
mOkButton = ControlBuilder.Button.CreateButton(
PlasticLocalization.Name.CreateButton.GetString(), OnOkClicked);
mOkButton.name = OK_BUTTON;
mOkButton.style.minWidth = BUTTON_WIDTH;
mCancelButton = ControlBuilder.Button.CreateButton(
PlasticLocalization.Name.CancelButton.GetString(), OnCancelClicked);
mCancelButton.name = CANCEL_BUTTON;
mCancelButton.style.minWidth = BUTTON_WIDTH;
mProgressControls = new ProgressControlsForDialogs(
new VisualElement[] { mOkButton, mCancelButton, mChooseButton });
Add(BuildLabeledRow(
PlasticLocalization.Name.LabelNameEntry.GetString(), mNameField));
Add(BuildLabeledRow(
PlasticLocalization.Name.CommentsEntry.GetString(), mCommentField));
Add(BuildChangesetRow());
Add(mLabelAllXlinksToggle);
Add(mSwitchToLabelToggle);
Add(BuildButtonsArea());
Add(mProgressControls);
}
VisualElement BuildLabeledRow(string labelText, VisualElement field)
{
VisualElement row = new VisualElement();
row.style.flexDirection = FlexDirection.Row;
row.style.marginBottom = ROW_SPACING;
Label label = new Label(labelText);
label.style.width = LABEL_WIDTH;
label.style.flexShrink = 0;
field.style.flexGrow = 1;
row.Add(label);
row.Add(field);
return row;
}
VisualElement BuildChangesetRow()
{
VisualElement row = new VisualElement();
row.style.flexDirection = FlexDirection.Row;
row.style.alignItems = Align.Center;
row.style.marginBottom = ROW_SPACING;
Label label = new Label(
PlasticLocalization.Name.ChangesetToLabelEntry.GetString());
label.style.width = LABEL_WIDTH;
label.style.flexShrink = 0;
mChangesetIdLabel.style.flexGrow = 1;
row.Add(label);
row.Add(mChangesetIdLabel);
row.Add(mChooseButton);
return row;
}
VisualElement BuildButtonsArea()
{
VisualElement row = new VisualElement();
row.style.flexDirection = FlexDirection.Row;
row.style.justifyContent = Justify.FlexEnd;
row.style.marginTop = ROW_SPACING;
if (Application.platform == RuntimePlatform.WindowsEditor)
{
row.Add(mOkButton);
row.Add(mCancelButton);
}
else
{
row.Add(mCancelButton);
row.Add(mOkButton);
}
return row;
}
void OnKeyDown(KeyDownEvent e)
{
if (e.keyCode == KeyCode.Return ||
e.keyCode == KeyCode.KeypadEnter)
{
if (IsCommentFieldFocused())
return;
OnOkClicked();
e.StopPropagation();
return;
}
if (e.keyCode == KeyCode.Escape)
{
OnCancelClicked();
e.StopPropagation();
}
}
bool IsCommentFieldFocused()
{
if (mCommentField.panel == null)
return false;
VisualElement focused =
mCommentField.panel.focusController.focusedElement as VisualElement;
return focused != null &&
(focused == mCommentField || mCommentField.Contains(focused));
}
void OnOkClicked()
{
LabelCreationValidation.AsyncValidation(
BuildCreationData(), this, mProgressControls);
}
void OnCancelClicked()
{
Cancelled?.Invoke();
}
void OnChooseClicked()
{
ChooseChangesetRequested?.Invoke();
}
internal event Action Confirmed;
internal event Action Cancelled;
internal event Action ChooseChangesetRequested;
TextField mNameField;
TextField mCommentField;
Label mChangesetIdLabel;
Button mChooseButton;
Toggle mLabelAllXlinksToggle;
Toggle mSwitchToLabelToggle;
Button mOkButton;
Button mCancelButton;
ProgressControlsForDialogs mProgressControls;
LabelCreationData mResultData;
long mChangesetId;
bool mbConfirmed;
readonly RepositorySpec mRepSpec;
const float LABEL_WIDTH = 150f;
const float BUTTON_WIDTH = 80f;
const float COMMENT_HEIGHT = 100f;
const float ROW_SPACING = 5f;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d6860a2b66cf4b143a06d0bc3b87c0df
@@ -0,0 +1,40 @@
using UnityEditor;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.QueryViews.Labels;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.PlasticSCM.Editor.Views.Labels.Dialogs
{
internal class RenameLabelDialog
{
internal static LabelRenameData GetLabelRenameData(
RepositorySpec repSpec,
MarkerInfo labelInfo,
EditorWindow parentWindow)
{
InputTextDialogResult dialogResult = InputTextDialog.GetInputText(
PlasticLocalization.Name.RenameLabelTitle.GetString(),
null,
PlasticLocalization.GetString(PlasticLocalization.Name.NewName),
labelInfo.Name,
PlasticLocalization.GetString(PlasticLocalization.Name.RenameButton),
(text, closer, progressControls) =>
{
LabelRenameData data = new LabelRenameData(
repSpec, labelInfo, text);
LabelRenameValidation.AsyncValidation(data, closer, progressControls);
},
parentWindow,
width: 500);
LabelRenameData result = new LabelRenameData(
repSpec, labelInfo, dialogResult.Text);
result.Result = dialogResult.Result;
return result;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 31fe6c8e7de5e554b8d261d6870cde2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: