initial commit

This commit is contained in:
Jo 2025-01-07 02:06:59 +01:00
parent 6715289efe
commit 788c3389af
37645 changed files with 2526849 additions and 80 deletions

View file

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

View file

@ -0,0 +1,69 @@
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI.Avatar
{
internal static class ApplyCircleMask
{
internal static Texture2D For(Texture2D sourceImage)
{
int width = sourceImage.width;
int height = sourceImage.height;
int centerx = sourceImage.width / 2;
int centery = sourceImage.height / 2;
int radius = sourceImage.width / 2;
Texture2D result = new Texture2D(height, width);
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,73 @@
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 = new Texture2D(32, 32);
result.LoadImage(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,43 @@
using System;
using UnityEngine;
using PlasticGui;
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,
byte[] avatarBytes,
Action avatarLoadedAction)
{
AvatarImages.UpdateGravatar(email, avatarBytes);
avatarLoadedAction();
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,79 @@
using System;
using UnityEditor;
namespace Unity.PlasticSCM.Editor.UI
{
internal class CooldownWindowDelayer
{
internal static bool IsUnitTesting { get; set; }
internal CooldownWindowDelayer(Action action, double cooldownSeconds)
{
mAction = action;
mCooldownSeconds = cooldownSeconds;
}
internal 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 });
}
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) }, 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,43 @@
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DrawActionButton
{
internal static bool For(string buttonText)
{
GUIContent buttonContent = new GUIContent(buttonText);
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, buttonText, buttonStyle);
}
internal static bool ForCommentSection(string buttonText)
{
GUIContent buttonContent = new GUIContent(buttonText);
GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButton);
buttonStyle.stretchWidth = false;
var width = MeasureMaxWidth.ForTexts(buttonStyle, buttonText);
Rect rt = GUILayoutUtility.GetRect(
buttonContent,
buttonStyle,
GUILayout.MinWidth(width),
GUILayout.MaxWidth(width));
return GUI.Button(rt, buttonText, 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,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,75 @@
using System;
using System.Reflection;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DrawSearchField
{
internal static void For(
SearchField searchField,
TreeView treeView,
float width)
{
Rect searchFieldRect = GUILayoutUtility.GetRect(
width / 2f, EditorGUIUtility.singleLineHeight);
searchFieldRect.y += 2f;
treeView.searchString = Draw(
searchField,
searchFieldRect,
treeView.searchString);
if (!string.IsNullOrEmpty(treeView.searchString))
return;
GUI.Label(searchFieldRect, PlasticLocalization.GetString(
PlasticLocalization.Name.SearchTooltip), UnityStyles.Search);
}
static string Draw(
SearchField searchField,
Rect searchFieldRect,
string searchString)
{
#if UNITY_2019
if (!mIsToolbarSearchFieldSearched)
{
mIsToolbarSearchFieldSearched = true;
InternalToolbarSearchField = FindToolbarSearchField();
}
if (InternalToolbarSearchField != null)
{
return (string)InternalToolbarSearchField.Invoke(
null,
new object[] { searchFieldRect, searchString, false });
}
#endif
return searchField.OnToolbarGUI(
searchFieldRect, searchString);
}
#if UNITY_2019
static MethodInfo FindToolbarSearchField()
{
return EditorGUIType.GetMethod(
"ToolbarSearchField",
BindingFlags.Static | BindingFlags.NonPublic,
null,
new Type[] { typeof(Rect), typeof(string), typeof(bool) },
null);
}
static bool mIsToolbarSearchFieldSearched;
static MethodInfo InternalToolbarSearchField;
static readonly Type EditorGUIType = typeof(EditorGUI);
#endif
}
}

View file

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

View file

@ -0,0 +1,25 @@
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DrawSplitter
{
internal static void ForHorizontalIndicator()
{
ForWidth(EditorGUIUtility.currentViewWidth);
}
internal static void ForWidth(float width)
{
GUIStyle style = UnityStyles.SplitterIndicator;
Rect splitterRect = GUILayoutUtility.GetRect(
width,
UnityConstants.SPLITTER_INDICATOR_HEIGHT,
style);
GUI.Label(splitterRect, string.Empty, style);
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,78 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DropDownTextField
{
internal static string DoDropDownTextField(
string text,
string controlName,
List<string> dropDownOptions,
GenericMenu.MenuFunction2 optionSelected,
params GUILayoutOption[] options)
{
GUIContent textContent = new GUIContent(text);
Rect textFieldRect = GUILayoutUtility.GetRect(
textContent,
EditorStyles.textField,
options);
return DoDropDownTextField(
text,
controlName,
dropDownOptions,
optionSelected,
textFieldRect);
}
internal static string DoDropDownTextField(
string text,
string controlName,
List<string> dropDownOptions,
GenericMenu.MenuFunction2 optionSelected,
Rect textFieldRect)
{
Texture popupIcon = Images.GetDropDownIcon();
Rect popupButtonRect = new Rect(
textFieldRect.x + textFieldRect.width - BUTTON_WIDTH,
textFieldRect.y,
BUTTON_WIDTH,
textFieldRect.height);
if (GUI.Button(popupButtonRect, string.Empty, EditorStyles.label))
{
GenericMenu menu = new GenericMenu();
foreach (string option in dropDownOptions)
{
menu.AddItem(
new GUIContent(UnityMenuItem.EscapedText(option)),
false,
optionSelected,
option);
}
menu.DropDown(textFieldRect);
}
Rect popupIconRect = new Rect(
popupButtonRect.x,
popupButtonRect.y + UnityConstants.DROPDOWN_ICON_Y_OFFSET,
popupButtonRect.width,
popupButtonRect.height);
GUI.SetNextControlName(controlName);
string result = GUI.TextField(textFieldRect, text);
GUI.Label(popupIconRect, popupIcon);
return result;
}
const int BUTTON_WIDTH = 16;
}
}

View file

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

View file

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

View file

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

View file

@ -0,0 +1,39 @@
using System.Linq;
using System.Reflection;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class EditorProgressBar
{
static EditorProgressBar()
{
var type = typeof(UnityEditor.Editor).Assembly.GetTypes().Where(
t => t.Name == "AsyncProgressBar").FirstOrDefault();
if (type == null)
return;
mDisplayMethod = type.GetMethod("Display");
mClearMethod = type.GetMethod("Clear");
}
internal static void ShowProgressBar(string text, float progress)
{
if (mDisplayMethod == null)
return;
mDisplayMethod.Invoke(null, new object[] { text, progress });
}
internal static void ClearProgressBar()
{
if (mClearMethod == null)
return;
mClearMethod.Invoke(null, null);
}
static MethodInfo mDisplayMethod = null;
static MethodInfo mClearMethod = null;
}
}

View file

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

View file

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

View file

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

View file

@ -0,0 +1,75 @@
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)
{
#if UNITY_2017_1_OR_NEWER
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;
#else
return false;
#endif
}
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 = LogManager.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,14 @@
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class GUISpace
{
internal static void ForToolbar()
{
#if UNITY_2019_1_OR_NEWER
GUILayout.Space(5);
#endif
}
}
}

View file

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

View file

@ -0,0 +1,52 @@
using Codice.Utils;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class GetPlasticShortcut
{
internal static string ForOpen()
{
return PlasticLocalization.GetString(
PlasticLocalization.Name.UnityOpenShortcut);
}
internal static string ForDelete()
{
if (PlatformIdentifier.IsWindows())
return PlasticLocalization.GetString(
PlasticLocalization.Name.UnityDeleteShortcutForWindows);
if (PlatformIdentifier.IsMac())
return PlasticLocalization.GetString(
PlasticLocalization.Name.UnityDeleteShortcutForMacOS);
return string.Empty;
}
internal static string ForDiff()
{
return PlasticLocalization.GetString(
PlasticLocalization.Name.UnityDiffShortcut);
}
internal static string ForAssetDiff()
{
return PlasticLocalization.GetString(
PlasticLocalization.Name.UnityAssetDiffShortcut);
}
internal static string ForHistory()
{
if (PlatformIdentifier.IsWindows())
return PlasticLocalization.GetString(
PlasticLocalization.Name.UnityHistoryShortcutForWindows);
if (PlatformIdentifier.IsMac())
return PlasticLocalization.GetString(
PlasticLocalization.Name.UnityHistoryShortcutForMacOS);
return string.Empty;
}
}
}

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,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,85 @@
using PlasticGui;
using System;
using System.Reflection;
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);
}
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,694 @@
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using Codice.LogWrapper;
using PlasticGui.Help;
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,
XLink,
Ok,
SecondaryTabClose,
SecondaryTabCloseHover,
NotOnDisk,
IconRepository,
IconPlasticView,
IconPlasticViewNotify,
IconPlasticNotifyIncoming,
IconPlasticNotifyConflict,
Loading,
IconEmptyGravatar,
Step1,
Step2,
Step3,
StepOk,
ButtonSsoSignInUnity,
ButtonSsoSignInEmail,
ButtonSsoSignInGoogle,
IconBranch,
IconUndo,
Refresh
}
internal static Texture2D GetHelpImage(HelpImage image)
{
// We use the dark version for both the light/dark skins since it matches the grey background better
string helpImageFileName = string.Format(
"d_{0}.png",
HelpImageName.FromHelpImage(image));
string imageRelativePath = GetImageFileRelativePath(helpImageFileName);
Texture2D result = TryLoadImage(imageRelativePath, imageRelativePath);
if (result != null)
return result;
mLog.WarnFormat("Image not found: {0}", helpImageFileName);
return GetEmptyImage();
}
internal static Texture2D GetImage(Name image)
{
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);
if (result != null)
return result;
result = TryLoadImage(imageFileRelativePath, imageFileRelativePath2x);
if (result != null)
return result;
mLog.WarnFormat("Image not found: {0}", imageFileName);
return GetEmptyImage();
}
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 = GetImage(Name.IconPrivateOverlay);
return mPrivatedOverlayIcon;
}
internal static Texture GetAddedOverlayIcon()
{
if (mAddedOverlayIcon == null)
mAddedOverlayIcon = GetImage(Name.IconAddedOverlay);
return mAddedOverlayIcon;
}
internal static Texture GetDeletedLocalOverlayIcon()
{
if (mDeletedLocalOverlayIcon == null)
mDeletedLocalOverlayIcon = GetImage(Name.IconDeletedLocalOverlay);
return mDeletedLocalOverlayIcon;
}
internal static Texture GetDeletedRemoteOverlayIcon()
{
if (mDeletedRemoteOverlayIcon == null)
mDeletedRemoteOverlayIcon = GetImage(Name.IconDeletedRemoteOverlay);
return mDeletedRemoteOverlayIcon;
}
internal static Texture GetCheckedOutOverlayIcon()
{
if (mCheckedOutOverlayIcon == null)
mCheckedOutOverlayIcon = GetImage(Name.IconCheckedOutLocalOverlay);
return mCheckedOutOverlayIcon;
}
internal static Texture GetOutOfSyncOverlayIcon()
{
if (mOutOfSyncOverlayIcon == null)
mOutOfSyncOverlayIcon = GetImage(Name.IconOutOfSyncOverlay);
return mOutOfSyncOverlayIcon;
}
internal static Texture GetConflictedOverlayIcon()
{
if (mConflictedOverlayIcon == null)
mConflictedOverlayIcon = GetImage(Name.IconConflictedOverlay);
return mConflictedOverlayIcon;
}
internal static Texture GetConflictResolvedOverlayIcon()
{
if (mConflictResolvedOverlayIcon == null)
mConflictResolvedOverlayIcon = GetImage(Name.IconConflictResolvedOverlay);
return mConflictResolvedOverlayIcon;
}
internal static Texture GetLockedLocalOverlayIcon()
{
if (mLockedLocalOverlayIcon == null)
mLockedLocalOverlayIcon = GetImage(Name.IconLockedLocalOverlay);
return mLockedLocalOverlayIcon;
}
internal static Texture GetLockedRemoteOverlayIcon()
{
if (mLockedRemoteOverlayIcon == null)
mLockedRemoteOverlayIcon = GetImage(Name.IconLockedRemoteOverlay);
return mLockedRemoteOverlayIcon;
}
internal static Texture GetIgnoredOverlayIcon()
{
if (mIgnoredverlayIcon == null)
mIgnoredverlayIcon = GetImage(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 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;
}
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 isImageAvailable = File.Exists(Path.GetFullPath(imageFileRelativePath));
if ((EditorGUIUtility.pixelsPerPoint > 1f || !isImageAvailable) && File.Exists(image2xFilePath))
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);
}
byte[] fileData = File.ReadAllBytes(path);
result = new Texture2D(1, 1);
result.LoadImage(fileData); //auto-resizes the texture dimensions
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 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 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 = LogManager.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,8 @@
fileFormatVersion: 2
guid: 505d068a241298242a99aa9dd5b1701e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,46 @@
using UnityEditor;
using UnityEngine;
using Codice.Client.Common;
namespace Unity.PlasticSCM.Editor.UI.Message
{
internal static class DrawDialogIcon
{
internal static void ForMessage(GuiMessage.GuiMessageType alertType)
{
using (new EditorGUILayout.VerticalScope(GUILayout.Width(80)))
{
Rect iconRect = GUILayoutUtility.GetRect(
GUIContent.none, EditorStyles.label,
GUILayout.Width(60), GUILayout.Height(60));
GUI.DrawTexture(
iconRect,
Images.GetPlasticIcon(),
ScaleMode.ScaleToFit);
Rect overlayIconRect = new Rect(
iconRect.xMax - 30, iconRect.yMax - 24, 32, 32);
GUI.DrawTexture(
overlayIconRect,
GetHelpIcon(alertType),
ScaleMode.ScaleToFit);
}
}
static Texture GetHelpIcon(GuiMessage.GuiMessageType alertType)
{
switch (alertType)
{
case GuiMessage.GuiMessageType.Critical:
return Images.GetErrorDialogIcon();
case GuiMessage.GuiMessageType.Warning:
return Images.GetWarnDialogIcon();
default:
return Images.GetInfoDialogIcon();
}
}
}
}

View file

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

View file

@ -0,0 +1,202 @@
using System;
using UnityEditor;
using UnityEngine;
using Codice.Client.Common;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI.Message
{
internal class PlasticQuestionAlert : PlasticDialog
{
protected override Rect DefaultRect
{
get
{
var baseRect = base.DefaultRect;
string buttonsText = mFirst + mSecond + (mThird ?? string.Empty);
int textWidth = (int)((GUIStyle)UnityStyles.Dialog.AcceptButtonText)
.CalcSize(new GUIContent(buttonsText)).x;
return new Rect(
baseRect.x, baseRect.y,
Math.Max(500, textWidth + 150), 180);
}
}
internal static ResponseType Show(
string title,
string message, string first,
string second, string third,
bool isFirstButtonEnabled,
GuiMessage.GuiMessageType alertType,
EditorWindow parentWindow)
{
PlasticQuestionAlert alert = Create(
title, message, first, second, third,
isFirstButtonEnabled, alertType);
return alert.RunModal(parentWindow);
}
protected override void OnModalGUI()
{
DoMessageArea();
GUILayout.FlexibleSpace();
GUILayout.Space(20);
DoButtonsArea();
}
protected override string GetTitle()
{
return PlasticLocalization.GetString(
PlasticLocalization.Name.PlasticSCM);
}
void DoMessageArea()
{
using (new EditorGUILayout.HorizontalScope())
{
DrawDialogIcon.ForMessage(mAlertType);
using (new EditorGUILayout.VerticalScope())
{
GUILayout.Label(mTitle, UnityStyles.Dialog.MessageTitle);
GUIContent message = new GUIContent(mMessage);
Rect lastRect = GUILayoutUtility.GetLastRect();
GUIStyle scrollPlaceholder = new GUIStyle(UnityStyles.Dialog.MessageText);
scrollPlaceholder.normal.textColor = Color.clear;
scrollPlaceholder.clipping = TextClipping.Clip;
if (Event.current.type == EventType.Repaint)
{
mMessageDesiredHeight = ((GUIStyle)UnityStyles.Dialog.MessageText)
.CalcHeight(message, lastRect.width - 20) + 20;
mMessageViewHeight = Mathf.Min(mMessageDesiredHeight, 60);
}
GUILayout.Space(mMessageViewHeight);
Rect scrollPanelRect = new Rect(
lastRect.xMin, lastRect.yMax,
lastRect.width + 20, mMessageViewHeight);
Rect contentRect = new Rect(
scrollPanelRect.xMin,
scrollPanelRect.yMin,
scrollPanelRect.width - 20,
mMessageDesiredHeight);
mScroll = GUI.BeginScrollView(scrollPanelRect, mScroll, contentRect);
GUI.Label(contentRect, mMessage, UnityStyles.Dialog.MessageText);
GUI.EndScrollView();
}
}
}
void DoButtonsArea()
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (Application.platform == RuntimePlatform.WindowsEditor)
{
DoFirstButton();
DoSecondButton();
DoThirdButton();
return;
}
DoThirdButton();
DoSecondButton();
DoFirstButton();
}
}
void DoFirstButton()
{
GUI.enabled = mIsFirstButtonEnabled;
bool pressed = mIsFirstButtonEnabled ?
AcceptButton(mFirst) :
NormalButton(mFirst);
GUI.enabled = true;
if (!pressed)
return;
OkButtonAction();
}
void DoSecondButton()
{
if (!NormalButton(mSecond))
return;
CancelButtonAction();
}
void DoThirdButton()
{
if (mThird == null)
return;
bool pressed = mIsFirstButtonEnabled ?
NormalButton(mThird) :
AcceptButton(mThird);
if (!pressed)
return;
ApplyButtonAction();
}
static PlasticQuestionAlert Create(
string title, string message, string first,
string second, string third, bool isFirstButtonEnabled,
GuiMessage.GuiMessageType alertType)
{
var instance = CreateInstance<PlasticQuestionAlert>();
instance.titleContent = new GUIContent(title);
instance.mTitle = title;
instance.mMessage = message;
instance.mFirst = first;
instance.mSecond = second;
instance.mThird = third;
instance.mIsFirstButtonEnabled = isFirstButtonEnabled;
instance.mAlertType = alertType;
instance.mEnterKeyAction = GetEnterKeyAction(isFirstButtonEnabled, instance);
instance.mEscapeKeyAction = instance.CancelButtonAction;
return instance;
}
static Action GetEnterKeyAction(
bool isFirstButtonEnabled,
PlasticQuestionAlert instance)
{
if (isFirstButtonEnabled)
return instance.OkButtonAction;
return instance.ApplyButtonAction;
}
string mTitle;
string mMessage, mFirst, mSecond, mThird;
bool mIsFirstButtonEnabled;
GuiMessage.GuiMessageType mAlertType;
Vector2 mScroll;
float mMessageDesiredHeight;
float mMessageViewHeight;
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b835f3512ad594c8587c02ae715fc919
timeCreated: 1541005984
licenseType: Free
MonoImporter:
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,411 @@
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 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.PlasticSCM),
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)
{
DrawTextBlockWithEndLink.For(url, 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,
string controlName,
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, '*');
}
}
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 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 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);
}
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;
Dictionary<string, string[]> mWrappedTextLines =
new Dictionary<string, string[]>();
EditorWindow mParentWindow;
protected const float DEFAULT_LINE_SPACING = -5f;
const float DEFAULT_WIDTH = 500f;
const float DEFAULT_HEIGHT = 180f;
const float DEFAULT_PARAGRAPH_SPACING = 10f;
static class BuildLine
{
internal static string ForIndex(string text, int index)
{
if (index < 0 || index > text.Length)
return string.Empty;
return text.Substring(index).Trim();
}
internal static string ForIndexAndLenght(string text, int index, int lenght)
{
if (index < 0 || index > text.Length)
return string.Empty;
return text.Substring(index, lenght);
}
}
}
}

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,66 @@
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI.Progress
{
internal static class DrawProgressForMigration
{
internal static void For(ProgressControlsForMigration.Data data)
{
Rect rect = GUILayoutUtility.GetRect(
GUILayoutUtility.GetLastRect().width, 30);
if (!string.IsNullOrEmpty(data.NotificationMessage))
{
DoNotificationMessage(rect, data.NotificationMessage, data.NotificationType);
return;
}
if (!data.IsOperationRunning)
return;
if (data.ProgressPercent == 0)
{
DoProgressMessage(rect, data.HeaderMessage);
return;
}
DoProgressMessage(rect, data.ProgressMessage);
DoProgressBar(rect, data.HeaderMessage, data.ProgressPercent);
}
static void DoNotificationMessage(
Rect rect,
string notificationMessage,
MessageType notificationType)
{
Rect notificationRect = new Rect(
rect.xMin + 5, rect.yMin + 10, rect.width - 10, 30);
EditorGUI.HelpBox(notificationRect, notificationMessage, notificationType);
}
static void DoProgressMessage(
Rect rect,
string progressMessage)
{
Rect messageRect = new Rect(
rect.xMin + 10, rect.yMin, rect.width - 20, 16);
GUI.Label(messageRect, progressMessage, EditorStyles.miniLabel);
}
static void DoProgressBar(
Rect rect,
string progressMessage,
float progressPercent)
{
Rect messageRect = new Rect(
rect.xMin+10, rect.yMin + 35, rect.width-20, 16);
Rect progresRect = new Rect(
rect.xMin+10, rect.yMin + 27, rect.width-20, 6);
EditorGUI.ProgressBar(progresRect, progressPercent, string.Empty);
GUI.Label(messageRect, progressMessage, EditorStyles.miniLabel);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73eed00edf708bd49a7c2fdfd1a97246
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,99 @@
using UnityEditor;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI.Progress
{
internal class ProgressControlsForMigration
{
internal class Data
{
internal bool IsOperationRunning;
internal float ProgressPercent;
internal string ProgressMessage;
internal string HeaderMessage;
internal MessageType NotificationType;
internal string NotificationMessage;
internal void CopyInto(Data other)
{
other.IsOperationRunning = IsOperationRunning;
other.ProgressPercent = ProgressPercent;
other.ProgressMessage = ProgressMessage;
other.HeaderMessage = HeaderMessage;
other.NotificationType = NotificationType;
other.NotificationMessage = NotificationMessage;
}
}
internal Data ProgressData { get { return mData; } }
internal bool IsOperationRunning()
{
return mData.IsOperationRunning;
}
internal void UpdateDeterminateProgress(EditorWindow parentWindow)
{
if (IsOperationRunning() || mRequestedRepaint)
{
parentWindow.Repaint();
mRequestedRepaint = false;
}
}
internal void HideProgress()
{
HideNotification();
mData.IsOperationRunning = false;
mData.HeaderMessage = string.Empty;
mData.ProgressMessage = string.Empty;
mData.ProgressPercent = 0;
mRequestedRepaint = true;
}
internal void ShowProgress(string header, string message, float progressPercent)
{
HideNotification();
mData.IsOperationRunning = true;
mData.HeaderMessage = header;
mData.ProgressMessage = message;
mData.ProgressPercent = progressPercent;
mRequestedRepaint = true;
}
internal void ShowError(string message)
{
mData.NotificationMessage = message;
mData.NotificationType = MessageType.Error;
mRequestedRepaint = true;
}
internal void ShowSuccess(string message)
{
mData.NotificationMessage = message;
mData.NotificationType = MessageType.Info;
mRequestedRepaint = true;
}
void HideNotification()
{
mData.NotificationMessage = string.Empty;
mData.NotificationType = MessageType.None;
mRequestedRepaint = true;
}
Data mData = new Data();
bool mRequestedRepaint;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9cdff34864f9de54da0012a571b87f78
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,232 @@
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)
{
#if UNITY_2020_1_OR_NEWER
//UnityEngine.UIElements.EventDispatcher.editorDispatcher.PopDispatcherContext();
object editorDispatcher = mEditorDispatcherProp2020.GetValue(null);
mPopContextMethod2020.Invoke(editorDispatcher, null);
#else
// m_Parent.visualTree.panel.dispatcher?.PopDispatcherContext();
object dispatcher = GetDispatcher(window);
if (dispatcher != null)
mPopContextMethod.Invoke(dispatcher, null);
#endif
}
static void PushDispatcherContext(EditorWindow window)
{
#if UNITY_2020_1_OR_NEWER
//UnityEngine.UIElements.EventDispatcher.editorDispatcher.PushDispatcherContext();
object editorDispatcher = mEditorDispatcherProp2020.GetValue(null);
mPushContextMethod2020.Invoke(editorDispatcher, null);
#else
// m_Parent.visualTree.panel.dispatcher?.PushDispatcherContext();
object dispatcher = GetDispatcher(window);
if (dispatcher != null)
mPushContextMethod.Invoke(dispatcher, null);
#endif
}
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);
#if UNITY_2020_1_OR_NEWER
mEditorDispatcherProp2020 = typeof(UnityEngine.UIElements.EventDispatcher).GetProperty("editorDispatcher", flags);
mPushContextMethod2020 = mEditorDispatcherProp2020.PropertyType.GetMethod("PushDispatcherContext", flags);
mPopContextMethod2020 = mEditorDispatcherProp2020.PropertyType.GetMethod("PopDispatcherContext", flags);
#endif
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)
{
if (EditorVersion.IsCurrentEditorOlderThan("2019.3.10f1"))
return typeof(EditorWindow).GetMethod("MakeModal", 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;
#if UNITY_2020_1_OR_NEWER
static PropertyInfo mEditorDispatcherProp2020;
static MethodInfo mPushContextMethod2020;
static MethodInfo mPopContextMethod2020;
#endif
// // 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
// Tooltip = 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,40 @@
using System;
using UnityEditor;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class ShowWindow
{
internal static PlasticWindow Plastic()
{
return ShowPlasticWindow(false);
}
internal static PlasticWindow PlasticAfterDownloadingProject()
{
return ShowPlasticWindow(true);
}
static PlasticWindow ShowPlasticWindow(bool disableCollabWhenLoaded)
{
PlasticWindow window = EditorWindow.GetWindow<PlasticWindow>(
UnityConstants.PLASTIC_WINDOW_TITLE,
true,
mConsoleWindowType,
mProjectBrowserType);
if (disableCollabWhenLoaded)
window.DisableCollabIfEnabledWhenLoaded();
window.SetupWindowTitle(PlasticNotification.Status.None);
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:

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