I made some errors since I couldn't previously test compile my source. Anyway fixed now. Just gonna check runtime later too.
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1616 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
1279cb208c
commit
e75c42869d
@ -85,40 +85,49 @@ static void Event_Free( sf::Event *anObject )
|
|||||||
delete anObject;
|
delete anObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define AXIS2NUM( x ) INT2NUM( static_cast< int > ( x ) )
|
||||||
|
#define NUM2AXIS( x ) static_cast< sf::Joy::Axis >( NUM2INT( x ) )
|
||||||
|
|
||||||
|
#define KEY2NUM( x ) INT2NUM( static_cast< int > ( x ) )
|
||||||
|
#define NUM2KEY( x ) static_cast< sf::Key::Code >( NUM2INT( x ) )
|
||||||
|
|
||||||
|
#define MOUSE2NUM( x ) INT2NUM( static_cast< int > ( x ) )
|
||||||
|
#define NUM2MOUSE( x ) static_cast< sf::Mouse::Button >( NUM2INT( x ) )
|
||||||
|
|
||||||
#define EVENT_TYPE_ACCESSORS( a, b, conv1, conv2 ) \
|
#define EVENT_TYPE_ACCESSORS( a, b, conv1, conv2 ) \
|
||||||
static VALUE a##Event_Get##b##( VALUE self ) \
|
static VALUE a##Event_Get##b ( VALUE self ) \
|
||||||
{ \
|
{ \
|
||||||
sf::Event::##a##Event * object = NULL; \
|
sf::Event:: a##Event * object = NULL; \
|
||||||
Data_Get_Struct( self, sf::Event::##a##Event, object ); \
|
Data_Get_Struct( self, sf::Event:: a##Event, object ); \
|
||||||
return conv1##( object->##a##.##b ); \
|
return conv1 ( object-> b ); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static VALUE a##Event_Set##b##( VALUE self, VALUE aVal ) \
|
static VALUE a##Event_Set##b ( VALUE self, VALUE aVal ) \
|
||||||
{ \
|
{ \
|
||||||
sf::Event::##a##Event * object = NULL; \
|
sf::Event:: a##Event * object = NULL; \
|
||||||
Data_Get_Struct( self, sf::Event::##a##Event, object ); \
|
Data_Get_Struct( self, sf::Event:: a##Event, object ); \
|
||||||
return conv1##( object->##a##.##b = conv2##( aVal ) ); \
|
return conv1 ( object-> b = conv2 ( aVal ) ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EVENT_TYÅE_BOOL_ACCESSORS( a, b ) \
|
#define EVENT_TYPE_BOOL_ACCESSORS( a, b ) \
|
||||||
static VALUE a##Event_Get##b##( VALUE self ) \
|
static VALUE a##Event_Get##b ( VALUE self ) \
|
||||||
{ \
|
{ \
|
||||||
sf::Event::##a##Event * object = NULL; \
|
sf::Event:: a##Event * object = NULL; \
|
||||||
Data_Get_Struct( self, sf::Event::##a##Event, object ); \
|
Data_Get_Struct( self, sf::Event:: a##Event, object ); \
|
||||||
if( object->##a##.##b == true ) \
|
if( object-> b == true ) \
|
||||||
return Qtrue; \
|
return Qtrue; \
|
||||||
else \
|
else \
|
||||||
return Qfalse; \
|
return Qfalse; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static VALUE a##Event_Set##b##( VALUE self, VALUE aVal ) \
|
static VALUE a##Event_Set##b ( VALUE self, VALUE aVal ) \
|
||||||
{ \
|
{ \
|
||||||
sf::Event::##a##Event * object = NULL; \
|
sf::Event:: a##Event * object = NULL; \
|
||||||
Data_Get_Struct( self, sf::Event::##a##Event, object ); \
|
Data_Get_Struct( self, sf::Event:: a##Event, object ); \
|
||||||
if( aVal == Qtrue ) \
|
if( aVal == Qtrue ) \
|
||||||
object->##a##.##b = true; \
|
object-> b = true; \
|
||||||
else \
|
else \
|
||||||
object->##a##.##b = false; \
|
object-> b = false; \
|
||||||
return aVal; \
|
return aVal; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,15 +149,15 @@ EVENT_TYPE_ACCESSORS( JoyButton, JoystickId, INT2NUM, NUM2UINT );
|
|||||||
EVENT_TYPE_ACCESSORS( JoyButton, Button, INT2NUM, NUM2UINT );
|
EVENT_TYPE_ACCESSORS( JoyButton, Button, INT2NUM, NUM2UINT );
|
||||||
|
|
||||||
EVENT_TYPE_ACCESSORS( JoyMove, JoystickId, INT2NUM, NUM2UINT );
|
EVENT_TYPE_ACCESSORS( JoyMove, JoystickId, INT2NUM, NUM2UINT );
|
||||||
EVENT_TYPE_ACCESSORS( JoyMove, Axis, INT2NUM, NUM2INT );
|
EVENT_TYPE_ACCESSORS( JoyMove, Axis, AXIS2NUM, NUM2AXIS );
|
||||||
EVENT_TYPE_ACCESSORS( JoyMove, Position, rb_float_new, NUM2DBL );
|
EVENT_TYPE_ACCESSORS( JoyMove, Position, rb_float_new, NUM2DBL );
|
||||||
|
|
||||||
EVENT_TYPE_ACCESSORS( Key, Code, INT2NUM, NUM2INT );
|
EVENT_TYPE_ACCESSORS( Key, Code, KEY2NUM, NUM2KEY );
|
||||||
EVENT_TYPE_BOOL_ACCESSORS( Key, Alt );
|
EVENT_TYPE_BOOL_ACCESSORS( Key, Alt );
|
||||||
EVENT_TYPE_BOOL_ACCESSORS( Key, Control );
|
EVENT_TYPE_BOOL_ACCESSORS( Key, Control );
|
||||||
EVENT_TYPE_BOOL_ACCESSORS( Key, Shift );
|
EVENT_TYPE_BOOL_ACCESSORS( Key, Shift );
|
||||||
|
|
||||||
EVENT_TYPE_ACCESSORS( MouseButton, Button, INT2NUM, NUM2INT );
|
EVENT_TYPE_ACCESSORS( MouseButton, Button, MOUSE2NUM, NUM2MOUSE );
|
||||||
EVENT_TYPE_ACCESSORS( MouseButton, X, INT2NUM, NUM2INT );
|
EVENT_TYPE_ACCESSORS( MouseButton, X, INT2NUM, NUM2INT );
|
||||||
EVENT_TYPE_ACCESSORS( MouseButton, Y, INT2NUM, NUM2INT );
|
EVENT_TYPE_ACCESSORS( MouseButton, Y, INT2NUM, NUM2INT );
|
||||||
|
|
||||||
@ -171,33 +180,33 @@ static VALUE Event_Initialize( VALUE self )
|
|||||||
|
|
||||||
bool noSpecialType = false;
|
bool noSpecialType = false;
|
||||||
VALUE eventType;
|
VALUE eventType;
|
||||||
switch( self->Type )
|
switch( object->Type )
|
||||||
{
|
{
|
||||||
case JoyButtonPressed:
|
case sf::Event::JoyButtonPressed:
|
||||||
case JoyButtonReleased:
|
case sf::Event::JoyButtonReleased:
|
||||||
eventType = Data_Wrap_Struct( globalJoyButtonEventClass, 0, 0, &object->JoyButton );
|
eventType = Data_Wrap_Struct( globalJoyButtonEventClass, 0, 0, &object->JoyButton );
|
||||||
break;
|
break;
|
||||||
case JoyMoved:
|
case sf::Event::JoyMoved:
|
||||||
eventType = Data_Wrap_Struct( globalJoyMoveEventClass, 0, 0, &object->JoyMove );
|
eventType = Data_Wrap_Struct( globalJoyMoveEventClass, 0, 0, &object->JoyMove );
|
||||||
break;
|
break;
|
||||||
case KeyPressed:
|
case sf::Event::KeyPressed:
|
||||||
case KeyReleased:
|
case sf::Event::KeyReleased:
|
||||||
eventType = Data_Wrap_Struct( globalKeyEventClass, 0, 0, &object->Key );
|
eventType = Data_Wrap_Struct( globalKeyEventClass, 0, 0, &object->Key );
|
||||||
break;
|
break;
|
||||||
case MouseButtonPressed:
|
case sf::Event::MouseButtonPressed:
|
||||||
case MouseButtonReleased:
|
case sf::Event::MouseButtonReleased:
|
||||||
eventType = Data_Wrap_Struct( globalMouseButtonEventClass, 0, 0, &object->MouseButton );
|
eventType = Data_Wrap_Struct( globalMouseButtonEventClass, 0, 0, &object->MouseButton );
|
||||||
break;
|
break;
|
||||||
case MouseMoved:
|
case sf::Event::MouseMoved:
|
||||||
eventType = Data_Wrap_Struct( globalMouseMoveEventClass, 0, 0, &object->MouseMove );
|
eventType = Data_Wrap_Struct( globalMouseMoveEventClass, 0, 0, &object->MouseMove );
|
||||||
break;
|
break;
|
||||||
case MouseWheelMoved:
|
case sf::Event::MouseWheelMoved:
|
||||||
eventType = Data_Wrap_Struct( globalMouseWheelEventClass, 0, 0, &object->MouseWheel );
|
eventType = Data_Wrap_Struct( globalMouseWheelEventClass, 0, 0, &object->MouseWheel );
|
||||||
break;
|
break;
|
||||||
case Resized:
|
case sf::Event::Resized:
|
||||||
eventType = Data_Wrap_Struct( globalSizeEventClass, 0, 0, &object->Size );
|
eventType = Data_Wrap_Struct( globalSizeEventClass, 0, 0, &object->Size );
|
||||||
break;
|
break;
|
||||||
case TextEntered:
|
case sf::Event::TextEntered:
|
||||||
eventType = Data_Wrap_Struct( globalTextEventClass, 0, 0, &object->Text );
|
eventType = Data_Wrap_Struct( globalTextEventClass, 0, 0, &object->Text );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -307,6 +316,6 @@ void Init_Event( void )
|
|||||||
rb_define_method( globalSizeEventClass, "height=", FUNCPTR( SizeEvent_SetWidth ), 1 );
|
rb_define_method( globalSizeEventClass, "height=", FUNCPTR( SizeEvent_SetWidth ), 1 );
|
||||||
|
|
||||||
// Text methods
|
// Text methods
|
||||||
rb_define_method( globalTextEventClass, "unicode", FUNCPTR( SizeEvent_GetUnicode ), 0 );
|
rb_define_method( globalTextEventClass, "unicode", FUNCPTR( TextEvent_GetUnicode ), 0 );
|
||||||
rb_define_method( globalTextEventClass, "unicode=", FUNCPTR( SizeEvent_SetUnicode ), 1 )
|
rb_define_method( globalTextEventClass, "unicode=", FUNCPTR( TextEvent_SetUnicode ), 1 );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user