28
28
// Includes.
29
29
// -----------------------------------------------------------------------------
30
30
#include " modules/export_main.h"
31
+ #include " utility/sp_util.h"
31
32
#include " usermessage.h"
33
+ #include " Color.h"
32
34
33
35
// -----------------------------------------------------------------------------
34
36
// Namespaces to use
@@ -41,6 +43,7 @@ using namespace boost::python;
41
43
void export_usermessage_interface ();
42
44
void export_message_functions ();
43
45
void export_dialog_enum ();
46
+ void export_color ();
44
47
45
48
// -----------------------------------------------------------------------------
46
49
// Method overloads
@@ -62,6 +65,7 @@ DECLARE_SP_MODULE(usermessage_c)
62
65
export_usermessage_interface ();
63
66
export_message_functions ();
64
67
export_dialog_enum ();
68
+ export_color ();
65
69
}
66
70
67
71
void export_usermessage_interface ()
@@ -144,8 +148,7 @@ void export_usermessage_interface()
144
148
" Sets a field parameter to the specified value." ,
145
149
args (" field_name" , " field_value" , " index" )
146
150
)
147
-
148
- BOOST_END_CLASS ()
151
+ ;
149
152
}
150
153
151
154
void export_message_functions ()
@@ -159,10 +162,65 @@ void export_message_functions()
159
162
void export_dialog_enum ()
160
163
{
161
164
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
+ ;
168
171
}
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