Example #1
0
        private void PerformDraggingUpdate()
        {
            Cursor cursor = GuiManager.Cursor;

            if (mNodeGrabbed != null)
            {
                if (GuiData.ToolsWindow.IsMoveButtonPressed)
                {
                    PositionedObjectMover.MouseMoveObject(mNodeGrabbed);

                    foreach (Link link in mNodeGrabbed.Links)
                    {
                        link.Cost = (mNodeGrabbed.Position - link.NodeLinkingTo.Position).Length();

                        // Currently links are two-way, so make sure that the cost is updated both ways
                        PositionedNode nodeLinkedTo = link.NodeLinkingTo;
                        foreach (Link otherLink in nodeLinkedTo.Links)
                        {
                            if (otherLink.NodeLinkingTo == mNodeGrabbed)
                            {
                                otherLink.Cost = link.Cost;
                            }
                        }
                    }

                    UpdateDistanceDisplay();

                    EditorData.NodeNetwork.UpdateShapes();
                }
            }
        }
Example #2
0
        private void PerformDraggingObjectControl()
        {
            Cursor cursor = GuiManager.Cursor;

            if (mObjectGrabbed == null || cursor.WindowOver != null)
            {
                return;
            }

            #region Move

            if (GuiData.ToolsWindow.MoveButton.IsPressed)
            {
                PositionedObjectMover.MouseMoveObject(mObjectGrabbed);
            }

            #endregion

            #region Scale

            else if (GuiData.ToolsWindow.ScaleButton.IsPressed && mObjectGrabbed is IScalable)
            {
                cursor.StaticPosition = true;

                IScalable asIScalable = mObjectGrabbed as IScalable;

                asIScalable.ScaleX *= 1 + cursor.XVelocity / 100.0f;
                asIScalable.ScaleY *= 1 + cursor.YVelocity / 100.0f;
            }

            #endregion

            #region Rotate

            else if (GuiData.ToolsWindow.RotateButton.IsPressed && mObjectGrabbed is IRotatable)
            {
                cursor.StaticPosition = true;

                IRotatable asiRotatable = mObjectGrabbed as IRotatable;

                asiRotatable.RotationZ += cursor.YVelocity * SpriteManager.Camera.Z / 100.0f;

                if (mObjectGrabbed.Parent != null)
                {
                    mObjectGrabbed.SetRelativeFromAbsolute();
                }
            }

            #endregion
        }
 private void HandleGrabbedMovement(FlatRedBall.Gui.Cursor cursor)
 {
     // Don't do any movement on a push because the window could be gaining focus
     if (!cursor.PrimaryPush && mGrabbedElementRuntime != null)
     {
         if (mGrabbedElementRuntime.DirectObjectReference != null)
         {
             if (mGrabbedElementRuntime.DirectObjectReference is PositionedObject)
             {
                 PositionedObjectMover.MouseMoveObject(mGrabbedElementRuntime.DirectObjectReference as PositionedObject, MovementStyle.Hierarchy);
             }
         }
         else
         {
             PositionedObjectMover.MouseMoveObject(mGrabbedElementRuntime, MovementStyle.Hierarchy);
         }
     }
 }
        private void MouseControlOverObjects(float worldX, float worldY)
        {
            Cursor cursor = GuiManager.Cursor;

            if (cursor.PrimaryPush)
            {
                mNodeGrabbed = GetNodeOver(worldX, worldY);
            }

            if (cursor.PrimaryClick)
            {
                mNodeGrabbed = null;
            }

            if (mNodeGrabbed != null)
            {
                PositionedObjectMover.MouseMoveObject <HierarchyNode>(mNodeGrabbed);
            }
        }
Example #5
0
        private void MouseControlOverObjects()
        {
            #region If over a window, exit out

            Cursor cursor = GuiManager.Cursor;

            if (cursor.WindowOver != null)
            {
                return;
            }
            #endregion

            // See if the mouse is over anything
            PositionedObject objectOver = GetObjectOver();

            #region Cursor Push
            if (GuiManager.Cursor.PrimaryPush)
            {
                mObjectGrabbed = objectOver;

                if (mObjectGrabbed != null)
                {
                    PositionedObjectMover.SetStartPosition(mObjectGrabbed);
                }

                if (mObjectGrabbed == null)
                {
                    SelectObject <Sprite>(null, mCurrentSprites);
                    SelectObject <Text>(null, mCurrentTexts);
                }
                else if (SpriteGrabbed != null)
                {
                    SelectObject(SpriteGrabbed, mCurrentSprites);
                }
                else if (SpriteFrameGrabbed != null)
                {
                    SelectObject(SpriteFrameGrabbed, mCurrentSpriteFrames);
                }
                else if (PositionedModelGrabbed != null)
                {
                    SelectObject(PositionedModelGrabbed, mCurrentPositionedModels);
                }
                else if (TextGrabbed != null)
                {
                    SelectObject(TextGrabbed, mCurrentTexts);
                }
            }
            #endregion

            #region Cursor Down (Drag)

            if (cursor.PrimaryDown)
            {
                PerformDraggingObjectControl();
            }

            #endregion

            #region Cursor Click

            if (cursor.PrimaryClick)
            {
                cursor.StaticPosition = false;
            }
            #endregion
        }
Example #6
0
        private void MouseControlOverObjects()
        {
            Cursor cursor = GuiManager.Cursor;

            if (cursor.WindowOver != null)
            {
                return;
            }

            GuiManager.Cursor.StaticPosition = false;

            #region moving mEditorLogic.CurrentEmitter and its boundary
            if (AppState.Self.CurrentEmitter != null)
            {
                #region see if we pushed the mouse buttons  on a marker
                if (cursor.PrimaryPush || cursor.SecondaryPush)
                {
                    if (cursor.WindowOver == null)
                    {
                        if (cursor.IsOn(EditorData.EditorLogic.ReactiveHud.CurrentEmitterMarker))
                        {
                            mGrabbedObject = AppState.Self.CurrentEmitter;
                        }
                        else if (AppState.Self.CurrentEmitter.BoundedEmission)
                        {
                            foreach (AxisAlignedRectangle corner in EditorData.EditorLogic.ReactiveHud.CurrentEmitterBoundaryCorners)
                            {
                                if (cursor.IsOn <AxisAlignedRectangle>(corner))
                                {
                                    mGrabbedObject = corner;
                                    break;
                                }
                            }
                        }
                    }
                }
                #endregion

                #region release emitter
                if (cursor.PrimaryClick || cursor.SecondaryClick)
                {
                    mGrabbedObject = null;
                }
                #endregion

                #region move the emitter or its boundary if we have one grabbed
                if (mGrabbedObject != null && GuiData.ToolsWindow.moveObject.IsPressed)
                {
                    PositionedObjectMover.MouseMoveObject(mGrabbedObject, MovementStyle.Hierarchy);
                    if (mGrabbedObject is AxisAlignedRectangle)
                    {
                        for (int i = 0; i < EditorData.EditorLogic.ReactiveHud.CurrentEmitterBoundaryCorners.Count; i++)
                        {
                            if (EditorData.EditorLogic.ReactiveHud.CurrentEmitterBoundaryCorners[i].Equals(mGrabbedObject))
                            {
                                AppState.Self.CurrentEmitter.EmissionBoundary.SetPoint(i, mGrabbedObject.X - AppState.Self.CurrentEmitter.X, mGrabbedObject.Y - AppState.Self.CurrentEmitter.Y);
                                if (i == 0)
                                {
                                    AppState.Self.CurrentEmitter.EmissionBoundary.SetPoint(AppState.Self.CurrentEmitter.EmissionBoundary.Points.Count - 1,
                                                                                           mGrabbedObject.X - AppState.Self.CurrentEmitter.X, mGrabbedObject.Y - AppState.Self.CurrentEmitter.Y);
                                }
                            }
                        }
                    }
                }
                #endregion
            }
            #endregion

            #region scnFileArray  logic for moving our scene
            if (EditorData.Scene != null && mGrabbedObject == null)
            {
                #region grabbing a sprite
                if (cursor.PrimaryPush)
                {
                    if (cursor.WindowOver == null)
                    {
                        if (cursor.GetSpriteOver(EditorData.Scene.Sprites) != null)
                        {
                            arrayGrabbed = true;
                        }
                    }
                }
                #endregion

                #region release sprite
                if (cursor.PrimaryClick)
                {
                    arrayGrabbed = false;
                }

                #endregion

                #region if an array is grabbed, move the entire scene by the sprite's velocity
                if (arrayGrabbed && GuiData.ToolsWindow.moveObject.IsPressed)
                {
                    EditorData.Scene.Shift(
                        new Vector3(
                            cursor.ActualXVelocityAt(0),
                            cursor.ActualYVelocityAt(0),
                            0));
                }
                #endregion
            }
            #endregion

            if (GuiData.ToolsWindow.attachObject.IsPressed && cursor.PrimaryClick)
            {
                TryAttachEmitterToSprite();
            }
        }
Example #7
0
        /// <summary>
        /// Controls selecting new Shapes and performing move, scale, and rotate (when appropriate).
        /// </summary>
        #endregion
        private void CursorControlOverShapes()
        {
            if (GuiManager.DominantWindowActive)
            {
                return;
            }


            Cursor cursor = GuiManager.Cursor;

            #region Pushing selects and grabs a Shape or the corner of a Polygon
            if (cursor.PrimaryPush)
            {
                #region If the user has not interacted with the corners then see check for grabbing any Shapes

                if (mReactiveHud.HasPolygonEdgeGrabbed == false)
                {
                    mObjectGrabbed = GetShapeOver(cursor.PrimaryDoublePush);

                    ShowErrorIfObjectCanNotBeGrabbed();

                    // If the object is not null store its original position.  This will be used
                    // for SHIFT+drag which allows movement only on one axis.
                    if (mObjectGrabbed != null)
                    {
                        PositionedObjectMover.SetStartPosition(mObjectGrabbed);
                    }

                    cursor.SetObjectRelativePosition(mObjectGrabbed);

                    if (PolygonGrabbed != null)
                    {
                        UndoManager.AddToWatch(PolygonGrabbed);
                        SelectPolygon(PolygonGrabbed);
                    }

                    if (AxisAlignedCubeGrabbed != null)
                    {
                        UndoManager.AddToWatch(AxisAlignedCubeGrabbed);
                        SelectAxisAlignedCube(AxisAlignedCubeGrabbed);
                    }

                    if (AxisAlignedRectangleGrabbed != null)
                    {
                        UndoManager.AddToWatch(AxisAlignedRectangleGrabbed);
                        SelectAxisAlignedRectangle(AxisAlignedRectangleGrabbed);
                    }
                    if (CircleGrabbed != null)
                    {
                        UndoManager.AddToWatch(CircleGrabbed);
                        SelectCircle(CircleGrabbed);
                    }
                    if (SphereGrabbed != null)
                    {
                        UndoManager.AddToWatch(SphereGrabbed);
                        SelectSphere(SphereGrabbed);
                    }

                    if (mObjectGrabbed == null)
                    {
                        DeselectAll();
                    }
                }

                #endregion
            }
            #endregion

            #region Holding the button down can be used to drag objects
            if (cursor.PrimaryDown)
            {
                PerformDraggingUpdate();
            }
            #endregion

            #region Clicking (releasing) the mouse lets go of grabbed Polygons

            if (cursor.PrimaryClick)
            {
                if (PolygonGrabbed != null)
                {
                    UndoManager.RecordUndos <Polygon>();
                    UndoManager.ClearObjectsWatching <Polygon>();
                }

                if (AxisAlignedRectangleGrabbed != null)
                {
                    UndoManager.RecordUndos <AxisAlignedRectangle>();
                    UndoManager.ClearObjectsWatching <AxisAlignedRectangle>();
                }

                if (AxisAlignedCubeGrabbed != null)
                {
                    UndoManager.RecordUndos <AxisAlignedCube>();
                    UndoManager.ClearObjectsWatching <AxisAlignedCube>();
                }

                if (CircleGrabbed != null)
                {
                    UndoManager.RecordUndos <Circle>();
                    UndoManager.ClearObjectsWatching <Circle>();
                }

                if (SphereGrabbed != null)
                {
                    UndoManager.RecordUndos <Sphere>();
                    UndoManager.ClearObjectsWatching <Sphere>();
                }

                mObjectGrabbed = null;

                cursor.StaticPosition = false;

                cursor.ObjectGrabbed = null;
            }

            #endregion
        }
Example #8
0
 private void PerformMoveDragging(Cursor cursor)
 {
     PositionedObjectMover.MouseMoveObject(mObjectGrabbed);
 }