Ejemplo n.º 1
0
        public void AddToUndo(IRevertable revertable)
        {
            if (undoCollection != null)
            {
                if (revertable is IRevertableCollection)
                {
                    foreach (IRevertable _revertable in ((IRevertableCollection)revertable).GetRevertables())
                    {
                        undoCollection.Add(_revertable);
                    }
                }
                else
                {
                    undoCollection.Add(revertable);
                }
            }
            else
            {
                undoStack.Push(revertable);

                IsSaved = false;
            }

            redoStack.Clear();
        }
Ejemplo n.º 2
0
            public bool TryGetRevertable(out IRevertable revertable)
            {
                var infos = new List <RevertablePropertyInfo>();

                foreach (CapturedProperty cp in capturedProperties)
                {
                    if (!cp.info.GetValue(obj).Equals(cp.value))
                    {
                        infos.Add(new RevertablePropertyInfo(cp.info, obj, cp.value));
                    }
                }

                if (infos.Count == 0)
                {
                    revertable = null;
                    return(false);
                }

                if (infos.Count == 1)
                {
                    revertable = new RevertablePropertyChange(infos[0]);
                }
                else
                {
                    revertable = new RevertableMulityPropertyChange(infos.ToArray());
                }

                return(true);
            }
Ejemplo n.º 3
0
        /// <summary>
        /// The user has selected an extractable thing in the catalogue and opted to include it in the extraction
        /// So we have to convert it to an <see cref="ExtractableColumn"/> (which has configuration specific stuff - and lets
        /// data analyst override stuff for this extraction only)
        ///
        /// <para>Then add it to the right hand list</para>
        /// </summary>
        /// <param name="columns"></param>
        private void Include(params IColumn[] columns)
        {
            olvSelected.BeginUpdate();
            try
            {
                //for each column we are adding
                foreach (IColumn c in columns)
                {
                    //make sure it is up to date with database

                    IRevertable r = c as IRevertable;

                    //if the column is out of date
                    if (r != null && r.HasLocalChanges().Evaluation == ChangeDescription.DatabaseCopyDifferent)
                    {
                        r.RevertToDatabaseState();//get a fresh copy
                    }
                    //add to the config
                    ExtractableColumn addMe = _config.AddColumnToExtraction(_dataSet, c);

                    //update on the UI
                    olvSelected.AddObject(addMe);
                }
            }
            finally
            {
                olvSelected.EndUpdate();
            }

            RefreshDisabledObjectStatus();
            SortSelectedByOrder();

            Publish(_config);
        }
Ejemplo n.º 4
0
        private OfferChanceToSaveDialogUI(IRevertable revertable, RevertableObjectReport differences)
        {
            _revertable = revertable;
            InitializeComponent();

            if (revertable == null)
            {
                return;
            }

            Text = "Save changes to " + revertable.GetType().Name + " " + revertable + " (ID = " + revertable.ID + ")";

            lblFirstPrompt.Text = "Would you like to save changes to " + revertable.GetType().Name + " '" + revertable + "' (ID=" + revertable.ID + ")";

            tableLayoutPanel1.RowCount = differences.Differences.Count;
            for (int index = 0; index < differences.Differences.Count; index++)
            {
                var d     = differences.Differences[index];
                var toAdd = new RevertablePropertyDifferenceUI(d);
                toAdd.Dock = DockStyle.Fill;
                tableLayoutPanel1.Controls.Add(toAdd, 0, index);
            }

            for (int i = 0; i < tableLayoutPanel1.RowStyles.Count; i++)
            {
                tableLayoutPanel1.RowStyles[i].SizeType = SizeType.AutoSize;
            }
        }
Ejemplo n.º 5
0
        public void Push(IRevertable cellChangeState)
        {
            if (_historyForwardStack.Any())
            {
                _historyForwardStack.Clear();
            }

            _historyBackStack.Push(cellChangeState);
        }
 /// <summary>
 /// Cache all the revert data.
 /// </summary>
 private void saveRevertData()
 {
     revertCache.Clear();
     // Build the cache of revert info.
     foreach (MonoBehaviour mb in this.GetComponentsInChildren <MonoBehaviour>())
     {
         IRevertable revertable = mb as IRevertable;
         if (revertable != null)
         {
             revertCache.AddRange(revertable.CacheState());
         }
     }
 }
Ejemplo n.º 7
0
            public IRevertable Revert(EditorSceneBase scene)
            {
                IRevertable[] newRevertables = new IRevertable[revertables.Length];

                int _i = 0;

                for (int i = revertables.Length - 1; i >= 0; i--) //Revertables are meant to be reverted in the reverse order (First In Last Out)
                {
                    newRevertables[_i++] = revertables[i].Revert(scene);
                }

                return(new MultiRevertable(newRevertables));
            }
Ejemplo n.º 8
0
        /// <summary>
        /// Shows a yes no to saving and describes differences in an IMapsDirectlyToDatabaseTable object which suports IRevertable
        /// </summary>
        /// <param name="revertable"></param>
        public static DialogResult?ShowIfRequired(IRevertable revertable)
        {
            if (revertable == null)
            {
                return(null);
            }

            var differences = revertable.HasLocalChanges();

            if (differences.Evaluation == ChangeDescription.DatabaseCopyDifferent)
            {
                return(new OfferChanceToSaveDialogUI(revertable, differences).ShowDialog());
            }

            return(null);
        }
Ejemplo n.º 9
0
        public void StartTransformAction(AbstractTransformAction transformAction, IRevertable revertable = null)
        {
            if (CurrentAction != null || SelectionTransformAction != NoAction)
            {
                return;
            }

            actionStartCamTarget = control.CameraTarget;

            if (revertable != null)
            {
                BeginUndoCollection();
                AddToUndo(revertable);
            }


            SelectionTransformAction = transformAction;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// The user has selected an extractable thing in the catalogue and opted to include it in the extraction
        /// So we have to convert it to an ExtractableColumn (which has configuration specific stuff - and lets
        /// data analyst override stuff for this extraction only)
        ///
        /// <para>Then add it to the right hand list</para>
        /// </summary>
        /// <param name="item"></param>
        private ExtractableColumn AddColumnToExtraction(IColumn item)
        {
            IRevertable r = item as IRevertable;

            //if the column is out of date
            if (r != null && r.HasLocalChanges().Evaluation == ChangeDescription.DatabaseCopyDifferent)
            {
                r.RevertToDatabaseState();//get a fresh copy
            }
            ExtractableColumn addMe = _config.AddColumnToExtraction(_dataSet, item);

            olvSelected.AddObject(addMe);

            RefreshDisabledObjectStatus();
            SortSelectedByOrder();

            return(addMe);
        }
Ejemplo n.º 11
0
        public ConsoleGuiEdit(IBasicActivateItems activator, IRevertable databaseObject)
        {
            _activator     = activator;
            DatabaseObject = databaseObject;

            ColorScheme = ConsoleMainWindow.ColorScheme;
            collection  =

                TableRepository.GetPropertyInfos(DatabaseObject.GetType())
                .Select(p => new PropertyInListView(p, DatabaseObject)).ToList();

            list = new ListView(collection)
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(2),
                Height = Dim.Fill(2)
            };
            list.KeyPress += List_KeyPress;

            var btnSet = new Button("Set")
            {
                X         = 0,
                Y         = Pos.Bottom(list),
                IsDefault = true
            };

            btnSet.Clicked += () =>
            {
                SetProperty(false);
            };

            var btnClose = new Button("Close")
            {
                X = Pos.Right(btnSet),
                Y = Pos.Bottom(list)
            };

            btnClose.Clicked += () => Application.RequestStop();

            this.Add(list);
            this.Add(btnSet);
            this.Add(btnClose);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Cache all the revert data.
 /// </summary>
 private void saveRevertData()
 {
     revertCache.Clear();
     {
         var __array9       = this.GetComponentsInChildren <MonoBehaviour>();
         var __arrayLength9 = __array9.Length;
         for (int __i9 = 0; __i9 < __arrayLength9; ++__i9)
         {
             var mb = (MonoBehaviour)__array9[__i9];
             {
                 IRevertable revertable = mb as IRevertable;
                 if (revertable != null)
                 {
                     revertCache.AddRange(revertable.CacheState());
                 }
             }
         }
     }
 }
Ejemplo n.º 13
0
        protected override void ActivateImpl(object o)
        {
            IRevertable m = o as IRevertable;

            if (o is IMasqueradeAs masq)
            {
                if (masq.MasqueradingAs() is IRevertable underlyingObject)
                {
                    m = underlyingObject;
                }
            }

            if (m != null)
            {
                var view = new ConsoleGuiEdit(this, m)
                {
                    Modal = true
                };
                Application.Run(view);
            }
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Cache all the revert data.
 /// </summary>
 private void saveRevertData()
 {
     revertCache.Clear();
     // Build the cache of revert info.
     foreach (MonoBehaviour mb in this.GetComponentsInChildren <MonoBehaviour>())
     {
         IRevertable revertable = mb as IRevertable;
         if (revertable != null)
         {
             RevertInfo[] ri = revertable.CacheState();
             if (ri == null || ri.Length < 1)
             {
                 Debug.Log(string.Format("Cinema Director tried to cache the state of {0}, but failed.", mb.name));
             }
             else
             {
                 revertCache.AddRange(ri);
             }
         }
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Cache all the revert data.
 /// </summary>
 private void saveRevertData()
 {
     revertCache.Clear();
     // Build the cache of revert info.
     MonoBehaviour[] mbArray = this.GetComponentsInChildren <MonoBehaviour>();
     for (int i = 0; i < mbArray.Length; i++)
     {
         IRevertable revertable = mbArray[i] as IRevertable;
         if (revertable != null)
         {
             List <RevertInfo> ri = revertable.CacheState();
             if (ri == null || ri.Count < 1)
             {
                 //Debug.Log(HobaString.Format("Cinema Director tried to cache the state of {0}, but failed.", mbArray[i].name));
             }
             else
             {
                 revertCache.AddRange(ri);
             }
         }
     }
 }
Ejemplo n.º 16
0
        public SecondaryConstraintUI(ICatalogueRepository repository, SecondaryConstraint secondaryConstriant, string[] otherColumns)
        {
            const int rowHeight = 30;
            //the amount of additional space required to accomodate description labels
            int inflation = 0;

            _repository = repository;
            this.SecondaryConstriant = secondaryConstriant;

            _otherColumns = otherColumns;

            InitializeComponent();

            if (repository == null)
            {
                return;
            }

            cbxConsequence.DataSource   = Enum.GetValues(typeof(Consequence));
            cbxConsequence.SelectedItem = secondaryConstriant.Consequence;

            //put the name of the secondary constraint into the header
            this.lblType.Text = SecondaryConstriant.GetType().Name;

            lblConsequence.Left = lblType.Right + 5;
            cbxConsequence.Left = lblConsequence.Right + 5;

            //work out what properties can be set on this constraint and create the relevant controls using reflection
            _requiredProperties = secondaryConstriant.GetType().GetProperties().Where(p =>
                                                                                      p.CanRead && p.CanWrite && p.GetSetMethod(true).IsPublic

                                                                                      && p.Name != "Name" &&//skip this one, it is Writeable in order to support XMLSerialization...
                                                                                      p.Name != "Consequence" &&//skip this one because it is dealt with explicitly
                                                                                      !p.IsDefined(typeof(HideOnValidationUI), true)
                                                                                      ).ToArray();

            for (int i = 0; i < _requiredProperties.Length; i++)
            {
                var currentRowPanel = new Panel();
                currentRowPanel.Bounds = new Rectangle(0, 0, tableLayoutPanel1.Width, rowHeight);
                currentRowPanel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                currentRowPanel.Margin = Padding.Empty;

                tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;

                tableLayoutPanel1.Controls.Add(currentRowPanel, 0, i + 1);


                Label lblName = new Label();
                lblName.Text     = _requiredProperties[i].Name;
                lblName.AutoSize = true;

                object currentValue = _requiredProperties[i].GetValue(SecondaryConstriant, null);


                //Hard Typed properties - Bool
                if (_requiredProperties[i].PropertyType == typeof(bool))
                {
                    CheckBox boolControl = new CheckBox();
                    boolControl.Text    = _requiredProperties[i].Name;
                    boolControl.Tag     = i;
                    boolControl.Checked = (bool)currentValue;

                    boolControl.CheckStateChanged += (s, e) => _requiredProperties[(int)boolControl.Tag].SetValue(SecondaryConstriant, boolControl.Checked, null);
                    currentRowPanel.Controls.Add(boolControl);
                }
                else
                if (_requiredProperties[i].PropertyType == typeof(PredictionRule))    //Hard Typed property PredictionRule
                {
                    //for prediction rules fields
                    ComboBox cbx = new ComboBox();
                    cbx.Items.AddRange(Validator.GetPredictionExtraTypes());
                    cbx.Items.Add("");
                    cbx.DropDownStyle         = ComboBoxStyle.DropDownList;
                    cbx.DisplayMember         = "Name";
                    cbx.Tag                   = i;
                    cbx.SelectedIndexChanged += (s, e) => _requiredProperties[(int)cbx.Tag].SetValue(SecondaryConstriant, cbx.SelectedItem is Type ? Activator.CreateInstance((Type)cbx.SelectedItem) : null);
                    cbx.Width                 = 200;

                    //The dropdown box is a list of Types but we are actually instantiating a value when user selects it (for XML Serialization).  Consequently we must now get the Type for selection purposes
                    if (currentValue != null)
                    {
                        cbx.SelectedItem = currentValue.GetType();
                    }

                    currentRowPanel.Controls.Add(lblName);

                    cbx.Left = lblName.Right + 5;
                    currentRowPanel.Controls.Add(cbx);
                }
                else
                {
                    //it's a value control (basically anything that can be represented by text (i.e. not a boolean))
                    Control valueControl;

                    //if it is expects a column then create a dropdown box
                    if (_requiredProperties[i].IsDefined(typeof(ExpectsColumnNameAsInput), true))
                    {
                        //for column fields
                        ComboBox cbx = new ComboBox();
                        cbx.Items.AddRange(_otherColumns);
                        cbx.Items.Add("");
                        cbx.DropDownStyle         = ComboBoxStyle.DropDownList;
                        cbx.Tag                   = i;
                        cbx.SelectedIndexChanged += (s, e) => _requiredProperties[(int)cbx.Tag].SetValue(SecondaryConstriant, Convert.ChangeType(cbx.SelectedItem, _requiredProperties[(int)cbx.Tag].PropertyType), null);
                        cbx.Width                 = 350;

                        valueControl = cbx;
                    }
                    else
                    if (typeof(IMapsDirectlyToDatabaseTable).IsAssignableFrom(_requiredProperties[i].PropertyType))//it is a Catalogue type
                    {
                        ComboBox dd = new ComboBox();
                        dd.Tag   = i;
                        dd.Width = 350;
                        dd.AutoCompleteSource = AutoCompleteSource.ListItems;
                        dd.AutoCompleteMode   = AutoCompleteMode.Suggest;
                        var entities = _repository.GetAllObjects(_requiredProperties[i].PropertyType).ToArray();

                        if (!entities.Any())
                        {
                            if (_requiredProperties[i].PropertyType == typeof(StandardRegex))
                            {
                                MessageBox.Show("You currently do not have any standard regex concepts in your database.  These can be created from the Table(Advanced) collection.",
                                                "No StandardRegex configured in your Catalogue");
                            }
                            else
                            {
                                MessageBox.Show("You currently do not have any " + _requiredProperties[i].PropertyType + " in your database", "Catalogue Entity Collection Empty");
                            }
                        }
                        else
                        {
                            dd.Items.Add("<<Clear>>");
                            dd.Items.AddRange(entities);
                            dd.SelectedIndexChanged += (s, e) => _requiredProperties[(int)dd.Tag].SetValue(SecondaryConstriant, dd.SelectedItem as IMapsDirectlyToDatabaseTable, null);
                        }

                        //See if it has a value
                        IRevertable v = _requiredProperties[i].GetValue(SecondaryConstriant, null) as IRevertable;

                        //It has a value, this is a dropdown control right here though so if the revertable state out of date then it means someone else made a change to the database while we were picking columns
                        if (v != null)
                        {
                            v.RevertToDatabaseState();
                        }

                        valueControl = dd;
                    }
                    else //otherwise create a textbox
                    {
                        //for string fields
                        valueControl = new TextBox();

                        //if they edit this then write it to the SecondaryConstraint... we can't put i in directly because it goes out of scope so instead we stuff it into Tag and then
                        //get it back at delegate execution time when they change the text.
                        valueControl.Tag          = i;
                        valueControl.TextChanged += setTextOrParseableProperty;

                        if (_requiredProperties[i].IsDefined(typeof(ExpectsLotsOfText), true))
                        {
                            valueControl.Width = 300;
                        }
                    }

                    if (currentValue != null)
                    {
                        valueControl.Text = _requiredProperties[i].GetValue(SecondaryConstriant, null).ToString().Replace("00:00:00", "");
                    }

                    currentRowPanel.Controls.Add(lblName);

                    valueControl.Left = lblName.Right + 5;
                    currentRowPanel.Controls.Add(valueControl);
                }

                var desc = _requiredProperties[i].GetCustomAttribute <DescriptionAttribute>();

                if (desc != null)
                {
                    var lbl = new Label();

                    lbl.AutoSize = true;
                    lbl.Text     = desc.Description;

                    lbl.Font = new Font(lbl.Font, FontStyle.Italic);

                    //make some space for it
                    inflation += lbl.Height - 7;
                    lbl.Top    = rowHeight - 7;

                    currentRowPanel.Controls.Add(lbl);
                    currentRowPanel.Height = rowHeight + lbl.Height;
                }
            }

            //first row
            tableLayoutPanel1.RowStyles[0].SizeType = SizeType.AutoSize;

            Height = (_requiredProperties.Length * rowHeight) + 35 + inflation;

            loadingComplete = true;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Bake the Mecanim preview data.
        /// </summary>
        public void Bake()
        {
            if (Actor == null || Application.isPlaying)
            {
                return;
            }
            Animator animator = Actor.GetComponent <Animator>();

            if (animator == null)
            {
                return;
            }

            List <RevertInfo> revertCache = new List <RevertInfo>();

            // Build the cache of revert info.
            foreach (MonoBehaviour mb in this.GetComponentsInChildren <MonoBehaviour>())
            {
                IRevertable revertable = mb as IRevertable;
                if (revertable != null)
                {
                    revertCache.AddRange(revertable.CacheState());
                }
            }

            Vector3    position = Actor.transform.localPosition;
            Quaternion rotation = Actor.transform.localRotation;
            Vector3    scale    = Actor.transform.localScale;

            float frameRate  = 30;
            int   frameCount = (int)((Cutscene.Duration * frameRate) + 2);

            animator.StopPlayback();
            animator.recorderStartTime = 0;
            animator.StartRecording(frameCount);

            base.SetRunningTime(0);

            for (int i = 0; i < frameCount - 1; i++)
            {
                foreach (TimelineTrack track in GetTracks())
                {
                    if (!(track is DialogueTrack))
                    {
                        track.UpdateTrack(i * (1.0f / frameRate), (1.0f / frameRate));
                    }
                }
                animator.Update(1.0f / frameRate);
            }
            animator.recorderStopTime = frameCount * (1.0f / frameRate);
            animator.StopRecording();
            animator.StartPlayback();

            hasBeenBaked = true;

            // Return the Actor to his initial position.
            Actor.transform.localPosition = position;
            Actor.transform.localRotation = rotation;
            Actor.transform.localScale    = scale;

            foreach (RevertInfo revertable in revertCache)
            {
                if (revertable != null)
                {
                    if ((revertable.EditorRevert == RevertMode.Revert && !Application.isPlaying) ||
                        (revertable.RuntimeRevert == RevertMode.Revert && Application.isPlaying))
                    {
                        revertable.Revert();
                    }
                }
            }

            base.Initialize();
        }
Ejemplo n.º 18
0
 protected virtual void OnUndo(IRevertable revertable)
 {
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Bake the Mecanim preview data.
        /// </summary>
        public void Bake()
        {
#if PROFILE_FILE
            Profiler.BeginSample("CharacterTrackGroup.Bake");
#endif // PROFILE_FILE
            if (Actor == null || Application.isPlaying)
            {
#if PROFILE_FILE
                Profiler.EndSample();
#endif // PROFILE_FILE
                return;
            }
            Animator animator = Actor.GetComponent <Animator>();
            if (animator == null)
            {
#if PROFILE_FILE
                Profiler.EndSample();
#endif // PROFILE_FILE
                return;
            }

            List <RevertInfo> revertCache = new List <RevertInfo>();

            // Build the cache of revert info.
            var comps = this.GetComponentsInChildren <MonoBehaviour>();
            for (var i = 0; i < comps.Length; ++i)
            {
                MonoBehaviour mb         = comps[i];
                IRevertable   revertable = mb as IRevertable;
                if (revertable != null)
                {
                    revertCache.AddRange(revertable.CacheState());
                }
            }

            Vector3    position = Actor.transform.localPosition;
            Quaternion rotation = Actor.transform.localRotation;
            Vector3    scale    = Actor.transform.localScale;

            float frameRate  = 30;
            int   frameCount = (int)((Cutscene.Duration * frameRate) + 2);
            animator.StopPlayback();
            animator.recorderStartTime = 0;
            animator.StartRecording(frameCount);

            base.SetRunningTime(0);

            for (int i = 0; i < frameCount - 1; i++)
            {
                var tracks = GetTracks();
                for (int j = 0; j < tracks.Length; ++j)
                {
                    TimelineTrack track = tracks[j];
                    if (!(track is DialogueTrack))
                    {
                        track.UpdateTrack(i * (1.0f / frameRate), (1.0f / frameRate));
                    }
                }
                animator.Update(1.0f / frameRate);
            }
            animator.recorderStopTime = frameCount * (1.0f / frameRate);
            animator.StopRecording();
            animator.StartPlayback();

            hasBeenBaked = true;

            // Return the Actor to his initial position.
            Actor.transform.localPosition = position;
            Actor.transform.localRotation = rotation;
            Actor.transform.localScale    = scale;

            for (int i = 0; i < revertCache.Count; ++i)
            {
                RevertInfo revertable = revertCache[i];
                if (revertable != null)
                {
                    if ((revertable.EditorRevert == RevertMode.Revert && !Application.isPlaying) ||
                        (revertable.RuntimeRevert == RevertMode.Revert && Application.isPlaying))
                    {
                        revertable.Revert();
                    }
                }
            }

            base.Initialize();
#if PROFILE_FILE
            Profiler.EndSample();
#endif // PROFILE_FILE
        }
Ejemplo n.º 20
0
 protected virtual void OnSubmitUndoable(IRevertable revertable)
 {
 }
Ejemplo n.º 21
0
 protected override void OnUndo(IRevertable revertable)
 {
 }
Ejemplo n.º 22
0
 public DoubleRevertable(IRevertable first, IRevertable second)
 {
     this.first  = first;
     this.second = second;
 }
Ejemplo n.º 23
0
 protected override void OnSubmitUndoable(IRevertable revertable)
 {
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Bake the Mecanim preview data.
        /// </summary>
        public void Bake()
        {
            if (Actor == null || Application.isPlaying)
            {
                return;
            }
            Animator animator = Actor.GetComponent <Animator>();

            if (animator == null)
            {
                return;
            }

            List <RevertInfo> revertCache = new List <RevertInfo>();
            {
                var __array1       = this.GetComponentsInChildren <MonoBehaviour>();
                var __arrayLength1 = __array1.Length;
                for (int __i1 = 0; __i1 < __arrayLength1; ++__i1)
                {
                    var mb = (MonoBehaviour)__array1[__i1];
                    {
                        IRevertable revertable = mb as IRevertable;
                        if (revertable != null)
                        {
                            revertCache.AddRange(revertable.CacheState());
                        }
                    }
                }
            }
            Vector3    position = Actor.transform.localPosition;
            Quaternion rotation = Actor.transform.localRotation;
            Vector3    scale    = Actor.transform.localScale;

            float frameRate  = 30;
            int   frameCount = (int)((Cutscene.Duration * frameRate) + 2);

            animator.StopPlayback();
            animator.recorderStartTime = 0;
            animator.StartRecording(frameCount);

            base.SetRunningTime(0);

            for (int i = 0; i < frameCount - 1; i++)
            {
                {
                    var __array2       = GetTracks();
                    var __arrayLength2 = __array2.Length;
                    for (int __i2 = 0; __i2 < __arrayLength2; ++__i2)
                    {
                        var track = (TimelineTrack)__array2[__i2];
                        {
                            if (!(track is DialogueTrack))
                            {
                                track.UpdateTrack(i * (1.0f / frameRate), (1.0f / frameRate));
                            }
                        }
                    }
                }
                animator.Update(1.0f / frameRate);
            }
            animator.recorderStopTime = frameCount * (1.0f / frameRate);
            animator.StopRecording();
            animator.StartPlayback();

            hasBeenBaked = true;

            // Return the Actor to his initial position.
            Actor.transform.localPosition = position;
            Actor.transform.localRotation = rotation;
            Actor.transform.localScale    = scale;
            {
                var __list3      = revertCache;
                var __listCount3 = __list3.Count;
                for (int __i3 = 0; __i3 < __listCount3; ++__i3)
                {
                    var revertable = (RevertInfo)__list3[__i3];
                    {
                        if (revertable != null)
                        {
                            if ((revertable.EditorRevert == RevertMode.Revert && !Application.isPlaying) ||
                                (revertable.RuntimeRevert == RevertMode.Revert && Application.isPlaying))
                            {
                                revertable.Revert();
                            }
                        }
                    }
                }
            }
            base.Initialize();
        }
Ejemplo n.º 25
0
        public void StartTransformAction(AbstractTransformAction transformAction, int part = -1, IRevertable revertable = null)
        {
            if (revertable != null)
            {
                BeginUndoCollection();
                AddToUndo(revertable);
            }

            if (part != -1)
            {
                HoveredPart     = part;
                ExclusiveAction = transformAction;
            }
            else
            {
                CurrentAction = transformAction;
            }
        }
Ejemplo n.º 26
0
        public void StartTransformAction(LocalOrientation localOrientation, DragActionType dragActionType, int part = -1, IRevertable revertable = null)
        {
            AbstractTransformAction transformAction;

            Vector3 pivot;

            draggingDepth = control.PickingDepth;
            if (part != -1)
            {
                pivot = localOrientation.Origin;
            }
            else
            {
                BoundingBox box = BoundingBox.Default;

                foreach (IEditableObject obj in GetObjects())
                {
                    obj.GetSelectionBox(ref box);
                }

                pivot = box.GetCenter();

                if (box == BoundingBox.Default)
                {
                    return;
                }
            }

            switch (dragActionType)
            {
            case DragActionType.TRANSLATE:
                transformAction = new TranslateAction(control, control.GetMousePos(), pivot, draggingDepth);
                break;

            case DragActionType.ROTATE:
                transformAction = new RotateAction(control, control.GetMousePos(), pivot, draggingDepth);
                break;

            case DragActionType.SCALE:
                transformAction = new ScaleAction(control, control.GetMousePos(), pivot);
                break;

            case DragActionType.SCALE_INDIVIDUAL:
                transformAction = new ScaleActionIndividual(control, control.GetMousePos(), localOrientation);
                break;

            default:
                return;
            }

            StartTransformAction(transformAction, part, revertable);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Bake the Mecanim preview data.
        /// </summary>
        public void Bake()
        {
            if (Actor == null || Application.isPlaying)
            {
                return;
            }
            Animator animator = Actor.GetComponent <Animator>();

            if (animator == null)
            {
                return;
            }

            AnimatorCullingMode cullingData = animator.cullingMode;

            animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;

            List <RevertInfo> revertCache = new List <RevertInfo>();

            // Build the cache of revert info.
            MonoBehaviour[] mb = this.GetComponentsInChildren <MonoBehaviour>();
            for (int i = 0; i < mb.Length; i++)
            {
                IRevertable revertable = mb[i] as IRevertable;
                if (revertable != null)
                {
                    revertCache.AddRange(revertable.CacheState());
                }
            }

            Vector3    position = Actor.transform.localPosition;
            Quaternion rotation = Actor.transform.localRotation;
            Vector3    scale    = Actor.transform.localScale;

            Cutscene cutScene   = GetCutScene();
            float    frameRate  = 30;
            int      frameCount = (int)((cutScene.Duration * frameRate) + 2);

            animator.StopPlayback();
            animator.recorderStartTime = 0;
            animator.StartRecording(frameCount);

            base.SetRunningTime(0);

            for (int i = 0; i < frameCount - 1; i++)
            {
                List <TimelineTrack> tracks = GetTracks();
                for (int j = 0; j < tracks.Count; j++)
                {
                    tracks[j].UpdateTrack(i * (1.0f / frameRate), (1.0f / frameRate));
                }
                animator.Update(1.0f / frameRate);
            }
            animator.recorderStopTime = frameCount * (1.0f / frameRate);
            animator.StopRecording();
            animator.StartPlayback();

            hasBeenBaked = true;

            // Return the Actor to his initial position.
            Actor.transform.localPosition = position;
            Actor.transform.localRotation = rotation;
            Actor.transform.localScale    = scale;

            for (int i = 0; i < revertCache.Count; i++)
            {
                RevertInfo revertable = revertCache[i];
                if (revertable != null)
                {
                    if ((revertable.EditorRevert == RevertMode.Revert && !Application.isPlaying) ||
                        (revertable.RuntimeRevert == RevertMode.Revert && Application.isPlaying))
                    {
                        revertable.Revert();
                    }
                }
            }
            animator.cullingMode = cullingData;
            base.Initialize();
        }
Ejemplo n.º 28
0
 public RevertedEventArgs(IRevertable revertable)
 {
     Revertable = revertable;
 }
Ejemplo n.º 29
0
 public void AppendOperation(IRevertable revertable)
 {
     Operations.Add(revertable);
     Save();
 }