mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Initial commit
This commit is contained in:
commit
3c7cc0c973
8391 changed files with 704313 additions and 0 deletions
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Collaboration;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEngine.UIElements;
|
||||
#else
|
||||
using UnityEngine.Experimental.UIElements;
|
||||
#endif
|
||||
|
||||
namespace UnityEditor.Collaboration
|
||||
{
|
||||
internal class BuildStatusButton : Button
|
||||
{
|
||||
private readonly string iconPrefix = "Icons/Collab.Build";
|
||||
private readonly string iconSuffix = ".png";
|
||||
Label labelElement = new Label();
|
||||
Image iconElement = new Image() {name = "BuildIcon"};
|
||||
|
||||
public BuildStatusButton(Action clickEvent) : base(clickEvent)
|
||||
{
|
||||
iconElement.image = EditorGUIUtility.Load(iconPrefix + iconSuffix) as Texture;
|
||||
labelElement.text = "Build Now";
|
||||
Add(iconElement);
|
||||
Add(labelElement);
|
||||
}
|
||||
|
||||
public BuildStatusButton(Action clickEvent, BuildState state, int failures) : base(clickEvent)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case BuildState.InProgress:
|
||||
iconElement.image = EditorGUIUtility.Load(iconPrefix + iconSuffix) as Texture;
|
||||
labelElement.text = "In progress";
|
||||
break;
|
||||
|
||||
case BuildState.Failed:
|
||||
iconElement.image = EditorGUIUtility.Load(iconPrefix + "Failed" + iconSuffix) as Texture;
|
||||
labelElement.text = failures + ((failures == 1) ? " failure" : " failures");
|
||||
break;
|
||||
|
||||
case BuildState.Success:
|
||||
iconElement.image = EditorGUIUtility.Load(iconPrefix + "Succeeded" + iconSuffix) as Texture;
|
||||
labelElement.text = "success";
|
||||
break;
|
||||
}
|
||||
|
||||
Add(iconElement);
|
||||
Add(labelElement);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0217a80286f79419daa202f69409f19b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,78 @@
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.Connect;
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEngine.UIElements;
|
||||
#else
|
||||
using UnityEngine.Experimental.UIElements;
|
||||
#endif
|
||||
|
||||
|
||||
namespace UnityEditor.Collaboration
|
||||
{
|
||||
internal class CollabHistoryDropDown : VisualElement
|
||||
{
|
||||
private readonly VisualElement m_FilesContainer;
|
||||
private readonly Label m_ToggleLabel;
|
||||
private int m_ChangesTotal;
|
||||
private string m_RevisionId;
|
||||
|
||||
public CollabHistoryDropDown(ICollection<ChangeData> changes, int changesTotal, bool changesTruncated, string revisionId)
|
||||
{
|
||||
m_FilesContainer = new VisualElement();
|
||||
m_ChangesTotal = changesTotal;
|
||||
m_RevisionId = revisionId;
|
||||
|
||||
m_ToggleLabel = new Label(ToggleText(false));
|
||||
m_ToggleLabel.AddManipulator(new Clickable(ToggleDropdown));
|
||||
Add(m_ToggleLabel);
|
||||
|
||||
foreach (ChangeData change in changes)
|
||||
{
|
||||
m_FilesContainer.Add(new CollabHistoryDropDownItem(change.path, change.action));
|
||||
}
|
||||
|
||||
if (changesTruncated)
|
||||
{
|
||||
m_FilesContainer.Add(new Button(ShowAllClick)
|
||||
{
|
||||
text = "Show all on dashboard"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleDropdown()
|
||||
{
|
||||
if (Contains(m_FilesContainer))
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "CollapseAssets");
|
||||
Remove(m_FilesContainer);
|
||||
m_ToggleLabel.text = ToggleText(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "ExpandAssets");
|
||||
Add(m_FilesContainer);
|
||||
m_ToggleLabel.text = ToggleText(true);
|
||||
}
|
||||
}
|
||||
|
||||
private string ToggleText(bool open)
|
||||
{
|
||||
var icon = open ? "\u25bc" : "\u25b6";
|
||||
var change = m_ChangesTotal == 1 ? "Change" : "Changes";
|
||||
return string.Format("{0} {1} Asset {2}", icon, m_ChangesTotal, change);
|
||||
}
|
||||
|
||||
private void ShowAllClick()
|
||||
{
|
||||
var host = UnityConnect.instance.GetConfigurationURL(CloudConfigUrl.CloudServicesDashboard);
|
||||
var org = UnityConnect.instance.GetOrganizationId();
|
||||
var proj = UnityConnect.instance.GetProjectGUID();
|
||||
var url = string.Format("{0}/collab/orgs/{1}/projects/{2}/commits?commit={3}", host, org, proj, m_RevisionId);
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "ShowAllOnDashboard");
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a483595b0257945278dc75c5ff7d82ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEngine.UIElements;
|
||||
#else
|
||||
using UnityEngine.Experimental.UIElements;
|
||||
#endif
|
||||
|
||||
|
||||
namespace UnityEditor.Collaboration
|
||||
{
|
||||
internal class CollabHistoryDropDownItem : VisualElement
|
||||
{
|
||||
public CollabHistoryDropDownItem(string path, string action)
|
||||
{
|
||||
var fileName = Path.GetFileName(path);
|
||||
var isFolder = Path.GetFileNameWithoutExtension(path).Equals(fileName);
|
||||
var fileIcon = GetIconElement(action, fileName, isFolder);
|
||||
var metaContainer = new VisualElement();
|
||||
var fileNameLabel = new Label
|
||||
{
|
||||
name = "FileName",
|
||||
text = fileName
|
||||
};
|
||||
var filePathLabel = new Label
|
||||
{
|
||||
name = "FilePath",
|
||||
text = path
|
||||
};
|
||||
metaContainer.Add(fileNameLabel);
|
||||
metaContainer.Add(filePathLabel);
|
||||
Add(fileIcon);
|
||||
Add(metaContainer);
|
||||
}
|
||||
|
||||
private Image GetIconElement(string action, string fileName, bool isFolder)
|
||||
{
|
||||
var prefix = isFolder ? "Folder" : "File";
|
||||
var actionName = action.First().ToString().ToUpper() + action.Substring(1);
|
||||
// Use the same icon for renamed and moved files
|
||||
actionName = actionName.Equals("Renamed") ? "Moved" : actionName;
|
||||
var iconElement = new Image
|
||||
{
|
||||
name = "FileIcon",
|
||||
image = EditorGUIUtility.LoadIcon("Icons/Collab." + prefix + actionName + ".png")
|
||||
};
|
||||
return iconElement;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d912d4873af534bd4a9d44bf1b52f14e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,229 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using UnityEditor.Connect;
|
||||
using UnityEditor.Web;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEngine.UIElements;
|
||||
#else
|
||||
using UnityEngine.Experimental.UIElements;
|
||||
using UnityEngine.Experimental.UIElements.StyleEnums;
|
||||
#endif
|
||||
|
||||
namespace UnityEditor.Collaboration
|
||||
{
|
||||
internal class CollabHistoryItem : VisualElement
|
||||
{
|
||||
public static RevisionAction s_OnRestore;
|
||||
public static RevisionAction s_OnGoBack;
|
||||
public static RevisionAction s_OnUpdate;
|
||||
public static ShowBuildAction s_OnShowBuild;
|
||||
public static Action s_OnShowServices;
|
||||
|
||||
private readonly string m_RevisionId;
|
||||
private readonly string m_FullDescription;
|
||||
private readonly DateTime m_TimeStamp;
|
||||
private readonly Button m_Button;
|
||||
private readonly HistoryProgressSpinner m_ProgressSpinner;
|
||||
private VisualElement m_ActionsTray;
|
||||
private VisualElement m_Details;
|
||||
private Label m_Description;
|
||||
private Label m_TimeAgo;
|
||||
private readonly Button m_ExpandCollapseButton;
|
||||
private bool m_Expanded;
|
||||
|
||||
private const int kMaxDescriptionChars = 500;
|
||||
|
||||
public bool RevisionActionsEnabled
|
||||
{
|
||||
set
|
||||
{
|
||||
m_Button.SetEnabled(value);
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime timeStamp
|
||||
{
|
||||
get { return m_TimeStamp; }
|
||||
}
|
||||
|
||||
public CollabHistoryItem(RevisionData data)
|
||||
{
|
||||
m_RevisionId = data.id;
|
||||
m_TimeStamp = data.timeStamp;
|
||||
name = "HistoryItem";
|
||||
m_ActionsTray = new VisualElement {name = "HistoryItemActionsTray"};
|
||||
m_ProgressSpinner = new HistoryProgressSpinner();
|
||||
m_Details = new VisualElement {name = "HistoryDetail"};
|
||||
var author = new Label(data.authorName) {name = "Author"};
|
||||
m_TimeAgo = new Label(TimeAgo.GetString(m_TimeStamp));
|
||||
m_FullDescription = data.comment;
|
||||
var shouldTruncate = ShouldTruncateDescription(m_FullDescription);
|
||||
if (shouldTruncate)
|
||||
{
|
||||
m_Description = new Label(GetTruncatedDescription(m_FullDescription));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Description = new Label(m_FullDescription);
|
||||
}
|
||||
m_Description.name = "RevisionDescription";
|
||||
var dropdown = new CollabHistoryDropDown(data.changes, data.changesTotal, data.changesTruncated, data.id);
|
||||
if (data.current)
|
||||
{
|
||||
m_Button = new Button(Restore) {name = "ActionButton", text = "Restore"};
|
||||
}
|
||||
else if (data.obtained)
|
||||
{
|
||||
m_Button = new Button(GoBackTo) {name = "ActionButton", text = "Go back to..."};
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Button = new Button(UpdateTo) {name = "ActionButton", text = "Update"};
|
||||
}
|
||||
m_Button.SetEnabled(data.enabled);
|
||||
m_ProgressSpinner.ProgressEnabled = data.inProgress;
|
||||
|
||||
m_ActionsTray.Add(m_ProgressSpinner);
|
||||
m_ActionsTray.Add(m_Button);
|
||||
|
||||
m_Details.Add(author);
|
||||
m_Details.Add(m_TimeAgo);
|
||||
m_Details.Add(m_Description);
|
||||
|
||||
if (shouldTruncate)
|
||||
{
|
||||
m_ExpandCollapseButton = new Button(ToggleDescription) { name = "ToggleDescription", text = "Show More" };
|
||||
m_Details.Add(m_ExpandCollapseButton);
|
||||
}
|
||||
|
||||
if (data.buildState != BuildState.None)
|
||||
{
|
||||
BuildStatusButton buildButton;
|
||||
if (data.buildState == BuildState.Configure)
|
||||
buildButton = new BuildStatusButton(ShowServicePage);
|
||||
else
|
||||
buildButton = new BuildStatusButton(ShowBuildForCommit, data.buildState, data.buildFailures);
|
||||
|
||||
m_Details.Add(buildButton);
|
||||
}
|
||||
|
||||
m_Details.Add(m_ActionsTray);
|
||||
m_Details.Add(dropdown);
|
||||
|
||||
Add(m_Details);
|
||||
|
||||
this.schedule.Execute(UpdateTimeAgo).Every(1000 * 20);
|
||||
}
|
||||
|
||||
public static void SetUpCallbacks(RevisionAction Restore, RevisionAction GoBack, RevisionAction Update)
|
||||
{
|
||||
s_OnRestore = Restore;
|
||||
s_OnGoBack = GoBack;
|
||||
s_OnUpdate = Update;
|
||||
}
|
||||
|
||||
public void SetInProgressStatus(string revisionIdInProgress)
|
||||
{
|
||||
if (String.IsNullOrEmpty(revisionIdInProgress))
|
||||
{
|
||||
m_Button.SetEnabled(true);
|
||||
m_ProgressSpinner.ProgressEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Button.SetEnabled(false);
|
||||
if (m_RevisionId.Equals(revisionIdInProgress))
|
||||
{
|
||||
m_ProgressSpinner.ProgressEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShowBuildForCommit()
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "ShowBuild");
|
||||
if (s_OnShowBuild != null)
|
||||
{
|
||||
s_OnShowBuild(m_RevisionId);
|
||||
}
|
||||
}
|
||||
|
||||
void ShowServicePage()
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "ShowServices");
|
||||
if (s_OnShowServices != null)
|
||||
{
|
||||
s_OnShowServices();
|
||||
}
|
||||
}
|
||||
|
||||
void Restore()
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "Restore");
|
||||
if (s_OnRestore != null)
|
||||
{
|
||||
s_OnRestore(m_RevisionId, false);
|
||||
}
|
||||
}
|
||||
|
||||
void GoBackTo()
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "GoBackTo");
|
||||
if (s_OnGoBack != null)
|
||||
{
|
||||
s_OnGoBack(m_RevisionId, false);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateTo()
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "Update");
|
||||
if (s_OnUpdate != null)
|
||||
{
|
||||
s_OnUpdate(m_RevisionId, true);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateTimeAgo()
|
||||
{
|
||||
m_TimeAgo.text = TimeAgo.GetString(m_TimeStamp);
|
||||
}
|
||||
|
||||
bool ShouldTruncateDescription(string description)
|
||||
{
|
||||
return description.Contains(Environment.NewLine) || description.Length > kMaxDescriptionChars;
|
||||
}
|
||||
|
||||
string GetTruncatedDescription(string description)
|
||||
{
|
||||
string result = description.Contains(Environment.NewLine) ?
|
||||
description.Substring(0, description.IndexOf(Environment.NewLine)) : description;
|
||||
if (result.Length > kMaxDescriptionChars)
|
||||
{
|
||||
result = result.Substring(0, kMaxDescriptionChars) + "...";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void ToggleDescription()
|
||||
{
|
||||
if (m_Expanded)
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "CollapseDescription");
|
||||
m_Expanded = false;
|
||||
m_ExpandCollapseButton.text = "Show More";
|
||||
m_Description.text = GetTruncatedDescription(m_FullDescription);
|
||||
}
|
||||
else
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "ExpandDescription");
|
||||
m_Expanded = true;
|
||||
m_ExpandCollapseButton.text = "Show Less";
|
||||
m_Description.text = m_FullDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c4c1445ee948a4124bfa9fb818a17e36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,121 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor.Collaboration;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEngine.UIElements;
|
||||
#else
|
||||
using UnityEngine.Experimental.UIElements;
|
||||
using UnityEngine.Experimental.UIElements.StyleEnums;
|
||||
#endif
|
||||
|
||||
|
||||
namespace UnityEditor.Collaboration
|
||||
{
|
||||
internal class CollabHistoryItemFactory : ICollabHistoryItemFactory
|
||||
{
|
||||
const int k_MaxChangesPerRevision = 10;
|
||||
|
||||
public IEnumerable<RevisionData> GenerateElements(IEnumerable<Revision> revisions, int totalRevisions, int startIndex, string tipRev, string inProgressRevision, bool revisionActionsEnabled, bool buildServiceEnabled, string currentUser)
|
||||
{
|
||||
int index = startIndex;
|
||||
|
||||
foreach (var rev in revisions)
|
||||
{
|
||||
index++;
|
||||
var current = rev.revisionID == tipRev;
|
||||
|
||||
// Calculate build status
|
||||
BuildState buildState = BuildState.None;
|
||||
int buildFailures = 0;
|
||||
if (rev.buildStatuses != null && rev.buildStatuses.Length > 0)
|
||||
{
|
||||
bool inProgress = false;
|
||||
foreach (CloudBuildStatus buildStatus in rev.buildStatuses)
|
||||
{
|
||||
if (buildStatus.complete)
|
||||
{
|
||||
if (!buildStatus.success)
|
||||
{
|
||||
buildFailures++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
inProgress = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (inProgress)
|
||||
{
|
||||
buildState = BuildState.InProgress;
|
||||
}
|
||||
else if (buildFailures > 0)
|
||||
{
|
||||
buildState = BuildState.Failed;
|
||||
}
|
||||
else
|
||||
{
|
||||
buildState = BuildState.Success;
|
||||
}
|
||||
}
|
||||
else if (current && !buildServiceEnabled)
|
||||
{
|
||||
buildState = BuildState.Configure;
|
||||
}
|
||||
|
||||
// Calculate the number of changes performed on files and folders (not meta files)
|
||||
var paths = new Dictionary<string, ChangeData>();
|
||||
foreach (ChangeAction change in rev.entries)
|
||||
{
|
||||
if (change.path.EndsWith(".meta"))
|
||||
{
|
||||
var path = change.path.Substring(0, change.path.Length - 5);
|
||||
// Actions taken on meta files are secondary to any actions taken on the main file
|
||||
if (!paths.ContainsKey(path))
|
||||
paths[path] = new ChangeData() {path = path, action = change.action};
|
||||
}
|
||||
else
|
||||
{
|
||||
paths[change.path] = new ChangeData() {path = change.path, action = change.action};
|
||||
}
|
||||
}
|
||||
|
||||
var displayName = (rev.author != currentUser) ? rev.authorName : "You";
|
||||
|
||||
var item = new RevisionData
|
||||
{
|
||||
id = rev.revisionID,
|
||||
index = totalRevisions - index + 1,
|
||||
timeStamp = TimeStampToDateTime(rev.timeStamp),
|
||||
authorName = displayName,
|
||||
comment = rev.comment,
|
||||
|
||||
obtained = rev.isObtained,
|
||||
current = current,
|
||||
inProgress = (rev.revisionID == inProgressRevision),
|
||||
enabled = revisionActionsEnabled,
|
||||
|
||||
buildState = buildState,
|
||||
buildFailures = buildFailures,
|
||||
|
||||
changes = paths.Values.Take(k_MaxChangesPerRevision).ToList(),
|
||||
changesTotal = paths.Values.Count,
|
||||
changesTruncated = paths.Values.Count > k_MaxChangesPerRevision,
|
||||
};
|
||||
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
|
||||
private static DateTime TimeStampToDateTime(double timeStamp)
|
||||
{
|
||||
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
dateTime = dateTime.AddSeconds(timeStamp).ToLocalTime();
|
||||
return dateTime;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fc46f91ea1e8e4ca2ab693fef9156dbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Collaboration;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEngine.UIElements;
|
||||
#else
|
||||
using UnityEngine.Experimental.UIElements;
|
||||
#endif
|
||||
|
||||
namespace UnityEditor.Collaboration
|
||||
{
|
||||
internal class CollabHistoryRevisionLine : VisualElement
|
||||
{
|
||||
public CollabHistoryRevisionLine(int number)
|
||||
{
|
||||
AddNumber(number);
|
||||
AddLine("topLine");
|
||||
AddLine("bottomLine");
|
||||
AddIndicator();
|
||||
}
|
||||
|
||||
public CollabHistoryRevisionLine(DateTime date, bool isFullDateObtained)
|
||||
{
|
||||
AddLine(isFullDateObtained ? "obtainedDateLine" : "absentDateLine");
|
||||
AddHeader(GetFormattedHeader(date));
|
||||
AddToClassList("revisionLineHeader");
|
||||
}
|
||||
|
||||
private void AddHeader(string content)
|
||||
{
|
||||
Add(new Label
|
||||
{
|
||||
text = content
|
||||
});
|
||||
}
|
||||
|
||||
private void AddIndicator()
|
||||
{
|
||||
Add(new VisualElement
|
||||
{
|
||||
name = "RevisionIndicator"
|
||||
});
|
||||
}
|
||||
|
||||
private void AddLine(string className = null)
|
||||
{
|
||||
var line = new VisualElement
|
||||
{
|
||||
name = "RevisionLine"
|
||||
};
|
||||
if (!String.IsNullOrEmpty(className))
|
||||
{
|
||||
line.AddToClassList(className);
|
||||
}
|
||||
Add(line);
|
||||
}
|
||||
|
||||
private void AddNumber(int number)
|
||||
{
|
||||
Add(new Label
|
||||
{
|
||||
text = number.ToString(),
|
||||
name = "RevisionIndex"
|
||||
});
|
||||
}
|
||||
|
||||
private string GetFormattedHeader(DateTime date)
|
||||
{
|
||||
string result = "Commits on " + date.ToString("MMM d");
|
||||
switch (date.Day)
|
||||
{
|
||||
case 1:
|
||||
case 21:
|
||||
case 31:
|
||||
result += "st";
|
||||
break;
|
||||
case 2:
|
||||
case 22:
|
||||
result += "nd";
|
||||
break;
|
||||
case 3:
|
||||
case 23:
|
||||
result += "rd";
|
||||
break;
|
||||
default:
|
||||
result += "th";
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3c737f7a9d78541d1ab25f28f045dd32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,69 @@
|
|||
using UnityEngine;
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEngine.UIElements;
|
||||
#else
|
||||
using UnityEngine.Experimental.UIElements;
|
||||
#endif
|
||||
|
||||
namespace UnityEditor.Collaboration
|
||||
{
|
||||
internal class HistoryProgressSpinner : Image
|
||||
{
|
||||
private readonly Texture2D[] m_StatusWheelTextures;
|
||||
private bool m_ProgressEnabled;
|
||||
private IVisualElementScheduledItem m_Animation;
|
||||
|
||||
public bool ProgressEnabled
|
||||
{
|
||||
set
|
||||
{
|
||||
if (m_ProgressEnabled == value)
|
||||
return;
|
||||
|
||||
m_ProgressEnabled = value;
|
||||
visible = value;
|
||||
|
||||
|
||||
if (value)
|
||||
{
|
||||
if (m_Animation == null)
|
||||
{
|
||||
m_Animation = this.schedule.Execute(AnimateProgress).Every(33);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Animation.Resume();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Animation != null)
|
||||
{
|
||||
m_Animation.Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HistoryProgressSpinner()
|
||||
{
|
||||
m_StatusWheelTextures = new Texture2D[12];
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
m_StatusWheelTextures[i] = EditorGUIUtility.LoadIcon("WaitSpin" + i.ToString("00"));
|
||||
}
|
||||
image = m_StatusWheelTextures[0];
|
||||
style.width = m_StatusWheelTextures[0].width;
|
||||
style.height = m_StatusWheelTextures[0].height;
|
||||
visible = false;
|
||||
}
|
||||
|
||||
private void AnimateProgress(TimerState obj)
|
||||
{
|
||||
int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f);
|
||||
image = m_StatusWheelTextures[frame];
|
||||
MarkDirtyRepaint();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cf6aca931950a4a6a886e214e9e649c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.Collaboration;
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEngine.UIElements;
|
||||
#else
|
||||
using UnityEngine.Experimental.UIElements;
|
||||
#endif
|
||||
|
||||
namespace UnityEditor.Collaboration
|
||||
{
|
||||
internal interface ICollabHistoryItemFactory
|
||||
{
|
||||
IEnumerable<RevisionData> GenerateElements(IEnumerable<Revision> revsRevisions, int mTotalRevisions, int startIndex, string tipRev, string inProgressRevision, bool revisionActionsEnabled, bool buildServiceEnabled, string currentUser);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 821f5482c5a3f4389885f4432433f56f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,192 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEngine.UIElements;
|
||||
#else
|
||||
using UnityEngine.Experimental.UIElements;
|
||||
using UnityEngine.Experimental.UIElements.StyleEnums;
|
||||
#endif
|
||||
|
||||
namespace UnityEditor.Collaboration
|
||||
{
|
||||
internal interface IPagerData
|
||||
{
|
||||
int curPage { get; }
|
||||
int totalPages { get; }
|
||||
PageChangeAction OnPageChanged { get; }
|
||||
}
|
||||
|
||||
internal class PagerElement : VisualElement
|
||||
{
|
||||
IPagerData m_Data;
|
||||
readonly Label m_PageText;
|
||||
readonly Button m_DownButton;
|
||||
readonly Button m_UpButton;
|
||||
|
||||
public PagerElement(IPagerData dataSource)
|
||||
{
|
||||
m_Data = dataSource;
|
||||
|
||||
this.style.flexDirection = FlexDirection.Row;
|
||||
this.style.alignSelf = Align.Center;
|
||||
|
||||
Add(m_DownButton = new Button(OnPageDownClicked) {text = "\u25c5 Newer"});
|
||||
m_DownButton.AddToClassList("PagerDown");
|
||||
|
||||
m_PageText = new Label();
|
||||
m_PageText.AddToClassList("PagerLabel");
|
||||
Add(m_PageText);
|
||||
|
||||
Add(m_UpButton = new Button(OnPageUpClicked) {text = "Older \u25bb"});
|
||||
m_UpButton.AddToClassList("PagerUp");
|
||||
|
||||
UpdateControls();
|
||||
}
|
||||
|
||||
void OnPageDownClicked()
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "NewerPage");
|
||||
m_Data.OnPageChanged(m_Data.curPage - 1);
|
||||
}
|
||||
|
||||
void OnPageUpClicked()
|
||||
{
|
||||
CollabAnalytics.SendUserAction(CollabAnalytics.historyCategoryString, "OlderPage");
|
||||
m_Data.OnPageChanged(m_Data.curPage + 1);
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
UpdateControls();
|
||||
}
|
||||
|
||||
void UpdateControls()
|
||||
{
|
||||
var curPage = m_Data.curPage;
|
||||
var totalPages = m_Data.totalPages;
|
||||
|
||||
m_PageText.text = (curPage + 1) + " / " + totalPages;
|
||||
m_DownButton.SetEnabled(curPage > 0);
|
||||
m_UpButton.SetEnabled(curPage < totalPages - 1);
|
||||
}
|
||||
}
|
||||
|
||||
internal enum PagerLocation
|
||||
{
|
||||
Top,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
internal class PagedListView : VisualElement, IPagerData
|
||||
{
|
||||
public const int DefaultItemsPerPage = 10;
|
||||
|
||||
readonly VisualElement m_ItemContainer;
|
||||
readonly PagerElement m_PagerTop, m_PagerBottom;
|
||||
int m_PageSize = DefaultItemsPerPage;
|
||||
IEnumerable<VisualElement> m_Items;
|
||||
int m_TotalItems;
|
||||
int m_CurPage;
|
||||
|
||||
public int pageSize
|
||||
{
|
||||
set { m_PageSize = value; }
|
||||
}
|
||||
|
||||
public IEnumerable<VisualElement> items
|
||||
{
|
||||
set
|
||||
{
|
||||
m_Items = value;
|
||||
LayoutItems();
|
||||
}
|
||||
}
|
||||
|
||||
public int totalItems
|
||||
{
|
||||
set
|
||||
{
|
||||
if (m_TotalItems == value)
|
||||
return;
|
||||
|
||||
m_TotalItems = value;
|
||||
UpdatePager();
|
||||
}
|
||||
}
|
||||
|
||||
public PageChangeAction OnPageChanged { get; set; }
|
||||
|
||||
public PagedListView()
|
||||
{
|
||||
m_PagerTop = new PagerElement(this);
|
||||
|
||||
m_ItemContainer = new VisualElement()
|
||||
{
|
||||
name = "PagerItems",
|
||||
};
|
||||
Add(m_ItemContainer);
|
||||
m_Items = new List<VisualElement>();
|
||||
|
||||
m_PagerBottom = new PagerElement(this);
|
||||
}
|
||||
|
||||
void LayoutItems()
|
||||
{
|
||||
m_ItemContainer.Clear();
|
||||
foreach (var item in m_Items)
|
||||
{
|
||||
m_ItemContainer.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdatePager()
|
||||
{
|
||||
if (m_PagerTop.parent != this && totalPages > 1 && curPage > 0)
|
||||
Insert(0, m_PagerTop);
|
||||
if (m_PagerTop.parent == this && (totalPages <= 1 || curPage == 0))
|
||||
Remove(m_PagerTop);
|
||||
|
||||
if (m_PagerBottom.parent != this && totalPages > 1)
|
||||
Add(m_PagerBottom);
|
||||
if (m_PagerBottom.parent == this && totalPages <= 1)
|
||||
Remove(m_PagerBottom);
|
||||
|
||||
m_PagerTop.Refresh();
|
||||
m_PagerBottom.Refresh();
|
||||
}
|
||||
|
||||
int pageCount
|
||||
{
|
||||
get
|
||||
{
|
||||
var pages = m_TotalItems / m_PageSize;
|
||||
if (m_TotalItems % m_PageSize > 0)
|
||||
pages++;
|
||||
|
||||
return pages;
|
||||
}
|
||||
}
|
||||
|
||||
public int curPage
|
||||
{
|
||||
get { return m_CurPage; }
|
||||
set
|
||||
{
|
||||
m_CurPage = value;
|
||||
UpdatePager();
|
||||
}
|
||||
}
|
||||
|
||||
public int totalPages
|
||||
{
|
||||
get
|
||||
{
|
||||
var extraPage = 0;
|
||||
if (m_TotalItems % m_PageSize > 0)
|
||||
extraPage = 1;
|
||||
return m_TotalItems / m_PageSize + extraPage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 50de529b6a28f4a7093045e08810a5df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEngine.UIElements;
|
||||
#else
|
||||
using UnityEngine.Experimental.UIElements;
|
||||
using UnityEngine.Experimental.UIElements.StyleEnums;
|
||||
#endif
|
||||
|
||||
namespace UnityEditor.Collaboration
|
||||
{
|
||||
internal class StatusView : VisualElement
|
||||
{
|
||||
Image m_Image;
|
||||
Label m_Message;
|
||||
Button m_Button;
|
||||
Action m_Callback;
|
||||
|
||||
public Texture icon
|
||||
{
|
||||
get { return m_Image.image; }
|
||||
set
|
||||
{
|
||||
m_Image.image = value;
|
||||
m_Image.visible = value != null;
|
||||
// Until "display: hidden" is added, this is the only way to hide an element
|
||||
m_Image.style.height = value != null ? 150 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public string message
|
||||
{
|
||||
get { return m_Message.text; }
|
||||
set
|
||||
{
|
||||
m_Message.text = value;
|
||||
m_Message.visible = value != null;
|
||||
}
|
||||
}
|
||||
|
||||
public string buttonText
|
||||
{
|
||||
get { return m_Button.text; }
|
||||
set
|
||||
{
|
||||
m_Button.text = value;
|
||||
UpdateButton();
|
||||
}
|
||||
}
|
||||
|
||||
public Action callback
|
||||
{
|
||||
get { return m_Callback; }
|
||||
set
|
||||
{
|
||||
m_Callback = value;
|
||||
UpdateButton();
|
||||
}
|
||||
}
|
||||
|
||||
public StatusView()
|
||||
{
|
||||
name = "StatusView";
|
||||
|
||||
this.StretchToParentSize();
|
||||
|
||||
m_Image = new Image() { name = "StatusIcon", visible = false, style = { height = 0f }};
|
||||
m_Message = new Label() { name = "StatusMessage", visible = false};
|
||||
m_Button = new Button(InternalCallaback) { name = "StatusButton", visible = false};
|
||||
|
||||
Add(m_Image);
|
||||
Add(m_Message);
|
||||
Add(m_Button);
|
||||
}
|
||||
|
||||
private void UpdateButton()
|
||||
{
|
||||
m_Button.visible = m_Button.text != null && m_Callback != null;
|
||||
}
|
||||
|
||||
private void InternalCallaback()
|
||||
{
|
||||
m_Callback();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 08e9894bdf0834710b22d3c0aa245ac0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue