/*
* SpriteBatchProxy.cs
* Authors: Mike DeMauro
* Copyright (c) 2007-2008 Cornell University
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
namespace tAC_Engine.GUI
{
///
/// Enables a group of sprites to be drawn using the same settings.
///
///
/// Controls access to a contained SpriteBatch. Only calls to Draw, DrawString, and respective overrides are allowed.
///
public class SpriteBatchProxy
{
///
/// The encapsulated SpriteBatch.
///
private SpriteBatch sb;
///
/// Creates a new SpriteBatchProxy for a given SpriteBatch
///
///
public SpriteBatchProxy(SpriteBatch spriteBatch)
{
sb = spriteBatch;
}
//
// Summary:
// Adds a sprite to the batch of sprites to be rendered, specifying the texture,
// destination rectangle, and color tint. Reference page contains links to related
// code samples.
//
// Parameters:
// texture:
// The sprite texture.
//
// destinationRectangle:
// A rectangle specifying, in screen coordinates, where the sprite will be drawn.
// If this rectangle is not the same size as sourcerectangle, the sprite is
// scaled to fit.
//
// color:
// The color channel modulation to use. Use Color.White for full color with
// no tinting.
public void Draw(Texture2D texture, Rectangle destinationRectangle, Color color)
{
sb.Draw(texture, destinationRectangle, color);
}
//
// Summary:
// Adds a sprite to the batch of sprites to be rendered, specifying the texture,
// screen position, and color tint. Reference page contains links to related
// code samples.
//
// Parameters:
// texture:
// The sprite texture.
//
// position:
// The location, in screen coordinates, where the sprite will be drawn.
//
// color:
// The color channel modulation to use. Use Color.White for full color with
// no tinting.
public void Draw(Texture2D texture, Vector2 position, Color color)
{
sb.Draw(texture, position, color);
}
//
// Summary:
// Adds a sprite to the batch of sprites to be rendered, specifying the texture,
// destination and source rectangles, and color tint. Reference page contains
// links to related code samples.
//
// Parameters:
// texture:
// The sprite texture.
//
// destinationRectangle:
// A rectangle specifying, in screen coordinates, where the sprite will be drawn.
// If this rectangle is not the same size as sourcerectangle the sprite will
// be scaled to fit.
//
// sourceRectangle:
// A rectangle specifying, in texels, which section of the rectangle to draw.
// Use null to draw the entire texture.
//
// color:
// The color channel modulation to use. Use Color.White for full color with
// no tinting.
public void Draw(Texture2D texture, Rectangle destinationRectangle, Rectangle? sourceRectangle, Color color)
{
sb.Draw(texture, destinationRectangle, sourceRectangle, color);
}
//
// Summary:
// Adds a sprite to the batch of sprites to be rendered, specifying the texture,
// screen position, source rectangle, and color tint. Reference page contains
// links to related code samples.
//
// Parameters:
// texture:
// The sprite texture.
//
// position:
// The location, in screen coordinates, where the sprite will be drawn.
//
// sourceRectangle:
// A rectangle specifying, in texels, which section of the rectangle to draw.
// Use null to draw the entire texture.
//
// color:
// The color channel modulation to use. Use Color.White for full color with
// no tinting.
public void Draw(Texture2D texture, Vector2 position, Rectangle? sourceRectangle, Color color)
{
sb.Draw(texture, position, sourceRectangle, color);
}
//
// Summary:
// Adds a sprite to the batch of sprites to be rendered, specifying the texture,
// destination, and source rectangles, color tint, rotation, origin, effects,
// and sort depth. Reference page contains links to related code samples.
//
// Parameters:
// texture:
// The sprite texture.
//
// destinationRectangle:
// A rectangle specifying, in screen coordinates, where the sprite will be drawn.
// If this rectangle is not the same size as sourceRectangle, the sprite is
// scaled to fit.
//
// sourceRectangle:
// A rectangle specifying, in texels, which section of the rectangle to draw.
// Use null to draw the entire texture.
//
// color:
// The color channel modulation to use. Use Color.White for full color with
// no tinting.
//
// rotation:
// The angle, in radians, to rotate the sprite around the origin.
//
// origin:
// The origin of the sprite. Specify (0,0) for the upper-left corner.
//
// effects:
// Rotations to apply prior to rendering.
//
// layerDepth:
// The sorting depth of the sprite, between 0 (front) and 1 (back). You must
// specify either SpriteSortMode.FrontToBack or SpriteSortMode.BackToFront for
// this parameter to affect sprite drawing.
public void Draw(Texture2D texture, Rectangle destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth)
{
sb.Draw(texture, destinationRectangle, sourceRectangle, color, rotation, origin, effects, layerDepth);
}
//
// Summary:
// Adds a sprite to the batch of sprites to be rendered, specifying the texture,
// screen position, optional source rectangle, color tint, rotation, origin,
// scale, effects, and sort depth. Reference page contains links to related
// code samples.
//
// Parameters:
// texture:
// The sprite texture.
//
// position:
// The location, in screen coordinates, where the sprite will be drawn.
//
// sourceRectangle:
// A rectangle specifying, in texels, which section of the rectangle to draw.
// Use null to draw the entire texture.
//
// color:
// The color channel modulation to use. Use Color.White for full color with
// no tinting.
//
// rotation:
// The angle, in radians, to rotate the sprite around the origin.
//
// origin:
// The origin of the sprite. Specify (0,0) for the upper-left corner.
//
// scale:
// Uniform multiple by which to scale the sprite width and height.
//
// effects:
// Rotations to apply prior to rendering.
//
// layerDepth:
// The sorting depth of the sprite, between 0 (front) and 1 (back). You must
// specify either SpriteSortMode.FrontToBack or SpriteSortMode.BackToFront for
// this parameter to affect sprite drawing.
public void Draw(Texture2D texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
{
sb.Draw(texture, position, sourceRectangle, color, rotation, origin, scale, effects, layerDepth);
}
//
// Summary:
// Adds a sprite to the batch of sprites to be rendered, specifying the texture,
// screen position, source rectangle, color tint, rotation, origin, scale, effects,
// and sort depth. Reference page contains links to related code samples.
//
// Parameters:
// texture:
// The sprite texture.
//
// position:
// The location, in screen coordinates, where the sprite will be drawn.
//
// sourceRectangle:
// A rectangle specifying, in texels, which section of the rectangle to draw.
// Use null to draw the entire texture.
//
// color:
// The color channel modulation to use. Use Color.White for full color with
// no tinting.
//
// rotation:
// The angle, in radians, to rotate the sprite around the origin.
//
// origin:
// The origin of the sprite. Specify (0,0) for the upper-left corner.
//
// scale:
// Vector containing separate scalar multiples for the x- and y-axes of the
// sprite.
//
// effects:
// Rotations to apply before rendering.
//
// layerDepth:
// The sorting depth of the sprite, between 0 (front) and 1 (back). You must
// specify either SpriteSortMode.FrontToBack or SpriteSortMode.BackToFront for
// this parameter to affect sprite drawing.
public void Draw(Texture2D texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)
{
sb.Draw(texture, position, sourceRectangle, color, rotation, origin, scale, effects, layerDepth);
}
//
// Summary:
// Adds a sprite string to the batch of sprites to be rendered, specifying the
// font, output text, screen position, and color tint. Reference page contains
// links to related code samples.
//
// Parameters:
// spriteFont:
// The sprite font.
//
// text:
// The string to draw.
//
// position:
// The location, in screen coordinates, where the text will be drawn.
//
// color:
// The desired color of the text.
public void DrawString(SpriteFont spriteFont, string text, Vector2 position, Color color)
{
sb.DrawString(spriteFont, text, position, color);
}
//
// Summary:
// Adds a mutable sprite string to the batch of sprites to be rendered, specifying
// the font, output text, screen position, and color tint. Reference page contains
// links to related code samples.
//
// Parameters:
// spriteFont:
// The sprite font.
//
// text:
// The mutable (read/write) string to draw.
//
// position:
// The location, in screen coordinates, where the text will be drawn.
//
// color:
// The desired color of the text.
public void DrawString(SpriteFont spriteFont, StringBuilder text, Vector2 position, Color color)
{
sb.DrawString(spriteFont, text, position, color);
}
//
// Summary:
// Adds a sprite string to the batch of sprites to be rendered, specifying the
// font, output text, screen position, color tint, rotation, origin, scale,
// and effects. Reference page contains links to related code samples.
//
// Parameters:
// spriteFont:
// The sprite font.
//
// text:
// The string to draw.
//
// position:
// The location, in screen coordinates, where the text will be drawn.
//
// color:
// The desired color of the text.
//
// rotation:
// The angle, in radians, to rotate the text around the origin.
//
// origin:
// The origin of the string. Specify (0,0) for the upper-left corner.
//
// scale:
// Uniform multiple by which to scale the sprite width and height.
//
// effects:
// Rotations to apply prior to rendering.
//
// layerDepth:
// The sorting depth of the sprite, between 0 (front) and 1 (back).
public void DrawString(SpriteFont spriteFont, string text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
{
sb.DrawString(spriteFont, text, position, color, rotation, origin, scale, effects, layerDepth);
}
//
// Summary:
// Adds a sprite string to the batch of sprites to be rendered, specifying the
// font, output text, screen position, color tint, rotation, origin, scale,
// effects, and depth. Reference page contains links to related code samples.
//
// Parameters:
// spriteFont:
// The sprite font.
//
// text:
// The string to draw.
//
// position:
// The location, in screen coordinates, where the text will be drawn.
//
// color:
// The desired color of the text.
//
// rotation:
// The angle, in radians, to rotate the text around the origin.
//
// origin:
// The origin of the string. Specify (0,0) for the upper-left corner.
//
// scale:
// Vector containing separate scalar multiples for the x- and y-axes of the
// sprite.
//
// effects:
// Rotations to apply prior to rendering.
//
// layerDepth:
// The sorting depth of the sprite, between 0 (front) and 1 (back).
public void DrawString(SpriteFont spriteFont, string text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)
{
sb.DrawString(spriteFont, text, position, color, rotation, origin, scale, effects, layerDepth);
}
//
// Summary:
// Adds a mutable sprite string to the batch of sprites to be rendered, specifying
// the font, output text, screen position, color tint, rotation, origin, scale,
// and effects. Reference page contains links to related code samples.
//
// Parameters:
// spriteFont:
// The sprite font.
//
// text:
// The mutable (read/write) string to draw.
//
// position:
// The location, in screen coordinates, where the text will be drawn.
//
// color:
// The desired color of the text.
//
// rotation:
// The angle, in radians, to rotate the text around the origin.
//
// origin:
// The origin of the string. Specify (0,0) for the upper-left corner.
//
// scale:
// Uniform multiple by which to scale the sprite width and height.
//
// effects:
// Rotations to apply prior to rendering.
//
// layerDepth:
// The sorting depth of the sprite, between 0 (front) and 1 (back).
public void DrawString(SpriteFont spriteFont, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
{
sb.DrawString(spriteFont, text, position, color, rotation, origin, scale, effects, layerDepth);
}
//
// Summary:
// Adds a mutable sprite string to the batch of sprites to be rendered, specifying
// the font, output text, screen position, color tint, rotation, origin, scale,
// effects, and depth. Reference page contains links to related code samples.
//
// Parameters:
// spriteFont:
// The sprite font.
//
// text:
// The mutable (read/write) string to draw.
//
// position:
// The location, in screen coordinates, where the text will be drawn.
//
// color:
// The desired color of the text.
//
// rotation:
// The angle, in radians, to rotate the text around the origin.
//
// origin:
// The origin of the string. Specify (0,0) for the upper-left corner.
//
// scale:
// Vector containing separate scalar multiples for the x- and y-axes of the
// sprite.
//
// effects:
// Rotations to apply prior to rendering.
//
// layerDepth:
// The sorting depth of the sprite, between 0 (front) and 1 (back).
public void DrawString(SpriteFont spriteFont, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)
{
sb.DrawString(spriteFont, text, position, color, rotation, origin, scale, effects, layerDepth);
}
}
}