public void UpdateSourceRectangleControls() { _ignoreNumericUpDownEvent = true; toolStripButtonAutoDetect.Enabled = true; if (spriteEditorControl.Sprite.SourceRectangle != null) { toolStripButtonUseFullTexture.Enabled = true; numericUpDownRectX.Value = (decimal)spriteEditorControl.Sprite.SourceRectangle.Value.X; numericUpDownRectY.Value = (decimal)spriteEditorControl.Sprite.SourceRectangle.Value.Y; numericUpDownRectW.Maximum = (decimal)spriteEditorControl.Sprite.Material.Texture.Width - numericUpDownRectX.Value; numericUpDownRectH.Maximum = (decimal)spriteEditorControl.Sprite.Material.Texture.Height - numericUpDownRectY.Value; numericUpDownRectW.Value = (decimal)SquidMath.Clamp(spriteEditorControl.Sprite.SourceRectangle.Value.Width, (int)numericUpDownRectW.Minimum, (int)numericUpDownRectW.Maximum); numericUpDownRectH.Value = (decimal)SquidMath.Clamp(spriteEditorControl.Sprite.SourceRectangle.Value.Height, (int)numericUpDownRectH.Minimum, (int)numericUpDownRectH.Maximum); } else { toolStripButtonUseFullTexture.Enabled = false; numericUpDownRectX.Value = 0; numericUpDownRectY.Value = 0; if (spriteEditorControl.Sprite.Material != null) { numericUpDownRectW.Maximum = (decimal)spriteEditorControl.Sprite.Material.Texture.Width; numericUpDownRectH.Maximum = (decimal)spriteEditorControl.Sprite.Material.Texture.Height; numericUpDownRectW.Value = (decimal)spriteEditorControl.Sprite.Material.Texture.Width; numericUpDownRectH.Value = (decimal)spriteEditorControl.Sprite.Material.Texture.Height; } } _ignoreNumericUpDownEvent = false; toolStripButtonShowWholeImage.Visible = spriteEditorControl.Sprite.SourceRectangle.HasValue; }
protected void DrawBrushTileHighlight(Color color) { if (_brushStartPoint.X > -1 && _brushStartPoint.Y > -1) { Point clampedSize = _brushSize; clampedSize.X = SquidMath.Clamp(_brushStartPoint.X + clampedSize.X, 0, TileGrid.TileCols) - _brushStartPoint.X; clampedSize.Y = SquidMath.Clamp(_brushStartPoint.Y + clampedSize.Y, 0, TileGrid.TileRows) - _brushStartPoint.Y; Vector2 pos = new Vector2(_brushStartPoint.X * TileGrid.TileSize.X * TileGrid.Scale.X, _brushStartPoint.Y * TileGrid.TileSize.Y * TileGrid.Scale.Y); Vector2 size = new Vector2(clampedSize.X * TileGrid.TileSize.X * TileGrid.Scale.X, clampedSize.Y * TileGrid.TileSize.Y * TileGrid.Scale.Y); DrawingManager.DrawFilledRectangle(TileGrid.Layer, pos, size, color, TileGrid.BlendingType); } }
/// <summary> /// Insert a children bone at specific index /// </summary> public void InsertChildBone(int index, CompositeBone childBone) { index = SquidMath.Clamp(index, 0, _childBones.Count); _childBones.Insert(index, childBone); childBone.ParentBone = this; childBone.Parent = this.Parent; CompositeBone precedingBone; if (index == 0) { precedingBone = this; } else { precedingBone = this.ChildBones[index - 1]; } // sync transforms for (int i = 0; i < Parent.Animations.Count; i++) { // loop through every keyframe to sync them for (int j = 0; j < Parent.Animations[i].KeyFrames.Count; j++) { CompositeKeyFrame keyframe = Parent.Animations[i].KeyFrames[j]; // loop to find the previous bone for (int k = 0; k < keyframe.BoneTransforms.Count; k++) { CompositeBoneTransform transform = keyframe.BoneTransforms[k]; if (transform.Bone.Equals(precedingBone)) { CompositeBoneTransform newTransform = new CompositeBoneTransform(); newTransform.Parent = keyframe; newTransform.BoneReference = childBone.Name; // insert the new bone just after the preceding bone keyframe.BoneTransforms.Insert(k + 1, newTransform); } } } } }
protected Point ClampTile(Point tileCoord) { tileCoord.X = SquidMath.Clamp(tileCoord.X, 0, TileGrid.TileCols - 1); tileCoord.Y = SquidMath.Clamp(tileCoord.Y, 0, TileGrid.TileRows - 1); return(tileCoord); }