private IEnumerator ProcessAnimateUndo <T>(IEnumerable <T> extras)
            where T : MonoBehaviour
        {
            HistoryState state = this.history[this.history.Count - 1];

            this.animationFinished = false;
            bool finished = false;

            while (!finished)
            {
                finished = true;
                if (!AnimateOne(state, this.gameObject))
                {
                    finished = false;
                }
                if (extras != null)
                {
                    foreach (T obj in extras)
                    {
                        if (!AnimateOne(state, obj.gameObject))
                        {
                            finished = false;
                        }
                    }
                }
                this.animationFinished = finished;
                yield return(null);
            }
            this.Restore(state, extras);
        }
Exemple #2
0
    //
    // Undo system implementation
    //

    public void RecordHistory(string state, Direction playerDir)
    {
        if (activeLevel == null)
        {
            return;
        }

        if (gameCamera.isInTransition)
        {
            return;
        }

        var room = activeLevel.room;

        if (room == null)
        {
            Debug.Log("Room is null");
            return;
        }

        var hs = new HistoryState(state, playerDir);

        history.Add(hs);
        levelUI.UpdateText(activeLevel.goldMedalThreshold, history.Count);
    }
 private void ForEachPriorityHighlight(HistoryState state, byte p)
 {
     if (state.IsBeforeOrDuring(p))
     {
         uiController.HighlightCommands(p);
     }
 }
        public void OnWindowEnabled()
        {
            UnityConnect.instance.StateChanged     += new UnityEditor.Connect.StateChangedDelegate(this.OnConnectStateChanged);
            Collab.instance.StateChanged           += new StateChangedDelegate(this.OnCollabStateChanged);
            Collab.instance.RevisionUpdated        += new StateChangedDelegate(this.OnCollabRevisionUpdated);
            Collab.instance.JobsCompleted          += new StateChangedDelegate(this.OnCollabJobsCompleted);
            EditorApplication.playModeStateChanged += new Action <PlayModeStateChange>(this.OnPlayModeStateChanged);
            if (Collab.instance.IsConnected())
            {
                this.m_ConnectState = UnityConnect.instance.GetConnectInfo();
                this.m_CollabState  = Collab.instance.GetCollabInfo();
            }
            this.m_Window.revisionActionsEnabled = !EditorApplication.isPlayingOrWillChangePlaymode;
            this.m_Window.OnPageChangeAction     = new PageChangeAction(this.OnUpdatePage);
            this.m_Window.OnUpdateAction         = new RevisionAction(this.OnUpdate);
            this.m_Window.OnRestoreAction        = new RevisionAction(this.OnRestore);
            this.m_Window.OnGoBackAction         = new RevisionAction(this.OnGoBack);
            this.m_Window.OnShowBuildAction      = new ShowBuildAction(this.ShowBuildForCommit);
            this.m_Window.OnShowServicesAction   = new Action(this.ShowServicePage);
            this.m_Window.itemsPerPage           = 5;
            this.UpdateBuildServiceStatus();
            HistoryState historyState = this.RecalculateState();

            if (historyState == HistoryState.Ready)
            {
                this.OnUpdatePage(this.m_CurrentPage);
            }
            this.m_Window.UpdateState(historyState, true);
        }
        private void SaveCurrentFilter_HistoryState(Document docRef)
        {
            HistoryState savedState = docRef.ActiveHistoryState;

            docRef.ArtLayers[1].ApplyMotionBlur(20, 20); // Angle,Radius
            docRef.ActiveHistoryState = savedState;
        }
        // Save the state of one object into history.
        public void Commit(object metadata)
        {
            HistoryState state = new HistoryState();

            state.metadata = metadata;
            CommitOne(state, this.gameObject);
            this.history.Add(state);
        }
    private HistoryState SerializeState(byte turn, byte priority)
    {
        HistoryState historyState = new HistoryState(turn, priority);

        historyState.SerializeRobots(robotControllers);
        historyState.SerializeTiles(boardController.GetAllTiles());
        historyState.SerializeScore(boardController.GetMyBatteryScore(), boardController.GetOpponentBatteryScore());
        return(historyState);
    }
 public RandomImageService(IServiceProvider services)
 {
     logger          = services.GetService <ILogger>();
     Config          = services.GetService <ConfigService>();
     CommandState    = services.GetService <EnabledCommandState>();
     Images          = services.GetService <ImagesState>();
     History         = services.GetService <HistoryState>();
     Discord         = services.GetService <DiscordSocketClient>();
     ManageMessages  = services.GetService <ManageMessagesService>();
     RandomFrequency = services.GetService <RandomizeFrequency>();
 }
        private void BlockAccessor_OnStoreHistoryState(HistoryState obj)
        {
            obj.OldStartMarker = prevStartMarker?.Copy();
            obj.OldEndMarker   = prevEndMarker?.Copy();

            obj.NewStartMarker = StartMarker?.Copy();
            obj.NewEndMarker   = EndMarker?.Copy();

            prevStartMarker = StartMarker?.Copy();
            prevEndMarker   = EndMarker?.Copy();
        }
        void SaveCurrentState(object sender, EventArgs e)
        {
            HistoryState historyState = new HistoryState();

            historyState.Date             = DateTime.Now;
            historyState.DifferenceAmount = Convert.ToDecimal(currentAccount.TotalBalance) - Convert.ToDecimal(currentAccount.SavingBalance);
            historyState.Currency         = "RON";
            historyState.UserId           = App.CurrentUser.Id;
            App.HistoryStateDatabaseController.SaveHistoryState(historyState);
            DisplayAlert("Saving state", "Current state saved. It will be available in History menu.", "Ok");
        }
Exemple #11
0
 private void Restore <T>(HistoryState state, IEnumerable <T> extras)
     where T : MonoBehaviour
 {
     RestoreOne(state, this.gameObject);
     if (extras != null)
     {
         foreach (T obj in extras)
         {
             RestoreOne(state, obj.gameObject);
         }
     }
 }
 private void ApplyState(HistoryState state)
 {
     gridWidth  = state.GridWidth;
     gridHeight = state.GridHeight;
     Pixels.Reset(state.GetGridClone());
     OnPropertyChanged("GridHeight");
     OnPropertyChanged("GridWidth");
     OnPropertyChanged("PixelWidth");
     OnPropertyChanged("Pixels");
     OnPropertyChanged("UndoAction");
     OnPropertyChanged("RedoAction");
     OnPropertyChanged("CanUndo");
     OnPropertyChanged("CanRedo");
 }
 /// <summary>
 /// Initializes a new instance of the HistoryResponseModel class.
 /// </summary>
 /// <param name="type">Possible values include: 'CashIn', 'CashOut',
 /// 'Trade', 'OrderEvent'</param>
 /// <param name="state">Possible values include: 'None', 'InProgress',
 /// 'Finished', 'Canceled', 'Failed'</param>
 /// <param name="feeType">Possible values include: 'Unknown',
 /// 'Absolute', 'Relative'</param>
 public HistoryResponseModel(string id, System.DateTime dateTime, HistoryType type, HistoryState state, double amount, string asset, string assetPair, double price, double feeSize, FeeType feeType)
 {
     Id        = id;
     DateTime  = dateTime;
     Type      = type;
     State     = state;
     Amount    = amount;
     Asset     = asset;
     AssetPair = assetPair;
     Price     = price;
     FeeSize   = feeSize;
     FeeType   = feeType;
     CustomInit();
 }
Exemple #14
0
        private void RestoreOne(HistoryState state, GameObject obj)
        {
            Component[]   components    = obj.GetComponents(typeof(Component));
            UndoHistorian thisHistorian = null;

            foreach (Component comp in components)
            {
                if (comp.GetType() == typeof(UndoHistorian))
                {
                    thisHistorian = comp as UndoHistorian;
                    continue;
                }
                foreach (FieldInfo f in comp.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
                {
                    foreach (Attribute a in f.GetCustomAttributes(false))
                    {
                        if (a is UndoHistoryable)
                        {
                            f.SetValue(comp, state.storedFields[comp.GetInstanceID()][f.Name]);
                        }
                    }
                }
                foreach (PropertyInfo p in comp.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
                {
                    foreach (Attribute a in p.GetCustomAttributes(false))
                    {
                        if (a is UndoHistoryable)
                        {
                            p.SetValue(comp, state.storedFields[comp.GetInstanceID()][p.Name]);
                        }
                    }
                }
            }
            if (thisHistorian != null)
            {
                if (thisHistorian.config.includeParent)
                {
                    obj.transform.SetParent(state.transformData[obj.GetInstanceID()].parent, true);
                }
                if (thisHistorian.config.includePosition)
                {
                    obj.transform.position = state.transformData[obj.GetInstanceID()].position;
                }
                if (thisHistorian.config.includeRotation)
                {
                    obj.transform.rotation = state.transformData[obj.GetInstanceID()].rotation;
                }
            }
        }
 public int SaveHistoryState(HistoryState HistoryState)
 {
     lock (locker)
     {
         if (HistoryState.Id != 0)
         {
             database.Update(HistoryState);
             return HistoryState.Id;
         }
         else
         {
             return database.Insert(HistoryState);
         }
     }
 }
        private void BlockAccessor_OnRestoreHistoryState(HistoryState obj, int dir)
        {
            if (dir > 0)
            {
                StartMarker = obj.NewStartMarker?.Copy();
                EndMarker   = obj.NewEndMarker?.Copy();
            }
            else
            {
                StartMarker = obj.OldStartMarker?.Copy();
                EndMarker   = obj.OldEndMarker?.Copy();
            }

            HighlightSelectedArea();
        }
Exemple #17
0
        // Returns true when animation is finished.
        private bool AnimateOne(HistoryState state, GameObject obj)
        {
            UndoAnimatable[] components = obj.GetComponents <UndoAnimatable>();
            bool             finished   = true;

            foreach (UndoAnimatable comp in components)
            {
                HistoryStateAccess access = new HistoryStateAccess(state, comp as Component);
                if (!comp.AnimateUndo(access))
                {
                    finished = false;
                }
            }
            return(finished);
        }
Exemple #18
0
        // Save the state of one object plus a bunch of other extra objects into history.
        // When restoring this committed state, the same extras in the same order must be passed in.
        public void Commit <T>(object metadata, IEnumerable <T> extras)
            where T : MonoBehaviour
        {
            HistoryState state = new HistoryState();

            state.metadata = metadata;
            CommitOne(state, this.gameObject);
            if (extras != null)
            {
                foreach (T obj in extras)
                {
                    CommitOne(state, obj.gameObject);
                }
            }
            this.history.Add(state);
        }
    private void GoTo(HistoryState historyState)
    {
        DeserializeState(historyState);
        robotControllers.Values.ToList().ForEach(RefillCommands);
        Enumerable.Range(0, GameConstants.MAX_PRIORITY).ToList().ForEach(p => ForEachPriorityHighlight(historyState, (byte)(p + 1)));
        robotControllers.Values.ToList().ForEach(uiController.ChangeToBoardLayer);

        bool isPresent = currentHistoryIndex == history.Count - 1;

        uiController.submitCommands.SetActive(isPresent && robotControllers.Values.ToList().Any(r => r.commands.Count > 0));
        uiController.stepForwardButton.SetActive(currentHistoryIndex < history.Count - 1);
        uiController.stepBackButton.SetActive(currentHistoryIndex > 0);
        uiController.backToPresent.SetActive(currentHistoryIndex < history.Count - 1);

        uiController.robotButtonContainer.SetButtons(isPresent);
        uiController.commandButtonContainer.SetButtons(false);
        uiController.directionButtonContainer.SetButtons(false);
    }
Exemple #20
0
        internal static string ToSerializedValue(this HistoryState value)
        {
            switch (value)
            {
            case HistoryState.None:
                return("None");

            case HistoryState.InProgress:
                return("InProgress");

            case HistoryState.Finished:
                return("Finished");

            case HistoryState.Canceled:
                return("Canceled");

            case HistoryState.Failed:
                return("Failed");
            }
            return(null);
        }
 public void UpdateState(HistoryState state, bool force)
 {
     if (state != this.m_State || force)
     {
         if (state != HistoryState.Ready)
         {
             if (state == HistoryState.Disabled)
             {
                 base.Close();
                 return;
             }
         }
         else
         {
             this.UpdateHistoryView(this.m_Pager);
         }
         this.m_State = state;
         this.m_Container.Clear();
         this.m_Container.Add(this.m_Views[this.m_State]);
     }
 }
Exemple #22
0
        public void UpdateState(HistoryState state, bool force)
        {
            if (state == m_State && !force)
            {
                return;
            }

            m_State = state;
            switch (state)
            {
            case HistoryState.Ready:
                UpdateHistoryView(m_Pager);
                break;

            case HistoryState.Disabled:
                Close();
                return;
            }

            m_Container.Clear();
            m_Container.Add(m_Views[m_State]);
        }
        /// <summary>コンストラクタ Sig付き</summary>
        public BoHistroyContainer(HistoryState State_, SignalOrder Sig_)
        {
            this.State = State_;
            this.Sig   = Sig_;

            // 当初はブック単位でシグナルを切り替える予定だったが、1つのブックで管理するように変更
            this.PostURL_SpredSheet = Constants.URL_GAS_POST_COMMON;

            // 切り替える必要が出てきたらここで変える
            //switch (this.Sig.signalRoomName)
            //{
            //    case Constants.ROOM_NAME_CmdLine:
            //    case Constants.ROOM_NAME_SignalMeijin:
            //        this.PostURL_SpredSheet = Constants.URL_GAS_POST_AUXSIS;
            //            break;
            //    case Constants.ROOM_NAME_AUXESIS:
            //        this.PostURL_SpredSheet = Constants.URL_GAS_POST_AUXSIS;
            //        break;
            //    case Constants.ROOM_NAME_DebugRoomName:
            //        this.PostURL_SpredSheet = Constants.URL_GAS_POST_AUXSIS;        // debug 
            //        break;
            //}
        }
Exemple #24
0
        private void CommitOne(HistoryState state, GameObject obj)
        {
            Component[]   components    = obj.GetComponents(typeof(Component));
            UndoHistorian thisHistorian = null;

            foreach (Component comp in components)
            {
                if (comp.GetType() == typeof(UndoHistorian))
                {
                    thisHistorian = comp as UndoHistorian;
                    continue;
                }
                foreach (FieldInfo f in comp.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
                {
                    foreach (Attribute a in f.GetCustomAttributes(false))
                    {
                        if (a is UndoHistoryable)
                        {
                            if (!state.storedFields.ContainsKey(comp.GetInstanceID()))
                            {
                                state.storedFields[comp.GetInstanceID()] = new Dictionary <string, object>();
                            }
                            state.storedFields[comp.GetInstanceID()][f.Name] = f.GetValue(comp);
                        }
                    }
                }
                foreach (PropertyInfo p in comp.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
                {
                    foreach (Attribute a in p.GetCustomAttributes(false))
                    {
                        if (a is UndoHistoryable)
                        {
                            if (!state.storedFields.ContainsKey(comp.GetInstanceID()))
                            {
                                state.storedFields[comp.GetInstanceID()] = new Dictionary <string, object>();
                            }
                            state.storedFields[comp.GetInstanceID()][p.Name] = p.GetValue(comp);
                        }
                    }
                }
            }

            if (thisHistorian != null)
            {
                HistoryTransformData transformDataState = new HistoryTransformData();

                if (thisHistorian.config.includeParent)
                {
                    transformDataState.parent = obj.transform.parent;
                }
                if (thisHistorian.config.includePosition)
                {
                    transformDataState.position = obj.transform.position;
                }
                if (thisHistorian.config.includeRotation)
                {
                    transformDataState.rotation = obj.transform.rotation;
                }
                state.transformData[obj.GetInstanceID()] = transformDataState;
            }
        }
Exemple #25
0
 public HistoryStateAccess(HistoryState aState, Component aComponent)
 {
     this.state     = aState;
     this.component = aComponent;
 }
 private void DeserializeState(HistoryState historyState)
 {
     historyState.DeserializeRobots(robotControllers, uiController.AddSubmittedCommand);
     historyState.DeserializeTiles(boardController.GetAllTiles());
     historyState.DeserializeScore(boardController);
 }
 public void UpdateState(HistoryState state, bool force)
 {
 }