* renamed SoundRecorder.canCapture to isAvailable

* some internal fixes/changes

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1352 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
trass3r 2010-01-12 19:56:38 +00:00
parent 8a848e3175
commit 9f1354b2a9
6 changed files with 74 additions and 70 deletions

View File

@ -43,7 +43,7 @@ import core.thread;
* $(B onProcessSamples and onStop will be called by a different thread, take care of synchronization issues.) * $(B onProcessSamples and onStop will be called by a different thread, take care of synchronization issues.)
* *
* Examples: * Examples:
* ------- * -------
* class MySoundRecorder : SoundRecorder * class MySoundRecorder : SoundRecorder
* { * {
* this() * this()
@ -53,21 +53,21 @@ import core.thread;
* *
* protected bool onStart() * protected bool onStart()
* { * {
* return true; * return true;
* } * }
* *
* protected void onStop() * protected void onStop()
* { * {
* *
* } * }
* *
* protected bool onProcessSamples(out short[]) * protected bool onProcessSamples(out short[])
* { * {
* // Process data here * // Process data here
* *
* return true; //return true to continue capture, else return false * return true; //return true to continue capture, else return false
* } * }
* } * }
* ------- * -------
*/ */
abstract class SoundRecorder : DSFMLObject abstract class SoundRecorder : DSFMLObject
@ -128,9 +128,9 @@ abstract class SoundRecorder : DSFMLObject
* True if audio capture is supported * True if audio capture is supported
* *
*/ */
static bool canCapture() static bool isAvailable()
{ {
return cast(bool)sfSoundRecorder_CanCapture(); return cast(bool) sfSoundRecorder_IsAvailable();
} }
protected: protected:
@ -286,38 +286,18 @@ private:
// External ==================================================================== // External ====================================================================
extern (C) static extern (C)
{ {
typedef void* function(int function(void*), int function(short*, size_t, void*), void function(void*), void*) pf_sfSoundRecorder_Create; void* function(int function(void*), int function(short*, size_t, void*), void function(void*), void*) sfSoundRecorder_Create;
typedef void function(void*) pf_sfSoundRecorder_Destroy; void function(void*) sfSoundRecorder_Destroy;
typedef void function(void*, uint SampleRate) pf_sfSoundRecorder_Start; void function(void*, uint SampleRate) sfSoundRecorder_Start;
typedef void function(void*) pf_sfSoundRecorder_Stop; void function(void*) sfSoundRecorder_Stop;
typedef uint function(void*) pf_sfSoundRecorder_GetSampleRate; uint function(void*) sfSoundRecorder_GetSampleRate;
typedef int function() pf_sfSoundRecorder_CanCapture; int function() sfSoundRecorder_IsAvailable;
static pf_sfSoundRecorder_Create sfSoundRecorder_Create;
static pf_sfSoundRecorder_Destroy sfSoundRecorder_Destroy;
static pf_sfSoundRecorder_Start sfSoundRecorder_Start;
static pf_sfSoundRecorder_Stop sfSoundRecorder_Stop;
static pf_sfSoundRecorder_GetSampleRate sfSoundRecorder_GetSampleRate;
static pf_sfSoundRecorder_CanCapture sfSoundRecorder_CanCapture;
}
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-audio-d");
else
DllLoader dll = DllLoader.load("csfml-audio");
sfSoundRecorder_Create = cast(pf_sfSoundRecorder_Create)dll.getSymbol("sfSoundRecorder_Create");
sfSoundRecorder_Destroy = cast(pf_sfSoundRecorder_Destroy)dll.getSymbol("sfSoundRecorder_Destroy");
sfSoundRecorder_Start = cast(pf_sfSoundRecorder_Start)dll.getSymbol("sfSoundRecorder_Start");
sfSoundRecorder_Stop = cast(pf_sfSoundRecorder_Stop)dll.getSymbol("sfSoundRecorder_Stop");
sfSoundRecorder_GetSampleRate = cast(pf_sfSoundRecorder_GetSampleRate)dll.getSymbol("sfSoundRecorder_GetSampleRate");
sfSoundRecorder_CanCapture = cast(pf_sfSoundRecorder_CanCapture)dll.getSymbol("sfSoundRecorder_CanCapture");
} }
mixin(loadFromSharedLib2("csfml-audio", "sfSoundRecorder_Create", "sfSoundRecorder_Destroy", "sfSoundRecorder_Start",
"sfSoundRecorder_Stop", "sfSoundRecorder_GetSampleRate", "sfSoundRecorder_IsAvailable"));
} }
// Use explicit alloc to allow instaciation by C thread // Use explicit alloc to allow instaciation by C thread
@ -333,5 +313,4 @@ private class Samples
public short* data; public short* data;
public size_t length; public size_t length;
} }

View File

@ -51,7 +51,7 @@ protected:
this(void* ptr) this(void* ptr)
{ {
super(ptr); super(ptr, true);
} }
public: public:

View File

@ -149,7 +149,7 @@ public:
* Returns: * Returns:
* Center of the view * Center of the view
*/ */
Vector2f GetCenter() Vector2f getCenter()
{ {
return Vector2f(sfView_GetCenterX(m_ptr), sfView_GetCenterY(m_ptr)); return Vector2f(sfView_GetCenterX(m_ptr), sfView_GetCenterY(m_ptr));
} }
@ -207,10 +207,12 @@ public:
* offsetX = Offset to move the view, on X axis * offsetX = Offset to move the view, on X axis
* offsetY = Offset to move the view, on Y axis * offsetY = Offset to move the view, on Y axis
*/ */
void move(float offsetX, float offsetY) View move(float offsetX, float offsetY)
{ {
sfView_Move(m_ptr, offsetX, offsetY); sfView_Move(m_ptr, offsetX, offsetY);
m_isModified = true; m_isModified = true;
return this;
} }
/** /**
@ -219,10 +221,12 @@ public:
* Params: * Params:
* offset = offsetto move the view * offset = offsetto move the view
*/ */
void move(Vector2f offset) View move(Vector2f offset)
{ {
sfView_Move(m_ptr, offset.x, offset.y); sfView_Move(m_ptr, offset.x, offset.y);
m_isModified = true; m_isModified = true;
return this;
} }
/** /**
@ -230,11 +234,13 @@ public:
* *
* Params: * Params:
* factor = Zoom factor to apply, relative to the current zoom * factor = Zoom factor to apply, relative to the current zoom
*/ */
void zoom(float factor) View zoom(float factor)
{ {
sfView_Zoom(m_ptr, factor); sfView_Zoom(m_ptr, factor);
m_isModified = true; m_isModified = true;
return this;
} }
/** /**
@ -243,9 +249,11 @@ public:
* Params: * Params:
* angle = Angle to rotate, in degree * angle = Angle to rotate, in degree
*/ */
void rotate(float angle) View rotate(float angle)
{ {
sfView_Rotate(m_ptr, angle); sfView_Rotate(m_ptr, angle);
return this;
} }
/** /**
@ -255,9 +263,11 @@ public:
* Params: * Params:
* angle = New angle, in degrees * angle = New angle, in degrees
*/ */
void setRotation(float angle) View setRotation(float angle)
{ {
sfView_SetRotation(m_ptr, angle); sfView_SetRotation(m_ptr, angle);
return this;
} }
/** /**

View File

@ -46,6 +46,30 @@ string loadFromSharedLib(string fname)
return fname ~ " = " ~ "cast(typeof(" ~ fname ~ ")) dll.getSymbol(\"" ~ fname ~ "\");"; return fname ~ " = " ~ "cast(typeof(" ~ fname ~ ")) dll.getSymbol(\"" ~ fname ~ "\");";
} }
//used to mixin code function
string loadFromSharedLib2(S...)(string lib, S fnames)
{
string res = `static this()
{
debug
DllLoader dll = DllLoader.load("` ~ lib ~ `-d");
else
DllLoader dll = DllLoader.load("` ~ lib ~ `");
`;
foreach(fname; fnames)
{
res ~= "\t" ~ fname ~ " = " ~ "cast(typeof(" ~ fname ~ ")) dll.getSymbol(\"" ~ fname ~ "\");\n";
}
return res ~ "}\n";
}
string loadDerivedFromSharedLib(string base, string fname, string derived)
{
return base ~ "_" ~ fname ~ " = " ~ "cast(typeof(" ~ base ~ "_" ~ fname ~ ")) dll.getSymbol(\"" ~ derived ~ "_" ~ fname ~ "\");";
}
/** /**
* Base class for all DSFML classes. * Base class for all DSFML classes.
*/ */

View File

@ -272,13 +272,11 @@ align(1) struct Event
struct SKey struct SKey
{ {
align(4): // cause bool is size 1
KeyCode Code; KeyCode Code;
bool Alt; bool Alt;
byte[3] Filler1;
bool Control; bool Control;
byte[3] Filler2;
bool Shift; bool Shift;
byte[3] Filler3;
} }
SKey Key; SKey Key;

View File

@ -132,21 +132,14 @@ private:
// External ==================================================================== // External ====================================================================
extern (C) static extern (C)
{ {
typedef int function(void*, KeyCode) pf_sfInput_IsKeyDown; int function(void*, KeyCode) sfInput_IsKeyDown;
typedef int function(void*, MouseButtons) pf_sfInput_IsMouseButtonDown; int function(void*, MouseButtons) sfInput_IsMouseButtonDown;
typedef int function(void*, uint, uint) pf_sfInput_IsJoystickButtonDown; int function(void*, uint, uint) sfInput_IsJoystickButtonDown;
typedef uint function (void*) pf_sfInput_GetMouseX; int function(void*) sfInput_GetMouseX;
typedef uint function(void*) pf_sfInput_GetMouseY; int function(void*) sfInput_GetMouseY;
typedef float function(void*, uint, JoyAxis) pf_sfInput_GetJoystickAxis; float function(void*, uint, JoyAxis) sfInput_GetJoystickAxis;
static pf_sfInput_IsKeyDown sfInput_IsKeyDown;
static pf_sfInput_IsMouseButtonDown sfInput_IsMouseButtonDown;
static pf_sfInput_IsJoystickButtonDown sfInput_IsJoystickButtonDown;
static pf_sfInput_GetMouseX sfInput_GetMouseX;
static pf_sfInput_GetMouseY sfInput_GetMouseY;
static pf_sfInput_GetJoystickAxis sfInput_GetJoystickAxis;
} }
static this() static this()
@ -156,11 +149,11 @@ private:
else else
DllLoader dll = DllLoader.load("csfml-window"); DllLoader dll = DllLoader.load("csfml-window");
sfInput_IsKeyDown = cast(pf_sfInput_IsKeyDown)dll.getSymbol("sfInput_IsKeyDown"); mixin(loadFromSharedLib("sfInput_IsKeyDown"));
sfInput_IsMouseButtonDown = cast(pf_sfInput_IsMouseButtonDown)dll.getSymbol("sfInput_IsMouseButtonDown"); mixin(loadFromSharedLib("sfInput_IsMouseButtonDown"));
sfInput_IsJoystickButtonDown = cast(pf_sfInput_IsJoystickButtonDown)dll.getSymbol("sfInput_IsJoystickButtonDown"); mixin(loadFromSharedLib("sfInput_IsJoystickButtonDown"));
sfInput_GetMouseX = cast(pf_sfInput_GetMouseX)dll.getSymbol("sfInput_GetMouseX"); mixin(loadFromSharedLib("sfInput_GetMouseX"));
sfInput_GetMouseY = cast(pf_sfInput_GetMouseY)dll.getSymbol("sfInput_GetMouseY"); mixin(loadFromSharedLib("sfInput_GetMouseY"));
sfInput_GetJoystickAxis = cast(pf_sfInput_GetJoystickAxis)dll.getSymbol("sfInput_GetJoystickAxis"); mixin(loadFromSharedLib("sfInput_GetJoystickAxis"));
} }
} }