first commit

This commit is contained in:
SimonSayeBabu
2025-01-17 13:10:20 +01:00
commit bd1057cec0
16967 changed files with 1048699 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 43aad6ec3599fb84a89e8fce31748cce
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e76ce7703143a924b9c0693ee66ebee7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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>();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43c380b3a07cbf449a54619bb50096b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0afb4c6d979970647841ee14a55b8d25
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
using UnityEditor;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class BoolSetting
{
internal static bool Load(
string boolSettingName,
bool defaultValue)
{
return EditorPrefs.GetBool(
GetSettingKey(boolSettingName),
defaultValue);
}
internal static void Save(
bool value,
string boolSettingName)
{
EditorPrefs.SetBool(
GetSettingKey(boolSettingName), value);
}
internal static void Clear(
string boolSettingName)
{
EditorPrefs.DeleteKey(
GetSettingKey(boolSettingName));
}
static string GetSettingKey(string boolSettingName)
{
return string.Format(
boolSettingName, PlayerSettings.productGUID);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5be77ef41db4cc24a82cd1eca7456b5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using UnityEditor;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class CloseWindowIfOpened
{
internal static void Plastic()
{
if (!EditorWindow.HasOpenInstances<PlasticWindow>())
return;
PlasticWindow window = EditorWindow.
GetWindow<PlasticWindow>(null, false);
window.Close();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 25e3b426e5be4f64db3f9184fd625379
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,79 @@
using System;
using UnityEditor;
namespace Unity.PlasticSCM.Editor.UI
{
public class CooldownWindowDelayer
{
internal static bool IsUnitTesting { get; set; }
public CooldownWindowDelayer(Action action, double cooldownSeconds)
{
mAction = action;
mCooldownSeconds = cooldownSeconds;
}
public void Ping()
{
if (IsUnitTesting)
{
mAction();
return;
}
if (mIsOnCooldown)
{
RefreshCooldown();
return;
}
StartCooldown();
}
void RefreshCooldown()
{
mIsOnCooldown = true;
mSecondsOnCooldown = mCooldownSeconds;
}
void StartCooldown()
{
mLastUpdateTime = EditorApplication.timeSinceStartup;
EditorApplication.update += OnUpdate;
RefreshCooldown();
}
void EndCooldown()
{
EditorApplication.update -= OnUpdate;
mIsOnCooldown = false;
mAction();
}
void OnUpdate()
{
double updateTime = EditorApplication.timeSinceStartup;
double deltaSeconds = updateTime - mLastUpdateTime;
mSecondsOnCooldown -= deltaSeconds;
if (mSecondsOnCooldown < 0)
EndCooldown();
mLastUpdateTime = updateTime;
}
readonly Action mAction;
readonly double mCooldownSeconds;
double mLastUpdateTime;
bool mIsOnCooldown;
double mSecondsOnCooldown;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 75e502da07ff345528edbecd094b5cb5
timeCreated: 1541676676
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
using System;
using System.Reflection;
using UnityEditor;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DockEditorWindow
{
static DockEditorWindow()
{
InitializeInfo();
}
internal static bool IsAvailable()
{
return mParentField != null
&& mAddTabMethod != null;
}
internal static void To(EditorWindow dockWindow, EditorWindow window)
{
var dockArea = mParentField.GetValue(dockWindow);
mAddTabMethod.Invoke(dockArea, new object[] { window, true });
}
static void InitializeInfo()
{
var flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static;
mParentField = typeof(EditorWindow).GetField("m_Parent", flags);
var dockAreaType = typeof(EditorWindow).Assembly.GetType("UnityEditor.DockArea");
if (dockAreaType == null)
return;
mAddTabMethod = dockAreaType.GetMethod("AddTab", flags,
null, new Type[] { typeof(EditorWindow), typeof(bool) }, null);
}
static MethodInfo mAddTabMethod;
static FieldInfo mParentField;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3a6fba741cdd5fb4982a73a4d791754f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
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 For(string buttonText, string buttonTooltip)
{
GUIContent buttonContent = new GUIContent(buttonText, buttonTooltip);
return ForRegularButton(buttonContent);
}
internal static bool ForCommentSection(string buttonText)
{
GUIContent buttonContent = new GUIContent(buttonText);
GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButton);
buttonStyle.stretchWidth = false;
float width = MeasureMaxWidth.ForTexts(buttonStyle, buttonText);
Rect rt = GUILayoutUtility.GetRect(
buttonContent,
buttonStyle,
GUILayout.MinWidth(width),
GUILayout.MaxWidth(width));
return GUI.Button(rt, buttonContent, buttonStyle);
}
static bool ForRegularButton(GUIContent buttonContent)
{
GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButton);
buttonStyle.stretchWidth = false;
Rect rt = GUILayoutUtility.GetRect(
buttonContent,
buttonStyle,
GUILayout.MinWidth(UnityConstants.REGULAR_BUTTON_WIDTH));
return GUI.Button(rt, buttonContent, buttonStyle);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c08cfcfc4c2c46c46940ed103538acae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using System;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DrawActionButtonWithMenu
{
internal static void For(string buttonText, Action buttonAction, GenericMenu actionMenu)
{
// Action button
GUIContent buttonContent = new GUIContent(buttonText);
GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButtonLeft);
buttonStyle.stretchWidth = false;
float width = MeasureMaxWidth.ForTexts(buttonStyle, buttonText);
Rect rt = GUILayoutUtility.GetRect(
buttonContent,
buttonStyle,
GUILayout.MinWidth(width),
GUILayout.MaxWidth(width));
if (GUI.Button(rt, buttonContent, buttonStyle))
{
buttonAction();
}
// Menu dropdown
GUIStyle dropDownStyle = new GUIStyle(EditorStyles.miniButtonRight);
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;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 640fd06dff6f43498693eeda77683e6e
timeCreated: 1715597188

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 30c4cfa3209d4a44480017a19ec5b3b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DrawActionToolbar
{
internal static void Begin(EditorWindow parentWindow)
{
Rect result = GUILayoutUtility.GetRect(parentWindow.position.width, 1);
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();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3c3253f17b35cd14ab618b470fb0e52a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DrawSearchField
{
internal static void For(
SearchField searchField,
TreeView treeView,
float width)
{
Rect searchFieldRect = GUILayoutUtility.GetRect(
width / 2f, EditorGUIUtility.singleLineHeight);
searchFieldRect.y += 2f;
treeView.searchString = Draw(
searchField,
searchFieldRect,
treeView.searchString);
if (!string.IsNullOrEmpty(treeView.searchString))
return;
GUI.Label(searchFieldRect, PlasticLocalization.GetString(
PlasticLocalization.Name.SearchTooltip), UnityStyles.Search);
}
static string Draw(
SearchField searchField,
Rect searchFieldRect,
string searchString)
{
return searchField.OnToolbarGUI(
searchFieldRect, searchString);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5474cb78511de04459cac50d50b9d9e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ddfa6de84251ce4448a66bad9e7d326e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DrawTextBlockWithEndLink
{
internal static void For(
string url,
string formattedExplanation,
GUIStyle textblockStyle)
{
string explanation = string.Format(
formattedExplanation, "");
GUILayout.Label(explanation, textblockStyle);
if (explanation == formattedExplanation)
return;
string coloredUrl = string.Format(
"<color=\"{0}\">{1}</color>",
UnityStyles.HexColors.LINK_COLOR,
url);
float linkWidth =
textblockStyle.CalcSize(new GUIContent(url)).x;
if (GUILayout.Button(coloredUrl, textblockStyle, GUILayout.Width(linkWidth)))
Application.OpenURL(url);
EditorGUIUtility.AddCursorRect(
GUILayoutUtility.GetLastRect(), MouseCursor.Link);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 54390afd4066b724d9a802ff75bed13b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DrawUserIcon
{
static internal void ForPendingChangesTab(string commentText)
{
Rect rect = BuildUserIconAreaRect(commentText, 35f);
GUI.DrawTexture(rect, Images.GetEmptyGravatar());
}
static Rect BuildUserIconAreaRect(string commentText, float sizeOfImage)
{
GUIStyle commentTextAreaStyle = UnityStyles.PendingChangesTab.CommentTextArea;
Rect result = GUILayoutUtility.GetRect(sizeOfImage, sizeOfImage); // Needs to be a square
result.x = commentTextAreaStyle.margin.left;
return result;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f222cc01be81b842b1333c92fb7355c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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 = GUI.TextField(textFieldRect, text);
GUI.Label(popupIconRect, popupIcon);
return result;
}
const int BUTTON_WIDTH = 16;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d2e4782a922433041be291edaf12421a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Threading;
using UnityEditor;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class EditorDispatcher
{
internal static void Initialize()
{
mMainThread = Thread.CurrentThread;
}
internal static bool IsOnMainThread
{
get { return Thread.CurrentThread == mMainThread; }
}
internal static void Dispatch(Action task)
{
lock (mDispatchQueue)
{
if (mDispatchQueue.Count == 0)
EditorApplication.update += Update;
mDispatchQueue.Enqueue(task);
}
}
internal static void Update()
{
Action[] actions;
lock (mDispatchQueue)
{
if (mDispatchQueue.Count == 0)
return;
actions = mDispatchQueue.ToArray();
mDispatchQueue.Clear();
EditorApplication.update -= Update;
}
foreach (Action action in actions)
action();
}
static readonly Queue<Action> mDispatchQueue = new Queue<Action>();
static Thread mMainThread;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de4aea75bc204d14cb432cf1708548f1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 245d2c4b912b39a4784287979ea8cfd9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
using Codice.Client.Common;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI
{
internal class EditorProgressControls : IProgressControls
{
internal EditorProgressControls(GuiMessage.IGuiMessage guiMessage)
{
mGuiMessage = guiMessage;
}
void IProgressControls.HideProgress()
{
EditorProgressBar.ClearProgressBar();
}
void IProgressControls.ShowError(string message)
{
mGuiMessage.ShowError(message);
}
void IProgressControls.ShowNotification(string message)
{
mGuiMessage.ShowMessage(
UnityConstants.PLASTIC_WINDOW_TITLE,
message,
GuiMessage.GuiMessageType.Informational);
}
void IProgressControls.ShowProgress(string message)
{
EditorProgressBar.ShowProgressBar(message, 1f);
}
void IProgressControls.ShowSuccess(string message)
{
mGuiMessage.ShowMessage(
UnityConstants.PLASTIC_WINDOW_TITLE,
message,
GuiMessage.GuiMessageType.Informational);
}
void IProgressControls.ShowWarning(string message)
{
mGuiMessage.ShowMessage(
UnityConstants.PLASTIC_WINDOW_TITLE,
message,
GuiMessage.GuiMessageType.Warning);
}
GuiMessage.IGuiMessage mGuiMessage;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e436e24eba68eff48b3fb264ad0ab953
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0e1e2d80d9c79b042ab42fdf0b5c0b65
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 84ce5571ebc476e45b6c9bc6644599c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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";
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de396a7891b8b7f4f9649c3ccee67421
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
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();
}
static List<EditorWindow> GetAvailableWindows()
{
List<EditorWindow> result = new List<EditorWindow>();
var hostViewField = typeof(EditorWindow).GetField(
"m_Parent", BindingFlags.Instance | BindingFlags.NonPublic);
if (hostViewField == null)
return null;
var hostViewType = hostViewField.FieldType;
var actualViewField = hostViewType.GetField(
"m_ActualView", BindingFlags.Instance | BindingFlags.NonPublic);
if (actualViewField == null)
return null;
foreach (var window in Resources.FindObjectsOfTypeAll<EditorWindow>())
{
var hostView = hostViewField.GetValue(window);
if (hostView == null)
continue;
EditorWindow actualDrawnWindow = actualViewField
.GetValue(hostView) as EditorWindow;
if (actualDrawnWindow == null)
continue;
if (result.Contains(actualDrawnWindow))
continue;
result.Add(actualDrawnWindow);
}
return result;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f5401cd5ff8fc4409bf9540072b14bc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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");
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6dbc54b503a79034d9c544e39451fd10
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
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;
}
}
}

Some files were not shown because too many files have changed in this diff Show More