Update() публичный Метод

public Update ( UpdateState state ) : void
state FSO.Common.Rendering.Framework.Model.UpdateState
Результат void
Пример #1
0
        public override void Update(UpdateState state)
        {
            lock (Commands)
            {
                if (Commands.Count > 0)
                {
                    RedoStack.Clear();
                }
                foreach (var cmd in Commands)
                {
                    state.SharedData["ExternalDraw"] = true;
                    cmd.Execute(BHAVView.EditTarget, this);
                    UndoStack.Push(cmd);
                }
                if (Commands.Count > 0)
                {
                    BHAVView.Scope.Object.Resource.Recache();
                }
                Commands.Clear();
            }

            lock (ValueChangeCmds)
            {
                foreach (var cmd in ValueChangeCmds)
                {
                    cmd.Execute();
                }
                Commands.Clear();
            }

            while (UndoRedoDir > 0)
            {
                if (UndoStack.Count > 0)
                {
                    var cmd = UndoStack.Pop();
                    state.SharedData["ExternalDraw"] = true;
                    cmd.Undo(BHAVView.EditTarget, this);
                    RedoStack.Push(cmd);
                }
                UndoRedoDir--;
            }

            while (UndoRedoDir < 0)
            {
                if (RedoStack.Count > 0)
                {
                    var cmd = RedoStack.Pop();
                    state.SharedData["ExternalDraw"] = true;
                    cmd.Execute(BHAVView.EditTarget, this);
                    UndoStack.Push(cmd);
                }
                UndoRedoDir++;
            }

            if (RedrawNext)
            {
                state.SharedData["ExternalDraw"] = true;
                RedrawNext = false;
            }

            if (Placement != null)
            {
                Placement.Position = GlobalPoint(new Vector2(state.MouseState.X, state.MouseState.Y)) - (new Vector2(Placement.Width, Placement.Height) / 2);
                Placement.Style    = PGroupStyles.ByType[PrimitiveGroup.Placement];
                state.SharedData["ExternalDraw"] = true;
                Placement.Update(state);

                PlacingName.Position = new Vector2(LastWidth / 2, LastHeight - 66);
                PlacingDesc.Position = new Vector2(LastWidth / 2, LastHeight - 48);

                var mx = state.MouseState.Position.X;
                var my = state.MouseState.Position.Y;

                if (MouseWasDown && (state.MouseState.LeftButton == ButtonState.Released) &&
                    mx > 0 && mx < LastWidth && my > 0 && my < LastHeight)
                {
                    QueueCommand(new AddPrimCommand(Placement));
                    Placement.Position -= BHAVView.Position;
                    ClearPlacement();
                }
            }
            CutoutPhase++;
            MouseWasDown = state.MouseState.LeftButton == ButtonState.Pressed;
            base.Update(state);

            if (BHAVView.HoverPrim != null && (!RightMouseWasDown) &&
                state.MouseState.RightButton == ButtonState.Pressed &&
                BHAVView.HoverPrim.Type == PrimBoxType.Primitive)
            {
                QueueCommand(new ToggleBreakpointCommand(BHAVView.HoverPrim));
            }

            RightMouseWasDown = state.MouseState.RightButton == ButtonState.Pressed;
        }
Пример #2
0
        public override void Update(UpdateState state)
        {
            if (Refocused)
            {
                Refocused = false;
                if (LastTreeVersion != BHAVView.EditTargetTree.TreeVersion)
                {
                    //reload the BHAV
                    BHAVView.Init();
                    UndoStack.Clear();
                    RedoStack.Clear();
                    LastTreeVersion = BHAVView.EditTargetTree.TreeVersion;
                    if (DebugMode && DebugFrame != null)
                    {
                        UpdateDebugPointer(DebugFrame);
                    }
                }
            }

            lock (Commands)
            {
                if (Commands.Count > 0)
                {
                    RedoStack.Clear();
                }
                foreach (var cmd in Commands)
                {
                    state.SharedData["ExternalDraw"] = true;
                    cmd.Execute(BHAVView.EditTarget, this);
                    UndoStack.Push(cmd);
                }
                if (Commands.Count > 0)
                {
                    BHAVView.Scope.Object.Resource.Recache();
                }
                Commands.Clear();
            }

            lock (ValueChangeCmds)
            {
                foreach (var cmd in ValueChangeCmds)
                {
                    cmd.Execute();
                }
                Commands.Clear();
            }

            while (UndoRedoDir > 0)
            {
                if (UndoStack.Count > 0)
                {
                    var cmd = UndoStack.Pop();
                    state.SharedData["ExternalDraw"] = true;
                    cmd.Undo(BHAVView.EditTarget, this);
                    RedoStack.Push(cmd);
                }
                UndoRedoDir--;
            }

            while (UndoRedoDir < 0)
            {
                if (RedoStack.Count > 0)
                {
                    var cmd = RedoStack.Pop();
                    state.SharedData["ExternalDraw"] = true;
                    cmd.Execute(BHAVView.EditTarget, this);
                    UndoStack.Push(cmd);
                }
                UndoRedoDir++;
            }

            if (RedrawNext)
            {
                state.SharedData["ExternalDraw"] = true;
                RedrawNext = false;
            }

            if (Placement != null)
            {
                var desiredPos = new Vector2(state.MouseState.X, state.MouseState.Y) - (new Vector2(Placement.Width, Placement.Height) / 2); // the mouse-placement position
                if (SnapPrims)
                {
                    var snappedPos = BHAVView.LocalPoint(Placement.SnapToNearbyPrims(state, new Vector2(), BHAVView.GetMousePosition(state.MouseState), out bool result)); // snapped position
                    if (result)
                    {
                        desiredPos = snappedPos;
                    }
                }
                Placement.Position = GlobalPoint(desiredPos);
                Placement.Style    = PGroupStyles.ByType[PrimitiveGroup.Placement];
                state.SharedData["ExternalDraw"] = true;
                Placement.Update(state);

                PlacingName.Position = new Vector2(LastWidth / 2, LastHeight - 66);
                PlacingDesc.Position = new Vector2(LastWidth / 2, LastHeight - 48);

                var mx = state.MouseState.Position.X;
                var my = state.MouseState.Position.Y;

                if (MouseWasDown && (state.MouseState.LeftButton == ButtonState.Released) &&
                    mx > 0 && mx < LastWidth && my > 0 && my < LastHeight)
                {
                    QueueCommand(new AddPrimCommand(Placement));
                    Placement.Position -= BHAVView.Position;
                    ClearPlacement();
                }
            }
            CutoutPhase++;
            MouseWasDown = state.MouseState.LeftButton == ButtonState.Pressed;
            base.Update(state);

            if (BHAVView.HoverPrim != null && (!RightMouseWasDown) &&
                state.MouseState.RightButton == ButtonState.Pressed &&
                BHAVView.HoverPrim.Type == TREEBoxType.Primitive)
            {
                QueueCommand(new ToggleBreakpointCommand(BHAVView.HoverPrim));
            }

            RightMouseWasDown = state.MouseState.RightButton == ButtonState.Pressed;
        }