git.fiddlerwoaroof.com
Browse code

windoze

Ed L authored on 24/07/2012 00:20:31
Showing 5 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,1177 @@
1
+
2
+from ctypes import *
3
+from libtcodpy import Color
4
+
5
+# HACK for return types
6
+c_void = c_int
7
+
8
+def setup_protos(lib):
9
+    lib.TCOD_line_step.restype = c_bool
10
+    lib.TCOD_line_step.argtypes=[POINTER(c_int), POINTER(c_int)]
11
+
12
+    #_lib.TCOD_line.restype=c_bool 
13
+    #_lib.TCOD_line.argtypes=[c_int, c_int, c_int, c_int, TCOD_line_listener_t]
14
+
15
+    lib.TCOD_line_init_mt.restype=c_void 
16
+    lib.TCOD_line_init_mt.argtypes=[c_int, c_int, c_int, c_int, c_void_p]
17
+
18
+    lib.TCOD_line_step_mt.restype=c_bool 
19
+    lib.TCOD_line_step_mt.argtypes=[POINTER(c_int), POINTER(c_int), c_void_p]
20
+
21
+    #_lib.TCOD_line_mt.restype=c_bool 
22
+    #_lib.TCOD_line_mt.argtypes=[c_int, c_int, c_int, c_int, TCOD_line_listener_t , c_void_p]
23
+
24
+    lib.TCOD_bsp_new.restype=c_void_p
25
+    lib.TCOD_bsp_new.argtypes=[]
26
+
27
+    lib.TCOD_bsp_new_with_size.restype=c_void_p
28
+    lib.TCOD_bsp_new_with_size.argtypes=[c_int,c_int,c_int, c_int]
29
+
30
+    lib.TCOD_bsp_delete.restype=c_void 
31
+    lib.TCOD_bsp_delete.argtypes=[c_void_p]
32
+
33
+    lib.TCOD_bsp_left.restype=c_void_p
34
+    lib.TCOD_bsp_left.argtypes=[c_void_p]
35
+
36
+    lib.TCOD_bsp_right.restype=c_void_p
37
+    lib.TCOD_bsp_right.argtypes=[c_void_p]
38
+
39
+    lib.TCOD_bsp_father.restype=c_void_p
40
+    lib.TCOD_bsp_father.argtypes=[c_void_p]
41
+
42
+    lib.TCOD_bsp_is_leaf.restype=c_bool 
43
+    lib.TCOD_bsp_is_leaf.argtypes=[c_void_p]
44
+
45
+    #_lib.c_void_pre_order.restype=c_bool 
46
+    #_lib.c_void_pre_order.argtypes=[c_void_p, TCOD_bsp_callback_t , void_p]
47
+
48
+    #_lib.TCOD_bsp_traverse_in_order.restype=c_bool 
49
+    #_lib.TCOD_bsp_traverse_in_order.argtypes=[c_void_p, TCOD_bsp_callback_t , void_p]
50
+
51
+    #_lib.c_void_post_order.restype=c_bool 
52
+    #_lib.c_void_post_order.argtypes=[c_void_p, TCOD_bsp_callback_t , void_p]
53
+
54
+    #_lib.TCOD_bsp_traverse_level_order.restype=c_bool 
55
+    #_lib.TCOD_bsp_traverse_level_order.argtypes=[c_void_p, TCOD_bsp_callback_t , void_p]
56
+
57
+    #_lib.TCOD_bsp_traverse_inverted_level_order.restype=c_bool 
58
+    #_lib.TCOD_bsp_traverse_inverted_level_order.argtypes=[c_void_p, TCOD_bsp_callback_t , void_p]
59
+
60
+    lib.TCOD_bsp_contains.restype=c_bool 
61
+    lib.TCOD_bsp_contains.argtypes=[c_void_p, c_int, c_int]
62
+
63
+    lib.TCOD_bsp_find_node.restype=c_void_p
64
+    lib.TCOD_bsp_find_node.argtypes=[c_void_p, c_int, c_int]
65
+
66
+    lib.TCOD_bsp_resize.restype=c_void 
67
+    lib.TCOD_bsp_resize.argtypes=[c_void_p, c_int,c_int, c_int, c_int]
68
+
69
+    lib.TCOD_bsp_split_once.restype=c_void 
70
+    lib.TCOD_bsp_split_once.argtypes=[c_void_p, c_bool , c_int]
71
+
72
+    lib.TCOD_bsp_split_recursive.restype=c_void 
73
+    lib.TCOD_bsp_split_recursive.argtypes=[c_void_p, c_void_p , c_int, ]
74
+
75
+    lib.TCOD_bsp_remove_sons.restype=c_void
76
+    lib.TCOD_bsp_remove_sons.argtypes=[c_void_p]
77
+
78
+    lib.TCOD_color_RGB.restype=Color
79
+    lib.TCOD_color_RGB.argtypes=[c_byte , c_byte , c_byte ]
80
+
81
+    lib.TCOD_color_HSV.restype=Color
82
+    lib.TCOD_color_HSV.argtypes=[c_float , c_float , c_float ]
83
+
84
+    lib.TCOD_color_equals .restype=c_bool
85
+    lib.TCOD_color_equals .argtypes=[Color, Color]
86
+
87
+    lib.TCOD_color_add .restype=Color
88
+    lib.TCOD_color_add .argtypes=[Color, Color]
89
+
90
+    lib.TCOD_color_subtract .restype=Color
91
+    lib.TCOD_color_subtract .argtypes=[Color, Color]
92
+
93
+    lib.TCOD_color_multiply .restype=Color
94
+    lib.TCOD_color_multiply .argtypes=[Color , Color ]
95
+
96
+    lib.TCOD_color_multiply_scalar .restype=Color
97
+    lib.TCOD_color_multiply_scalar .argtypes=[Color , c_float ]
98
+
99
+#    lib.TCOD_color_lerp .restype=c_int
100
+#    lib.TCOD_color_lerp .argtypes=[c_int , c_int , c_float ]
101
+
102
+    lib.TCOD_color_set_HSV .restype=c_void
103
+    lib.TCOD_color_set_HSV .argtypes=[POINTER(Color),c_float , c_float , c_float ]
104
+
105
+    lib.TCOD_color_get_HSV .restype=c_void
106
+    lib.TCOD_color_get_HSV .argtypes=[Color ,POINTER(c_float) , POINTER(c_float) , POINTER(c_float) ]
107
+
108
+    lib.TCOD_color_get_hue .restype=c_float
109
+    lib.TCOD_color_get_hue .argtypes=[Color ]
110
+
111
+    lib.TCOD_color_set_hue .restype=c_void
112
+    lib.TCOD_color_set_hue .argtypes=[POINTER(Color), c_float ]
113
+
114
+    lib.TCOD_color_get_saturation .restype=c_float
115
+    lib.TCOD_color_get_saturation .argtypes=[Color ]
116
+
117
+    lib.TCOD_color_set_saturation .restype=c_void
118
+    lib.TCOD_color_set_saturation .argtypes=[POINTER(Color), c_float ]
119
+
120
+    lib.TCOD_color_get_value .restype=c_float
121
+    lib.TCOD_color_get_value .argtypes=[Color ]
122
+
123
+    lib.TCOD_color_set_value .restype=c_void
124
+    lib.TCOD_color_set_value .argtypes=[POINTER(Color), c_float ]
125
+
126
+    lib.TCOD_color_shift_hue .restype=c_void
127
+    lib.TCOD_color_shift_hue .argtypes=[POINTER(Color), c_float ]
128
+
129
+    lib.TCOD_color_scale_HSV .restype=c_void
130
+    lib.TCOD_color_scale_HSV .argtypes=[POINTER(Color), c_float , c_float ]
131
+
132
+    lib.TCOD_color_gen_map.restype=c_void
133
+    lib.TCOD_color_gen_map.argtypes=[POINTER(Color), c_int, POINTER(Color), POINTER(c_int)]
134
+
135
+    lib.TCOD_console_init_root.restype=c_void
136
+    lib.TCOD_console_init_root.argtypes=[c_int, c_int, c_char_p , c_bool , c_uint ]
137
+
138
+    lib.TCOD_console_set_window_title.restype=c_void
139
+    lib.TCOD_console_set_window_title.argtypes=[c_char_p]
140
+
141
+    lib.TCOD_console_set_fullscreen.restype=c_void
142
+    lib.TCOD_console_set_fullscreen.argtypes=[c_bool ]
143
+
144
+    lib.TCOD_console_is_fullscreen.restype=c_bool
145
+    lib.TCOD_console_is_fullscreen.argtypes=[]
146
+
147
+    lib.TCOD_console_is_window_closed.restype=c_bool
148
+    lib.TCOD_console_is_window_closed.argtypes=[]
149
+
150
+    lib.TCOD_console_set_custom_font.restype=c_void
151
+    lib.TCOD_console_set_custom_font.argtypes=[c_char_p, c_int,c_int, c_int]
152
+
153
+    lib.TCOD_console_map_ascii_code_to_font.restype=c_void
154
+    lib.TCOD_console_map_ascii_code_to_font.argtypes=[c_int, c_int, c_int]
155
+
156
+    lib.TCOD_console_map_ascii_codes_to_font.restype=c_void
157
+    lib.TCOD_console_map_ascii_codes_to_font.argtypes=[c_int, c_int, c_int, c_int]
158
+
159
+    lib.TCOD_console_map_string_to_font.restype=c_void
160
+    lib.TCOD_console_map_string_to_font.argtypes=[c_char_p, c_int, c_int]
161
+
162
+    lib.TCOD_console_set_dirty.restype=c_void
163
+    lib.TCOD_console_set_dirty.argtypes=[c_int, c_int, c_int, c_int]
164
+
165
+    lib.TCOD_console_set_default_background.restype=c_void
166
+    lib.TCOD_console_set_default_background.argtypes=[c_void_p ,Color ]
167
+
168
+    lib.TCOD_console_set_default_foreground.restype=c_void
169
+    lib.TCOD_console_set_default_foreground.argtypes=[c_void_p ,Color ]
170
+
171
+    lib.TCOD_console_clear.restype=c_void
172
+    lib.TCOD_console_clear.argtypes=[c_void_p ]
173
+
174
+    lib.TCOD_console_set_char_background.restype=c_void
175
+    lib.TCOD_console_set_char_background.argtypes=[c_void_p ,c_int, c_int, Color , c_int ]
176
+
177
+    lib.TCOD_console_set_char_foreground.restype=c_void
178
+    lib.TCOD_console_set_char_foreground.argtypes=[c_void_p ,c_int, c_int, Color ]
179
+
180
+    lib.TCOD_console_set_char.restype=c_void
181
+    lib.TCOD_console_set_char.argtypes=[c_void_p ,c_int, c_int, c_int]
182
+
183
+    lib.TCOD_console_put_char.restype=c_void
184
+    lib.TCOD_console_put_char.argtypes=[c_void_p ,c_int, c_int, c_int, c_int ]
185
+
186
+    lib.TCOD_console_put_char_ex.restype=c_void
187
+    lib.TCOD_console_put_char_ex.argtypes=[c_void_p ,c_int, c_int, c_int, Color, Color ]
188
+
189
+    lib.TCOD_console_set_background_flag.restype=c_void
190
+    lib.TCOD_console_set_background_flag.argtypes=[c_void_p ,c_int ]
191
+
192
+    lib.TCOD_console_get_background_flag.restype=c_int
193
+    lib.TCOD_console_get_background_flag.argtypes=[c_void_p ]
194
+
195
+    lib.TCOD_console_set_alignment.restype=c_void
196
+    lib.TCOD_console_set_alignment.argtypes=[c_void_p ,c_int ]
197
+
198
+    lib.TCOD_console_get_alignment.restype=c_int
199
+    lib.TCOD_console_get_alignment.argtypes=[c_void_p ]
200
+
201
+#    lib.TCOD_console_print.restype=c_void
202
+#    lib.TCOD_console_print.argtypes=[c_void_p ,c_int, c_int, c_char_p, ...]
203
+
204
+#    lib.TCOD_console_print_ex.restype=c_void
205
+#    lib.TCOD_console_print_ex.argtypes=[c_void_p ,c_int, c_int, c_int , c_int , c_char_p, ...]
206
+
207
+#    lib.TCOD_console_print_rect.restype=c_int
208
+#    lib.TCOD_console_print_rect.argtypes=[c_void_p ,c_int, c_int, c_int, c_int, c_char_p, ...]
209
+
210
+#    lib.TCOD_console_print_rect_ex.restype=c_int
211
+#    lib.TCOD_console_print_rect_ex.argtypes=[c_void_p ,c_int, c_int, c_int, c_int, c_int , c_int , c_char_p, ...]
212
+
213
+#    lib.TCOD_console_get_height_rect.restype=c_int
214
+#    lib.TCOD_console_get_height_rect.argtypes=[c_void_p ,c_int, c_int, c_int, c_int, c_char_p, ...]
215
+
216
+    lib.TCOD_console_rect.restype=c_void
217
+    lib.TCOD_console_rect.argtypes=[c_void_p ,c_int, c_int, c_int, c_int, c_bool , c_int ]
218
+
219
+    lib.TCOD_console_hline.restype=c_void
220
+    lib.TCOD_console_hline.argtypes=[c_void_p ,c_int,c_int, c_int, c_int ]
221
+
222
+    lib.TCOD_console_vline.restype=c_void
223
+    lib.TCOD_console_vline.argtypes=[c_void_p ,c_int,c_int, c_int, c_int ]
224
+
225
+#    lib.TCOD_console_print_frame.restype=c_void
226
+#    lib.TCOD_console_print_frame.argtypes=[c_void_p ,c_int,c_int,c_int,c_int, c_bool , c_int , c_char_p, ...]
227
+
228
+    lib.TCOD_console_map_string_to_font_utf.restype=c_void
229
+    lib.TCOD_console_map_string_to_font_utf.argtypes=[c_char_p, c_int, c_int]
230
+
231
+#    lib.TCOD_console_print_utf.restype=c_void
232
+#    lib.TCOD_console_print_utf.argtypes=[c_void_p ,c_int, c_int, wchar_t_p, ...]
233
+
234
+#    lib.TCOD_console_print_ex_utf.restype=c_void
235
+#    lib.TCOD_console_print_ex_utf.argtypes=[c_void_p ,c_int, c_int, c_int , c_int , wchar_t_p, ...]
236
+
237
+#    lib.TCOD_console_print_rect_utf.restype=c_int
238
+#    lib.TCOD_console_print_rect_utf.argtypes=[c_void_p ,c_int, c_int, c_int, c_int, wchar_t_p, ...]
239
+
240
+#    lib.TCOD_console_print_rect_ex_utf.restype=c_int
241
+#    lib.TCOD_console_print_rect_ex_utf.argtypes=[c_void_p ,c_int, c_int, c_int, c_int, c_int , c_int , wchar_t_p, ...]
242
+
243
+    lib.TCOD_console_get_height_rect_utf.restype=c_int
244
+#    lib.TCOD_console_get_height_rect_utf.argtypes=[c_void_p ,c_int, c_int, c_int, c_int, wchar_t_p, ...]
245
+
246
+    lib.TCOD_console_get_default_background.restype=Color
247
+    lib.TCOD_console_get_default_background.argtypes=[c_void_p ]
248
+
249
+    lib.TCOD_console_get_default_foreground.restype=Color
250
+    lib.TCOD_console_get_default_foreground.argtypes=[c_void_p ]
251
+
252
+    lib.TCOD_console_get_char_background.restype=Color
253
+    lib.TCOD_console_get_char_background.argtypes=[c_void_p ,c_int, c_int]
254
+
255
+    lib.TCOD_console_get_char_foreground.restype=Color
256
+    lib.TCOD_console_get_char_foreground.argtypes=[c_void_p ,c_int, c_int]
257
+
258
+    lib.TCOD_console_get_char.restype=c_int
259
+    lib.TCOD_console_get_char.argtypes=[c_void_p ,c_int, c_int]
260
+
261
+    lib.TCOD_console_set_fade.restype=c_void
262
+    lib.TCOD_console_set_fade.argtypes=[c_byte , Color ]
263
+
264
+    lib.TCOD_console_get_fade.restype=c_byte
265
+    lib.TCOD_console_get_fade.argtypes=[]
266
+
267
+    lib.TCOD_console_get_fading_color.restype=Color
268
+    lib.TCOD_console_get_fading_color.argtypes=[]
269
+
270
+    lib.TCOD_console_flush.restype=c_void
271
+    lib.TCOD_console_flush.argtypes=[]
272
+
273
+    lib.TCOD_console_set_color_control.restype=c_void
274
+    lib.TCOD_console_set_color_control.argtypes=[c_int , Color , Color ]
275
+
276
+#    lib.TCOD_console_check_for_keypress.restype=TCOD_key_t
277
+#    lib.TCOD_console_check_for_keypress.argtypes=[c_int]
278
+
279
+#    lib.TCOD_console_wait_for_keypress.restype=TCOD_key_t
280
+#    lib.TCOD_console_wait_for_keypress.argtypes=[c_bool ]
281
+
282
+    lib.TCOD_console_set_keyboard_repeat.restype=c_void
283
+    lib.TCOD_console_set_keyboard_repeat.argtypes=[c_int, c_int]
284
+
285
+    lib.TCOD_console_disable_keyboard_repeat.restype=c_void
286
+    lib.TCOD_console_disable_keyboard_repeat.argtypes=[]
287
+
288
+    lib.TCOD_console_is_key_pressed.restype=c_bool
289
+    lib.TCOD_console_is_key_pressed.argtypes=[c_int ]
290
+
291
+    lib.TCOD_console_from_file.restype=c_void_p
292
+    lib.TCOD_console_from_file.argtypes=[c_char_p]
293
+
294
+    lib.TCOD_console_load_asc.restype=c_bool
295
+    lib.TCOD_console_load_asc.argtypes=[c_void_p , c_char_p]
296
+
297
+    lib.TCOD_console_load_apf.restype=c_bool
298
+    lib.TCOD_console_load_apf.argtypes=[c_void_p , c_char_p]
299
+
300
+    lib.TCOD_console_save_asc.restype=c_bool
301
+    lib.TCOD_console_save_asc.argtypes=[c_void_p , c_char_p]
302
+
303
+    lib.TCOD_console_save_apf.restype=c_bool
304
+    lib.TCOD_console_save_apf.argtypes=[c_void_p , c_char_p]
305
+
306
+    lib.TCOD_console_new.restype=c_void_p
307
+    lib.TCOD_console_new.argtypes=[c_int, c_int]
308
+
309
+    lib.TCOD_console_get_width.restype=c_int
310
+    lib.TCOD_console_get_width.argtypes=[c_void_p ]
311
+
312
+    lib.TCOD_console_get_height.restype=c_int
313
+    lib.TCOD_console_get_height.argtypes=[c_void_p ]
314
+
315
+    lib.TCOD_console_set_key_color.restype=c_void
316
+    lib.TCOD_console_set_key_color.argtypes=[c_void_p ,Color ]
317
+
318
+    lib.TCOD_console_blit.restype=c_void
319
+    lib.TCOD_console_blit.argtypes=[c_void_p ,c_int, c_int, c_int, c_int, c_void_p , c_int, c_int, c_float, c_float]
320
+
321
+    lib.TCOD_console_delete.restype=c_void
322
+    lib.TCOD_console_delete.argtypes=[c_void_p ]
323
+
324
+    lib.TCOD_console_credits.restype=c_void
325
+    lib.TCOD_console_credits.argtypes=[]
326
+
327
+    lib.TCOD_console_credits_reset.restype=c_void
328
+    lib.TCOD_console_credits_reset.argtypes=[]
329
+
330
+    lib.TCOD_console_credits_render.restype=c_bool
331
+    lib.TCOD_console_credits_render.argtypes=[c_int, c_int, c_bool ]
332
+
333
+    lib.TCOD_map_new.restype=c_void_p
334
+    lib.TCOD_map_new.argtypes=[c_int, c_int]
335
+
336
+    lib.TCOD_map_clear.restype=c_void
337
+    lib.TCOD_map_clear.argtypes=[c_void_p , c_bool , c_bool ]
338
+
339
+    lib.TCOD_map_copy.restype=c_void
340
+    lib.TCOD_map_copy.argtypes=[c_void_p , c_void_p ]
341
+
342
+    lib.TCOD_map_set_properties.restype=c_void
343
+    lib.TCOD_map_set_properties.argtypes=[c_void_p , c_int, c_int, c_bool, c_bool]
344
+
345
+    lib.TCOD_map_delete.restype=c_void
346
+    lib.TCOD_map_delete.argtypes=[c_void_p ]
347
+
348
+    lib.TCOD_map_compute_fov.restype=c_void
349
+    lib.TCOD_map_compute_fov.argtypes=[c_void_p , c_int, c_int, c_int, c_bool, c_int ]
350
+
351
+    lib.TCOD_map_is_in_fov.restype=c_bool
352
+    lib.TCOD_map_is_in_fov.argtypes=[c_void_p , c_int, c_int]
353
+
354
+    lib.TCOD_map_set_in_fov.restype=c_void
355
+    lib.TCOD_map_set_in_fov.argtypes=[c_void_p , c_int, c_int, c_bool ]
356
+
357
+    lib.TCOD_map_is_transparent.restype=c_bool
358
+    lib.TCOD_map_is_transparent.argtypes=[c_void_p , c_int, c_int]
359
+
360
+    lib.TCOD_map_is_walkable.restype=c_bool
361
+    lib.TCOD_map_is_walkable.argtypes=[c_void_p , c_int, c_int]
362
+
363
+    lib.TCOD_map_get_width.restype=c_int
364
+    lib.TCOD_map_get_width.argtypes=[c_void_p ]
365
+
366
+    lib.TCOD_map_get_height.restype=c_int
367
+    lib.TCOD_map_get_height.argtypes=[c_void_p ]
368
+
369
+    lib.TCOD_map_get_nb_cells.restype=c_int
370
+    lib.TCOD_map_get_nb_cells.argtypes=[c_void_p ]
371
+
372
+    lib.TCOD_heightmap_new.restype=c_void_p
373
+    lib.TCOD_heightmap_new.argtypes=[c_int,c_int]
374
+
375
+    lib.TCOD_heightmap_delete.restype=c_void
376
+    lib.TCOD_heightmap_delete.argtypes=[c_void_p]
377
+
378
+    lib.TCOD_heightmap_get_value.restype=c_float
379
+    lib.TCOD_heightmap_get_value.argtypes=[c_void_p, c_int, c_int]
380
+
381
+    lib.TCOD_heightmap_get_interpolated_value.restype=c_float
382
+    lib.TCOD_heightmap_get_interpolated_value.argtypes=[c_void_p, c_float , c_float ]
383
+
384
+    lib.TCOD_heightmap_set_value.restype=c_void
385
+    lib.TCOD_heightmap_set_value.argtypes=[c_void_p, c_int, c_int, c_float ]
386
+
387
+    lib.TCOD_heightmap_get_slope.restype=c_float
388
+    lib.TCOD_heightmap_get_slope.argtypes=[c_void_p, c_int, c_int]
389
+
390
+    lib.TCOD_heightmap_get_normal.restype=c_void
391
+    lib.TCOD_heightmap_get_normal.argtypes=[c_void_p, c_float , c_float , POINTER(c_float), c_float ]
392
+
393
+    lib.TCOD_heightmap_count_cells.restype=c_int
394
+    lib.TCOD_heightmap_count_cells.argtypes=[c_void_p, c_float , c_float ]
395
+
396
+    lib.TCOD_heightmap_has_land_on_border.restype=c_bool
397
+    lib.TCOD_heightmap_has_land_on_border.argtypes=[c_void_p, c_float ]
398
+
399
+    lib.TCOD_heightmap_get_minmax.restype=c_void
400
+    lib.TCOD_heightmap_get_minmax.argtypes=[c_void_p, POINTER(c_float), POINTER(c_float)]
401
+
402
+    lib.TCOD_heightmap_copy.restype=c_void
403
+    lib.TCOD_heightmap_copy.argtypes=[c_void_p,c_void_p]
404
+
405
+    lib.TCOD_heightmap_add.restype=c_void
406
+    lib.TCOD_heightmap_add.argtypes=[c_void_p, c_float ]
407
+
408
+    lib.TCOD_heightmap_scale.restype=c_void
409
+    lib.TCOD_heightmap_scale.argtypes=[c_void_p, c_float ]
410
+
411
+    lib.TCOD_heightmap_clamp.restype=c_void
412
+    lib.TCOD_heightmap_clamp.argtypes=[c_void_p, c_float , c_float ]
413
+
414
+    lib.TCOD_heightmap_normalize.restype=c_void
415
+    lib.TCOD_heightmap_normalize.argtypes=[c_void_p, c_float , c_float ]
416
+
417
+    lib.TCOD_heightmap_clear.restype=c_void
418
+    lib.TCOD_heightmap_clear.argtypes=[c_void_p]
419
+
420
+    lib.TCOD_heightmap_lerp_hm.restype=c_void
421
+    lib.TCOD_heightmap_lerp_hm.argtypes=[c_void_p, c_void_p, c_void_p, c_float ]
422
+
423
+    lib.TCOD_heightmap_add_hm.restype=c_void
424
+    lib.TCOD_heightmap_add_hm.argtypes=[c_void_p, c_void_p, c_void_p]
425
+
426
+    lib.TCOD_heightmap_multiply_hm.restype=c_void
427
+    lib.TCOD_heightmap_multiply_hm.argtypes=[c_void_p, c_void_p, c_void_p]
428
+
429
+    lib.TCOD_heightmap_add_hill.restype=c_void
430
+    lib.TCOD_heightmap_add_hill.argtypes=[c_void_p, c_float , c_float , c_float , c_float ]
431
+
432
+    lib.TCOD_heightmap_dig_hill.restype=c_void
433
+    lib.TCOD_heightmap_dig_hill.argtypes=[c_void_p, c_float , c_float , c_float , c_float ]
434
+
435
+    lib.TCOD_heightmap_dig_bezier.restype=c_void
436
+    lib.TCOD_heightmap_dig_bezier.argtypes=[c_void_p, POINTER(c_int), POINTER(c_int), c_float , c_float , c_float , c_float ]
437
+
438
+    lib.TCOD_heightmap_rain_erosion.restype=c_void
439
+    lib.TCOD_heightmap_rain_erosion.argtypes=[c_void_p, c_int,c_float ,c_float ,c_void_p ]
440
+
441
+
442
+    lib.TCOD_heightmap_kernel_transform.restype=c_void
443
+    lib.TCOD_heightmap_kernel_transform.argtypes=[c_void_p, c_int, POINTER(c_int), POINTER(c_int), POINTER(c_float), c_float ,c_float ]
444
+
445
+    lib.TCOD_heightmap_add_voronoi.restype=c_void
446
+    lib.TCOD_heightmap_add_voronoi.argtypes=[c_void_p, c_int, c_int, POINTER(c_float),c_void_p ]
447
+
448
+
449
+    lib.TCOD_heightmap_add_fbm.restype=c_void
450
+    lib.TCOD_heightmap_add_fbm.argtypes=[c_void_p, c_int ,c_float , c_float , c_float , c_float , c_float , c_float , c_float ]
451
+
452
+    lib.TCOD_heightmap_scale_fbm.restype=c_void
453
+    lib.TCOD_heightmap_scale_fbm.argtypes=[c_void_p, c_int ,c_float , c_float , c_float , c_float , c_float , c_float , c_float ]
454
+
455
+    lib.TCOD_heightmap_islandify.restype=c_void
456
+    lib.TCOD_heightmap_islandify.argtypes=[c_void_p, c_float ,c_void_p ]
457
+
458
+    lib.TCOD_image_new.restype=c_void_p
459
+    lib.TCOD_image_new.argtypes=[c_int, c_int]
460
+
461
+    lib.TCOD_image_from_console.restype=c_void_p
462
+    lib.TCOD_image_from_console.argtypes=[c_void_p ]
463
+
464
+    lib.TCOD_image_refresh_console.restype=c_void
465
+    lib.TCOD_image_refresh_console.argtypes=[c_void_p , c_void_p ]
466
+
467
+    lib.TCOD_image_load.restype=c_void_p
468
+    lib.TCOD_image_load.argtypes=[c_char_p]
469
+
470
+    lib.TCOD_image_clear.restype=c_void
471
+    lib.TCOD_image_clear.argtypes=[c_void_p , Color ]
472
+
473
+    lib.TCOD_image_invert.restype=c_void
474
+    lib.TCOD_image_invert.argtypes=[c_void_p ]
475
+
476
+    lib.TCOD_image_hflip.restype=c_void
477
+    lib.TCOD_image_hflip.argtypes=[c_void_p ]
478
+
479
+    lib.TCOD_image_rotate90.restype=c_void
480
+    lib.TCOD_image_rotate90.argtypes=[c_void_p , c_int]
481
+
482
+    lib.TCOD_image_vflip.restype=c_void
483
+    lib.TCOD_image_vflip.argtypes=[c_void_p ]
484
+
485
+    lib.TCOD_image_scale.restype=c_void
486
+    lib.TCOD_image_scale.argtypes=[c_void_p , c_int, c_int]
487
+
488
+    lib.TCOD_image_save.restype=c_void
489
+    lib.TCOD_image_save.argtypes=[c_void_p , c_char_p]
490
+
491
+    lib.TCOD_image_get_size.restype=c_void
492
+    lib.TCOD_image_get_size.argtypes=[c_void_p , POINTER(c_int),POINTER(c_int)]
493
+
494
+    lib.TCOD_image_get_pixel.restype=Color
495
+    lib.TCOD_image_get_pixel.argtypes=[c_void_p ,c_int, c_int]
496
+
497
+    lib.TCOD_image_get_alpha.restype=c_int
498
+    lib.TCOD_image_get_alpha.argtypes=[c_void_p ,c_int, c_int]
499
+
500
+    lib.TCOD_image_get_mipmap_pixel.restype=c_int
501
+    lib.TCOD_image_get_mipmap_pixel.argtypes=[c_void_p ,c_float,c_float, c_float, c_float]
502
+
503
+    lib.TCOD_image_put_pixel.restype=c_void
504
+    lib.TCOD_image_put_pixel.argtypes=[c_void_p ,c_int, c_int,Color ]
505
+
506
+    lib.TCOD_image_blit.restype=c_void
507
+    lib.TCOD_image_blit.argtypes=[c_void_p , c_void_p , c_float , c_float , ]
508
+
509
+    lib.TCOD_image_blit_rect.restype=c_void
510
+    lib.TCOD_image_blit_rect.argtypes=[c_void_p , c_void_p , c_int, c_int, c_int, c_int, ]
511
+
512
+    lib.TCOD_image_blit_2x.restype=c_void
513
+    lib.TCOD_image_blit_2x.argtypes=[c_void_p , c_void_p , c_int, c_int, c_int, c_int, c_int, c_int]
514
+
515
+    lib.TCOD_image_delete.restype=c_void
516
+    lib.TCOD_image_delete.argtypes=[c_void_p ]
517
+
518
+    lib.TCOD_image_set_key_color.restype=c_void
519
+    lib.TCOD_image_set_key_color.argtypes=[c_void_p , Color]
520
+
521
+    lib.TCOD_image_is_pixel_transparent.restype=c_bool
522
+    lib.TCOD_image_is_pixel_transparent.argtypes=[c_void_p , c_int, c_int]
523
+
524
+    lib.TCOD_lex_new_intern.restype=c_void_p
525
+    lib.TCOD_lex_new_intern.argtypes=[]
526
+
527
+    lib.TCOD_lex_new.restype=c_void_p
528
+    lib.TCOD_lex_new.argtypes=[POINTER(c_char_p), POINTER(c_char_p), c_char_p, ]
529
+
530
+    lib.TCOD_lex_delete.restype=c_void
531
+    lib.TCOD_lex_delete.argtypes=[c_void_p]
532
+
533
+    lib.TCOD_lex_set_data_buffer.restype=c_void
534
+    lib.TCOD_lex_set_data_buffer.argtypes=[c_void_p,c_char_p]
535
+
536
+    lib.TCOD_lex_set_data_file.restype=c_bool
537
+    lib.TCOD_lex_set_data_file.argtypes=[c_void_p,c_char_p]
538
+
539
+    lib.TCOD_lex_parse.restype=c_int
540
+    lib.TCOD_lex_parse.argtypes=[c_void_p]
541
+
542
+    lib.TCOD_lex_parse_until_token_type.restype=c_int
543
+    lib.TCOD_lex_parse_until_token_type.argtypes=[c_void_p,c_int]
544
+
545
+    lib.TCOD_lex_parse_until_token_value.restype=c_int
546
+    lib.TCOD_lex_parse_until_token_value.argtypes=[c_void_p,c_char_p]
547
+
548
+    lib.TCOD_lex_expect_token_type.restype=c_bool
549
+    lib.TCOD_lex_expect_token_type.argtypes=[c_void_p,c_int]
550
+
551
+    lib.TCOD_lex_expect_token_value.restype=c_bool
552
+    lib.TCOD_lex_expect_token_value.argtypes=[c_void_p,c_int,c_char_p]
553
+
554
+    lib.TCOD_lex_savepoint.restype=c_void
555
+    lib.TCOD_lex_savepoint.argtypes=[c_void_p,c_void_p]
556
+
557
+    lib.TCOD_lex_restore.restype=c_void
558
+    lib.TCOD_lex_restore.argtypes=[c_void_p,c_void_p]
559
+
560
+    lib.TCOD_lex_get_last_javadoc.restype=c_char_p
561
+    lib.TCOD_lex_get_last_javadoc.argtypes=[c_void_p]
562
+
563
+    lib.TCOD_lex_get_token_name.restype=c_char_p
564
+    lib.TCOD_lex_get_token_name.argtypes=[c_int]
565
+
566
+    lib.TCOD_lex_get_last_error.restype=c_char_p
567
+    lib.TCOD_lex_get_last_error.argtypes=[]
568
+
569
+    lib.TCOD_lex_hextoint.restype=c_int
570
+    lib.TCOD_lex_hextoint.argtypes=[c_char]
571
+
572
+    lib.TCOD_sys_get_surface.restype=c_void_p
573
+    lib.TCOD_sys_get_surface.argtypes=[c_int, c_int, c_bool ]
574
+
575
+    lib.TCOD_sys_load_image.restype=c_void_p
576
+    lib.TCOD_sys_load_image.argtypes=[c_char_p]
577
+
578
+    lib.TCOD_list_new.restype=c_void_p
579
+    lib.TCOD_list_new.argtypes=[]
580
+
581
+    lib.TCOD_list_allocate.restype=c_void_p
582
+    lib.TCOD_list_allocate.argtypes=[c_int]
583
+
584
+    lib.TCOD_list_duplicate.restype=c_void_p
585
+    lib.TCOD_list_duplicate.argtypes=[c_void_p ]
586
+
587
+    lib.TCOD_list_delete.restype=c_void
588
+    lib.TCOD_list_delete.argtypes=[c_void_p ]
589
+
590
+    lib.TCOD_list_push.restype=c_void
591
+    lib.TCOD_list_push.argtypes=[c_void_p ,c_void_p ]
592
+
593
+    lib.TCOD_list_pop.restype=c_void_p
594
+    lib.TCOD_list_pop.argtypes=[c_void_p ]
595
+
596
+    lib.TCOD_list_peek.restype=c_void_p
597
+    lib.TCOD_list_peek.argtypes=[c_void_p ]
598
+
599
+    lib.TCOD_list_add_all.restype=c_void
600
+    lib.TCOD_list_add_all.argtypes=[c_void_p , c_void_p ]
601
+
602
+    lib.TCOD_list_get.restype=c_void_p
603
+    lib.TCOD_list_get.argtypes=[c_void_p ,c_int]
604
+
605
+    lib.TCOD_list_set.restype=c_void
606
+    lib.TCOD_list_set.argtypes=[c_void_p ,c_void_p, c_int]
607
+
608
+    lib.TCOD_list_begin.restype=POINTER(c_void_p)
609
+    lib.TCOD_list_begin.argtypes=[c_void_p ]
610
+
611
+    lib.TCOD_list_end.restype=POINTER(c_void_p)
612
+    lib.TCOD_list_end.argtypes=[c_void_p ]
613
+
614
+    lib.TCOD_list_reverse.restype=c_void
615
+    lib.TCOD_list_reverse.argtypes=[c_void_p ]
616
+
617
+    lib.TCOD_list_remove_iterator.restype=POINTER(c_void_p)
618
+    lib.TCOD_list_remove_iterator.argtypes=[c_void_p , POINTER(c_void_p)]
619
+
620
+    lib.TCOD_list_remove.restype=c_void
621
+    lib.TCOD_list_remove.argtypes=[c_void_p ,c_void_p ]
622
+
623
+    lib.TCOD_list_remove_iterator_fast.restype=POINTER(c_void_p)
624
+    lib.TCOD_list_remove_iterator_fast.argtypes=[c_void_p , POINTER(c_void_p)]
625
+
626
+    lib.TCOD_list_remove_fast.restype=c_void
627
+    lib.TCOD_list_remove_fast.argtypes=[c_void_p ,c_void_p ]
628
+
629
+    lib.TCOD_list_contains.restype=c_bool
630
+    lib.TCOD_list_contains.argtypes=[c_void_p ,c_void_p ]
631
+
632
+    lib.TCOD_list_clear.restype=c_void
633
+    lib.TCOD_list_clear.argtypes=[c_void_p ]
634
+
635
+    lib.TCOD_list_clear_and_delete.restype=c_void
636
+    lib.TCOD_list_clear_and_delete.argtypes=[c_void_p ]
637
+
638
+    lib.TCOD_list_size.restype=c_int
639
+    lib.TCOD_list_size.argtypes=[c_void_p ]
640
+
641
+    lib.TCOD_list_insert_before.restype=POINTER(c_void_p)
642
+    lib.TCOD_list_insert_before.argtypes=[c_void_p ,c_void_p,c_int]
643
+
644
+    lib.TCOD_list_is_empty.restype=c_bool
645
+    lib.TCOD_list_is_empty.argtypes=[c_void_p ]
646
+
647
+    lib.TCOD_random_get_instance.restype=c_void_p
648
+    lib.TCOD_random_get_instance.argtypes=[]
649
+
650
+    lib.TCOD_random_new.restype=c_void_p
651
+    lib.TCOD_random_new.argtypes=[c_int ]
652
+
653
+    lib.TCOD_random_save.restype=c_void_p
654
+    lib.TCOD_random_save.argtypes=[c_void_p ]
655
+
656
+    lib.TCOD_random_restore.restype=c_void
657
+    lib.TCOD_random_restore.argtypes=[c_void_p , c_void_p ]
658
+
659
+    lib.TCOD_random_new_from_seed.restype=c_void_p
660
+    lib.TCOD_random_new_from_seed.argtypes=[c_int , c_int ]
661
+
662
+    lib.TCOD_random_delete.restype=c_void
663
+    lib.TCOD_random_delete.argtypes=[c_void_p ]
664
+
665
+    lib.TCOD_random_set_distribution .restype=c_void
666
+    lib.TCOD_random_set_distribution .argtypes=[c_void_p , c_int ]
667
+
668
+    lib.TCOD_random_get_int.restype=c_int
669
+    lib.TCOD_random_get_int.argtypes=[c_void_p , c_int, c_int]
670
+
671
+    lib.TCOD_random_get_float .restype=c_float
672
+    lib.TCOD_random_get_float .argtypes=[c_void_p , c_float , c_float ]
673
+
674
+    lib.TCOD_random_get_double .restype=c_double
675
+    lib.TCOD_random_get_double .argtypes=[c_void_p , c_double , c_double ]
676
+
677
+    lib.TCOD_random_get_int_mean .restype=c_int
678
+    lib.TCOD_random_get_int_mean .argtypes=[c_void_p , c_int, c_int, c_int]
679
+
680
+    lib.TCOD_random_get_float_mean .restype=c_float
681
+    lib.TCOD_random_get_float_mean .argtypes=[c_void_p , c_float , c_float , c_float ]
682
+
683
+    lib.TCOD_random_get_double_mean .restype=c_double
684
+    lib.TCOD_random_get_double_mean .argtypes=[c_void_p , c_double , c_double , c_double ]
685
+
686
+#    lib.TCOD_random_dice_new .restype=TCOD_dice_t
687
+#    lib.TCOD_random_dice_new .argtypes=[c_char_p ]
688
+
689
+#    lib.TCOD_random_dice_roll .restype=c_int
690
+#    lib.TCOD_random_dice_roll .argtypes=[c_void_p , TCOD_dice_t ]
691
+
692
+    lib.TCOD_random_dice_roll_s .restype=c_int
693
+    lib.TCOD_random_dice_roll_s .argtypes=[c_void_p , c_char_p ]
694
+
695
+    lib.TCOD_mouse_show_cursor.restype=c_void
696
+    lib.TCOD_mouse_show_cursor.argtypes=[c_bool ]
697
+
698
+#    lib.TCOD_mouse_get_status.restype=TCOD_mouse_t
699
+#    lib.TCOD_mouse_get_status.argtypes=[]
700
+
701
+    lib.TCOD_mouse_is_cursor_visible.restype=c_bool
702
+    lib.TCOD_mouse_is_cursor_visible.argtypes=[]
703
+
704
+    lib.TCOD_mouse_move.restype=c_void
705
+    lib.TCOD_mouse_move.argtypes=[c_int, c_int]
706
+
707
+    lib.TCOD_namegen_parse .restype=c_void
708
+    lib.TCOD_namegen_parse .argtypes=[c_char_p , c_void_p ]
709
+
710
+    lib.TCOD_namegen_generate .restype=c_char_p
711
+    lib.TCOD_namegen_generate .argtypes=[c_char_p , c_bool ]
712
+
713
+    lib.TCOD_namegen_generate_custom .restype=c_char_p
714
+    lib.TCOD_namegen_generate_custom .argtypes=[c_char_p , c_char_p , c_bool ]
715
+
716
+    lib.TCOD_namegen_get_sets .restype=c_void_p
717
+    lib.TCOD_namegen_get_sets .argtypes=[]
718
+
719
+    lib.TCOD_namegen_destroy .restype=c_void
720
+    lib.TCOD_namegen_destroy .argtypes=[]
721
+
722
+    lib.TCOD_noise_new.restype=c_void_p
723
+    lib.TCOD_noise_new.argtypes=[c_int, c_float , c_float , c_void_p ]
724
+
725
+    lib.TCOD_noise_set_type .restype=c_void
726
+    lib.TCOD_noise_set_type .argtypes=[c_void_p , c_int ]
727
+
728
+    lib.TCOD_noise_get_ex .restype=c_float
729
+    lib.TCOD_noise_get_ex .argtypes=[c_void_p , POINTER(c_float), c_int ]
730
+
731
+    lib.TCOD_noise_get_fbm_ex .restype=c_float
732
+    lib.TCOD_noise_get_fbm_ex .argtypes=[c_void_p , POINTER(c_float), c_float , c_int ]
733
+
734
+    lib.TCOD_noise_get_turbulence_ex .restype=c_float
735
+    lib.TCOD_noise_get_turbulence_ex .argtypes=[c_void_p , POINTER(c_float), c_float , c_int ]
736
+
737
+    lib.TCOD_noise_get .restype=c_float
738
+    lib.TCOD_noise_get .argtypes=[c_void_p , POINTER(c_float)]
739
+
740
+    lib.TCOD_noise_get_fbm .restype=c_float
741
+    lib.TCOD_noise_get_fbm .argtypes=[c_void_p , POINTER(c_float), c_float ]
742
+
743
+    lib.TCOD_noise_get_turbulence .restype=c_float
744
+    lib.TCOD_noise_get_turbulence .argtypes=[c_void_p , POINTER(c_float), c_float ]
745
+
746
+    lib.TCOD_noise_delete.restype=c_void
747
+    lib.TCOD_noise_delete.argtypes=[c_void_p ]
748
+
749
+    lib.TCOD_struct_get_name.restype=c_char_p
750
+    lib.TCOD_struct_get_name.argtypes=[c_void_p ]
751
+
752
+    lib.TCOD_struct_add_property.restype=c_void
753
+    lib.TCOD_struct_add_property.argtypes=[c_void_p , c_char_p,c_int , c_bool ]
754
+
755
+    lib.TCOD_struct_add_list_property.restype=c_void
756
+    lib.TCOD_struct_add_list_property.argtypes=[c_void_p , c_char_p,c_int , c_bool ]
757
+
758
+    lib.TCOD_struct_add_value_list.restype=c_void
759
+    lib.TCOD_struct_add_value_list.argtypes=[c_void_p ,c_char_p, POINTER(c_char_p), c_bool ]
760
+
761
+    lib.TCOD_struct_add_value_list_sized.restype=c_void
762
+    lib.TCOD_struct_add_value_list_sized.argtypes=[c_void_p ,c_char_p, POINTER(c_char_p), c_int, c_bool ]
763
+
764
+    lib.TCOD_struct_add_flag.restype=c_void
765
+    lib.TCOD_struct_add_flag.argtypes=[c_void_p ,c_char_p]
766
+
767
+    lib.TCOD_struct_add_structure.restype=c_void
768
+    lib.TCOD_struct_add_structure.argtypes=[c_void_p ,c_void_p]
769
+
770
+    lib.TCOD_struct_is_mandatory.restype=c_bool
771
+    lib.TCOD_struct_is_mandatory.argtypes=[c_void_p ,c_char_p]
772
+
773
+    lib.TCOD_struct_get_type.restype=c_int
774
+    lib.TCOD_struct_get_type.argtypes=[c_void_p , c_char_p]
775
+
776
+    lib.TCOD_parser_new.restype=c_void_p
777
+    lib.TCOD_parser_new.argtypes=[]
778
+
779
+    lib.TCOD_parser_new_struct.restype=c_void_p
780
+    lib.TCOD_parser_new_struct.argtypes=[c_void_p , c_char_p]
781
+
782
+#    lib.TCOD_parser_new_custom_type.restype=c_int
783
+#    lib.TCOD_parser_new_custom_type.argtypes=[c_void_p ,TCOD_parser_custom_t custom_type_]
784
+
785
+    lib.TCOD_parser_run.restype=c_void
786
+    lib.TCOD_parser_run.argtypes=[c_void_p , c_char_p, c_void_p]
787
+
788
+    lib.TCOD_parser_delete.restype=c_void
789
+    lib.TCOD_parser_delete.argtypes=[c_void_p ]
790
+
791
+    lib.TCOD_parser_error.restype=c_void
792
+#    lib.TCOD_parser_error.argtypes=[c_char_p, ...]
793
+
794
+    lib.TCOD_parser_get_bool_property.restype=c_bool
795
+    lib.TCOD_parser_get_bool_property.argtypes=[c_void_p , c_char_p]
796
+
797
+    lib.TCOD_parser_get_char_property.restype=c_int
798
+    lib.TCOD_parser_get_char_property.argtypes=[c_void_p , c_char_p]
799
+
800
+    lib.TCOD_parser_get_int_property.restype=c_int
801
+    lib.TCOD_parser_get_int_property.argtypes=[c_void_p , c_char_p]
802
+
803
+    lib.TCOD_parser_get_float_property.restype=c_float
804
+    lib.TCOD_parser_get_float_property.argtypes=[c_void_p , c_char_p]
805
+
806
+    lib.TCOD_parser_get_string_property.restype=c_char_p
807
+    lib.TCOD_parser_get_string_property.argtypes=[c_void_p , c_char_p]
808
+
809
+    lib.TCOD_parser_get_color_property.restype=c_int
810
+    lib.TCOD_parser_get_color_property.argtypes=[c_void_p , c_char_p]
811
+
812
+#    lib.TCOD_parser_property.restype=TCOD_dice_t
813
+#    lib.TCOD_parser_property.argtypes=[c_void_p , c_char_p]
814
+
815
+#    lib.TCOD_parser_py.restype=c_void
816
+#    lib.TCOD_parser_py.argtypes=[c_void_p , c_char_p, c_void_p]
817
+
818
+    lib.TCOD_parser_get_custom_property.restype=c_void_p
819
+    lib.TCOD_parser_get_custom_property.argtypes=[c_void_p , c_char_p]
820
+
821
+    lib.TCOD_parser_get_list_property.restype=c_void_p
822
+    lib.TCOD_parser_get_list_property.argtypes=[c_void_p , c_char_p, c_int ]
823
+
824
+#    lib.TCOD_parse_c_bool_value.restype=TCOD_value_t
825
+#    lib.TCOD_parse_c_bool_value.argtypes=[]
826
+
827
+#    lib.TCOD_parse_char_value.restype=TCOD_value_t
828
+#    lib.TCOD_parse_char_value.argtypes=[]
829
+
830
+#    lib.TCOD_parse_integer_value.restype=TCOD_value_t
831
+#    lib.TCOD_parse_integer_value.argtypes=[]
832
+
833
+#    lib.TCOD_parse_float_value.restype=TCOD_value_t
834
+#    lib.TCOD_parse_float_value.argtypes=[]
835
+
836
+#    lib.TCOD_parse_string_value.restype=TCOD_value_t
837
+#    lib.TCOD_parse_string_value.argtypes=[]
838
+
839
+#    lib.TCOD_parse_color_value.restype=TCOD_value_t
840
+#    lib.TCOD_parse_color_value.argtypes=[]
841
+
842
+#    lib.TCOD_parse_dice_value.restype=TCOD_value_t
843
+#    lib.TCOD_parse_dice_value.argtypes=[]
844
+
845
+#    lib.TCOD_parse_value_list_value.restype=TCOD_value_t
846
+#    lib.TCOD_parse_value_list_value.argtypes=[c_void_p,c_int]
847
+
848
+#    lib.TCOD_parse_property_value.restype=TCOD_value_t
849
+#    lib.TCOD_parse_property_value.argtypes=[c_void_p, c_void_p , c_char_p, c_bool ]
850
+
851
+    lib.TCOD_path_new_using_map.restype=c_void_p
852
+    lib.TCOD_path_new_using_map.argtypes=[c_void_p , c_float ]
853
+
854
+#    lib.TCOD_path_new_using_function.restype=c_void_p
855
+#    lib.TCOD_path_new_using_function.argtypes=[c_int, c_int, TCOD_path_func_t ,c_void_p, c_float ]
856
+
857
+    lib.TCOD_path_compute.restype=c_bool
858
+    lib.TCOD_path_compute.argtypes=[c_void_p , c_int,c_int, c_int, c_int]
859
+
860
+    lib.TCOD_path_walk.restype=c_bool
861
+    lib.TCOD_path_walk.argtypes=[c_void_p , POINTER(c_int), POINTER(c_int), c_bool]
862
+
863
+    lib.TCOD_path_is_empty.restype=c_bool
864
+    lib.TCOD_path_is_empty.argtypes=[c_void_p ]
865
+
866
+    lib.TCOD_path_size.restype=c_int
867
+    lib.TCOD_path_size.argtypes=[c_void_p ]
868
+
869
+    lib.TCOD_path_reverse.restype=c_void
870
+    lib.TCOD_path_reverse.argtypes=[c_void_p ]
871
+
872
+    lib.TCOD_path_get.restype=c_void
873
+    lib.TCOD_path_get.argtypes=[c_void_p , c_int, POINTER(c_int), POINTER(c_int)]
874
+
875
+    lib.TCOD_path_get_origin.restype=c_void
876
+    lib.TCOD_path_get_origin.argtypes=[c_void_p , POINTER(c_int), POINTER(c_int)]
877
+
878
+    lib.TCOD_path_get_destination.restype=c_void
879
+    lib.TCOD_path_get_destination.argtypes=[c_void_p , POINTER(c_int), POINTER(c_int)]
880
+
881
+    lib.TCOD_path_delete.restype=c_void
882
+    lib.TCOD_path_delete.argtypes=[c_void_p ]
883
+
884
+    lib.TCOD_dijkstra_new .restype=c_void_p
885
+    lib.TCOD_dijkstra_new .argtypes=[c_void_p , c_float ]
886
+
887
+#    lib.TCOD_dijkstra_new_using_function.restype=c_void_p
888
+#    lib.TCOD_dijkstra_new_using_function.argtypes=[c_int, c_int, TCOD_path_func_t ,c_void_p, c_float ]
889
+
890
+    lib.TCOD_dijkstra_compute .restype=c_void
891
+    lib.TCOD_dijkstra_compute .argtypes=[c_void_p , c_int, c_int]
892
+
893
+    lib.TCOD_dijkstra_get_distance .restype=c_float
894
+    lib.TCOD_dijkstra_get_distance .argtypes=[c_void_p , c_int, c_int]
895
+
896
+    lib.TCOD_dijkstra_path_set .restype=c_bool
897
+    lib.TCOD_dijkstra_path_set .argtypes=[c_void_p , c_int, c_int]
898
+
899
+    lib.TCOD_dijkstra_is_empty.restype=c_bool
900
+    lib.TCOD_dijkstra_is_empty.argtypes=[c_void_p ]
901
+
902
+    lib.TCOD_dijkstra_size.restype=c_int
903
+    lib.TCOD_dijkstra_size.argtypes=[c_void_p ]
904
+
905
+    lib.TCOD_dijkstra_reverse.restype=c_void
906
+    lib.TCOD_dijkstra_reverse.argtypes=[c_void_p ]
907
+
908
+    lib.TCOD_dijkstra_get.restype=c_void
909
+    lib.TCOD_dijkstra_get.argtypes=[c_void_p , c_int, POINTER(c_int), POINTER(c_int)]
910
+
911
+    lib.TCOD_dijkstra_path_walk .restype=c_bool
912
+    lib.TCOD_dijkstra_path_walk .argtypes=[c_void_p , POINTER(c_int), POINTER(c_int)]
913
+
914
+    lib.TCOD_dijkstra_delete .restype=c_void
915
+    lib.TCOD_dijkstra_delete .argtypes=[c_void_p ]
916
+
917
+    lib.TCOD_sys_elapsed_milli.restype=c_int
918
+    lib.TCOD_sys_elapsed_milli.argtypes=[]
919
+
920
+    lib.TCOD_sys_elapsed_seconds.restype=c_float
921
+    lib.TCOD_sys_elapsed_seconds.argtypes=[]
922
+
923
+    lib.TCOD_sys_sleep_milli.restype=c_void
924
+    lib.TCOD_sys_sleep_milli.argtypes=[c_int ]
925
+
926
+    lib.TCOD_sys_save_screenshot.restype=c_void
927
+    lib.TCOD_sys_save_screenshot.argtypes=[c_char_p]
928
+
929
+    lib.TCOD_sys_force_fullscreen_resolution.restype=c_void
930
+    lib.TCOD_sys_force_fullscreen_resolution.argtypes=[c_int, c_int]
931
+
932
+    lib.TCOD_sys_set_renderer.restype=c_void
933
+    lib.TCOD_sys_set_renderer.argtypes=[c_int ]
934
+
935
+    lib.TCOD_sys_get_renderer.restype=c_int
936
+    lib.TCOD_sys_get_renderer.argtypes=[]
937
+
938
+    lib.TCOD_sys_set_fps.restype=c_void
939
+    lib.TCOD_sys_set_fps.argtypes=[c_int]
940
+
941
+    lib.TCOD_sys_get_fps.restype=c_int
942
+    lib.TCOD_sys_get_fps.argtypes=[]
943
+
944
+    lib.TCOD_sys_get_last_frame_length.restype=c_float
945
+    lib.TCOD_sys_get_last_frame_length.argtypes=[]
946
+
947
+    lib.TCOD_sys_get_current_resolution.restype=c_void
948
+    lib.TCOD_sys_get_current_resolution.argtypes=[POINTER(c_int), POINTER(c_int)]
949
+
950
+    lib.TCOD_sys_get_fullscreen_offsets.restype=c_void
951
+    lib.TCOD_sys_get_fullscreen_offsets.argtypes=[POINTER(c_int), POINTER(c_int)]
952
+
953
+    lib.TCOD_sys_update_char.restype=c_void
954
+    lib.TCOD_sys_update_char.argtypes=[c_int, c_int, c_int, c_void_p , c_int, c_int]
955
+
956
+    lib.TCOD_sys_get_char_size.restype=c_void
957
+    lib.TCOD_sys_get_char_size.argtypes=[POINTER(c_int), POINTER(c_int)]
958
+
959
+    lib.TCOD_sys_wait_for_event.restype=c_int
960
+    lib.TCOD_sys_wait_for_event.argtypes=[c_int, c_void_p, c_void_p, c_bool ]
961
+
962
+    lib.TCOD_sys_check_for_event.restype=c_int
963
+    lib.TCOD_sys_check_for_event.argtypes=[c_int, c_void_p, c_void_p]
964
+
965
+    lib.TCOD_sys_create_directory.restype=c_bool
966
+    lib.TCOD_sys_create_directory.argtypes=[c_char_p]
967
+
968
+    lib.TCOD_sys_delete_file.restype=c_bool
969
+    lib.TCOD_sys_delete_file.argtypes=[c_char_p]
970
+
971
+    lib.TCOD_sys_delete_directory.restype=c_bool
972
+    lib.TCOD_sys_delete_directory.argtypes=[c_char_p]
973
+
974
+    lib.TCOD_sys_is_directory.restype=c_bool
975
+    lib.TCOD_sys_is_directory.argtypes=[c_char_p]
976
+
977
+    lib.TCOD_sys_get_directory_content.restype=c_void_p
978
+    lib.TCOD_sys_get_directory_content.argtypes=[c_char_p, c_char_p]
979
+
980
+    lib.TCOD_sys_file_exists.restype=c_bool
981
+#    lib.TCOD_sys_file_exists.argtypes=[c_char_p , ...]
982
+
983
+    lib.TCOD_sys_clipboard_set.restype=c_void
984
+    lib.TCOD_sys_clipboard_set.argtypes=[c_char_p]
985
+
986
+    lib.TCOD_sys_clipboard_get.restype=c_char_p
987
+    lib.TCOD_sys_clipboard_get.argtypes=[]
988
+
989
+    #_lib.TCOD_thread_new.restype=TCOD_thread_t
990
+    #_lib.TCOD_thread_new.argtypes=[c_int(*func)(void_p),c_void_p]
991
+
992
+    #_lib.TCOD_thread_delete.restype=c_void
993
+    #_lib.TCOD_thread_delete.argtypes=[TCOD_thread_t ]
994
+
995
+    lib.TCOD_sys_get_num_cores.restype=c_int
996
+    lib.TCOD_sys_get_num_cores.argtypes=[]
997
+
998
+    lib.TCOD_thread_wait.restype=c_void
999
+    lib.TCOD_thread_wait.argtypes=[c_void_p ]
1000
+
1001
+    lib.TCOD_mutex_new.restype=c_void_p
1002
+    lib.TCOD_mutex_new.argtypes=[]
1003
+
1004
+    lib.TCOD_mutex_in.restype=c_void
1005
+    lib.TCOD_mutex_in.argtypes=[c_void_p ]
1006
+
1007
+    lib.TCOD_mutex_out.restype=c_void
1008
+    lib.TCOD_mutex_out.argtypes=[c_void_p ]
1009
+
1010
+    lib.TCOD_mutex_delete.restype=c_void
1011
+    lib.TCOD_mutex_delete.argtypes=[c_void_p ]
1012
+
1013
+    lib.TCOD_semaphore_new.restype=c_void_p
1014
+    lib.TCOD_semaphore_new.argtypes=[c_int]
1015
+
1016
+    lib.TCOD_semaphore_lock.restype=c_void
1017
+    lib.TCOD_semaphore_lock.argtypes=[c_void_p ]
1018
+
1019
+    lib.TCOD_semaphore_unlock.restype=c_void
1020
+    lib.TCOD_semaphore_unlock.argtypes=[c_void_p ]
1021
+
1022
+    lib.TCOD_semaphore_delete.restype=c_void
1023
+    lib.TCOD_semaphore_delete.argtypes=[ c_void_p ]
1024
+
1025
+    lib.TCOD_condition_new.restype=c_void_p
1026
+    lib.TCOD_condition_new.argtypes=[]
1027
+
1028
+    lib.TCOD_condition_signal.restype=c_void
1029
+    lib.TCOD_condition_signal.argtypes=[c_void_p ]
1030
+
1031
+    lib.TCOD_condition_broadcast.restype=c_void
1032
+    lib.TCOD_condition_broadcast.argtypes=[c_void_p ]
1033
+
1034
+    lib.TCOD_condition_wait.restype=c_void
1035
+    lib.TCOD_condition_wait.argtypes=[c_void_p , c_void_p ]
1036
+
1037
+    lib.TCOD_condition_delete.restype=c_void
1038
+    lib.TCOD_condition_delete.argtypes=[ c_void_p ]
1039
+
1040
+    #_lib.TCOD_load_library.restype=TCOD_library_t
1041
+    #_lib.TCOD_load_library.argtypes=[c_char_p]
1042
+
1043
+    #_lib.TCOD_get_function_address.restype=c_void_p
1044
+    #_lib.TCOD_get_function_address.argtypes=[TCOD_library_t , c_char_pfunction_]
1045
+
1046
+    #_lib.TCOD_close_library.restype=c_void
1047
+    #_lib.TCOD_close_library.argtypes=[TCOD_library_]
1048
+
1049
+    #_lib.TCOD_sys_register_SDL_renderer.restype=c_void
1050
+    #_lib.TCOD_sys_register_SDL_renderer.argtypes=[SDL_renderer_t ]
1051
+
1052
+    lib.TCOD_tree_new.restype=c_void_p
1053
+    lib.TCOD_tree_new.argtypes=[]
1054
+
1055
+    lib.TCOD_tree_add_son.restype=c_void
1056
+    lib.TCOD_tree_add_son.argtypes=[c_void_p, c_void_p]
1057
+
1058
+    lib.TCOD_text_init.restype=c_void_p
1059
+    lib.TCOD_text_init.argtypes=[c_int, c_int, c_int, c_int, c_int]
1060
+
1061
+    lib.TCOD_text_set_properties.restype=c_void
1062
+    lib.TCOD_text_set_properties.argtypes=[c_void_p , c_int, c_int, c_char_p , c_int]
1063
+
1064
+    lib.TCOD_text_set_colors.restype=c_void
1065
+    lib.TCOD_text_set_colors.argtypes=[c_void_p , c_int , c_int , c_float]
1066
+
1067
+    lib.TCOD_text_update.restype=c_bool
1068
+    lib.TCOD_text_update.argtypes=[c_void_p , c_int ]
1069
+
1070
+    lib.TCOD_text_render.restype=c_void
1071
+    lib.TCOD_text_render.argtypes=[c_void_p , c_void_p ]
1072
+
1073
+    lib.TCOD_text_get.restype=c_char_p
1074
+    lib.TCOD_text_get.argtypes=[c_void_p ]
1075
+
1076
+    lib.TCOD_text_reset.restype=c_void
1077
+    lib.TCOD_text_reset.argtypes=[c_void_p ]
1078
+
1079
+    lib.TCOD_text_delete.restype=c_void
1080
+    lib.TCOD_text_delete.argtypes=[c_void_p ]
1081
+
1082
+    lib.TCOD_console_fill_background.restype=c_void
1083
+    lib.TCOD_console_fill_background.argtypes=[c_void_p , POINTER(c_int), POINTER(c_int), POINTER(c_int)]
1084
+
1085
+    lib.TCOD_console_fill_foreground.restype=c_void
1086
+    lib.TCOD_console_fill_foreground.argtypes=[c_void_p , POINTER(c_int), POINTER(c_int), POINTER(c_int)]
1087
+
1088
+    lib.TCOD_console_fill_char.restype=c_void
1089
+    lib.TCOD_console_fill_char.argtypes=[c_void_p , POINTER(c_int)]
1090
+
1091
+    lib.TCOD_console_double_hline.restype=c_void
1092
+    lib.TCOD_console_double_hline.argtypes=[c_void_p ,c_int,c_int, c_int]
1093
+
1094
+    lib.TCOD_console_double_vline.restype=c_void
1095
+    lib.TCOD_console_double_vline.argtypes=[c_void_p ,c_int,c_int]
1096
+
1097
+    lib.TCOD_console_print_double_frame.restype=c_void
1098
+    lib.TCOD_console_print_double_frame.argtypes=[c_void_p ,c_int,c_int]
1099
+
1100
+    lib.TCOD_console_print_return_string.restype=c_char_p
1101
+    lib.TCOD_console_print_return_string.argtypes=[c_void_p ,c_int]
1102
+
1103
+    lib.TCOD_image_set_key_color_wrapper.restype=c_void
1104
+    lib.TCOD_image_set_key_color_wrapper.argtypes=[c_void_p ]
1105
+
1106
+    lib.TCOD_mouse_get_status_wrapper.restype=c_void
1107
+    lib.TCOD_mouse_get_status_wrapper.argtypes=[c_void_p]
1108
+
1109
+    lib.TCOD_zip_new.restype=c_void_p
1110
+    lib.TCOD_zip_new.argtypes=[]
1111
+
1112
+    lib.TCOD_zip_delete.restype=c_void
1113
+    lib.TCOD_zip_delete.argtypes=[c_void_p ]
1114
+
1115
+    lib.TCOD_zip_put_char.restype=c_void
1116
+    lib.TCOD_zip_put_char.argtypes=[c_void_p , c_char ]
1117
+
1118
+    lib.TCOD_zip_put_int.restype=c_void
1119
+    lib.TCOD_zip_put_int.argtypes=[c_void_p , c_int]
1120
+
1121
+    lib.TCOD_zip_put_float.restype=c_void
1122
+    lib.TCOD_zip_put_float.argtypes=[c_void_p , c_float ]
1123
+
1124
+    lib.TCOD_zip_put_string.restype=c_void
1125
+    lib.TCOD_zip_put_string.argtypes=[c_void_p , c_char_p]
1126
+
1127
+    lib.TCOD_zip_put_color.restype=c_void
1128
+    lib.TCOD_zip_put_color.argtypes=[c_void_p , c_int ]
1129
+
1130
+    lib.TCOD_zip_put_image.restype=c_void
1131
+    lib.TCOD_zip_put_image.argtypes=[c_void_p , c_void_p ]
1132
+
1133
+    lib.TCOD_zip_put_console.restype=c_void
1134
+    lib.TCOD_zip_put_console.argtypes=[c_void_p , c_void_p ]
1135
+
1136
+    lib.TCOD_zip_put_data.restype=c_void
1137
+    lib.TCOD_zip_put_data.argtypes=[c_void_p , c_int,c_void_p]
1138
+
1139
+    lib.TCOD_zip_get_current_bytes.restype=c_int
1140
+    lib.TCOD_zip_get_current_bytes.argtypes=[c_void_p ]
1141
+
1142
+    lib.TCOD_zip_save_to_file.restype=c_int
1143
+    lib.TCOD_zip_save_to_file.argtypes=[c_void_p , c_char_p]
1144
+
1145
+    lib.TCOD_zip_load_from_file.restype=c_int
1146
+    lib.TCOD_zip_load_from_file.argtypes=[c_void_p , c_char_p]
1147
+
1148
+    lib.TCOD_zip_get_char.restype=c_char
1149
+    lib.TCOD_zip_get_char.argtypes=[c_void_p ]
1150
+
1151
+    lib.TCOD_zip_get_int.restype=c_int
1152
+    lib.TCOD_zip_get_int.argtypes=[c_void_p ]
1153
+
1154
+    lib.TCOD_zip_get_float.restype=c_float
1155
+    lib.TCOD_zip_get_float.argtypes=[c_void_p ]
1156
+
1157
+    lib.TCOD_zip_get_string.restype=c_char_p
1158
+    lib.TCOD_zip_get_string.argtypes=[c_void_p ]
1159
+
1160
+    lib.TCOD_zip_get_color.restype=c_int
1161
+    lib.TCOD_zip_get_color.argtypes=[c_void_p ]
1162
+
1163
+    lib.TCOD_zip_get_image.restype=c_void_p
1164
+    lib.TCOD_zip_get_image.argtypes=[c_void_p ]
1165
+
1166
+    lib.TCOD_zip_get_console.restype=c_void_p
1167
+    lib.TCOD_zip_get_console.argtypes=[c_void_p ]
1168
+
1169
+    lib.TCOD_zip_get_data.restype=c_int
1170
+    lib.TCOD_zip_get_data.argtypes=[c_void_p , c_int,c_void_p]
1171
+
1172
+    lib.TCOD_zip_get_remaining_bytes.restype=c_int
1173
+    lib.TCOD_zip_get_remaining_bytes.argtypes=[c_void_p ]
1174
+
1175
+    lib.TCOD_zip_skip_bytes.restype=c_void
1176
+    lib.TCOD_zip_skip_bytes.argtypes=[c_void_p ,c_int ]
1177
+
0 1178
new file mode 100755
1 1179
Binary files /dev/null and b/src/libtcod-gui-mingw.dll differ
2 1180
new file mode 100755
3 1181
Binary files /dev/null and b/src/libtcod-gui.dylib differ
4 1182
new file mode 100755
5 1183
Binary files /dev/null and b/src/libtcod-mingw.dll differ
6 1184
new file mode 100644
... ...
@@ -0,0 +1,1902 @@
1
+#
2
+# libtcod 1.5.1 python wrapper
3
+# Copyright (c) 2008,2009,2010 Jice & Mingos
4
+# All rights reserved.
5
+#
6
+# Redistribution and use in source and binary forms, with or without
7
+# modification, are permitted provided that the following conditions are met:
8
+#     * Redistributions of source code must retain the above copyright
9
+#       notice, this list of conditions and the following disclaimer.
10
+#     * Redistributions in binary form must reproduce the above copyright
11
+#       notice, this list of conditions and the following disclaimer in the
12
+#       documentation and/or other materials provided with the distribution.
13
+#     * The name of Jice or Mingos may not be used to endorse or promote products
14
+#       derived from this software without specific prior written permission.
15
+#
16
+# THIS SOFTWARE IS PROVIDED BY JICE AND MINGOS ``AS IS'' AND ANY
17
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+# DISCLAIMED. IN NO EVENT SHALL JICE OR MINGOS BE LIABLE FOR ANY
20
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+#
27
+
28
+import sys
29
+import ctypes
30
+import struct
31
+from ctypes import *
32
+
33
+if not hasattr(ctypes, "c_bool"):   # for Python < 2.6
34
+    c_bool = c_uint8
35
+
36
+try:  #import NumPy if available
37
+    import numpy
38
+    numpy_available = True
39
+except ImportError:
40
+    numpy_available = False
41
+
42
+LINUX=False
43
+MAC=False
44
+MINGW=False
45
+MSVC=False
46
+if sys.platform.find('linux') != -1:
47
+    _lib = ctypes.cdll['./libtcod.so']
48
+    LINUX=True
49
+elif sys.platform.find('darwin') != -1:
50
+    _lib = ctypes.cdll['./libtcod.dylib']
51
+    MAC = True
52
+else:
53
+    try:
54
+        _lib = ctypes.cdll['./libtcod-mingw.dll']
55
+        MINGW=True
56
+    except WindowsError:
57
+        _lib = ctypes.cdll['./libtcod-VS.dll']
58
+        MSVC=True
59
+    # On Windows, ctypes doesn't work well with function returning structs,
60
+    # so we have to user the _wrapper functions instead
61
+    _lib.TCOD_color_multiply = _lib.TCOD_color_multiply_wrapper
62
+    _lib.TCOD_color_add = _lib.TCOD_color_add_wrapper
63
+    _lib.TCOD_color_multiply_scalar = _lib.TCOD_color_multiply_scalar_wrapper
64
+    _lib.TCOD_color_subtract = _lib.TCOD_color_subtract_wrapper
65
+    _lib.TCOD_color_lerp = _lib.TCOD_color_lerp_wrapper
66
+    _lib.TCOD_console_get_default_background = _lib.TCOD_console_get_default_background_wrapper
67
+    _lib.TCOD_console_get_default_foreground = _lib.TCOD_console_get_default_foreground_wrapper
68
+    _lib.TCOD_console_get_char_background = _lib.TCOD_console_get_char_background_wrapper
69
+    _lib.TCOD_console_get_char_foreground = _lib.TCOD_console_get_char_foreground_wrapper
70
+    _lib.TCOD_console_get_fading_color = _lib.TCOD_console_get_fading_color_wrapper
71
+    _lib.TCOD_image_get_pixel = _lib.TCOD_image_get_pixel_wrapper
72
+    _lib.TCOD_image_get_mipmap_pixel = _lib.TCOD_image_get_mipmap_pixel_wrapper
73
+    _lib.TCOD_parser_get_color_property = _lib.TCOD_parser_get_color_property_wrapper
74
+
75
+HEXVERSION = 0x010501
76
+STRVERSION = "1.5.1"
77
+TECHVERSION = 0x01050103
78
+
79
+############################
80
+# color module
81
+############################
82
+class Color(Structure):
83
+    _fields_ = [('r', c_uint8),
84
+                ('g', c_uint8),
85
+                ('b', c_uint8),
86
+                ]
87
+
88
+    def __eq__(self, c):
89
+        return _lib.TCOD_color_equals(self, c)
90
+
91
+    def __mul__(self, c):
92
+        if isinstance(c,Color):
93
+            return _lib.TCOD_color_multiply(self, c)
94
+        else:
95
+            return _lib.TCOD_color_multiply_scalar(self, c_float(c))
96
+
97
+    def __add__(self, c):
98
+        return _lib.TCOD_color_add(self, c)
99
+
100
+    def __sub__(self, c):
101
+        return _lib.TCOD_color_subtract(self, c)
102
+
103
+    def __repr__(self):
104
+        return "Color(%d,%d,%d)" % (self.r, self.g, self.b)
105
+
106
+    def __getitem__(self, i):
107
+        if type(i) == str:
108
+            return getattr(self, i)
109
+        else:
110
+            return getattr(self, "rgb"[i])
111
+
112
+    def __setitem__(self, i, c):
113
+        if type(i) == str:
114
+            setattr(self, i, c)
115
+        else:
116
+            setattr(self, "rgb"[i], c)
117
+
118
+    def __iter__(self):
119
+        yield self.r
120
+        yield self.g
121
+        yield self.b
122
+
123
+# Should be valid on any platform, check it!  Has to be done after Color is defined.
124
+if MAC:
125
+    from cprotos import setup_protos
126
+    setup_protos(_lib)
127
+
128
+_lib.TCOD_color_equals.restype = c_bool
129
+_lib.TCOD_color_multiply.restype = Color
130
+_lib.TCOD_color_multiply_scalar.restype = Color
131
+_lib.TCOD_color_add.restype = Color
132
+_lib.TCOD_color_subtract.restype = Color
133
+
134
+# default colors
135
+# grey levels
136
+black=Color(0,0,0)
137
+darkest_grey=Color(31,31,31)
138
+darker_grey=Color(63,63,63)
139
+dark_grey=Color(95,95,95)
140
+grey=Color(127,127,127)
141
+light_grey=Color(159,159,159)
142
+lighter_grey=Color(191,191,191)
143
+lightest_grey=Color(223,223,223)
144
+darkest_gray=Color(31,31,31)
145
+darker_gray=Color(63,63,63)
146
+dark_gray=Color(95,95,95)
147
+gray=Color(127,127,127)
148
+light_gray=Color(159,159,159)
149
+lighter_gray=Color(191,191,191)
150
+lightest_gray=Color(223,223,223)
151
+white=Color(255,255,255)
152
+
153
+# sepia
154
+darkest_sepia=Color(31,24,15)
155
+darker_sepia=Color(63,50,31)
156
+dark_sepia=Color(94,75,47)
157
+sepia=Color(127,101,63)
158
+light_sepia=Color(158,134,100)
159
+lighter_sepia=Color(191,171,143)
160
+lightest_sepia=Color(222,211,195)
161
+
162
+#standard colors
163
+red=Color(255,0,0)
164
+flame=Color(255,63,0)
165
+orange=Color(255,127,0)
166
+amber=Color(255,191,0)
167
+yellow=Color(255,255,0)
168
+lime=Color(191,255,0)
169
+chartreuse=Color(127,255,0)
170
+green=Color(0,255,0)
171
+sea=Color(0,255,127)
172
+turquoise=Color(0,255,191)
173
+cyan=Color(0,255,255)
174
+sky=Color(0,191,255)
175
+azure=Color(0,127,255)
176
+blue=Color(0,0,255)
177
+han=Color(63,0,255)
178
+violet=Color(127,0,255)
179
+purple=Color(191,0,255)
180
+fuchsia=Color(255,0,255)
181
+magenta=Color(255,0,191)
182
+pink=Color(255,0,127)
183
+crimson=Color(255,0,63)
184
+
185
+# dark colors
186
+dark_red=Color(191,0,0)
187
+dark_flame=Color(191,47,0)
188
+dark_orange=Color(191,95,0)
189
+dark_amber=Color(191,143,0)
190
+dark_yellow=Color(191,191,0)
191
+dark_lime=Color(143,191,0)
192
+dark_chartreuse=Color(95,191,0)
193
+dark_green=Color(0,191,0)
194
+dark_sea=Color(0,191,95)
195
+dark_turquoise=Color(0,191,143)
196
+dark_cyan=Color(0,191,191)
197
+dark_sky=Color(0,143,191)
198
+dark_azure=Color(0,95,191)
199
+dark_blue=Color(0,0,191)
200
+dark_han=Color(47,0,191)
201
+dark_violet=Color(95,0,191)
202
+dark_purple=Color(143,0,191)
203
+dark_fuchsia=Color(191,0,191)
204
+dark_magenta=Color(191,0,143)
205
+dark_pink=Color(191,0,95)
206
+dark_crimson=Color(191,0,47)
207
+
208
+# darker colors
209
+darker_red=Color(127,0,0)
210
+darker_flame=Color(127,31,0)
211
+darker_orange=Color(127,63,0)
212
+darker_amber=Color(127,95,0)
213
+darker_yellow=Color(127,127,0)
214
+darker_lime=Color(95,127,0)
215
+darker_chartreuse=Color(63,127,0)
216
+darker_green=Color(0,127,0)
217
+darker_sea=Color(0,127,63)
218
+darker_turquoise=Color(0,127,95)
219
+darker_cyan=Color(0,127,127)
220
+darker_sky=Color(0,95,127)
221
+darker_azure=Color(0,63,127)
222
+darker_blue=Color(0,0,127)
223
+darker_han=Color(31,0,127)
224
+darker_violet=Color(63,0,127)
225
+darker_purple=Color(95,0,127)
226
+darker_fuchsia=Color(127,0,127)
227
+darker_magenta=Color(127,0,95)
228
+darker_pink=Color(127,0,63)
229
+darker_crimson=Color(127,0,31)
230
+
231
+# darkest colors
232
+darkest_red=Color(63,0,0)
233
+darkest_flame=Color(63,15,0)
234
+darkest_orange=Color(63,31,0)
235
+darkest_amber=Color(63,47,0)
236
+darkest_yellow=Color(63,63,0)
237
+darkest_lime=Color(47,63,0)
238
+darkest_chartreuse=Color(31,63,0)
239
+darkest_green=Color(0,63,0)
240
+darkest_sea=Color(0,63,31)
241
+darkest_turquoise=Color(0,63,47)
242
+darkest_cyan=Color(0,63,63)
243
+darkest_sky=Color(0,47,63)
244
+darkest_azure=Color(0,31,63)
245
+darkest_blue=Color(0,0,63)
246
+darkest_han=Color(15,0,63)
247
+darkest_violet=Color(31,0,63)
248
+darkest_purple=Color(47,0,63)
249
+darkest_fuchsia=Color(63,0,63)
250
+darkest_magenta=Color(63,0,47)
251
+darkest_pink=Color(63,0,31)
252
+darkest_crimson=Color(63,0,15)
253
+
254
+# light colors
255
+light_red=Color(255,114,114)
256
+light_flame=Color(255,149,114)
257
+light_orange=Color(255,184,114)
258
+light_amber=Color(255,219,114)
259
+light_yellow=Color(255,255,114)
260
+light_lime=Color(219,255,114)
261
+light_chartreuse=Color(184,255,114)
262
+light_green=Color(114,255,114)
263
+light_sea=Color(114,255,184)
264
+light_turquoise=Color(114,255,219)
265
+light_cyan=Color(114,255,255)
266
+light_sky=Color(114,219,255)
267
+light_azure=Color(114,184,255)
268
+light_blue=Color(114,114,255)
269
+light_han=Color(149,114,255)
270
+light_violet=Color(184,114,255)
271
+light_purple=Color(219,114,255)
272
+light_fuchsia=Color(255,114,255)
273
+light_magenta=Color(255,114,219)
274
+light_pink=Color(255,114,184)
275
+light_crimson=Color(255,114,149)
276
+
277
+#lighter colors
278
+lighter_red=Color(255,165,165)
279
+lighter_flame=Color(255,188,165)
280
+lighter_orange=Color(255,210,165)
281
+lighter_amber=Color(255,232,165)
282
+lighter_yellow=Color(255,255,165)
283
+lighter_lime=Color(232,255,165)
284
+lighter_chartreuse=Color(210,255,165)
285
+lighter_green=Color(165,255,165)
286
+lighter_sea=Color(165,255,210)
287
+lighter_turquoise=Color(165,255,232)
288
+lighter_cyan=Color(165,255,255)
289
+lighter_sky=Color(165,232,255)
290
+lighter_azure=Color(165,210,255)
291
+lighter_blue=Color(165,165,255)
292
+lighter_han=Color(188,165,255)
293
+lighter_violet=Color(210,165,255)
294
+lighter_purple=Color(232,165,255)
295
+lighter_fuchsia=Color(255,165,255)
296
+lighter_magenta=Color(255,165,232)
297
+lighter_pink=Color(255,165,210)
298
+lighter_crimson=Color(255,165,188)
299
+
300
+# lightest colors
301
+lightest_red=Color(255,191,191)
302
+lightest_flame=Color(255,207,191)
303
+lightest_orange=Color(255,223,191)
304
+lightest_amber=Color(255,239,191)
305
+lightest_yellow=Color(255,255,191)
306
+lightest_lime=Color(239,255,191)
307
+lightest_chartreuse=Color(223,255,191)
308
+lightest_green=Color(191,255,191)
309
+lightest_sea=Color(191,255,223)
310
+lightest_turquoise=Color(191,255,239)
311
+lightest_cyan=Color(191,255,255)
312
+lightest_sky=Color(191,239,255)
313
+lightest_azure=Color(191,223,255)
314
+lightest_blue=Color(191,191,255)
315
+lightest_han=Color(207,191,255)
316
+lightest_violet=Color(223,191,255)
317
+lightest_purple=Color(239,191,255)
318
+lightest_fuchsia=Color(255,191,255)
319
+lightest_magenta=Color(255,191,239)
320
+lightest_pink=Color(255,191,223)
321
+lightest_crimson=Color(255,191,207)
322
+
323
+# desaturated colors
324
+desaturated_red=Color(127,63,63)
325
+desaturated_flame=Color(127,79,63)
326
+desaturated_orange=Color(127,95,63)
327
+desaturated_amber=Color(127,111,63)
328
+desaturated_yellow=Color(127,127,63)
329
+desaturated_lime=Color(111,127,63)
330
+desaturated_chartreuse=Color(95,127,63)
331
+desaturated_green=Color(63,127,63)
332
+desaturated_sea=Color(63,127,95)
333
+desaturated_turquoise=Color(63,127,111)
334
+desaturated_cyan=Color(63,127,127)
335
+desaturated_sky=Color(63,111,127)
336
+desaturated_azure=Color(63,95,127)
337
+desaturated_blue=Color(63,63,127)
338
+desaturated_han=Color(79,63,127)
339
+desaturated_violet=Color(95,63,127)
340
+desaturated_purple=Color(111,63,127)
341
+desaturated_fuchsia=Color(127,63,127)
342
+desaturated_magenta=Color(127,63,111)
343
+desaturated_pink=Color(127,63,95)
344
+desaturated_crimson=Color(127,63,79)
345
+
346
+# metallic
347
+brass=Color(191,151,96)
348
+copper=Color(197,136,124)
349
+gold=Color(229,191,0)
350
+silver=Color(203,203,203)
351
+
352
+# miscellaneous
353
+celadon=Color(172,255,175)
354
+peach=Color(255,159,127)
355
+
356
+# color functions
357
+_lib.TCOD_color_lerp.restype = Color
358
+def color_lerp(c1, c2, a):
359
+    return _lib.TCOD_color_lerp(c1, c2, c_float(a))
360
+
361
+def color_set_hsv(c, h, s, v):
362
+    _lib.TCOD_color_set_HSV(byref(c), c_float(h), c_float(s), c_float(v))
363
+
364
+def color_get_hsv(c):
365
+    h = c_float()
366
+    s = c_float()
367
+    v = c_float()
368
+    _lib.TCOD_color_get_HSV(c, byref(h), byref(s), byref(v))
369
+    return h.value, s.value, v.value
370
+
371
+def color_scale_HSV(c, scoef, vcoef) :
372
+    _lib.TCOD_color_scale_HSV(byref(c),c_float(scoef),c_float(vcoef))
373
+
374
+def color_gen_map(colors, indexes):
375
+    ccolors = (Color * len(colors))(*colors)
376
+    cindexes = (c_int * len(indexes))(*indexes)
377
+    cres = (Color * (max(indexes) + 1))()
378
+    _lib.TCOD_color_gen_map(cres, len(colors), ccolors, cindexes)
379
+    return cres
380
+
381
+############################
382
+# console module
383
+############################
384
+class Key(Structure):
385
+    _fields_=[('vk', c_int),
386
+              ('c', c_uint8),
387
+              ('pressed', c_bool),
388
+              ('lalt', c_bool),
389
+              ('lctrl', c_bool),
390
+              ('ralt', c_bool),
391
+              ('rctrl', c_bool),
392
+              ('shift', c_bool),
393
+              ]
394
+
395
+class ConsoleBuffer:
396
+    # simple console that allows direct (fast) access to cells. simplifies
397
+    # use of the "fill" functions.
398
+    def __init__(self, width, height, back_r=0, back_g=0, back_b=0, fore_r=0, fore_g=0, fore_b=0, char=' '):
399
+        # initialize with given width and height. values to fill the buffer
400
+        # are optional, defaults to black with no characters.
401
+        n = width * height
402
+        self.width = width
403
+        self.height = height
404
+        self.clear(back_r, back_g, back_b, fore_r, fore_g, fore_b, char)
405
+
406
+    def clear(self, back_r=0, back_g=0, back_b=0, fore_r=0, fore_g=0, fore_b=0, char=' '):
407
+        # clears the console. values to fill it with are optional, defaults
408
+        # to black with no characters.
409
+        n = self.width * self.height
410
+        self.back_r = [back_r] * n
411
+        self.back_g = [back_g] * n
412
+        self.back_b = [back_b] * n
413
+        self.fore_r = [fore_r] * n
414
+        self.fore_g = [fore_g] * n
415
+        self.fore_b = [fore_b] * n
416
+        self.char = [ord(char)] * n
417
+    
418
+    def copy(self):
419
+        # returns a copy of this ConsoleBuffer.
420
+        other = ConsoleBuffer(0, 0)
421
+        other.width = self.width
422
+        other.height = self.height
423
+        other.back_r = list(self.back_r)  # make explicit copies of all lists
424
+        other.back_g = list(self.back_g)
425
+        other.back_b = list(self.back_b)
426
+        other.fore_r = list(self.fore_r)
427
+        other.fore_g = list(self.fore_g)
428
+        other.fore_b = list(self.fore_b)
429
+        other.char = list(self.char)
430
+        return other
431
+    
432
+    def set_fore(self, x, y, r, g, b, char):
433
+        # set the character and foreground color of one cell.
434
+        i = self.width * y + x
435
+        self.fore_r[i] = r
436
+        self.fore_g[i] = g
437
+        self.fore_b[i] = b
438
+        self.char[i] = ord(char)
439
+    
440
+    def set_back(self, x, y, r, g, b):
441
+        # set the background color of one cell.
442
+        i = self.width * y + x
443
+        self.back_r[i] = r
444
+        self.back_g[i] = g
445
+        self.back_b[i] = b
446
+    
447
+    def set(self, x, y, back_r, back_g, back_b, fore_r, fore_g, fore_b, char):
448
+        # set the background color, foreground color and character of one cell.
449
+        i = self.width * y + x
450
+        self.back_r[i] = back_r
451
+        self.back_g[i] = back_g
452
+        self.back_b[i] = back_b
453
+        self.fore_r[i] = fore_r
454
+        self.fore_g[i] = fore_g
455
+        self.fore_b[i] = fore_b
456
+        self.char[i] = ord(char)
457
+    
458
+    def blit(self, dest, fill_fore=True, fill_back=True):
459
+        # use libtcod's "fill" functions to write the buffer to a console.
460
+        if (console_get_width(dest) != self.width or
461
+            console_get_height(dest) != self.height):
462
+            raise ValueError('ConsoleBuffer.blit: Destination console has an incorrect size.')
463
+
464
+        s = struct.Struct('%di' % len(self.back_r))
465
+
466
+        if fill_back:
467
+            _lib.TCOD_console_fill_background(dest, (c_int * len(self.back_r))(*self.back_r), (c_int * len(self.back_g))(*self.back_g), (c_int * len(self.back_b))(*self.back_b))
468
+
469
+        if fill_fore:
470
+            _lib.TCOD_console_fill_foreground(dest, (c_int * len(self.fore_r))(*self.fore_r), (c_int * len(self.fore_g))(*self.fore_g), (c_int * len(self.fore_b))(*self.fore_b))
471
+            _lib.TCOD_console_fill_char(dest, (c_int * len(self.char))(*self.char))
472
+
473
+_lib.TCOD_console_credits_render.restype = c_bool
474
+_lib.TCOD_console_set_custom_font.argtypes=[c_char_p,c_int]
475
+_lib.TCOD_console_is_fullscreen.restype = c_bool
476
+_lib.TCOD_console_is_window_closed.restype = c_bool
477
+_lib.TCOD_console_get_default_background.restype = Color
478
+_lib.TCOD_console_get_default_foreground.restype = Color
479
+_lib.TCOD_console_get_char_background.restype = Color
480
+_lib.TCOD_console_get_char_foreground.restype = Color
481
+_lib.TCOD_console_get_fading_color.restype = Color
482
+_lib.TCOD_console_is_key_pressed.restype = c_bool
483
+
484
+# background rendering modes
485
+BKGND_NONE = 0
486
+BKGND_SET = 1
487
+BKGND_MULTIPLY = 2
488
+BKGND_LIGHTEN = 3
489
+BKGND_DARKEN = 4
490
+BKGND_SCREEN = 5
491
+BKGND_COLOR_DODGE = 6
492
+BKGND_COLOR_BURN = 7
493
+BKGND_ADD = 8
494
+BKGND_ADDA = 9
495
+BKGND_BURN = 10
496
+BKGND_OVERLAY = 11
497
+BKGND_ALPH = 12
498
+BKGND_DEFAULT=13
499
+
500
+def BKGND_ALPHA(a):
501
+    return BKGND_ALPH | (int(a * 255) << 8)
502
+
503
+def BKGND_ADDALPHA(a):
504
+    return BKGND_ADDA | (int(a * 255) << 8)
505
+
506
+# non blocking key events types
507
+KEY_PRESSED = 1
508
+KEY_RELEASED = 2
509
+# key codes
510
+KEY_NONE = 0
511
+KEY_ESCAPE = 1
512
+KEY_BACKSPACE = 2
513
+KEY_TAB = 3
514
+KEY_ENTER = 4
515
+KEY_SHIFT = 5
516
+KEY_CONTROL = 6
517
+KEY_ALT = 7
518
+KEY_PAUSE = 8
519
+KEY_CAPSLOCK = 9
520
+KEY_PAGEUP = 10
521
+KEY_PAGEDOWN = 11
522
+KEY_END = 12
523
+KEY_HOME = 13
524
+KEY_UP = 14
525
+KEY_LEFT = 15
526
+KEY_RIGHT = 16
527
+KEY_DOWN = 17
528
+KEY_PRINTSCREEN = 18
529
+KEY_INSERT = 19
530
+KEY_DELETE = 20
531
+KEY_LWIN = 21
532
+KEY_RWIN = 22
533
+KEY_APPS = 23
534
+KEY_0 = 24
535
+KEY_1 = 25
536
+KEY_2 = 26
537
+KEY_3 = 27
538
+KEY_4 = 28
539
+KEY_5 = 29
540
+KEY_6 = 30
541
+KEY_7 = 31
542
+KEY_8 = 32
543
+KEY_9 = 33
544
+KEY_KP0 = 34
545
+KEY_KP1 = 35
546
+KEY_KP2 = 36
547
+KEY_KP3 = 37
548
+KEY_KP4 = 38
549
+KEY_KP5 = 39
550
+KEY_KP6 = 40
551
+KEY_KP7 = 41
552
+KEY_KP8 = 42
553
+KEY_KP9 = 43
554
+KEY_KPADD = 44
555
+KEY_KPSUB = 45
556
+KEY_KPDIV = 46
557
+KEY_KPMUL = 47
558
+KEY_KPDEC = 48
559
+KEY_KPENTER = 49
560
+KEY_F1 = 50
561
+KEY_F2 = 51
562
+KEY_F3 = 52
563
+KEY_F4 = 53
564
+KEY_F5 = 54
565
+KEY_F6 = 55
566
+KEY_F7 = 56
567
+KEY_F8 = 57
568
+KEY_F9 = 58
569
+KEY_F10 = 59
570
+KEY_F11 = 60
571
+KEY_F12 = 61
572
+KEY_NUMLOCK = 62
573
+KEY_SCROLLLOCK = 63
574
+KEY_SPACE = 64
575
+KEY_CHAR = 65
576
+# special chars
577
+# single walls
578
+CHAR_HLINE = 196
579
+CHAR_VLINE = 179
580
+CHAR_NE = 191
581
+CHAR_NW = 218
582
+CHAR_SE = 217
583
+CHAR_SW = 192
584
+CHAR_TEEW = 180
585
+CHAR_TEEE = 195
586
+CHAR_TEEN = 193
587
+CHAR_TEES = 194
588
+CHAR_CROSS = 197
589
+# double walls
590
+CHAR_DHLINE = 205
591
+CHAR_DVLINE = 186
592
+CHAR_DNE = 187
593
+CHAR_DNW = 201
594
+CHAR_DSE = 188
595
+CHAR_DSW = 200
596
+CHAR_DTEEW = 185
597
+CHAR_DTEEE = 204
598
+CHAR_DTEEN = 202
599
+CHAR_DTEES = 203
600
+CHAR_DCROSS = 206
601
+# blocks
602
+CHAR_BLOCK1 = 176
603
+CHAR_BLOCK2 = 177
604
+CHAR_BLOCK3 = 178
605
+# arrows
606
+CHAR_ARROW_N = 24
607
+CHAR_ARROW_S = 25
608
+CHAR_ARROW_E = 26
609
+CHAR_ARROW_W = 27
610
+# arrows without tail
611
+CHAR_ARROW2_N = 30
612
+CHAR_ARROW2_S = 31
613
+CHAR_ARROW2_E = 16
614
+CHAR_ARROW2_W = 17
615
+# double arrows
616
+CHAR_DARROW_H = 29
617
+CHAR_DARROW_V = 18
618
+# GUI stuff
619
+CHAR_CHECKBOX_UNSET = 224
620
+CHAR_CHECKBOX_SET = 225
621
+CHAR_RADIO_UNSET = 9
622
+CHAR_RADIO_SET = 10
623
+# sub-pixel resolution kit
624
+CHAR_SUBP_NW = 226
625
+CHAR_SUBP_NE = 227
626
+CHAR_SUBP_N = 228
627
+CHAR_SUBP_SE = 229
628
+CHAR_SUBP_DIAG = 230
629
+CHAR_SUBP_E = 231
630
+CHAR_SUBP_SW = 232
631
+# font flags
632
+FONT_LAYOUT_ASCII_INCOL = 1
633
+FONT_LAYOUT_ASCII_INROW = 2
634
+FONT_TYPE_GREYSCALE = 4
635
+FONT_TYPE_GRAYSCALE = 4
636
+FONT_LAYOUT_TCOD = 8
637
+# color control codes
638
+COLCTRL_1=1
639
+COLCTRL_2=2
640
+COLCTRL_3=3
641
+COLCTRL_4=4
642
+COLCTRL_5=5
643
+COLCTRL_NUMBER=5
644
+COLCTRL_FORE_RGB=6
645
+COLCTRL_BACK_RGB=7
646
+COLCTRL_STOP=8
647
+# renderers
648
+RENDERER_GLSL=0
649
+RENDERER_OPENGL=1
650
+RENDERER_SDL=2
651
+NB_RENDERERS=3
652
+# alignment
653
+LEFT=0
654
+RIGHT=1
655
+CENTER=2
656
+# initializing the console
657
+def console_init_root(w, h, title, fullscreen=False, renderer=RENDERER_SDL):
658
+    _lib.TCOD_console_init_root(w, h, title, c_uint(fullscreen), c_uint(renderer))
659
+
660
+def console_get_width(con):
661
+    return _lib.TCOD_console_get_width(con)
662
+
663
+def console_get_height(con):
664
+    return _lib.TCOD_console_get_height(con)
665
+
666
+def console_set_custom_font(fontFile, flags=FONT_LAYOUT_ASCII_INCOL, nb_char_horiz=0, nb_char_vertic=0):
667
+    _lib.TCOD_console_set_custom_font(fontFile, flags, nb_char_horiz, nb_char_vertic)
668
+
669
+def console_map_ascii_code_to_font(asciiCode, fontCharX, fontCharY):
670
+    if type(asciiCode) == str:
671
+        _lib.TCOD_console_map_ascii_code_to_font(ord(asciiCode), fontCharX,
672
+                                                 fontCharY)
673
+    else:
674
+        _lib.TCOD_console_map_ascii_code_to_font(asciiCode, fontCharX,
675
+                                                 fontCharY)
676
+
677
+def console_map_ascii_codes_to_font(firstAsciiCode, nbCodes, fontCharX,
678
+                                    fontCharY):
679
+    if type(firstAsciiCode) == str:
680
+        _lib.TCOD_console_map_ascii_codes_to_font(ord(firstAsciiCode), nbCodes,
681
+                                                  fontCharX, fontCharY)
682
+    else:
683
+        _lib.TCOD_console_map_ascii_codes_to_font(firstAsciiCode, nbCodes,
684
+                                                  fontCharX, fontCharY)
685
+
686
+def console_map_string_to_font(s, fontCharX, fontCharY):
687
+    _lib.TCOD_console_map_string_to_font(s, fontCharX, fontCharY)
688
+
689
+def console_is_fullscreen():
690
+    return _lib.TCOD_console_is_fullscreen()
691
+
692
+def console_set_fullscreen(fullscreen):
693
+    _lib.TCOD_console_set_fullscreen(c_int(fullscreen))
694
+
695
+def console_is_window_closed():
696
+    return _lib.TCOD_console_is_window_closed()
697
+
698
+def console_set_window_title(title):
699
+    _lib.TCOD_console_set_window_title(title)
700
+
701
+def console_credits():
702
+    _lib.TCOD_console_credits()
703
+
704
+def console_credits_reset():
705
+    _lib.TCOD_console_credits_reset()
706
+
707
+def console_credits_render(x, y, alpha):
708
+    return _lib.TCOD_console_credits_render(x, y, c_int(alpha))
709
+
710
+def console_flush():
711
+    _lib.TCOD_console_flush()
712
+
713
+# drawing on a console
714
+def console_set_default_background(con, col):
715
+    _lib.TCOD_console_set_default_background(con, col)
716
+
717
+def console_set_default_foreground(con, col):
718
+    _lib.TCOD_console_set_default_foreground(con, col)
719
+
720
+def console_clear(con):
721
+    return _lib.TCOD_console_clear(con)
722
+
723
+def console_put_char(con, x, y, c, flag=BKGND_DEFAULT):
724
+    if type(c) == str:
725
+        _lib.TCOD_console_put_char(con, x, y, ord(c), flag)
726
+    else:
727
+        _lib.TCOD_console_put_char(con, x, y, c, flag)
728
+
729
+def console_put_char_ex(con, x, y, c, fore, back):
730
+    if type(c) == str:
731
+        _lib.TCOD_console_put_char_ex(con, x, y, ord(c), fore, back)
732
+    else:
733
+        _lib.TCOD_console_put_char_ex(con, x, y, c, fore, back)
734
+
735
+def console_set_char_background(con, x, y, col, flag=BKGND_SET):
736
+    _lib.TCOD_console_set_char_background(con, x, y, col, flag)
737
+
738
+def console_set_char_foreground(con, x, y, col):
739
+    _lib.TCOD_console_set_char_foreground(con, x, y, col)
740
+
741
+def console_set_char(con, x, y, c):
742
+    if type(c) == str:
743
+        _lib.TCOD_console_set_char(con, x, y, ord(c))
744
+    else:
745
+        _lib.TCOD_console_set_char(con, x, y, c)
746
+
747
+def console_set_background_flag(con, flag):
748
+    _lib.TCOD_console_set_background_flag(con, c_int(flag))
749
+
750
+def console_get_background_flag(con):
751
+    return _lib.TCOD_console_get_background_flag(con)
752
+
753
+def console_set_alignment(con, alignment):
754
+    _lib.TCOD_console_set_alignment(con, c_int(alignment))
755
+
756
+def console_get_alignment(con):
757
+    return _lib.TCOD_console_get_alignment(con)
758
+
759
+def console_print(con, x, y, fmt):
760
+    _lib.TCOD_console_print(c_void_p(con), x, y, c_char_p(fmt))
761
+
762
+def console_print_ex(con, x, y, flag, alignment, fmt):
763
+    _lib.TCOD_console_print_ex(c_void_p(con), x, y, flag, alignment, c_char_p(fmt))
764
+
765
+def console_print_rect(con, x, y, w, h, fmt):
766
+    return _lib.TCOD_console_print_rect(c_void_p(con), x, y, w, h, c_char_p(fmt))
767
+
768
+def console_print_rect_ex(con, x, y, w, h, flag, alignment, fmt):
769
+    return _lib.TCOD_console_print_rect_ex(c_void_p(con), x, y, w, h, flag, alignment, c_char_p(fmt))
770
+
771
+def console_get_height_rect(con, x, y, w, h, fmt):
772
+    return _lib.TCOD_console_get_height_rect(c_void_p(con), x, y, w, h, c_char_p(fmt))
773
+
774
+def console_rect(con, x, y, w, h, clr, flag=BKGND_DEFAULT):
775
+    _lib.TCOD_console_rect(con, x, y, w, h, c_int(clr), flag)
776
+
777
+def console_hline(con, x, y, l, flag=BKGND_DEFAULT):
778
+    _lib.TCOD_console_hline( con, x, y, l, flag)
779
+
780
+def console_vline(con, x, y, l, flag=BKGND_DEFAULT):
781
+    _lib.TCOD_console_vline( con, x, y, l, flag)
782
+
783
+def console_print_frame(con, x, y, w, h, clear=True, flag=BKGND_DEFAULT, fmt=0):
784
+    _lib.TCOD_console_print_frame(c_void_p(con), x, y, w, h, c_int(clear), flag, c_char_p(fmt))
785
+
786
+def console_set_color_control(con,fore,back) :
787
+    _lib.TCOD_console_set_color_control(con,fore,back)
788
+
789
+def console_get_default_background(con):
790
+    return _lib.TCOD_console_get_default_background(con)
791
+
792
+def console_get_default_foreground(con):
793
+    return _lib.TCOD_console_get_default_foreground(con)
794
+
795
+def console_get_char_background(con, x, y):
796
+    return _lib.TCOD_console_get_char_background(con, x, y)
797
+
798
+def console_get_char_foreground(con, x, y):
799
+    return _lib.TCOD_console_get_char_foreground(con, x, y)
800
+
801
+def console_get_char(con, x, y):
802
+    return _lib.TCOD_console_get_char(con, x, y)
803
+
804
+def console_set_fade(fade, fadingColor):
805
+    _lib.TCOD_console_set_fade(fade, fadingColor)
806
+    ##_lib.TCOD_console_set_fade_wrapper(fade, fadingColor)
807
+
808
+def console_get_fade():
809
+    return _lib.TCOD_console_get_fade().value
810
+
811
+def console_get_fading_color():
812
+    return _lib.TCOD_console_get_fading_color()
813
+
814
+# handling keyboard input
815
+def console_wait_for_keypress(flush):
816
+    k=Key()
817
+    _lib.TCOD_console_wait_for_keypress_wrapper(byref(k),c_bool(flush))
818
+    return k
819
+
820
+def console_check_for_keypress(flags=KEY_RELEASED):
821
+    k=Key()
822
+    _lib.TCOD_console_check_for_keypress_wrapper(byref(k),c_int(flags))
823
+    return k
824
+
825
+def console_is_key_pressed(key):
826
+    return _lib.TCOD_console_is_key_pressed(key)
827
+
828
+def console_set_keyboard_repeat(initial_delay, interval):
829
+    _lib.TCOD_console_set_keyboard_repeat(initial_delay, interval)
830
+
831
+def console_disable_keyboard_repeat():
832
+    _lib.TCOD_console_disable_keyboard_repeat()
833
+
834
+# using offscreen consoles
835
+def console_new(w, h):
836
+    return _lib.TCOD_console_new(w, h)
837
+def console_from_file(filename):
838
+    return _lib.TCOD_console_from_file(filename)
839
+def console_get_width(con):
840
+    return _lib.TCOD_console_get_width(con)
841
+
842
+def console_get_height(con):
843
+    return _lib.TCOD_console_get_height(con)
844
+
845
+def console_blit(src, x, y, w, h, dst, xdst, ydst, ffade=1.0,bfade=1.0):
846
+    _lib.TCOD_console_blit(src, x, y, w, h, dst, xdst, ydst, c_float(ffade), c_float(bfade))
847
+
848
+def console_set_key_color(con, col):
849
+    _lib.TCOD_console_set_key_color(con, col)
850
+
851
+def console_delete(con):
852
+    _lib.TCOD_console_delete(con)
853
+
854
+# fast color filling
855
+def console_fill_foreground(con,r,g,b) :
856
+    if len(r) != len(g) or len(r) != len(b):
857
+        raise TypeError('R, G and B must all have the same size.')
858
+
859
+    if (numpy_available and isinstance(r, numpy.ndarray) and
860
+        isinstance(g, numpy.ndarray) and isinstance(b, numpy.ndarray)):
861
+        #numpy arrays, use numpy's ctypes functions
862
+        r = numpy.ascontiguousarray(r, dtype=numpy.int_)
863
+        g = numpy.ascontiguousarray(g, dtype=numpy.int_)
864
+        b = numpy.ascontiguousarray(b, dtype=numpy.int_)
865
+        cr = r.ctypes.data_as(POINTER(c_int))
866
+        cg = g.ctypes.data_as(POINTER(c_int))
867
+        cb = b.ctypes.data_as(POINTER(c_int))
868
+    else:
869
+        # otherwise convert using ctypes arrays
870
+        cr = (c_int * len(r))(*r)
871
+        cg = (c_int * len(g))(*g)
872
+        cb = (c_int * len(b))(*b)
873
+
874
+    _lib.TCOD_console_fill_foreground(con, cr, cg, cb)
875
+
876
+def console_fill_background(con,r,g,b) :
877
+    if len(r) != len(g) or len(r) != len(b):
878
+        raise TypeError('R, G and B must all have the same size.')
879
+
880
+    if (numpy_available and isinstance(r, numpy.ndarray) and
881
+        isinstance(g, numpy.ndarray) and isinstance(b, numpy.ndarray)):
882
+        #numpy arrays, use numpy's ctypes functions
883
+        r = numpy.ascontiguousarray(r, dtype=numpy.int_)
884
+        g = numpy.ascontiguousarray(g, dtype=numpy.int_)
885
+        b = numpy.ascontiguousarray(b, dtype=numpy.int_)
886
+        cr = r.ctypes.data_as(POINTER(c_int))
887
+        cg = g.ctypes.data_as(POINTER(c_int))
888
+        cb = b.ctypes.data_as(POINTER(c_int))
889
+    else:
890
+        # otherwise convert using ctypes arrays
891
+        cr = (c_int * len(r))(*r)
892
+        cg = (c_int * len(g))(*g)
893
+        cb = (c_int * len(b))(*b)
894
+
895
+    _lib.TCOD_console_fill_background(con, cr, cg, cb)
896
+
897
+def console_fill_char(con,arr) :
898
+    if (numpy_available and isinstance(arr, numpy.ndarray) ):
899
+        #numpy arrays, use numpy's ctypes functions
900
+        arr = numpy.ascontiguousarray(arr, dtype=numpy.int_)
901
+        carr = arr.ctypes.data_as(POINTER(c_int))
902
+    else:
903
+        #otherwise convert using the struct module
904
+        carr = struct.pack('%di' % len(arr), *arr)
905
+
906
+    _lib.TCOD_console_fill_char(con, carr)
907
+        
908
+def console_load_asc(con, filename) :
909
+    _lib.TCOD_console_load_asc(con,filename)
910
+def console_save_asc(con, filename) :
911
+    _lib.TCOD_console_save_asc(con,filename)
912
+def console_load_apf(con, filename) :
913
+    _lib.TCOD_console_load_apf(con,filename)
914
+def console_save_apf(con, filename) :
915
+    _lib.TCOD_console_save_apf(con,filename)
916
+
917
+############################
918
+# sys module
919
+############################
920
+_lib.TCOD_sys_get_last_frame_length.restype = c_float
921
+_lib.TCOD_sys_elapsed_seconds.restype = c_float
922
+
923
+# high precision time functions
924
+def sys_set_fps(fps):
925
+    _lib.TCOD_sys_set_fps(fps)
926
+
927
+def sys_get_fps():
928
+    return _lib.TCOD_sys_get_fps()
929
+
930
+def sys_get_last_frame_length():
931
+    return _lib.TCOD_sys_get_last_frame_length()
932
+
933
+def sys_sleep_milli(val):
934
+    _lib.TCOD_sys_sleep_milli(c_uint(val))
935
+
936
+def sys_elapsed_milli():
937
+    return _lib.TCOD_sys_elapsed_milli()
938
+
939
+def sys_elapsed_seconds():
940
+    return _lib.TCOD_sys_elapsed_seconds()
941
+
942
+def sys_set_renderer(renderer):
943
+    _lib.TCOD_sys_set_renderer(renderer)
944
+
945
+def sys_get_renderer():
946
+    return _lib.TCOD_sys_get_renderer()
947
+
948
+# easy screenshots
949
+def sys_save_screenshot(name=0):
950
+    _lib.TCOD_sys_save_screenshot(name)
951
+
952
+# custom fullscreen resolution
953
+def sys_force_fullscreen_resolution(width, height):
954
+    _lib.TCOD_sys_force_fullscreen_resolution(width, height)
955
+
956
+def sys_get_current_resolution():
957
+    w = c_int()
958
+    h = c_int()
959
+    _lib.TCOD_sys_get_current_resolution(byref(w), byref(h))
960
+    return w.value, h.value
961
+
962
+def sys_get_char_size():
963
+    w = c_int()
964
+    h = c_int()
965
+    _lib.TCOD_sys_get_char_size(byref(w), byref(h))
966
+    return w.value, h.value
967
+
968
+# update font bitmap
969
+def sys_update_char(asciiCode, fontx, fonty, img, x, y) :
970
+    _lib.TCOD_sys_update_char(c_int(asciiCode),c_int(fontx),c_int(fonty),img,c_int(x),c_int(y))
971
+
972
+# custom SDL post renderer
973
+SDL_RENDERER_FUNC = CFUNCTYPE(None, c_void_p)
974
+def sys_register_SDL_renderer(callback):
975
+    global sdl_renderer_func
976
+    sdl_renderer_func = SDL_RENDERER_FUNC(callback)
977
+    _lib.TCOD_sys_register_SDL_renderer(sdl_renderer_func)
978
+
979
+# events
980
+EVENT_KEY_PRESS=1
981
+EVENT_KEY_RELEASE=2
982
+EVENT_KEY=EVENT_KEY_PRESS|EVENT_KEY_RELEASE
983
+EVENT_MOUSE_MOVE=4
984
+EVENT_MOUSE_PRESS=8
985
+EVENT_MOUSE_RELEASE=16
986
+EVENT_MOUSE=EVENT_MOUSE_MOVE|EVENT_MOUSE_PRESS|EVENT_MOUSE_RELEASE
987
+EVENT_ANY=EVENT_KEY|EVENT_MOUSE
988
+def sys_check_for_event(mask,k,m) :
989
+    return _lib.TCOD_sys_check_for_event(c_int(mask),byref(k),byref(m))
990
+
991
+def sys_wait_for_event(mask,k,m,flush) :
992
+    return _lib.TCOD_sys_wait_for_event(c_int(mask),byref(k),byref(m),c_bool(flush))
993
+
994
+############################
995
+# line module
996
+############################
997
+_lib.TCOD_line_step.restype = c_bool
998
+_lib.TCOD_line.restype=c_bool
999
+_lib.TCOD_line_step_mt.restype = c_bool
1000
+
1001
+def line_init(xo, yo, xd, yd):
1002
+    _lib.TCOD_line_init(xo, yo, xd, yd)
1003
+
1004
+def line_step():
1005
+    x = c_int()
1006
+    y = c_int()
1007
+    ret = _lib.TCOD_line_step(byref(x), byref(y))
1008
+    if not ret:
1009
+        return x.value, y.value
1010
+    return None,None
1011
+
1012
+def line(xo,yo,xd,yd,py_callback) :
1013
+    LINE_CBK_FUNC=CFUNCTYPE(c_bool,c_int,c_int)
1014
+    c_callback=LINE_CBK_FUNC(py_callback)
1015
+    return _lib.TCOD_line(xo,yo,xd,yd,c_callback)
1016
+
1017
+def line_iter(xo, yo, xd, yd):
1018
+    data = (c_int * 9)()        # struct TCOD_bresenham_data_t
1019
+    _lib.TCOD_line_init_mt(xo, yo, xd, yd, data)
1020
+    x = c_int(xo)
1021
+    y = c_int(yo)
1022
+    done = False
1023
+    while not done:
1024
+        yield x.value, y.value
1025
+        done = _lib.TCOD_line_step_mt(byref(x), byref(y), data)
1026
+
1027
+############################
1028
+# image module
1029
+############################
1030
+_lib.TCOD_image_is_pixel_transparent.restype = c_bool
1031
+_lib.TCOD_image_get_pixel.restype = Color
1032
+_lib.TCOD_image_get_mipmap_pixel.restype = Color
1033
+
1034
+def image_new(width, height):
1035
+    return _lib.TCOD_image_new(width, height)
1036
+
1037
+def image_clear(image,col) :
1038
+    _lib.TCOD_image_clear(image,col)
1039
+
1040
+def image_invert(image) :
1041
+    _lib.TCOD_image_invert(image)
1042
+
1043
+def image_hflip(image) :
1044
+    _lib.TCOD_image_hflip(image)
1045
+
1046
+def image_rotate90(image, num=1) :
1047
+    _lib.TCOD_image_rotate90(image,num)
1048
+
1049
+def image_vflip(image) :
1050
+    _lib.TCOD_image_vflip(image)
1051
+
1052
+def image_scale(image, neww, newh) :
1053
+    _lib.TCOD_image_scale(image,c_int(neww),c_int(newh))
1054
+
1055
+def image_set_key_color(image,col) :
1056
+    _lib.TCOD_image_set_key_color(image,col)
1057
+
1058
+def image_get_alpha(image,x,y) :
1059
+    return _lib.TCOD_image_get_alpha(image,c_int(x),c_int(y))
1060
+
1061
+def image_is_pixel_transparent(image,x,y) :
1062
+    return _lib.TCOD_image_is_pixel_transparent(image,c_int(x),c_int(y))
1063
+
1064
+def image_load(filename):
1065
+    return _lib.TCOD_image_load(filename)
1066
+
1067
+def image_from_console(console):
1068
+    return _lib.TCOD_image_from_console(console)
1069
+
1070
+def image_refresh_console(image, console):
1071
+    _lib.TCOD_image_refresh_console(image, console)
1072
+
1073
+def image_get_size(image):
1074
+    w=c_int()
1075
+    h=c_int()
1076
+    _lib.TCOD_image_get_size(image, byref(w), byref(h))
1077
+    return w.value, h.value
1078
+
1079
+def image_get_pixel(image, x, y):
1080
+    return _lib.TCOD_image_get_pixel(image, x, y)
1081
+
1082
+def image_get_mipmap_pixel(image, x0, y0, x1, y1):
1083
+    return _lib.TCOD_image_get_mipmap_pixel(image, c_float(x0), c_float(y0),
1084
+                                            c_float(x1), c_float(y1))
1085
+def image_put_pixel(image, x, y, col):
1086
+    _lib.TCOD_image_put_pixel(image, x, y, col)
1087
+    ##_lib.TCOD_image_put_pixel_wrapper(image, x, y, col)
1088
+
1089
+def image_blit(image, console, x, y, bkgnd_flag, scalex, scaley, angle):
1090
+    _lib.TCOD_image_blit(image, console, c_float(x), c_float(y), bkgnd_flag,
1091
+                         c_float(scalex), c_float(scaley), c_float(angle))
1092
+
1093
+def image_blit_rect(image, console, x, y, w, h, bkgnd_flag):
1094
+    _lib.TCOD_image_blit_rect(image, console, x, y, w, h, bkgnd_flag)
1095
+
1096
+def image_blit_2x(image, console, dx, dy, sx=0, sy=0, w=-1, h=-1):
1097
+    _lib.TCOD_image_blit_2x(image, console, dx,dy,sx,sy,w,h)
1098
+
1099
+def image_save(image, filename):
1100
+    _lib.TCOD_image_save(image, filename)
1101
+
1102
+def image_delete(image):
1103
+    _lib.TCOD_image_delete(image)
1104
+
1105
+############################
1106
+# mouse module
1107
+############################
1108
+class Mouse(Structure):
1109
+    _fields_=[('x', c_int),
1110
+              ('y', c_int),
1111
+              ('dx', c_int),
1112
+              ('dy', c_int),
1113
+              ('cx', c_int),
1114
+              ('cy', c_int),
1115
+              ('dcx', c_int),
1116
+              ('dcy', c_int),
1117
+              ('lbutton', c_bool),
1118
+              ('rbutton', c_bool),
1119
+              ('mbutton', c_bool),
1120
+              ('lbutton_pressed', c_bool),
1121
+              ('rbutton_pressed', c_bool),
1122
+              ('mbutton_pressed', c_bool),
1123
+              ('wheel_up', c_bool),
1124
+              ('wheel_down', c_bool),
1125
+              ]
1126
+
1127
+_lib.TCOD_mouse_is_cursor_visible.restype = c_bool
1128
+
1129
+def mouse_show_cursor(visible):
1130
+    _lib.TCOD_mouse_show_cursor(c_int(visible))
1131
+
1132
+def mouse_is_cursor_visible():
1133
+    return _lib.TCOD_mouse_is_cursor_visible()
1134
+
1135
+def mouse_move(x, y):
1136
+    _lib.TCOD_mouse_move(x, y)
1137
+
1138
+def mouse_get_status():
1139
+    mouse=Mouse()
1140
+    _lib.TCOD_mouse_get_status_wrapper(byref(mouse))
1141
+    return mouse
1142
+
1143
+############################
1144
+# parser module
1145
+############################
1146
+_lib.TCOD_struct_get_name.restype = c_char_p
1147
+_lib.TCOD_struct_is_mandatory.restype = c_bool
1148
+_lib.TCOD_parser_get_bool_property.restype = c_bool
1149
+_lib.TCOD_parser_get_float_property.restype = c_float
1150
+_lib.TCOD_parser_get_string_property.restype = c_char_p
1151
+_lib.TCOD_parser_get_color_property.restype = Color
1152
+
1153
+class Dice(Structure):
1154
+    _fields_=[('nb_dices', c_int),
1155
+              ('nb_faces', c_int),
1156
+              ('multiplier', c_float),
1157
+              ('addsub', c_float),
1158
+              ]
1159
+
1160
+    def __repr__(self):
1161
+        return "Dice(%d, %d, %s, %s)" % (self.nb_dices, self.nb_faces,
1162
+                                      self.multiplier, self.addsub)
1163
+
1164
+class _CValue(Union):
1165
+    _fields_=[('c',c_uint8),
1166
+              ('i',c_int),
1167
+              ('f',c_float),
1168
+              ('s',c_char_p),
1169
+              # JBR03192012 See http://bugs.python.org/issue14354 for why these are not defined as their actual types
1170
+              ('col',c_uint8 * 3),
1171
+              ('dice',c_int * 4),
1172
+              ('custom',c_void_p),
1173
+              ]
1174
+
1175
+_CFUNC_NEW_STRUCT = CFUNCTYPE(c_uint, c_void_p, c_char_p)
1176
+_CFUNC_NEW_FLAG = CFUNCTYPE(c_uint, c_char_p)
1177
+_CFUNC_NEW_PROPERTY = CFUNCTYPE(c_uint, c_char_p, c_int, _CValue)
1178
+
1179
+class _CParserListener(Structure):
1180
+    _fields_=[('new_struct', _CFUNC_NEW_STRUCT),
1181
+              ('new_flag',_CFUNC_NEW_FLAG),
1182
+              ('new_property',_CFUNC_NEW_PROPERTY),
1183
+              ('end_struct',_CFUNC_NEW_STRUCT),
1184
+              ('error',_CFUNC_NEW_FLAG),
1185
+              ]
1186
+
1187
+# property types
1188
+TYPE_NONE = 0
1189
+TYPE_BOOL = 1
1190
+TYPE_CHAR = 2
1191
+TYPE_INT = 3
1192
+TYPE_FLOAT = 4
1193
+TYPE_STRING = 5
1194
+TYPE_COLOR = 6
1195
+TYPE_DICE = 7
1196
+TYPE_VALUELIST00 = 8
1197
+TYPE_VALUELIST01 = 9
1198
+TYPE_VALUELIST02 = 10
1199
+TYPE_VALUELIST03 = 11
1200
+TYPE_VALUELIST04 = 12
1201
+TYPE_VALUELIST05 = 13
1202
+TYPE_VALUELIST06 = 14
1203
+TYPE_VALUELIST07 = 15
1204
+TYPE_VALUELIST08 = 16
1205
+TYPE_VALUELIST09 = 17
1206
+TYPE_VALUELIST10 = 18
1207
+TYPE_VALUELIST11 = 19
1208
+TYPE_VALUELIST12 = 20
1209
+TYPE_VALUELIST13 = 21
1210
+TYPE_VALUELIST14 = 22
1211
+TYPE_VALUELIST15 = 23
1212
+TYPE_LIST = 1024
1213
+
1214
+def _convert_TCODList(clist, typ):
1215
+    res = list()
1216
+    for i in range(_lib.TCOD_list_size(clist)):
1217
+        elt = _lib.TCOD_list_get(clist, i)
1218
+        elt = cast(elt, c_void_p)
1219
+        if typ == TYPE_BOOL:
1220
+            elt = c_bool.from_buffer(elt).value
1221
+        elif typ == TYPE_CHAR:
1222
+            elt = c_char.from_buffer(elt).value
1223
+        elif typ == TYPE_INT:
1224
+            elt = c_int.from_buffer(elt).value
1225
+        elif typ == TYPE_FLOAT:
1226
+            elt = c_float.from_buffer(elt).value
1227
+        elif typ == TYPE_STRING or TYPE_VALUELIST15 >= typ >= TYPE_VALUELIST00:
1228
+            elt = cast(elt, c_char_p).value
1229
+        elif typ == TYPE_COLOR:
1230
+            elt = Color.from_buffer_copy(elt)
1231
+        elif typ == TYPE_DICE:
1232
+            # doesn't work
1233
+            elt = Dice.from_buffer_copy(elt)
1234
+        res.append(elt)
1235
+    return res
1236
+
1237
+def parser_new():
1238
+    return _lib.TCOD_parser_new()
1239
+
1240
+def parser_new_struct(parser, name):
1241
+    return _lib.TCOD_parser_new_struct(parser, name)
1242
+
1243
+def struct_add_flag(struct, name):
1244
+    _lib.TCOD_struct_add_flag(struct, name)
1245
+
1246
+def struct_add_property(struct, name, typ, mandatory):
1247
+    _lib.TCOD_struct_add_property(struct, name, typ, c_bool(mandatory))
1248
+
1249
+def struct_add_value_list(struct, name, value_list, mandatory):
1250
+    CARRAY = c_char_p * (len(value_list) + 1)
1251
+    cvalue_list = CARRAY()
1252
+    for i in range(len(value_list)):
1253
+        cvalue_list[i] = cast(value_list[i], c_char_p)
1254
+    cvalue_list[len(value_list)] = 0
1255
+    _lib.TCOD_struct_add_value_list(struct, name, cvalue_list, c_bool(mandatory))
1256
+
1257
+def struct_add_list_property(struct, name, typ, mandatory):
1258
+    _lib.TCOD_struct_add_list_property(struct, name, typ, c_bool(mandatory))
1259
+
1260
+def struct_add_structure(struct, sub_struct):
1261
+    _lib.TCOD_struct_add_structure(struct, sub_struct)
1262
+
1263
+def struct_get_name(struct):
1264
+    return _lib.TCOD_struct_get_name(struct)
1265
+
1266
+def struct_is_mandatory(struct, name):
1267
+    return _lib.TCOD_struct_is_mandatory(struct, name)
1268
+
1269
+def struct_get_type(struct, name):
1270
+    return _lib.TCOD_struct_get_type(struct, name)
1271
+
1272
+def parser_run(parser, filename, listener=0):
1273
+    if listener != 0:
1274
+        clistener=_CParserListener()
1275
+        def value_converter(name, typ, value):
1276
+            if typ == TYPE_BOOL:
1277
+                return listener.new_property(name, typ, value.c == 1)
1278
+            elif typ == TYPE_CHAR:
1279
+                return listener.new_property(name, typ, '%c' % (value.c & 0xFF))
1280
+            elif typ == TYPE_INT:
1281
+                return listener.new_property(name, typ, value.i)
1282
+            elif typ == TYPE_FLOAT:
1283
+                return listener.new_property(name, typ, value.f)
1284
+            elif typ == TYPE_STRING or \
1285
+                 TYPE_VALUELIST15 >= typ >= TYPE_VALUELIST00:
1286
+                 return listener.new_property(name, typ, value.s)
1287
+            elif typ == TYPE_COLOR:
1288
+                col = cast(value.col, POINTER(Color)).contents
1289
+                return listener.new_property(name, typ, col)
1290
+            elif typ == TYPE_DICE:
1291
+                dice = cast(value.dice, POINTER(Dice)).contents
1292
+                return listener.new_property(name, typ, dice)
1293
+            elif typ & TYPE_LIST:
1294
+                return listener.new_property(name, typ,
1295
+                                        _convert_TCODList(value.custom, typ & 0xFF))
1296
+            return True
1297
+        clistener.new_struct = _CFUNC_NEW_STRUCT(listener.new_struct)
1298
+        clistener.new_flag = _CFUNC_NEW_FLAG(listener.new_flag)
1299
+        clistener.new_property = _CFUNC_NEW_PROPERTY(value_converter)
1300
+        clistener.end_struct = _CFUNC_NEW_STRUCT(listener.end_struct)
1301
+        clistener.error = _CFUNC_NEW_FLAG(listener.error)
1302
+        _lib.TCOD_parser_run(parser, filename, byref(clistener))
1303
+    else:
1304
+        _lib.TCOD_parser_run(parser, filename, 0)
1305
+
1306
+def parser_delete(parser):
1307
+    _lib.TCOD_parser_delete(parser)
1308
+
1309
+def parser_get_bool_property(parser, name):
1310
+    return _lib.TCOD_parser_get_bool_property(parser, name)
1311
+
1312
+def parser_get_int_property(parser, name):
1313
+    return _lib.TCOD_parser_get_int_property(parser, name)
1314
+
1315
+def parser_get_char_property(parser, name):
1316
+    return '%c' % _lib.TCOD_parser_get_char_property(parser, name)
1317
+
1318
+def parser_get_float_property(parser, name):
1319
+    return _lib.TCOD_parser_get_float_property(parser, name)
1320
+
1321
+def parser_get_string_property(parser, name):
1322
+    return _lib.TCOD_parser_get_string_property(parser, name)
1323
+
1324
+def parser_get_color_property(parser, name):
1325
+    return _lib.TCOD_parser_get_color_property(parser, name)
1326
+
1327
+def parser_get_dice_property(parser, name):
1328
+    d = Dice()
1329
+    _lib.TCOD_parser_get_dice_property_py(c_void_p(parser), name, byref(d))
1330
+    return d
1331
+
1332
+def parser_get_list_property(parser, name, typ):
1333
+    clist = _lib.TCOD_parser_get_list_property(parser, name, c_int(typ))
1334
+    return _convert_TCODList(clist, typ)
1335
+
1336
+############################
1337
+# random module
1338
+############################
1339
+_lib.TCOD_random_get_float.restype = c_float
1340
+_lib.TCOD_random_get_double.restype = c_double
1341
+
1342
+RNG_MT = 0
1343
+RNG_CMWC = 1
1344
+
1345
+DISTRIBUTION_LINEAR = 0
1346
+DISTRIBUTION_GAUSSIAN = 1
1347
+DISTRIBUTION_GAUSSIAN_RANGE = 2
1348
+DISTRIBUTION_GAUSSIAN_INVERSE = 3
1349
+DISTRIBUTION_GAUSSIAN_RANGE_INVERSE = 4
1350
+
1351
+def random_get_instance():
1352
+    return _lib.TCOD_random_get_instance()
1353
+
1354
+def random_new(algo=RNG_CMWC):
1355
+    return _lib.TCOD_random_new(algo)
1356
+
1357
+def random_new_from_seed(seed, algo=RNG_CMWC):
1358
+    return _lib.TCOD_random_new_from_seed(algo,c_uint(seed))
1359
+
1360
+def random_set_distribution(rnd, dist) :
1361
+	_lib.TCOD_random_set_distribution(rnd, dist)
1362
+
1363
+def random_get_int(rnd, mi, ma):
1364
+    return _lib.TCOD_random_get_int(rnd, mi, ma)
1365
+
1366
+def random_get_float(rnd, mi, ma):
1367
+    return _lib.TCOD_random_get_float(rnd, c_float(mi), c_float(ma))
1368
+
1369
+def random_get_double(rnd, mi, ma):
1370
+    return _lib.TCOD_random_get_double(rnd, c_double(mi), c_double(ma))
1371
+
1372
+def random_get_int_mean(rnd, mi, ma, mean):
1373
+    return _lib.TCOD_random_get_int_mean(rnd, mi, ma, mean)
1374
+
1375
+def random_get_float_mean(rnd, mi, ma, mean):
1376
+    return _lib.TCOD_random_get_float_mean(rnd, c_float(mi), c_float(ma), c_float(mean))
1377
+
1378
+def random_get_double_mean(rnd, mi, ma, mean):
1379
+    return _lib.TCOD_random_get_double_mean(rnd, c_double(mi), c_double(ma), c_double(mean))
1380
+
1381
+def random_save(rnd):
1382
+    return _lib.TCOD_random_save(rnd)
1383
+
1384
+def random_restore(rnd, backup):
1385
+    _lib.TCOD_random_restore(rnd, backup)
1386
+
1387
+def random_delete(rnd):
1388
+    _lib.TCOD_random_delete(rnd)
1389
+
1390
+############################
1391
+# noise module
1392
+############################
1393
+_lib.TCOD_noise_get.restype = c_float
1394
+_lib.TCOD_noise_get_ex.restype = c_float
1395
+_lib.TCOD_noise_get_fbm.restype = c_float
1396
+_lib.TCOD_noise_get_fbm_ex.restype = c_float
1397
+_lib.TCOD_noise_get_turbulence.restype = c_float
1398
+_lib.TCOD_noise_get_turbulence_ex.restype = c_float
1399
+
1400
+NOISE_DEFAULT_HURST = 0.5
1401
+NOISE_DEFAULT_LACUNARITY = 2.0
1402
+
1403
+NOISE_DEFAULT = 0
1404
+NOISE_PERLIN = 1
1405
+NOISE_SIMPLEX = 2
1406
+NOISE_WAVELET = 4
1407
+
1408
+_NOISE_PACKER_FUNC = (None,
1409
+                      (c_float * 1),
1410
+                      (c_float * 2),
1411
+                      (c_float * 3),
1412
+                      (c_float * 4),
1413
+                      )
1414
+
1415
+def noise_new(dim, h=NOISE_DEFAULT_HURST, l=NOISE_DEFAULT_LACUNARITY, random=0):
1416
+    return _lib.TCOD_noise_new(dim, c_float(h), c_float(l), random)
1417
+
1418
+def noise_set_type(n, typ) :
1419
+    _lib.TCOD_noise_set_type(n,typ)
1420
+
1421
+def noise_get(n, f, typ=NOISE_DEFAULT):
1422
+    return _lib.TCOD_noise_get_ex(n, _NOISE_PACKER_FUNC[len(f)](*f), typ)
1423
+
1424
+def noise_get_fbm(n, f, oc, typ=NOISE_DEFAULT):
1425
+    return _lib.TCOD_noise_get_fbm_ex(n, _NOISE_PACKER_FUNC[len(f)](*f), c_float(oc), typ)
1426
+
1427
+def noise_get_turbulence(n, f, oc, typ=NOISE_DEFAULT):
1428
+    return _lib.TCOD_noise_get_turbulence_ex(n, _NOISE_PACKER_FUNC[len(f)](*f), c_float(oc), typ)
1429
+
1430
+def noise_delete(n):
1431
+    _lib.TCOD_noise_delete(n)
1432
+
1433
+############################
1434
+# fov module
1435
+############################
1436
+_lib.TCOD_map_is_in_fov.restype = c_bool
1437
+_lib.TCOD_map_is_transparent.restype = c_bool
1438
+_lib.TCOD_map_is_walkable.restype = c_bool
1439
+
1440
+FOV_BASIC = 0
1441
+FOV_DIAMOND = 1
1442
+FOV_SHADOW = 2
1443
+FOV_PERMISSIVE_0 = 3
1444
+FOV_PERMISSIVE_1 = 4
1445
+FOV_PERMISSIVE_2 = 5
1446
+FOV_PERMISSIVE_3 = 6
1447
+FOV_PERMISSIVE_4 = 7
1448
+FOV_PERMISSIVE_5 = 8
1449
+FOV_PERMISSIVE_6 = 9
1450
+FOV_PERMISSIVE_7 = 10
1451
+FOV_PERMISSIVE_8 = 11
1452
+FOV_RESTRICTIVE = 12
1453
+NB_FOV_ALGORITHMS = 13
1454
+
1455
+def FOV_PERMISSIVE(p) :
1456
+    return FOV_PERMISSIVE_0+p
1457
+
1458
+def map_new(w, h):
1459
+    return _lib.TCOD_map_new(w, h)
1460
+
1461
+def map_copy(source, dest):
1462
+    return _lib.TCOD_map_copy(source, dest)
1463
+
1464
+def map_set_properties(m, x, y, isTrans, isWalk):
1465
+    _lib.TCOD_map_set_properties(m, x, y, c_int(isTrans), c_int(isWalk))
1466
+
1467
+def map_clear(m,walkable=False,transparent=False):
1468
+    _lib.TCOD_map_clear(m,c_int(walkable),c_int(transparent))
1469
+
1470
+def map_compute_fov(m, x, y, radius=0, light_walls=True, algo=FOV_RESTRICTIVE ):
1471
+    _lib.TCOD_map_compute_fov(m, x, y, c_int(radius), c_bool(light_walls), c_int(algo))
1472
+
1473
+def map_is_in_fov(m, x, y):
1474
+    return _lib.TCOD_map_is_in_fov(m, x, y)
1475
+
1476
+def map_is_transparent(m, x, y):
1477
+    return _lib.TCOD_map_is_transparent(m, x, y)
1478
+
1479
+def map_is_walkable(m, x, y):
1480
+    return _lib.TCOD_map_is_walkable(m, x, y)
1481
+
1482
+def map_delete(m):
1483
+    return _lib.TCOD_map_delete(m)
1484
+
1485
+def map_get_width(map):
1486
+    return _lib.TCOD_map_get_width(map)
1487
+
1488
+def map_get_height(map):
1489
+    return _lib.TCOD_map_get_height(map)
1490
+
1491
+############################
1492
+# pathfinding module
1493
+############################
1494
+_lib.TCOD_path_compute.restype = c_bool
1495
+_lib.TCOD_path_is_empty.restype = c_bool
1496
+_lib.TCOD_path_walk.restype = c_bool
1497
+
1498
+PATH_CBK_FUNC = CFUNCTYPE(c_float, c_int, c_int, c_int, c_int, py_object)
1499
+
1500
+def path_new_using_map(m, dcost=1.41):
1501
+    return (_lib.TCOD_path_new_using_map(c_void_p(m), c_float(dcost)), None)
1502
+
1503
+def path_new_using_function(w, h, func, userdata=0, dcost=1.41):
1504
+    cbk_func = PATH_CBK_FUNC(func)
1505
+    return (_lib.TCOD_path_new_using_function(w, h, cbk_func,
1506
+            py_object(userdata), c_float(dcost)), cbk_func)
1507
+
1508
+def path_compute(p, ox, oy, dx, dy):
1509
+    return _lib.TCOD_path_compute(p[0], ox, oy, dx, dy)
1510
+
1511
+def path_get_origin(p):
1512
+    x = c_int()
1513
+    y = c_int()
1514
+    _lib.TCOD_path_get_origin(p[0], byref(x), byref(y))
1515
+    return x.value, y.value
1516
+
1517
+def path_get_destination(p):
1518
+    x = c_int()
1519
+    y = c_int()
1520
+    _lib.TCOD_path_get_destination(p[0], byref(x), byref(y))
1521
+    return x.value, y.value
1522
+
1523
+def path_size(p):
1524
+    return _lib.TCOD_path_size(p[0])
1525
+
1526
+def path_reverse(p):
1527
+    _lib.TCOD_path_reverse(p[0])  
1528
+
1529
+def path_get(p, idx):
1530
+    x = c_int()
1531
+    y = c_int()
1532
+    _lib.TCOD_path_get(p[0], idx, byref(x), byref(y))
1533
+    return x.value, y.value
1534
+
1535
+def path_is_empty(p):
1536
+    return _lib.TCOD_path_is_empty(p[0])
1537
+
1538
+def path_walk(p, recompute):
1539
+    x = c_int()
1540
+    y = c_int()
1541
+    if _lib.TCOD_path_walk(p[0], byref(x), byref(y), c_int(recompute)):
1542
+        return x.value, y.value
1543
+    return None,None
1544
+
1545
+def path_delete(p):
1546
+    _lib.TCOD_path_delete(p[0])
1547
+
1548
+_lib.TCOD_dijkstra_path_set.restype = c_bool
1549
+_lib.TCOD_dijkstra_is_empty.restype = c_bool
1550
+_lib.TCOD_dijkstra_path_walk.restype = c_bool
1551
+_lib.TCOD_dijkstra_get_distance.restype = c_float
1552
+
1553
+def dijkstra_new(m, dcost=1.41):
1554
+    return (_lib.TCOD_dijkstra_new(c_void_p(m), c_float(dcost)), None)
1555
+
1556
+def dijkstra_new_using_function(w, h, func, userdata=0, dcost=1.41):
1557
+    cbk_func = PATH_CBK_FUNC(func)
1558
+    return (_lib.TCOD_path_dijkstra_using_function(w, h, cbk_func,
1559
+            py_object(userdata), c_float(dcost)), cbk_func)
1560
+
1561
+def dijkstra_compute(p, ox, oy):
1562
+    _lib.TCOD_dijkstra_compute(p[0], c_int(ox), c_int(oy))
1563
+
1564
+def dijkstra_path_set(p, x, y):
1565
+    return _lib.TCOD_dijkstra_path_set(p[0], c_int(x), c_int(y))
1566
+
1567
+def dijkstra_get_distance(p, x, y):
1568
+    return _lib.TCOD_dijkstra_get_distance(p[0], c_int(x), c_int(y))
1569
+
1570
+def dijkstra_size(p):
1571
+    return _lib.TCOD_dijkstra_size(p[0])
1572
+
1573
+def dijkstra_reverse(p):
1574
+    _lib.TCOD_dijkstra_reverse(p[0])
1575
+
1576
+def dijkstra_get(p, idx):
1577
+    x = c_int()
1578
+    y = c_int()
1579
+    _lib.TCOD_dijkstra_get(p[0], c_int(idx), byref(x), byref(y))
1580
+    return x.value, y.value
1581
+
1582
+def dijkstra_is_empty(p):
1583
+    return _lib.TCOD_dijkstra_is_empty(p[0])
1584
+
1585
+def dijkstra_path_walk(p):
1586
+    x = c_int()
1587
+    y = c_int()
1588
+    if _lib.TCOD_dijkstra_path_walk(p[0], byref(x), byref(y)):
1589
+        return x.value, y.value
1590
+    return None,None
1591
+
1592
+def dijkstra_delete(p):
1593
+    _lib.TCOD_dijkstra_delete(p[0])
1594
+
1595
+############################
1596
+# bsp module
1597
+############################
1598
+class _CBsp(Structure):
1599
+    _fields_ = [('next', c_void_p),
1600
+                ('father', c_void_p),
1601
+                ('son', c_void_p),
1602
+                ('x', c_int),
1603
+                ('y', c_int),
1604
+                ('w', c_int),
1605
+                ('h', c_int),
1606
+                ('position', c_int),
1607
+                ('level', c_uint8),
1608
+                ('horizontal', c_bool),
1609
+                ]
1610
+
1611
+_lib.TCOD_bsp_new_with_size.restype = POINTER(_CBsp)
1612
+_lib.TCOD_bsp_left.restype = POINTER(_CBsp)
1613
+_lib.TCOD_bsp_right.restype = POINTER(_CBsp)
1614
+_lib.TCOD_bsp_father.restype = POINTER(_CBsp)
1615
+_lib.TCOD_bsp_is_leaf.restype = c_bool
1616
+_lib.TCOD_bsp_contains.restype = c_bool
1617
+_lib.TCOD_bsp_find_node.restype = POINTER(_CBsp)
1618
+
1619
+BSP_CBK_FUNC = CFUNCTYPE(c_int, c_void_p, c_void_p)
1620
+
1621
+# python class encapsulating the _CBsp pointer
1622
+class Bsp(object):
1623
+    def __init__(self, cnode):
1624
+        pcbsp = cast(cnode, POINTER(_CBsp))
1625
+        self.p = pcbsp
1626
+
1627
+    def getx(self):
1628
+        return self.p.contents.x
1629
+    def setx(self, value):
1630
+        self.p.contents.x = value
1631
+    x = property(getx, setx)
1632
+
1633
+    def gety(self):
1634
+        return self.p.contents.y
1635
+    def sety(self, value):
1636
+        self.p.contents.y = value
1637
+    y = property(gety, sety)
1638
+
1639
+    def getw(self):
1640
+        return self.p.contents.w
1641
+    def setw(self, value):
1642
+        self.p.contents.w = value
1643
+    w = property(getw, setw)
1644
+
1645
+    def geth(self):
1646
+        return self.p.contents.h
1647
+    def seth(self, value):
1648
+        self.p.contents.h = value
1649
+    h = property(geth, seth)
1650
+
1651
+    def getpos(self):
1652
+        return self.p.contents.position
1653
+    def setpos(self, value):
1654
+        self.p.contents.position = value
1655
+    position = property(getpos, setpos)
1656
+
1657
+    def gethor(self):
1658
+        return self.p.contents.horizontal
1659
+    def sethor(self,value):
1660
+        self.p.contents.horizontal = value
1661
+    horizontal = property(gethor, sethor)
1662
+
1663
+    def getlev(self):
1664
+        return self.p.contents.level
1665
+    def setlev(self,value):
1666
+        self.p.contents.level = value
1667
+    level = property(getlev, setlev)
1668
+
1669
+
1670
+def bsp_new_with_size(x, y, w, h):
1671
+    return Bsp(_lib.TCOD_bsp_new_with_size(x, y, w, h))
1672
+
1673
+def bsp_split_once(node, horizontal, position):
1674
+    _lib.TCOD_bsp_split_once(node.p, c_int(horizontal), position)
1675
+
1676
+def bsp_split_recursive(node, randomizer, nb, minHSize, minVSize, maxHRatio,
1677
+                        maxVRatio):
1678
+    _lib.TCOD_bsp_split_recursive(node.p, randomizer, nb, minHSize, minVSize,
1679
+                                  c_float(maxHRatio), c_float(maxVRatio))
1680
+
1681
+def bsp_resize(node, x, y, w, h):
1682
+    _lib.TCOD_bsp_resize(node.p, x, y, w, h)
1683
+
1684
+def bsp_left(node):
1685
+    return Bsp(_lib.TCOD_bsp_left(node.p))
1686
+
1687
+def bsp_right(node):
1688
+    return Bsp(_lib.TCOD_bsp_right(node.p))
1689
+
1690
+def bsp_father(node):
1691
+    return Bsp(_lib.TCOD_bsp_father(node.p))
1692
+
1693
+def bsp_is_leaf(node):
1694
+    return _lib.TCOD_bsp_is_leaf(node.p)
1695
+
1696
+def bsp_contains(node, cx, cy):
1697
+    return _lib.TCOD_bsp_contains(node.p, cx, cy)
1698
+
1699
+def bsp_find_node(node, cx, cy):
1700
+    return Bsp(_lib.TCOD_bsp_find_node(node.p, cx, cy))
1701
+
1702
+def _bsp_traverse(node, callback, userData, func):
1703
+    # convert the c node into a python node
1704
+    #before passing it to the actual callback
1705
+    def node_converter(cnode, data):
1706
+        node = Bsp(cnode)
1707
+        return callback(node, data)
1708
+    cbk_func = BSP_CBK_FUNC(node_converter)
1709
+    func(node.p, cbk_func, userData)
1710
+
1711
+def bsp_traverse_pre_order(node, callback, userData=0):
1712
+    _bsp_traverse(node, callback, userData, _lib.TCOD_bsp_traverse_pre_order)
1713
+
1714
+def bsp_traverse_in_order(node, callback, userData=0):
1715
+    _bsp_traverse(node, callback, userData, _lib.TCOD_bsp_traverse_in_order)
1716
+
1717
+def bsp_traverse_post_order(node, callback, userData=0):
1718
+    _bsp_traverse(node, callback, userData, _lib.TCOD_bsp_traverse_post_order)
1719
+
1720
+def bsp_traverse_level_order(node, callback, userData=0):
1721
+    _bsp_traverse(node, callback, userData, _lib.TCOD_bsp_traverse_level_order)
1722
+
1723
+def bsp_traverse_inverted_level_order(node, callback, userData=0):
1724
+    _bsp_traverse(node, callback, userData,
1725
+                  _lib.TCOD_bsp_traverse_inverted_level_order)
1726
+
1727
+def bsp_remove_sons(node):
1728
+    _lib.TCOD_bsp_remove_sons(node.p)
1729
+
1730
+def bsp_delete(node):
1731
+    _lib.TCOD_bsp_delete(node.p)
1732
+
1733
+############################
1734
+# heightmap module
1735
+############################
1736
+class _CHeightMap(Structure):
1737
+    _fields_=[('w', c_int),
1738
+              ('h', c_int),
1739
+              ('values', POINTER(c_float)),
1740
+              ]
1741
+
1742
+_lib.TCOD_heightmap_new.restype = POINTER(_CHeightMap)
1743
+_lib.TCOD_heightmap_get_value.restype = c_float
1744
+_lib.TCOD_heightmap_has_land_on_border.restype = c_bool
1745
+
1746
+class HeightMap(object):
1747
+    def __init__(self, chm):
1748
+        pchm = cast(chm, POINTER(_CHeightMap))
1749
+        self.p = pchm
1750
+
1751
+    def getw(self):
1752
+        return self.p.contents.w
1753
+    def setw(self, value):
1754
+        self.p.contents.w = value
1755
+    w = property(getw, setw)
1756
+
1757
+    def geth(self):
1758
+        return self.p.contents.h
1759
+    def seth(self, value):
1760
+        self.p.contents.h = value
1761
+    h = property(geth, seth)
1762
+
1763
+def heightmap_new(w, h):
1764
+    phm = _lib.TCOD_heightmap_new(w, h)
1765
+    return HeightMap(phm)
1766
+
1767
+def heightmap_set_value(hm, x, y, value):
1768
+    _lib.TCOD_heightmap_set_value(hm.p, x, y, c_float(value))
1769
+
1770
+def heightmap_add(hm, value):
1771
+    _lib.TCOD_heightmap_add(hm.p, c_float(value))
1772
+
1773
+def heightmap_scale(hm, value):
1774
+    _lib.TCOD_heightmap_scale(hm.p, c_float(value))
1775
+
1776
+def heightmap_clear(hm):
1777
+    _lib.TCOD_heightmap_clear(hm.p)
1778
+
1779
+def heightmap_clamp(hm, mi, ma):
1780
+    _lib.TCOD_heightmap_clamp(hm.p, c_float(mi),c_float(ma))
1781
+
1782
+def heightmap_copy(hm1, hm2):
1783
+    _lib.TCOD_heightmap_copy(hm1.p, hm2.p)
1784
+
1785
+def heightmap_normalize(hm,  mi=0.0, ma=1.0):
1786
+    _lib.TCOD_heightmap_normalize(hm.p, c_float(mi), c_float(ma))
1787
+
1788
+def heightmap_lerp_hm(hm1, hm2, hm3, coef):
1789
+    _lib.TCOD_heightmap_lerp_hm(hm1.p, hm2.p, hm3.p, c_float(coef))
1790
+
1791
+def heightmap_add_hm(hm1, hm2, hm3):
1792
+    _lib.TCOD_heightmap_add_hm(hm1.p, hm2.p, hm3.p)
1793
+
1794
+def heightmap_multiply_hm(hm1, hm2, hm3):
1795
+    _lib.TCOD_heightmap_multiply_hm(hm1.p, hm2.p, hm3.p)
1796
+
1797
+def heightmap_add_hill(hm, x, y, radius, height):
1798
+    _lib.TCOD_heightmap_add_hill(hm.p, c_float( x), c_float( y),
1799
+                                 c_float( radius), c_float( height))
1800
+
1801
+def heightmap_dig_hill(hm, x, y, radius, height):
1802
+    _lib.TCOD_heightmap_dig_hill(hm.p, c_float( x), c_float( y),
1803
+                                 c_float( radius), c_float( height))
1804
+
1805
+def heightmap_rain_erosion(hm, nbDrops, erosionCoef, sedimentationCoef, rnd=0):
1806
+    _lib.TCOD_heightmap_rain_erosion(hm.p, nbDrops, c_float( erosionCoef),
1807
+                                     c_float( sedimentationCoef), rnd)
1808
+
1809
+def heightmap_kernel_transform(hm, kernelsize, dx, dy, weight, minLevel,
1810
+                               maxLevel):
1811
+    FARRAY = c_float * kernelsize
1812
+    IARRAY = c_int * kernelsize
1813
+    cdx = IARRAY(*dx)
1814
+    cdy = IARRAY(*dy)
1815
+    cweight = FARRAY(*weight)
1816
+    _lib.TCOD_heightmap_kernel_transform(hm.p, kernelsize, cdx, cdy, cweight,
1817
+                                         c_float(minLevel), c_float(maxLevel))
1818
+
1819
+def heightmap_add_voronoi(hm, nbPoints, nbCoef, coef, rnd=0):
1820
+    FARRAY = c_float * nbCoef
1821
+    ccoef = FARRAY(*coef)
1822
+    _lib.TCOD_heightmap_add_voronoi(hm.p, nbPoints, nbCoef, ccoef, rnd)
1823
+
1824
+def heightmap_add_fbm(hm, noise, mulx, muly, addx, addy, octaves, delta, scale):
1825
+    _lib.TCOD_heightmap_add_fbm(hm.p, noise, c_float(mulx), c_float(muly),
1826
+                                c_float(addx), c_float(addy),
1827
+                                c_float(octaves), c_float(delta),
1828
+                                c_float(scale))
1829
+def heightmap_scale_fbm(hm, noise, mulx, muly, addx, addy, octaves, delta,
1830
+                        scale):
1831
+    _lib.TCOD_heightmap_scale_fbm(hm.p, noise, c_float(mulx), c_float(muly),
1832
+                                  c_float(addx), c_float(addy),
1833
+                                  c_float(octaves), c_float(delta),
1834
+                                  c_float(scale))
1835
+def heightmap_dig_bezier(hm, px, py, startRadius, startDepth, endRadius,
1836
+                         endDepth):
1837
+    IARRAY = c_int * 4
1838
+    cpx = IARRAY(*px)
1839
+    cpy = IARRAY(*py)
1840
+    _lib.TCOD_heightmap_dig_bezier(hm.p, cpx, cpy, c_float(startRadius),
1841
+                                   c_float(startDepth), c_float(endRadius),
1842
+                                   c_float(endDepth))
1843
+
1844
+def heightmap_get_value(hm, x, y):
1845
+    return _lib.TCOD_heightmap_get_value(hm.p, x, y)
1846
+
1847
+def heightmap_get_interpolated_value(hm, x, y):
1848
+    return _lib.TCOD_heightmap_get_interpolated_value(hm.p, c_float(x),
1849
+                                                     c_float(y))
1850
+
1851
+def heightmap_get_slope(hm, x, y):
1852
+    return _lib.TCOD_heightmap_get_slope(hm.p, x, y)
1853
+
1854
+def heightmap_get_normal(hm, x, y, waterLevel):
1855
+    FARRAY = c_float * 3
1856
+    cn = FARRAY()
1857
+    _lib.TCOD_heightmap_get_normal(hm.p, c_float(x), c_float(y), cn,
1858
+                                   c_float(waterLevel))
1859
+    return cn[0], cn[1], cn[2]
1860
+
1861
+def heightmap_count_cells(hm, mi, ma):
1862
+    return _lib.TCOD_heightmap_count_cells(hm.p, c_float(mi), c_float(ma))
1863
+
1864
+def heightmap_has_land_on_border(hm, waterlevel):
1865
+    return _lib.TCOD_heightmap_has_land_on_border(hm.p, c_float(waterlevel))
1866
+
1867
+def heightmap_get_minmax(hm):
1868
+    mi = c_float()
1869
+    ma = c_float()
1870
+    _lib.TCOD_heightmap_get_minmax(hm.p, byref(mi), byref(ma))
1871
+    return mi.value, ma.value
1872
+
1873
+def heightmap_delete(hm):
1874
+    _lib.TCOD_heightmap_delete(hm.p)
1875
+
1876
+
1877
+############################
1878
+# name generator module
1879
+############################
1880
+_lib.TCOD_namegen_generate.restype = c_char_p
1881
+_lib.TCOD_namegen_generate_custom.restype = c_char_p
1882
+
1883
+def namegen_parse(filename,random=0) :
1884
+    _lib.TCOD_namegen_parse(filename,random)
1885
+
1886
+def namegen_generate(name) :
1887
+    return _lib.TCOD_namegen_generate(name, 0)
1888
+
1889
+def namegen_generate_custom(name, rule) :
1890
+    return _lib.TCOD_namegen_generate(name, rule, 0)
1891
+
1892
+def namegen_get_sets():
1893
+    nb=_lib.TCOD_namegen_get_nb_sets_wrapper()
1894
+    SARRAY = c_char_p * nb;
1895
+    setsa = SARRAY()
1896
+    _lib.TCOD_namegen_get_sets_wrapper(setsa)
1897
+    return list(setsa)
1898
+
1899
+def namegen_destroy() :
1900
+    _lib.TCOD_namegen_destroy()
1901
+
1902
+