init project
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43aad6ec3599fb84a89e8fce31748cce
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI.Avatar
|
||||
{
|
||||
internal static class ApplyCircleMask
|
||||
{
|
||||
internal static Texture2D For(Texture2D sourceImage)
|
||||
{
|
||||
int centerx = sourceImage.width / 2;
|
||||
int centery = sourceImage.height / 2;
|
||||
|
||||
int radius = sourceImage.width / 2;
|
||||
|
||||
Texture2D result = Images.GetNewTextureFromTexture(sourceImage);
|
||||
|
||||
for (int i = (centerx - radius); i < centerx + radius; i++)
|
||||
{
|
||||
for (int j = (centery - radius); j < centery + radius; j++)
|
||||
{
|
||||
float dx = i - centerx;
|
||||
float dy = j - centery;
|
||||
|
||||
float d = Mathf.Sqrt(dx * dx + dy * dy);
|
||||
|
||||
float borderSize = 1f;
|
||||
|
||||
if (d <= (radius - borderSize))
|
||||
{
|
||||
result.SetPixel(
|
||||
i - (centerx - radius),
|
||||
j - (centery - radius),
|
||||
sourceImage.GetPixel(i, j));
|
||||
continue;
|
||||
}
|
||||
|
||||
Color color = sourceImage.GetPixel(i, j);
|
||||
|
||||
result.SetPixel(
|
||||
i - (centerx - radius),
|
||||
j - (centery - radius),
|
||||
Color.Lerp(Color.clear, color,
|
||||
GetAntialiasAlpha(radius, d, borderSize)));
|
||||
}
|
||||
}
|
||||
|
||||
result.Apply();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static float GetAntialiasAlpha(float radius, float d, float borderSize)
|
||||
{
|
||||
if (d >= (radius + borderSize))
|
||||
return 0f;
|
||||
|
||||
if (d - radius - borderSize == 0)
|
||||
return 0;
|
||||
|
||||
float proportion =
|
||||
Mathf.Abs(d - radius - borderSize) /
|
||||
(radius + borderSize) - (radius - borderSize);
|
||||
|
||||
return Mathf.Max(0, 1.0f - proportion);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e76ce7703143a924b9c0693ee66ebee7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI.Avatar
|
||||
{
|
||||
internal static class AvatarImages
|
||||
{
|
||||
internal static void Dispose()
|
||||
{
|
||||
foreach (Texture2D image in mAvatars.Values)
|
||||
UnityEngine.Object.DestroyImmediate(image, true);
|
||||
|
||||
mAvatars.Clear();
|
||||
}
|
||||
|
||||
internal static bool HasGravatar(string email)
|
||||
{
|
||||
return mAvatars.ContainsKey(email);
|
||||
}
|
||||
|
||||
internal static void AddGravatar(string email, Texture2D image)
|
||||
{
|
||||
if (mAvatars.ContainsKey(email))
|
||||
return;
|
||||
|
||||
mAvatars.Add(email, image);
|
||||
}
|
||||
|
||||
internal static void UpdateGravatar(string email, byte[] rawImage)
|
||||
{
|
||||
if (!mAvatars.ContainsKey(email))
|
||||
return;
|
||||
|
||||
Texture2D result = GetTexture(rawImage);
|
||||
|
||||
mAvatars[email] = result;
|
||||
}
|
||||
|
||||
internal static Texture2D GetAvatar(string email)
|
||||
{
|
||||
Texture2D image = GetGravatarImage(email);
|
||||
|
||||
if (image != null)
|
||||
return image;
|
||||
|
||||
return Images.GetEmptyGravatar();
|
||||
}
|
||||
|
||||
static Texture2D GetGravatarImage(string email)
|
||||
{
|
||||
Texture2D avatar;
|
||||
mAvatars.TryGetValue(email, out avatar);
|
||||
return avatar;
|
||||
}
|
||||
|
||||
static Texture2D GetTexture(byte[] rawImage)
|
||||
{
|
||||
Texture2D result = Images.GetNewTextureFromBytes(32, 32, rawImage);
|
||||
Texture2D maskImage = ApplyCircleMask.For(result);
|
||||
|
||||
UnityEngine.Object.DestroyImmediate(result, true);
|
||||
|
||||
return maskImage;
|
||||
}
|
||||
|
||||
static readonly Dictionary<string, Texture2D> mAvatars =
|
||||
new Dictionary<string, Texture2D>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43c380b3a07cbf449a54619bb50096b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using CodiceApp.Gravatar;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI.Avatar
|
||||
{
|
||||
internal static class GetAvatar
|
||||
{
|
||||
internal static Texture2D ForEmail(
|
||||
string email,
|
||||
Action avatarLoadedAction)
|
||||
{
|
||||
if (string.IsNullOrEmpty(email))
|
||||
return Images.GetEmptyGravatar();
|
||||
|
||||
if (AvatarImages.HasGravatar(email))
|
||||
return AvatarImages.GetAvatar(email);
|
||||
|
||||
Texture2D defaultImage =
|
||||
Images.GetEmptyGravatar();
|
||||
|
||||
AvatarImages.AddGravatar(email, defaultImage);
|
||||
|
||||
LoadAvatar.ForEmail(
|
||||
email, avatarLoadedAction,
|
||||
AfterDownloadSucceed);
|
||||
|
||||
return defaultImage;
|
||||
}
|
||||
|
||||
static void AfterDownloadSucceed(
|
||||
string email,
|
||||
GravatarImagesProvider.Result result,
|
||||
Action avatarLoadedAction)
|
||||
{
|
||||
if (result.ResultCode == GravatarImagesProvider.Result.OperationResult.OK)
|
||||
{
|
||||
AvatarImages.UpdateGravatar(email, result.RawGravatar);
|
||||
|
||||
avatarLoadedAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0afb4c6d979970647841ee14a55b8d25
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class CheckUnityException
|
||||
{
|
||||
internal static bool IsExitGUIException(Exception ex)
|
||||
{
|
||||
return ex is ExitGUIException;
|
||||
}
|
||||
|
||||
internal static bool IsIMGUIPaintException(Exception ex)
|
||||
{
|
||||
if (!(ex is ArgumentException))
|
||||
return false;
|
||||
|
||||
return ex.Message.StartsWith("Getting control") &&
|
||||
ex.Message.Contains("controls when doing repaint");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f79c84772bc81844fb9e662249f1e400
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using Unity.PlasticSCM.Editor.CloudDrive;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class CloseWindowIfOpened
|
||||
{
|
||||
internal static void UVCS()
|
||||
{
|
||||
if (!EditorWindow.HasOpenInstances<UVCSWindow>())
|
||||
return;
|
||||
|
||||
UVCSWindow window = EditorWindow.
|
||||
GetWindow<UVCSWindow>(null, false);
|
||||
|
||||
window.Close();
|
||||
}
|
||||
|
||||
internal static void CloudDrive()
|
||||
{
|
||||
if (!EditorWindow.HasOpenInstances<CloudDriveWindow>())
|
||||
return;
|
||||
|
||||
CloudDriveWindow window = EditorWindow.
|
||||
GetWindow<CloudDriveWindow>(null, false);
|
||||
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25e3b426e5be4f64db3f9184fd625379
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class DelayedActionByFramesRunner
|
||||
{
|
||||
internal static bool IsUnitTesting { get; set; }
|
||||
internal bool IsRunning { get { return mIsOnDelay; } }
|
||||
|
||||
internal DelayedActionByFramesRunner(Action action, int delayFrames)
|
||||
{
|
||||
mAction = action;
|
||||
mDelayFrames = delayFrames;
|
||||
}
|
||||
|
||||
internal void Run()
|
||||
{
|
||||
if (IsUnitTesting)
|
||||
{
|
||||
mAction();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsOnDelay)
|
||||
{
|
||||
RefreshDelay();
|
||||
return;
|
||||
}
|
||||
|
||||
StartDelay();
|
||||
}
|
||||
|
||||
void RefreshDelay()
|
||||
{
|
||||
mFramesOnDelay = mDelayFrames;
|
||||
}
|
||||
|
||||
void StartDelay()
|
||||
{
|
||||
mIsOnDelay = true;
|
||||
|
||||
EditorApplication.update += OnUpdate;
|
||||
|
||||
RefreshDelay();
|
||||
}
|
||||
|
||||
void EndDelay()
|
||||
{
|
||||
mIsOnDelay = false;
|
||||
|
||||
EditorApplication.update -= OnUpdate;
|
||||
|
||||
mAction();
|
||||
}
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
mFramesOnDelay--;
|
||||
|
||||
if (mFramesOnDelay <= 0)
|
||||
EndDelay();
|
||||
}
|
||||
|
||||
bool mIsOnDelay;
|
||||
int mFramesOnDelay;
|
||||
|
||||
readonly int mDelayFrames;
|
||||
readonly Action mAction;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0faad526f5548c1a53c288b045580b0
|
||||
timeCreated: 1744730269
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class DelayedActionBySecondsRunner
|
||||
{
|
||||
internal static bool IsUnitTesting { get; set; }
|
||||
internal bool IsRunning { get { return mIsOnDelay; } }
|
||||
|
||||
internal DelayedActionBySecondsRunner(Action action, double delaySeconds)
|
||||
{
|
||||
mAction = action;
|
||||
mDelaySeconds = delaySeconds;
|
||||
}
|
||||
|
||||
internal void Run()
|
||||
{
|
||||
if (IsUnitTesting)
|
||||
{
|
||||
mAction();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsOnDelay)
|
||||
{
|
||||
RefreshDelay();
|
||||
return;
|
||||
}
|
||||
|
||||
StartDelay();
|
||||
}
|
||||
|
||||
internal void Pause()
|
||||
{
|
||||
mIsPaused = true;
|
||||
}
|
||||
|
||||
internal void Resume()
|
||||
{
|
||||
if (!mIsPaused)
|
||||
return;
|
||||
|
||||
mIsPaused = false;
|
||||
mLastUpdateTime = EditorApplication.timeSinceStartup;
|
||||
}
|
||||
|
||||
void RefreshDelay()
|
||||
{
|
||||
mIsOnDelay = true;
|
||||
|
||||
mSecondsOnDelay = mDelaySeconds;
|
||||
}
|
||||
|
||||
void StartDelay()
|
||||
{
|
||||
mLastUpdateTime = EditorApplication.timeSinceStartup;
|
||||
|
||||
EditorApplication.update += OnUpdate;
|
||||
|
||||
RefreshDelay();
|
||||
}
|
||||
|
||||
void EndDelay()
|
||||
{
|
||||
EditorApplication.update -= OnUpdate;
|
||||
|
||||
mIsOnDelay = false;
|
||||
|
||||
mAction();
|
||||
}
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
if (mIsPaused)
|
||||
return;
|
||||
|
||||
double updateTime = EditorApplication.timeSinceStartup;
|
||||
double deltaSeconds = updateTime - mLastUpdateTime;
|
||||
|
||||
mSecondsOnDelay -= deltaSeconds;
|
||||
|
||||
if (mSecondsOnDelay < 0)
|
||||
EndDelay();
|
||||
|
||||
mLastUpdateTime = updateTime;
|
||||
}
|
||||
|
||||
bool mIsOnDelay;
|
||||
bool mIsPaused;
|
||||
double mLastUpdateTime;
|
||||
double mSecondsOnDelay;
|
||||
|
||||
readonly double mDelaySeconds;
|
||||
readonly Action mAction;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75e502da07ff345528edbecd094b5cb5
|
||||
timeCreated: 1541676676
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,127 @@
|
||||
#if UNITY_6000_3_OR_NEWER
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
using Codice.Client.Common;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class DialogWithCheckBox
|
||||
{
|
||||
internal static GuiMessage.GuiMessageResponseButton Show(
|
||||
string title,
|
||||
string message,
|
||||
string positiveButtonText,
|
||||
string neutralButtonText,
|
||||
string negativeButtonText,
|
||||
GuiMessage.GuiMessageType messageType,
|
||||
MultiLinkLabelData dontShowAgainContent,
|
||||
EditorWindow parentWindow,
|
||||
out bool checkBoxValue)
|
||||
{
|
||||
string optOutKey = Guid.NewGuid().ToString();
|
||||
string prefixedOptOutKey = OPT_OUT_PREFIX + optOutKey;
|
||||
|
||||
GuiMessage.GuiMessageResponseButton result;
|
||||
if (string.IsNullOrEmpty(negativeButtonText))
|
||||
{
|
||||
result = ShowTwoOptionsDialog(
|
||||
title,
|
||||
message,
|
||||
positiveButtonText,
|
||||
neutralButtonText,
|
||||
optOutKey,
|
||||
messageType);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = ShowThreeOptionsDialog(
|
||||
title,
|
||||
message,
|
||||
positiveButtonText,
|
||||
neutralButtonText,
|
||||
negativeButtonText,
|
||||
optOutKey,
|
||||
messageType);
|
||||
}
|
||||
|
||||
checkBoxValue = EditorPrefs.HasKey(prefixedOptOutKey);
|
||||
|
||||
EditorPrefs.DeleteKey(prefixedOptOutKey);
|
||||
SessionState.EraseInt(prefixedOptOutKey);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GuiMessage.GuiMessageResponseButton ShowTwoOptionsDialog(
|
||||
string title,
|
||||
string message,
|
||||
string positiveButtonText,
|
||||
string neutralButtonText,
|
||||
string optOutKey,
|
||||
GuiMessage.GuiMessageType messageType)
|
||||
{
|
||||
bool dialogResult = EditorDialog.DisplayDecisionDialogWithOptOut(
|
||||
title,
|
||||
message,
|
||||
positiveButtonText,
|
||||
neutralButtonText,
|
||||
DialogOptOutDecisionType.ForThisMachine,
|
||||
optOutKey,
|
||||
GetDialogIconType(messageType));
|
||||
|
||||
return dialogResult ?
|
||||
GuiMessage.GuiMessageResponseButton.Positive :
|
||||
GuiMessage.GuiMessageResponseButton.Neutral;
|
||||
}
|
||||
|
||||
static GuiMessage.GuiMessageResponseButton ShowThreeOptionsDialog(
|
||||
string title,
|
||||
string message,
|
||||
string positiveButtonText,
|
||||
string neutralButtonText,
|
||||
string negativeButtonText,
|
||||
string optOutKey,
|
||||
GuiMessage.GuiMessageType messageType)
|
||||
{
|
||||
DialogResult dialogResult = EditorDialog.DisplayComplexDecisionDialogWithOptOut(
|
||||
title,
|
||||
message,
|
||||
positiveButtonText,
|
||||
negativeButtonText,
|
||||
neutralButtonText,
|
||||
DialogOptOutDecisionType.ForThisMachine,
|
||||
optOutKey,
|
||||
GetDialogIconType(messageType));
|
||||
|
||||
if (dialogResult == DialogResult.Cancel)
|
||||
return GuiMessage.GuiMessageResponseButton.Neutral;
|
||||
|
||||
if (dialogResult == DialogResult.DefaultAction)
|
||||
return GuiMessage.GuiMessageResponseButton.Positive;
|
||||
|
||||
return GuiMessage.GuiMessageResponseButton.Negative;
|
||||
}
|
||||
|
||||
static DialogIconType GetDialogIconType(GuiMessage.GuiMessageType messageType)
|
||||
{
|
||||
switch (messageType)
|
||||
{
|
||||
case GuiMessage.GuiMessageType.Warning:
|
||||
return DialogIconType.Warning;
|
||||
|
||||
case GuiMessage.GuiMessageType.Critical:
|
||||
return DialogIconType.Error;
|
||||
|
||||
case GuiMessage.GuiMessageType.Informational:
|
||||
case GuiMessage.GuiMessageType.Question:
|
||||
default:
|
||||
return DialogIconType.Info;
|
||||
}
|
||||
}
|
||||
|
||||
const string OPT_OUT_PREFIX = "DialogOptOut."; // UnityEditor.EditorDialog.k_OptOutPrefix
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf4c80d864854f97a4b2f1dcad326904
|
||||
timeCreated: 1763722019
|
||||
@@ -0,0 +1,156 @@
|
||||
#if !UNITY_6000_3_OR_NEWER
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class DialogWithCheckBox : PlasticDialog
|
||||
{
|
||||
protected override Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var baseRect = base.DefaultRect;
|
||||
return new Rect(baseRect.x, baseRect.y, 535, baseRect.height);
|
||||
}
|
||||
}
|
||||
|
||||
internal static GuiMessage.GuiMessageResponseButton Show(
|
||||
string title,
|
||||
string message,
|
||||
string positiveButtonText,
|
||||
string neutralButtonText,
|
||||
string negativeButtonText,
|
||||
GuiMessage.GuiMessageType messageType,
|
||||
MultiLinkLabelData dontShowAgainContent,
|
||||
EditorWindow parentWindow,
|
||||
out bool checkBoxValue)
|
||||
{
|
||||
checkBoxValue = false;
|
||||
|
||||
DialogWithCheckBox dialog = Create(
|
||||
title,
|
||||
message,
|
||||
positiveButtonText,
|
||||
neutralButtonText,
|
||||
negativeButtonText,
|
||||
dontShowAgainContent);
|
||||
|
||||
ResponseType result = dialog.RunModal(parentWindow);
|
||||
|
||||
if (result == ResponseType.None)
|
||||
return GuiMessage.GuiMessageResponseButton.None;
|
||||
|
||||
checkBoxValue = dialog.mCheckBox;
|
||||
|
||||
if (result == ResponseType.Cancel)
|
||||
return GuiMessage.GuiMessageResponseButton.Neutral;
|
||||
|
||||
if (result == ResponseType.Ok)
|
||||
return GuiMessage.GuiMessageResponseButton.Positive;
|
||||
|
||||
return GuiMessage.GuiMessageResponseButton.Negative;
|
||||
}
|
||||
|
||||
protected override string GetTitle()
|
||||
{
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
protected override string GetExplanation()
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
protected override void DoCheckBoxArea_Legacy()
|
||||
{
|
||||
if (mDontShowAgainContent == null)
|
||||
return;
|
||||
|
||||
GUILayout.Space(22f);
|
||||
|
||||
Rect backgroundRect = new Rect(0, GUILayoutUtility.GetLastRect().yMax, position.width, 50);
|
||||
|
||||
EditorGUI.DrawRect(backgroundRect, UnityStyles.Colors.DarkGray);
|
||||
|
||||
GUILayout.Space(4f);
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
mCheckBox = EditorGUILayout.ToggleLeft(
|
||||
string.Empty,
|
||||
mCheckBox,
|
||||
EditorStyles.boldLabel);
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
|
||||
GUILayout.Space(-22);
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(22);
|
||||
DrawTextBlockWithLink.ForMultiLinkLabelInDialog(mDontShowAgainContent);
|
||||
}
|
||||
|
||||
GUILayout.Space(-19);
|
||||
}
|
||||
|
||||
protected override void DoButtonsArea()
|
||||
{
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
GUILayout.Space(25f);
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
DoButtonsWithPlatformOrdering(DoOkButton, DoNegativeButton, DoCancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DoNegativeButton()
|
||||
{
|
||||
if (string.IsNullOrEmpty(mNegativeButtonText))
|
||||
return;
|
||||
|
||||
if (!NormalButton(mNegativeButtonText))
|
||||
return;
|
||||
|
||||
ApplyButtonAction();
|
||||
}
|
||||
|
||||
static DialogWithCheckBox Create(
|
||||
string title,
|
||||
string message,
|
||||
string positiveButtonText,
|
||||
string neutralButtonText,
|
||||
string negativeButtonText,
|
||||
MultiLinkLabelData dontShowAgainContent)
|
||||
{
|
||||
DialogWithCheckBox instance = CreateInstance<DialogWithCheckBox>();
|
||||
instance.mEnterKeyAction = instance.OkButtonAction;
|
||||
instance.mEscapeKeyAction = instance.CancelButtonAction;
|
||||
|
||||
instance.mTitle = title;
|
||||
instance.mMessage = message;
|
||||
instance.mOkButtonText = positiveButtonText;
|
||||
instance.mCancelButtonText = neutralButtonText;
|
||||
instance.mNegativeButtonText = negativeButtonText;
|
||||
instance.mDontShowAgainContent = dontShowAgainContent;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
string mTitle;
|
||||
string mMessage;
|
||||
string mNegativeButtonText;
|
||||
MultiLinkLabelData mDontShowAgainContent;
|
||||
|
||||
bool mCheckBox;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e26dd2ea146011948b8e7518465ea71a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEditor;
|
||||
|
||||
#if !UNITY_6000_3_OR_NEWER
|
||||
using Unity.PlasticSCM.Editor.UnityInternals.UnityEditor;
|
||||
|
||||
using EditorWindow = UnityEditor.EditorWindow;
|
||||
using DockArea = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.DockArea;
|
||||
#endif
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DockEditorWindow
|
||||
{
|
||||
internal static void To(EditorWindow dockWindow, EditorWindow window)
|
||||
{
|
||||
#if !UNITY_6000_3_OR_NEWER
|
||||
DockArea dockArea = dockWindow.m_Parent() as DockArea;
|
||||
#else
|
||||
DockArea dockArea = dockWindow.m_Parent as DockArea;
|
||||
#endif
|
||||
|
||||
if (dockArea == null)
|
||||
return;
|
||||
|
||||
dockArea.AddTab(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a6fba741cdd5fb4982a73a4d791754f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DrawActionButton
|
||||
{
|
||||
internal static bool For(string buttonText)
|
||||
{
|
||||
GUIContent buttonContent = new GUIContent(buttonText);
|
||||
|
||||
return ForRegularButton(buttonContent);
|
||||
}
|
||||
|
||||
internal static bool ForCommentSection(
|
||||
string buttonText,
|
||||
float width,
|
||||
GUIStyle style)
|
||||
{
|
||||
GUIContent buttonContent = new GUIContent(buttonText);
|
||||
|
||||
Rect rt = GUILayoutUtility.GetRect(
|
||||
buttonContent,
|
||||
style,
|
||||
GUILayout.MinWidth(width),
|
||||
GUILayout.MaxWidth(width));
|
||||
|
||||
return GUI.Button(rt, buttonContent, style);
|
||||
}
|
||||
|
||||
static bool ForRegularButton(GUIContent buttonContent)
|
||||
{
|
||||
GUIStyle style = UnityStyles.PendingChangesTab.ActionButton;
|
||||
|
||||
Rect rt = GUILayoutUtility.GetRect(
|
||||
buttonContent,
|
||||
style,
|
||||
GUILayout.MinWidth(UnityConstants.REGULAR_BUTTON_WIDTH));
|
||||
|
||||
return GUI.Button(rt, buttonContent, style);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c08cfcfc4c2c46c46940ed103538acae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DrawActionButtonWithMenu
|
||||
{
|
||||
internal static void For(
|
||||
string text,
|
||||
string tooltip,
|
||||
Action buttonAction,
|
||||
GenericMenu actionMenu)
|
||||
{
|
||||
float width = MeasureMaxWidth.ForTexts(UnityStyles.PendingChangesTab.ActionButtonLeft, text);
|
||||
|
||||
For(
|
||||
text,
|
||||
tooltip,
|
||||
width,
|
||||
buttonAction,
|
||||
actionMenu,
|
||||
UnityStyles.PendingChangesTab.ActionButtonLeft,
|
||||
UnityStyles.PendingChangesTab.DropDownButton);
|
||||
}
|
||||
|
||||
internal static void ForTopbar(
|
||||
string text,
|
||||
string tooltip,
|
||||
Action buttonAction,
|
||||
GenericMenu actionMenu)
|
||||
{
|
||||
float width = MeasureMaxWidth.ForTexts(UnityStyles.Topbar.Button, text);
|
||||
|
||||
For(
|
||||
text,
|
||||
tooltip,
|
||||
width,
|
||||
buttonAction,
|
||||
actionMenu,
|
||||
UnityStyles.Topbar.ButtonLeft,
|
||||
UnityStyles.Topbar.ButtonRight);
|
||||
}
|
||||
|
||||
internal static void ForCommentsSection(
|
||||
string text,
|
||||
float totalWidth,
|
||||
Action buttonAction,
|
||||
GenericMenu actionMenu)
|
||||
{
|
||||
// Action button
|
||||
GUIContent buttonContent = new GUIContent(text);
|
||||
|
||||
Rect rt = GUILayoutUtility.GetRect(
|
||||
buttonContent,
|
||||
UnityStyles.PendingChangesTab.ActionButtonLeft,
|
||||
GUILayout.MinWidth(totalWidth - DROPDOWN_BUTTON_WIDTH),
|
||||
GUILayout.MaxWidth(totalWidth - DROPDOWN_BUTTON_WIDTH));
|
||||
|
||||
if (GUI.Button(rt, buttonContent, UnityStyles.PendingChangesTab.ActionButton))
|
||||
{
|
||||
buttonAction();
|
||||
}
|
||||
|
||||
// Menu dropdown
|
||||
GUIContent dropDownContent = new GUIContent(
|
||||
string.Empty, Images.GetDropDownIcon());
|
||||
|
||||
Rect dropDownRect = GUILayoutUtility.GetRect(
|
||||
dropDownContent,
|
||||
UnityStyles.PendingChangesTab.DropDownButton,
|
||||
GUILayout.MinWidth(DROPDOWN_BUTTON_WIDTH),
|
||||
GUILayout.MaxWidth(DROPDOWN_BUTTON_WIDTH));
|
||||
|
||||
if (EditorGUI.DropdownButton(
|
||||
dropDownRect,
|
||||
dropDownContent,
|
||||
FocusType.Passive,
|
||||
UnityStyles.PendingChangesTab.DropDownButton))
|
||||
{
|
||||
actionMenu.DropDown(dropDownRect);
|
||||
}
|
||||
}
|
||||
|
||||
static void For(
|
||||
string text,
|
||||
string tooltip,
|
||||
float width,
|
||||
Action buttonAction,
|
||||
GenericMenu actionMenu,
|
||||
GUIStyle buttonStyle,
|
||||
GUIStyle dropDownStyle)
|
||||
{
|
||||
// Action button
|
||||
GUIContent buttonContent = new GUIContent(text, tooltip);
|
||||
|
||||
Rect rt = GUILayoutUtility.GetRect(
|
||||
buttonContent,
|
||||
buttonStyle,
|
||||
GUILayout.MinWidth(width),
|
||||
GUILayout.MaxWidth(width));
|
||||
|
||||
if (GUI.Button(rt, buttonContent, buttonStyle))
|
||||
{
|
||||
buttonAction();
|
||||
}
|
||||
|
||||
// Menu dropdown
|
||||
GUIContent dropDownContent = new GUIContent(
|
||||
string.Empty, Images.GetDropDownIcon());
|
||||
|
||||
Rect dropDownRect = GUILayoutUtility.GetRect(
|
||||
dropDownContent,
|
||||
dropDownStyle,
|
||||
GUILayout.MinWidth(DROPDOWN_BUTTON_WIDTH),
|
||||
GUILayout.MaxWidth(DROPDOWN_BUTTON_WIDTH));
|
||||
|
||||
if (EditorGUI.DropdownButton(
|
||||
dropDownRect, dropDownContent, FocusType.Passive, dropDownStyle))
|
||||
{
|
||||
actionMenu.DropDown(dropDownRect);
|
||||
}
|
||||
}
|
||||
|
||||
const int DROPDOWN_BUTTON_WIDTH = 16;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 640fd06dff6f43498693eeda77683e6e
|
||||
timeCreated: 1715597188
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DrawActionHelpBox
|
||||
{
|
||||
internal static void For(
|
||||
Texture image,
|
||||
string labelText,
|
||||
string buttonText,
|
||||
Action buttonAction)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal(
|
||||
EditorStyles.helpBox, GUILayout.MinHeight(40));
|
||||
|
||||
DoNotificationLabel(image, labelText);
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
DoActionButton(buttonText, buttonAction);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
static void DoNotificationLabel(
|
||||
Texture image, string labelText)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.Label(
|
||||
new GUIContent(labelText, image),
|
||||
UnityStyles.HelpBoxLabel);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
static void DoActionButton(
|
||||
string buttonText, Action buttonAction)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUIContent buttonContent = new GUIContent(buttonText);
|
||||
|
||||
float width = GetButtonWidth(
|
||||
buttonContent, EditorStyles.miniButton);
|
||||
|
||||
if (GUILayout.Button(
|
||||
buttonContent, EditorStyles.miniButton,
|
||||
GUILayout.MinWidth(Math.Max(50, width))))
|
||||
{
|
||||
buttonAction();
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
static float GetButtonWidth(
|
||||
GUIContent buttonContent, GUIStyle buttonStyle)
|
||||
{
|
||||
return buttonStyle.CalcSize(buttonContent).x + 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30c4cfa3209d4a44480017a19ec5b3b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DrawActionToolbar
|
||||
{
|
||||
internal static void Begin()
|
||||
{
|
||||
Rect result = GUILayoutUtility.GetRect(0, 1, GUILayout.ExpandWidth(true));
|
||||
EditorGUI.DrawRect(result, UnityStyles.Colors.BarBorder);
|
||||
|
||||
EditorGUILayout.BeginVertical(UnityStyles.ActionToolbar);
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
}
|
||||
|
||||
internal static void End()
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c3253f17b35cd14ab618b470fb0e52a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DrawCopyableLabel
|
||||
{
|
||||
internal static void For(string label, GUIStyle style)
|
||||
{
|
||||
Rect rect = GUILayoutUtility.GetRect(
|
||||
new GUIContent(label), style);
|
||||
|
||||
GUI.Label(rect, label, style);
|
||||
|
||||
if (Event.current.type != EventType.ContextClick)
|
||||
return;
|
||||
|
||||
if (!rect.Contains(Event.current.mousePosition))
|
||||
return;
|
||||
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddItem(
|
||||
new GUIContent(PlasticLocalization.Name.Copy.GetString()),
|
||||
false,
|
||||
() => EditorGUIUtility.systemCopyBuffer = label);
|
||||
menu.ShowAsContext();
|
||||
|
||||
Event.current.Use();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eda42d85846dab04a81db79ea2ab5e12
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
#if UNITY_6000_2_OR_NEWER
|
||||
using TreeView = UnityEditor.IMGUI.Controls.TreeView<int>;
|
||||
#endif
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DrawSearchField
|
||||
{
|
||||
internal static void For(
|
||||
SearchField searchField,
|
||||
TreeView treeView,
|
||||
float width)
|
||||
{
|
||||
treeView.searchString = searchField.OnToolbarGUI(
|
||||
treeView.searchString, GUILayout.MaxWidth(width / 2f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5474cb78511de04459cac50d50b9d9e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DrawSplitter
|
||||
{
|
||||
internal static void ForHorizontalIndicator()
|
||||
{
|
||||
ForWidth(EditorGUIUtility.currentViewWidth);
|
||||
}
|
||||
|
||||
internal static void ForWidth(float width)
|
||||
{
|
||||
GUIStyle style = UnityStyles.SplitterIndicator;
|
||||
|
||||
Rect splitterRect = GUILayoutUtility.GetRect(
|
||||
width,
|
||||
UnityConstants.SPLITTER_INDICATOR_HEIGHT,
|
||||
style);
|
||||
|
||||
GUI.Label(splitterRect, string.Empty, style);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddfa6de84251ce4448a66bad9e7d326e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DrawStaticElement
|
||||
{
|
||||
internal static void Empty()
|
||||
{
|
||||
GUILayout.Label(GUIContent.none, UnityStyles.NoSizeStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70bf1fe1bcd44b64b43910da6487eab4
|
||||
timeCreated: 1736508572
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DrawTextBlockWithLink
|
||||
{
|
||||
internal static void ForExternalLink(
|
||||
ExternalLink externalLink,
|
||||
string explanation,
|
||||
GUIStyle textBlockStyle)
|
||||
{
|
||||
GUILayout.Label(explanation, textBlockStyle);
|
||||
|
||||
GUIStyle linkStyle = new GUIStyle(UnityStyles.LinkLabel);
|
||||
linkStyle.fontSize = textBlockStyle.fontSize;
|
||||
linkStyle.stretchWidth = false;
|
||||
|
||||
if (GUILayout.Button(externalLink.Label, linkStyle))
|
||||
Application.OpenURL(externalLink.Url);
|
||||
|
||||
EditorGUIUtility.AddCursorRect(
|
||||
GUILayoutUtility.GetLastRect(), MouseCursor.Link);
|
||||
}
|
||||
|
||||
internal static void ForMultiLinkLabelInDialog(
|
||||
MultiLinkLabelData data)
|
||||
{
|
||||
ForMultiLinkLabel(
|
||||
data,
|
||||
UnityStyles.Dialog.ParagraphForMultiLinkLabel,
|
||||
UnityStyles.Dialog.LinkForMultiLinkLabel,
|
||||
areLinkActionsSupported: Application.platform == RuntimePlatform.WindowsEditor,
|
||||
isEndFlexibleSpaceNeeded: true);
|
||||
}
|
||||
|
||||
internal static void ForMultiLinkLabel(
|
||||
MultiLinkLabelData data,
|
||||
GUIStyle labelStyle,
|
||||
GUIStyle linkStyle)
|
||||
{
|
||||
ForMultiLinkLabel(
|
||||
data, labelStyle, linkStyle,
|
||||
areLinkActionsSupported: true,
|
||||
isEndFlexibleSpaceNeeded: false);
|
||||
}
|
||||
|
||||
static void ForMultiLinkLabel(
|
||||
MultiLinkLabelData data,
|
||||
GUIStyle labelStyle,
|
||||
GUIStyle linkStyle,
|
||||
bool areLinkActionsSupported,
|
||||
bool isEndFlexibleSpaceNeeded)
|
||||
{
|
||||
if (!areLinkActionsSupported)
|
||||
{
|
||||
GUILayout.Label(
|
||||
string.Format(data.Text, data.LinkNames.ToArray()),
|
||||
labelStyle);
|
||||
return;
|
||||
}
|
||||
|
||||
string[] labels = Regex.Split(data.Text, @"\{\d+\}");
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
for (int i = 0; i < labels.Length; i++)
|
||||
{
|
||||
GUILayout.Label(labels[i], labelStyle);
|
||||
|
||||
if (data.LinkNames.Count <= i)
|
||||
break;
|
||||
|
||||
bool buttonResult = GUILayout.Button(data.LinkNames[i], linkStyle);
|
||||
|
||||
EditorGUIUtility.AddCursorRect(
|
||||
GUILayoutUtility.GetLastRect(), MouseCursor.Link);
|
||||
|
||||
if (buttonResult)
|
||||
{
|
||||
((Action)data.LinkActions[i])();
|
||||
GUIUtility.ExitGUI();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isEndFlexibleSpaceNeeded)
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54390afd4066b724d9a802ff75bed13b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
using Codice.Client.Common;
|
||||
|
||||
using Unity.PlasticSCM.Editor.UI.Avatar;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DrawUserIcon
|
||||
{
|
||||
internal static void ForPendingChangesTab(
|
||||
ResolvedUser currentUser,
|
||||
Action avatarLoadedAction)
|
||||
{
|
||||
Rect rect = GUILayoutUtility.GetRect(28f, 28f, GUILayout.ExpandWidth(false));
|
||||
|
||||
if (currentUser == null)
|
||||
{
|
||||
GUI.DrawTexture(rect, Images.GetEmptyGravatar());
|
||||
return;
|
||||
}
|
||||
|
||||
GUI.Label(rect, new GUIContent(
|
||||
GetAvatar.ForEmail(currentUser.Name, avatarLoadedAction),
|
||||
currentUser.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f222cc01be81b842b1333c92fb7355c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,78 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class DropDownTextField
|
||||
{
|
||||
internal static string DoDropDownTextField(
|
||||
string text,
|
||||
string controlName,
|
||||
List<string> dropDownOptions,
|
||||
GenericMenu.MenuFunction2 optionSelected,
|
||||
params GUILayoutOption[] options)
|
||||
{
|
||||
GUIContent textContent = new GUIContent(text);
|
||||
|
||||
Rect textFieldRect = GUILayoutUtility.GetRect(
|
||||
textContent,
|
||||
EditorStyles.textField,
|
||||
options);
|
||||
|
||||
return DoDropDownTextField(
|
||||
text,
|
||||
controlName,
|
||||
dropDownOptions,
|
||||
optionSelected,
|
||||
textFieldRect);
|
||||
}
|
||||
|
||||
internal static string DoDropDownTextField(
|
||||
string text,
|
||||
string controlName,
|
||||
List<string> dropDownOptions,
|
||||
GenericMenu.MenuFunction2 optionSelected,
|
||||
Rect textFieldRect)
|
||||
{
|
||||
Texture popupIcon = Images.GetDropDownIcon();
|
||||
|
||||
Rect popupButtonRect = new Rect(
|
||||
textFieldRect.x + textFieldRect.width - BUTTON_WIDTH,
|
||||
textFieldRect.y,
|
||||
BUTTON_WIDTH,
|
||||
textFieldRect.height);
|
||||
|
||||
if (GUI.Button(popupButtonRect, string.Empty, EditorStyles.label))
|
||||
{
|
||||
GenericMenu menu = new GenericMenu();
|
||||
foreach (string option in dropDownOptions)
|
||||
{
|
||||
menu.AddItem(
|
||||
new GUIContent(UnityMenuItem.EscapedText(option)),
|
||||
false,
|
||||
optionSelected,
|
||||
option);
|
||||
}
|
||||
|
||||
menu.DropDown(textFieldRect);
|
||||
}
|
||||
|
||||
Rect popupIconRect = new Rect(
|
||||
popupButtonRect.x,
|
||||
popupButtonRect.y + UnityConstants.DROPDOWN_ICON_Y_OFFSET,
|
||||
popupButtonRect.width,
|
||||
popupButtonRect.height);
|
||||
|
||||
GUI.SetNextControlName(controlName);
|
||||
string result = EditorGUI.TextField(textFieldRect, text);
|
||||
|
||||
GUI.Label(popupIconRect, popupIcon);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const int BUTTON_WIDTH = 16;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2e4782a922433041be291edaf12421a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
using Codice.LogWrapper;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class EditorDispatcher
|
||||
{
|
||||
internal static bool IsOnMainThread
|
||||
{
|
||||
get { return Thread.CurrentThread.ManagedThreadId == mMainThreadId; }
|
||||
}
|
||||
|
||||
internal static void InitializeMainThreadIdAndContext(
|
||||
int mainThreadId,
|
||||
SynchronizationContext mainUnitySyncContext)
|
||||
{
|
||||
mMainThreadId = mainThreadId;
|
||||
mMainUnitySyncContext = mainUnitySyncContext;
|
||||
}
|
||||
|
||||
internal static void Shutdown()
|
||||
{
|
||||
lock (mLock)
|
||||
{
|
||||
mMainUnitySyncContext = null;
|
||||
mDispatchQueue.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
internal static void Dispatch(Action task)
|
||||
{
|
||||
bool shouldPost = false;
|
||||
SynchronizationContext syncContext = null;
|
||||
|
||||
lock (mLock)
|
||||
{
|
||||
syncContext = mMainUnitySyncContext;
|
||||
if (syncContext == null)
|
||||
return;
|
||||
|
||||
mDispatchQueue.Enqueue(task);
|
||||
|
||||
if (mDispatchQueue.Count == 1)
|
||||
shouldPost = true;
|
||||
}
|
||||
|
||||
if (shouldPost)
|
||||
syncContext.Post(_ => Update(), null);
|
||||
}
|
||||
|
||||
internal static void Update()
|
||||
{
|
||||
if (!IsOnMainThread)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"EditorDispatcher.Update() must be called on the main thread");
|
||||
}
|
||||
|
||||
Action[] actions;
|
||||
|
||||
lock (mLock)
|
||||
{
|
||||
if (mDispatchQueue.Count == 0)
|
||||
return;
|
||||
|
||||
actions = mDispatchQueue.ToArray();
|
||||
mDispatchQueue.Clear();
|
||||
}
|
||||
|
||||
foreach (Action action in actions)
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mLog.ErrorFormat("Error dispatching action: {0}", ex.Message);
|
||||
mLog.DebugFormat("Stack trace: {0}", ex.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static readonly ILog mLog = PlasticApp.GetLogger("EditorDispatcher");
|
||||
static readonly object mLock = new object();
|
||||
static SynchronizationContext mMainUnitySyncContext;
|
||||
static readonly Queue<Action> mDispatchQueue = new Queue<Action>();
|
||||
static int mMainThreadId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de4aea75bc204d14cb432cf1708548f1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class EditorProgressBar
|
||||
{
|
||||
static EditorProgressBar()
|
||||
{
|
||||
var type = typeof(UnityEditor.Editor).Assembly.GetTypes().Where(
|
||||
t => t.Name == "AsyncProgressBar").FirstOrDefault();
|
||||
|
||||
if (type == null)
|
||||
return;
|
||||
|
||||
mDisplayMethod = type.GetMethod("Display");
|
||||
mClearMethod = type.GetMethod("Clear");
|
||||
}
|
||||
|
||||
internal static void ShowProgressBar(string text, float progress)
|
||||
{
|
||||
if (mDisplayMethod == null)
|
||||
return;
|
||||
|
||||
mDisplayMethod.Invoke(null, new object[] { text, progress });
|
||||
}
|
||||
|
||||
internal static void ClearProgressBar()
|
||||
{
|
||||
if (mClearMethod == null)
|
||||
return;
|
||||
|
||||
mClearMethod.Invoke(null, null);
|
||||
}
|
||||
|
||||
static MethodInfo mDisplayMethod = null;
|
||||
static MethodInfo mClearMethod = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 245d2c4b912b39a4784287979ea8cfd9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using Codice.Client.Common;
|
||||
using PlasticGui;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class EditorProgressControls : IProgressControls
|
||||
{
|
||||
internal EditorProgressControls(
|
||||
GuiMessage.IGuiMessage guiMessage,
|
||||
string title)
|
||||
{
|
||||
mGuiMessage = guiMessage;
|
||||
mTitle = title;
|
||||
}
|
||||
|
||||
void IProgressControls.HideProgress()
|
||||
{
|
||||
EditorProgressBar.ClearProgressBar();
|
||||
}
|
||||
|
||||
void IProgressControls.ShowError(string message)
|
||||
{
|
||||
mGuiMessage.ShowError(message);
|
||||
}
|
||||
|
||||
void IProgressControls.ShowNotification(string message)
|
||||
{
|
||||
mGuiMessage.ShowMessage(
|
||||
mTitle, message, GuiMessage.GuiMessageType.Informational);
|
||||
}
|
||||
|
||||
void IProgressControls.ShowProgress(string message)
|
||||
{
|
||||
EditorProgressBar.ShowProgressBar(message, 1f);
|
||||
}
|
||||
|
||||
void IProgressControls.ShowSuccess(string message)
|
||||
{
|
||||
mGuiMessage.ShowMessage(
|
||||
mTitle, message, GuiMessage.GuiMessageType.Informational);
|
||||
}
|
||||
|
||||
void IProgressControls.ShowWarning(string message)
|
||||
{
|
||||
mGuiMessage.ShowMessage(
|
||||
mTitle, message, GuiMessage.GuiMessageType.Warning);
|
||||
}
|
||||
|
||||
readonly string mTitle;
|
||||
readonly GuiMessage.IGuiMessage mGuiMessage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e436e24eba68eff48b3fb264ad0ab953
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class EditorVersion
|
||||
{
|
||||
internal int Year;
|
||||
internal int Release;
|
||||
internal int Update;
|
||||
|
||||
EditorVersion(int year, int release, int update)
|
||||
{
|
||||
Year = year;
|
||||
Release = release;
|
||||
Update = update;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{0}.{1}.{2}", Year, Release, Update);
|
||||
}
|
||||
|
||||
internal static bool IsCurrentEditorOlderThan(string version)
|
||||
{
|
||||
return IsEditorOlderThan(Application.unityVersion, version);
|
||||
}
|
||||
|
||||
internal static bool IsEditorOlderThan(string versionA, string versionB)
|
||||
{
|
||||
var editorA = Parse(versionA);
|
||||
var editorB = Parse(versionB);
|
||||
if (editorA.Year == editorB.Year)
|
||||
{
|
||||
if (editorA.Release == editorB.Release)
|
||||
{
|
||||
return editorA.Update < editorB.Update;
|
||||
}
|
||||
return editorA.Release < editorB.Release;
|
||||
}
|
||||
return editorA.Year < editorB.Year;
|
||||
}
|
||||
|
||||
static int ParseUpdateString(string version)
|
||||
{
|
||||
int pos = 0;
|
||||
char[] characters = version.ToCharArray();
|
||||
while (Char.IsDigit(characters[pos]))
|
||||
{
|
||||
++pos;
|
||||
}
|
||||
return int.Parse(version.Substring(0, pos));
|
||||
}
|
||||
|
||||
static EditorVersion Parse(string version)
|
||||
{
|
||||
var versions = version.Split('.');
|
||||
|
||||
var year = 0;
|
||||
year = int.Parse(versions[0]);
|
||||
var release = 0;
|
||||
release = int.Parse(versions[1]);
|
||||
var update = 0;
|
||||
update = ParseUpdateString(versions[2]);
|
||||
|
||||
return new EditorVersion(year, release, update);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e1e2d80d9c79b042ab42fdf0b5c0b65
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class EditorWindowFocus
|
||||
{
|
||||
internal static event Action OnApplicationActivated;
|
||||
internal static event Action OnApplicationDeactivated;
|
||||
|
||||
static EditorWindowFocus()
|
||||
{
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
|
||||
static void Update()
|
||||
{
|
||||
bool isApplicationActive = InternalEditorUtility.isApplicationActive;
|
||||
|
||||
if (!mLastIsApplicationFocused && isApplicationActive)
|
||||
{
|
||||
mLastIsApplicationFocused = isApplicationActive;
|
||||
|
||||
if (OnApplicationActivated != null)
|
||||
OnApplicationActivated();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (mLastIsApplicationFocused && !isApplicationActive)
|
||||
{
|
||||
mLastIsApplicationFocused = isApplicationActive;
|
||||
|
||||
if (OnApplicationDeactivated != null)
|
||||
OnApplicationDeactivated();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static bool mLastIsApplicationFocused;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84ce5571ebc476e45b6c9bc6644599c2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,132 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class EntryBuilder
|
||||
{
|
||||
internal static string CreateTextEntry(
|
||||
string label,
|
||||
string value,
|
||||
float width,
|
||||
float x)
|
||||
{
|
||||
return CreateTextEntry(
|
||||
label,
|
||||
value,
|
||||
null,
|
||||
width,
|
||||
x);
|
||||
}
|
||||
|
||||
internal static string CreateTextEntry(
|
||||
string label,
|
||||
string value,
|
||||
string controlName,
|
||||
float width,
|
||||
float x)
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
CreateLabel(label);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
var rt = GUILayoutUtility.GetRect(
|
||||
new GUIContent(value), UnityStyles.Dialog.EntryLabel);
|
||||
rt.width = width;
|
||||
rt.x = x;
|
||||
|
||||
if (!string.IsNullOrEmpty(controlName))
|
||||
GUI.SetNextControlName(controlName);
|
||||
|
||||
return GUI.TextField(rt, value);
|
||||
}
|
||||
}
|
||||
|
||||
internal static string CreatePasswordEntry(
|
||||
string label,
|
||||
string value,
|
||||
float width,
|
||||
float x)
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
CreateLabel(label);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
var rt = GUILayoutUtility.GetRect(
|
||||
new GUIContent(value), UnityStyles.Dialog.EntryLabel);
|
||||
rt.width = width;
|
||||
rt.x = x;
|
||||
|
||||
return GUI.PasswordField(rt, value, '*');
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool CreateToggleEntry(
|
||||
string label,
|
||||
bool value,
|
||||
float width,
|
||||
float x)
|
||||
{
|
||||
var rt = GUILayoutUtility.GetRect(
|
||||
new GUIContent(label), UnityStyles.Dialog.EntryLabel);
|
||||
rt.width = width;
|
||||
rt.x = x;
|
||||
|
||||
return GUI.Toggle(rt, value, label);
|
||||
}
|
||||
|
||||
internal static bool CreateToggleEntry(
|
||||
string label,
|
||||
bool value)
|
||||
{
|
||||
var rt = GUILayoutUtility.GetRect(
|
||||
new GUIContent(label), UnityStyles.Dialog.EntryLabel);
|
||||
|
||||
return GUI.Toggle(rt, value, label);
|
||||
}
|
||||
|
||||
internal static string CreateComboBoxEntry(
|
||||
string label,
|
||||
string value,
|
||||
List<string> dropDownOptions,
|
||||
GenericMenu.MenuFunction2 optionSelected,
|
||||
float width,
|
||||
float x)
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
CreateLabel(label);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
var rt = GUILayoutUtility.GetRect(
|
||||
new GUIContent(value), UnityStyles.Dialog.EntryLabel);
|
||||
rt.width = width;
|
||||
rt.x = x;
|
||||
|
||||
return DropDownTextField.DoDropDownTextField(
|
||||
value,
|
||||
label,
|
||||
dropDownOptions,
|
||||
optionSelected,
|
||||
rt);
|
||||
}
|
||||
}
|
||||
|
||||
static void CreateLabel(string labelText)
|
||||
{
|
||||
GUIContent labelContent = new GUIContent(labelText);
|
||||
GUIStyle labelStyle = UnityStyles.Dialog.EntryLabel;
|
||||
|
||||
Rect rt = GUILayoutUtility.GetRect(labelContent, labelStyle);
|
||||
|
||||
GUI.Label(rt, labelText, EditorStyles.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97b51e80cfabfe341958267f3d6c2ed6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class EnumPopupSetting<E>
|
||||
{
|
||||
internal static E Load(
|
||||
string popupSettingName,
|
||||
E defaultValue)
|
||||
{
|
||||
string enumValue = EditorPrefs.GetString(
|
||||
GetSettingKey(popupSettingName));
|
||||
|
||||
if (string.IsNullOrEmpty(enumValue))
|
||||
return defaultValue;
|
||||
|
||||
return (E)Enum.Parse(typeof(E), enumValue);
|
||||
}
|
||||
|
||||
internal static void Save(
|
||||
E selected,
|
||||
string popupSettingName)
|
||||
{
|
||||
EditorPrefs.SetString(
|
||||
GetSettingKey(popupSettingName),
|
||||
selected.ToString());
|
||||
}
|
||||
|
||||
internal static void Clear(
|
||||
string popupSettingName)
|
||||
{
|
||||
EditorPrefs.DeleteKey(
|
||||
GetSettingKey(popupSettingName));
|
||||
}
|
||||
|
||||
static string GetSettingKey(string popupSettingName)
|
||||
{
|
||||
return string.Format(
|
||||
popupSettingName, PlayerSettings.productGUID,
|
||||
SELECTED_ENUM_VALUE_KEY);
|
||||
}
|
||||
|
||||
static string SELECTED_ENUM_VALUE_KEY = "SelectedEnumValue";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de396a7891b8b7f4f9649c3ccee67421
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4edf5537f8245134c8b023ab85d8e640
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
using Codice.CM.Common;
|
||||
#if UNITY_6000_2_OR_NEWER
|
||||
using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem<int>;
|
||||
#endif
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI.Errors
|
||||
{
|
||||
internal class ErrorListViewItem : TreeViewItem
|
||||
{
|
||||
internal ErrorMessage ErrorMessage { get; private set; }
|
||||
|
||||
internal ErrorListViewItem(int id, ErrorMessage errorMessage)
|
||||
: base(id, 0)
|
||||
{
|
||||
ErrorMessage = errorMessage;
|
||||
|
||||
displayName = errorMessage.Path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71c34e5fa319ca644b6806e573c33d88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,80 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI.Errors
|
||||
{
|
||||
internal class ErrorsDialog : PlasticDialog
|
||||
{
|
||||
protected override Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var baseRect = base.DefaultRect;
|
||||
return new Rect(baseRect.x, baseRect.y, 810, 385);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ShowDialog(
|
||||
string title,
|
||||
string explanation,
|
||||
List<ErrorMessage> errors,
|
||||
EditorWindow parentWindow)
|
||||
{
|
||||
ErrorsDialog dialog = Create(title, explanation, errors);
|
||||
dialog.RunModal(parentWindow);
|
||||
}
|
||||
|
||||
protected override void DoComponentsArea()
|
||||
{
|
||||
mErrorsPanel.OnGUI();
|
||||
}
|
||||
|
||||
protected override string GetTitle()
|
||||
{
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
protected override string GetExplanation()
|
||||
{
|
||||
return mExplanation;
|
||||
}
|
||||
|
||||
static ErrorsDialog Create(
|
||||
string title,
|
||||
string explanation,
|
||||
List<ErrorMessage> errors)
|
||||
{
|
||||
var instance = CreateInstance<ErrorsDialog>();
|
||||
instance.mEscapeKeyAction = instance.CloseButtonAction;
|
||||
instance.mOkButtonText = string.Empty;
|
||||
instance.mCancelButtonText = string.Empty;
|
||||
instance.mCloseButtonText = PlasticLocalization.Name.CloseButton.GetString();
|
||||
instance.mTitle = title;
|
||||
instance.mExplanation = explanation;
|
||||
instance.BuildComponents();
|
||||
instance.SetErrorsList(errors);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void SetErrorsList(List<ErrorMessage> errors)
|
||||
{
|
||||
mErrorsPanel.UpdateErrorsList(errors);
|
||||
}
|
||||
|
||||
void BuildComponents()
|
||||
{
|
||||
mErrorsPanel = new ErrorsPanel(
|
||||
string.Empty,
|
||||
UnityConstants.CloudDrive.ERRORS_DIALOG_SETTINGS_NAME);
|
||||
}
|
||||
|
||||
ErrorsPanel mErrorsPanel;
|
||||
string mTitle;
|
||||
string mExplanation;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e27c01b3192a4dcfbd46563a4acacd59
|
||||
timeCreated: 1750232788
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI.Errors
|
||||
{
|
||||
internal enum ErrorsListColumn
|
||||
{
|
||||
Path,
|
||||
Reason
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal class ErrorsListHeaderState : MultiColumnHeaderState, ISerializationCallbackReceiver
|
||||
{
|
||||
internal static ErrorsListHeaderState GetDefault()
|
||||
{
|
||||
return new ErrorsListHeaderState(BuildColumns());
|
||||
}
|
||||
|
||||
static string GetColumnName(ErrorsListColumn column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case ErrorsListColumn.Path:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.PathColumn);
|
||||
case ErrorsListColumn.Reason:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.Reason);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
if (mHeaderTitles != null)
|
||||
TreeHeaderColumns.SetTitles(columns, mHeaderTitles);
|
||||
|
||||
if (mColumnsAllowedToggleVisibility != null)
|
||||
TreeHeaderColumns.SetVisibilities(columns, mColumnsAllowedToggleVisibility);
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
static Column[] BuildColumns()
|
||||
{
|
||||
return new Column[]
|
||||
{
|
||||
new Column()
|
||||
{
|
||||
width = 300,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ErrorsListColumn.Path)),
|
||||
minWidth = 200,
|
||||
allowToggleVisibility = false,
|
||||
canSort = false,
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = 600,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ErrorsListColumn.Reason)),
|
||||
minWidth = 200,
|
||||
canSort = false,
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ErrorsListHeaderState(Column[] columns)
|
||||
: base(columns)
|
||||
{
|
||||
if (mHeaderTitles == null)
|
||||
mHeaderTitles = TreeHeaderColumns.GetTitles(columns);
|
||||
|
||||
if (mColumnsAllowedToggleVisibility == null)
|
||||
mColumnsAllowedToggleVisibility = TreeHeaderColumns.GetVisibilities(columns);
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
string[] mHeaderTitles;
|
||||
|
||||
[SerializeField]
|
||||
bool[] mColumnsAllowedToggleVisibility;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c069d7fb0d30cf499458f0d9c9fe035
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,151 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
#if UNITY_6000_2_OR_NEWER
|
||||
using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem<int>;
|
||||
#endif
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI.Errors
|
||||
{
|
||||
internal class ErrorsListView : PlasticTreeView
|
||||
{
|
||||
internal ErrorsListView(ErrorsListHeaderState headerState)
|
||||
{
|
||||
multiColumnHeader = new MultiColumnHeader(headerState);
|
||||
multiColumnHeader.canSort = false;
|
||||
|
||||
showAlternatingRowBackgrounds = true;
|
||||
}
|
||||
|
||||
protected override IList<TreeViewItem> BuildRows(TreeViewItem rootItem)
|
||||
{
|
||||
RegenerateRows(
|
||||
this, mErrorMessages, rootItem, mRows);
|
||||
|
||||
return mRows;
|
||||
}
|
||||
|
||||
protected override void RowGUI(RowGUIArgs args)
|
||||
{
|
||||
if (args.item is ErrorListViewItem)
|
||||
{
|
||||
ErrorListViewItemGUI((ErrorListViewItem)args.item, args);
|
||||
return;
|
||||
}
|
||||
|
||||
base.RowGUI(args);
|
||||
}
|
||||
|
||||
internal void BuildModel(List<ErrorMessage> errorMessages)
|
||||
{
|
||||
mErrorMessages = errorMessages;
|
||||
}
|
||||
|
||||
internal ErrorMessage GetSelectedError()
|
||||
{
|
||||
List<ErrorMessage> selectedErrors = GetSelectedErrors(this);
|
||||
|
||||
if (selectedErrors.Count != 1)
|
||||
return null;
|
||||
|
||||
return selectedErrors[0];
|
||||
}
|
||||
|
||||
static List<ErrorMessage> GetSelectedErrors(
|
||||
ErrorsListView listView)
|
||||
{
|
||||
List<ErrorMessage> result = new List<ErrorMessage>();
|
||||
|
||||
IList<int> selectedIds = listView.GetSelection();
|
||||
|
||||
if (selectedIds.Count == 0)
|
||||
return result;
|
||||
|
||||
foreach (ErrorListViewItem treeViewItem in
|
||||
listView.FindRows(selectedIds))
|
||||
{
|
||||
result.Add(treeViewItem.ErrorMessage);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void RegenerateRows(
|
||||
ErrorsListView listView,
|
||||
List<ErrorMessage> errorMessages,
|
||||
TreeViewItem rootItem,
|
||||
List<TreeViewItem> rows)
|
||||
{
|
||||
ClearRows(rootItem, rows);
|
||||
|
||||
if (errorMessages.Count == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < errorMessages.Count; i++)
|
||||
{
|
||||
ErrorListViewItem errorListViewItem =
|
||||
new ErrorListViewItem(i + 1, errorMessages[i]);
|
||||
|
||||
rootItem.AddChild(errorListViewItem);
|
||||
rows.Add(errorListViewItem);
|
||||
}
|
||||
|
||||
listView.SetSelection(new List<int> { 1 });
|
||||
}
|
||||
|
||||
static void ClearRows(
|
||||
TreeViewItem rootItem,
|
||||
List<TreeViewItem> rows)
|
||||
{
|
||||
if (rootItem.hasChildren)
|
||||
rootItem.children.Clear();
|
||||
|
||||
rows.Clear();
|
||||
}
|
||||
|
||||
static void ErrorListViewItemGUI(
|
||||
ErrorListViewItem item,
|
||||
RowGUIArgs args)
|
||||
{
|
||||
for (int visibleColumnIdx = 0; visibleColumnIdx < args.GetNumVisibleColumns(); visibleColumnIdx++)
|
||||
{
|
||||
Rect cellRect = args.GetCellRect(visibleColumnIdx);
|
||||
|
||||
ErrorsListColumn column =
|
||||
(ErrorsListColumn)args.GetColumn(visibleColumnIdx);
|
||||
|
||||
ErrorListViewItemCellGUI(
|
||||
cellRect, item, column, args.selected, args.focused);
|
||||
}
|
||||
}
|
||||
|
||||
static void ErrorListViewItemCellGUI(
|
||||
Rect rect,
|
||||
ErrorListViewItem item,
|
||||
ErrorsListColumn column,
|
||||
bool isSelected,
|
||||
bool isFocused)
|
||||
{
|
||||
ErrorMessage errorMessage = item.ErrorMessage;
|
||||
|
||||
string label = column == ErrorsListColumn.Path ?
|
||||
errorMessage.Path : errorMessage.Error;
|
||||
|
||||
if (column == ErrorsListColumn.Path)
|
||||
{
|
||||
DrawTreeViewItem.ForLabel(
|
||||
rect, label, isSelected, isFocused, false);
|
||||
return;
|
||||
}
|
||||
|
||||
DrawTreeViewItem.ForSecondaryLabel(
|
||||
rect, label, isSelected, isFocused, false);
|
||||
}
|
||||
|
||||
List<ErrorMessage> mErrorMessages = new List<ErrorMessage>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 331d1c37d891f334390adb8324042856
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,126 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
using EditorGUILayout = UnityEditor.EditorGUILayout;
|
||||
using EditorStyles = UnityEditor.EditorStyles;
|
||||
|
||||
#if !UNITY_6000_3_OR_NEWER
|
||||
using Unity.PlasticSCM.Editor.UnityInternals.UnityEditor;
|
||||
#else
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI.Errors
|
||||
{
|
||||
internal class ErrorsPanel
|
||||
{
|
||||
internal bool IsVisible { get; private set; }
|
||||
|
||||
internal ErrorsPanel(
|
||||
string title,
|
||||
string treeSettingsName)
|
||||
{
|
||||
mTitle = title;
|
||||
|
||||
ErrorsListHeaderState errorsListHeaderState =
|
||||
ErrorsListHeaderState.GetDefault();
|
||||
TreeHeaderSettings.Load(
|
||||
errorsListHeaderState,
|
||||
treeSettingsName,
|
||||
UnityConstants.UNSORT_COLUMN_ID);
|
||||
|
||||
mErrorsListView = new ErrorsListView(errorsListHeaderState);
|
||||
mErrorsListView.Reload();
|
||||
|
||||
mErrorDetailsSplitterState = PlasticSplitterGUILayout.InitSplitterState(
|
||||
new float[] { 0.60f, 0.40f },
|
||||
new int[] { 100, 100 },
|
||||
new int[] { 100000, 100000 }
|
||||
);
|
||||
}
|
||||
|
||||
internal void UpdateErrorsList(List<ErrorMessage> errorMessages)
|
||||
{
|
||||
mErrorsListView.BuildModel(errorMessages);
|
||||
mErrorsListView.Reload();
|
||||
|
||||
IsVisible = errorMessages.Count > 0;
|
||||
}
|
||||
|
||||
internal void OnDisable()
|
||||
{
|
||||
TreeHeaderSettings.Save(
|
||||
mErrorsListView.multiColumnHeader.state,
|
||||
UnityConstants.GLUON_INCOMING_ERRORS_TABLE_SETTINGS_NAME);
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
if (!string.IsNullOrEmpty(mTitle))
|
||||
{
|
||||
DrawSplitter.ForHorizontalIndicator();
|
||||
|
||||
GUILayout.Label(
|
||||
mTitle,
|
||||
EditorStyles.boldLabel);
|
||||
}
|
||||
|
||||
DoErrorsListSplitViewArea(
|
||||
mErrorsListView, mErrorDetailsSplitterState);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
void DoErrorsListSplitViewArea(
|
||||
ErrorsListView errorsListView,
|
||||
SplitterState splitterState)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
PlasticSplitterGUILayout.BeginHorizontalSplit(splitterState);
|
||||
|
||||
DoErrorsListViewArea(errorsListView);
|
||||
|
||||
DoErrorDetailsTextArea(errorsListView.GetSelectedError());
|
||||
|
||||
PlasticSplitterGUILayout.EndHorizontalSplit();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
static void DoErrorsListViewArea(
|
||||
ErrorsListView errorsListView)
|
||||
{
|
||||
Rect treeRect = GUILayoutUtility.GetRect(0, 100000, 0, 100000);
|
||||
|
||||
errorsListView.OnGUI(treeRect);
|
||||
}
|
||||
|
||||
void DoErrorDetailsTextArea(ErrorMessage selectedErrorMessage)
|
||||
{
|
||||
string errorDetailsText = selectedErrorMessage == null ?
|
||||
string.Empty : selectedErrorMessage.Error;
|
||||
|
||||
mErrorDetailsScrollPosition = GUILayout.BeginScrollView(
|
||||
mErrorDetailsScrollPosition);
|
||||
|
||||
GUILayout.TextArea(
|
||||
errorDetailsText, UnityStyles.TextFieldWithWrapping,
|
||||
GUILayout.ExpandHeight(true));
|
||||
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
Vector2 mErrorDetailsScrollPosition;
|
||||
|
||||
readonly string mTitle;
|
||||
readonly ErrorsListView mErrorsListView;
|
||||
readonly SplitterState mErrorDetailsSplitterState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79a84f5f92624d57ae40a84a53bd9d24
|
||||
timeCreated: 1737719456
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
using Unity.PlasticSCM.Editor.UnityInternals.UnityEditor;
|
||||
|
||||
using EditorWindow = UnityEditor.EditorWindow;
|
||||
using HostView = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.HostView;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class FindEditorWindow
|
||||
{
|
||||
internal static EditorWindow ProjectWindow()
|
||||
{
|
||||
Type projectBrowserType = typeof(EditorWindow).Assembly.GetType(
|
||||
"UnityEditor.ProjectBrowser");
|
||||
|
||||
UnityEngine.Object[] windows = Resources.FindObjectsOfTypeAll(
|
||||
projectBrowserType);
|
||||
|
||||
if (windows.Length == 0)
|
||||
return null;
|
||||
|
||||
return windows[0] as EditorWindow;
|
||||
}
|
||||
|
||||
internal static EditorWindow ToDock<T>()
|
||||
{
|
||||
List<EditorWindow> windows = GetAvailableWindows();
|
||||
|
||||
IEnumerable<EditorWindow> candidateWindows = windows
|
||||
.Where(w => !(w is T))
|
||||
.Where(w => w.position.width > 400 && w.position.height > 300)
|
||||
.OrderByDescending(w => w.position.width * w.position.height);
|
||||
|
||||
return candidateWindows.FirstOrDefault();
|
||||
}
|
||||
|
||||
internal static EditorWindow FirstAvailableWindow()
|
||||
{
|
||||
List<EditorWindow> windows = GetAvailableWindows();
|
||||
|
||||
if (windows == null || windows.Count == 0)
|
||||
return null;
|
||||
|
||||
return windows[0];
|
||||
}
|
||||
|
||||
static List<EditorWindow> GetAvailableWindows()
|
||||
{
|
||||
List<EditorWindow> result = new List<EditorWindow>();
|
||||
|
||||
foreach (EditorWindow window in Resources.FindObjectsOfTypeAll<EditorWindow>())
|
||||
{
|
||||
HostView hostView = window.m_Parent();
|
||||
|
||||
if (hostView == null)
|
||||
continue;
|
||||
|
||||
EditorWindow actualDrawnWindow = hostView.m_ActualView;
|
||||
|
||||
if (actualDrawnWindow == null)
|
||||
continue;
|
||||
|
||||
if (result.Contains(actualDrawnWindow))
|
||||
continue;
|
||||
|
||||
result.Add(actualDrawnWindow);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f5401cd5ff8fc4409bf9540072b14bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
using Codice.LogWrapper;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class GUIActionRunner
|
||||
{
|
||||
internal delegate void ActionDelegate();
|
||||
|
||||
internal static void RunGUIAction(ActionDelegate action)
|
||||
{
|
||||
if (EditorDispatcher.IsOnMainThread)
|
||||
{
|
||||
action();
|
||||
return;
|
||||
}
|
||||
|
||||
lock (mLock)
|
||||
{
|
||||
ManualResetEvent syncEvent = new ManualResetEvent(false);
|
||||
|
||||
EditorDispatcher.Dispatch(delegate {
|
||||
try
|
||||
{
|
||||
action();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
mLog.ErrorFormat("GUI action failed: {0}", e.Message);
|
||||
mLog.DebugFormat("Stack trace:{0}{1}", Environment.NewLine, e.StackTrace);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
syncEvent.Set();
|
||||
}
|
||||
});
|
||||
|
||||
syncEvent.WaitOne();
|
||||
}
|
||||
}
|
||||
|
||||
static object mLock = new object();
|
||||
|
||||
static readonly ILog mLog = PlasticApp.GetLogger("GUIActionRunner");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dbc54b503a79034d9c544e39451fd10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class GUIContentNotification : INotificationContent
|
||||
{
|
||||
internal GUIContentNotification(string content) : this(new GUIContent(content)) { }
|
||||
|
||||
internal GUIContentNotification(GUIContent content)
|
||||
{
|
||||
mGUIContent = content;
|
||||
}
|
||||
|
||||
void INotificationContent.OnGUI()
|
||||
{
|
||||
GUILayout.Label(
|
||||
mGUIContent,
|
||||
UnityStyles.StatusBar.NotificationLabel);
|
||||
}
|
||||
|
||||
readonly GUIContent mGUIContent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61c9e0bcd840dcb4f907e8cc9b89772a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class GetOverlayRect
|
||||
{
|
||||
internal static Rect ForPendingChanges(Rect iconRect)
|
||||
{
|
||||
return new Rect(
|
||||
iconRect.x + 6f,
|
||||
iconRect.y + 8f,
|
||||
UnityConstants.OVERLAY_STATUS_ICON_SIZE,
|
||||
UnityConstants.OVERLAY_STATUS_ICON_SIZE);
|
||||
}
|
||||
|
||||
internal static Rect ForSelectionRect(Rect selectionRect)
|
||||
{
|
||||
// smallest size (16px height), e.g.
|
||||
// - treeView in project view
|
||||
// - tree view in hierarchy view
|
||||
if (Mathf.Approximately(selectionRect.height, 16f))
|
||||
return GetForSmallItems(selectionRect);
|
||||
|
||||
// larger items, e.g. grid view in project view
|
||||
return GetForOtherSizes(selectionRect);
|
||||
}
|
||||
|
||||
static Rect GetForSmallItems(
|
||||
Rect selectionRect)
|
||||
{
|
||||
Rect result = new Rect(
|
||||
selectionRect.x + 4f,
|
||||
selectionRect.y + 4f,
|
||||
UnityConstants.OVERLAY_STATUS_ICON_SIZE,
|
||||
UnityConstants.OVERLAY_STATUS_ICON_SIZE);
|
||||
|
||||
if (Mathf.Approximately(selectionRect.x, 14))
|
||||
{
|
||||
// In the Project window grid view at min size,
|
||||
// the items have an extra 3px margin to the left.
|
||||
// We can detect that case because the x position is always 14 there.
|
||||
// Compensate for that margin
|
||||
result.x += 3;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static Rect GetForOtherSizes(
|
||||
Rect selectionRect)
|
||||
{
|
||||
int sizeToCalculateRatio = 32;
|
||||
float iconOffset = 20f;
|
||||
|
||||
float widthRatio = selectionRect.width /
|
||||
sizeToCalculateRatio;
|
||||
float heightRatio = selectionRect.height /
|
||||
sizeToCalculateRatio;
|
||||
|
||||
return new Rect(
|
||||
selectionRect.x + (iconOffset * widthRatio) - 1f,
|
||||
selectionRect.y + (iconOffset * heightRatio) - 13f,
|
||||
UnityConstants.OVERLAY_STATUS_ICON_SIZE * widthRatio,
|
||||
UnityConstants.OVERLAY_STATUS_ICON_SIZE * heightRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4830608cb1ca7f4289f521d7578de88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,141 @@
|
||||
using Codice.Utils;
|
||||
using PlasticGui;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class GetPlasticShortcut
|
||||
{
|
||||
internal static string ForOpen()
|
||||
{
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityOpenShortcut);
|
||||
}
|
||||
|
||||
internal static string ForDelete()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityDeleteShortcutForWindows);
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityDeleteShortcutForMacOS);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
internal static string ForDiff()
|
||||
{
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityDiffShortcut);
|
||||
}
|
||||
|
||||
internal static string ForAssetDiff()
|
||||
{
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityAssetDiffShortcut);
|
||||
}
|
||||
|
||||
internal static string ForHistory()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityHistoryShortcutForWindows);
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityHistoryShortcutForMacOS);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
internal static string ForMerge()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityMergeShortcutForWindows);
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityMergeShortcutForMacOS);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
internal static string ForHideUnhide()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityHideUnhideShortcutForWindows);
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityHideUnhideShortcutForMacOS);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
internal static string ForLabel()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityLabelShortcutForWindows);
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityLabelShortcutForMacOS);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
internal static string ForSwitch()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnitySwitchShortcutForWindows);
|
||||
if (PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnitySwitchShortcutForMacOS);
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
internal static string ForRename()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityRenameShortcutForWindows);
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityRenameShortcutForMacOS);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
internal static string ForShowInExplorer()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityShowInExplorerShortcutForWindows);
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityShowInExplorerShortcutForMacOS);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
internal static string ForEnter()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityEnterShortcutForWindows);
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UnityEnterShortcutForMacOS);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65c9d93f86da86b41a712d92e8f03dc2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEditor;
|
||||
|
||||
using Unity.PlasticSCM.Editor.CloudDrive;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class GetWindowIfOpened
|
||||
{
|
||||
internal static UVCSWindow UVCS()
|
||||
{
|
||||
if (!EditorWindow.HasOpenInstances<UVCSWindow>())
|
||||
return null;
|
||||
|
||||
return EditorWindow.GetWindow<UVCSWindow>(null, false);
|
||||
}
|
||||
|
||||
internal static CloudDriveWindow CloudDrive()
|
||||
{
|
||||
if (!EditorWindow.HasOpenInstances<CloudDriveWindow>())
|
||||
return null;
|
||||
|
||||
return EditorWindow.GetWindow<CloudDriveWindow>(null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3320b7341e4731842a6fd50ae97c96f5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class GuiEnabled : IDisposable
|
||||
{
|
||||
internal GuiEnabled(bool enabled)
|
||||
{
|
||||
mEnabled = GUI.enabled;
|
||||
GUI.enabled = enabled && mEnabled;
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
GUI.enabled = mEnabled;
|
||||
}
|
||||
|
||||
bool mEnabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a4d828da4d125740924da08b5fbe1cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
#if !UNITY_6000_3_OR_NEWER
|
||||
using EditorUtility = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.EditorUtility;
|
||||
using Menu = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.Menu;
|
||||
#endif
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class HandleMenuItem
|
||||
{
|
||||
internal static void AddMenuItem(
|
||||
string name,
|
||||
int priority,
|
||||
Action execute,
|
||||
Func<bool> validate)
|
||||
{
|
||||
AddMenuItem(name, string.Empty, priority, execute, validate);
|
||||
}
|
||||
|
||||
internal static void AddMenuItem(
|
||||
string name,
|
||||
string shortcut,
|
||||
int priority,
|
||||
Action execute,
|
||||
Func<bool> validate)
|
||||
{
|
||||
Menu.AddMenuItem(name, shortcut, false, priority, execute, validate);
|
||||
}
|
||||
|
||||
internal static void RemoveMenuItem(string name)
|
||||
{
|
||||
Menu.RemoveMenuItem(name);
|
||||
}
|
||||
|
||||
internal static void UpdateAllMenus()
|
||||
{
|
||||
EditorUtility.Internal_UpdateAllMenus();
|
||||
}
|
||||
|
||||
internal static bool GetEnabled(string menuPath)
|
||||
{
|
||||
return Menu.GetEnabled(menuPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01023c055f6f08e408b78d36d5f7a803
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal interface INotificationContent
|
||||
{
|
||||
void OnGUI();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bd4f044bfa05a14ebd7f4e6dcd0fb74
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,946 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.LogWrapper;
|
||||
using Unity.PlasticSCM.Editor.AssetUtils;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class Images
|
||||
{
|
||||
internal enum Name
|
||||
{
|
||||
None,
|
||||
IconCloseButton,
|
||||
IconPressedCloseButton,
|
||||
IconAddedLocal,
|
||||
IconAddedOverlay,
|
||||
IconPrivateOverlay,
|
||||
IconMovedOverlay,
|
||||
IconCheckedOutLocalOverlay,
|
||||
IconDeletedLocalOverlay,
|
||||
IconDeletedRemote,
|
||||
IconDeletedRemoteOverlay,
|
||||
IconOutOfSync,
|
||||
IconInfoBellNotification,
|
||||
IconOutOfSyncOverlay,
|
||||
IconMergeLink,
|
||||
Ignored,
|
||||
IconIgnoredOverlay,
|
||||
IconPendingChanges,
|
||||
IconConflicted,
|
||||
IconConflictedOverlay,
|
||||
IconConflictResolvedOverlay,
|
||||
IconLockedLocalOverlay,
|
||||
IconLockedRemoteOverlay,
|
||||
IconRetainedOverlay,
|
||||
XLink,
|
||||
SecondaryTabClose,
|
||||
SecondaryTabCloseHover,
|
||||
IconRepository,
|
||||
IconPlasticView,
|
||||
IconPlasticNotifyIncoming,
|
||||
IconPlasticNotifyConflict,
|
||||
IconPlasticNotifyPendingChanges,
|
||||
IconPlasticNotifyPendingChangesAndIncoming,
|
||||
IconPackageUpdateAvailable,
|
||||
Loading,
|
||||
IconEmptyGravatar,
|
||||
Step1,
|
||||
Step2,
|
||||
Step3,
|
||||
StepOk,
|
||||
ButtonSsoSignInUnity,
|
||||
ButtonSsoSignInEmail,
|
||||
ButtonSsoSignInGoogle,
|
||||
IconPendingChangesView,
|
||||
IconIncomingChangesView,
|
||||
IconMergeView,
|
||||
IconChangesets,
|
||||
IconBranch,
|
||||
IconBranches,
|
||||
IconBrEx,
|
||||
IconCurrentBranch,
|
||||
IconUndo,
|
||||
Refresh,
|
||||
IconInviteUsers,
|
||||
IconLock,
|
||||
IconLockRetained,
|
||||
IconShelve,
|
||||
IconClipboard,
|
||||
IconLabel,
|
||||
IconHistory,
|
||||
HideVersionControl,
|
||||
GetIncomingChangesIcon,
|
||||
|
||||
// Cloud Drive plugin
|
||||
IconCloudDriveView,
|
||||
}
|
||||
|
||||
internal static Texture2D GetImage(Name image)
|
||||
{
|
||||
return LoadImage(image, false);
|
||||
}
|
||||
|
||||
internal static Texture GetFileIcon(string path)
|
||||
{
|
||||
string relativePath = GetRelativePath.ToApplication(path);
|
||||
|
||||
return GetFileIconFromRelativePath(relativePath);
|
||||
}
|
||||
|
||||
internal static Texture GetFileIconFromCmPath(string path)
|
||||
{
|
||||
return GetFileIconFromRelativePath(
|
||||
path.Substring(1).Replace("/",
|
||||
Path.DirectorySeparatorChar.ToString()));
|
||||
}
|
||||
|
||||
internal static Texture GetDropDownIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("icon dropdown");
|
||||
}
|
||||
|
||||
internal static Texture GetFolderIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("Folder Icon");
|
||||
}
|
||||
|
||||
internal static Texture GetFolderOpenedIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("FolderOpened Icon");
|
||||
}
|
||||
|
||||
internal static Texture GetCloudWorkspaceIcon()
|
||||
{
|
||||
return GetShelveIcon();
|
||||
}
|
||||
|
||||
internal static Texture GetPrivateOverlayIcon()
|
||||
{
|
||||
if (mPrivateOverlayIcon == null)
|
||||
mPrivateOverlayIcon = GetOverlay(Name.IconPrivateOverlay);
|
||||
|
||||
return mPrivateOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetAddedOverlayIcon()
|
||||
{
|
||||
if (mAddedOverlayIcon == null)
|
||||
mAddedOverlayIcon = GetOverlay(Name.IconAddedOverlay);
|
||||
|
||||
return mAddedOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetDeletedLocalOverlayIcon()
|
||||
{
|
||||
if (mDeletedLocalOverlayIcon == null)
|
||||
mDeletedLocalOverlayIcon = GetOverlay(Name.IconDeletedLocalOverlay);
|
||||
|
||||
return mDeletedLocalOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetDeletedRemoteOverlayIcon()
|
||||
{
|
||||
if (mDeletedRemoteOverlayIcon == null)
|
||||
mDeletedRemoteOverlayIcon = GetOverlay(Name.IconDeletedRemoteOverlay);
|
||||
|
||||
return mDeletedRemoteOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetMovedOverlayIcon()
|
||||
{
|
||||
if (mMovedOverlayIcon == null)
|
||||
mMovedOverlayIcon = GetOverlay(Name.IconMovedOverlay);
|
||||
|
||||
return mMovedOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetCheckedOutOverlayIcon()
|
||||
{
|
||||
if (mCheckedOutOverlayIcon == null)
|
||||
mCheckedOutOverlayIcon = GetOverlay(Name.IconCheckedOutLocalOverlay);
|
||||
|
||||
return mCheckedOutOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetOutOfSyncOverlayIcon()
|
||||
{
|
||||
if (mOutOfSyncOverlayIcon == null)
|
||||
mOutOfSyncOverlayIcon = GetOverlay(Name.IconOutOfSyncOverlay);
|
||||
|
||||
return mOutOfSyncOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetConflictedOverlayIcon()
|
||||
{
|
||||
if (mConflictedOverlayIcon == null)
|
||||
mConflictedOverlayIcon = GetOverlay(Name.IconConflictedOverlay);
|
||||
|
||||
return mConflictedOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetConflictResolvedOverlayIcon()
|
||||
{
|
||||
if (mConflictResolvedOverlayIcon == null)
|
||||
mConflictResolvedOverlayIcon = GetOverlay(Name.IconConflictResolvedOverlay);
|
||||
|
||||
return mConflictResolvedOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetLockedLocalOverlayIcon()
|
||||
{
|
||||
if (mLockedLocalOverlayIcon == null)
|
||||
mLockedLocalOverlayIcon = GetOverlay(Name.IconLockedLocalOverlay);
|
||||
|
||||
return mLockedLocalOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetLockedRemoteOverlayIcon()
|
||||
{
|
||||
if (mLockedRemoteOverlayIcon == null)
|
||||
mLockedRemoteOverlayIcon = GetOverlay(Name.IconLockedRemoteOverlay);
|
||||
|
||||
return mLockedRemoteOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetRetainedOverlayIcon()
|
||||
{
|
||||
if (mRetainedOverlayIcon == null)
|
||||
mRetainedOverlayIcon = GetOverlay(Name.IconRetainedOverlay);
|
||||
|
||||
return mRetainedOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetIgnoredOverlayIcon()
|
||||
{
|
||||
if (mIgnoredOverlayIcon == null)
|
||||
mIgnoredOverlayIcon = GetOverlay(Name.IconIgnoredOverlay);
|
||||
|
||||
return mIgnoredOverlayIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetWarnIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("console.warnicon.sml");
|
||||
}
|
||||
|
||||
internal static Texture GetInfoIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("console.infoicon.sml");
|
||||
}
|
||||
|
||||
internal static Texture GetErrorDialogIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("console.erroricon");
|
||||
}
|
||||
|
||||
internal static Texture GetWarnDialogIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("console.warnicon");
|
||||
}
|
||||
|
||||
internal static Texture GetInfoDialogIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("console.infoicon");
|
||||
}
|
||||
|
||||
internal static Texture GetRefreshIcon()
|
||||
{
|
||||
if (mRefreshIcon == null)
|
||||
mRefreshIcon = GetImage(Name.Refresh);
|
||||
|
||||
return mRefreshIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetHideIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("scenevis_hidden_hover");
|
||||
}
|
||||
|
||||
internal static Texture GetUnhideIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("scenevis_visible_hover");
|
||||
}
|
||||
|
||||
internal static Texture GetSettingsIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("settings");
|
||||
}
|
||||
|
||||
internal static Texture GetCloudIcon()
|
||||
{
|
||||
return GetIconFromEditorGUI("CloudConnect@2x");
|
||||
}
|
||||
|
||||
internal static Texture GetCloseIcon()
|
||||
{
|
||||
if (mCloseIcon == null)
|
||||
mCloseIcon = GetImage(Name.SecondaryTabClose);
|
||||
|
||||
return mCloseIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetClickedCloseIcon()
|
||||
{
|
||||
if (mClickedCloseIcon == null)
|
||||
mClickedCloseIcon = GetImage(Name.SecondaryTabCloseHover);
|
||||
|
||||
return mClickedCloseIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetHoveredCloseIcon()
|
||||
{
|
||||
if (mHoveredCloseIcon == null)
|
||||
mHoveredCloseIcon = GetImage(Name.SecondaryTabCloseHover);
|
||||
|
||||
return mHoveredCloseIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetHideVersionControlIcon()
|
||||
{
|
||||
if (mHideVersionControlIcon == null)
|
||||
mHideVersionControlIcon = GetImage(Name.HideVersionControl);
|
||||
|
||||
return mHideVersionControlIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetUndoIcon()
|
||||
{
|
||||
if (mUndoIcon == null)
|
||||
mUndoIcon = GetImage(Name.IconUndo);
|
||||
|
||||
return mUndoIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetClipboardIcon()
|
||||
{
|
||||
if (mClipboardIcon == null)
|
||||
mClipboardIcon = GetImage(Name.IconClipboard);
|
||||
|
||||
return mClipboardIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetPendingChangesViewIcon()
|
||||
{
|
||||
if (mPendingChangesViewIcon == null)
|
||||
mPendingChangesViewIcon = GetImage(Name.IconPendingChangesView);
|
||||
|
||||
return mPendingChangesViewIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetIncomingChangesViewIcon()
|
||||
{
|
||||
if (mIncomingChangesViewIcon == null)
|
||||
mIncomingChangesViewIcon = GetImage(Name.IconIncomingChangesView);
|
||||
|
||||
return mIncomingChangesViewIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetMergeViewIcon()
|
||||
{
|
||||
if (mMergeViewIcon == null)
|
||||
mMergeViewIcon = GetImage(Name.IconMergeView);
|
||||
|
||||
return mMergeViewIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetChangesetsIcon()
|
||||
{
|
||||
if (mChangesetsIcon == null)
|
||||
mChangesetsIcon = GetImage(Name.IconChangesets);
|
||||
|
||||
return mChangesetsIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetBranchIcon()
|
||||
{
|
||||
if (mBranchIcon == null)
|
||||
mBranchIcon = GetImage(Name.IconBranch);
|
||||
|
||||
return mBranchIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetBranchesIcon()
|
||||
{
|
||||
if (mBranchesIcon == null)
|
||||
mBranchesIcon = GetImage(Name.IconBranches);
|
||||
|
||||
return mBranchesIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetBranchExplorerIcon()
|
||||
{
|
||||
if (mBranchExplorerIcon == null)
|
||||
mBranchExplorerIcon = GetImage(Name.IconBrEx);
|
||||
|
||||
return mBranchExplorerIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetCurrentBranchIcon()
|
||||
{
|
||||
if (mCurrentBranchIcon == null)
|
||||
mCurrentBranchIcon = GetImage(Name.IconCurrentBranch);
|
||||
|
||||
return mCurrentBranchIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetConflictedIcon()
|
||||
{
|
||||
if (mConflictedIcon == null)
|
||||
mConflictedIcon = GetImage(Name.IconConflicted);
|
||||
|
||||
return mConflictedIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetPendingChangesIcon()
|
||||
{
|
||||
if (mPendingChangesIcon == null)
|
||||
mPendingChangesIcon = GetImage(Name.IconPendingChanges);
|
||||
|
||||
return mPendingChangesIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetOutOfSyncIcon()
|
||||
{
|
||||
if (mOutOfSyncIcon == null)
|
||||
mOutOfSyncIcon = GetImage(Name.IconOutOfSync);
|
||||
|
||||
return mOutOfSyncIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetInfoBellNotificationIcon()
|
||||
{
|
||||
if (mIncomingNotificationIcon == null)
|
||||
mIncomingNotificationIcon = GetImage(Name.IconInfoBellNotification);
|
||||
|
||||
return mIncomingNotificationIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetPlasticViewIcon()
|
||||
{
|
||||
if (mPlasticViewIcon == null)
|
||||
mPlasticViewIcon = GetImage(Name.IconPlasticView);
|
||||
|
||||
return mPlasticViewIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetPlasticNotifyIncomingIcon()
|
||||
{
|
||||
if (mPlasticNotifyIncomingIcon == null)
|
||||
mPlasticNotifyIncomingIcon = GetImage(Name.IconPlasticNotifyIncoming);
|
||||
|
||||
return mPlasticNotifyIncomingIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetPlasticNotifyConflictIcon()
|
||||
{
|
||||
if (mPlasticNotifyConflictIcon == null)
|
||||
mPlasticNotifyConflictIcon = GetImage(Name.IconPlasticNotifyConflict);
|
||||
|
||||
return mPlasticNotifyConflictIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetPlasticNotifyPendingChangesIcon()
|
||||
{
|
||||
if (mPlasticNotifyPendingChangesIcon == null)
|
||||
mPlasticNotifyPendingChangesIcon = GetImage(Name.IconPlasticNotifyPendingChanges);
|
||||
|
||||
return mPlasticNotifyPendingChangesIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetPlasticNotifyPendingChangesAndIncomingIcon()
|
||||
{
|
||||
if (mPlasticNotifyPendingChangesAndIncomingIcon == null)
|
||||
mPlasticNotifyPendingChangesAndIncomingIcon = GetImage(Name.IconPlasticNotifyPendingChangesAndIncoming);
|
||||
|
||||
return mPlasticNotifyPendingChangesAndIncomingIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetCloudDriveViewIcon()
|
||||
{
|
||||
if (mCloudDriveViewIcon == null)
|
||||
mCloudDriveViewIcon = GetImage(Name.IconCloudDriveView);
|
||||
|
||||
return mCloudDriveViewIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetPackageUpdateAvailableIcon()
|
||||
{
|
||||
if (mPackageUpdateAvailabledIcon == null)
|
||||
mPackageUpdateAvailabledIcon = GetImage(Name.IconPackageUpdateAvailable);
|
||||
|
||||
return mPackageUpdateAvailabledIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetEmptyGravatar()
|
||||
{
|
||||
if (mEmptyGravatarIcon == null)
|
||||
mEmptyGravatarIcon = Images.GetImage(Images.Name.IconEmptyGravatar);
|
||||
|
||||
return mEmptyGravatarIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetStepOkIcon()
|
||||
{
|
||||
if (mStepOkIcon == null)
|
||||
mStepOkIcon = Images.GetImage(Images.Name.StepOk);
|
||||
|
||||
return mStepOkIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetStep1Icon()
|
||||
{
|
||||
if (mStep1Icon == null)
|
||||
mStep1Icon = Images.GetImage(Images.Name.Step1);
|
||||
|
||||
return mStep1Icon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetStep2Icon()
|
||||
{
|
||||
if (mStep2Icon == null)
|
||||
mStep2Icon = Images.GetImage(Images.Name.Step2);
|
||||
|
||||
return mStep2Icon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetStep3Icon()
|
||||
{
|
||||
if (mStep3Icon == null)
|
||||
mStep3Icon = Images.GetImage(Images.Name.Step3);
|
||||
|
||||
return mStep3Icon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetMergeLinkIcon()
|
||||
{
|
||||
if (mMergeLinkIcon == null)
|
||||
mMergeLinkIcon = Images.GetImage(Images.Name.IconMergeLink);
|
||||
|
||||
return mMergeLinkIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetAddedLocalIcon()
|
||||
{
|
||||
if (mAddedLocalIcon == null)
|
||||
mAddedLocalIcon = Images.GetImage(Images.Name.IconAddedLocal);
|
||||
|
||||
return mAddedLocalIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetDeletedRemoteIcon()
|
||||
{
|
||||
if (mDeletedRemoteIcon == null)
|
||||
mDeletedRemoteIcon = Images.GetImage(Images.Name.IconDeletedRemote);
|
||||
|
||||
return mDeletedRemoteIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetRepositoryIcon()
|
||||
{
|
||||
if (mRepositoryIcon == null)
|
||||
mRepositoryIcon = Images.GetImage(Images.Name.IconRepository);
|
||||
|
||||
return mRepositoryIcon;
|
||||
}
|
||||
|
||||
internal static Texture GetFileIcon()
|
||||
{
|
||||
if (mFileIcon == null)
|
||||
mFileIcon = EditorGUIUtility.FindTexture("DefaultAsset Icon");
|
||||
|
||||
if (mFileIcon == null)
|
||||
mFileIcon = GetIconFromAssetPreview(typeof(DefaultAsset));
|
||||
|
||||
if (mFileIcon == null)
|
||||
mFileIcon = GetEmptyImage();
|
||||
|
||||
return mFileIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetLinkUnderlineImage()
|
||||
{
|
||||
if (mLinkUnderlineImage == null)
|
||||
{
|
||||
mLinkUnderlineImage = new Texture2D(1, 1);
|
||||
mLinkUnderlineImage.SetPixel(0, 0, UnityStyles.Colors.Link);
|
||||
mLinkUnderlineImage.Apply();
|
||||
}
|
||||
|
||||
return mLinkUnderlineImage;
|
||||
}
|
||||
|
||||
internal static Texture2D GetInviteUsersIcon()
|
||||
{
|
||||
if (mInviteUsersIcon == null)
|
||||
mInviteUsersIcon = GetImage(Name.IconInviteUsers);
|
||||
|
||||
return mInviteUsersIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetShelveIcon()
|
||||
{
|
||||
if (mShelveIcon == null)
|
||||
mShelveIcon = GetImage(Name.IconShelve);
|
||||
|
||||
return mShelveIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetLabelIcon()
|
||||
{
|
||||
if (mLabelIcon == null)
|
||||
mLabelIcon = GetImage(Name.IconLabel);
|
||||
|
||||
return mLabelIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetHistoryIcon()
|
||||
{
|
||||
if (mHistoryIcon == null)
|
||||
mHistoryIcon = GetImage(Name.IconHistory);
|
||||
|
||||
return mHistoryIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetLockIcon()
|
||||
{
|
||||
if (mLockIcon == null)
|
||||
mLockIcon = GetImage(Name.IconLock);
|
||||
|
||||
return mLockIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetLockRetainedIcon()
|
||||
{
|
||||
if (mLockRetainedIcon == null)
|
||||
mLockRetainedIcon = GetImage(Name.IconLockRetained);
|
||||
|
||||
return mLockRetainedIcon;
|
||||
}
|
||||
|
||||
internal static Texture2D GetTreeviewBackgroundTexture()
|
||||
{
|
||||
if (mTreeviewBackgroundTexture == null)
|
||||
mTreeviewBackgroundTexture = GetTextureFromColor(UnityStyles.Colors.TreeViewBackground);
|
||||
|
||||
return mTreeviewBackgroundTexture;
|
||||
}
|
||||
|
||||
internal static Texture2D GetToolbarBackgroundTexture()
|
||||
{
|
||||
if (mToolbarBackground == null)
|
||||
mToolbarBackground = GetTextureFromColor(UnityStyles.Colors.ToolbarBackground);
|
||||
|
||||
return mToolbarBackground;
|
||||
}
|
||||
|
||||
internal static Texture2D GetColumnsBackgroundTexture()
|
||||
{
|
||||
if (mColumnsBackgroundTexture == null)
|
||||
mColumnsBackgroundTexture = GetTextureFromColor(UnityStyles.Colors.ColumnsBackground);
|
||||
|
||||
return mColumnsBackgroundTexture;
|
||||
}
|
||||
|
||||
internal static Texture2D GetNewTextureFromTexture(Texture2D texture)
|
||||
{
|
||||
Texture2D result = new Texture2D(texture.width, texture.height, TextureFormat.BGRA32, false);
|
||||
|
||||
// To keep images consistent throughout the plugin,
|
||||
// manually set the filter mode
|
||||
result.filterMode = FilterMode.Bilinear;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static Texture2D GetNewTextureFromBytes(int width, int height, byte[] bytes)
|
||||
{
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGBA32, false);
|
||||
|
||||
result.LoadImage(bytes);
|
||||
|
||||
// To keep images consistent throughout the plugin,
|
||||
// manually set the filter mode
|
||||
result.filterMode = FilterMode.Bilinear;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static Texture2D GetNewTextureFromFile(string path)
|
||||
{
|
||||
return GetNewTextureFromBytes(1, 1, File.ReadAllBytes(path));
|
||||
}
|
||||
|
||||
static Texture2D GetOverlay(Name image)
|
||||
{
|
||||
return LoadImage(image, true);
|
||||
}
|
||||
|
||||
static Texture2D LoadImage(Name image, bool preferFulResImage)
|
||||
{
|
||||
string imageFileName = image.ToString().ToLower() + ".png";
|
||||
string imageFileName2x = image.ToString().ToLower() + "@2x.png";
|
||||
|
||||
string darkImageFileName = string.Format("d_{0}", imageFileName);
|
||||
string darkImageFileName2x = string.Format("d_{0}", imageFileName2x);
|
||||
|
||||
string imageFileRelativePath = GetImageFileRelativePath(imageFileName);
|
||||
string imageFileRelativePath2x = GetImageFileRelativePath(imageFileName2x);
|
||||
|
||||
string darkImageFileRelativePath = GetImageFileRelativePath(darkImageFileName);
|
||||
string darkImageFileRelativePath2x = GetImageFileRelativePath(darkImageFileName2x);
|
||||
|
||||
Texture2D result = null;
|
||||
|
||||
if (EditorGUIUtility.isProSkin)
|
||||
result = TryLoadImage(darkImageFileRelativePath, darkImageFileRelativePath2x, preferFulResImage);
|
||||
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
result = TryLoadImage(imageFileRelativePath, imageFileRelativePath2x, preferFulResImage);
|
||||
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
mLog.WarnFormat("Image not found: {0}", imageFileName);
|
||||
return GetEmptyImage();
|
||||
}
|
||||
|
||||
static Texture2D GetEmptyImage()
|
||||
{
|
||||
if (mEmptyImage == null)
|
||||
mEmptyImage = GetTextureFromColor(Color.clear);
|
||||
|
||||
return mEmptyImage;
|
||||
}
|
||||
|
||||
static Texture2D GetTextureFromColor(Color color)
|
||||
{
|
||||
Texture2D texture = new Texture2D(1, 1);
|
||||
|
||||
texture.SetPixel(0, 0, color);
|
||||
texture.Apply();
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
static Texture GetFileIconFromRelativePath(string relativePath)
|
||||
{
|
||||
Texture result = AssetDatabase.GetCachedIcon(relativePath);
|
||||
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
result = GetFileIconFromKnownExtension(relativePath);
|
||||
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
return GetFileIcon();
|
||||
}
|
||||
|
||||
static Texture GetFileIconFromKnownExtension(string relativePath)
|
||||
{
|
||||
if (relativePath.EndsWith(UnityConstants.TREEVIEW_META_LABEL))
|
||||
{
|
||||
relativePath = relativePath.Substring(0,
|
||||
relativePath.Length- UnityConstants.TREEVIEW_META_LABEL.Length);
|
||||
}
|
||||
|
||||
Texture result = InternalEditorUtility.FindIconForFile(relativePath);
|
||||
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
string extension = Path.GetExtension(relativePath).ToLower();
|
||||
|
||||
if (extension == ".anim")
|
||||
return GetIconFromAssetPreview(typeof(UnityEngine.AnimationClip));
|
||||
|
||||
if (extension == ".controller" ||
|
||||
extension == ".overridecontroller")
|
||||
return GetIconFromEditorGUI("AnimatorController Icon");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static Texture2D GetIconFromEditorGUI(string name)
|
||||
{
|
||||
Texture2D result;
|
||||
|
||||
if (mImagesFromEditorGUICache.TryGetValue(name, out result))
|
||||
{
|
||||
if (result != null)
|
||||
return result;
|
||||
mImagesFromEditorGUICache.Remove(name);
|
||||
}
|
||||
|
||||
result = EditorGUIUtility.IconContent(name).image as Texture2D;
|
||||
|
||||
mImagesFromEditorGUICache.Add(name, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static Texture2D GetIconFromAssetPreview(System.Type type)
|
||||
{
|
||||
Texture2D result;
|
||||
|
||||
if (mImagesFromAssetPreviewCache.TryGetValue(type.ToString(), out result))
|
||||
{
|
||||
if (result != null)
|
||||
return result;
|
||||
mImagesFromAssetPreviewCache.Remove(type.ToString());
|
||||
}
|
||||
|
||||
result = AssetPreview.GetMiniTypeThumbnail(type);
|
||||
|
||||
mImagesFromAssetPreviewCache.Add(type.ToString(), result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static string GetImageFileRelativePath(string imageFileName)
|
||||
{
|
||||
return Path.Combine(
|
||||
AssetsPath.GetImagesFolderRelativePath(),
|
||||
imageFileName);
|
||||
}
|
||||
|
||||
static Texture2D TryLoadImage(
|
||||
string imageFileRelativePath, string image2xFilePath, bool preferFulResImage)
|
||||
{
|
||||
bool isImageAvailable = File.Exists(AssetsPath.GetFullPath.ForPath(imageFileRelativePath));
|
||||
bool isImage2XAvailable = File.Exists(AssetsPath.GetFullPath.ForPath(image2xFilePath));
|
||||
|
||||
if ((EditorGUIUtility.pixelsPerPoint > 1f || !isImageAvailable || preferFulResImage) &&
|
||||
isImage2XAvailable)
|
||||
return LoadTextureFromFile(image2xFilePath);
|
||||
|
||||
if (isImageAvailable)
|
||||
return LoadTextureFromFile(imageFileRelativePath);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static Texture2D LoadTextureFromFile(string path)
|
||||
{
|
||||
Texture2D result;
|
||||
|
||||
if (mImagesByPathCache.TryGetValue(path, out result))
|
||||
{
|
||||
if (result != null)
|
||||
return result;
|
||||
mImagesByPathCache.Remove(path);
|
||||
}
|
||||
|
||||
// Don't use AssetDatabase to load as it will
|
||||
// pick filtering mode from the asset itself
|
||||
// which leads to inconsistent filtering between
|
||||
// images.
|
||||
result = GetNewTextureFromFile(path);
|
||||
|
||||
mImagesByPathCache.Add(path, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static Dictionary<string, Texture2D> mImagesByPathCache =
|
||||
new Dictionary<string, Texture2D>();
|
||||
|
||||
static Dictionary<string, Texture2D> mImagesFromEditorGUICache =
|
||||
new Dictionary<string, Texture2D>();
|
||||
|
||||
static Dictionary<string, Texture2D> mImagesFromAssetPreviewCache =
|
||||
new Dictionary<string, Texture2D>();
|
||||
|
||||
static Texture mFileIcon;
|
||||
|
||||
static Texture mPrivateOverlayIcon;
|
||||
static Texture mAddedOverlayIcon;
|
||||
static Texture mDeletedLocalOverlayIcon;
|
||||
static Texture mDeletedRemoteOverlayIcon;
|
||||
static Texture mMovedOverlayIcon;
|
||||
static Texture mCheckedOutOverlayIcon;
|
||||
static Texture mOutOfSyncOverlayIcon;
|
||||
static Texture mConflictedOverlayIcon;
|
||||
static Texture mConflictResolvedOverlayIcon;
|
||||
static Texture mLockedLocalOverlayIcon;
|
||||
static Texture mLockedRemoteOverlayIcon;
|
||||
static Texture mRetainedOverlayIcon;
|
||||
static Texture mIgnoredOverlayIcon;
|
||||
|
||||
static Texture mRefreshIcon;
|
||||
|
||||
static Texture mCloseIcon;
|
||||
static Texture mClickedCloseIcon;
|
||||
static Texture mHoveredCloseIcon;
|
||||
static Texture mHideVersionControlIcon;
|
||||
|
||||
static Texture2D mLinkUnderlineImage;
|
||||
|
||||
static Texture2D mEmptyImage;
|
||||
|
||||
static Texture2D mTreeviewBackgroundTexture;
|
||||
static Texture2D mColumnsBackgroundTexture;
|
||||
static Texture2D mToolbarBackground;
|
||||
|
||||
static Texture2D mUndoIcon;
|
||||
static Texture2D mClipboardIcon;
|
||||
static Texture2D mPendingChangesViewIcon;
|
||||
static Texture2D mIncomingChangesViewIcon;
|
||||
static Texture2D mMergeViewIcon;
|
||||
static Texture2D mChangesetsIcon;
|
||||
static Texture2D mBranchIcon;
|
||||
static Texture2D mBranchesIcon;
|
||||
static Texture2D mBranchExplorerIcon;
|
||||
static Texture2D mCurrentBranchIcon;
|
||||
static Texture2D mPendingChangesIcon;
|
||||
static Texture2D mConflictedIcon;
|
||||
static Texture2D mOutOfSyncIcon;
|
||||
static Texture2D mIncomingNotificationIcon;
|
||||
static Texture2D mInviteUsersIcon;
|
||||
static Texture2D mShelveIcon;
|
||||
static Texture2D mLockIcon;
|
||||
static Texture2D mLockRetainedIcon;
|
||||
static Texture2D mLabelIcon;
|
||||
static Texture2D mHistoryIcon;
|
||||
|
||||
static Texture2D mPlasticViewIcon;
|
||||
static Texture2D mPlasticNotifyIncomingIcon;
|
||||
static Texture2D mPlasticNotifyConflictIcon;
|
||||
static Texture2D mPlasticNotifyPendingChangesIcon;
|
||||
static Texture2D mPlasticNotifyPendingChangesAndIncomingIcon;
|
||||
static Texture2D mCloudDriveViewIcon;
|
||||
|
||||
static Texture2D mPackageUpdateAvailabledIcon;
|
||||
|
||||
static Texture2D mEmptyGravatarIcon;
|
||||
static Texture2D mStepOkIcon;
|
||||
static Texture2D mStep1Icon;
|
||||
static Texture2D mStep2Icon;
|
||||
static Texture2D mStep3Icon;
|
||||
|
||||
static Texture2D mMergeLinkIcon;
|
||||
static Texture2D mAddedLocalIcon;
|
||||
static Texture2D mDeletedRemoteIcon;
|
||||
static Texture2D mRepositoryIcon;
|
||||
|
||||
static readonly HashSet<string> mAudioExtensions = new HashSet<string> {
|
||||
".wav", ".mp3", ".ogg", ".aiff", ".aif" };
|
||||
static readonly HashSet<string> mFontExtensions = new HashSet<string> {
|
||||
".ttf", ".otf" };
|
||||
static readonly HashSet<string> mImageExtensions = new HashSet<string> {
|
||||
".png", ".jpg", ".jpeg", ".gif", ".tga", ".bmp", ".tif", ".tiff", ".psd" };
|
||||
static readonly HashSet<string> mModelExtensions = new HashSet<string> {
|
||||
".fbx", ".ma", ".mb", ".blend", ".max", ".obj" };
|
||||
|
||||
static readonly ILog mLog = PlasticApp.GetLogger("Images");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d765c78b18a58b14a986b34841ae9c52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI.Progress;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal class InputTextDialog : PlasticDialog
|
||||
{
|
||||
internal delegate void OkEventHandler(
|
||||
string text,
|
||||
IPlasticDialogCloser closer,
|
||||
ProgressControlsForDialogs progressControls);
|
||||
|
||||
internal string TextValue { get { return mTextValue; } }
|
||||
|
||||
protected override Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var baseRect = base.DefaultRect;
|
||||
return new Rect(baseRect.x, baseRect.y, mWidth, baseRect.height);
|
||||
}
|
||||
}
|
||||
|
||||
protected override string GetTitle()
|
||||
{
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
protected override void DoComponentsArea()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(mExplanation))
|
||||
{
|
||||
Title(mTitle);
|
||||
GUILayout.Space(10f);
|
||||
}
|
||||
|
||||
DoInputArea();
|
||||
}
|
||||
|
||||
internal static InputTextDialogResult GetInputText(
|
||||
string title,
|
||||
string explanation,
|
||||
string labelText,
|
||||
string defaultValue,
|
||||
string okButtonText,
|
||||
OkEventHandler onOk,
|
||||
EditorWindow parentWindow,
|
||||
int width)
|
||||
{
|
||||
InputTextDialog dialog = Create(
|
||||
title,
|
||||
explanation,
|
||||
labelText,
|
||||
defaultValue,
|
||||
okButtonText,
|
||||
onOk,
|
||||
width,
|
||||
new ProgressControlsForDialogs());
|
||||
|
||||
ResponseType dialogResult = dialog.RunModal(parentWindow);
|
||||
|
||||
InputTextDialogResult result = new InputTextDialogResult
|
||||
{
|
||||
Result = dialogResult == ResponseType.Ok,
|
||||
Text = dialog.mTextValue
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static InputTextDialog Create(
|
||||
string title,
|
||||
string explanation,
|
||||
string labelText,
|
||||
string defaultValue,
|
||||
string okButtonText,
|
||||
OkEventHandler onOk,
|
||||
int width,
|
||||
ProgressControlsForDialogs progressControls)
|
||||
{
|
||||
var instance = CreateInstance<InputTextDialog>();
|
||||
instance.mTitle = title;
|
||||
instance.mExplanation = explanation;
|
||||
instance.mLabelText = labelText;
|
||||
instance.mTextValue = defaultValue;
|
||||
instance.mOkButtonText = okButtonText;
|
||||
instance.mOnOk = onOk;
|
||||
instance.mWidth = width;
|
||||
instance.mProgressControls = progressControls;
|
||||
instance.mEnterKeyAction = instance.OkButtonWithValidationAction;
|
||||
instance.mEscapeKeyAction = instance.CancelButtonAction;
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected override void DoButtonsArea()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope(GUILayout.MinWidth(300)))
|
||||
{
|
||||
GUILayout.Space(2);
|
||||
DrawProgressForDialogs.For(
|
||||
mProgressControls.ProgressData);
|
||||
GUILayout.Space(2);
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
DoButtonsWithPlatformOrdering(DoOkButton, () => { }, DoCancelButton);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DoOkButton()
|
||||
{
|
||||
if (string.IsNullOrEmpty(mOkButtonText))
|
||||
return;
|
||||
|
||||
if (!NormalButton(mOkButtonText))
|
||||
return;
|
||||
|
||||
OkButtonWithValidationAction();
|
||||
}
|
||||
|
||||
void DoInputArea()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Label(mLabelText, GUILayout.ExpandWidth(false));
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
GUI.SetNextControlName(INPUT_TEXT_CONTROL_NAME);
|
||||
|
||||
Rect nameRect = GUILayoutUtility.GetRect(
|
||||
new GUIContent(string.Empty),
|
||||
EditorStyles.textField,
|
||||
GUILayout.ExpandWidth(true));
|
||||
|
||||
mTextValue = EditorGUI.TextField(nameRect, mTextValue);
|
||||
|
||||
if (!mTextAreaFocused)
|
||||
{
|
||||
EditorGUI.FocusTextInControl(INPUT_TEXT_CONTROL_NAME);
|
||||
mTextAreaFocused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OkButtonWithValidationAction()
|
||||
{
|
||||
mTextValue = mTextValue.Trim();
|
||||
mOnOk?.Invoke(mTextValue, this, mProgressControls);
|
||||
}
|
||||
|
||||
string mTitle;
|
||||
string mExplanation;
|
||||
string mLabelText;
|
||||
string mTextValue;
|
||||
bool mTextAreaFocused;
|
||||
int mWidth;
|
||||
|
||||
OkEventHandler mOnOk;
|
||||
|
||||
const string INPUT_TEXT_CONTROL_NAME = "input_text_control";
|
||||
}
|
||||
|
||||
internal class InputTextDialogResult
|
||||
{
|
||||
internal bool Result { get; set; }
|
||||
internal string Text { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e269ac752b6af4e40bc8fbf471ece79b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class MeasureMaxWidth
|
||||
{
|
||||
internal static float ForTexts(GUIStyle style, params string[] texts)
|
||||
{
|
||||
float result = 0;
|
||||
|
||||
GUIContent content = new GUIContent();
|
||||
|
||||
foreach (string text in texts)
|
||||
{
|
||||
content.text = text;
|
||||
|
||||
result = Math.Max(result,
|
||||
style.CalcSize(content).x);
|
||||
}
|
||||
|
||||
return result + 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5eeef8c7e006fbe49ab66c960691f11e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class OverlayProgress
|
||||
{
|
||||
internal static Rect CaptureViewRectangle()
|
||||
{
|
||||
// capture the initial x,y position of the view
|
||||
return GUILayoutUtility.GetRect(
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
internal static void DoOverlayProgress(
|
||||
Rect viewRect,
|
||||
float progressPercent,
|
||||
string progressMessage)
|
||||
{
|
||||
Rect lastRect = GUILayoutUtility.GetLastRect();
|
||||
|
||||
// capture the total width and height of the view
|
||||
// based on the last rect
|
||||
Rect overlayRect = new Rect(
|
||||
viewRect.x,
|
||||
viewRect.y,
|
||||
lastRect.xMax - viewRect.x,
|
||||
lastRect.yMax - viewRect.y - 1);
|
||||
|
||||
DrawDebugRect(overlayRect, Color.green, 2);
|
||||
|
||||
EditorGUI.DrawRect(overlayRect, UnityStyles.Colors.OverlayProgressBackgroundColor);
|
||||
|
||||
const int progressBarHeight = 20;
|
||||
const int padding = 20;
|
||||
|
||||
float progressBarWidth = Mathf.Clamp(
|
||||
overlayRect.width - (padding * 2),
|
||||
MIN_PROGRESS_BAR_WIDTH,
|
||||
MAX_PROGRESS_BAR_WIDTH);
|
||||
|
||||
Rect progressRect = new Rect(
|
||||
overlayRect.x + ((overlayRect.width - progressBarWidth) / 2),
|
||||
overlayRect.y + ((overlayRect.height - progressBarHeight) / 2),
|
||||
progressBarWidth,
|
||||
progressBarHeight);
|
||||
|
||||
EditorGUI.ProgressBar(
|
||||
progressRect,
|
||||
progressPercent,
|
||||
progressMessage);
|
||||
}
|
||||
|
||||
static void DrawDebugRect(Rect rect, Color color, int thickness)
|
||||
{
|
||||
// keep this code commented for future debug purposes
|
||||
|
||||
/*EditorGUI.DrawRect(new Rect(rect.xMin, rect.yMin, rect.width, thickness), color);
|
||||
EditorGUI.DrawRect(new Rect(rect.xMin, rect.yMin, thickness, rect.height), color);
|
||||
EditorGUI.DrawRect(new Rect(rect.xMax - thickness, rect.yMin, thickness, rect.height), color);
|
||||
EditorGUI.DrawRect(new Rect(rect.xMin, rect.yMax - thickness, rect.width, thickness), color);*/
|
||||
}
|
||||
|
||||
const float MAX_PROGRESS_BAR_WIDTH = 290;
|
||||
const float MIN_PROGRESS_BAR_WIDTH = 50;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ea55c972a804304b2c7212f93c6bc4e
|
||||
timeCreated: 1762874042
|
||||
@@ -0,0 +1,190 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal interface ICalcTextSize
|
||||
{
|
||||
float GetTextWidth(string text);
|
||||
}
|
||||
|
||||
internal class CalcTextSize : ICalcTextSize
|
||||
{
|
||||
internal static ICalcTextSize FromStyle(GUIStyle style)
|
||||
{
|
||||
return new CalcTextSize(style);
|
||||
}
|
||||
|
||||
CalcTextSize(GUIStyle style)
|
||||
{
|
||||
mStyle = style;
|
||||
}
|
||||
|
||||
float ICalcTextSize.GetTextWidth(string text)
|
||||
{
|
||||
return mStyle.CalcSize(new GUIContent(text)).x;
|
||||
}
|
||||
|
||||
readonly GUIStyle mStyle;
|
||||
}
|
||||
|
||||
internal static class PathTrimming
|
||||
{
|
||||
/// <summary>
|
||||
/// Truncates a path to fit within the available width using binary search.
|
||||
/// Always preserves the beginning and end of the path when truncating.
|
||||
/// </summary>
|
||||
internal static string TruncatePath(
|
||||
string path,
|
||||
float availableWidth,
|
||||
ICalcTextSize calcTextSize,
|
||||
out bool wasTrimmed)
|
||||
{
|
||||
wasTrimmed = false;
|
||||
|
||||
if (availableWidth <= 0)
|
||||
return string.Empty;
|
||||
|
||||
float fullWidth = calcTextSize.GetTextWidth(path);
|
||||
|
||||
// Path fits completely
|
||||
if (fullWidth <= availableWidth)
|
||||
return path;
|
||||
|
||||
wasTrimmed = true;
|
||||
|
||||
// Binary search for the optimal character count
|
||||
int minChars = 1;
|
||||
int maxChars = path.Length;
|
||||
int bestLength = 0;
|
||||
string bestFit = string.Empty;
|
||||
|
||||
while (minChars <= maxChars)
|
||||
{
|
||||
int midLength = (minChars + maxChars) / 2;
|
||||
string truncated = TruncatePathByLength(path, midLength);
|
||||
float width = calcTextSize.GetTextWidth(truncated);
|
||||
|
||||
if (width <= availableWidth)
|
||||
{
|
||||
// This fits, try to fit more
|
||||
bestLength = midLength;
|
||||
bestFit = truncated;
|
||||
minChars = midLength + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Too wide, try less
|
||||
maxChars = midLength - 1;
|
||||
}
|
||||
|
||||
// If we couldn't fit anything reasonable, ensure at least some content is shown
|
||||
if (bestLength == 0 || string.IsNullOrEmpty(bestFit))
|
||||
{
|
||||
// Show at least part of the filename
|
||||
int lastSeparator = FindLastSeparator(path);
|
||||
if (lastSeparator != -1)
|
||||
{
|
||||
string filename = path.Substring(lastSeparator + 1);
|
||||
|
||||
// Try to fit just the filename with middle truncation
|
||||
minChars = 1;
|
||||
maxChars = filename.Length;
|
||||
|
||||
while (minChars <= maxChars)
|
||||
{
|
||||
int midLength = (minChars + maxChars) / 2;
|
||||
string truncated = TruncateMid(filename, midLength);
|
||||
float width = calcTextSize.GetTextWidth(truncated);
|
||||
|
||||
if (width <= availableWidth)
|
||||
{
|
||||
bestFit = truncated;
|
||||
minChars = midLength + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
maxChars = midLength - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No path separator, just truncate the middle
|
||||
bestFit = TruncateMid(path, 3);
|
||||
}
|
||||
}
|
||||
|
||||
return bestFit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the last occurrence of either forward slash or backslash separator.
|
||||
/// Works cross-platform for both Windows and Unix-style paths.
|
||||
/// </summary>
|
||||
static int FindLastSeparator(string path)
|
||||
{
|
||||
int lastBackslash = path.LastIndexOf('\\');
|
||||
int lastForwardSlash = path.LastIndexOf('/');
|
||||
return Mathf.Max(lastBackslash, lastForwardSlash);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncates the given string to the number of characters given by the length parameter.
|
||||
/// The value is truncated (if necessary) by removing characters from the middle of the
|
||||
/// string and inserting an ellipsis in their place.
|
||||
/// </summary>
|
||||
static string TruncateMid(string value, int length)
|
||||
{
|
||||
if (value.Length <= length)
|
||||
return value;
|
||||
|
||||
if (length <= 0)
|
||||
return string.Empty;
|
||||
|
||||
if (length == 1)
|
||||
return ELLIPSIS;
|
||||
|
||||
int mid = (length - 1) / 2;
|
||||
string pre = value.Substring(0, Mathf.FloorToInt(mid));
|
||||
string post = value.Substring(value.Length - Mathf.CeilToInt(mid));
|
||||
|
||||
return string.Concat(pre, ELLIPSIS, post);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// String truncation for paths.
|
||||
/// This method takes a path and returns it truncated (if necessary) to the exact
|
||||
/// number of characters specified by the length parameter.
|
||||
/// </summary>
|
||||
static string TruncatePathByLength(string path, int length)
|
||||
{
|
||||
if (path.Length <= length)
|
||||
return path;
|
||||
|
||||
if (length <= 0)
|
||||
return string.Empty;
|
||||
|
||||
if (length == 1)
|
||||
return ELLIPSIS;
|
||||
|
||||
int lastSeparator = FindLastSeparator(path);
|
||||
|
||||
// No directory prefix, fall back to middle ellipsis
|
||||
if (lastSeparator == -1)
|
||||
return TruncateMid(path, length);
|
||||
|
||||
int filenameLength = path.Length - lastSeparator - 1;
|
||||
|
||||
// File name prefixed with …/ would be too long, fall back to middle ellipsis
|
||||
if (filenameLength + 2 > length)
|
||||
return TruncateMid(path, length);
|
||||
|
||||
string pre = path.Substring(0, length - filenameLength - 2);
|
||||
string post = path.Substring(lastSeparator);
|
||||
|
||||
return string.Concat(pre, ELLIPSIS, post);
|
||||
}
|
||||
|
||||
const string ELLIPSIS = "…";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6a44f63ad4048afb913f7b9194abcb1
|
||||
timeCreated: 1762942148
|
||||
@@ -0,0 +1,395 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI.Progress;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal abstract class PlasticDialog : EditorWindow, IPlasticDialogCloser
|
||||
{
|
||||
internal enum SizeToContent
|
||||
{
|
||||
Manual = 0,
|
||||
Automatic = 1
|
||||
}
|
||||
|
||||
protected virtual Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
int pixelWidth = Screen.currentResolution.width;
|
||||
float x = (pixelWidth - DEFAULT_WIDTH) / 2;
|
||||
return new Rect(x, 200, DEFAULT_WIDTH, 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool IsResizable { get; set; }
|
||||
|
||||
internal void SetSizeToContent(SizeToContent sizeToContent)
|
||||
{
|
||||
mSizeToContent = sizeToContent;
|
||||
}
|
||||
|
||||
internal virtual void OkButtonAction()
|
||||
{
|
||||
CompleteModal(ResponseType.Ok);
|
||||
}
|
||||
|
||||
internal virtual void CancelButtonAction()
|
||||
{
|
||||
CompleteModal(ResponseType.Cancel);
|
||||
}
|
||||
|
||||
internal void CloseButtonAction()
|
||||
{
|
||||
CompleteModal(ResponseType.None);
|
||||
}
|
||||
|
||||
internal void ApplyButtonAction()
|
||||
{
|
||||
CompleteModal(ResponseType.Apply);
|
||||
}
|
||||
|
||||
internal void AddControlConsumingEnterKey(string controlName)
|
||||
{
|
||||
mControlsConsumingEnterKey.Add(controlName);
|
||||
}
|
||||
|
||||
internal void RunUtility(EditorWindow parentWindow)
|
||||
{
|
||||
InitializeVars(parentWindow);
|
||||
|
||||
if (!IsResizable)
|
||||
MakeNonResizable();
|
||||
|
||||
ShowUtility();
|
||||
}
|
||||
|
||||
internal ResponseType RunModal(EditorWindow parentWindow)
|
||||
{
|
||||
InitializeVars(parentWindow);
|
||||
|
||||
if (!IsResizable)
|
||||
MakeNonResizable();
|
||||
|
||||
UI.RunModal.Dialog(this);
|
||||
return mAnswer;
|
||||
}
|
||||
|
||||
internal static void DoButtonsWithPlatformOrdering(
|
||||
Action doPrimaryButton,
|
||||
Action doCloseButton,
|
||||
Action doCancelButton)
|
||||
{
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
doPrimaryButton();
|
||||
doCloseButton();
|
||||
doCancelButton();
|
||||
return;
|
||||
}
|
||||
|
||||
doCancelButton();
|
||||
doCloseButton();
|
||||
doPrimaryButton();
|
||||
}
|
||||
|
||||
protected virtual void OnGUI()
|
||||
{
|
||||
if (Event.current == null)
|
||||
return;
|
||||
|
||||
// If the Dialog has been saved into the Unity editor layout and persisted between restarts, the methods
|
||||
// to configure the dialogs will be skipped. Simple fix here is to close it when this state is detected.
|
||||
// Fixes a NPE loop when the state mentioned above is occurring.
|
||||
if (!mIsConfigured)
|
||||
{
|
||||
Close();
|
||||
EditorGUIUtility.ExitGUI();
|
||||
return;
|
||||
}
|
||||
|
||||
// When a modal dialog is displayed, Unity's SynchronizationContext.Post() callbacks are not processed
|
||||
// because the modal dialog runs its own event loop.
|
||||
// We need to explicitly pump the EditorDispatcher queue to ensure that callbacks from background threads
|
||||
// (like ThreadWaiter's afterOperationDelegate) are executed.
|
||||
if (Event.current.type == EventType.Layout)
|
||||
{
|
||||
EditorDispatcher.Update();
|
||||
}
|
||||
|
||||
if (!mFocusedOnce)
|
||||
{
|
||||
// Somehow the prevents the dialog from jumping when dragged
|
||||
// NOTE(rafa): We cannot do every frame because the modal kidnaps focus for all processes (in mac at least)
|
||||
Focus();
|
||||
mFocusedOnce = true;
|
||||
}
|
||||
|
||||
ProcessKeyActions();
|
||||
|
||||
GUI.Box(new Rect(0, 0, position.width, position.height), GUIContent.none, EditorStyles.label);
|
||||
|
||||
float margin = 25;
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(margin);
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
GUILayout.Space(margin);
|
||||
|
||||
if (!string.IsNullOrEmpty(GetExplanation()))
|
||||
Paragraph(GetExplanation());
|
||||
|
||||
DoComponentsArea();
|
||||
|
||||
GUILayout.Space(15);
|
||||
|
||||
DoButtonsArea();
|
||||
|
||||
DoCheckBoxArea_Legacy();
|
||||
|
||||
mProgressControls.UpdateProgress(this);
|
||||
|
||||
GUILayout.Space(margin);
|
||||
}
|
||||
GUILayout.Space(margin);
|
||||
}
|
||||
|
||||
if (!IsResizable && mSizeToContent == SizeToContent.Automatic && Event.current.type == EventType.Repaint)
|
||||
{
|
||||
var lastRect = GUILayoutUtility.GetLastRect();
|
||||
float desiredHeight = lastRect.yMax;
|
||||
|
||||
Rect newPos = position;
|
||||
newPos.height = desiredHeight;
|
||||
position = newPos;
|
||||
|
||||
maxSize = newPos.size;
|
||||
minSize = maxSize;
|
||||
}
|
||||
|
||||
if (Event.current.type != EventType.Layout)
|
||||
mFocusedControlName = GUI.GetNameOfFocusedControl();
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (!mIsConfigured)
|
||||
return;
|
||||
|
||||
SaveSettings();
|
||||
|
||||
if (mParentWindow == null)
|
||||
return;
|
||||
|
||||
mParentWindow.Focus();
|
||||
}
|
||||
|
||||
protected virtual void SaveSettings() { }
|
||||
|
||||
protected virtual void DoComponentsArea() { }
|
||||
|
||||
protected abstract string GetTitle();
|
||||
|
||||
protected void Paragraph(string text)
|
||||
{
|
||||
GUILayout.Label(text, UnityStyles.Paragraph);
|
||||
GUILayout.Space(DEFAULT_PARAGRAPH_SPACING);
|
||||
}
|
||||
protected virtual string GetExplanation() { return string.Empty; }
|
||||
|
||||
protected void TextBlockWithEndLink(
|
||||
string url, string formattedExplanation, GUIStyle textblockStyle)
|
||||
{
|
||||
ExternalLink externalLink = new ExternalLink
|
||||
{
|
||||
Label = url,
|
||||
Url = url
|
||||
};
|
||||
|
||||
DrawTextBlockWithLink.ForExternalLink(
|
||||
externalLink, formattedExplanation, textblockStyle);
|
||||
}
|
||||
|
||||
protected static void Title(string text)
|
||||
{
|
||||
GUILayout.Label(text, UnityStyles.Dialog.Title);
|
||||
}
|
||||
|
||||
protected static bool TitleToggle(string text, bool isOn)
|
||||
{
|
||||
return EditorGUILayout.ToggleLeft(text, isOn, UnityStyles.Dialog.Title);
|
||||
}
|
||||
|
||||
protected static bool TitleToggle(string text, bool isOn, GUIStyle style)
|
||||
{
|
||||
return EditorGUILayout.ToggleLeft(text, isOn, style);
|
||||
}
|
||||
|
||||
protected static bool NormalButton(string text)
|
||||
{
|
||||
int textWidth = (int)((GUIStyle)UnityStyles.Dialog.NormalButton)
|
||||
.CalcSize(new GUIContent(text)).x;
|
||||
|
||||
return GUILayout.Button(
|
||||
text,
|
||||
UnityStyles.Dialog.NormalButton,
|
||||
GUILayout.Width(Math.Max(80, textWidth)));
|
||||
}
|
||||
|
||||
protected virtual void DoCheckBoxArea_Legacy() { }
|
||||
|
||||
protected virtual void DoButtonsArea()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
DrawProgressForDialogs.For(mProgressControls.ProgressData);
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
DoButtonsWithPlatformOrdering(DoOkButton, DoCloseButton, DoCancelButton);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DoOkButton()
|
||||
{
|
||||
if (string.IsNullOrEmpty(mOkButtonText))
|
||||
return;
|
||||
|
||||
if (!NormalButton(mOkButtonText))
|
||||
return;
|
||||
|
||||
OkButtonAction();
|
||||
}
|
||||
|
||||
protected void DoCancelButton()
|
||||
{
|
||||
if (string.IsNullOrEmpty(mCancelButtonText))
|
||||
return;
|
||||
|
||||
if (!NormalButton(mCancelButtonText))
|
||||
return;
|
||||
|
||||
CancelButtonAction();
|
||||
}
|
||||
|
||||
protected virtual void DoCloseButton()
|
||||
{
|
||||
if (string.IsNullOrEmpty(mCloseButtonText))
|
||||
return;
|
||||
|
||||
if (!NormalButton(mCloseButtonText))
|
||||
return;
|
||||
|
||||
CloseButtonAction();
|
||||
}
|
||||
|
||||
void IPlasticDialogCloser.CloseDialog()
|
||||
{
|
||||
CompleteModal(ResponseType.Ok);
|
||||
}
|
||||
|
||||
void ProcessKeyActions()
|
||||
{
|
||||
Event e = Event.current;
|
||||
|
||||
if (mEnterKeyAction != null &&
|
||||
Keyboard.IsReturnOrEnterKeyPressed(e) &&
|
||||
!ControlConsumesKey(mControlsConsumingEnterKey, mFocusedControlName))
|
||||
{
|
||||
mEnterKeyAction();
|
||||
e.Use();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mEscapeKeyAction != null &&
|
||||
Keyboard.IsKeyPressed(e, KeyCode.Escape))
|
||||
{
|
||||
mEscapeKeyAction();
|
||||
e.Use();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CompleteModal(ResponseType answer)
|
||||
{
|
||||
mAnswer = answer;
|
||||
|
||||
if (mParentWindow == null)
|
||||
return;
|
||||
|
||||
Close();
|
||||
Repaint();
|
||||
}
|
||||
|
||||
void InitializeVars(EditorWindow parentWindow)
|
||||
{
|
||||
mIsConfigured = true;
|
||||
mAnswer = ResponseType.None;
|
||||
|
||||
titleContent = new GUIContent(GetTitle());
|
||||
|
||||
mFocusedOnce = false;
|
||||
|
||||
position = DefaultRect;
|
||||
mParentWindow = parentWindow;
|
||||
}
|
||||
|
||||
void MakeNonResizable()
|
||||
{
|
||||
maxSize = DefaultRect.size;
|
||||
minSize = maxSize;
|
||||
}
|
||||
|
||||
static bool ControlConsumesKey(
|
||||
List<string> controlsConsumingKey,
|
||||
string focusedControlName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(focusedControlName))
|
||||
return false;
|
||||
|
||||
foreach (string controlName in controlsConsumingKey)
|
||||
{
|
||||
if (focusedControlName.Equals(controlName))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static GUISkin GetEditorSkin()
|
||||
{
|
||||
return EditorGUIUtility.isProSkin ?
|
||||
EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene) :
|
||||
EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
|
||||
}
|
||||
|
||||
string mFocusedControlName;
|
||||
|
||||
bool mFocusedOnce;
|
||||
bool mIsConfigured;
|
||||
ResponseType mAnswer;
|
||||
|
||||
protected Action mEnterKeyAction = null;
|
||||
protected Action mEscapeKeyAction = null;
|
||||
|
||||
protected string mOkButtonText = PlasticLocalization.Name.OkButton.GetString();
|
||||
protected string mCancelButtonText = PlasticLocalization.Name.CancelButton.GetString();
|
||||
protected string mCloseButtonText;
|
||||
|
||||
EditorWindow mParentWindow;
|
||||
SizeToContent mSizeToContent = SizeToContent.Automatic;
|
||||
|
||||
protected ProgressControlsForDialogs mProgressControls = new ProgressControlsForDialogs();
|
||||
|
||||
List<string> mControlsConsumingEnterKey = new List<string>();
|
||||
|
||||
const float DEFAULT_WIDTH = 500f;
|
||||
const float DEFAULT_PARAGRAPH_SPACING = 10f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac908610ab768459d9be962750408b43
|
||||
timeCreated: 1541414966
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using UnityEditor;
|
||||
|
||||
#if !UNITY_6000_3_OR_NEWER
|
||||
using SplitterState = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.SplitterState;
|
||||
using SplitterGUILayout = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.SplitterGUILayout;
|
||||
#endif
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.UI
|
||||
{
|
||||
internal static class PlasticSplitterGUILayout
|
||||
{
|
||||
internal static void BeginHorizontalSplit(SplitterState splitterState)
|
||||
{
|
||||
SplitterGUILayout.BeginHorizontalSplit(splitterState);
|
||||
}
|
||||
|
||||
internal static void EndHorizontalSplit()
|
||||
{
|
||||
SplitterGUILayout.EndHorizontalSplit();
|
||||
}
|
||||
|
||||
internal static void BeginVerticalSplit(SplitterState splitterState)
|
||||
{
|
||||
SplitterGUILayout.BeginVerticalSplit(splitterState);
|
||||
}
|
||||
|
||||
internal static void EndVerticalSplit()
|
||||
{
|
||||
SplitterGUILayout.EndVerticalSplit();
|
||||
}
|
||||
|
||||
internal static SplitterState InitSplitterState(
|
||||
float[] relativeSizes, int[] minSizes, int[] maxSizes)
|
||||
{
|
||||
return new SplitterState(relativeSizes, minSizes, maxSizes);
|
||||
}
|
||||
|
||||
internal static float[] GetRelativeSizes(SplitterState splitterState)
|
||||
{
|
||||
return splitterState.relativeSizes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aaa080d8f7504a868c0c980890f9d5fd
|
||||
timeCreated: 1590087409
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user