FS#145 - Implement copy constructors and ToString functions in SFML.Net
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1330 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
bd9a60fef2
commit
dd255a916d
28 changed files with 627 additions and 0 deletions
|
@ -54,6 +54,21 @@ namespace SFML
|
|||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[Color]" +
|
||||
" R = " + R +
|
||||
" G = " + G +
|
||||
" B = " + B +
|
||||
" A = " + A;
|
||||
}
|
||||
|
||||
/// <summary>Red component of the color</summary>
|
||||
public byte R;
|
||||
|
||||
|
|
|
@ -61,6 +61,17 @@ namespace SFML
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[Context]";
|
||||
}
|
||||
|
||||
private static Context ourGlobalContext = null;
|
||||
|
||||
private IntPtr myThis = IntPtr.Zero;
|
||||
|
|
|
@ -74,6 +74,17 @@ namespace SFML
|
|||
throw new LoadingFailedException("font");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Construct the font from another font
|
||||
/// </summary>
|
||||
/// <param name="copy">Font to copy</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Font(Font copy) :
|
||||
base(sfFont_Copy(copy.This))
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get a glyph in the font
|
||||
|
@ -143,6 +154,17 @@ namespace SFML
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[Font]";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Handle the destruction of the object
|
||||
|
@ -190,6 +212,9 @@ namespace SFML
|
|||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
unsafe static extern IntPtr sfFont_CreateFromMemory(char* Data, uint SizeInBytes);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfFont_Copy(IntPtr Font);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfFont_Destroy(IntPtr This);
|
||||
|
||||
|
|
|
@ -120,6 +120,17 @@ namespace SFML
|
|||
throw new LoadingFailedException("image");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Construct the image from another image
|
||||
/// </summary>
|
||||
/// <param name="copy">Image to copy</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Image(Image copy) :
|
||||
base(sfImage_Copy(copy.This))
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Save the contents of the image to a file
|
||||
|
@ -297,6 +308,20 @@ namespace SFML
|
|||
get {return sfImage_GetHeight(This);}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[Image]" +
|
||||
" Width = " + Width +
|
||||
" Height = " + Height +
|
||||
" Smooth = " + Smooth;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Internal constructor
|
||||
|
@ -338,6 +363,9 @@ namespace SFML
|
|||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfImage_CreateFromFile(string Filename);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfImage_Copy(IntPtr Image);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
unsafe static extern IntPtr sfImage_CreateFromMemory(char* Data, uint Size);
|
||||
|
||||
|
|
|
@ -125,6 +125,21 @@ namespace SFML
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[IntRect]" +
|
||||
" Left = " + Left +
|
||||
" Top = " + Top +
|
||||
" Right = " + Right +
|
||||
" Bottom = " + Bottom;
|
||||
}
|
||||
|
||||
/// <summary>Left coordinate of the rectangle</summary>
|
||||
public int Left;
|
||||
|
||||
|
@ -258,6 +273,21 @@ namespace SFML
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[FloatRect]" +
|
||||
" Left = " + Left +
|
||||
" Top = " + Top +
|
||||
" Right = " + Right +
|
||||
" Bottom = " + Bottom;
|
||||
}
|
||||
|
||||
/// <summary>Left coordinate of the rectangle</summary>
|
||||
public float Left;
|
||||
|
||||
|
|
|
@ -242,6 +242,22 @@ namespace SFML
|
|||
get {return sfRenderImage_IsAvailable();}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[RenderImage]" +
|
||||
" Width = " + Width +
|
||||
" Height = " + Height +
|
||||
" Image = " + Image +
|
||||
" DefaultView = " + DefaultView +
|
||||
" CurrentView = " + CurrentView;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Handle the destruction of the object
|
||||
|
|
|
@ -425,6 +425,22 @@ namespace SFML
|
|||
sfRenderWindow_Flush(This);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[RenderWindow]" +
|
||||
" Width = " + Width +
|
||||
" Height = " + Height +
|
||||
" Settings = " + Settings +
|
||||
" DefaultView = " + DefaultView +
|
||||
" CurrentView = " + CurrentView;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Internal function to get the next event
|
||||
|
|
|
@ -41,6 +41,19 @@ namespace SFML
|
|||
throw new LoadingFailedException("shader", filename);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Construct the shader from another shader
|
||||
/// </summary>
|
||||
/// <param name="copy">Shader to copy</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Shader(Shader copy) :
|
||||
base(sfShader_Copy(copy.This))
|
||||
{
|
||||
foreach (KeyValuePair<string, Image> pair in copy.myTextures)
|
||||
myTextures[pair.Key] = copy.myTextures[pair.Key];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Load the shader from a text in memory
|
||||
|
@ -175,6 +188,17 @@ namespace SFML
|
|||
get {return null;}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[Shader]";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Handle the destruction of the object
|
||||
|
@ -205,6 +229,9 @@ namespace SFML
|
|||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfShader_CreateFromMemory(string Shader);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfShader_Copy(IntPtr Shader);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfShader_Destroy(IntPtr Shader);
|
||||
|
||||
|
|
|
@ -25,6 +25,17 @@ namespace SFML
|
|||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Construct the shape from another shape
|
||||
/// </summary>
|
||||
/// <param name="copy">Shape to copy</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Shape(Shape copy) :
|
||||
base(sfShape_Copy(copy.This))
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Position of the object on screen
|
||||
|
@ -361,6 +372,25 @@ namespace SFML
|
|||
return new Shape(sfShape_CreateCircle(center.X, center.Y, radius, color, outline, outlineColor));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[Shape]" +
|
||||
" Position = " + Position +
|
||||
" Rotation = " + Rotation +
|
||||
" Scale = " + Scale +
|
||||
" Origin = " + Origin +
|
||||
" Color = " + Color +
|
||||
" BlendMode = " + BlendMode +
|
||||
" OutlineWidth = " + OutlineWidth +
|
||||
" NbPoints = " + NbPoints;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Render the object into the given render window
|
||||
|
@ -417,6 +447,9 @@ namespace SFML
|
|||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfShape_Create();
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfShape_Copy(IntPtr Shape);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfShape_Destroy(IntPtr This);
|
||||
|
||||
|
|
|
@ -36,6 +36,18 @@ namespace SFML
|
|||
Image = image;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Construct the sprite from another sprite
|
||||
/// </summary>
|
||||
/// <param name="copy">Sprite to copy</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Sprite(Sprite copy) :
|
||||
base(sfSprite_Copy(copy.This))
|
||||
{
|
||||
Image = copy.Image;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Position of the object on screen
|
||||
|
@ -215,6 +227,27 @@ namespace SFML
|
|||
return sfSprite_GetPixel(This, x, y);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[Sprite]" +
|
||||
" Position = " + Position +
|
||||
" Rotation = " + Rotation +
|
||||
" Scale = " + Scale +
|
||||
" Origin = " + Origin +
|
||||
" Color = " + Color +
|
||||
" BlendMode = " + BlendMode +
|
||||
" Width = " + Width +
|
||||
" Height = " + Height +
|
||||
" SubRect = " + SubRect +
|
||||
" Image = " + Image;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Render the object into the given render window
|
||||
|
@ -262,6 +295,9 @@ namespace SFML
|
|||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfSprite_Create();
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfSprite_Copy(IntPtr Sprite);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfSprite_Destroy(IntPtr This);
|
||||
|
||||
|
|
|
@ -83,6 +83,18 @@ namespace SFML
|
|||
Size = size;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Construct the text from another text
|
||||
/// </summary>
|
||||
/// <param name="copy">Text to copy</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Text(Text copy) :
|
||||
base(sfText_Copy(copy.This))
|
||||
{
|
||||
Font = copy.Font;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Position of the object on screen
|
||||
|
@ -256,6 +268,28 @@ namespace SFML
|
|||
return Pos;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[Text]" +
|
||||
" Position = " + Position +
|
||||
" Rotation = " + Rotation +
|
||||
" Scale = " + Scale +
|
||||
" Origin = " + Origin +
|
||||
" Color = " + Color +
|
||||
" BlendMode = " + BlendMode +
|
||||
" String = " + DisplayedString +
|
||||
" Font = " + Font +
|
||||
" Size = " + Size +
|
||||
" Style = " + Style +
|
||||
" Rectangle = " + GetRect();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Render the object into the given render window
|
||||
|
@ -303,6 +337,9 @@ namespace SFML
|
|||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfText_Create();
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfText_Copy(IntPtr Text);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfText_Destroy(IntPtr This);
|
||||
|
||||
|
|
|
@ -104,6 +104,19 @@ namespace SFML
|
|||
return new Vector2(v.X / x, v.Y / x);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[Vector2]" +
|
||||
" X = " + X +
|
||||
" Y = " + Y;
|
||||
}
|
||||
|
||||
/// <summary>X (horizontal) component of the vector</summary>
|
||||
public float X;
|
||||
|
||||
|
|
|
@ -49,6 +49,17 @@ namespace SFML
|
|||
this.Size = size;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Construct the view from another view
|
||||
/// </summary>
|
||||
/// <param name="copy">View to copy</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public View(View copy) :
|
||||
base(sfView_Copy(copy.This))
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Center of the view
|
||||
|
@ -138,6 +149,21 @@ namespace SFML
|
|||
sfView_Zoom(This, factor);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Provide a string describing the object
|
||||
/// </summary>
|
||||
/// <returns>String description of the object</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override string ToString()
|
||||
{
|
||||
return "[View]" +
|
||||
" Center = " + Center +
|
||||
" Size = " + Size +
|
||||
" Rotation = " + Rotation +
|
||||
" Viewport = " + Viewport;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Internal constructor for other classes which need to manipulate raw views
|
||||
|
@ -167,6 +193,9 @@ namespace SFML
|
|||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfView_CreateFromRect(FloatRect Rect);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfView_Copy(IntPtr View);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfView_Destroy(IntPtr View);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue