first commit
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c32dc56ff6d08947a329b5c4789c728
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73eed00edf708bd49a7c2fdfd1a97246
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa1cd36edf652db46b5fa11c2ed355b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab0090fd6aa8c604a828244d4ba93c84
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e858d866b71d5245b9b869476a487f1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa3f399d17e1dcf4c9e417ffce5eb905
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cdff34864f9de54da0012a571b87f78
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2837297e95f28c44eb67b93417fce9d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user