* changed SoundStream.onStart to onSeek
* made network package compilable in D2 + Vector2.max function to return the bigger member git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1354 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
40f13c7302
commit
bf539551b9
@ -68,8 +68,8 @@ class Sound : SoundSource!("sfSound")
|
|||||||
throw new NullParameterException("NullParameterException : SoundBuffer is null.");
|
throw new NullParameterException("NullParameterException : SoundBuffer is null.");
|
||||||
|
|
||||||
super();
|
super();
|
||||||
sfSound_SetBuffer(m_ptr, buffer.getNativePointer());
|
setBuffer(buffer);
|
||||||
sfSound_SetLoop(m_ptr, loop);
|
setLoop(loop);
|
||||||
setPitch(pitch);
|
setPitch(pitch);
|
||||||
setVolume(volume);
|
setVolume(volume);
|
||||||
setPosition(x, y, z);
|
setPosition(x, y, z);
|
||||||
|
@ -32,7 +32,7 @@ protected :
|
|||||||
|
|
||||||
this(void* ptr)
|
this(void* ptr)
|
||||||
{
|
{
|
||||||
super(ptr, true);
|
super(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -199,7 +199,7 @@ protected:
|
|||||||
m_channelsCount = channelsCount;
|
m_channelsCount = channelsCount;
|
||||||
m_sampleRate = sampleRate;
|
m_sampleRate = sampleRate;
|
||||||
|
|
||||||
m_ptr = sfSoundStream_Create(&externalOnGetData, &externalOnSeek, channelsCount, sampleRate, &m_id); // TODO: hack
|
super(sfSoundStream_Create(&externalOnGetData, &externalOnSeek, channelsCount, sampleRate, &m_id));
|
||||||
|
|
||||||
m_mutex = new Mutex();
|
m_mutex = new Mutex();
|
||||||
|
|
||||||
@ -212,12 +212,9 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called each time the stream restart
|
* Called each time the stream is seeked
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* false to abort the playback
|
|
||||||
*/
|
*/
|
||||||
abstract bool onStart();
|
abstract void onSeek();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called each time the stream needs new data.
|
* Called each time the stream needs new data.
|
||||||
@ -233,16 +230,15 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// Called sync when user calling play()
|
// Called sync when user calling play()
|
||||||
// FIXME: this needs to be transformed from OnStart to OnSeek
|
// TODO: check if it's correct that way
|
||||||
extern(C) static void externalOnSeek(float t, void* user)
|
extern(C) static void externalOnSeek(float t, void* user)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
if ((id = *cast(int*) user) in s_instances)
|
if ((id = *cast(int*) user) in s_instances)
|
||||||
{
|
{
|
||||||
SoundStream temp = s_instances[id];
|
SoundStream temp = s_instances[id];
|
||||||
return (temp.m_flag = temp.onStart());
|
return (temp.onSeek());
|
||||||
}
|
}
|
||||||
// return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// C Thread callback (no allocation can be done)
|
// C Thread callback (no allocation can be done)
|
||||||
|
@ -173,7 +173,7 @@ class Ftp : DSFMLObject
|
|||||||
typedef void function(void*) pf_sfFtpResponse_Destroy;
|
typedef void function(void*) pf_sfFtpResponse_Destroy;
|
||||||
typedef int function(void*) pf_sfFtpResponse_IsOk;
|
typedef int function(void*) pf_sfFtpResponse_IsOk;
|
||||||
typedef FtpStatus function(void*) pf_sfFtpResponse_GetStatus;
|
typedef FtpStatus function(void*) pf_sfFtpResponse_GetStatus;
|
||||||
typedef char* function(void*) pf_sfFtpResponse_GetMessage;
|
typedef ichar* function(void*) pf_sfFtpResponse_GetMessage;
|
||||||
|
|
||||||
static pf_sfFtpResponse_Destroy sfFtpResponse_Destroy;
|
static pf_sfFtpResponse_Destroy sfFtpResponse_Destroy;
|
||||||
static pf_sfFtpResponse_IsOk sfFtpResponse_IsOk;
|
static pf_sfFtpResponse_IsOk sfFtpResponse_IsOk;
|
||||||
@ -222,7 +222,7 @@ class Ftp : DSFMLObject
|
|||||||
extern (C)
|
extern (C)
|
||||||
{
|
{
|
||||||
typedef void function(void*) pf_sfFtpDirectoryResponse_Destroy;
|
typedef void function(void*) pf_sfFtpDirectoryResponse_Destroy;
|
||||||
typedef char* function(void*) pf_sfFtpDirectoryResponse_GetDirectory;
|
typedef ichar* function(void*) pf_sfFtpDirectoryResponse_GetDirectory;
|
||||||
|
|
||||||
static pf_sfFtpDirectoryResponse_Destroy sfFtpDirectoryResponse_Destroy;
|
static pf_sfFtpDirectoryResponse_Destroy sfFtpDirectoryResponse_Destroy;
|
||||||
static pf_sfFtpDirectoryResponse_GetDirectory sfFtpDirectoryResponse_GetDirectory;
|
static pf_sfFtpDirectoryResponse_GetDirectory sfFtpDirectoryResponse_GetDirectory;
|
||||||
@ -301,7 +301,7 @@ class Ftp : DSFMLObject
|
|||||||
{
|
{
|
||||||
typedef void function(void*) pf_sfFtpListingResponse_Destroy;
|
typedef void function(void*) pf_sfFtpListingResponse_Destroy;
|
||||||
typedef size_t function(void*) pf_sfFtpListingResponse_GetCount;
|
typedef size_t function(void*) pf_sfFtpListingResponse_GetCount;
|
||||||
typedef char* function(void*, size_t) pf_sfFtpListingResponse_GetFilename;
|
typedef ichar* function(void*, size_t) pf_sfFtpListingResponse_GetFilename;
|
||||||
|
|
||||||
static pf_sfFtpListingResponse_Destroy sfFtpListingResponse_Destroy;
|
static pf_sfFtpListingResponse_Destroy sfFtpListingResponse_Destroy;
|
||||||
static pf_sfFtpListingResponse_GetCount sfFtpListingResponse_GetCount;
|
static pf_sfFtpListingResponse_GetCount sfFtpListingResponse_GetCount;
|
||||||
@ -542,19 +542,19 @@ private:
|
|||||||
typedef void function(void*) pf_sfFtp_Destroy;
|
typedef void function(void*) pf_sfFtp_Destroy;
|
||||||
typedef void* function(void*, IPAddress, ushort, float) pf_sfFtp_Connect;
|
typedef void* function(void*, IPAddress, ushort, float) pf_sfFtp_Connect;
|
||||||
typedef void* function(void*) pf_sfFtp_LoginAnonymous;
|
typedef void* function(void*) pf_sfFtp_LoginAnonymous;
|
||||||
typedef void* function(void*, char*, char*) pf_sfFtp_Login;
|
typedef void* function(void*, cchar*, cchar*) pf_sfFtp_Login;
|
||||||
typedef void* function(void*) pf_sfFtp_Disconnect;
|
typedef void* function(void*) pf_sfFtp_Disconnect;
|
||||||
typedef void* function(void*) pf_sfFtp_KeepAlive;
|
typedef void* function(void*) pf_sfFtp_KeepAlive;
|
||||||
typedef void* function(void*) pf_sfFtp_GetWorkingDirectory;
|
typedef void* function(void*) pf_sfFtp_GetWorkingDirectory;
|
||||||
typedef void* function(void*, char*) pf_sfFtp_GetDirectoryListing;
|
typedef void* function(void*, cchar*) pf_sfFtp_GetDirectoryListing;
|
||||||
typedef void* function(void*, char*) pf_sfFtp_ChangeDirectory;
|
typedef void* function(void*, cchar*) pf_sfFtp_ChangeDirectory;
|
||||||
typedef void* function(void*) pf_sfFtp_ParentDirectory;
|
typedef void* function(void*) pf_sfFtp_ParentDirectory;
|
||||||
typedef void* function(void*, char*) pf_sfFtp_MakeDirectory;
|
typedef void* function(void*, cchar*) pf_sfFtp_MakeDirectory;
|
||||||
typedef void* function(void*, char*) pf_sfFtp_DeleteDirectory;
|
typedef void* function(void*, cchar*) pf_sfFtp_DeleteDirectory;
|
||||||
typedef void* function(void*, char*, char*) pf_sfFtp_RenameFile;
|
typedef void* function(void*, cchar*, cchar*) pf_sfFtp_RenameFile;
|
||||||
typedef void* function(void*, char*) pf_sfFtp_DeleteFile;
|
typedef void* function(void*, cchar*) pf_sfFtp_DeleteFile;
|
||||||
typedef void* function(void*, char*, char*, FtpTransferMode) pf_sfFtp_Download;
|
typedef void* function(void*, cchar*, cchar*, FtpTransferMode) pf_sfFtp_Download;
|
||||||
typedef void* function(void*, char*, char*, FtpTransferMode) pf_sfFtp_Upload;
|
typedef void* function(void*, cchar*, cchar*, FtpTransferMode) pf_sfFtp_Upload;
|
||||||
|
|
||||||
static pf_sfFtp_Create sfFtp_Create;
|
static pf_sfFtp_Create sfFtp_Create;
|
||||||
static pf_sfFtp_Destroy sfFtp_Destroy;
|
static pf_sfFtp_Destroy sfFtp_Destroy;
|
||||||
|
@ -162,11 +162,11 @@ class Http : DSFMLObject
|
|||||||
extern (C)
|
extern (C)
|
||||||
{
|
{
|
||||||
typedef void function(void*) pf_sfHttpResponse_Destroy;
|
typedef void function(void*) pf_sfHttpResponse_Destroy;
|
||||||
typedef char* function(void*, char*) pf_sfHttpResponse_GetField;
|
typedef ichar* function(void*, cchar*) pf_sfHttpResponse_GetField;
|
||||||
typedef HttpStatus function(void*) pf_sfHttpResponse_GetStatus;
|
typedef HttpStatus function(void*) pf_sfHttpResponse_GetStatus;
|
||||||
typedef uint function(void*) pf_sfHttpResponse_GetMajorVersion;
|
typedef uint function(void*) pf_sfHttpResponse_GetMajorVersion;
|
||||||
typedef uint function(void*) pf_sfHttpResponse_GetMinorVersion;
|
typedef uint function(void*) pf_sfHttpResponse_GetMinorVersion;
|
||||||
typedef char* function(void*) pf_sfHttpResponse_GetBody;
|
typedef ichar* function(void*) pf_sfHttpResponse_GetBody;
|
||||||
|
|
||||||
static pf_sfHttpResponse_Destroy sfHttpResponse_Destroy;
|
static pf_sfHttpResponse_Destroy sfHttpResponse_Destroy;
|
||||||
static pf_sfHttpResponse_GetField sfHttpResponse_GetField;
|
static pf_sfHttpResponse_GetField sfHttpResponse_GetField;
|
||||||
@ -278,11 +278,11 @@ class Http : DSFMLObject
|
|||||||
{
|
{
|
||||||
typedef void* function() pf_sfHttpRequest_Create;
|
typedef void* function() pf_sfHttpRequest_Create;
|
||||||
typedef void function(void*) pf_sfHttpRequest_Destroy;
|
typedef void function(void*) pf_sfHttpRequest_Destroy;
|
||||||
typedef void function(void*, char*, char*) pf_sfHttpRequest_SetField;
|
typedef void function(void*, cchar*, cchar*) pf_sfHttpRequest_SetField;
|
||||||
typedef void function(void*, HttpMethod) pf_sfHttpRequest_SetMethod;
|
typedef void function(void*, HttpMethod) pf_sfHttpRequest_SetMethod;
|
||||||
typedef void function(void*, char*) pf_sfHttpRequest_SetURI;
|
typedef void function(void*, cchar*) pf_sfHttpRequest_SetURI;
|
||||||
typedef void function(void*, uint, uint) pf_sfHttpRequest_SetHttpVersion;
|
typedef void function(void*, uint, uint) pf_sfHttpRequest_SetHttpVersion;
|
||||||
typedef void function(void*, char*) pf_sfHttpRequest_SetBody;
|
typedef void function(void*, cchar*) pf_sfHttpRequest_SetBody;
|
||||||
|
|
||||||
static pf_sfHttpRequest_Create sfHttpRequest_Create;
|
static pf_sfHttpRequest_Create sfHttpRequest_Create;
|
||||||
static pf_sfHttpRequest_Destroy sfHttpRequest_Destroy;
|
static pf_sfHttpRequest_Destroy sfHttpRequest_Destroy;
|
||||||
@ -374,7 +374,7 @@ private:
|
|||||||
{
|
{
|
||||||
typedef void* function() pf_sfHttp_Create;
|
typedef void* function() pf_sfHttp_Create;
|
||||||
typedef void function(void*) pf_sfHttp_Destroy;
|
typedef void function(void*) pf_sfHttp_Destroy;
|
||||||
typedef void function(void*, char*, ushort) pf_sfHttp_SetHost;
|
typedef void function(void*, cchar*, ushort) pf_sfHttp_SetHost;
|
||||||
typedef void* function(void*, void*) pf_sfHttp_SendRequest;
|
typedef void* function(void*, void*) pf_sfHttp_SendRequest;
|
||||||
|
|
||||||
static pf_sfHttp_Create sfHttp_Create;
|
static pf_sfHttp_Create sfHttp_Create;
|
||||||
|
@ -134,7 +134,7 @@ private:
|
|||||||
|
|
||||||
extern (C)
|
extern (C)
|
||||||
{
|
{
|
||||||
typedef IPAddress function(char*) pf_sfIPAddress_FromString;
|
typedef IPAddress function(cchar*) pf_sfIPAddress_FromString;
|
||||||
typedef IPAddress function(ubyte, ubyte, ubyte, ubyte) pf_sfIPAddress_FromBytes;
|
typedef IPAddress function(ubyte, ubyte, ubyte, ubyte) pf_sfIPAddress_FromBytes;
|
||||||
typedef IPAddress function(uint) pf_sfIPAddress_FromInteger;
|
typedef IPAddress function(uint) pf_sfIPAddress_FromInteger;
|
||||||
typedef int function(IPAddress) pf_sfIPAddress_IsValid;
|
typedef int function(IPAddress) pf_sfIPAddress_IsValid;
|
||||||
|
@ -130,7 +130,9 @@ class Packet : DSFMLObject
|
|||||||
byte[] getData()
|
byte[] getData()
|
||||||
{
|
{
|
||||||
if (canRead)
|
if (canRead)
|
||||||
return sfPacket_GetData(m_ptr)[0..getDataSize];
|
return sfPacket_GetData(m_ptr)[0..getDataSize()];
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -253,20 +255,18 @@ private:
|
|||||||
}
|
}
|
||||||
void internalGet(ref string data)
|
void internalGet(ref string data)
|
||||||
{
|
{
|
||||||
scope string temp = new char[sfPacket_GetDataSize(m_ptr)];
|
scope char[] temp = new char[sfPacket_GetDataSize(m_ptr)];
|
||||||
sfPacket_ReadString(m_ptr, temp.ptr);
|
sfPacket_ReadString(m_ptr, temp.ptr);
|
||||||
size_t l = fromStringz(temp.ptr).length;
|
size_t l = fromStringz(temp.ptr).length;
|
||||||
data = new char[l];
|
data = cast(string) temp[0 .. l];
|
||||||
data[] = temp[0 .. l];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void internalGet(ref wstring data)
|
void internalGet(ref wstring data)
|
||||||
{
|
{
|
||||||
scope wstring temp = new wchar[sfPacket_GetDataSize(m_ptr)];
|
scope wchar[] temp = new wchar[sfPacket_GetDataSize(m_ptr)];
|
||||||
sfPacket_ReadWideString(m_ptr, temp.ptr);
|
sfPacket_ReadWideString(m_ptr, temp.ptr);
|
||||||
size_t l = fromStringz(temp.ptr).length;
|
size_t l = fromStringz(temp.ptr).length;
|
||||||
data = new wchar[l];
|
data = cast(wstring) temp[0 .. l];
|
||||||
data[] = temp[0 .. l];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void internalSet(bool data)
|
void internalSet(bool data)
|
||||||
@ -345,8 +345,8 @@ private:
|
|||||||
typedef void function(void*, uint) pf_sfPacket_WriteUint32;
|
typedef void function(void*, uint) pf_sfPacket_WriteUint32;
|
||||||
typedef void function(void*, float) pf_sfPacket_WriteFloat;
|
typedef void function(void*, float) pf_sfPacket_WriteFloat;
|
||||||
typedef void function(void*, double) pf_sfPacket_WriteDouble;
|
typedef void function(void*, double) pf_sfPacket_WriteDouble;
|
||||||
typedef void function(void*, char*) pf_sfPacket_WriteString;
|
typedef void function(void*, cchar*) pf_sfPacket_WriteString;
|
||||||
typedef void function(void*, wchar*) pf_sfPacket_WriteWideString;
|
typedef void function(void*, cwchar*) pf_sfPacket_WriteWideString;
|
||||||
|
|
||||||
static pf_sfPacket_Create sfPacket_Create;
|
static pf_sfPacket_Create sfPacket_Create;
|
||||||
static pf_sfPacket_Destroy sfPacket_Destroy;
|
static pf_sfPacket_Destroy sfPacket_Destroy;
|
||||||
|
@ -128,8 +128,12 @@ class SocketTCP : DSFMLObject
|
|||||||
* Status code
|
* Status code
|
||||||
*/
|
*/
|
||||||
SocketStatus send(byte[] data)
|
SocketStatus send(byte[] data)
|
||||||
|
in
|
||||||
|
{
|
||||||
|
assert(data && data.length);
|
||||||
|
}
|
||||||
|
body
|
||||||
{
|
{
|
||||||
if (data && data.length > 0)
|
|
||||||
return cast(SocketStatus)sfSocketTCP_Send(m_ptr, data.ptr, data.length);
|
return cast(SocketStatus)sfSocketTCP_Send(m_ptr, data.ptr, data.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +153,12 @@ class SocketTCP : DSFMLObject
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SocketStatus receive(byte[] data, out size_t sizeReceived)
|
SocketStatus receive(byte[] data, out size_t sizeReceived)
|
||||||
|
in
|
||||||
|
{
|
||||||
|
assert(data && data.length);
|
||||||
|
}
|
||||||
|
body
|
||||||
{
|
{
|
||||||
if (data && data.length > 0)
|
|
||||||
return cast(SocketStatus)sfSocketTCP_Receive(m_ptr, data.ptr, data.length, &sizeReceived);
|
return cast(SocketStatus)sfSocketTCP_Receive(m_ptr, data.ptr, data.length, &sizeReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +103,11 @@ struct Vector2(T)
|
|||||||
{
|
{
|
||||||
return (x == other.x) && (y == other.y);
|
return (x == other.x) && (y == other.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T max()
|
||||||
|
{
|
||||||
|
return (x>y) ? x : y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
version (UnitTest)
|
version (UnitTest)
|
||||||
|
Loading…
Reference in New Issue
Block a user