Example #1
0
        public static void VersionControlStatusGUI(GUIStyle style, VersionControlStatus assetStatus, Object obj, bool showAddCommit, bool showLockAndAllowLocalEdit, bool showRevert, bool confirmRevert = false)
        {
            using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
            {
                if (assetStatus.lockStatus == VCLockStatus.LockedHere || assetStatus.ModifiedOrLocalEditAllowed() || !VCUtility.ManagedByRepository(assetStatus))
                {
                    if (!assetStatus.ModifiedOrLocalEditAllowed() && obj.GetAssetPath() != "" && showAddCommit)
                    {
                        if (GUILayout.Button((VCUtility.ManagedByRepository(assetStatus) ? Terminology.commit : Terminology.add), GetPrefabToolbarStyle(style, true)))
                        {
                            VCUtility.ApplyAndCommit(obj, Terminology.commit + " from Inspector");
                        }
                    }
                }

                if (!VCUtility.HaveVCLock(assetStatus) && VCUtility.ManagedByRepository(assetStatus) && showLockAndAllowLocalEdit)
                {
                    if (assetStatus.fileStatus == VCFileStatus.Added)
                    {
                        if (GUILayout.Button(Terminology.commit, GetPrefabToolbarStyle(style, true)))
                        {
                            VCUtility.ApplyAndCommit(obj, Terminology.commit + " from Inspector");
                        }
                    }
                    else if (assetStatus.lockStatus != VCLockStatus.LockedOther)
                    {
                        if (GUILayout.Button(Terminology.getlock, GetPrefabToolbarStyle(style, true)))
                        {
                            VCCommands.Instance.GetLockTask(obj.ToAssetPaths());
                        }
                    }
                    if (!assetStatus.LocalEditAllowed())
                    {
                        if (GUILayout.Button(Terminology.allowLocalEdit, GetPrefabToolbarStyle(style, true)))
                        {
                            VCCommands.Instance.AllowLocalEdit(obj.ToAssetPaths());
                        }
                    }
                }

                if (showRevert)
                {
                    if (GUILayout.Button(Terminology.revert, GetPrefabToolbarStyle(style, VCUtility.ShouldVCRevert(obj))))
                    {
                        if ((!confirmRevert || Event.current.shift) || VCUtility.VCDialog(Terminology.revert, obj))
                        {
                            var seletedGo   = Selection.activeGameObject;
                            var revertedObj = VCUtility.Revert(obj);
                            OnNextUpdate.Do(() => Selection.activeObject = ((obj is GameObject) ? revertedObj : seletedGo));
                        }
                    }
                }
            }
        }
Example #2
0
        // This is a performance critical function
        private bool BaseFilter(VersionControlStatus vcStatus)
        {
            if (!vcStatus.Reflected)
            {
                return(false);
            }

            bool assetCriteria = vcStatus.fileStatus != VCFileStatus.None && (vcStatus.ModifiedOrLocalEditAllowed() || vcStatus.fileStatus != VCFileStatus.Normal) && vcStatus.fileStatus != VCFileStatus.Ignored;

            if (assetCriteria)
            {
                return(true);
            }

            bool localLock = vcStatus.lockStatus == VCLockStatus.LockedHere;

            if (localLock)
            {
                return(true);
            }

            var  metaStatus   = vcStatus.MetaStatus();
            bool metaCriteria = metaStatus.fileStatus != VCFileStatus.Normal && metaStatus.fileStatus != VCFileStatus.None && metaStatus.fileStatus != VCFileStatus.Ignored;

            if (metaCriteria)
            {
                return(true);
            }

            return(false);
        }
Example #3
0
        private bool GUIFilter(VersionControlStatus vcStatus)
        {
            var  metaStatus     = vcStatus.MetaStatus();
            bool projectSetting = vcStatus.assetPath.StartsWith("ProjectSettings/");
            bool unversioned    = vcStatus.fileStatus == VCFileStatus.Unversioned;
            bool meta           = metaStatus.fileStatus != VCFileStatus.Normal && vcStatus.fileStatus == VCFileStatus.Normal;
            bool modifiedNoLock = !projectSetting && vcStatus.ModifiedOrLocalEditAllowed();

            bool rest = !unversioned && !meta && !modifiedNoLock && !projectSetting;

            return((showUnversioned && unversioned) || (showMeta && meta) || (showModifiedNoLock && modifiedNoLock) || (showProjectSetting && projectSetting) || rest);
        }
Example #4
0
        private bool GUIFilter(VersionControlStatus vcStatus)
        {
            var  metaStatus     = vcStatus.MetaStatus();
            bool projectSetting = vcStatus.assetPath.StartsWith("ProjectSettings/");
            bool unversioned    = vcStatus.fileStatus == VCFileStatus.Unversioned;
            bool meta           = metaStatus.fileStatus != VCFileStatus.Normal && vcStatus.fileStatus == VCFileStatus.Normal;
            bool modifiedNoLock = !projectSetting && vcStatus.ModifiedOrLocalEditAllowed();

            bool rest = !unversioned && !meta && !modifiedNoLock && !projectSetting;

            return(((showUnversioned && unversioned) || (showMeta && meta) || (showModifiedNoLock && modifiedNoLock) || (showProjectSetting && projectSetting) || rest) &&
                   (string.IsNullOrEmpty(searchString) || vcStatus.assetPath.Compose().Contains(searchString) || vcStatus.changelist.Compose().Contains(searchString)));
        }
Example #5
0
        // This is a performance critical function
        private bool BaseFilter(VersionControlStatus vcStatus)
        {
            if (!vcStatus.Reflected)
            {
                return(false);
            }

            bool assetCriteria = vcStatus.fileStatus != VCFileStatus.None && (vcStatus.ModifiedOrLocalEditAllowed() || vcStatus.fileStatus != VCFileStatus.Normal || !ComposedString.IsNullOrEmpty(vcStatus.changelist)) && vcStatus.fileStatus != VCFileStatus.Ignored;

            if (assetCriteria)
            {
                return(true);
            }

            bool property = vcStatus.property == VCProperty.Modified || vcStatus.property == VCProperty.Conflicted;

            if (property)
            {
                return(true);
            }

            bool localLock = vcStatus.lockStatus == VCLockStatus.LockedHere;

            if (localLock)
            {
                return(true);
            }

            var  metaStatus   = vcStatus.MetaStatus();
            bool metaCriteria = metaStatus.fileStatus != VCFileStatus.Normal && (metaStatus.fileStatus != VCFileStatus.None || !ComposedString.IsNullOrEmpty(metaStatus.changelist)) && metaStatus.fileStatus != VCFileStatus.Ignored;

            if (metaCriteria)
            {
                return(true);
            }

            return(false);
        }
Example #6
0
        private bool GUIFilter(VersionControlStatus vcStatus)
        {
            if (searchString.Length > 0)
            {
                return(vcStatus.assetPath.Compose().IndexOf(searchString, System.StringComparison.OrdinalIgnoreCase) >= 0);
            }

            var  metaStatus     = vcStatus.MetaStatus();
            bool projectSetting = vcStatus.assetPath.StartsWith("ProjectSettings/");
            bool unversioned    = vcStatus.fileStatus == VCFileStatus.Unversioned;
            bool meta           = metaStatus.fileStatus != VCFileStatus.Normal && vcStatus.fileStatus == VCFileStatus.Normal;
            bool modifiedNoLock = !projectSetting && vcStatus.ModifiedOrLocalEditAllowed();

            bool bHidden = false;

            if (!string.IsNullOrEmpty(VCSettings.strHiddenFilePaths))
            {
                string[] arPaths = VCSettings.strHiddenFilePaths.Split(';');
                for (int i = 0; i < arPaths.Length; i++)
                {
                    string strPathToCheck = arPaths[i].Trim(new[] { ' ' });
                    string strPath        = vcStatus.assetPath.Compose();
                    if (strPath == strPathToCheck ||
                        (strPathToCheck != "" && strPath.StartsWith(strPathToCheck) && strPath.Replace(strPathToCheck, "").StartsWith("/")))
                    {
                        bHidden = true;
                    }
                }
            }
            bool bExternal = (vcStatus.fileStatus == VCFileStatus.External);

            bool bFitsFilter =
                !((!m_bShowExternal && bExternal) || (!m_bShowUserHidden && bHidden) || (!showUnversioned && unversioned) || (!showMeta && meta) || (!showModifiedNoLock && modifiedNoLock) || (!showProjectSetting && projectSetting));

            return(bFitsFilter);
            //bool rest = !unversioned && !meta && !modifiedNoLock && !projectSetting;
            //return (showUnversioned && unversioned) || (showMeta && meta) || (showModifiedNoLock && modifiedNoLock) || (showProjectSetting && projectSetting) || rest;
        }
Example #7
0
        public static void VersionControlStatusGUI(GUIStyle style, VersionControlStatus assetStatus, Object obj, bool showAddCommit, bool showLockAndAllowLocalEdit, bool showRevert, bool confirmRevert = false)
        {
            using (new PushState<bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
            {
                if (assetStatus.lockStatus == VCLockStatus.LockedHere || assetStatus.ModifiedOrLocalEditAllowed() || !VCUtility.ManagedByRepository(assetStatus))
                {
                    if (!assetStatus.ModifiedOrLocalEditAllowed() && obj.GetAssetPath() != "" && showAddCommit)
                    {
                        if (GUILayout.Button((VCUtility.ManagedByRepository(assetStatus) ? Terminology.commit : Terminology.add), GetPrefabToolbarStyle(style, true)))
                        {
                            VCUtility.ApplyAndCommit(obj, Terminology.commit + " from Inspector");
                        }
                    }
                }

                if (!VCUtility.HaveVCLock(assetStatus) && VCUtility.ManagedByRepository(assetStatus) && showLockAndAllowLocalEdit)
                {
                    if (assetStatus.fileStatus == VCFileStatus.Added)
                    {
                        if (GUILayout.Button(Terminology.commit, GetPrefabToolbarStyle(style, true)))
                        {
                            VCUtility.ApplyAndCommit(obj, Terminology.commit + " from Inspector");
                        }
                    }
                    else if (assetStatus.lockStatus != VCLockStatus.LockedOther)
                    {
                        if (GUILayout.Button(Terminology.getlock, GetPrefabToolbarStyle(style, true)))
                        {
                            VCCommands.Instance.GetLockTask(obj.ToAssetPaths());
                        }
                    }
                    if (!assetStatus.LocalEditAllowed())
                    {
                        if (GUILayout.Button(Terminology.allowLocalEdit, GetPrefabToolbarStyle(style, true)))
                        {
                            VCCommands.Instance.AllowLocalEdit(obj.ToAssetPaths());
                        }
                    }
                }

                if (showRevert)
                {
                    if (GUILayout.Button(Terminology.revert, GetPrefabToolbarStyle(style, VCUtility.ShouldVCRevert(obj))))
                    {
                        if ((!confirmRevert || Event.current.shift) || VCUtility.VCDialog(Terminology.revert, obj))
                        {
                            var seletedGo = Selection.activeGameObject;
                            var revertedObj = VCUtility.Revert(obj);
                            OnNextUpdate.Do(() => Selection.activeObject = ((obj is GameObject) ? revertedObj : seletedGo));
                        }
                    }
                }
            }
        }