mirror of
https://github.com/Halofreak1990/XFXFramework
synced 2024-12-26 13:49:34 +01:00
Updated System::Nullable
Replaced sourceRectangle parameter with Nullable
This commit is contained in:
parent
baf4174344
commit
245a1b1034
@ -17,6 +17,7 @@
|
||||
#include "Sprite.h"
|
||||
#include "StateBlock.h"
|
||||
#include <System/Collections/Generic/List.h>
|
||||
#include <System/Nullable.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Types.h>
|
||||
|
||||
@ -73,12 +74,12 @@ namespace XFX
|
||||
void Begin(SpriteSortMode_t sortMode, const BlendState& blendState, const SamplerState& samplerState, const DepthStencilState& depthStencilState, const RasterizerState& rasterizerState, Effect* effect, Matrix transformMatrix);
|
||||
void Dispose();
|
||||
void Draw(Texture2D * const texture, const Rectangle destinationRectangle, Color color);
|
||||
void Draw(Texture2D * const texture, const Rectangle destinationRectangle, const Rectangle sourceRectangle, Color color);
|
||||
void Draw(Texture2D * const texture, const Rectangle destinationRectangle, const Nullable<Rectangle> sourceRectangle, Color color);
|
||||
void Draw(Texture2D * const texture, const Vector2 position, const Color color);
|
||||
void Draw(Texture2D * const texture, const Vector2 position, const Rectangle sourceRectangle, const Color color);
|
||||
void Draw(Texture2D * const texture, const Vector2 position, const Rectangle sourceRectangle, const Color color, const float rotation, const Vector2 origin, const float scale, const SpriteEffects_t effects, const float layerDepth);
|
||||
void Draw(Texture2D * const texture, const Vector2 position, const Rectangle sourceRectangle, const Color color, const float rotation, const Vector2 origin, const Vector2 scale, const SpriteEffects_t effects, const float layerDepth);
|
||||
void Draw(Texture2D * const texture, const Rectangle destinationRectangle, const Rectangle sourceRectangle, const Color color, const float rotation, const Vector2 origin, const SpriteEffects_t effects, const float layerDepth);
|
||||
void Draw(Texture2D * const texture, const Vector2 position, const Nullable<Rectangle> sourceRectangle, const Color color);
|
||||
void Draw(Texture2D * const texture, const Vector2 position, const Nullable<Rectangle> sourceRectangle, const Color color, const float rotation, const Vector2 origin, const float scale, const SpriteEffects_t effects, const float layerDepth);
|
||||
void Draw(Texture2D * const texture, const Vector2 position, const Nullable<Rectangle> sourceRectangle, const Color color, const float rotation, const Vector2 origin, const Vector2 scale, const SpriteEffects_t effects, const float layerDepth);
|
||||
void Draw(Texture2D * const texture, const Rectangle destinationRectangle, const Nullable<Rectangle> sourceRectangle, const Color color, const float rotation, const Vector2 origin, const SpriteEffects_t effects, const float layerDepth);
|
||||
void DrawString(SpriteFont * const spriteFont, String& text, const Vector2 position, const Color color);
|
||||
void DrawString(SpriteFont * const spriteFont, String& text, const Vector2 position, const Color color, const float rotation, const Vector2 origin, const Vector2 scale, const SpriteEffects_t effects, const float layerDepth);
|
||||
void DrawString(SpriteFont * const spriteFont, String& text, const Vector2 position, const Color color, const float rotation, const Vector2 origin, const float scale, const SpriteEffects_t effects, const float layerDepth);
|
||||
|
@ -30,6 +30,22 @@ namespace System
|
||||
T getValue() const { return *data; }
|
||||
|
||||
operator T() const { return *data; }
|
||||
|
||||
Nullable<T>& operator =(const T * newVal)
|
||||
{
|
||||
data = newVal;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Nullable<T>& operator =(const Nullable<T>& right)
|
||||
{
|
||||
if (right == *this)
|
||||
goto end;
|
||||
|
||||
*data = *right.data;
|
||||
end:
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -125,21 +125,21 @@ namespace XFX
|
||||
Draw(texture, destination, Rectangle::Empty, color, 0.0f, Vector2::Zero, SpriteEffects::None, 0.0f);
|
||||
}
|
||||
|
||||
void SpriteBatch::Draw(Texture2D * const texture, const Rectangle destinationRectangle, const Rectangle sourceRectangle, const Color color)
|
||||
void SpriteBatch::Draw(Texture2D * const texture, const Rectangle destinationRectangle, const Nullable<Rectangle> sourceRectangle, const Color color)
|
||||
{
|
||||
Draw(texture, destinationRectangle, sourceRectangle, color, 0.0f, Vector2::Zero, SpriteEffects::None, 0.0f);
|
||||
}
|
||||
|
||||
void SpriteBatch::Draw(Texture2D * const texture, const Vector2 position, const Rectangle sourceRectangle, const Color color)
|
||||
void SpriteBatch::Draw(Texture2D * const texture, const Vector2 position, const Nullable<Rectangle> sourceRectangle, const Color color)
|
||||
{
|
||||
Rectangle destination = Rectangle((int)position.X, (int)position.Y, texture->Width, texture->Height);
|
||||
Draw(texture, destination, sourceRectangle, color, 0.0f, Vector2::Zero, SpriteEffects::None, 0.0f);
|
||||
}
|
||||
|
||||
void SpriteBatch::Draw(Texture2D * const texture, const Rectangle destinationRectangle, const Rectangle sourceRectangle, const Color color, const float rotation, const Vector2 origin, const SpriteEffects_t effects, const float layerDepth)
|
||||
void SpriteBatch::Draw(Texture2D * const texture, const Rectangle destinationRectangle, const Nullable<Rectangle> sourceRectangle, const Color color, const float rotation, const Vector2 origin, const SpriteEffects_t effects, const float layerDepth)
|
||||
{
|
||||
Sprite sprite = Sprite(texture,
|
||||
sourceRectangle != Rectangle::Empty ? sourceRectangle : Rectangle(0, 0, texture->Width, texture->Height),
|
||||
sourceRectangle.HasValue() ? sourceRectangle : Rectangle(0, 0, texture->Width, texture->Height),
|
||||
destinationRectangle,
|
||||
color,
|
||||
rotation,
|
||||
@ -153,14 +153,14 @@ namespace XFX
|
||||
Flush();
|
||||
}
|
||||
|
||||
void SpriteBatch::Draw(Texture2D * const texture, const Vector2 position, const Rectangle sourceRectangle, const Color color, const float rotation, const Vector2 origin, const Vector2 scale, const SpriteEffects_t effects, const float layerDepth)
|
||||
void SpriteBatch::Draw(Texture2D * const texture, const Vector2 position, const Nullable<Rectangle> sourceRectangle, const Color color, const float rotation, const Vector2 origin, const Vector2 scale, const SpriteEffects_t effects, const float layerDepth)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
if (sourceRectangle != Rectangle::Empty)
|
||||
if (sourceRectangle.HasValue())
|
||||
{
|
||||
width = (int)(sourceRectangle.Width * scale.X);
|
||||
height = (int)(sourceRectangle.Height * scale.Y);
|
||||
width = (int)(sourceRectangle.getValue().Width * scale.X);
|
||||
height = (int)(sourceRectangle.getValue().Height * scale.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -171,14 +171,14 @@ namespace XFX
|
||||
Draw(texture, destination, sourceRectangle, color, rotation, origin, effects, layerDepth);
|
||||
}
|
||||
|
||||
void SpriteBatch::Draw(Texture2D * const texture, const Vector2 position, const Rectangle sourceRectangle, const Color color, const float rotation, const Vector2 origin, const float scale, const SpriteEffects_t effects, const float layerDepth)
|
||||
void SpriteBatch::Draw(Texture2D * const texture, const Vector2 position, const Nullable<Rectangle> sourceRectangle, const Color color, const float rotation, const Vector2 origin, const float scale, const SpriteEffects_t effects, const float layerDepth)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
if (sourceRectangle != Rectangle::Empty)
|
||||
if (sourceRectangle.HasValue())
|
||||
{
|
||||
width = (int)(sourceRectangle.Width * scale);
|
||||
height = (int)(sourceRectangle.Height * scale);
|
||||
width = (int)(sourceRectangle.getValue().Width * scale);
|
||||
height = (int)(sourceRectangle.getValue().Height * scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user