2828// Includes.
2929// -----------------------------------------------------------------------------
3030#include " modules/export_main.h"
31+ #include " utility/sp_util.h"
3132#include " usermessage.h"
33+ #include " Color.h"
3234
3335// -----------------------------------------------------------------------------
3436// Namespaces to use
@@ -41,6 +43,7 @@ using namespace boost::python;
4143void export_usermessage_interface ();
4244void export_message_functions ();
4345void export_dialog_enum ();
46+ void export_color ();
4447
4548// -----------------------------------------------------------------------------
4649// Method overloads
@@ -62,6 +65,7 @@ DECLARE_SP_MODULE(usermessage_c)
6265 export_usermessage_interface ();
6366 export_message_functions ();
6467 export_dialog_enum ();
68+ export_color ();
6569}
6670
6771void export_usermessage_interface ()
@@ -144,8 +148,7 @@ void export_usermessage_interface()
144148 " Sets a field parameter to the specified value." ,
145149 args (" field_name" , " field_value" , " index" )
146150 )
147-
148- BOOST_END_CLASS ()
151+ ;
149152}
150153
151154void export_message_functions ()
@@ -159,10 +162,65 @@ void export_message_functions()
159162void export_dialog_enum ()
160163{
161164 enum_<DIALOG_TYPE>(" DialogType" )
162- ENUM_VALUE (" MSG" , DIALOG_MSG)
163- ENUM_VALUE (" MENU" , DIALOG_MENU)
164- ENUM_VALUE (" TEXT" , DIALOG_TEXT)
165- ENUM_VALUE (" ENTRY" , DIALOG_ENTRY)
166- ENUM_VALUE (" ASKCONNECT" , DIALOG_ASKCONNECT)
167- BOOST_END_CLASS ()
165+ . value (" MSG" , DIALOG_MSG)
166+ . value (" MENU" , DIALOG_MENU)
167+ . value (" TEXT" , DIALOG_TEXT)
168+ . value (" ENTRY" , DIALOG_ENTRY)
169+ . value (" ASKCONNECT" , DIALOG_ASKCONNECT)
170+ ;
168171}
172+
173+ // ---------------------------------------------------------------------------------
174+ // Exposes the Color class
175+ // ---------------------------------------------------------------------------------
176+ class ColorExt
177+ {
178+ public:
179+ static tuple GetColor (Color* pColor)
180+ {
181+ list color;
182+ int r, g, b, a;
183+ pColor->GetColor (r, g, b, a);
184+ color.append (r);
185+ color.append (g);
186+ color.append (b);
187+ color.append (a);
188+ return tuple (color);
189+ }
190+ };
191+
192+ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS (set_color_overload, SetColor, 3 , 4 );
193+
194+ void export_color ()
195+ {
196+ class_<Color>(" Color" )
197+ .def (init<int , int , int >())
198+ .def (init<int , int , int , int >())
199+
200+ .def (" set_color" ,
201+ &Color::SetColor,
202+ set_color_overload (
203+ " Sets the color in a RGB(A) format (0-255)." ,
204+ args (" r" , " g" , " b" , " a" )
205+ )
206+ )
207+
208+ .def (" get_color" ,
209+ &ColorExt::GetColor,
210+ " Returns the color as a tuple containing the RGBA values."
211+ )
212+
213+ .def (" __getitem__" ,
214+ &GetItemIndexer<Color, unsigned char >,
215+ " Returns the color at the given index (0-3)."
216+ )
217+
218+ .def (" __setitem__" ,
219+ &SetItemIndexer<Color, unsigned char >,
220+ " Sets the color at the given index (0-3)."
221+ )
222+
223+ .def (self == self)
224+ .def (self != self)
225+ ;
226+ }
0 commit comments