Esempio n. 1
0
        public static ValidActions GetValidActions(string assetPath, Object instance = null)
        {
            if (!VCCommands.Active || string.IsNullOrEmpty(assetPath))
            {
                return(noAction);
            }

            var assetStatus = VCCommands.Instance.GetAssetStatus(assetPath);

            ValidActions validActions;
            bool         isPrefab              = instance != null && PrefabHelper.IsPrefab(instance);
            bool         isPrefabParent        = isPrefab && PrefabHelper.IsPrefabParent(instance);
            bool         isFolder              = AssetDatabase.IsValidFolder(assetPath);
            bool         diffableAsset         = VCUtility.IsDiffableAsset(assetPath);
            bool         mergableAsset         = VCUtility.IsMergableAsset(assetPath);
            bool         modifiedDiffableAsset = diffableAsset && assetStatus.fileStatus != VCFileStatus.Normal;
            bool         modifiedMeta          = assetStatus.MetaStatus().fileStatus != VCFileStatus.Normal;
            bool         lockedMeta            = assetStatus.MetaStatus().lockStatus == VCLockStatus.LockedHere;
            bool         modified              = assetStatus.fileStatus == VCFileStatus.Modified;
            bool         deleted        = assetStatus.fileStatus == VCFileStatus.Deleted;
            bool         added          = assetStatus.fileStatus == VCFileStatus.Added;
            bool         unversioned    = assetStatus.fileStatus == VCFileStatus.Unversioned;
            bool         ignored        = assetStatus.fileStatus == VCFileStatus.Ignored;
            bool         replaced       = assetStatus.fileStatus == VCFileStatus.Replaced;
            bool         lockedByOther  = assetStatus.lockStatus == VCLockStatus.LockedOther;
            bool         managedByRep   = VCUtility.ManagedByRepository(assetStatus);
            bool         haveControl    = VCUtility.HaveAssetControl(assetStatus);
            bool         haveLock       = VCUtility.HaveVCLock(assetStatus);
            bool         allowLocalEdit = assetStatus.LocalEditAllowed();
            bool         pending        = assetStatus.reflectionLevel == VCReflectionLevel.Pending;

            validActions.showAdd        = !pending && !ignored && unversioned;
            validActions.showOpen       = !pending && !validActions.showAdd && !added && !haveLock && !deleted && !isFolder && !mergableAsset && (!lockedByOther || allowLocalEdit);
            validActions.showDiff       = !pending && !ignored && !deleted && modifiedDiffableAsset && managedByRep;
            validActions.showCommit     = !pending && !ignored && !allowLocalEdit && (haveLock || added || deleted || modifiedDiffableAsset || isFolder || modifiedMeta);
            validActions.showRevert     = !pending && !ignored && !unversioned && (haveControl || modified || added || deleted || replaced || modifiedDiffableAsset || modifiedMeta || lockedMeta);
            validActions.showDelete     = !pending && !ignored && !deleted && !lockedByOther;
            validActions.showOpenLocal  = !pending && !ignored && !deleted && !isFolder && !allowLocalEdit && !unversioned && !added && !haveLock && !mergableAsset;
            validActions.showUnlock     = !pending && !ignored && !allowLocalEdit && haveLock;
            validActions.showUpdate     = !pending && !ignored && !added && managedByRep && instance != null;
            validActions.showForceOpen  = !pending && !ignored && !deleted && !isFolder && !allowLocalEdit && !unversioned && !added && lockedByOther && Event.current.shift;
            validActions.showDisconnect = isPrefab && !isPrefabParent;

            return(validActions);
        }
Esempio n. 2
0
 public static bool HaveAssetControl(this VersionControlStatus vcs)
 {
     return(VCUtility.HaveAssetControl(vcs));
 }
Esempio n. 3
0
        public static ValidActions GetValidActions(string assetPath, Object instance = null)
        {
            using (sceneviewUpdateMarker.Auto())
            {
                if (!VCCommands.Active || string.IsNullOrEmpty(assetPath))
                {
                    return(noAction);
                }

                var assetStatus = VCCommands.Instance.GetAssetStatus(assetPath);

                bool isPrefab              = instance != null && PrefabHelper.IsPrefab(instance);
                bool isPrefabParent        = isPrefab && PrefabHelper.IsPrefabParent(instance);
                bool isFolder              = AssetDatabase.IsValidFolder(assetPath);
                bool diffableAsset         = MergeHandler.IsDiffableAsset(assetPath);
                bool mergableAsset         = MergeHandler.IsMergableAsset(assetPath);
                bool modifiedDiffableAsset = diffableAsset && assetStatus.fileStatus != VCFileStatus.Normal;
                bool modifiedMeta          = assetStatus.MetaStatus().fileStatus != VCFileStatus.Normal;
                bool lockedMeta            = assetStatus.MetaStatus().lockStatus == VCLockStatus.LockedHere;
                bool modified              = assetStatus.fileStatus == VCFileStatus.Modified;
                bool localOnly             = assetStatus.localOnly;
                bool deleted        = assetStatus.fileStatus == VCFileStatus.Deleted;
                bool added          = assetStatus.fileStatus == VCFileStatus.Added;
                bool unversioned    = assetStatus.fileStatus == VCFileStatus.Unversioned;
                bool ignored        = assetStatus.fileStatus == VCFileStatus.Ignored;
                bool replaced       = assetStatus.fileStatus == VCFileStatus.Replaced;
                bool lockedByOther  = assetStatus.lockStatus == VCLockStatus.LockedOther;
                bool managedByRep   = VCUtility.ManagedByRepository(assetStatus);
                bool haveControl    = VCUtility.HaveAssetControl(assetStatus);
                bool haveLock       = VCUtility.HaveVCLock(assetStatus);
                bool allowLocalEdit = assetStatus.LocalEditAllowed();
                bool pending        = assetStatus.reflectionLevel == VCReflectionLevel.Pending;
                bool mergeinfo      = assetStatus.property == VCProperty.Modified;
                bool conflicted     = assetStatus.fileStatus == VCFileStatus.Conflicted;
                bool hasChangeSet   = !ComposedString.IsNullOrEmpty(assetStatus.changelist);

                bool showAdd    = !pending && !ignored && unversioned;
                bool showOpen   = !pending && !showAdd && !added && !haveLock && !deleted && !isFolder && !mergableAsset && ((!lockedByOther && !localOnly) || allowLocalEdit);
                bool showDiff   = !pending && !ignored && !deleted && modifiedDiffableAsset && managedByRep;
                bool showCommit = !pending && !ignored && !allowLocalEdit && !localOnly && (haveLock || added || deleted || modifiedDiffableAsset || modifiedMeta || mergeinfo);
                bool showRevert = !pending && !ignored && !unversioned &&
                                  (haveControl || modified || added || deleted || replaced || modifiedDiffableAsset || modifiedMeta || lockedMeta || mergeinfo);
                bool showDelete           = !pending && !ignored && !deleted && !lockedByOther;
                bool showOpenLocal        = !pending && !ignored && !deleted && !isFolder && !allowLocalEdit && !unversioned && !added && !haveLock && !mergableAsset && !localOnly;
                bool showUnlock           = !pending && !ignored && !allowLocalEdit && haveLock;
                bool showUpdate           = !pending && !ignored && !added && managedByRep && instance != null;
                bool showUseTheirs        = !pending && !ignored && conflicted;
                bool showUseMine          = !pending && !ignored && conflicted;
                bool showMerge            = !pending && !ignored && conflicted && mergableAsset;
                bool showAddChangeList    = !pending && !ignored && !unversioned;
                bool showRemoveChangeList = !pending && !ignored && hasChangeSet;

                ValidActions validActions = 0;
                if (showAdd)
                {
                    validActions |= ValidActions.Add;
                }
                if (showOpen)
                {
                    validActions |= ValidActions.Open;
                }
                if (showDiff)
                {
                    validActions |= ValidActions.Diff;
                }
                if (showCommit)
                {
                    validActions |= ValidActions.Commit;
                }
                if (showRevert)
                {
                    validActions |= ValidActions.Revert;
                }
                if (showDelete)
                {
                    validActions |= ValidActions.Delete;
                }
                if (showOpenLocal)
                {
                    validActions |= ValidActions.OpenLocal;
                }
                if (showUnlock)
                {
                    validActions |= ValidActions.Unlock;
                }
                if (showUpdate)
                {
                    validActions |= ValidActions.Update;
                }
                if (showUseTheirs)
                {
                    validActions |= ValidActions.UseTheirs;
                }
                if (showUseMine)
                {
                    validActions |= ValidActions.UseMine;
                }
                if (showMerge)
                {
                    validActions |= ValidActions.Merge;
                }
                if (showAddChangeList)
                {
                    validActions |= ValidActions.AddChangeList;
                }
                if (showRemoveChangeList)
                {
                    validActions |= ValidActions.RemoveChangeList;
                }

                return(validActions);
            }
        }