mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-26 21:16:13 +01:00
Updated to the new time API (sfTime)
This commit is contained in:
1 parent
44d4c4e707
commit
7615382a68
28 files changed
+293
-95
No files matched your search
@@ -97,9 +97,12 @@ sfBool sfMusic_GetLoop(const sfMusic* music)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfUint32 sfMusic_GetDuration(const sfMusic* music)
|
||||
sfTime sfMusic_GetDuration(const sfMusic* music)
|
||||
{
|
||||
CSFML_CALL_RETURN(music, GetDuration(), 0);
|
||||
CSFML_CHECK_RETURN(music, sfTimeZero);
|
||||
|
||||
sf::Time time = music->This.GetDuration();
|
||||
return sfMicroseconds(time.AsMicroseconds());
|
||||
}
|
||||
|
||||
|
||||
@@ -148,9 +151,12 @@ sfSoundStatus sfMusic_GetStatus(const sfMusic* music)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfUint32 sfMusic_GetPlayingOffset(const sfMusic* music)
|
||||
sfTime sfMusic_GetPlayingOffset(const sfMusic* music)
|
||||
{
|
||||
CSFML_CALL_RETURN(music, GetPlayingOffset(), 0);
|
||||
CSFML_CHECK_RETURN(music, sfTimeZero);
|
||||
|
||||
sf::Time time = music->This.GetPlayingOffset();
|
||||
return sfMicroseconds(time.AsMicroseconds());
|
||||
}
|
||||
|
||||
|
||||
@@ -197,9 +203,9 @@ void sfMusic_SetAttenuation(sfMusic* music, float attenuation)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfMusic_SetPlayingOffset(sfMusic* music, sfUint32 timeOffset)
|
||||
void sfMusic_SetPlayingOffset(sfMusic* music, sfTime timeOffset)
|
||||
{
|
||||
CSFML_CALL(music, SetPlayingOffset(timeOffset));
|
||||
CSFML_CALL(music, SetPlayingOffset(sf::Microseconds(timeOffset.Microseconds)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -160,9 +160,9 @@ void sfSound_SetAttenuation(sfSound* sound, float attenuation)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfSound_SetPlayingOffset(sfSound* sound, sfUint32 timeOffset)
|
||||
void sfSound_SetPlayingOffset(sfSound* sound, sfTime timeOffset)
|
||||
{
|
||||
CSFML_CALL(sound, SetPlayingOffset(timeOffset));
|
||||
CSFML_CALL(sound, SetPlayingOffset(sf::Microseconds(timeOffset.Microseconds)));
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,10 @@ float sfSound_GetAttenuation(const sfSound* sound)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfUint32 sfSound_GetPlayingOffset(const sfSound* sound)
|
||||
sfTime sfSound_GetPlayingOffset(const sfSound* sound)
|
||||
{
|
||||
CSFML_CALL_RETURN(sound, GetPlayingOffset(), 0)
|
||||
CSFML_CHECK_RETURN(sound, sfTimeZero)
|
||||
|
||||
sf::Time time = sound->This.GetPlayingOffset();
|
||||
return sfMicroseconds(time.AsMicroseconds());
|
||||
}
|
||||
@@ -146,7 +146,10 @@ unsigned int sfSoundBuffer_GetChannelCount(const sfSoundBuffer* soundBuffer)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfUint32 sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer)
|
||||
sfTime sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer)
|
||||
{
|
||||
CSFML_CALL_RETURN(soundBuffer, GetDuration(), 0)
|
||||
CSFML_CHECK_RETURN(soundBuffer, sfTimeZero)
|
||||
|
||||
sf::Time duration = soundBuffer->This.GetDuration();
|
||||
return sfMicroseconds(duration.AsMicroseconds());
|
||||
}
|
||||
@@ -135,9 +135,9 @@ void sfSoundStream_SetAttenuation(sfSoundStream* soundStream, float attenuation)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfUint32 timeOffset)
|
||||
void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfTime timeOffset)
|
||||
{
|
||||
CSFML_CALL(soundStream, SetPlayingOffset(timeOffset));
|
||||
CSFML_CALL(soundStream, SetPlayingOffset(sf::Microseconds(timeOffset.Microseconds)));
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,10 @@ sfBool sfSoundStream_GetLoop(const sfSoundStream* soundStream)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfUint32 sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream)
|
||||
sfTime sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream)
|
||||
{
|
||||
CSFML_CALL_RETURN(soundStream, GetPlayingOffset(), 0);
|
||||
CSFML_CHECK_RETURN(soundStream, sfTimeZero);
|
||||
|
||||
sf::Time offset = soundStream->This.GetPlayingOffset();
|
||||
return sfMicroseconds(offset.AsMicroseconds());
|
||||
}
|
||||
@@ -64,10 +64,10 @@ private :
|
||||
return ok;
|
||||
}
|
||||
|
||||
virtual void OnSeek(sfUint32 timeOffset)
|
||||
virtual void OnSeek(sf::Time timeOffset)
|
||||
{
|
||||
if (mySeekCallback)
|
||||
mySeekCallback(timeOffset, myUserData);
|
||||
mySeekCallback(sfMicroseconds(timeOffset.AsMicroseconds()), myUserData);
|
||||
}
|
||||
|
||||
sfSoundStreamGetDataCallback myGetDataCallback;
|
||||
|
||||
@@ -248,25 +248,6 @@ sfBool sfTexture_IsRepeated(const sfTexture* texture)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfFloatRect sfTexture_GetTexCoords(const sfTexture* texture, sfIntRect rectangle)
|
||||
{
|
||||
sfFloatRect result = {0, 0, 0, 0};
|
||||
CSFML_CHECK_RETURN(texture, result);
|
||||
CSFML_CHECK_RETURN(texture->This, result);
|
||||
|
||||
sf::IntRect rect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height);
|
||||
sf::FloatRect sfmlResult = texture->This->GetTexCoords(rect);
|
||||
|
||||
result.Left = sfmlResult.Left;
|
||||
result.Top = sfmlResult.Top;
|
||||
result.Width = sfmlResult.Width;
|
||||
result.Height = sfmlResult.Height;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int sfTexture_GetMaximumSize()
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ sfVertexArray* sfVertexArray_Create(void)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfVertexArray* sfTransform_Copy(sfVertexArray* vertexArray)
|
||||
sfVertexArray* sfVertexArray_Copy(sfVertexArray* vertexArray)
|
||||
{
|
||||
CSFML_CHECK_RETURN(vertexArray, NULL);
|
||||
|
||||
@@ -118,4 +118,6 @@ sfFloatRect sfVertexArray_GetBounds(sfVertexArray* vertexArray)
|
||||
rect.Top = sfmlRect.Top;
|
||||
rect.Width = sfmlRect.Width;
|
||||
rect.Height = sfmlRect.Height;
|
||||
|
||||
return rect;
|
||||
}
|
||||
@@ -169,13 +169,13 @@ void sfFtp_Destroy(sfFtp* ftp)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfFtpResponse* sfFtp_Connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfUint32 timeout)
|
||||
sfFtpResponse* sfFtp_Connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfTime timeout)
|
||||
{
|
||||
CSFML_CHECK_RETURN(ftp, NULL);
|
||||
|
||||
sf::IpAddress SFMLServer(server.Address);
|
||||
|
||||
return new sfFtpResponse(ftp->This.Connect(SFMLServer, port, timeout));
|
||||
return new sfFtpResponse(ftp->This.Connect(SFMLServer, port, sf::Microseconds(timeout.Microseconds)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -153,13 +153,13 @@ void sfHttp_SetHost(sfHttp* http, const char* host, unsigned short port)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, sfUint32 timeout)
|
||||
sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, sfTime timeout)
|
||||
{
|
||||
CSFML_CHECK_RETURN(http, NULL);
|
||||
CSFML_CHECK_RETURN(request, NULL);
|
||||
|
||||
sfHttpResponse* response = new sfHttpResponse;
|
||||
response->This = http->This.SendRequest(request->This, timeout);
|
||||
response->This = http->This.SendRequest(request->This, sf::Microseconds(timeout.Microseconds));
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -93,9 +93,9 @@ sfIpAddress sfIpAddress_GetLocalAddress(void)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfIpAddress sfIpAddress_GetPublicAddress(sfUint32 timeout)
|
||||
sfIpAddress sfIpAddress_GetPublicAddress(sfTime timeout)
|
||||
{
|
||||
return FromSFMLAddress(sf::IpAddress::GetPublicAddress(timeout));
|
||||
return FromSFMLAddress(sf::IpAddress::GetPublicAddress(sf::Microseconds(timeout.Microseconds)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -100,9 +100,9 @@ void sfSocketSelector_Clear(sfSocketSelector* selector)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfBool sfSocketSelector_Wait(sfSocketSelector* selector, sfUint32 timeout)
|
||||
sfBool sfSocketSelector_Wait(sfSocketSelector* selector, sfTime timeout)
|
||||
{
|
||||
CSFML_CALL_RETURN(selector, Wait(timeout), sfFalse);
|
||||
CSFML_CALL_RETURN(selector, Wait(sf::Microseconds(timeout.Microseconds)), sfFalse);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -89,13 +89,13 @@ unsigned short sfTcpSocket_GetRemotePort(const sfTcpSocket* socket)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfUint32 timeout)
|
||||
sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfTime timeout)
|
||||
{
|
||||
sf::IpAddress address(host.Address);
|
||||
|
||||
CSFML_CHECK_RETURN(socket, sfSocketError);
|
||||
|
||||
return static_cast<sfSocketStatus>(socket->This.Connect(address, port, timeout));
|
||||
return static_cast<sfSocketStatus>(socket->This.Connect(address, port, sf::Microseconds(timeout.Microseconds)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ set(SRC
|
||||
${SRCROOT}/Thread.cpp
|
||||
${SRCROOT}/ThreadStruct.h
|
||||
${INCROOT}/Thread.h
|
||||
${SRCROOT}/Time.cpp
|
||||
${INCROOT}/Time.h
|
||||
${INCROOT}/Types.h
|
||||
)
|
||||
|
||||
|
||||
@@ -54,14 +54,20 @@ void sfClock_Destroy(sfClock* clock)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfUint32 sfClock_GetTime(const sfClock* clock)
|
||||
sfTime sfClock_GetElapsedTime(const sfClock* clock)
|
||||
{
|
||||
CSFML_CALL_RETURN(clock, GetElapsedTime(), 0)
|
||||
CSFML_CHECK_RETURN(clock, sfTimeZero);
|
||||
|
||||
sf::Time time = clock->This.GetElapsedTime();
|
||||
return sfMicroseconds(time.AsMicroseconds());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfClock_Reset(sfClock* clock)
|
||||
sfTime sfClock_Restart(sfClock* clock)
|
||||
{
|
||||
CSFML_CALL(clock, Reset())
|
||||
CSFML_CHECK_RETURN(clock, sfTimeZero);
|
||||
|
||||
sf::Time time = clock->This.Restart();
|
||||
return sfMicroseconds(time.AsMicroseconds());
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfSleep(sfUint32 Duration)
|
||||
void sfSleep(sfTime duration)
|
||||
{
|
||||
sf::Sleep(Duration);
|
||||
sf::Sleep(sf::Microseconds(duration.Microseconds));
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/System/Time.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfTime sfTimeZero = {0};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfTime_AsSeconds(sfTime time)
|
||||
{
|
||||
return time.Microseconds / 1000000.f;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfInt32 sfTime_AsMilliseconds(sfTime time)
|
||||
{
|
||||
return static_cast<sfUint32>(time.Microseconds / 1000);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfInt64 sfTime_AsMicroseconds(sfTime time)
|
||||
{
|
||||
return time.Microseconds;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfTime sfSeconds(float amount)
|
||||
{
|
||||
sfTime time;
|
||||
time.Microseconds = static_cast<sfUint64>(amount * 1000000);
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfTime sfMilliseconds(sfInt32 amount)
|
||||
{
|
||||
sfTime time;
|
||||
time.Microseconds = static_cast<sfUint64>(amount) * 1000;
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfTime sfMicroseconds(sfInt64 amount)
|
||||
{
|
||||
sfTime time;
|
||||
time.Microseconds = amount;
|
||||
return time;
|
||||
}
|
||||
Reference in new issue
Block a user