Beispiel #1
0
            static bool IsApplicableForOperation(
                string path,
                bool isDirectory,
                AssetMenuOperations operation,
                IAssetStatusCache assetStatusCache)
            {
                SelectedAssetGroupInfo info = SelectedAssetGroupInfo.BuildFromSingleFile(
                    path, isDirectory, assetStatusCache);

                return(AssetMenuUpdater.GetAvailableMenuOperations(info).HasFlag(operation));
            }
        static void Editor_finishedDefaultHeaderGUI(UnityEditor.Editor obj)
        {
            if (!mIsEnabled)
            {
                return;
            }

            AssetList assetList = mAssetsSelection.GetSelectedAssets();

            if (mOperations == null ||
                assetList.Count == 0 ||
                string.IsNullOrEmpty(assetList[0].path))
            {
                return;
            }

            string selectionFullPath = Path.GetFullPath(assetList[0].path);

            AssetsOverlays.AssetStatus assetStatus = (assetList.Count > 1) ?
                                                     AssetsOverlays.AssetStatus.None :
                                                     mStatusCache.GetStatusForPath(selectionFullPath);

            LockStatusData lockStatusData = mStatusCache.GetLockStatusDataForPath(
                selectionFullPath);

            SelectedAssetGroupInfo selectedGroupInfo = SelectedAssetGroupInfo.
                                                       BuildFromAssetList(assetList, mStatusCache);

            AssetMenuOperations assetOperations =
                AssetMenuUpdater.GetAvailableMenuOperations(selectedGroupInfo);

            bool guiEnabledBck = GUI.enabled;

            GUI.enabled = true;
            try
            {
                DrawBackRectangle(guiEnabledBck);

                GUILayout.BeginHorizontal();

                DrawStatusLabel(assetStatus, lockStatusData);

                GUILayout.FlexibleSpace();

                DrawButtons(assetList, assetOperations);

                GUILayout.EndHorizontal();
            }
            finally
            {
                GUI.enabled = guiEnabledBck;
            }
        }
Beispiel #3
0
        internal static AssetMenuOperations GetAvailableMenuOperations(
            SelectedAssetGroupInfo info)
        {
            AssetMenuOperations result = AssetMenuOperations.None;

            if (info.SelectedCount == 0)
            {
                return(result);
            }

            if (info.IsControlledSelection &&
                info.IsCheckedInSelection &&
                info.IsFileSelection &&
                !info.HasAnyRemoteLockedInSelection)
            {
                result |= AssetMenuOperations.Checkout;
            }

            if (info.IsFileSelection &&
                info.IsPrivateSelection)
            {
                result |= AssetMenuOperations.Add;
            }

            if (info.IsFileSelection &&
                info.IsControlledSelection &&
                info.IsCheckedOutSelection)
            {
                result |= AssetMenuOperations.Checkin;
                result |= AssetMenuOperations.Undo;
            }

            if (info.SelectedCount == 1 &&
                info.IsControlledSelection &&
                !info.HasAnyAddedInSelection &&
                info.IsFileSelection)
            {
                result |= AssetMenuOperations.Diff;
            }

            if (info.SelectedCount == 1 &&
                info.IsControlledSelection &&
                !info.HasAnyAddedInSelection)
            {
                result |= AssetMenuOperations.History;
            }

            return(result);
        }
        static bool ShouldMenuItemBeEnabled(AssetMenuOperations operation)
        {
            if (sOperations == null)
            {
                return(false);
            }

            SelectedAssetGroupInfo selectedGroupInfo = SelectedAssetGroupInfo.
                                                       BuildFromAssetList(
                sAssetSelection.GetSelectedAssets(),
                sAssetStatusCache);

            AssetMenuOperations operations = AssetMenuUpdater.
                                             GetAvailableMenuOperations(selectedGroupInfo);

            return(operations.HasFlag(operation));
        }
Beispiel #5
0
            internal static List <string> ForOperation(
                IAssetSelection assetSelection,
                IAssetStatusCache assetStatusCache,
                AssetMenuOperations operation)
            {
                List <string> selectedPaths = AssetsSelection.GetSelectedPaths(
                    assetSelection.GetSelectedAssets());

                List <string> result = new List <string>(selectedPaths);

                foreach (string path in selectedPaths)
                {
                    if (MetaPath.IsMetaPath(path))
                    {
                        continue;
                    }

                    string metaPath = MetaPath.GetMetaPath(path);

                    if (!File.Exists(metaPath))
                    {
                        continue;
                    }

                    if (result.Contains(metaPath))
                    {
                        continue;
                    }

                    if (!IsApplicableForOperation(
                            metaPath, false, operation, assetStatusCache))
                    {
                        continue;
                    }

                    result.Add(metaPath);
                }

                return(result);
            }
        static void DrawButtons(
            AssetList assetList,
            AssetMenuOperations selectedGroupInfo)
        {
            if (selectedGroupInfo.HasFlag(AssetMenuOperations.Add))
            {
                DoAddButton();
            }

            if (selectedGroupInfo.HasFlag(AssetMenuOperations.Checkout))
            {
                DoCheckoutButton();
            }

            if (selectedGroupInfo.HasFlag(AssetMenuOperations.Checkin))
            {
                DoCheckinButton();
            }

            if (selectedGroupInfo.HasFlag(AssetMenuOperations.Undo))
            {
                DoUndoButton();
            }
        }
Beispiel #7
0
        static void Editor_finishedDefaultHeaderGUI(UnityEditor.Editor inspector)
        {
            if (!sIsEnabled)
            {
                return;
            }

            if (!FindWorkspace.HasWorkspace(Application.dataPath))
            {
                Disable();
                return;
            }

            sAssetSelection.SetActiveInspector(inspector);

            AssetList assetList = ((AssetOperations.IAssetSelection)
                                   sAssetSelection).GetSelectedAssets();

            if (assetList.Count == 0 ||
                string.IsNullOrEmpty(assetList[0].path))
            {
                return;
            }

            string selectionFullPath = Path.GetFullPath(assetList[0].path);

            AssetsOverlays.AssetStatus assetStatus = (assetList.Count > 1) ?
                                                     AssetsOverlays.AssetStatus.None :
                                                     PlasticPlugin.AssetStatusCache.GetStatusForPath(selectionFullPath);

            LockStatusData lockStatusData = PlasticPlugin.AssetStatusCache.GetLockStatusDataForPath(
                selectionFullPath);

            SelectedAssetGroupInfo selectedGroupInfo = SelectedAssetGroupInfo.
                                                       BuildFromAssetList(assetList, PlasticPlugin.AssetStatusCache);

            AssetMenuOperations assetOperations =
                AssetMenuUpdater.GetAvailableMenuOperations(selectedGroupInfo);

            bool guiEnabledBck = GUI.enabled;

            GUI.enabled = true;
            try
            {
                DrawBackRectangle(guiEnabledBck);

                GUILayout.BeginHorizontal();

                DrawStatusLabel(assetStatus, lockStatusData);

                GUILayout.FlexibleSpace();

                DrawButtons(assetList, assetOperations);

                GUILayout.EndHorizontal();
            }
            finally
            {
                GUI.enabled = guiEnabledBck;
            }
        }