protected override void Draw()
 {
     UpdateTileSelection();
     GraphicsDevice.Clear(Color.LightGray);
     DrawTiles();
     MilkshakeForm.SwapCameraAndRenderScene(_camera);
 }
        /// <summary>
        /// Draws the control.
        /// </summary>
        protected override void Draw()
        {
            GraphicsDevice.Clear(Color.Black);
            if (_background != null)
            {
                float       scaledWidth       = this.Width / (float)_background.Width;
                float       scaledHeight      = this.Height / (float)_background.Height;
                DrawRequest backgroundRequest = new DrawRequest(_background, Vector2.Zero,
                                                                null, 0, new Vector2(scaledWidth, scaledHeight), Vector2.Zero, false, Color.White, false, false, null);
                DrawingManager.DrawOnLayer(backgroundRequest, 10, DrawingBlendingType.Alpha);
            }
            _ppAnim.Update(1 / 60f);
            _parent = Parent as PostProcessAnimationEditor;
            // if the animation was paused externally, pause it in the GUI
            if (_ppAnim.IsPaused == true && _parent.toolStripButtonPause.Enabled == true)
            {
                _parent.toolStripButtonPause_Click(null, EventArgs.Empty);
            }
            // if the animation was stopped externally, stop it in the GUI
            if (_ppAnim.IsStopped == true && _parent.toolStripButtonStop.Enabled == true)
            {
                _parent.toolStripButtonStop_Click(null, EventArgs.Empty);
            }
            int oldLayer = _ppAnim.Layer;

            _ppAnim.Draw(1 / 60f);
            _ppAnim.Layer = oldLayer;
            DrawingManager.ViewPortSize = new Point(this.Width, this.Height);
            MilkshakeForm.SwapCameraAndRenderScene(ParentEditor.ZoomBox.Camera);
            ((PostProcessAnimationEditor)this.Parent).Update(1 / 60f);
        }
Beispiel #3
0
        /// <summary>
        /// Draws the control.
        /// </summary>
        protected override void Draw()
        {
            ParentEditor.ZoomBox.Camera.Update(1 / 60f);
            if (particleEffect.Position != updatedPosition)
            {
                particleEffect.Position = updatedPosition;
            }
            particleEffect.Update(1 / 60f);
            _parent = Parent as ParticleEffectEditor;
            // if the animation was paused externally, pause it in the GUI
            if (particleEffect.Emitter.IsPaused == true && _parent.toolStripButtonPause.Enabled == true)
            {
                _parent.toolStripButtonPause_Click(null, EventArgs.Empty);
            }
            // if the animation was stopped externally, stop it in the GUI
            if (particleEffect.Emitter.IsStopped == true && _parent.toolStripButtonStop.Enabled == true)
            {
                _parent.toolStripButtonStop_Click(null, EventArgs.Empty);
            }
            if (background != null)
            {
                DrawRequest backgroundRequest = new DrawRequest(background, Vector2.Zero, false,
                                                                null, 0, Vector2.One, new Vector2(0.5f), true, Color.White, false, false, null);
                DrawingManager.DrawOnLayer(backgroundRequest, 10, DrawingBlendingType.Alpha);
            }
            particleEffect.Draw(1f);
            GraphicsDevice.Clear(backgroundColor);

            DrawingManager.ViewPortSize = new Point(this.Width, this.Height);
            MilkshakeForm.SwapCameraAndRenderScene(ParentEditor.ZoomBox.Camera);
            ParentEditor.Update(1 / 60f);
        }
        protected override void Draw()
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            // Use SpriteSortMode.Immediate, so we can apply custom renderstates.
            _spriteBatch.Begin(SpriteBlendMode.AlphaBlend,
                               SpriteSortMode.Immediate,
                               SaveStateMode.SaveState);

            // Set the texture addressing mode to wrap, so we can repeat
            // many copies of our tiled checkerboard texture.
            GraphicsDevice.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
            GraphicsDevice.SamplerStates[0].AddressV = TextureAddressMode.Wrap;
            Rectangle fullRect = new Rectangle(0, 0, this.Width, this.Height);

            // Draw a tiled checkerboard pattern in the background.
            _spriteBatch.Draw(_crossTexture, fullRect, fullRect, Color.White);
            if (SceneItem == null)
            {
                _spriteBatch.End();
            }
            else
            {
                _spriteBatch.End();
                DrawingManager.ViewPortSize = new Point(this.Width, this.Height);
                _camera.Position            = Vector2.Zero;
                _camera.Update(1 / 60f);
                Vector2 oldPivot           = SceneItem.Pivot;
                bool    oldIsPivotRelative = SceneItem.IsPivotRelative;
                Vector2 oldPosition        = SceneItem.Position;
                float   oldRotation        = SceneItem.Rotation;
                Vector2 oldScale           = SceneItem.Scale;
                bool    oldVisibility      = SceneItem.Visible;
                SceneItem.Visible         = true;
                SceneItem.Position        = Vector2.Zero;
                SceneItem.Pivot           = new Vector2(0.5f);
                SceneItem.IsPivotRelative = true;
                SceneItem.Scale           = Vector2.One;
                SceneItem.Rotation        = 0;
                SceneItem.Update(1 / 60f);
                SceneItem.Draw(1 / 60f);
                SceneItem.Position        = oldPosition;
                SceneItem.Pivot           = oldPivot;
                SceneItem.IsPivotRelative = oldIsPivotRelative;
                SceneItem.Scale           = oldScale;
                SceneItem.Rotation        = oldRotation;
                SceneItem.Visible         = oldVisibility;
                MilkshakeForm.SwapCameraAndRenderScene(_camera);
            }
        }
Beispiel #5
0
        protected override void Draw()
        {
            GraphicsDevice.Clear(Color.LightGray);
            Vector2 oldPosition = _parentGrid.Position;
            Vector2 oldScale    = _parentGrid.Scale;

            _parentGrid.Position = Vector2.Zero;
            _parentGrid.Scale    = Vector2.One;
            _parentGrid.UpdateBoundingRect();
            _parentGrid.Scale = new Vector2(
                (float)this.Size.Width / (float)_parentGrid.BoundingRect.Width,
                (float)this.Size.Height / (float)_parentGrid.BoundingRect.Height);
            _parentGrid.Draw(1 / 60f);
            MilkshakeForm.SwapCameraAndRenderScene(_camera);
            _parentGrid.Position = oldPosition;
            _parentGrid.Scale    = oldScale;
            _parentGrid.UpdateBoundingRect();
        }
        protected override void Draw()
        {
            DrawingManager.ViewPortSize = new Point(this.Width, this.Height);
            Update(1 / 60f);
            ParentEditor.ZoomBox.Camera.Position = new Vector2(-this.AutoScrollPosition.X, -this.AutoScrollPosition.Y);
            ParentEditor.ZoomBox.Camera.Update(1 / 60f);
            Vector2 sizeRatio = new Vector2(
                (float)this.Size.Width / ((float)this.Size.Width * ParentEditor.ZoomBox.Camera.Zoom.X),
                (float)this.Size.Height / ((float)this.Size.Height * ParentEditor.ZoomBox.Camera.Zoom.Y));

            GraphicsDevice.Clear(Color.LightBlue);
            // Use SpriteSortMode.Immediate, so we can apply custom renderstates.
            _spriteBatch.Begin(SpriteBlendMode.AlphaBlend,
                               SpriteSortMode.Immediate,
                               SaveStateMode.SaveState);
            // Set the texture addressing mode to wrap, so we can repeat
            // many copies of our tiled checkerboard texture.
            GraphicsDevice.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
            GraphicsDevice.SamplerStates[0].AddressV = TextureAddressMode.Wrap;
            Rectangle fullRect = new Rectangle(0, 0, this.Width, this.Height);

            // Draw a tiled crossed pattern in the background.
            _spriteBatch.Draw(_crossTexture, fullRect, fullRect, Color.White);
            _spriteBatch.Draw(_checkerTexture, new Rectangle(0, 0, (int)(_tileGrid.BoundingRect.Width * ParentEditor.ZoomBox.Camera.Zoom.X),
                                                             (int)(_tileGrid.BoundingRect.Height * ParentEditor.ZoomBox.Camera.Zoom.Y)),
                              new Rectangle(0, 0, (int)(_tileGrid.BoundingRect.Width * ParentEditor.ZoomBox.Camera.Zoom.X),
                                            (int)(_tileGrid.BoundingRect.Height * ParentEditor.ZoomBox.Camera.Zoom.Y)), Color.White);
            _spriteBatch.End();

            this.AutoScrollMinSize = new System.Drawing.Size((int)(_tileGrid.BoundingRect.Width * ParentEditor.ZoomBox.Camera.Zoom.X),
                                                             (int)(_tileGrid.BoundingRect.Height * ParentEditor.ZoomBox.Camera.Zoom.Y));

            Vector2 pos = _tileGrid.Position;

            _tileGrid.Position = Vector2.Zero;
            _tileGrid.Pivot    = Vector2.Zero;
            _tileGrid.Draw(1 / 60f);
            _tileGrid.Position = pos;
            //_camera.Position += _tileGrid.Position;
            if (PaintMode == TileGridPaintMode.Brush)
            {
                DrawBrushTileHighlight(new Color(25, 255, 100, 150));
            }
            else if (PaintMode == TileGridPaintMode.Bucket)
            {
                DrawBrushTileHighlight(new Color(25, 100, 255, 150));
                _brushSize = new Point(1, 1);
            }
            else if (PaintMode == TileGridPaintMode.Eraser)
            {
                DrawBrushTileHighlight(new Color(255, 0, 0, 150));
            }
            else if (PaintMode == TileGridPaintMode.Edit)
            {
                foreach (Point tile in _selectedTiles)
                {
                    DrawTileSelection(tile.X, tile.Y);
                }
                if (_isPastingTiles)
                {
                    DrawPastingSelection(_drawPosPastingSelection.X,
                                         _drawPosPastingSelection.Y);
                }
            }
            if (_drawGrid == true)
            {
                DrawGridLines();
            }
            MilkshakeForm.SwapCameraAndRenderScene(ParentEditor.ZoomBox.Camera);
            _parent.Update(1 / 60f);
        }
Beispiel #7
0
        /// <summary>
        /// Draws the control, using SpriteBatch and SpriteFont.
        /// </summary>
        protected override void Draw()
        {
            ParentEditor.ZoomBox.Camera.Update(1 / 60f);
            GraphicsDevice.Clear(Color.RoyalBlue);

            // Use SpriteSortMode.Immediate, so we can apply custom renderstates.
            _spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, null, null);
            _sprite.Pivot    = Vector2.Zero;
            _sprite.Position = Vector2.Zero;
            Rectangle fullRect    = new Rectangle(0, 0, this.Width, this.Height);
            Rectangle spriteRect  = new Rectangle(0, 0, _sprite.Material.Texture.Width, _sprite.Material.Texture.Height);;
            Point     textureSize = new Point(_sprite.Material.Texture.Width, _sprite.Material.Texture.Height);

            if (!ShowWholeImage)
            {
                if (_sprite.SourceRectangle != null)
                {
                    Rectangle rect = _sprite.SourceRectangle.Value;
                    spriteRect  = new Rectangle(0, 0, rect.Width, rect.Height);
                    textureSize = new Point(rect.Width, rect.Height);
                }
            }
            ParentEditor.ZoomBox.Camera.Position = new Vector2(-this.AutoScrollPosition.X,
                                                               -this.AutoScrollPosition.Y);
            // Draw a tiled checkerboard pattern in the background.
            _spriteBatch.Draw(_crossTexture, fullRect, fullRect, Color.White);
            _spriteBatch.Draw(_checkerTexture,
                              new Rectangle(0, 0, (int)(spriteRect.Width * _sprite.Scale.X * ParentEditor.ZoomBox.ZoomFactor),
                                            (int)(spriteRect.Height * _sprite.Scale.Y * ParentEditor.ZoomBox.ZoomFactor)),
                              new Rectangle(0, 0, (int)(spriteRect.Width * _sprite.Scale.X * ParentEditor.ZoomBox.ZoomFactor),
                                            (int)(spriteRect.Height * _sprite.Scale.Y * ParentEditor.ZoomBox.ZoomFactor)), Color.White);

            _spriteBatch.End();

            this.AutoScrollMinSize = new System.Drawing.Size((int)(textureSize.X * _sprite.Scale.X * ParentEditor.ZoomBox.ZoomFactor),
                                                             (int)(textureSize.Y * _sprite.Scale.Y * ParentEditor.ZoomBox.ZoomFactor));

            if (ShowWholeImage)
            {
                Rectangle?_srcRectangle = _sprite.SourceRectangle;
                _sprite.SourceRectangle = null;
                _sprite.Draw(1f);
                _sprite.SourceRectangle = _srcRectangle;

                if (_sprite.SourceRectangle.HasValue)
                {
                    IceCream.Drawing.DebugShapes.DrawRectangle(_sprite.SourceRectangle.Value, Color.Yellow);
                }
            }
            else
            {
                _sprite.Draw(1f);
            }
            // if selection a rectangle, draw a fading selection
            if (_selectionMode == SpriteEditorSelectionMode.SelectingTile)
            {
                Rectangle hRect              = _spriteRectangles[_selectedRectangle];
                Color     rectColor          = new Color(255, 255, 255, (byte)_alphaCounter);
                Color     highlightRectColor = new Color(155, 225, 255, (byte)_alphaCounter);
                foreach (var rect in this.Sprite.Material.Areas)
                {
                    Color color = rectColor;
                    if (rect.Key == _selectedRectangle)
                    {
                        color = highlightRectColor;
                    }
                    DrawingManager.DrawFilledRectangle(1, new Vector2(rect.Value.X, rect.Value.Y),
                                                       new Vector2(rect.Value.Width, rect.Value.Height), color, DrawingBlendingType.Alpha);
                }
                if (_alphaGoingUp)
                {
                    _alphaCounter += 8;
                    if (_alphaCounter > 190)
                    {
                        _alphaCounter = 190;
                        _alphaGoingUp = false;
                    }
                }
                else
                {
                    _alphaCounter -= 8;
                    if (_alphaCounter < 40)
                    {
                        _alphaCounter = 40;
                        _alphaGoingUp = true;
                    }
                }
            }

            DrawingManager.ViewPortSize = new Point(this.Width, this.Height);
            MilkshakeForm.SwapCameraAndRenderScene(ParentEditor.ZoomBox.Camera);
            _parent.Update(1 / 60f);
        }
Beispiel #8
0
        protected override void Draw()
        {
            DrawingManager.ViewPortSize = new Point(this.Width, this.Height);
            ParentEditor.ZoomBox.Camera.Update(1 / 60f);
            GraphicsDevice.Clear(Color.CornflowerBlue);
            // Use SpriteSortMode.Immediate, so we can apply custom renderstates.
            _spriteBatch.Begin(SpriteBlendMode.AlphaBlend,
                               SpriteSortMode.Immediate,
                               SaveStateMode.SaveState);

            // Set the texture addressing mode to wrap, so we can repeat
            // many copies of our tiled checkerboard texture.
            GraphicsDevice.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
            GraphicsDevice.SamplerStates[0].AddressV = TextureAddressMode.Wrap;
            Rectangle fullRect = new Rectangle(0, 0, this.Width, this.Height);

            // Draw a tiled checkerboard pattern in the background.
            _spriteBatch.Draw(_checkerTexture, fullRect, fullRect, new Color(64, 64, 92));
            if (CompositeEntity == null)
            {
                _spriteBatch.End();
            }
            else
            {
                _spriteBatch.End();

                float gridSize = 100000;
                DrawingManager.DrawFilledRectangle(10, new Vector2(-gridSize, 0),
                                                   new Vector2(gridSize * 2, 1), new Color(128, 128, 128, 40), DrawingBlendingType.Alpha);
                DrawingManager.DrawFilledRectangle(10, new Vector2(0, -gridSize),
                                                   new Vector2(1, gridSize * 2), new Color(128, 128, 128, 40), DrawingBlendingType.Alpha);


                DrawingManager.DrawFilledRectangle(10, new Vector2(-gridSize, 213),
                                                   new Vector2(gridSize * 2, 1), new Color(255, 0, 255, 0), DrawingBlendingType.Alpha);


                CompositeEntity.Position = new Vector2(0);
                if (ParentEditor.SelectedCompositeKeyFrame != null)
                {
                    DrawKeyFrame(ParentEditor.SelectedCompositeKeyFrame);

                    if (String.IsNullOrEmpty(this.HighlightedBone) == false)
                    {
                        DrawBoneSceneItemBoundingRect(this.HighlightedBone, Color.Gray);
                    }
                    foreach (String boneTransformRef in this.SelectedBones)
                    {
                        DrawBoneSceneItemBoundingRect(boneTransformRef, Color.Blue);
                    }

                    if (_refreshSceneItemProperties == true)
                    {
                        ParentEditor.propertyGridCompositeBoneTransform.SelectedObject
                            = this.ParentEditor.SelectedCompositeBoneTransform;
                        _refreshSceneItemProperties = false;
                    }
                }
                MilkshakeForm.SwapCameraAndRenderScene(ParentEditor.ZoomBox.Camera);

                // draw Pivot
                if (String.IsNullOrEmpty(this.HighlightedBone) != true)
                {
                    _spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
                    Vector2 offset = new Vector2(this.Width / 2f, this.Height / 2f);
                    CompositeBoneTransform boneTransform = ParentEditor.SelectedCompositeKeyFrame.GetBoneTransformFromKeyFrame(
                        ParentEditor.SelectedCompositeKeyFrame, this.HighlightedBone);
                    SceneItem boneTransformSceneItem = boneTransform.GetSceneItem();
                    if (boneTransform.IsVisible == true &&
                        boneTransformSceneItem != null)
                    {
                        Rectangle boundingRect = boneTransformSceneItem.BoundingRect;
                        Vector2   pivotPos     = offset + boneTransformSceneItem.GetAbsolutePivot(true)
                                                 + new Vector2(boundingRect.X, boundingRect.Y);
                        _spriteBatch.Draw(_pivotTexture, pivotPos, null, Color.White, 0, new Vector2(6.5f),
                                          Vector2.One, SpriteEffects.None, 1);
                    }
                    _spriteBatch.End();
                }
            }
            if (ParentEditor.UpdatePreview == true)
            {
                ParentEditor.UpdatePreview = false;
                ParentEditor.PreviewAnimation();
            }
            ParentEditor.Update(1 / 60f);
        }