예제 #1
0
        private void toolStripButtonDelPartType_Click(object sender, EventArgs e)
        {
            int      index        = -1;
            TreeNode selectedNode = particleEffectProperties.SelectedNode;

            // check particle types
            for (int i = 0; i < particleEffectControl.ParticleEffect.Emitter.ParticleTypes.Count; i++)
            {
                // check the root
                if (selectedNode == particleEffectProperties.Nodes[0].Nodes[0].Nodes[i + 1])
                {
                    index = i;
                    break;
                }
            }
            if (index != -1)
            {
                if (MilkshakeForm.ShowWarningQuestion("Do you really want to delete this particle type?")
                    == true)
                {
                    particleEffectControl.RemoveParticleType(index);
                    UpdateParticleEffectTree();
                }
            }
        }
예제 #2
0
 private void TileGridEditor_Load(object sender, EventArgs e)
 {
     tileGridEditorControl.ParentEditor = this;
     ZoomBox = new ZoomBox();
     ZoomBox.SetToolStripButtomZoomIn(toolStripButtonZoomIn);
     ZoomBox.SetToolStripButtomZoomOut(toolStripButtonZoomOut);
     ZoomBox.SetToolStripButtomZoomNormal(toolStripButtonZoomNormal);
     labelTextureName.Text = TileGrid.Material.ToString();
     // load all the Blending Type values in the combo box
     for (int i = 0; i < (int)DrawingBlendingType.EnumSize; i++)
     {
         comboBoxBlendingType.Items.Add(((DrawingBlendingType)i).ToString());
     }
     comboBoxBlendingType.SelectedIndex = (int)TileGrid.BlendingType;
     pictureBoxTint.BackColor           = MilkshakeForm.GetGDIColor(TileGrid.Tint);
     _ignoreNumericUpDownEvent          = true;
     numericUpDownTintRed.Value         = TileGrid.Tint.R;
     numericUpDownTintGreen.Value       = TileGrid.Tint.G;
     numericUpDownTintBlue.Value        = TileGrid.Tint.B;
     _ignoreNumericUpDownEvent          = false;
     trackBarOpacity.Value         = (int)TileGrid.Tint.A;
     labelOpacity.Text             = trackBarOpacity.Value.ToString();
     checkBoxUseSafeBorder.Checked = TileGrid.UseTilingSafeBorders;
     textBoxTileWidth.Text         = TileGrid.TileSize.X.ToString(CultureInfo.InvariantCulture);
     textBoxTileHeight.Text        = TileGrid.TileSize.Y.ToString(CultureInfo.InvariantCulture);
     textBoxSizeCols.Text          = TileGrid.TileCols.ToString(CultureInfo.InvariantCulture);
     textBoxSizeRows.Text          = TileGrid.TileRows.ToString(CultureInfo.InvariantCulture);
     ApplyPaintModeSetting();
     AdjustTableLayersColumnSize();
     RefreshLayerTable();
 }
        /// <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);
        }
예제 #4
0
 private void AnimatedSpriteEditor_Load(object sender, EventArgs e)
 {
     this.ZoomBox = new ZoomBox();
     this.ZoomBox.SetToolStripButtomZoomIn(toolStripButtonZoomIn);
     this.ZoomBox.SetToolStripButtomZoomOut(toolStripButtonZoomOut);
     this.ZoomBox.SetToolStripButtomZoomNormal(toolStripButtonZoomNormal);
     this.ZoomBox.Camera.Pivot           = new Vector2(0.5f);
     this.ZoomBox.Camera.IsPivotRelative = true;
     if (this.AnimatedSprite.Material != null)
     {
         labelTextureName.Text = this.AnimatedSprite.Material.ToString();
     }
     // hack around designer bug that resize the control
     labelTextureName.Size = new Size(labelTextureName.Size.Width, 22);
     // load all the Blending Type values in the combo box
     for (int i = 0; i < (int)DrawingBlendingType.EnumSize; i++)
     {
         comboBoxBlendingType.Items.Add(((DrawingBlendingType)i).ToString());
     }
     comboBoxBlendingType.SelectedIndex = (int)this.AnimatedSprite.BlendingType;
     pictureBoxTint.BackColor           = MilkshakeForm.GetGDIColor(this.AnimatedSprite.Tint);
     _ignoreNumericUpDownEvent          = true;
     numericUpDownTintRed.Value         = this.AnimatedSprite.Tint.R;
     numericUpDownTintGreen.Value       = this.AnimatedSprite.Tint.G;
     numericUpDownTintBlue.Value        = this.AnimatedSprite.Tint.B;
     textBoxColorHTML.Text             = SpriteEditor.GetHTMLFromColor(this.AnimatedSprite.Tint);
     _ignoreNumericUpDownEvent         = false;
     sceneItemPreviewControl.SceneItem = this.AnimatedSprite;
     sceneItemPreviewControl.Camera    = this.ZoomBox.Camera;
     RefreshAreaComboList();
     LoadAnimationsList();
 }
예제 #5
0
        private void buttonSelectTexture_Click(object sender, EventArgs e)
        {
            MaterialSelectorDialog materialSelectorDialog = new MaterialSelectorDialog();

            materialSelectorDialog.SelectedMaterial  = this.AnimatedSprite.Material;
            materialSelectorDialog.ShowLocalTextures = ItemIsLocal;
            if (materialSelectorDialog.ShowDialog() == DialogResult.OK &&
                this.AnimatedSprite.Material != materialSelectorDialog.SelectedMaterial)
            {
                if (materialSelectorDialog.SelectedMaterial.Areas.Keys.Count == 0)
                {
                    MilkshakeForm.ShowErrorMessage("The selected Material \"" +
                                                   materialSelectorDialog.SelectedMaterial.ToString() + "\" does contain any defined Areas.\n" +
                                                   "To use the animations you need to load an area definition file with this Material");
                }
                else
                {
                    this.AnimatedSprite.Material        = materialSelectorDialog.SelectedMaterial;
                    this.AnimatedSprite.SourceRectangle = null;
                    this.AnimatedSprite.MaterialArea    = "";
                    labelTextureName.Text = materialSelectorDialog.SelectedMaterial.ToString();
                    RefreshAreaComboList();
                }
            }
        }
예제 #6
0
 private void toolStripButtonAutoDetect_Click(object sender, EventArgs e)
 {
     spriteEditorControl.Sprite.SourceRectangle = null;
     // if we are not already selecting a tile
     if (spriteEditorControl.SelectionMode != SpriteEditorSelectionMode.SelectingTile)
     {
         spriteEditorControl.SpriteRectangles = this.Sprite.Material.Areas;
         if (spriteEditorControl.SpriteRectangles.Count >= 1)
         {
             String firstKey = null;
             foreach (String key in this.Sprite.Material.Areas.Keys)
             {
                 firstKey = key;
                 break;
             }
             spriteEditorControl.SelectionMode     = SpriteEditorSelectionMode.SelectingTile;
             spriteEditorControl.SelectedRectangle = firstKey;
             toolStripButtonUseFullTexture.Enabled = true;
             toolStripButtonAutoDetect.Enabled     = false;
         }
         else
         {
             MilkshakeForm.ShowErrorMessage("This texture has no detected grid");
         }
     }
 }
예제 #7
0
 protected override void Draw()
 {
     UpdateTileSelection();
     GraphicsDevice.Clear(Color.LightGray);
     DrawTiles();
     MilkshakeForm.SwapCameraAndRenderScene(_camera);
 }
예제 #8
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);
        }
예제 #9
0
 private void SpriteEditor_Load(object sender, EventArgs e)
 {
     spriteEditorControl.ParentEditor = this;
     ZoomBox = new ZoomBox();
     ZoomBox.SetToolStripButtomZoomIn(toolStripButtonZoomIn);
     ZoomBox.SetToolStripButtomZoomOut(toolStripButtonZoomOut);
     ZoomBox.SetToolStripButtomZoomNormal(toolStripButtonZoomNormal);
     if (spriteEditorControl.Sprite.SourceRectangle != null)
     {
         toolStripButtonUseFullTexture.Enabled = true;
     }
     if (this.Sprite.Material != null)
     {
         labelTextureName.Text = spriteEditorControl.Sprite.Material.ToString();
     }
     LoadMaterialAreas();
     // hack around designer bug that resize the control
     labelTextureName.Size = new Size(labelTextureName.Size.Width, 22);
     // load all the Blending Type values in the combo box
     for (int i = 0; i < (int)DrawingBlendingType.EnumSize; i++)
     {
         comboBoxBlendingType.Items.Add(((DrawingBlendingType)i).ToString());
     }
     comboBoxBlendingType.SelectedIndex = (int)spriteEditorControl.Sprite.BlendingType;
     pictureBoxTint.BackColor           = MilkshakeForm.GetGDIColor(spriteEditorControl.Sprite.Tint);
     _ignoreNumericUpDownEvent          = true;
     numericUpDownTintRed.Value         = spriteEditorControl.Sprite.Tint.R;
     numericUpDownTintGreen.Value       = spriteEditorControl.Sprite.Tint.G;
     numericUpDownTintBlue.Value        = spriteEditorControl.Sprite.Tint.B;
     textBoxColorHTML.Text     = GetHTMLFromColor(Sprite.Tint);
     _ignoreNumericUpDownEvent = false;
     _ignoreNumericUpDownEvent = true;
     _ignoreNumericUpDownEvent = false;
     UpdateSourceRectangleControls();
 }
예제 #10
0
 private void buttonGenerate_Click(object sender, EventArgs e)
 {
     try
     {
         StartSpriteSheetGeneration();
         MilkshakeForm.ShowInfoMessage("Spritesheet \"" + comboBoxName.Text + "\" generated successfully");
     }
     catch (Exception ex)
     {
         MilkshakeForm.ShowErrorMessage("Could not generate spritesheet: " + ex.Message);
     }
 }
예제 #11
0
 protected virtual void RestoreValue(String errorMessage)
 {
     if (_initialized)
     {
         SetValue(_previousValue);
         MilkshakeForm.ShowErrorMessage(errorMessage);
     }
     else
     {
         SetValue(_defaultValue);
     }
 }
        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);
            }
        }
 private void textBoxLife_Validated(object sender, EventArgs e)
 {
     try
     {
         int newLife = Int32.Parse(textBoxLife.Text, System.Globalization.CultureInfo.InvariantCulture);
         if (newLife <= 0)
         {
             throw new Exception("The life of the animation must be greater than 0");
         }
         PostProcessAnimation.Life = newLife;
     }
     catch (Exception ex)
     {
         textBoxLife.Text = PostProcessAnimation.Life.ToString(CultureInfo.InvariantCulture);
         MilkshakeForm.ShowErrorMessage(ex.Message);
     }
 }
 private void textBoxLoopAmount_Validated(object sender, EventArgs e)
 {
     try
     {
         int newLoop = int.Parse(textBoxLoopAmount.Text, System.Globalization.CultureInfo.InvariantCulture);
         if (newLoop < 0)
         {
             throw new Exception("The loop amount of the animation must be greater than or equal to 0 (0 = infinite)");
         }
         PostProcessAnimation.LoopMax = newLoop;
     }
     catch (Exception ex)
     {
         textBoxLoopAmount.Text = PostProcessAnimation.LoopMax.ToString(CultureInfo.InvariantCulture);
         MilkshakeForm.ShowErrorMessage(ex.Message);
     }
 }
예제 #15
0
 private void toolStripButtonLayerClear_Click(object sender, EventArgs e)
 {
     if (MilkshakeForm.ShowWarningQuestion("Do you really want to clear the layer?"))
     {
         int layer = SelectedLayer;
         for (int y = 0; y < TileGrid.TileRows; y++)
         {
             for (int x = 0; x < TileGrid.TileCols; x++)
             {
                 TileGrid.TileLayers[layer].Tiles[x][y].Index    = -1;
                 TileGrid.TileLayers[layer].Tiles[x][y].Rotation = 0;
                 TileGrid.TileLayers[layer].Tiles[x][y].HFlip    = false;
                 TileGrid.TileLayers[layer].Tiles[x][y].VFlip    = false;
             }
         }
     }
 }
예제 #16
0
 private void RefreshTreeviewSceneItemBank()
 {
     for (int i = 0; i < treeViewSceneItems.Nodes.Count; i++)
     {
         treeViewSceneItems.Nodes[i].Nodes.Clear();
     }
     foreach (String key in CompositeEntity.SceneItemBank.Keys)
     {
         SceneItem     item     = CompositeEntity.SceneItemBank[key];
         SceneItemType itemType = MilkshakeForm.GetTypeOfSceneItem(item);
         TreeNode      newNode  = treeViewSceneItems.Nodes[(int)itemType].Nodes.Add(key);
         String        icon     = MilkshakeForm.GetIconFromType(itemType);
         newNode.SelectedImageKey = newNode.ImageKey = icon;
         newNode.Tag = item;
     }
     treeViewSceneItems.ExpandAll();
     SceneItemRefConverter.UpdateListSceneItemsRefs(CompositeEntity.SceneItemBank.Keys);
 }
예제 #17
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();
        }
예제 #18
0
 private void textBoxMax_Validated(object sender, EventArgs e)
 {
     try
     {
         int value = int.Parse(textBoxMax.Text, System.Globalization.CultureInfo.InvariantCulture);
         if (value <= selectedLinearProperty.LowerBound)
         {
             throw new Exception("The upper bound must be higher than the lower bound");
         }
         SelectedLinearProperty.UpperBound = value;
         ApplyNewRangeOfValues();
     }
     catch (Exception ex)
     {
         textBoxMax.Text = selectedLinearProperty.UpperBound
                           .ToString(System.Globalization.CultureInfo.InvariantCulture);
         MilkshakeForm.ShowErrorMessage(ex.Message);
     }
 }
예제 #19
0
        private void OpenTintSelectionDialog()
        {
            ColorDialog colorDialog = new ColorDialog();

            colorDialog.AllowFullOpen = true;
            colorDialog.FullOpen      = true;
            colorDialog.Color         = MilkshakeForm.GetGDIColor(TileGrid.Tint);
            if (colorDialog.ShowDialog() == DialogResult.OK)
            {
                pictureBoxTint.BackColor = colorDialog.Color;
                TileGrid.Tint            = new Microsoft.Xna.Framework.Graphics.Color(colorDialog.Color.R,
                                                                                      colorDialog.Color.G, colorDialog.Color.B, TileGrid.Tint.A);
                _ignoreNumericUpDownEvent    = true;
                numericUpDownTintRed.Value   = (decimal)colorDialog.Color.R;
                numericUpDownTintGreen.Value = (decimal)colorDialog.Color.G;
                numericUpDownTintBlue.Value  = (decimal)colorDialog.Color.B;
                _ignoreNumericUpDownEvent    = false;
            }
        }
예제 #20
0
        private void OpenTintSelectionDialog()
        {
            ColorDialog colorDialog = new ColorDialog();

            colorDialog.AllowFullOpen = true;
            colorDialog.FullOpen      = true;
            colorDialog.Color         = MilkshakeForm.GetGDIColor(spriteEditorControl.Sprite.Tint);
            if (colorDialog.ShowDialog() == DialogResult.OK)
            {
                pictureBoxTint.BackColor        = colorDialog.Color;
                spriteEditorControl.Sprite.Tint = new XnaColor(colorDialog.Color.R,
                                                               colorDialog.Color.G, colorDialog.Color.B, spriteEditorControl.Sprite.Tint.A);
                _ignoreNumericUpDownEvent    = true;
                numericUpDownTintRed.Value   = (decimal)colorDialog.Color.R;
                numericUpDownTintGreen.Value = (decimal)colorDialog.Color.G;
                numericUpDownTintBlue.Value  = (decimal)colorDialog.Color.B;
                _ignoreNumericUpDownEvent    = false;
                ApplyUpDownColors();
            }
        }
예제 #21
0
        private void PasteTemplate()
        {
            TreeNode node = MilkshakeForm.Instance.treeViewResources.SelectedNode;

            if (node == null || node.Tag == null || (node.Tag is SceneItem) == false)
            {
                MilkshakeForm.ShowErrorMessage("You must select a Template first");
            }
            else
            {
                SceneItem template = node.Tag as SceneItem;
                if (template.IsTemplate == false)
                {
                    MilkshakeForm.ShowErrorMessage("The selected SceneItem is not a Template");
                }
                else
                {
                    SceneItem copy = MilkshakeForm.Instance.CreateNewInstaceCopyOf(template);
                    MilkshakeForm.Instance.AddNewSceneItemInstance(copy, SceneItemGroup.SceneInstances, false);
                    copy.Position = this.SceneMousePos;
                }
            }
        }
예제 #22
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);
        }
예제 #23
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);
        }
예제 #24
0
        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);
        }