first commit in a series to change property functions into D style
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1454 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
809b09292f
commit
1c72b919e7
5 changed files with 443 additions and 460 deletions
|
@ -1,28 +1,28 @@
|
|||
/*
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module dsfml.audio.sound;
|
||||
|
||||
|
@ -34,79 +34,81 @@ import dsfml.system.exception;
|
|||
import dsfml.system.vector3;
|
||||
|
||||
/**
|
||||
* Sound defines the properties of the sound such as position,
|
||||
* volume, pitch, etc.
|
||||
*/
|
||||
* Sound defines the properties of the sound such as position,
|
||||
* volume, pitch, etc.
|
||||
*/
|
||||
class Sound : SoundSource!("sfSound")
|
||||
{
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
* Default constructor
|
||||
*/
|
||||
this()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the sound from its parameters
|
||||
*
|
||||
* Params:
|
||||
* buffer = Sound buffer to play
|
||||
* loop = Loop flag (false by default)
|
||||
* pitch = Value of the pitch (1 by default)
|
||||
* volume = Volume (100 by default)
|
||||
* x = X position (0 by default)
|
||||
* y = Y position (0 by default)
|
||||
* z = Z position (0 by default)
|
||||
*
|
||||
* Throws:
|
||||
* NullParameterException if buffer is null
|
||||
*/
|
||||
this(SoundBuffer buffer, bool loop = false, float pitch = 1.f, float volume = 100.f, float x = 0.f, float y = 0.f, float z = 0.f)
|
||||
* Construct the sound from its parameters
|
||||
*
|
||||
* Params:
|
||||
* soundbuffer = Sound buffer to play
|
||||
* loop = Loop flag (false by default)
|
||||
* pitch = Value of the pitch (1 by default)
|
||||
* volume = Volume (100 by default)
|
||||
* x = X position (0 by default)
|
||||
* y = Y position (0 by default)
|
||||
* z = Z position (0 by default)
|
||||
*
|
||||
* Throws:
|
||||
* NullParameterException if buffer is null
|
||||
*/
|
||||
this(SoundBuffer soundbuffer, bool loop = false, float pitch = 1.f, float volume = 100.f, float x = 0.f, float y = 0.f, float z = 0.f)
|
||||
{
|
||||
if (buffer is null)
|
||||
if (soundbuffer is null)
|
||||
throw new NullParameterException("NullParameterException : SoundBuffer is null.");
|
||||
|
||||
super();
|
||||
setBuffer(buffer);
|
||||
setLoop(loop);
|
||||
setPitch(pitch);
|
||||
setVolume(volume);
|
||||
buffer = soundbuffer;
|
||||
loop = loop;
|
||||
pitch = pitch;
|
||||
volume = volume;
|
||||
setPosition(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Play the sound
|
||||
*/
|
||||
* Play the sound
|
||||
*/
|
||||
void play()
|
||||
{
|
||||
sfSound_Play(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause the sound
|
||||
*/
|
||||
* Pause the sound
|
||||
*/
|
||||
void pause()
|
||||
{
|
||||
sfSound_Pause(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the sound
|
||||
*/
|
||||
* Stop the sound
|
||||
*/
|
||||
void stop()
|
||||
{
|
||||
sfSound_Stop(m_ptr);
|
||||
}
|
||||
|
||||
@property
|
||||
{
|
||||
/**
|
||||
* Set the source buffer
|
||||
*
|
||||
* Params:
|
||||
* buffer = New sound buffer to bind to the sound
|
||||
*/
|
||||
void setBuffer(SoundBuffer buffer)
|
||||
* Set the source buffer
|
||||
*
|
||||
* Params:
|
||||
* buffer = New sound buffer to bind to the sound
|
||||
*/
|
||||
void buffer(SoundBuffer buffer)
|
||||
{
|
||||
if (buffer is null)
|
||||
throw new NullParameterException("NullParameterException : SoundBuffer is null.");
|
||||
|
@ -116,62 +118,63 @@ class Sound : SoundSource!("sfSound")
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the sound loop state.
|
||||
* This parameter is disabled by default
|
||||
*
|
||||
* Params:
|
||||
* loop = True to play in loop, false to play once
|
||||
*/
|
||||
void setLoop(bool loop)
|
||||
* Set the sound loop state.
|
||||
* This parameter is disabled by default
|
||||
*
|
||||
* Params:
|
||||
* loop = True to play in loop, false to play once
|
||||
*/
|
||||
void loop(bool loop)
|
||||
{
|
||||
sfSound_SetLoop(m_ptr, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current playing offset of a sound
|
||||
*
|
||||
* Params:
|
||||
* offset = new playing position, expressed in seconds
|
||||
*/
|
||||
void setPlayingOffset(float offset)
|
||||
* Set the current playing offset of a sound
|
||||
*
|
||||
* Params:
|
||||
* offset = new playing position, expressed in seconds
|
||||
*/
|
||||
void playingOffset(float offset)
|
||||
{
|
||||
sfSound_SetPlayingOffset(m_ptr, offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the source buffer
|
||||
*
|
||||
* Returns:
|
||||
* Sound buffer bound to the sound (can be NULL)
|
||||
*/
|
||||
SoundBuffer getBuffer()
|
||||
* Get the source buffer
|
||||
*
|
||||
* Returns:
|
||||
* Sound buffer bound to the sound (can be NULL)
|
||||
*/
|
||||
SoundBuffer buffer()
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell whether or not the sound is looping
|
||||
*
|
||||
* Returns:
|
||||
* True if the sound is looping, false otherwise
|
||||
*/
|
||||
bool getLoop()
|
||||
* Tell whether or not the sound is looping
|
||||
*
|
||||
* Returns:
|
||||
* True if the sound is looping, false otherwise
|
||||
*/
|
||||
bool loop()
|
||||
{
|
||||
|
||||
return cast(bool)(sfSound_GetLoop(m_ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current playing position of the sound
|
||||
*
|
||||
* Returns:
|
||||
* Current playing position, expressed in seconds
|
||||
*/
|
||||
float getPlayingOffset()
|
||||
* Get the current playing position of the sound
|
||||
*
|
||||
* Returns:
|
||||
* Current playing position, expressed in seconds
|
||||
*/
|
||||
float playingOffset()
|
||||
{
|
||||
return sfSound_GetPlayingOffset(m_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SoundBuffer m_buffer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue