Пример #1
0
        public ActionDictionary InitAuto()
        {
            var actionMinLength = ValidActions.Select(a => a.route.Length).Min();
            var actions         = new ActionDictionary(actionMinLength);

            AddActions(actions, ValidActions, 0);
            return(actions);
        }
Пример #2
0
 static void EditorUpdate()
 {
     selectionPath = GetSelectionsPersistentAssetPath();
     shouldDraw    = VCSettings.SceneviewGUI && VCCommands.Active && VCUtility.ValidAssetPath(selectionPath);
     if (shouldDraw)
     {
         string assetPath = selectionPath;
         VCUtility.RequestStatus(assetPath, VCSettings.HierarchyReflectionMode);
         vcSceneStatus = VCCommands.Instance.GetAssetStatus(assetPath);
         validActions  = VCGUIControls.GetValidActions(assetPath);
         if (backgroundGuiStyle != null)
         {
             backgroundGuiStyle.normal.background = IconUtils.boxIcon.GetTexture(AssetStatusUtils.GetStatusColor(vcSceneStatus, true));
         }
     }
 }
Пример #3
0
    private string RenderActionParameters(ActionDefinition actionDefinition)
    {
        if (!ValidActions.Contains(actionDefinition.ActionName))
        {
            return(string.Empty);
        }

        var editor = ActionParameterEditorFactory.CreateEditor(actionDefinition);

        if (editor != null)
        {
            GUILayout.Label("\tAction Parameters");
            editor.OnInspectorGUI();
            return(editor.SerializedValue);
        }

        GUILayout.Label("\tNo Parameters Needed");
        return(string.Empty);
    }
Пример #4
0
        /// <summary>
        /// Be careful using this constructor, it's intended to be used internally.
        /// </summary>
        /// <param name="parentState"></param>
        /// <param name="actionToTake"></param>
        private StateOfBottles(StateOfBottles parentState, ValidActions actionToTake)
        {
            //TODO: Verify if simply FiveLiterBottle = ParentState.FiveLiterBottle is a copy or a reference
            //For now we play safe and copy manually
            FiveLiterBottle  = new Bottle(parentState.FiveLiterBottle);
            ThreeLiterBottle = new Bottle(parentState.ThreeLiterBottle);

            this.ParentState = parentState;

            ActionTaken = actionToTake;

            ActionsTaken = parentState.ActionsTaken + 1;
            switch (actionToTake)
            {
            case ValidActions.Fill5:
                FiveLiterBottle.Fill();
                break;

            case ValidActions.Fill3:
                ThreeLiterBottle.Fill();
                break;

            case ValidActions.Empty5:
                FiveLiterBottle.Empty();
                break;

            case ValidActions.Empty3:
                ThreeLiterBottle.Empty();
                break;

            case ValidActions.Pour5To3:
                ThreeLiterBottle.AddToVolumeFromThisBottle(FiveLiterBottle);
                break;

            case ValidActions.Pour3To5:
                FiveLiterBottle.AddToVolumeFromThisBottle(ThreeLiterBottle);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(actionToTake), actionToTake, null);
            }
        }
Пример #5
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);
            }
        }
Пример #6
0
 private StateOfBottles Perform(ValidActions action)
 {
     return(new StateOfBottles(this, action));
 }