Created unity project

This commit is contained in:
2024-12-07 20:55:50 +01:00
parent 539250d964
commit 54fe327198
13758 changed files with 865324 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,85 @@
using System;
using System.ComponentModel;
using UnityEditor;
namespace Unity.PlasticSCM.Editor.UI
{
// Internal usage. This isn't a public API.
[EditorBrowsable(EditorBrowsableState.Never)]
public class CooldownWindowDelayer
{
internal static bool IsUnitTesting { get; set; }
// Internal usage. This isn't a public API.
[EditorBrowsable(EditorBrowsableState.Never)]
public CooldownWindowDelayer(Action action, double cooldownSeconds)
{
mAction = action;
mCooldownSeconds = cooldownSeconds;
}
// Internal usage. This isn't a public API.
[EditorBrowsable(EditorBrowsableState.Never)]
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,17 @@
using UnityEditor.IMGUI.Controls;
using UnityEngine;
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));
}
}
}

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,26 @@
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DrawTextBlockWithEndLink
{
internal static void For(
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);
}
}
}

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,90 @@
using PlasticGui;
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
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)
{
MethodInfo InternalAddMenuItem = MenuType.GetMethod(
"AddMenuItem",
BindingFlags.Static | BindingFlags.NonPublic);
if (InternalAddMenuItem == null)
{
Debug.LogWarningFormat(
PlasticLocalization.GetString(
PlasticLocalization.Name.ErrorAddPlasticSCMMenuItem),
name);
return;
}
InternalAddMenuItem.Invoke(
null, new object[] {
name, shortcut, false,
priority, execute, validate });
}
internal static void RemoveMenuItem(string name)
{
MethodInfo InternalRemoveMenuItem = MenuType.GetMethod(
"RemoveMenuItem",
BindingFlags.Static | BindingFlags.NonPublic);
if (InternalRemoveMenuItem == null)
{
Debug.LogWarningFormat(
PlasticLocalization.GetString(
PlasticLocalization.Name.ErrorRemovePlasticSCMMenuItem),
name);
return;
}
InternalRemoveMenuItem.Invoke(
null, new object[] { name });
}
internal static void UpdateAllMenus()
{
MethodInfo InternalUpdateAllMenus = EditorUtilityType.GetMethod(
"Internal_UpdateAllMenus",
BindingFlags.Static | BindingFlags.NonPublic);
if (InternalUpdateAllMenus == null)
{
Debug.LogWarning(
PlasticLocalization.GetString(
PlasticLocalization.Name.ErrorUpdatePlasticSCMMenus));
return;
}
InternalUpdateAllMenus.Invoke(null, null);
}
internal static bool GetEnabled(string menuPath)
{
return Menu.GetEnabled(menuPath);
}
static readonly Type MenuType = typeof(UnityEditor.Menu);
static readonly Type EditorUtilityType = typeof(UnityEditor.EditorUtility);
}
}

View File

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

View File

@@ -0,0 +1,750 @@
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using Codice.LogWrapper;
using Unity.PlasticSCM.Editor.AssetUtils;
namespace Unity.PlasticSCM.Editor.UI
{
internal class Images
{
internal enum Name
{
None,
IconPlastic,
IconCloseButton,
IconPressedCloseButton,
IconAddedLocal,
IconAddedOverlay,
IconPrivateOverlay,
IconCheckedOutLocalOverlay,
IconDeleted,
IconDeletedLocalOverlay,
IconDeletedRemote,
IconDeletedRemoteOverlay,
IconOutOfSync,
IconOutOfSyncOverlay,
IconMoved,
IconMergeLink,
Ignored,
IgnoredOverlay,
IconConflicted,
IconConflictedOverlay,
IconConflictResolvedOverlay,
IconLockedLocalOverlay,
IconLockedRemoteOverlay,
IconRetainedOverlay,
XLink,
Ok,
SecondaryTabClose,
SecondaryTabCloseHover,
NotOnDisk,
IconRepository,
IconPlasticView,
IconPlasticNotifyIncoming,
IconPlasticNotifyConflict,
Loading,
IconEmptyGravatar,
Step1,
Step2,
Step3,
StepOk,
ButtonSsoSignInUnity,
ButtonSsoSignInEmail,
ButtonSsoSignInGoogle,
IconBranch,
IconUndo,
Refresh,
IconInviteUsers,
IconLock
}
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 GetDirectoryIcon()
{
return GetIconFromEditorGUI("Folder Icon");
}
internal static Texture GetPrivatedOverlayIcon()
{
if (mPrivatedOverlayIcon == null)
mPrivatedOverlayIcon = GetOverlay(Name.IconPrivateOverlay);
return mPrivatedOverlayIcon;
}
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 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 (mIgnoredverlayIcon == null)
mIgnoredverlayIcon = GetOverlay(Name.IgnoredOverlay);
return mIgnoredverlayIcon;
}
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 GetSettingsIcon()
{
return GetIconFromEditorGUI("settings");
}
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 Texture2D GetUndoIcon()
{
if (mUndoIcon == null)
mUndoIcon = GetImage(Name.IconUndo);
return mUndoIcon;
}
internal static Texture2D GetPlasticIcon()
{
if (mPlasticIcon == null)
mPlasticIcon = GetImage(Name.IconPlastic);
return mPlasticIcon;
}
internal static Texture2D GetBranchIcon()
{
if (mBranchIcon == null)
mBranchIcon = GetImage(Name.IconBranch);
return mBranchIcon;
}
internal static Texture2D GetConflictedIcon()
{
if (mConflictedIcon == null)
mConflictedIcon = GetImage(Name.IconConflicted);
return mConflictedIcon;
}
internal static Texture2D GetOutOfSyncIcon()
{
if (mOutOfSyncIcon == null)
mOutOfSyncIcon = GetImage(Name.IconOutOfSync);
return mOutOfSyncIcon;
}
internal static Texture2D GetPlasticViewIcon()
{
if (mPlasticViewIcon == null)
mPlasticViewIcon = GetImage(Name.IconPlasticView);
return mPlasticViewIcon;
}
internal static Texture2D GePlasticNotifyIncomingIcon()
{
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 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 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 GetDeletedIcon()
{
if (mDeletedIcon == null)
mDeletedIcon = Images.GetImage(Images.Name.IconDeleted);
return mDeletedIcon;
}
internal static Texture2D GetMovedIcon()
{
if (mMovedIcon == null)
mMovedIcon = Images.GetImage(Images.Name.IconMoved);
return mMovedIcon;
}
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 GetLockIcon()
{
if (mLockIcon == null)
mLockIcon = GetImage(Name.IconLock);
return mLockIcon;
}
internal static Texture2D GetTreeviewBackgroundTexture()
{
if (mTreeviewBackgroundTexture == null)
mTreeviewBackgroundTexture = GetTextureFromColor(UnityStyles.Colors.TreeViewBackground);
return mTreeviewBackgroundTexture;
}
internal static Texture2D GetCommentBackgroundTexture()
{
if (mCommentBackground == null)
mCommentBackground = GetTextureFromColor(UnityStyles.Colors.CommentsBackground);
return mCommentBackground;
}
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);
}
string extension = Path.GetExtension(relativePath).ToLower();
if (extension.Equals(".cs"))
return GetIconFromEditorGUI("cs Script Icon");
if (extension.Equals(".png") || extension.Equals(".jpg")
|| extension.Equals(".jpeg") || extension.Equals(".gif")
|| extension.Equals(".tga") || extension.Equals(".bmp")
|| extension.Equals(".tif") || extension.Equals(".tiff"))
return GetIconFromEditorGUI("d_Texture Icon");
if (extension.Equals(".mat"))
return GetIconFromAssetPreview(typeof(UnityEngine.Material));
if (extension.Equals(".fbx") || extension.Equals(".ma")
|| extension.Equals(".mb") || extension.Equals(".blend")
|| extension.Equals(".max") )
return GetIconFromAssetPreview(typeof(UnityEngine.GameObject));
if (extension.Equals(".wav") || extension.Equals(".mp3"))
return GetIconFromAssetPreview(typeof(UnityEngine.AudioClip));
if (extension.Equals(".anim"))
return GetIconFromAssetPreview(typeof(UnityEngine.Animation));
if (extension.Equals(".animator"))
return GetIconFromAssetPreview(typeof(UnityEngine.Animator));
if (extension.Equals(".shader"))
return GetIconFromEditorGUI("d_Shader Icon");
if (extension.Equals(".asset") && relativePath.StartsWith("ProjectSettings\\"))
return GetIconFromEditorGUI("EditorSettings 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(Path.GetFullPath(imageFileRelativePath));
bool isImage2XAvailable = File.Exists(Path.GetFullPath(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 mPrivatedOverlayIcon;
static Texture mAddedOverlayIcon;
static Texture mDeletedLocalOverlayIcon;
static Texture mDeletedRemoteOverlayIcon;
static Texture mCheckedOutOverlayIcon;
static Texture mOutOfSyncOverlayIcon;
static Texture mConflictedOverlayIcon;
static Texture mConflictResolvedOverlayIcon;
static Texture mLockedLocalOverlayIcon;
static Texture mLockedRemoteOverlayIcon;
static Texture mRetainedOverlayIcon;
static Texture mIgnoredverlayIcon;
static Texture mRefreshIcon;
static Texture mCloseIcon;
static Texture mClickedCloseIcon;
static Texture mHoveredCloseIcon;
static Texture2D mLinkUnderlineImage;
static Texture2D mEmptyImage;
static Texture2D mTreeviewBackgroundTexture;
static Texture2D mColumnsBackgroundTexture;
static Texture2D mCommentBackground;
static Texture2D mUndoIcon;
static Texture2D mPlasticIcon;
static Texture2D mBranchIcon;
static Texture2D mConflictedIcon;
static Texture2D mOutOfSyncIcon;
static Texture2D mInviteUsersIcon;
static Texture2D mLockIcon;
static Texture2D mPlasticViewIcon;
static Texture2D mPlasticNotifyIncomingIcon;
static Texture2D mPlasticNotifyConflictIcon;
static Texture2D mEmptyGravatarIcon;
static Texture2D mStepOkIcon;
static Texture2D mStep1Icon;
static Texture2D mStep2Icon;
static Texture2D mMergeLinkIcon;
static Texture2D mAddedLocalIcon;
static Texture2D mDeletedRemoteIcon;
static Texture2D mDeletedIcon;
static Texture2D mMovedIcon;
static Texture2D mRepositoryIcon;
static readonly ILog mLog = PlasticApp.GetLogger("Images");
}
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,56 @@
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal class OverlayRect
{
internal static Rect GetOverlayRect(
Rect selectionRect,
float iconOffset)
{
if (selectionRect.width > selectionRect.height)
return GetOverlayRectForSmallestSize(
selectionRect);
return GetOverlayRectForOtherSizes(selectionRect, iconOffset);
}
internal static Rect GetCenteredRect(
Rect selectionRect)
{
return new Rect(
selectionRect.x + 3f,
selectionRect.y + 1f,
UnityConstants.OVERLAY_STATUS_ICON_SIZE,
UnityConstants.OVERLAY_STATUS_ICON_SIZE);
}
static Rect GetOverlayRectForSmallestSize(
Rect selectionRect)
{
return new Rect(
selectionRect.x + 5f,
selectionRect.y + 4f,
UnityConstants.OVERLAY_STATUS_ICON_SIZE,
UnityConstants.OVERLAY_STATUS_ICON_SIZE);
}
static Rect GetOverlayRectForOtherSizes(
Rect selectionRect,
float iconOffset)
{
float widthRatio = selectionRect.width /
UNITY_STANDARD_ICON_SIZE;
float heightRatio = selectionRect.height /
UNITY_STANDARD_ICON_SIZE;
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);
}
const int UNITY_STANDARD_ICON_SIZE = 32;
}
}

View File

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

View File

@@ -0,0 +1,409 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI
{
internal abstract class PlasticDialog : EditorWindow, IPlasticDialogCloser
{
protected virtual Rect DefaultRect
{
get
{
int pixelWidth = Screen.currentResolution.width;
float x = (pixelWidth - DEFAULT_WIDTH) / 2;
return new Rect(x, 200, DEFAULT_WIDTH, DEFAULT_HEIGHT);
}
}
protected virtual bool IsResizable { get; set; }
internal void OkButtonAction()
{
CompleteModal(ResponseType.Ok);
}
internal void CancelButtonAction()
{
CompleteModal(ResponseType.Cancel);
}
internal void CloseButtonAction()
{
CompleteModal(ResponseType.None);
}
internal void ApplyButtonAction()
{
CompleteModal(ResponseType.Apply);
}
internal void RunUtility(EditorWindow parentWindow)
{
InitializeVars(parentWindow);
if (!IsResizable)
MakeNonResizable();
ShowUtility();
}
internal ResponseType RunModal(EditorWindow parentWindow)
{
InitializeVars(parentWindow);
if (!IsResizable)
MakeNonResizable();
if (UI.RunModal.IsAvailable())
{
UI.RunModal.Dialog(this);
return mAnswer;
}
EditorUtility.DisplayDialog(
PlasticLocalization.GetString(PlasticLocalization.Name.UnityVersionControl),
PlasticLocalization.GetString(PlasticLocalization.Name.PluginModalInformation),
PlasticLocalization.GetString(PlasticLocalization.Name.CloseButton));
return ResponseType.None;
}
protected void OnGUI()
{
try
{
// 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)
{
mIsClosed = true;
Close();
return;
}
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();
if (mIsClosed)
return;
GUI.Box(new Rect(0, 0, position.width, position.height), GUIContent.none, EditorStyles.label);
float margin = 25;
float marginTop = 25;
using (new EditorGUILayout.HorizontalScope(GUILayout.Height(position.height)))
{
GUILayout.Space(margin);
using (new EditorGUILayout.VerticalScope(GUILayout.Height(position.height)))
{
GUILayout.Space(marginTop);
OnModalGUI();
GUILayout.Space(margin);
}
GUILayout.Space(margin);
}
var lastRect = GUILayoutUtility.GetLastRect();
float desiredHeight = lastRect.yMax;
Rect newPos = position;
newPos.height = desiredHeight;
if (position.height < desiredHeight)
position = newPos;
if (Event.current.type == EventType.Repaint)
{
if (mIsCompleted)
{
mIsClosed = true;
Close();
}
}
}
finally
{
if (mIsClosed)
EditorGUIUtility.ExitGUI();
}
}
void OnDestroy()
{
if (!mIsConfigured)
return;
SaveSettings();
if (mParentWindow == null)
return;
mParentWindow.Focus();
}
protected virtual void SaveSettings() { }
protected abstract void OnModalGUI();
protected abstract string GetTitle();
protected void Paragraph(string text)
{
GUILayout.Label(text, UnityStyles.Paragraph);
GUILayout.Space(DEFAULT_PARAGRAPH_SPACING);
}
protected void TextBlockWithEndLink(
string url, string formattedExplanation, GUIStyle textblockStyle)
{
ExternalLink externalLink = new ExternalLink
{
Label = url,
Url = url
};
DrawTextBlockWithEndLink.For(externalLink, formattedExplanation, textblockStyle);
}
protected static void Title(string text)
{
GUILayout.Label(text, UnityStyles.Dialog.Toggle);
}
protected static bool TitleToggle(string text, bool isOn)
{
return EditorGUILayout.ToggleLeft(text, isOn, UnityStyles.Dialog.Toggle);
}
protected static bool TitleToggle(string text, bool isOn, GUIStyle style)
{
return EditorGUILayout.ToggleLeft(text, isOn, style);
}
protected static string TextEntry(
string label,
string value,
float width,
float x)
{
return TextEntry(
label,
value,
null,
width,
x);
}
protected static string TextEntry(
string label, string value, string controlName, float width, float x)
{
using (new EditorGUILayout.HorizontalScope())
{
EntryLabel(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);
}
}
protected static string ComboBox(
string label,
string value,
List<string> dropDownOptions,
GenericMenu.MenuFunction2 optionSelected,
float width,
float x)
{
using (new EditorGUILayout.HorizontalScope())
{
EntryLabel(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);
}
}
protected static string PasswordEntry(
string label, string value, float width, float x)
{
using (new EditorGUILayout.HorizontalScope())
{
EntryLabel(label);
GUILayout.FlexibleSpace();
var rt = GUILayoutUtility.GetRect(
new GUIContent(value), UnityStyles.Dialog.EntryLabel);
rt.width = width;
rt.x = x;
return GUI.PasswordField(rt, value, '*');
}
}
static void EntryLabel(string labelText)
{
GUIContent labelContent = new GUIContent(labelText);
GUIStyle labelStyle = UnityStyles.Dialog.EntryLabel;
Rect rt = GUILayoutUtility.GetRect(labelContent, labelStyle);
GUI.Label(rt, labelText, EditorStyles.label);
}
protected static bool ToggleEntry(
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);
}
protected static bool ToggleEntry(string label, bool value)
{
var rt = GUILayoutUtility.GetRect(
new GUIContent(label), UnityStyles.Dialog.EntryLabel);
return GUI.Toggle(rt, value, label);
}
protected static bool NormalButton(string text)
{
return GUILayout.Button(
text, UnityStyles.Dialog.NormalButton,
GUILayout.MinWidth(80),
GUILayout.Height(25));
}
void IPlasticDialogCloser.CloseDialog()
{
OkButtonAction();
}
void ProcessKeyActions()
{
Event e = Event.current;
if (mEnterKeyAction != null &&
Keyboard.IsReturnOrEnterKeyPressed(e))
{
mEnterKeyAction.Invoke();
e.Use();
return;
}
if (mEscapeKeyAction != null &&
Keyboard.IsKeyPressed(e, KeyCode.Escape))
{
mEscapeKeyAction.Invoke();
e.Use();
return;
}
}
protected static bool AcceptButton(string text, int extraWidth = 10)
{
GUI.color = new Color(0.098f, 0.502f, 0.965f, .8f);
int textWidth = (int)((GUIStyle)UnityStyles.Dialog.AcceptButtonText)
.CalcSize(new GUIContent(text)).x;
bool pressed = GUILayout.Button(
string.Empty, GetEditorSkin().button,
GUILayout.MinWidth(Math.Max(80, textWidth + extraWidth)),
GUILayout.Height(25));
GUI.color = Color.white;
Rect buttonRect = GUILayoutUtility.GetLastRect();
GUI.Label(buttonRect, text, UnityStyles.Dialog.AcceptButtonText);
return pressed;
}
void CompleteModal(ResponseType answer)
{
mIsCompleted = true;
mAnswer = answer;
}
void InitializeVars(EditorWindow parentWindow)
{
mIsConfigured = true;
mIsCompleted = false;
mIsClosed = false;
mAnswer = ResponseType.Cancel;
titleContent = new GUIContent(GetTitle());
mFocusedOnce = false;
position = DefaultRect;
mParentWindow = parentWindow;
}
void MakeNonResizable()
{
maxSize = DefaultRect.size;
minSize = maxSize;
}
static GUISkin GetEditorSkin()
{
return EditorGUIUtility.isProSkin ?
EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene) :
EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
}
bool mIsConfigured;
bool mIsCompleted;
bool mIsClosed;
ResponseType mAnswer;
protected Action mEnterKeyAction = null;
protected Action mEscapeKeyAction = null;
bool mFocusedOnce;
EditorWindow mParentWindow;
const float DEFAULT_WIDTH = 500f;
const float DEFAULT_HEIGHT = 180f;
const float DEFAULT_PARAGRAPH_SPACING = 10f;
}
}

View File

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

View File

@@ -0,0 +1,65 @@
using System;
using System.Reflection;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class PlasticSplitterGUILayout
{
internal static void BeginHorizontalSplit(object splitterState)
{
InternalBeginHorizontalSplit.Invoke(
null, new object[] {splitterState, new GUILayoutOption[] { }});
}
internal static void EndHorizontalSplit()
{
InternalEndHorizontalSplit.Invoke(
null, new object[] { });
}
internal static void BeginVerticalSplit(object splitterState)
{
InternalBeginVerticalSplit.Invoke(
null, new object[] {splitterState, new GUILayoutOption[] { }});
}
internal static void EndVerticalSplit()
{
InternalEndVerticalSplit.Invoke(
null, new object[] { });
}
internal static object InitSplitterState(
float[] relativeSizes, int[] minSizes, int[] maxSizes)
{
ConstructorInfo ctorInfo = SplitterState.GetConstructor(
new Type[] {typeof(float[]), typeof(int[]), typeof(int[])});
return ctorInfo.Invoke(
new object[] {relativeSizes, minSizes, maxSizes});
}
static readonly Type SplitterState =
typeof(UnityEditor.Editor).Assembly.
GetType("UnityEditor.SplitterState");
static readonly Type InternalSplitterGUILayout =
typeof(UnityEditor.Editor).Assembly.
GetType("UnityEditor.SplitterGUILayout");
static readonly MethodInfo InternalBeginHorizontalSplit =
InternalSplitterGUILayout.GetMethod(
"BeginHorizontalSplit",
new Type[] { SplitterState, typeof(GUILayoutOption[]) });
static readonly MethodInfo InternalEndHorizontalSplit =
InternalSplitterGUILayout.GetMethod("EndHorizontalSplit");
static readonly MethodInfo InternalBeginVerticalSplit =
InternalSplitterGUILayout.GetMethod(
"BeginVerticalSplit",
new Type[] { SplitterState, typeof(GUILayoutOption[]) });
static readonly MethodInfo InternalEndVerticalSplit =
InternalSplitterGUILayout.GetMethod("EndVerticalSplit");
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aaa080d8f7504a868c0c980890f9d5fd
timeCreated: 1590087409

View File

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

View File

@@ -0,0 +1,38 @@
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI.Progress
{
internal static class DrawProgressForDialogs
{
internal static void For(ProgressControlsForDialogs.Data data)
{
Rect rect = GUILayoutUtility.GetRect(
GUILayoutUtility.GetLastRect().width, 30);
if (!string.IsNullOrEmpty(data.StatusMessage))
{
EditorGUI.HelpBox(rect, data.StatusMessage, data.StatusType);
return;
}
if (data.IsWaitingAsyncResult)
DoProgressBar(rect, data.ProgressMessage, data.ProgressPercent);
}
static void DoProgressBar(
Rect rect,
string progressMessage,
float progressPercent)
{
Rect messageRect = new Rect(
rect.xMin, rect.yMin + 2, rect.width, 16);
Rect progresRect = new Rect(
rect.xMin, rect.yMin + 20, rect.width, 6);
GUI.Label(messageRect, progressMessage);
EditorGUI.ProgressBar(progresRect, progressPercent, string.Empty);
}
}
}

View File

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

View File

@@ -0,0 +1,77 @@
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI.Progress
{
internal static class DrawProgressForOperations
{
internal static void For(
WorkspaceWindow workspaceWindow,
OperationProgressData operationProgressData,
float width)
{
EditorGUILayout.BeginVertical(
EditorStyles.helpBox, GUILayout.Height(60));
GUILayout.Label(
operationProgressData.ProgressHeader ?? string.Empty,
EditorStyles.miniLabel);
DoProgressBar(
operationProgressData.TotalProgressMessage,
(float)operationProgressData.TotalProgressPercent,
operationProgressData.CanCancelProgress, width);
if (operationProgressData.CanCancelProgress)
DoCancelButton(workspaceWindow);
if (operationProgressData.ShowCurrentBlock)
{
GUILayout.Space(6);
DoProgressBar(
operationProgressData.CurrentBlockProgressMessage,
(float)operationProgressData.CurrentBlockProgressPercent,
operationProgressData.CanCancelProgress, width);
}
EditorGUILayout.EndVertical();
}
static void DoProgressBar(
string message,
float progressPercent,
bool canCancel,
float width)
{
Rect progressRect = GUILayoutUtility.GetRect(width, 15);
if (canCancel)
progressRect.width -= UnityConstants.CANCEL_BUTTON_SIZE + 2;
EditorGUI.ProgressBar(progressRect, progressPercent, string.Empty);
progressRect.xMin += 4;
GUI.Label(progressRect, message, EditorStyles.miniLabel);
}
static void DoCancelButton(
WorkspaceWindow workspaceWindow)
{
Rect beginRect = GUILayoutUtility.GetLastRect();
Rect endRect = GUILayoutUtility.GetLastRect();
float freeVerticalSpace = endRect.yMax - beginRect.yMin;
Rect cancelButtonRect = new Rect(
endRect.xMax - UnityConstants.CANCEL_BUTTON_SIZE + 1,
beginRect.yMin + (freeVerticalSpace - UnityConstants.CANCEL_BUTTON_SIZE) / 2,
UnityConstants.CANCEL_BUTTON_SIZE, UnityConstants.CANCEL_BUTTON_SIZE);
if (!GUI.Button(cancelButtonRect, GUIContent.none, UnityStyles.CancelButton))
return;
workspaceWindow.CancelCurrentOperation();
}
}
}

View File

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

View File

@@ -0,0 +1,66 @@
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI.Progress
{
internal static class DrawProgressForViews
{
internal static void ForNotificationArea(
ProgressControlsForViews.Data data)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.HelpBox(
data.NotificationMessage,
data.NotificationType);
EditorGUILayout.EndHorizontal();
}
internal static void ForIndeterminateProgress(
ProgressControlsForViews.Data data)
{
EditorGUILayout.BeginHorizontal();
GUILayout.Space(10);
DoProgressBar(data.ProgressPercent);
GUILayout.Space(3);
DoProgressLabel(data.ProgressMessage);
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
static void DoProgressBar(float progressPercent)
{
EditorGUILayout.BeginVertical();
GUILayout.FlexibleSpace();
Rect progressRect = GUILayoutUtility.GetRect(30, 10);
EditorGUI.ProgressBar(progressRect, progressPercent, string.Empty);
GUILayout.FlexibleSpace();
EditorGUILayout.EndVertical();
}
static void DoProgressLabel(string progressMessage)
{
EditorGUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.Label(progressMessage, UnityStyles.ProgressLabel);
GUILayout.FlexibleSpace();
EditorGUILayout.EndVertical();
}
}
}

View File

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

View File

@@ -0,0 +1,155 @@
namespace Unity.PlasticSCM.Editor.UI.Progress
{
internal class OperationProgressData
{
internal string ProgressHeader
{
get
{
lock (mLockGuard)
{
return mProgressHeader;
}
}
set
{
lock (mLockGuard)
{
mProgressHeader = value;
}
}
}
internal string TotalProgressMessage
{
get
{
lock (mLockGuard)
{
return mTotalProgressMessage;
}
}
set
{
lock (mLockGuard)
{
mTotalProgressMessage = value;
}
}
}
internal string CurrentBlockProgressMessage
{
get
{
lock (mLockGuard)
{
return mBlockProgressMessage;
}
}
set
{
lock (mLockGuard)
{
mBlockProgressMessage = value;
}
}
}
internal double TotalProgressPercent
{
get
{
lock (mLockGuard)
{
return mTotalProgressPercent;
}
}
set
{
lock (mLockGuard)
{
mTotalProgressPercent = value;
}
}
}
internal double CurrentBlockProgressPercent
{
get
{
lock (mLockGuard)
{
return mBlockProgressPercent;
}
}
set
{
lock (mLockGuard)
{
mBlockProgressPercent = value;
}
}
}
internal bool ShowCurrentBlock
{
get
{
lock (mLockGuard)
{
return mShowCurrentBlock;
}
}
set
{
lock (mLockGuard)
{
mShowCurrentBlock = value;
}
}
}
internal bool CanCancelProgress
{
get
{
lock (mLockGuard)
{
return mCanCancelProgress;
}
}
set
{
lock (mLockGuard)
{
mCanCancelProgress = value;
}
}
}
internal void ResetProgress()
{
lock (mLockGuard)
{
mProgressHeader = string.Empty;
mTotalProgressMessage = string.Empty;
mBlockProgressMessage = string.Empty;
mTotalProgressPercent = 0;
mBlockProgressPercent = 0;
mShowCurrentBlock = false;
mCanCancelProgress = false;
}
}
string mProgressHeader;
string mTotalProgressMessage;
string mBlockProgressMessage;
double mTotalProgressPercent;
double mBlockProgressPercent;
bool mShowCurrentBlock;
bool mCanCancelProgress;
object mLockGuard = new object();
}
}

View File

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

View File

@@ -0,0 +1,116 @@
using System;
using UnityEditor;
using UnityEngine;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI.Progress
{
class ProgressControlsForDialogs : IProgressControls
{
internal class Data
{
internal bool IsWaitingAsyncResult;
internal float ProgressPercent;
internal string ProgressMessage;
internal MessageType StatusType;
internal string StatusMessage;
internal void CopyInto(Data other)
{
other.IsWaitingAsyncResult = IsWaitingAsyncResult;
other.ProgressPercent = ProgressPercent;
other.ProgressMessage = ProgressMessage;
other.StatusType = StatusType;
other.StatusMessage = StatusMessage;
}
}
internal Data ProgressData { get { return mData; } }
internal void ForcedUpdateProgress(EditorWindow dialog)
{
double updateTime;
float progressPercent;
GetUpdateProgress(
mLastUpdateTime, mData.ProgressPercent,
out updateTime, out progressPercent);
mLastUpdateTime = updateTime;
if (!mData.IsWaitingAsyncResult)
return;
mData.ProgressPercent = progressPercent;
if (Event.current.type == EventType.Repaint)
dialog.Repaint();
}
void IProgressControls.HideProgress()
{
mData.IsWaitingAsyncResult = false;
mData.ProgressMessage = string.Empty;
}
void IProgressControls.ShowProgress(string message)
{
CleanStatusMessage(mData);
mData.IsWaitingAsyncResult = true;
mData.ProgressPercent = 0f;
mData.ProgressMessage = message;
}
void IProgressControls.ShowError(string message)
{
mData.StatusMessage = message;
mData.StatusType = MessageType.Error;
}
void IProgressControls.ShowNotification(string message)
{
mData.StatusMessage = message;
mData.StatusType = MessageType.Info;
}
void IProgressControls.ShowSuccess(string message)
{
mData.StatusMessage = message;
mData.StatusType = MessageType.Info;
}
void IProgressControls.ShowWarning(string message)
{
mData.StatusMessage = message;
mData.StatusType = MessageType.Warning;
}
static void CleanStatusMessage(Data data)
{
data.StatusMessage = string.Empty;
data.StatusType = MessageType.None;
}
static void GetUpdateProgress(
double lastUpdateTime, float lastProgressPercent,
out double updateTime, out float progressPercent)
{
updateTime = EditorApplication.timeSinceStartup;
double deltaTime = Math.Min(0.1, updateTime - lastUpdateTime);
double deltaPercent = (deltaTime / 0.1) * PERCENT_PER_SECONDS;
progressPercent = Mathf.Repeat(
lastProgressPercent + (float)deltaPercent, 1f);
}
double mLastUpdateTime = 0.0;
Data mData = new Data();
const double PERCENT_PER_SECONDS = 0.06;
}
}

View File

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

View File

@@ -0,0 +1,138 @@
using UnityEditor;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI.Progress
{
internal class ProgressControlsForViews : IProgressControls
{
internal class Data
{
internal bool IsOperationRunning;
internal float ProgressPercent;
internal string ProgressMessage;
internal MessageType NotificationType;
internal string NotificationMessage;
internal void CopyInto(Data other)
{
other.IsOperationRunning = IsOperationRunning;
other.ProgressPercent = ProgressPercent;
other.ProgressMessage = ProgressMessage;
other.NotificationType = NotificationType;
other.NotificationMessage = NotificationMessage;
}
}
internal Data ProgressData { get { return mData; } }
internal bool IsOperationRunning()
{
return mData.IsOperationRunning;
}
internal bool HasNotification()
{
return !string.IsNullOrEmpty(mData.NotificationMessage);
}
internal void UpdateDeterminateProgress(EditorWindow parentWindow)
{
if (IsOperationRunning() || mRequestedRepaint)
{
parentWindow.Repaint();
mRequestedRepaint = false;
}
}
internal void UpdateProgress(EditorWindow parentWindow)
{
if (IsOperationRunning() || mRequestedRepaint)
{
if (IsOperationRunning())
UpdateIndeterminateProgress();
parentWindow.Repaint();
mRequestedRepaint = false;
}
}
void IProgressControls.HideProgress()
{
HideNotification();
mData.IsOperationRunning = false;
mData.ProgressMessage = string.Empty;
mRequestedRepaint = true;
}
void IProgressControls.ShowProgress(string message)
{
HideNotification();
mData.IsOperationRunning = true;
mData.ProgressMessage = message;
mRequestedRepaint = true;
}
void IProgressControls.ShowError(string message)
{
mData.NotificationMessage = message;
mData.NotificationType = MessageType.Error;
mRequestedRepaint = true;
}
void IProgressControls.ShowNotification(string message)
{
mData.NotificationMessage = message;
mData.NotificationType = MessageType.Info;
mRequestedRepaint = true;
}
void IProgressControls.ShowSuccess(string message)
{
mData.NotificationMessage = message;
mData.NotificationType = MessageType.Info;
mRequestedRepaint = true;
}
void IProgressControls.ShowWarning(string message)
{
mData.NotificationMessage = message;
mData.NotificationType = MessageType.Warning;
mRequestedRepaint = true;
}
void HideNotification()
{
mData.NotificationMessage = string.Empty;
mData.NotificationType = MessageType.None;
mRequestedRepaint = true;
}
void UpdateIndeterminateProgress()
{
// NOTE(rafa): there is no support for indeterminate progress bar
// i use this neverending progress bar as workaround
mData.ProgressPercent += .003f;
if (mData.ProgressPercent > 1f)
mData.ProgressPercent = .1f;
}
Data mData = new Data();
bool mRequestedRepaint;
}
}

View File

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

View File

@@ -0,0 +1,10 @@
namespace Unity.PlasticSCM.Editor.UI
{
internal enum ResponseType
{
None,
Ok,
Cancel,
Apply
}
}

View File

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

View File

@@ -0,0 +1,208 @@
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class RunModal
{
static RunModal()
{
InitializeInfo();
}
internal static bool IsAvailable()
{
return mShowWithModeMethod != null
&& mCreateSavedGUIState != null
&& mApplyAndForgetMethod != null
&& mParentField != null
&& mParentWindowProp != null
&& mMakeModalMethod != null;
}
internal static void Dialog(EditorWindow window)
{
ShowAsUtility(window);
object savedGUIState = CreateSavedGUIState();
PushDispatcherContext(window);
MakeModal(window);
PopDispatcherContext(window);
ApplySavedGUIState(savedGUIState);
}
static void MakeModal(EditorWindow window)
{
// MakeModal(m_Parent.window);
var hostView = mParentField.GetValue(window);
var parentWindow = mParentWindowProp.GetValue(hostView, null);
mMakeModalMethod.Invoke(
mMakeModalMethod.IsStatic ? null : window,
new object[] { parentWindow });
}
static void ShowAsUtility(EditorWindow window)
{
// ShowWithMode(ShowMode.Utility);
mShowWithModeMethod.Invoke(window, new object[] { 2 });
}
static object CreateSavedGUIState()
{
// SavedGUIState guiState = SavedGUIState.Create();
return mCreateSavedGUIState.Invoke(null, null);
}
static void ApplySavedGUIState(object savedGUIState)
{
// guiState.ApplyAndForget();
mApplyAndForgetMethod.Invoke(savedGUIState, null);
}
static void PopDispatcherContext(EditorWindow window)
{
//UnityEngine.UIElements.EventDispatcher.editorDispatcher.PopDispatcherContext();
object editorDispatcher = mEditorDispatcherProp2020.GetValue(null);
mPopContextMethod2020.Invoke(editorDispatcher, null);
}
static void PushDispatcherContext(EditorWindow window)
{
//UnityEngine.UIElements.EventDispatcher.editorDispatcher.PushDispatcherContext();
object editorDispatcher = mEditorDispatcherProp2020.GetValue(null);
mPushContextMethod2020.Invoke(editorDispatcher, null);
}
static object GetDispatcher(EditorWindow window)
{
object dispatcher = null;
if (MayHaveDispatcher())
{
var parent = mParentField.GetValue(window);
if (parent != null)
{
var visualTree = mVisualTreeProp.GetValue(parent, null);
if (visualTree != null)
{
var panel = mPanelProp.GetValue(visualTree, null);
if (panel != null)
{
dispatcher = mDispatcherProp.GetValue(panel, null);
}
}
}
}
return dispatcher;
}
static bool MayHaveDispatcher()
{
return mDispatcherType != null
&& mPushContextMethod != null
&& mPopContextMethod != null;
}
static void InitializeInfo()
{
var flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static;
mMakeModalMethod = BuildMakeModalMethodInfo(flags);
mShowWithModeMethod = typeof(EditorWindow).GetMethod("ShowWithMode", flags);
mParentField = typeof(EditorWindow).GetField("m_Parent", flags);
var hostViewType = mParentField.FieldType;
mParentWindowProp = hostViewType.GetProperty("window", flags);
var savedGUIStateType = typeof(EditorWindow).Assembly.GetType("UnityEditor.SavedGUIState");
mCreateSavedGUIState = savedGUIStateType.GetMethod("Create", flags);
mApplyAndForgetMethod = savedGUIStateType.GetMethod("ApplyAndForget", flags);
mEditorDispatcherProp2020 = typeof(UnityEngine.UIElements.EventDispatcher).GetProperty("editorDispatcher", flags);
mPushContextMethod2020 = mEditorDispatcherProp2020.PropertyType.GetMethod("PushDispatcherContext", flags);
mPopContextMethod2020 = mEditorDispatcherProp2020.PropertyType.GetMethod("PopDispatcherContext", flags);
flags = BindingFlags.NonPublic
| BindingFlags.Instance
| BindingFlags.Public;
mParentField = typeof(EditorWindow).GetField("m_Parent", flags);
if (mParentField != null)
hostViewType = mParentField.FieldType;
if (hostViewType != null)
mVisualTreeProp = hostViewType.GetProperty("visualTree");
if (mVisualTreeProp != null)
{
var visualTreeType = mVisualTreeProp.PropertyType;
if (visualTreeType != null)
{
mPanelProp = visualTreeType.GetProperty("panel");
if (mPanelProp != null)
{
var panelType = mPanelProp.PropertyType;
if (panelType != null)
{
mDispatcherProp = panelType.GetProperty("dispatcher");
if (mDispatcherProp != null)
{
mDispatcherType = mDispatcherProp.PropertyType;
if (mDispatcherType != null)
{
mPushContextMethod = mDispatcherType.GetMethod("PushDispatcherContext", flags);
mPopContextMethod = mDispatcherType.GetMethod("PopDispatcherContext", flags);
}
}
}
}
}
}
}
static MethodInfo BuildMakeModalMethodInfo(BindingFlags flags)
{
return typeof(EditorWindow).GetMethod("Internal_MakeModal", flags);
}
static FieldInfo mParentField;
static PropertyInfo mParentWindowProp;
static MethodInfo mMakeModalMethod;
static MethodInfo mShowWithModeMethod;
static MethodInfo mCreateSavedGUIState;
static MethodInfo mApplyAndForgetMethod;
static PropertyInfo mVisualTreeProp;
static Type mDispatcherType;
static MethodInfo mPushContextMethod;
static MethodInfo mPopContextMethod;
static PropertyInfo mPanelProp;
static PropertyInfo mDispatcherProp;
static PropertyInfo mEditorDispatcherProp2020;
static MethodInfo mPushContextMethod2020;
static MethodInfo mPopContextMethod2020;
// // How ContainerWindows are visualized. Used with ContainerWindow.Show
// internal enum ShowMode
// {
// // Show as a normal window with max, min & close buttons.
// NormalWindow = 0,
// // Used for a popup menu. On mac this means light shadow and no titlebar.
// PopupMenu = 1,
// // Utility window - floats above the app. Disappears when app loses focus.
// Utility = 2,
// // Window has no shadow or decorations. Used internally for dragging stuff around.
// NoShadow = 3,
// // The Unity main window. On mac, this is the same as NormalWindow, except window doesn't have a close button.
// MainWindow = 4,
// // Aux windows. The ones that close the moment you move the mouse out of them.
// AuxWindow = 5,
// // Like PopupMenu, but without keyboard focus
// cm-help.es.txtTooltip = 6
// }
}
}

View File

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

View File

@@ -0,0 +1,14 @@
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class ScreenResolution
{
internal static string Get()
{
return string.Format("{0}x{1}",
Screen.currentResolution.width,
Screen.currentResolution.height);
}
}
}

View File

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

View File

@@ -0,0 +1,27 @@
using System;
using UnityEditor;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class ShowWindow
{
internal static PlasticWindow Plastic()
{
PlasticWindow window = EditorWindow.GetWindow<PlasticWindow>(
UnityConstants.PLASTIC_WINDOW_TITLE,
true,
mConsoleWindowType,
mProjectBrowserType);
window.UpdateWindowIcon(PlasticPlugin.GetNotificationStatus());
return window;
}
static Type mConsoleWindowType = typeof(EditorWindow).
Assembly.GetType("UnityEditor.ConsoleWindow");
static Type mProjectBrowserType = typeof(EditorWindow).
Assembly.GetType("UnityEditor.ProjectBrowser");
}
}

View File

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

View File

@@ -0,0 +1,22 @@
using System.Collections.Generic;
namespace Unity.PlasticSCM.Editor.UI
{
internal class SortOrderComparer<T> : IComparer<T>
{
internal SortOrderComparer(IComparer<T> comparer, bool isAscending)
{
mComparer = comparer;
mIsAscending = isAscending;
}
int IComparer<T>.Compare(T x, T y)
{
int result = mComparer.Compare(x, y);
return mIsAscending ? result : -result;
}
bool mIsAscending;
IComparer<T> mComparer;
}
}

View File

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

View File

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

View File

@@ -0,0 +1,20 @@
namespace Unity.PlasticSCM.Editor.UI.StatusBar
{
internal class IncomingChangesNotification
{
internal string InfoText;
internal string ActionText;
internal string TooltipText;
internal bool HasUpdateAction;
internal PlasticNotification.Status Status;
internal void Clear()
{
InfoText = string.Empty;
ActionText = string.Empty;
TooltipText = string.Empty;
HasUpdateAction = false;
Status = PlasticNotification.Status.None;
}
}
}

View File

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

View File

@@ -0,0 +1,189 @@
using UnityEditor;
using UnityEngine;
using PlasticGui.WebApi.Responses;
using PlasticGui.WorkspaceWindow.NotificationBar;
namespace Unity.PlasticSCM.Editor.UI.StatusBar
{
class NotificationBar : INotificationBar
{
internal bool HasNotification { get; private set; }
internal bool IsVisible { get; private set; }
internal NotificationBar()
{
mSubscriptionPanel = new ActionPanel();
mContactPanel = new ActionPanel();
IsVisible = EditorPrefs.GetBool(
UnityConstants.SHOW_NOTIFICATION_KEY_NAME,
true);
}
internal void SetVisibility(bool isVisible)
{
IsVisible = isVisible;
EditorPrefs.SetBool(
UnityConstants.SHOW_NOTIFICATION_KEY_NAME,
isVisible);
}
internal void OnGUI()
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal(UnityStyles.StatusBar.NotificationPanel);
if (mSubscriptionPanel.HasNotification)
mSubscriptionPanel.OnGUI();
GUILayout.FlexibleSpace();
if (mContactPanel.HasNotification)
mContactPanel.OnGUI();
DrawCloseButton(this);
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
void INotificationBar.SetActions(
CloudServerInfo cloudServerInfo,
CloudOrganizationHelpActionsResponse.Action subscriptionAction,
CloudOrganizationHelpActionsResponse.Action contactAction)
{
mSubscriptionPanel.SetAction(cloudServerInfo, subscriptionAction, false);
mContactPanel.SetAction(cloudServerInfo, contactAction, true);
HasNotification = mSubscriptionPanel.HasNotification || mContactPanel.HasNotification;
}
void INotificationBar.CleanActions()
{
HasNotification = false;
mSubscriptionPanel.SetAction(null, null, false);
mContactPanel.SetAction(null, null, false);
}
static void DrawCloseButton(NotificationBar notificationBar)
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
if (GUILayout.Button(
new GUIContent(Images.GetCloseIcon()),
UnityStyles.StatusBar.NotificationPanelCloseButton))
{
notificationBar.SetVisibility(false);
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
class ActionPanel
{
internal bool HasNotification { get; private set; }
internal void SetAction(
CloudServerInfo cloudServerInfo,
CloudOrganizationHelpActionsResponse.Action action,
bool isContactSupportAction)
{
if (action == null)
{
HasNotification = false;
return;
}
mCloudServerInfo = cloudServerInfo;
mActionButton = action.Button;
mIsContactSupportAction = isContactSupportAction;
HasNotification = true;
mLabelText = action.Message;
SetButton(action.Button);
}
internal void OnGUI()
{
DrawLabel(mLabelText);
if (!mIsButtonVisible)
return;
DrawButton(
mCloudServerInfo, mActionButton.Url,
mIsContactSupportAction, mButtonText);
}
void SetButton(
CloudOrganizationHelpActionsResponse.ActionButton actionButton)
{
if (actionButton == null)
{
mButtonText = string.Empty;
mIsButtonVisible = false;
return;
}
mButtonText = actionButton.Caption;
mIsButtonVisible = true;
}
static void DrawLabel(string text)
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.Label(
text,
UnityStyles.StatusBar.Label);
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
static void DrawButton(
CloudServerInfo cloudServerInfo,
string actionButtonUrl,
bool isContactSupportAction,
string buttonText)
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
if (GUILayout.Button(
buttonText,
UnityStyles.StatusBar.LinkLabel))
{
LaunchNotificationAction.For(
cloudServerInfo,
actionButtonUrl,
isContactSupportAction);
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
bool mIsButtonVisible;
string mButtonText;
string mLabelText;
bool mIsContactSupportAction;
CloudOrganizationHelpActionsResponse.ActionButton mActionButton;
CloudServerInfo mCloudServerInfo;
}
ActionPanel mSubscriptionPanel;
ActionPanel mContactPanel;
}
}

View File

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

View File

@@ -0,0 +1,284 @@
using UnityEditor;
using UnityEngine;
using Codice.Client.Common;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.Gluon;
using PlasticGui.WorkspaceWindow.Topbar;
using PlasticGui.WorkspaceWindow.PendingChanges;
using GluonShowIncomingChanges = PlasticGui.Gluon.WorkspaceWindow.ShowIncomingChanges;
namespace Unity.PlasticSCM.Editor.UI.StatusBar
{
interface IIncomingChangesNotifier
{
bool HasNotification { get; }
IncomingChangesNotification Notification { get; }
}
internal class StatusBar
{
internal NotificationBar NotificationBar { get; private set; }
internal StatusBar()
{
mCooldownNotificationClearAction = new CooldownWindowDelayer(
DelayedClearNotification,
UnityConstants.NOTIFICATION_CLEAR_INTERVAL);
NotificationBar = new NotificationBar();
}
internal void Notify(string message, MessageType type, Texture2D image)
{
mNotification = new Notification(message, type, image);
mCooldownNotificationClearAction.Ping();
}
internal void OnGUI(
WorkspaceInfo wkInfo,
WorkspaceWindow workspaceWindow,
IMergeViewLauncher mergeViewLauncher,
IGluonViewSwitcher gluonViewSwitcher,
IIncomingChangesNotifier incomingChangesNotifier,
bool isGluonMode)
{
if (NotificationBar.HasNotification &&
NotificationBar.IsVisible)
{
BeginDrawBar();
NotificationBar.OnGUI();
EndDrawBar();
}
BeginDrawBar();
if (NotificationBar.HasNotification)
{
DrawNotificationAvailablePanel(NotificationBar);
}
if (incomingChangesNotifier.HasNotification)
{
DrawIncomingChangesNotification(
wkInfo,
workspaceWindow,
mergeViewLauncher,
gluonViewSwitcher,
incomingChangesNotifier.Notification,
isGluonMode);
}
if (mNotification != null)
DrawNotification(mNotification);
GUILayout.FlexibleSpace();
DrawWorkspaceStatus(workspaceWindow);
EndDrawBar();
}
void DelayedClearNotification()
{
mNotification = null;
}
static void DrawNotificationAvailablePanel(
NotificationBar notificationBar)
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
if (GUILayout.Button(PlasticLocalization.GetString(
notificationBar.IsVisible ?
PlasticLocalization.Name.HideNotification :
PlasticLocalization.Name.ShowNotification)))
{
notificationBar.SetVisibility(!notificationBar.IsVisible);
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
static void DrawIncomingChangesNotification(
WorkspaceInfo wkInfo,
WorkspaceWindow workspaceWindow,
IMergeViewLauncher mergeViewLauncher,
IGluonViewSwitcher gluonViewSwitcher,
IncomingChangesNotification notification,
bool isGluonMode)
{
Texture2D icon = notification.Status == PlasticNotification.Status.Conflicts ?
Images.GetConflictedIcon() :
Images.GetOutOfSyncIcon();
DrawIcon(icon);
DrawNotificationLabel(notification.InfoText);
if (DrawButton(notification.ActionText, notification.TooltipText))
{
if (notification.HasUpdateAction)
{
workspaceWindow.UpdateWorkspace();
return;
}
ShowIncomingChangesForMode(
wkInfo,
mergeViewLauncher,
gluonViewSwitcher,
isGluonMode);
}
}
static void DrawNotification(Notification notification)
{
DrawIcon(notification.Image);
DrawNotificationLabel(notification.Message);
}
static void DrawWorkspaceStatus(WorkspaceWindow workspaceWindow)
{
DrawIcon(Images.GetBranchIcon());
if (workspaceWindow.WorkspaceStatus == null)
return;
DrawLabel(string.Format(
"{0}@{1}@{2}",
workspaceWindow.WorkspaceStatus.ObjectSpec,
workspaceWindow.WorkspaceStatus.RepositoryName,
workspaceWindow.ServerDisplayName));
}
static void DrawIcon(Texture2D icon)
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.Label(
icon,
UnityStyles.StatusBar.Icon,
GUILayout.Height(UnityConstants.STATUS_BAR_ICON_SIZE),
GUILayout.Width(UnityConstants.STATUS_BAR_ICON_SIZE));
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
static void DrawLabel(string label)
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.Label(
label,
UnityStyles.StatusBar.Label);
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
static void DrawNotificationLabel(string label)
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.Label(
label,
UnityStyles.StatusBar.NotificationLabel);
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
static bool DrawButton(string label, string tooltip)
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
bool buttonClicked = GUILayout.Button(
new GUIContent(label, tooltip),
UnityStyles.StatusBar.Button);
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
return buttonClicked;
}
static void ShowIncomingChangesForMode(
WorkspaceInfo workspaceInfo,
IMergeViewLauncher mergeViewLauncher,
IGluonViewSwitcher gluonSwitcher,
bool isGluonMode)
{
if (isGluonMode)
{
GluonShowIncomingChanges.FromNotificationBar(
workspaceInfo, gluonSwitcher);
return;
}
ShowIncomingChanges.FromNotificationBar(
workspaceInfo, mergeViewLauncher);
}
static void BeginDrawBar()
{
EditorGUILayout.BeginVertical(
GetBarStyle(),
GUILayout.Height(UnityConstants.STATUS_BAR_HEIGHT));
GUILayout.FlexibleSpace();
EditorGUILayout.BeginHorizontal();
}
static void EndDrawBar()
{
EditorGUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
EditorGUILayout.EndVertical();
}
static GUIStyle GetBarStyle()
{
if (sBarTexture == null)
sBarTexture = new Texture2D(1, 1);
if (sBarStyle == null)
sBarStyle = new GUIStyle();
sBarTexture.SetPixel(0, 0, UnityStyles.Colors.BackgroundBar);
sBarTexture.Apply();
sBarStyle.normal.background = sBarTexture;
return sBarStyle;
}
class Notification
{
internal string Message { get; private set; }
internal MessageType MessageType { get; private set; }
internal Texture2D Image { get; private set; }
internal Notification(string message, MessageType messageType, Texture2D image)
{
Message = message;
MessageType = messageType;
Image = image;
}
}
Notification mNotification;
readonly CooldownWindowDelayer mCooldownNotificationClearAction;
static Texture2D sBarTexture;
static GUIStyle sBarStyle;
}
}

View File

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

View File

@@ -0,0 +1,188 @@
using System;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal class TabButton
{
internal bool DrawTabButton(
string buttonText,
bool wasActive,
float width)
{
bool isCloseButtonClicked;
return DrawClosableTabButton(
buttonText,
wasActive,
false,
width,
null,
out isCloseButtonClicked);
}
internal bool DrawClosableTabButton(
string buttonText,
bool wasActive,
bool isClosable,
float width,
Action repaintAction,
out bool isCloseButtonClicked)
{
isCloseButtonClicked = false;
GUIContent buttonContent = new GUIContent(buttonText);
GUIStyle buttonStyle = UnityStyles.PlasticWindow.TabButton;
Rect toggleRect = GUILayoutUtility.GetRect(
buttonContent, buttonStyle,
GUILayout.Width(width));
if (isClosable && Event.current.type == EventType.MouseMove)
{
if (mCloseButtonRect.Contains(Event.current.mousePosition))
{
SetCloseButtonState(
CloseButtonState.Hovered,
repaintAction);
}
else
{
SetCloseButtonState(
CloseButtonState.Normal,
repaintAction);
}
}
if (isClosable && Event.current.type == EventType.MouseDown)
{
if (mCloseButtonRect.Contains(Event.current.mousePosition))
{
SetCloseButtonState(
CloseButtonState.Clicked,
repaintAction);
Event.current.Use();
}
}
if (isClosable && Event.current.type == EventType.MouseUp)
{
if (mCloseButtonRect.Contains(Event.current.mousePosition))
{
Event.current.Use();
isCloseButtonClicked = true;
}
if (IsTabClickWithMiddleButton(toggleRect, Event.current))
{
Event.current.Use();
isCloseButtonClicked = true;
}
SetCloseButtonState(
CloseButtonState.Normal,
repaintAction);
}
bool isActive = GUI.Toggle(
toggleRect, wasActive, buttonText, buttonStyle);
if (isClosable && toggleRect.height > 1)
{
mCloseButtonRect = DrawCloseButton(
toggleRect,
mCloseButtonState);
}
if (wasActive)
{
DrawUnderline(toggleRect);
}
return isActive;
}
static Rect DrawCloseButton(
Rect toggleRect,
CloseButtonState state)
{
int closeButtonSize = 15;
GUIContent closeImage = new GUIContent(GetCloseImage(state));
Rect closeTabRect = new Rect(
toggleRect.xMax - closeButtonSize - 1,
toggleRect.y + (toggleRect.height / 2 - closeButtonSize / 2),
closeButtonSize,
closeButtonSize);
GUI.Button(closeTabRect, closeImage, EditorStyles.label);
return new Rect(
closeTabRect.x - 1,
closeTabRect.y - 1,
closeTabRect.width + 2,
closeTabRect.height + 2);
}
static void DrawUnderline(Rect toggleRect)
{
GUIStyle activeTabStyle =
UnityStyles.PlasticWindow.ActiveTabUnderline;
Rect underlineRect = new Rect(
toggleRect.x,
toggleRect.yMax - (activeTabStyle.fixedHeight / 2),
toggleRect.width,
activeTabStyle.fixedHeight);
GUI.Label(underlineRect, string.Empty, activeTabStyle);
}
static bool IsTabClickWithMiddleButton(Rect toggleRect, Event currentEvent)
{
if (currentEvent.button != 2)
return false;
return toggleRect.height > 1 &&
toggleRect.Contains(Event.current.mousePosition);
}
static Texture GetCloseImage(CloseButtonState state)
{
if (state == CloseButtonState.Hovered)
return Images.GetHoveredCloseIcon();
if (state == CloseButtonState.Clicked)
return Images.GetClickedCloseIcon();
return Images.GetCloseIcon();
}
void SetCloseButtonState(
CloseButtonState newState,
Action repaintAction)
{
if (mCloseButtonState == newState)
return;
mCloseButtonState = newState;
if (repaintAction != null)
repaintAction();
}
Rect mCloseButtonRect;
CloseButtonState mCloseButtonState;
enum CloseButtonState
{
Normal,
Clicked,
Hovered,
}
}
}

View File

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

View File

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

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