From 888d4f75853b92db17f0c9f06faf1cd9792a6e38 Mon Sep 17 00:00:00 2001 From: groogy Date: Sat, 27 Nov 2010 22:51:38 +0000 Subject: [PATCH] Forgot to add the isValid method to the SFML::VideoMode class. Fixed now. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1720 4e206d99-4929-0410-ac5d-dfc041789085 --- .../ruby/sfml-window/window/VideoMode.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bindings/ruby/sfml-window/window/VideoMode.cpp b/bindings/ruby/sfml-window/window/VideoMode.cpp index 9fcd05f8..a39a767d 100644 --- a/bindings/ruby/sfml-window/window/VideoMode.cpp +++ b/bindings/ruby/sfml-window/window/VideoMode.cpp @@ -138,6 +138,21 @@ static VALUE VideoMode_SetBitsPerPixel( VALUE self, VALUE aValue ) return INT2FIX( object->BitsPerPixel = NUM2UINT( aValue ) ); } +/* call-seq: + * mode.isValid() -> true or false + * + * Tell whether or not the video mode is valid. + * + * The validity of video modes is only relevant when using fullscreen windows; otherwise any video mode can be used + * with no restriction. + */ +static VALUE VideoMode_IsValid( VALUE self ) +{ + sf::VideoMode *object = NULL; + Data_Get_Struct( self, sf::VideoMode, object ); + return ( object->IsValid() == true ? Qtrue : Qfalse ); +} + /* call-seq: * VideoMode.getDesktopMode -> desktop_mode * @@ -255,6 +270,8 @@ void Init_VideoMode( void ) rb_define_method( globalVideoModeClass, "bitsPerPixel", VideoMode_GetBitsPerPixel, 0 ); rb_define_method( globalVideoModeClass, "bitsPerPixel=", VideoMode_SetBitsPerPixel, 1 ); + rb_define_method( globalVideoModeClass, "isValid", VideoMode_IsValid, 0 ); + // Class aliases rb_define_alias( CLASS_OF( globalVideoModeClass ), "desktopMode", "getDesktopMode" ); rb_define_alias( CLASS_OF( globalVideoModeClass ), "desktop_mode", "getDesktopMode" ); @@ -266,4 +283,7 @@ void Init_VideoMode( void ) rb_define_alias( globalVideoModeClass, "bits_per_pixel=", "bitsPerPixel=" ); rb_define_alias( globalVideoModeClass, "bpp", "bitsPerPixel" ); rb_define_alias( globalVideoModeClass, "bpp=", "bitsPerPixel=" ); + + rb_define_alias( globalVideoModeClass, "is_valid", "isValid" ); + rb_define_alias( globalVideoModeClass, "valid?", "isValid" ); }