first commit
This commit is contained in:
@@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common;
|
||||
using Codice.CM.Client.Differences;
|
||||
using Codice.CM.Client.Differences.Merge;
|
||||
using MergetoolGui;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Settings
|
||||
{
|
||||
class DiffAndMergeOptionsFoldout
|
||||
{
|
||||
internal void OnActivate()
|
||||
{
|
||||
PlasticGuiConfigData data = PlasticGuiConfig.Get().Configuration;
|
||||
|
||||
mComparisonMethodSelectedIndex = ComparisonMethod.GetTypeIndexFromString(data.ComparisonMethod);
|
||||
mDefaultEncodingSelectedIndex = Array.IndexOf(mEncodingValues, data.Encoding);
|
||||
mResultEncodingSelectedIndex = Array.IndexOf(mEncodingValues, data.ResultEncoding);
|
||||
|
||||
mManualConflictResolution = data.MergeResolutionType == MergeResolutionType.OnlyOne.ToString();
|
||||
mAutomaticConflictResolution = !mManualConflictResolution;
|
||||
|
||||
mCloseMergeView = data.CloseMergeAndOpenPendingChanges;
|
||||
mMergeWithChanges = ClientConfig.Get().MergeWithPendingChanges();
|
||||
}
|
||||
|
||||
internal void OnDeactivate()
|
||||
{
|
||||
PlasticGuiConfigData guiConfigData = PlasticGuiConfig.Get().Configuration;
|
||||
|
||||
guiConfigData.ComparisonMethod = ComparisonMethod.GetStringFromTypeIndex(mComparisonMethodSelectedIndex);
|
||||
guiConfigData.Encoding = GetEncodingValue(mDefaultEncodingSelectedIndex);
|
||||
guiConfigData.ResultEncoding = GetEncodingValue(mResultEncodingSelectedIndex);
|
||||
|
||||
guiConfigData.MergeResolutionType = mAutomaticConflictResolution ?
|
||||
MergeResolutionType.Forced.ToString() : MergeResolutionType.OnlyOne.ToString();
|
||||
|
||||
guiConfigData.CloseMergeAndOpenPendingChanges = mCloseMergeView;
|
||||
|
||||
ClientConfigData configData = ClientConfig.Get().GetClientConfigData();
|
||||
configData.SetMergeWithPendingChanges(mMergeWithChanges);
|
||||
|
||||
ClientConfig.Get().Save(configData);
|
||||
PlasticGuiConfig.Get().Save();
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
DrawSplitter.ForWidth(UnityConstants.SETTINGS_GUI_WIDTH);
|
||||
|
||||
DrawSettingsSection(DoDiffAndMergePreferences);
|
||||
}
|
||||
|
||||
internal void SelectComparisonMethodForTesting(ComparisonMethodTypes comparisonMethod)
|
||||
{
|
||||
mComparisonMethodSelectedIndex = (int)comparisonMethod;
|
||||
}
|
||||
|
||||
internal void SelectDefaultEncodingForTesting(string defaultEncoding)
|
||||
{
|
||||
mDefaultEncodingSelectedIndex = Array.IndexOf(mEncodingValues, defaultEncoding);
|
||||
}
|
||||
|
||||
internal void SelectResultEncodingForTesting(string resultEncoding)
|
||||
{
|
||||
mResultEncodingSelectedIndex = Array.IndexOf(mEncodingValues, resultEncoding);
|
||||
}
|
||||
|
||||
internal void AutomaticConflictResolutionRadioButtonRaiseCheckedForTesting()
|
||||
{
|
||||
mAutomaticConflictResolution = true;
|
||||
mManualConflictResolution = false;
|
||||
}
|
||||
|
||||
internal void ManualConflictResolutionRadioButtonRaiseCheckedForTesting()
|
||||
{
|
||||
mManualConflictResolution = true;
|
||||
mAutomaticConflictResolution = false;
|
||||
}
|
||||
|
||||
internal void CloseMergeViewCheckboxRaiseCheckedForTesting()
|
||||
{
|
||||
mCloseMergeView = true;
|
||||
}
|
||||
|
||||
internal void CloseMergeViewCheckboxRaiseUncheckedForTesting()
|
||||
{
|
||||
mCloseMergeView = false;
|
||||
}
|
||||
|
||||
internal void MergeWithChangesCheckBoxRaiseCheckedForTesting()
|
||||
{
|
||||
mMergeWithChanges = true;
|
||||
}
|
||||
|
||||
internal void MergeWithChangesCheckBoxRaiseUncheckedForTesting()
|
||||
{
|
||||
mMergeWithChanges = false;
|
||||
}
|
||||
|
||||
void DoDiffAndMergePreferences()
|
||||
{
|
||||
DoComparisonMethodAndEncodingSettings();
|
||||
|
||||
DoMergeConflictResolutionSettings();
|
||||
|
||||
DoMergeViewBehaviorSettings();
|
||||
}
|
||||
|
||||
void DoComparisonMethodAndEncodingSettings()
|
||||
{
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.Name.ComparisonMethodAndEncodingTitle.GetString(),
|
||||
UnityStyles.ProjectSettings.SectionTitle);
|
||||
|
||||
mComparisonMethodSelectedIndex = EditorGUILayout.Popup(
|
||||
PlasticLocalization.Name.ComparisonMethod.GetString(),
|
||||
mComparisonMethodSelectedIndex,
|
||||
mComparisonMethods);
|
||||
|
||||
mDefaultEncodingSelectedIndex = EditorGUILayout.Popup(
|
||||
MergetoolLocalization.Name.DefaultEncoding.GetString(),
|
||||
mDefaultEncodingSelectedIndex,
|
||||
mEncodingValuesToDisplay);
|
||||
|
||||
mResultEncodingSelectedIndex = EditorGUILayout.Popup(
|
||||
MergetoolLocalization.Name.ResultEncoding.GetString(),
|
||||
mResultEncodingSelectedIndex,
|
||||
mEncodingValuesToDisplay);
|
||||
}
|
||||
|
||||
void DoMergeConflictResolutionSettings()
|
||||
{
|
||||
EditorGUILayout.Space(10);
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.Name.ConflictResolutionTitle.GetString(),
|
||||
UnityStyles.ProjectSettings.SectionTitle);
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.ManualConflictResolution,
|
||||
mManualConflictResolution,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mManualConflictResolution = true;
|
||||
mAutomaticConflictResolution = false;
|
||||
}
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.AutomaticConflictResolution,
|
||||
mAutomaticConflictResolution,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mAutomaticConflictResolution = true;
|
||||
mManualConflictResolution = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DoMergeViewBehaviorSettings()
|
||||
{
|
||||
EditorGUILayout.Space(10);
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.Name.MergeViewBehaviorTitle.GetString(),
|
||||
UnityStyles.ProjectSettings.SectionTitle);
|
||||
|
||||
mCloseMergeView = EditorGUILayout.Toggle(Styles.CloseMergeView, mCloseMergeView);
|
||||
mMergeWithChanges = EditorGUILayout.Toggle(Styles.MergeWithChanges, mMergeWithChanges);
|
||||
}
|
||||
|
||||
static void DrawSettingsSection(Action drawSettings)
|
||||
{
|
||||
float originalLabelWidth = EditorGUIUtility.labelWidth;
|
||||
|
||||
try
|
||||
{
|
||||
EditorGUIUtility.labelWidth = UnityConstants.SETTINGS_GUI_WIDTH;
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
|
||||
drawSettings();
|
||||
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUIUtility.labelWidth = originalLabelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
class Styles
|
||||
{
|
||||
internal static GUIContent ManualConflictResolution =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.ManualConflictResolution.GetString(),
|
||||
PlasticLocalization.Name.ManualConflictResolutionTooltip.GetString());
|
||||
|
||||
internal static GUIContent AutomaticConflictResolution =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.AutomaticConflictResolution.GetString(),
|
||||
PlasticLocalization.Name.AutomaticConflictResolutionTooltip.GetString());
|
||||
|
||||
internal static GUIContent CloseMergeView =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.CloseMergeAndOpenPendingChanges.GetString());
|
||||
|
||||
internal static GUIContent MergeWithChanges =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.MergeWithPendingChanges.GetString(),
|
||||
PlasticLocalization.Name.MergeWithPendingChangesExplanation.GetString());
|
||||
}
|
||||
|
||||
string GetEncodingValue(int selectedIndex)
|
||||
{
|
||||
if (selectedIndex < 0 || selectedIndex > mEncodingValues.Length)
|
||||
return string.Empty;
|
||||
|
||||
return mEncodingValues[selectedIndex];
|
||||
}
|
||||
|
||||
static string[] GetEncodingValuesToDisplay()
|
||||
{
|
||||
List<string> encodingValues = new List<string>();
|
||||
|
||||
encodingValues.AddRange(EncodingManager.GetPredefinedEncodings());
|
||||
|
||||
IEnumerable<Encoding> systemEncodings = EncodingManager.GetSystemEncodings()
|
||||
.Select(ei => ei.GetEncoding())
|
||||
.OrderBy(e => e.EncodingName);
|
||||
|
||||
foreach (Encoding encoding in systemEncodings)
|
||||
{
|
||||
encodingValues.Add(
|
||||
UnityMenuItem.EscapedText(
|
||||
string.Format("{0} {1} ({2})",
|
||||
encoding.EncodingName, encoding.WebName, encoding.CodePage.ToString())));
|
||||
}
|
||||
|
||||
return encodingValues.ToArray();
|
||||
}
|
||||
|
||||
static string[] mComparisonMethods = {
|
||||
MergetoolLocalization.GetString(MergetoolLocalization.Name.IgnoreEol),
|
||||
MergetoolLocalization.GetString(MergetoolLocalization.Name.IgnoreWhitespace),
|
||||
MergetoolLocalization.GetString(MergetoolLocalization.Name.IgnoreEolWhitespace),
|
||||
MergetoolLocalization.GetString(MergetoolLocalization.Name.RecognizeAll) };
|
||||
|
||||
static string[] mEncodingValues = EncodingManager.GetEncodingValues();
|
||||
static string[] mEncodingValuesToDisplay = GetEncodingValuesToDisplay();
|
||||
|
||||
int mComparisonMethodSelectedIndex;
|
||||
int mDefaultEncodingSelectedIndex;
|
||||
int mResultEncodingSelectedIndex;
|
||||
|
||||
bool mManualConflictResolution;
|
||||
bool mAutomaticConflictResolution;
|
||||
|
||||
bool mCloseMergeView;
|
||||
bool mMergeWithChanges;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c9b352f456640c9925a381f736ecb5d
|
||||
timeCreated: 1729607607
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
using Codice.Client.Common.Threading;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Settings
|
||||
{
|
||||
internal static class OpenPlasticProjectSettings
|
||||
{
|
||||
internal static void ByDefault()
|
||||
{
|
||||
PlasticProjectSettingsProvider provider = OpenInPlasticProjectSettings();
|
||||
|
||||
if (provider == null)
|
||||
return;
|
||||
|
||||
provider.OpenAllFoldouts();
|
||||
}
|
||||
|
||||
internal static void InShelveAndSwitchFoldout()
|
||||
{
|
||||
PlasticProjectSettingsProvider provider = OpenInPlasticProjectSettings();
|
||||
|
||||
if (provider == null)
|
||||
return;
|
||||
|
||||
provider.OpenShelveAndSwitchFoldout();
|
||||
}
|
||||
|
||||
internal static void InOtherFoldout()
|
||||
{
|
||||
PlasticProjectSettingsProvider provider = OpenInPlasticProjectSettings();
|
||||
|
||||
if (provider == null)
|
||||
return;
|
||||
|
||||
provider.OpenOtherFoldout();
|
||||
}
|
||||
|
||||
internal static PlasticProjectSettingsProvider OpenInPlasticProjectSettings()
|
||||
{
|
||||
EditorWindow settingsWindow = OpenProjectSettingsWithPlasticSelected();
|
||||
return GetPlasticProvider(settingsWindow);
|
||||
}
|
||||
|
||||
internal static EditorWindow OpenProjectSettingsWithPlasticSelected()
|
||||
{
|
||||
return SettingsService.OpenProjectSettings(
|
||||
UnityConstants.PROJECT_SETTINGS_TAB_PATH);
|
||||
}
|
||||
|
||||
internal static PlasticProjectSettingsProvider GetPlasticProvider(
|
||||
EditorWindow settingsWindow)
|
||||
{
|
||||
try
|
||||
{
|
||||
/* The following code must be compiled only for editor versions that allow our code
|
||||
to access internal code from the editor, otherwise the ProjectSettingsWindow is not
|
||||
accessible and the compilation fails.
|
||||
We don't know yet the version number that allows us to access this code, so for the
|
||||
moment the code is commented
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
ProjectSettingsWindow projectSettingsWindow = settingsWindow as ProjectSettingsWindow;
|
||||
return projectSettingsWindow.GetCurrentProvider() as PlasticProjectSettingsProvider;
|
||||
#else */
|
||||
|
||||
MethodInfo getCurrentProviderMethod = settingsWindow.GetType().GetMethod(
|
||||
"GetCurrentProvider",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
return getCurrentProviderMethod.Invoke(
|
||||
settingsWindow, null) as PlasticProjectSettingsProvider;
|
||||
//#endif
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExceptionsHandler.LogException("OpenPlasticProjectSettingsProvider", ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9731678ff16392a4d822454ca1052818
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Settings
|
||||
{
|
||||
class OtherOptionsFoldout
|
||||
{
|
||||
internal void OnActivate()
|
||||
{
|
||||
PlasticGuiConfigData data = PlasticGuiConfig.Get().Configuration;
|
||||
|
||||
mNewCodeReviewCreateAndOpenInDesktop = data.NewCodeReviewBehavior == NewCodeReviewBehavior.CreateAndOpenInDesktop;
|
||||
mNewCodeReviewRequestReviewInUnityCloud = data.NewCodeReviewBehavior == NewCodeReviewBehavior.RequestFromUnityCloud;
|
||||
mNewCodeReviewAskAlways = data.NewCodeReviewBehavior == NewCodeReviewBehavior.Ask;
|
||||
}
|
||||
|
||||
internal void OnDeactivate()
|
||||
{
|
||||
PlasticGuiConfig plasticGuiConfig = PlasticGuiConfig.Get();
|
||||
plasticGuiConfig.Configuration.NewCodeReviewBehavior = GetSelectedNewCodeReviewBehavior();
|
||||
plasticGuiConfig.Save();
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
DrawSplitter.ForWidth(UnityConstants.SETTINGS_GUI_WIDTH);
|
||||
|
||||
DrawSettingsSection(DoNewCodeReviewBehaviorSettings);
|
||||
}
|
||||
|
||||
internal void SelectNewCodeReviewBehaviorForTesting(NewCodeReviewBehavior shelveBehavior)
|
||||
{
|
||||
mNewCodeReviewCreateAndOpenInDesktop = shelveBehavior == NewCodeReviewBehavior.CreateAndOpenInDesktop;
|
||||
mNewCodeReviewRequestReviewInUnityCloud = shelveBehavior == NewCodeReviewBehavior.RequestFromUnityCloud;
|
||||
mNewCodeReviewAskAlways = shelveBehavior == NewCodeReviewBehavior.Ask;
|
||||
}
|
||||
|
||||
NewCodeReviewBehavior GetSelectedNewCodeReviewBehavior()
|
||||
{
|
||||
if (mNewCodeReviewCreateAndOpenInDesktop)
|
||||
return NewCodeReviewBehavior.CreateAndOpenInDesktop;
|
||||
|
||||
if (mNewCodeReviewRequestReviewInUnityCloud)
|
||||
return NewCodeReviewBehavior.RequestFromUnityCloud;
|
||||
|
||||
return NewCodeReviewBehavior.Ask;
|
||||
}
|
||||
|
||||
void DoNewCodeReviewBehaviorSettings()
|
||||
{
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.Name.NewCodeReviewDefaultBehavior.GetString(),
|
||||
UnityStyles.ProjectSettings.SectionTitle);
|
||||
EditorGUILayout.Space(2);
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.NewCodeReviewCreateAndOpenInDesktop,
|
||||
mNewCodeReviewCreateAndOpenInDesktop,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mNewCodeReviewCreateAndOpenInDesktop = true;
|
||||
mNewCodeReviewRequestReviewInUnityCloud = false;
|
||||
mNewCodeReviewAskAlways = false;
|
||||
}
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.NewCodeReviewRequestReviewInUnityCloud,
|
||||
mNewCodeReviewRequestReviewInUnityCloud,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mNewCodeReviewCreateAndOpenInDesktop = false;
|
||||
mNewCodeReviewRequestReviewInUnityCloud = true;
|
||||
mNewCodeReviewAskAlways = false;
|
||||
}
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.NewCodeReviewAskAlways,
|
||||
mNewCodeReviewAskAlways,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mNewCodeReviewCreateAndOpenInDesktop = false;
|
||||
mNewCodeReviewRequestReviewInUnityCloud = false;
|
||||
mNewCodeReviewAskAlways = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawSettingsSection(Action drawSettings)
|
||||
{
|
||||
float originalLabelWidth = EditorGUIUtility.labelWidth;
|
||||
|
||||
try
|
||||
{
|
||||
EditorGUIUtility.labelWidth = UnityConstants.SETTINGS_GUI_WIDTH;
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
|
||||
drawSettings();
|
||||
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUIUtility.labelWidth = originalLabelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
class Styles
|
||||
{
|
||||
internal static GUIContent NewCodeReviewAskAlways =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.NewCodeReviewAskAlways.GetString(),
|
||||
PlasticLocalization.Name.NewCodeReviewAskAlwaysExplanation.GetString());
|
||||
|
||||
internal static GUIContent NewCodeReviewCreateAndOpenInDesktop =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.OpenInDesktopApp.GetString(),
|
||||
PlasticLocalization.Name.CreateAndOpenCodeReviewInDesktopExplanation.GetString());
|
||||
|
||||
internal static GUIContent NewCodeReviewRequestReviewInUnityCloud =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.OpenInUnityCloud.GetString(),
|
||||
PlasticLocalization.Name.RequestCodeReviewFromUnityCloudExplanation.GetString());
|
||||
}
|
||||
|
||||
bool mNewCodeReviewCreateAndOpenInDesktop;
|
||||
bool mNewCodeReviewRequestReviewInUnityCloud;
|
||||
bool mNewCodeReviewAskAlways;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05c0641719e74f058e7530b150336e82
|
||||
timeCreated: 1736260811
|
||||
@@ -0,0 +1,506 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Commands;
|
||||
using Codice.Client.Common.FsNodeReaders;
|
||||
using Codice.Client.Common.Threading;
|
||||
using Codice.CM.Common;
|
||||
using Codice.Utils;
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow.PendingChanges;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
using AssetPostprocessor = Unity.PlasticSCM.Editor.AssetUtils.Processor.AssetPostprocessor;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Settings
|
||||
{
|
||||
class PendingChangesOptionsFoldout
|
||||
{
|
||||
internal void OnActivate(WorkspaceInfo wkInfo)
|
||||
{
|
||||
mWkInfo = wkInfo;
|
||||
|
||||
IAutoRefreshView autoRefreshView = GetPendingChangesView();
|
||||
|
||||
if (autoRefreshView != null)
|
||||
autoRefreshView.DisableAutoRefresh();
|
||||
|
||||
CheckFsWatcher(mWkInfo);
|
||||
|
||||
mAutomaticAdd = AssetPostprocessor.AutomaticAdd;
|
||||
|
||||
mPendingChangesSavedOptions = new PendingChangesOptions();
|
||||
mPendingChangesSavedOptions.LoadPendingChangesOptions();
|
||||
|
||||
SetPendingChangesOptions(mPendingChangesSavedOptions);
|
||||
}
|
||||
|
||||
internal void OnDeactivate()
|
||||
{
|
||||
bool arePendingChangesOptionsChanged = false;
|
||||
|
||||
try
|
||||
{
|
||||
AssetPostprocessor.SetAutomaticAddOption(mAutomaticAdd);
|
||||
|
||||
PendingChangesOptions newPendingChangesOptions = GetPendingChangesOptions();
|
||||
|
||||
arePendingChangesOptionsChanged = !mPendingChangesSavedOptions.AreSameOptions(newPendingChangesOptions);
|
||||
|
||||
if (arePendingChangesOptionsChanged)
|
||||
{
|
||||
newPendingChangesOptions.SavePreferences();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
IAutoRefreshView autoRefreshView = GetPendingChangesView();
|
||||
|
||||
if (autoRefreshView != null)
|
||||
{
|
||||
autoRefreshView.EnableAutoRefresh();
|
||||
|
||||
if (arePendingChangesOptionsChanged)
|
||||
{
|
||||
autoRefreshView.ForceRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
DrawSplitter.ForWidth(UnityConstants.SETTINGS_GUI_WIDTH);
|
||||
|
||||
DrawSettingsSection(
|
||||
DoPendingChangesSettings);
|
||||
}
|
||||
|
||||
void DoPendingChangesSettings()
|
||||
{
|
||||
DoGeneralSettings();
|
||||
|
||||
DoWhatToFindSettings();
|
||||
|
||||
DoWhatToShowSettings();
|
||||
|
||||
DoMoveDetectionSettings();
|
||||
}
|
||||
|
||||
void DoGeneralSettings()
|
||||
{
|
||||
mAutomaticAdd = EditorGUILayout.Toggle(Styles.AutomaticAdd, mAutomaticAdd);
|
||||
mAutoRefresh = EditorGUILayout.Toggle(Styles.AutoRefresh, mAutoRefresh);
|
||||
}
|
||||
|
||||
void DoWhatToFindSettings()
|
||||
{
|
||||
EditorGUILayout.Space(10);
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.Name.PendingChangesWhatToFindTab.GetString(),
|
||||
UnityStyles.ProjectSettings.SectionTitle);
|
||||
|
||||
mShowCheckouts = EditorGUILayout.Toggle(Styles.ShowCheckouts, mShowCheckouts);
|
||||
mShowChangedFiles = EditorGUILayout.Toggle(Styles.ShowChangedFiles, mShowChangedFiles);
|
||||
|
||||
DrawTabbedContent(
|
||||
DoCheckFileContentCheckbox);
|
||||
|
||||
DoFsWatcherMessage(mFSWatcherEnabled);
|
||||
}
|
||||
|
||||
void DoCheckFileContentCheckbox()
|
||||
{
|
||||
mCheckFileContent = EditorGUILayout.Toggle(Styles.CheckFileContent, mCheckFileContent);
|
||||
}
|
||||
|
||||
void DoFsWatcherMessage(bool isEnabled)
|
||||
{
|
||||
GUIContent message = new GUIContent(
|
||||
isEnabled ?
|
||||
GetFsWatcherEnabledMessage() :
|
||||
GetFsWatcherDisabledMessage(),
|
||||
isEnabled ?
|
||||
Images.GetInfoIcon() :
|
||||
Images.GetWarnIcon());
|
||||
|
||||
GUILayout.Label(message, UnityStyles.ProjectSettings.Title, GUILayout.Height(26));
|
||||
GUILayout.Space(-4);
|
||||
|
||||
string formattedExplanation = isEnabled ?
|
||||
GetFsWatcherEnabledExplanation() :
|
||||
GetFsWatcherDisabledExplanation();
|
||||
|
||||
ExternalLink externalLink = new ExternalLink
|
||||
{
|
||||
Label = PlasticLocalization.Name.UnityVersionControlSupport.GetString(),
|
||||
Url = SUPPORT_URL
|
||||
};
|
||||
|
||||
DrawTextBlockWithLink.ForExternalLink(
|
||||
externalLink, formattedExplanation, UnityStyles.ProjectSettings.Paragraph);
|
||||
}
|
||||
|
||||
void DoWhatToShowSettings()
|
||||
{
|
||||
EditorGUILayout.Space(10);
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesWhatToShowTab),
|
||||
UnityStyles.ProjectSettings.SectionTitle);
|
||||
|
||||
mUseChangeLists = EditorGUILayout.Toggle(Styles.UseChangeLists, mUseChangeLists);
|
||||
mShowPrivateFields = EditorGUILayout.Toggle(Styles.ShowPrivateFields, mShowPrivateFields);
|
||||
mShowIgnoredFiles = EditorGUILayout.Toggle(Styles.ShowIgnoredFields, mShowIgnoredFiles);
|
||||
mShowHiddenFiles = EditorGUILayout.Toggle(Styles.ShowHiddenFields, mShowHiddenFiles);
|
||||
mShowDeletedFiles = EditorGUILayout.Toggle(Styles.ShowDeletedFilesDirs, mShowDeletedFiles);
|
||||
}
|
||||
|
||||
void DoMoveDetectionSettings()
|
||||
{
|
||||
EditorGUILayout.Space(10);
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesMoveDetectionTab),
|
||||
UnityStyles.ProjectSettings.SectionTitle);
|
||||
|
||||
mShowMovedFiles = EditorGUILayout.Toggle(Styles.ShowMovedFiles, mShowMovedFiles);
|
||||
|
||||
DrawTabbedContent(
|
||||
DoMovedFilesCheckboxes);
|
||||
}
|
||||
|
||||
void DoMovedFilesCheckboxes()
|
||||
{
|
||||
mMatchBinarySameExtension =
|
||||
EditorGUILayout.Toggle(Styles.MatchBinarySameExtension, mMatchBinarySameExtension);
|
||||
mMatchTextSameExtension = EditorGUILayout.Toggle(Styles.MatchTextSameExtension, mMatchTextSameExtension);
|
||||
mSimilarityPercent = EditorGUILayout.IntSlider(Styles.SimilarityPercent, mSimilarityPercent, 0, 100);
|
||||
}
|
||||
|
||||
void CheckFsWatcher(WorkspaceInfo wkInfo)
|
||||
{
|
||||
bool isFileSystemWatcherEnabled = false;
|
||||
|
||||
IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);
|
||||
waiter.Execute(
|
||||
/*threadOperationDelegate*/
|
||||
delegate
|
||||
{
|
||||
isFileSystemWatcherEnabled =
|
||||
IsFileSystemWatcherEnabled(wkInfo);
|
||||
},
|
||||
/*afterOperationDelegate*/
|
||||
delegate
|
||||
{
|
||||
if (waiter.Exception != null)
|
||||
return;
|
||||
|
||||
mFSWatcherEnabled = isFileSystemWatcherEnabled;
|
||||
});
|
||||
}
|
||||
|
||||
void SetPendingChangesOptions(PendingChangesOptions options)
|
||||
{
|
||||
mShowCheckouts = IsEnabled(
|
||||
WorkspaceStatusOptions.FindCheckouts, options.WorkspaceStatusOptions);
|
||||
mAutoRefresh = options.AutoRefresh;
|
||||
|
||||
mShowChangedFiles = IsEnabled(
|
||||
WorkspaceStatusOptions.FindChanged, options.WorkspaceStatusOptions);
|
||||
mCheckFileContent = options.CheckFileContentForChanged;
|
||||
|
||||
mUseChangeLists = options.UseChangeLists;
|
||||
|
||||
mShowPrivateFields = IsEnabled(
|
||||
WorkspaceStatusOptions.FindPrivates, options.WorkspaceStatusOptions);
|
||||
mShowIgnoredFiles = IsEnabled(
|
||||
WorkspaceStatusOptions.ShowIgnored, options.WorkspaceStatusOptions);
|
||||
mShowHiddenFiles = IsEnabled(
|
||||
WorkspaceStatusOptions.ShowHiddenChanges, options.WorkspaceStatusOptions);
|
||||
mShowDeletedFiles = IsEnabled(
|
||||
WorkspaceStatusOptions.FindLocallyDeleted, options.WorkspaceStatusOptions);
|
||||
|
||||
mShowMovedFiles = IsEnabled(
|
||||
WorkspaceStatusOptions.CalculateLocalMoves, options.WorkspaceStatusOptions);
|
||||
mMatchBinarySameExtension =
|
||||
options.MovedMatchingOptions.bBinMatchingOnlySameExtension;
|
||||
mMatchTextSameExtension =
|
||||
options.MovedMatchingOptions.bTxtMatchingOnlySameExtension;
|
||||
mSimilarityPercent = (int)((1 - options.MovedMatchingOptions.AllowedChangesPerUnit) * 100f);
|
||||
}
|
||||
|
||||
PendingChangesOptions GetPendingChangesOptions()
|
||||
{
|
||||
WorkspaceStatusOptions resultWkStatusOptions =
|
||||
WorkspaceStatusOptions.None;
|
||||
|
||||
if (mShowCheckouts)
|
||||
{
|
||||
resultWkStatusOptions |= WorkspaceStatusOptions.FindCheckouts;
|
||||
resultWkStatusOptions |= WorkspaceStatusOptions.FindReplaced;
|
||||
resultWkStatusOptions |= WorkspaceStatusOptions.FindCopied;
|
||||
}
|
||||
|
||||
if (mShowChangedFiles)
|
||||
resultWkStatusOptions |= WorkspaceStatusOptions.FindChanged;
|
||||
if (mShowPrivateFields)
|
||||
resultWkStatusOptions |= WorkspaceStatusOptions.FindPrivates;
|
||||
if (mShowIgnoredFiles)
|
||||
resultWkStatusOptions |= WorkspaceStatusOptions.ShowIgnored;
|
||||
if (mShowHiddenFiles)
|
||||
resultWkStatusOptions |= WorkspaceStatusOptions.ShowHiddenChanges;
|
||||
if (mShowDeletedFiles)
|
||||
resultWkStatusOptions |= WorkspaceStatusOptions.FindLocallyDeleted;
|
||||
if (mShowMovedFiles)
|
||||
resultWkStatusOptions |= WorkspaceStatusOptions.CalculateLocalMoves;
|
||||
|
||||
MovedMatchingOptions matchingOptions = new MovedMatchingOptions();
|
||||
matchingOptions.AllowedChangesPerUnit =
|
||||
(100 - mSimilarityPercent) / 100f;
|
||||
matchingOptions.bBinMatchingOnlySameExtension =
|
||||
mMatchBinarySameExtension;
|
||||
matchingOptions.bTxtMatchingOnlySameExtension =
|
||||
mMatchTextSameExtension;
|
||||
|
||||
return new PendingChangesOptions(
|
||||
resultWkStatusOptions,
|
||||
matchingOptions,
|
||||
mUseChangeLists,
|
||||
true,
|
||||
false,
|
||||
mAutoRefresh,
|
||||
false,
|
||||
mCheckFileContent);
|
||||
}
|
||||
|
||||
static void DrawSettingsSection(Action drawSettings)
|
||||
{
|
||||
float originalLabelWidth = EditorGUIUtility.labelWidth;
|
||||
|
||||
try
|
||||
{
|
||||
EditorGUIUtility.labelWidth = UnityConstants.SETTINGS_GUI_WIDTH;
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
|
||||
drawSettings();
|
||||
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUIUtility.labelWidth = originalLabelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawTabbedContent(Action drawContent)
|
||||
{
|
||||
float originalLabelWidth = EditorGUIUtility.labelWidth;
|
||||
|
||||
try
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.Space(15);
|
||||
EditorGUIUtility.labelWidth -= 15;
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
GUILayout.Space(0);
|
||||
drawContent();
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUIUtility.labelWidth = originalLabelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
static IAutoRefreshView GetPendingChangesView()
|
||||
{
|
||||
PlasticWindow window = GetWindowIfOpened.Plastic();
|
||||
|
||||
if (window == null)
|
||||
return null;
|
||||
|
||||
return window.GetPendingChangesView();
|
||||
}
|
||||
|
||||
static string GetFsWatcherEnabledMessage()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows() || PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesFilesystemWatcherEnabled);
|
||||
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesINotifyEnabled);
|
||||
}
|
||||
|
||||
static string GetFsWatcherDisabledMessage()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows() || PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesFilesystemWatcherDisabled);
|
||||
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesINotifyDisabled);
|
||||
}
|
||||
|
||||
static string GetFsWatcherEnabledExplanation()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows() || PlatformIdentifier.IsMac())
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesFilesystemWatcherEnabledExplanationUnityVCS);
|
||||
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesINotifyEnabledExplanation);
|
||||
}
|
||||
|
||||
static string GetFsWatcherDisabledExplanation()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows() || PlatformIdentifier.IsMac())
|
||||
{
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesFilesystemWatcherDisabledExplanationUnityVCS)
|
||||
.Replace("[[HELP_URL|{0}]]", "");
|
||||
}
|
||||
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesINotifyDisabledExplanation);
|
||||
}
|
||||
|
||||
static bool IsFileSystemWatcherEnabled(
|
||||
WorkspaceInfo wkInfo)
|
||||
{
|
||||
return WorkspaceWatcherFsNodeReadersCache.Get().
|
||||
IsWatcherEnabled(wkInfo);
|
||||
}
|
||||
|
||||
static bool IsEnabled(
|
||||
WorkspaceStatusOptions option,
|
||||
WorkspaceStatusOptions options)
|
||||
{
|
||||
return (options & option) == option;
|
||||
}
|
||||
|
||||
internal interface IAutoRefreshView
|
||||
{
|
||||
void DisableAutoRefresh();
|
||||
void EnableAutoRefresh();
|
||||
void ForceRefresh();
|
||||
}
|
||||
|
||||
class Styles
|
||||
{
|
||||
internal static GUIContent AutomaticAdd =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.ProjectSettingsAutomaticAdd),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.ProjectSettingsAutomaticAddExplanation));
|
||||
internal static GUIContent ShowCheckouts =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesShowCheckouts),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesShowCheckoutsExplanation));
|
||||
internal static GUIContent AutoRefresh =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesAutoRefresh),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesAutoRefreshExplanation));
|
||||
internal static GUIContent ShowChangedFiles =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesFindChanged),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesFindChangedExplanation));
|
||||
internal static GUIContent CheckFileContent =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesCheckFileContent),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesCheckFileContentExplanation));
|
||||
internal static GUIContent UseChangeLists =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesGroupInChangeLists),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesGroupInChangeListsExplanation));
|
||||
internal static GUIContent ShowPrivateFields =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesShowPrivateFiles),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesShowPrivateFilesExplanation));
|
||||
internal static GUIContent ShowIgnoredFields =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesShowIgnoredFiles),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesShowIgnoredFilesExplanation));
|
||||
internal static GUIContent ShowHiddenFields =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesShowHiddenFiles),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesShowHiddenFilesExplanation));
|
||||
internal static GUIContent ShowDeletedFilesDirs =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesShowDeletedFiles),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesShowDeletedFilesExplanation));
|
||||
internal static GUIContent ShowMovedFiles =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesFindMovedFiles),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesFindMovedFilesExplanation));
|
||||
internal static GUIContent MatchBinarySameExtension =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesMatchBinarySameExtension),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesMatchBinarySameExtensionExplanation));
|
||||
internal static GUIContent MatchTextSameExtension =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesMatchTextSameExtension),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesMatchTextSameExtensionExplanation));
|
||||
internal static GUIContent SimilarityPercent =
|
||||
new GUIContent(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesSimilarityPercentage),
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PendingChangesSimilarityPercentageExplanation));
|
||||
}
|
||||
|
||||
WorkspaceInfo mWkInfo;
|
||||
PendingChangesOptions mPendingChangesSavedOptions;
|
||||
|
||||
bool mAutomaticAdd;
|
||||
bool mShowCheckouts;
|
||||
bool mAutoRefresh;
|
||||
bool mFSWatcherEnabled;
|
||||
|
||||
bool mShowChangedFiles;
|
||||
bool mCheckFileContent;
|
||||
|
||||
bool mUseChangeLists;
|
||||
bool mShowPrivateFields;
|
||||
bool mShowIgnoredFiles;
|
||||
bool mShowHiddenFiles;
|
||||
bool mShowDeletedFiles;
|
||||
|
||||
bool mShowMovedFiles;
|
||||
bool mMatchBinarySameExtension;
|
||||
bool mMatchTextSameExtension;
|
||||
int mSimilarityPercent;
|
||||
|
||||
const string SUPPORT_URL = "https://support.unity.com/hc/en-us/requests/new?ticket_form_id=360001051792";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4646098fa06b7764b843d936862b4d71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,254 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
using Codice.Client.Common.EventTracking;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Settings
|
||||
{
|
||||
class PlasticProjectSettingsProvider : SettingsProvider
|
||||
{
|
||||
// Internal usage. This isn't a public API.
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public PlasticProjectSettingsProvider(
|
||||
string path, SettingsScope scope = SettingsScope.User)
|
||||
: base(path, scope)
|
||||
{
|
||||
label = UnityConstants.PROJECT_SETTINGS_TAB_TITLE;
|
||||
|
||||
OpenAllFoldouts();
|
||||
}
|
||||
|
||||
// Internal usage. This isn't a public API.
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[SettingsProvider]
|
||||
public static SettingsProvider CreateSettingsProvider()
|
||||
{
|
||||
if (!FindWorkspace.HasWorkspace(ApplicationDataPath.Get()))
|
||||
return null;
|
||||
|
||||
PlasticApp.InitializeIfNeeded();
|
||||
|
||||
return new PlasticProjectSettingsProvider(
|
||||
UnityConstants.PROJECT_SETTINGS_TAB_PATH, SettingsScope.Project);
|
||||
}
|
||||
|
||||
public override void OnActivate(
|
||||
string searchContext,
|
||||
VisualElement rootElement)
|
||||
{
|
||||
mIsPluginEnabled = PlasticPluginIsEnabledPreference.IsEnabled();
|
||||
|
||||
mWkInfo = FindWorkspace.InfoForApplicationPath(
|
||||
ApplicationDataPath.Get(), PlasticGui.Plastic.API);
|
||||
|
||||
mIsProjectSettingsActivated = true;
|
||||
|
||||
mPendingChangesOptionsFoldout.OnActivate(mWkInfo);
|
||||
mDiffAndMergeOptionsFoldout.OnActivate();
|
||||
mShelveAndSwitchOptionsFoldout.OnActivate();
|
||||
mOtherOptionsFoldout.OnActivate();
|
||||
}
|
||||
|
||||
public override void OnDeactivate()
|
||||
{
|
||||
if (!mIsProjectSettingsActivated)
|
||||
return;
|
||||
|
||||
mIsProjectSettingsActivated = false;
|
||||
|
||||
mPendingChangesOptionsFoldout.OnDeactivate();
|
||||
mDiffAndMergeOptionsFoldout.OnDeactivate();
|
||||
mShelveAndSwitchOptionsFoldout.OnDeactivate();
|
||||
mOtherOptionsFoldout.OnDeactivate();
|
||||
}
|
||||
|
||||
public override void OnGUI(string searchContext)
|
||||
{
|
||||
DrawSettingsSection(
|
||||
DoIsEnabledSetting);
|
||||
|
||||
if (!mIsPluginEnabled)
|
||||
return;
|
||||
|
||||
mIsPendingChangesFoldoutOpen = DrawFoldout(
|
||||
mIsPendingChangesFoldoutOpen,
|
||||
PlasticLocalization.Name.PendingChangesOptionsSectionTitle.GetString(),
|
||||
mPendingChangesOptionsFoldout.OnGUI);
|
||||
|
||||
mIsDiffAndMergeFoldoutOpen = DrawFoldout(
|
||||
mIsDiffAndMergeFoldoutOpen,
|
||||
PlasticLocalization.Name.DiffAndMergeOptionsSectionTitle.GetString(),
|
||||
mDiffAndMergeOptionsFoldout.OnGUI);
|
||||
|
||||
mIsShelveAndSwitchFoldoutOpen = DrawFoldout(
|
||||
mIsShelveAndSwitchFoldoutOpen,
|
||||
PlasticLocalization.Name.ShelveAndSwitchOptionsSectionTitle.GetString(),
|
||||
mShelveAndSwitchOptionsFoldout.OnGUI);
|
||||
|
||||
mIsOtherFoldoutOpen = DrawFoldout(
|
||||
mIsOtherFoldoutOpen,
|
||||
PlasticLocalization.Name.OtherOptionsSectionTitle.GetString(),
|
||||
mOtherOptionsFoldout.OnGUI);
|
||||
}
|
||||
|
||||
internal void OpenAllFoldouts()
|
||||
{
|
||||
mIsPendingChangesFoldoutOpen = true;
|
||||
mIsDiffAndMergeFoldoutOpen = true;
|
||||
mIsShelveAndSwitchFoldoutOpen = true;
|
||||
mIsOtherFoldoutOpen = true;
|
||||
}
|
||||
|
||||
internal void OpenShelveAndSwitchFoldout()
|
||||
{
|
||||
mIsShelveAndSwitchFoldoutOpen = true;
|
||||
mIsPendingChangesFoldoutOpen = false;
|
||||
mIsDiffAndMergeFoldoutOpen = false;
|
||||
mIsOtherFoldoutOpen = false;
|
||||
}
|
||||
|
||||
internal void OpenOtherFoldout()
|
||||
{
|
||||
mIsOtherFoldoutOpen = true;
|
||||
mIsPendingChangesFoldoutOpen = false;
|
||||
mIsDiffAndMergeFoldoutOpen = false;
|
||||
mIsShelveAndSwitchFoldoutOpen = false;
|
||||
}
|
||||
|
||||
void DoIsEnabledSetting()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
string message = PlasticLocalization.GetString(
|
||||
mIsPluginEnabled ?
|
||||
PlasticLocalization.Name.UnityVCSIsEnabled :
|
||||
PlasticLocalization.Name.UnityVCSIsDisabled);
|
||||
|
||||
GUILayout.Label(
|
||||
message,
|
||||
EditorStyles.boldLabel,
|
||||
GUILayout.Height(20));
|
||||
|
||||
EditorGUILayout.Space(8);
|
||||
|
||||
DoIsEnabledButton();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
}
|
||||
|
||||
void DoIsEnabledButton()
|
||||
{
|
||||
if (!GUILayout.Button(PlasticLocalization.GetString(
|
||||
mIsPluginEnabled ?
|
||||
PlasticLocalization.Name.DisableButton :
|
||||
PlasticLocalization.Name.EnableButton),
|
||||
UnityStyles.ProjectSettings.ToggleOn))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mIsPluginEnabled)
|
||||
{
|
||||
mIsPluginEnabled = true;
|
||||
|
||||
TrackFeatureUseEvent.For(
|
||||
PlasticGui.Plastic.API.GetRepositorySpec(mWkInfo),
|
||||
TrackFeatureUseEvent.Features.UnityPackage.EnableManually);
|
||||
|
||||
PlasticPlugin.Enable();
|
||||
PlasticPluginIsEnabledPreference.Enable();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsPluginEnabled)
|
||||
{
|
||||
mIsPluginEnabled = false;
|
||||
|
||||
TrackFeatureUseEvent.For(
|
||||
PlasticGui.Plastic.API.GetRepositorySpec(mWkInfo),
|
||||
TrackFeatureUseEvent.Features.UnityPackage.DisableManually);
|
||||
|
||||
PlasticPluginIsEnabledPreference.Disable();
|
||||
CloseWindowIfOpened.Plastic();
|
||||
PlasticShutdown.Shutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawSettingsSection(Action drawSettings)
|
||||
{
|
||||
float originalLabelWidth = EditorGUIUtility.labelWidth;
|
||||
|
||||
try
|
||||
{
|
||||
EditorGUIUtility.labelWidth = UnityConstants.SETTINGS_GUI_WIDTH;
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
|
||||
drawSettings();
|
||||
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUIUtility.labelWidth = originalLabelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
static bool DrawFoldout(
|
||||
bool isFoldoutOpen,
|
||||
string title,
|
||||
Action drawContent)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
|
||||
bool result =
|
||||
EditorGUILayout.BeginFoldoutHeaderGroup(
|
||||
isFoldoutOpen,
|
||||
title,
|
||||
UnityStyles.ProjectSettings.FoldoutHeader);
|
||||
|
||||
if (result)
|
||||
drawContent();
|
||||
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool mIsPendingChangesFoldoutOpen;
|
||||
bool mIsDiffAndMergeFoldoutOpen;
|
||||
bool mIsShelveAndSwitchFoldoutOpen;
|
||||
bool mIsOtherFoldoutOpen;
|
||||
|
||||
bool mIsProjectSettingsActivated;
|
||||
|
||||
bool mIsPluginEnabled;
|
||||
|
||||
WorkspaceInfo mWkInfo;
|
||||
|
||||
PendingChangesOptionsFoldout mPendingChangesOptionsFoldout = new PendingChangesOptionsFoldout();
|
||||
DiffAndMergeOptionsFoldout mDiffAndMergeOptionsFoldout = new DiffAndMergeOptionsFoldout();
|
||||
ShelveAndSwitchOptionsFoldout mShelveAndSwitchOptionsFoldout = new ShelveAndSwitchOptionsFoldout();
|
||||
OtherOptionsFoldout mOtherOptionsFoldout = new OtherOptionsFoldout();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d097a5d507694ba7ac97bc9a9f2942e3
|
||||
timeCreated: 1729521930
|
||||
@@ -0,0 +1,264 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common;
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow.PendingChanges;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Settings
|
||||
{
|
||||
class ShelveAndSwitchOptionsFoldout
|
||||
{
|
||||
internal void OnActivate()
|
||||
{
|
||||
PlasticGuiConfigData data = PlasticGuiConfig.Get().Configuration;
|
||||
|
||||
mUndoChangesAfterShelve = data.ShelvingUndoBehavior == UndoShelveBehavior.UndoChanges;
|
||||
mKeepChangesAfterShelve = data.ShelvingUndoBehavior == UndoShelveBehavior.KeepChanges;
|
||||
mAskAlwaysAfterShelve = data.ShelvingUndoBehavior == UndoShelveBehavior.Ask;
|
||||
|
||||
mSwitchActionShelveOption = ClientConfig.Get().GetPendingChangesOnSwitchAction() == UserAction.Shelve;
|
||||
mSwitchActionAllowOption = ClientConfig.Get().GetPendingChangesOnSwitchAction() == UserAction.None;
|
||||
mSwitchActionWarnOption = ClientConfig.Get().GetPendingChangesOnSwitchAction() == UserAction.Warn;
|
||||
mSwitchActionFailOption = ClientConfig.Get().GetPendingChangesOnSwitchAction() == UserAction.Fail ||
|
||||
ClientConfig.Get().GetPendingChangesOnSwitchAction() == UserAction.NotDefined;
|
||||
}
|
||||
|
||||
internal void OnDeactivate()
|
||||
{
|
||||
PlasticGuiConfig plasticGuiConfig = PlasticGuiConfig.Get();
|
||||
plasticGuiConfig.Configuration.ShelvingUndoBehavior = GetSelectedShelvingUndoBehavior();
|
||||
plasticGuiConfig.Save();
|
||||
|
||||
ClientConfigData configData = ClientConfig.Get().GetClientConfigData();
|
||||
configData.SetPendingChangesOnSwitchAction(GetSelectedSwitchBehavior());
|
||||
ClientConfig.Get().Save(configData);
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
DrawSplitter.ForWidth(UnityConstants.SETTINGS_GUI_WIDTH);
|
||||
|
||||
DrawSettingsSection(DoDiffAndMergePreferences);
|
||||
}
|
||||
|
||||
internal void SelectShelvingUndoBehaviorForTesting(UndoShelveBehavior shelveBehavior)
|
||||
{
|
||||
mUndoChangesAfterShelve = shelveBehavior == UndoShelveBehavior.UndoChanges;
|
||||
mKeepChangesAfterShelve = shelveBehavior == UndoShelveBehavior.KeepChanges;
|
||||
mAskAlwaysAfterShelve = shelveBehavior == UndoShelveBehavior.Ask;
|
||||
}
|
||||
|
||||
internal void SelectSwitchActionForTesting(UserAction switchAction)
|
||||
{
|
||||
mSwitchActionShelveOption = switchAction == UserAction.Shelve;
|
||||
mSwitchActionAllowOption = switchAction == UserAction.None;
|
||||
mSwitchActionWarnOption = switchAction == UserAction.Warn;
|
||||
mSwitchActionFailOption = switchAction == UserAction.Fail ||
|
||||
switchAction == UserAction.NotDefined;
|
||||
}
|
||||
|
||||
UndoShelveBehavior GetSelectedShelvingUndoBehavior()
|
||||
{
|
||||
if (mUndoChangesAfterShelve)
|
||||
return UndoShelveBehavior.UndoChanges;
|
||||
|
||||
if (mKeepChangesAfterShelve)
|
||||
return UndoShelveBehavior.KeepChanges;
|
||||
|
||||
return UndoShelveBehavior.Ask;
|
||||
}
|
||||
|
||||
UserAction GetSelectedSwitchBehavior()
|
||||
{
|
||||
if (mSwitchActionAllowOption)
|
||||
return UserAction.None;
|
||||
|
||||
if (mSwitchActionWarnOption)
|
||||
return UserAction.Warn;
|
||||
|
||||
if (mSwitchActionFailOption)
|
||||
return UserAction.Fail;
|
||||
|
||||
return UserAction.Shelve;
|
||||
}
|
||||
|
||||
void DoDiffAndMergePreferences()
|
||||
{
|
||||
DoUndoAfterShelveBehaviorSettings();
|
||||
|
||||
DoSwitchActionSettings();
|
||||
}
|
||||
|
||||
void DoUndoAfterShelveBehaviorSettings()
|
||||
{
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.Name.UndoChangesAfterShelveDefaultBehavior.GetString(),
|
||||
UnityStyles.ProjectSettings.SectionTitle);
|
||||
EditorGUILayout.Space(2);
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.UndoChangesAfterShelve,
|
||||
mUndoChangesAfterShelve,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mUndoChangesAfterShelve = true;
|
||||
mKeepChangesAfterShelve = false;
|
||||
mAskAlwaysAfterShelve = false;
|
||||
}
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.KeepChangesAfterShelve,
|
||||
mKeepChangesAfterShelve,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mUndoChangesAfterShelve = false;
|
||||
mKeepChangesAfterShelve = true;
|
||||
mAskAlwaysAfterShelve = false;
|
||||
}
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.AskAlwaysAfterShelve,
|
||||
mAskAlwaysAfterShelve,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mUndoChangesAfterShelve = false;
|
||||
mKeepChangesAfterShelve = false;
|
||||
mAskAlwaysAfterShelve = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DoSwitchActionSettings()
|
||||
{
|
||||
EditorGUILayout.Space(10);
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.Name.SwitchActionOptionsTitle.GetString(),
|
||||
UnityStyles.ProjectSettings.SectionTitle);
|
||||
EditorGUILayout.Space(2);
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.SwitchActionShelve,
|
||||
mSwitchActionShelveOption,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mSwitchActionShelveOption = true;
|
||||
mSwitchActionAllowOption = false;
|
||||
mSwitchActionWarnOption = false;
|
||||
mSwitchActionFailOption = false;
|
||||
}
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.SwitchActionAllow,
|
||||
mSwitchActionAllowOption,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mSwitchActionShelveOption = false;
|
||||
mSwitchActionAllowOption = true;
|
||||
mSwitchActionWarnOption = false;
|
||||
mSwitchActionFailOption = false;
|
||||
}
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.SwitchActionWarn,
|
||||
mSwitchActionWarnOption,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mSwitchActionShelveOption = false;
|
||||
mSwitchActionAllowOption = false;
|
||||
mSwitchActionWarnOption = true;
|
||||
mSwitchActionFailOption = false;
|
||||
}
|
||||
|
||||
if (EditorGUILayout.Toggle(
|
||||
Styles.SwitchActionFail,
|
||||
mSwitchActionFailOption,
|
||||
new GUIStyle(EditorStyles.radioButton)))
|
||||
{
|
||||
mSwitchActionShelveOption = false;
|
||||
mSwitchActionAllowOption = false;
|
||||
mSwitchActionWarnOption = false;
|
||||
mSwitchActionFailOption = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawSettingsSection(Action drawSettings)
|
||||
{
|
||||
float originalLabelWidth = EditorGUIUtility.labelWidth;
|
||||
|
||||
try
|
||||
{
|
||||
EditorGUIUtility.labelWidth = UnityConstants.SETTINGS_GUI_WIDTH;
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
|
||||
drawSettings();
|
||||
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUIUtility.labelWidth = originalLabelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
class Styles
|
||||
{
|
||||
internal static GUIContent UndoChangesAfterShelve =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.UndoChangesAfterShelve.GetString(),
|
||||
PlasticLocalization.Name.UndoChangesAfterShelveExplanation.GetString());
|
||||
|
||||
internal static GUIContent KeepChangesAfterShelve =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.KeepChangesAfterShelve.GetString(),
|
||||
PlasticLocalization.Name.KeepChangesAfterShelveExplanation.GetString());
|
||||
|
||||
internal static GUIContent AskAlwaysAfterShelve =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.AskAlwaysAfterShelve.GetString(),
|
||||
PlasticLocalization.Name.AskAlwaysAfterShelveExplanation.GetString());
|
||||
|
||||
internal static GUIContent SwitchActionShelve =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.SwitchActionShelveOption.GetString(),
|
||||
PlasticLocalization.Name.SwitchActionShelveExplanation.GetString());
|
||||
|
||||
internal static GUIContent SwitchActionAllow =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.SwitchActionAllowOption.GetString(),
|
||||
PlasticLocalization.Name.SwitchActionAllowExplanation.GetString());
|
||||
|
||||
internal static GUIContent SwitchActionWarn =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.SwitchActionWarnOption.GetString(),
|
||||
PlasticLocalization.Name.SwitchActionWarnExplanation.GetString());
|
||||
|
||||
internal static GUIContent SwitchActionFail =
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.SwitchActionFailOption.GetString(),
|
||||
PlasticLocalization.Name.SwitchActionFailExplanation.GetString());
|
||||
}
|
||||
|
||||
bool mUndoChangesAfterShelve;
|
||||
bool mKeepChangesAfterShelve;
|
||||
bool mAskAlwaysAfterShelve;
|
||||
|
||||
bool mSwitchActionShelveOption;
|
||||
bool mSwitchActionAllowOption;
|
||||
bool mSwitchActionWarnOption;
|
||||
bool mSwitchActionFailOption;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c64851962d9c48068897eb736be4bed1
|
||||
timeCreated: 1731661639
|
||||
Reference in New Issue
Block a user