public override void Draw(DrawParameters p) { if (this.PropState.ScreenBounds.HasValue) { this.location.X = this.PropState.ScreenBounds.Value.X; this.location.Y = this.PropState.ScreenBounds.Value.Y; p.SpriteBatch.DrawString(this.font.Font, GetText(), this.location, actualColor, (float)screenRotation, this.Origin, this.PropState.Scale, (SpriteEffects)this.FlipEffects, this.Depth + p.NextSystemImageDepth()); } base.Draw(p); }
void DrawTiles(DrawParameters p) { var depth = this.PropState.Depth + p.NextSystemImageDepth(); var imageRes = this.texture.Image.Bounds; Rectangle screenBounds = Rectangle.Empty; this.PropState.ScreenBounds.Value.ToRectangle(ref screenBounds); // fill whole rows and cols first int wholeCols = screenBounds.Width / imageRes.Width; int wholeRows = screenBounds.Height / imageRes.Height; Vector2 loc = new Vector2(screenBounds.X, screenBounds.Y); Rectangle? srcRect = null; this.SourceRectangle.ToRectangle(ref srcRect); for(int row = 0; row < wholeRows; row++) { loc.X = screenBounds.X; for(int col = 0; col < wholeCols; col++) { p.SpriteBatch.Draw(this.texture.Image, loc, srcRect, actualBackColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, depth); loc.X += imageRes.Width; } loc.Y += imageRes.Height; } // fill margins int rightMargin = screenBounds.Width % imageRes.Width; int bottomMargin = screenBounds.Height % imageRes.Height; Rectangle sourceBounds = imageRes; if (rightMargin != 0) { loc.X = screenBounds.X + wholeCols * imageRes.Width; loc.Y = screenBounds.Y; sourceBounds.Width = rightMargin; for (int row = 0; row < wholeRows; row++) { p.SpriteBatch.Draw(this.texture.Image, loc, sourceBounds, actualBackColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, depth); loc.Y += imageRes.Height; } if (bottomMargin != 0) { sourceBounds.Height = bottomMargin; p.SpriteBatch.Draw(this.texture.Image, loc, sourceBounds, actualBackColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, depth); } } if (bottomMargin != 0) { loc.X = screenBounds.X; sourceBounds.Width = imageRes.Width; for (int col = 0; col < wholeCols; col++) { p.SpriteBatch.Draw(this.texture.Image, loc, sourceBounds, actualBackColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, depth); loc.X += imageRes.Width; } } }
void DrawStretched(DrawParameters p) { p.SpriteBatch.Draw(this.texture.Image, this.PropState.ScreenBounds.Value, this.SourceRectangle, actualBackColor, screenRotation, this.Origin, (SpriteEffects)this.FlipEffects, this.PropState.Depth + p.NextSystemImageDepth()); }
void DrawActualSize(DrawParameters p) { // we're using location this.tmpVector1.X = this.PropState.ScreenBounds.Value.X; this.tmpVector1.Y = this.PropState.ScreenBounds.Value.Y; p.SpriteBatch.Draw(this.texture.Image, this.tmpVector1, this.SourceRectangle, actualBackColor, (float)screenRotation, this.Origin, this.PropState.Scale, (SpriteEffects)this.FlipEffects, this.PropState.Depth + p.NextSystemImageDepth()); }
void DrawActualSize(DrawParameters p) { // we're using location this.tmpVector1.X = this.PropState.ScreenBounds.Value.X; this.tmpVector1.Y = this.PropState.ScreenBounds.Value.Y; p.SpriteBatch.Draw(this.texture.Image, this.tmpVector1, this.SourceRectangle, actualBackColor, (float)screenRotation, this.Origin, this.PropState.Scale, (SpriteEffects)this.FlipEffects, this.PropState.Depth + p.NextSystemImageDepth()); }
public override void Draw(DrawParameters p) { if (this.PropState.ScreenBounds.HasValue) { this.location.X = this.PropState.ScreenBounds.Value.X; this.location.Y = this.PropState.ScreenBounds.Value.Y; p.SpriteBatch.DrawString(this.font.Font, GetText(), this.location, actualColor, (float)screenRotation, this.Origin, this.PropState.Scale, (SpriteEffects)this.FlipEffects, this.Depth + p.NextSystemImageDepth()); } base.Draw(p); }