mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Changed resource classes initialize method to call often used methods if arguments are provided.
Check for details: http://tasks.groogy.se/index.php?do=details&task_id=1&project=2 git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1745 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
44e811ec64
commit
aa39447c26
@ -34,16 +34,6 @@ static VALUE Music_Free( sf::Music *anObject )
|
||||
delete anObject;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* Music.new() -> music
|
||||
*
|
||||
* Creates a new music instance.
|
||||
*/
|
||||
static VALUE Music_Initialize( int argc, VALUE *args, VALUE self )
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* music.openFromFile() -> true or false
|
||||
*
|
||||
@ -67,6 +57,20 @@ static VALUE Music_OpenFromFile( VALUE self, VALUE aFilename )
|
||||
}
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* Music.new() -> music
|
||||
*
|
||||
* Creates a new music instance.
|
||||
*/
|
||||
static VALUE Music_Initialize( int argc, VALUE *args, VALUE self )
|
||||
{
|
||||
if( argc > 0 )
|
||||
{
|
||||
rb_funcall2( self, rb_intern( "openFromFile" ), argc, args );
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* music.getDuration() -> float
|
||||
*
|
||||
@ -130,7 +134,7 @@ void Init_Music( void )
|
||||
rb_define_singleton_method( globalMusicClass, "new", Music_New, -1 );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalMusicClass, "initialize", Music_Initialize, 0 );
|
||||
rb_define_method( globalMusicClass, "initialize", Music_Initialize, -1 );
|
||||
rb_define_method( globalMusicClass, "openFromFile", Music_OpenFromFile, 1 );
|
||||
rb_define_method( globalMusicClass, "getDuration", Music_GetDuration, 0 );
|
||||
|
||||
|
@ -193,6 +193,19 @@ static VALUE SoundBuffer_GetDuration( VALUE self )
|
||||
return rb_float_new( object->GetDuration() );
|
||||
}
|
||||
|
||||
static VALUE SoundBuffer_Initialize( int argc, VALUE *args, VALUE self )
|
||||
{
|
||||
if( argc > 1 )
|
||||
{
|
||||
rb_funcall2( self, rb_intern( "loadFromSampels" ), argc, args );
|
||||
}
|
||||
else if( argc > 0 )
|
||||
{
|
||||
rb_funcall2( self, rb_intern( "loadFromFile" ), argc, args );
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static VALUE SoundBuffer_InitializeCopy( VALUE self, VALUE aSource )
|
||||
{
|
||||
sf::SoundBuffer *object = NULL;
|
||||
@ -273,6 +286,7 @@ void Init_SoundBuffer( void )
|
||||
rb_define_singleton_method( globalSoundBufferClass, "new", SoundBuffer_New, -1 );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalSoundBufferClass, "initialize", SoundBuffer_Initialize, -1 );
|
||||
rb_define_method( globalSoundBufferClass, "initialize_copy", SoundBuffer_InitializeCopy, 1 );
|
||||
rb_define_method( globalSoundBufferClass, "loadFromFile", SoundBuffer_LoadFromFile, 1 );
|
||||
rb_define_method( globalSoundBufferClass, "loadFromSamples", SoundBuffer_LoadFromSamples, 4 );
|
||||
|
@ -130,6 +130,15 @@ static VALUE Font_GetImage( VALUE self, VALUE aCharacterSize )
|
||||
return rbImage;
|
||||
}
|
||||
|
||||
static VALUE Font_Initialize( int argc, VALUE *args, VALUE self )
|
||||
{
|
||||
if( argc > 0 )
|
||||
{
|
||||
rb_funcall2( self, rb_intern( "loadFromFile" ), argc, args );
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static VALUE Font_InitializeCopy( VALUE self, VALUE aSource )
|
||||
{
|
||||
sf::Font *object = NULL;
|
||||
@ -228,6 +237,7 @@ void Init_Font( void )
|
||||
rb_define_singleton_method( globalFontClass, "getDefaultFont", Font_GetDefaultFont, 0 );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalFontClass, "initialize", Font_Initialize, -1 );
|
||||
rb_define_method( globalFontClass, "initialize_copy", Font_InitializeCopy, 1 );
|
||||
rb_define_method( globalFontClass, "loadFromFile", Font_LoadFromFile, 1 );
|
||||
rb_define_method( globalFontClass, "getGlyph", Font_GetGlyph, 3 );
|
||||
|
@ -517,6 +517,19 @@ static VALUE Image_GetTexCoords( VALUE self, VALUE aRectangle )
|
||||
rb_float_new( result.Width ), rb_float_new( result.Height ) );
|
||||
}
|
||||
|
||||
static VALUE Image_Initialize( int argc, VALUE *args, VALUE self )
|
||||
{
|
||||
if( argc > 1 )
|
||||
{
|
||||
rb_funcall2( self, rb_intern( "loadFromPixels" ), argc, args );
|
||||
}
|
||||
else if( argc > 0 )
|
||||
{
|
||||
rb_funcall2( self, rb_intern( "loadFromFile" ), argc, args );
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static VALUE Image_InitializeCopy( VALUE self, VALUE aSource )
|
||||
{
|
||||
sf::Image *object = NULL;
|
||||
@ -605,6 +618,7 @@ void Init_Image( void )
|
||||
rb_define_singleton_method( globalImageClass, "getMaximumSize", Image_GetMaximumSize, 0 );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalImageClass, "initialize", Image_Initialize, 1 );
|
||||
rb_define_method( globalImageClass, "initialize_copy", Image_InitializeCopy, 1 );
|
||||
rb_define_method( globalImageClass, "loadFromFile", Image_LoadFromFile, 1 );
|
||||
rb_define_method( globalImageClass, "loadFromPixels", Image_LoadFromPixels, 3 );
|
||||
|
@ -215,6 +215,16 @@ static VALUE Shader_Unbind( VALUE self )
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
||||
static VALUE Shader_Initialize( int argc, VALUE *args, VALUE self )
|
||||
{
|
||||
if( argc > 0 )
|
||||
{
|
||||
rb_funcall2( self, rb_intern( "loadFromFile" ), argc, args );
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static VALUE Shader_InitializeCopy( VALUE self, VALUE aSource )
|
||||
{
|
||||
sf::Shader *object = NULL;
|
||||
@ -325,6 +335,7 @@ void Init_Shader( void )
|
||||
rb_define_const( globalShaderClass, "CurrentTexture", CreateCurrentTextureWrapper() );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalShaderClass, "initialize", Shader_Initialize, -1 );
|
||||
rb_define_method( globalShaderClass, "initialize_copy", Shader_InitializeCopy, 1 );
|
||||
rb_define_method( globalShaderClass, "loadFromFile", Shader_LoadFromFile, 1 );
|
||||
rb_define_method( globalShaderClass, "loadFromMemory", Shader_LoadFromMemory, 1 );
|
||||
|
Loading…
Reference in New Issue
Block a user