public void Clear() { mSprites.Clear(); mSpriteGrids.Clear(); mSpriteFrames.Clear(); mTexts.Clear(); }
public void AutoPosition() { const float depthSpacing = 4; for (int i = 0; i < mNodesAsList.Count; i++) { HierarchyNode node = mNodesAsList[i]; node.RelativeY = -depthSpacing; IAttachable parent = GetParent(node.ObjectRepresenting); if (parent == null) { node.AttachTo(null, false); node.Y = 5; } else { HierarchyNode parentNode = GetNodeFromAttachable(parent); node.AttachTo(parentNode, false); } } mUnparentedNodes.Clear(); // Gotta do this after all attachments have been made for (int i = 0; i < mNodesAsList.Count; i++) { HierarchyNode node = mNodesAsList[i]; if (node.Parent != null) { node.SetRelativeX(); node.ForceUpdateDependencies(); } else { float xToStartAt = 0; if (mUnparentedNodes.Count != 0) { xToStartAt = mUnparentedNodes.Last.X + mUnparentedNodes.Last.Width / 2.0f; } node.Y = 5; node.X = xToStartAt + node.Width / 2.0f; mUnparentedNodes.Add(node); } } UpdateSelectionMarker(); }
private void DraggingActivity(Cursor cursor, float xToY) { try { changeVector = new Vector3(0, 0, 0); #region Button down if (cursor.PrimaryDown && mCursorPushedOnAxis && origin.Parent != null && (cursor.XVelocity != 0 || cursor.YVelocity != 0)) { // At the time of this writing it is possible to // select a Sprite in the SpriteGrid and shrink the // grid which removes the Sprite but does not remove the // EditAxes. If the user tries to perform operations on the // Sprite it's possible to get an exception. Therefore, add a // test to make sure the Sprite isn't null in the above if statement. spritesAlreadyChanged.Clear(); float movementMultiplier = DistanceFromCamera / 40.0f; #if FRB_MDX Vector3 cursorVector = cursor.WorldXChangeAt(origin.Parent.Z) * SpriteManager.Camera.RotationMatrix.Right() + cursor.WorldYChangeAt(origin.Parent.Z) * SpriteManager.Camera.RotationMatrix.Up(); //Plane screenPlane = Plane.FromPointNormal(SpriteManager.Camera.Position, SpriteManager.Camera.RotationMatrix.Forward()); Vector3 cameraRight = SpriteManager.Camera.RotationMatrix.Right(); Vector3 cameraUp = SpriteManager.Camera.RotationMatrix.Up(); #else Vector3 cursorVector = cursor.XVelocity * SpriteManager.Camera.RotationMatrix.Right + cursor.YVelocity * SpriteManager.Camera.RotationMatrix.Up; //Plane screenPlane = Plane.FromPointNormal(SpriteManager.Camera.Position, SpriteManager.Camera.RotationMatrix.Forward()); Vector3 cameraRight = SpriteManager.Camera.RotationMatrix.Right; Vector3 cameraUp = SpriteManager.Camera.RotationMatrix.Up; #endif Vector3 vectorToMoveAlong = GetVectorToMoveAlong(); ApplyMovement(ref cursorVector, ref cameraRight, ref cameraUp, ref vectorToMoveAlong); #region xScale grabbed if (axisGrabbed == xScale) { cursor.StaticPosition = true; float change; if (origin.Parent.RotationZ == (float)System.Math.PI * .5f || origin.Parent.RotationZ == (float)System.Math.PI * 1.5f) { change = 1 + cursor.YVelocity / 100.0f; } else { change = 1 + cursor.XVelocity / 100.0f; } if (origin.Parent as IScalable != null) { ((IScalable)(origin.Parent)).ScaleX *= change; } else { ((IScalable)origin.Parent).ScaleX *= change; // if (GameData.sfMan.CurrentSpriteFrames.Count != 0) // GuiData.propertiesWindow.sfSpriteBorderWidth.MaxValue = // System.Math.Min(GameData.sfMan.CurrentSpriteFrames[0].ScaleX, GameData.sfMan.CurrentSpriteFrames[0].ScaleY); } if (InputManager.Keyboard.KeyDown(Keys.LeftShift) || InputManager.Keyboard.KeyDown(Keys.RightShift)) { if (origin.Parent is IScalable) { ((IScalable)(origin.Parent)).ScaleY = ((IScalable)(origin.Parent)).ScaleX / xToY; } else { ((IScalable)origin.Parent).ScaleY = ((IScalable)origin.Parent).ScaleX / xToY; } } } #endregion #region xRot grabbed else if (axisGrabbed == xRot) { cursor.StaticPosition = true; #if FRB_MDX Vector3 xAxisVector = origin.Parent.RotationMatrix.Right(); #else Vector3 xAxisVector = origin.Parent.RotationMatrix.Right; #endif RotatePrivateSpritesAboutAxis(xAxisVector, cursor); } #endregion #region yScale grabbed else if (axisGrabbed == yScale) { cursor.StaticPosition = true; float change; if (origin.Parent.RotationZ == (float)System.Math.PI * .5f || origin.Parent.RotationZ == (float)System.Math.PI * 1.5f) { change = 1 + cursor.XVelocity / 100.0f; } else { change = 1 + cursor.YVelocity / 100.0f; } ((IScalable)origin.Parent).ScaleY *= change; if (origin.Parent is SpriteFrame) { // GuiData.propertiesWindow.sfSpriteBorderWidth.MaxValue = // System.Math.Min(GameData.sfMan.CurrentSpriteFrames[0].ScaleX, GameData.sfMan.CurrentSpriteFrames[0].ScaleY); } if (InputManager.Keyboard.KeyDown(Keys.LeftShift) || InputManager.Keyboard.KeyDown(Keys.RightShift)) { ((Sprite)origin.Parent).ScaleX = ((Sprite)origin.Parent).ScaleY * xToY; } } #endregion #region yRot grabbed else if (axisGrabbed == yRot) { cursor.StaticPosition = true; #if FRB_MDX Vector3 yAxisVector = origin.Parent.RotationMatrix.Up(); #else Vector3 yAxisVector = origin.Parent.RotationMatrix.Up; #endif RotatePrivateSpritesAboutAxis(yAxisVector, cursor); } #endregion #region origin grabbed else if (axisGrabbed == origin) { cursor.StaticPosition = true; #if FRB_MDX Vector3 zAxisVector = origin.Parent.RotationMatrix.Forward(); #else Vector3 zAxisVector = origin.Parent.RotationMatrix.Forward; #endif RotatePrivateSpritesAboutAxis(zAxisVector, cursor); } #endregion } #endregion } catch (NullReferenceException) { throw new NullReferenceException("Exception in Button down"); } }