Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 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
        }
Ejemplo n.º 3
0
 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);
         }
     }
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
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();
            }
        }
Ejemplo n.º 6
0
 private void PerformMoveDragging(Cursor cursor)
 {
     PositionedObjectMover.MouseMoveObject(mObjectGrabbed);
 }