git.fiddlerwoaroof.com
edwlan authored on 26/07/2013 05:55:43
Showing 59 changed files
... ...
@@ -1,7 +1,5 @@
1 1
 *.py[cod]
2 2
 
3
-# C extensions
4
-*.so
5 3
 
6 4
 # Packages
7 5
 *.egg
8 6
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 100644
... ...
@@ -0,0 +1,55 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_BRESENHAM_H
29
+#define _TCOD_BRESENHAM_H
30
+
31
+typedef bool (*TCOD_line_listener_t) (int x, int y);
32
+
33
+TCODLIB_API void TCOD_line_init(int xFrom, int yFrom, int xTo, int yTo);
34
+TCODLIB_API bool TCOD_line_step(int *xCur, int *yCur); /* advance one step. returns true if we reach destination */
35
+/* atomic callback function. Stops when the callback returns false */
36
+TCODLIB_API bool TCOD_line(int xFrom, int yFrom, int xTo, int yTo, TCOD_line_listener_t listener);
37
+
38
+/* thread-safe versions */
39
+typedef struct {
40
+	int stepx;
41
+	int stepy;
42
+	int e;
43
+	int deltax;
44
+	int deltay;
45
+	int origx; 
46
+	int origy; 
47
+	int destx; 
48
+	int desty; 
49
+} TCOD_bresenham_data_t;
50
+
51
+TCODLIB_API void TCOD_line_init_mt(int xFrom, int yFrom, int xTo, int yTo, TCOD_bresenham_data_t *data);
52
+TCODLIB_API bool TCOD_line_step_mt(int *xCur, int *yCur, TCOD_bresenham_data_t *data);
53
+TCODLIB_API bool TCOD_line_mt(int xFrom, int yFrom, int xTo, int yTo, TCOD_line_listener_t listener, TCOD_bresenham_data_t *data);
54
+
55
+#endif
0 56
new file mode 100644
... ...
@@ -0,0 +1,138 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_BRESENHAM_HPP
29
+#define _TCOD_BRESENHAM_HPP
30
+class TCODLIB_API TCODLineListener {
31
+public :
32
+	virtual bool putPoint(int x,int y) = 0;
33
+	virtual ~TCODLineListener() {}
34
+};
35
+
36
+class TCODLIB_API TCODLine {
37
+public :
38
+	/**
39
+	@PageName line
40
+	@PageCategory Base toolkits
41
+	@PageTitle Line drawing toolkit
42
+	@PageDesc This toolkit is a very simple and lightweight implementation of the bresenham line drawing algorithm. It allows you to follow straight paths on your map very easily.
43
+	@FuncTitle Initializing the line
44
+	@FuncDesc First, you have to initialize the toolkit with your starting and ending coordinates.
45
+	@Cpp static void TCODLine::init (int xFrom, int yFrom, int xTo, int yTo)
46
+	@C void TCOD_line_init (int xFrom, int yFrom, int xTo, int yTo)
47
+	@Py line_init (xFrom, yFrom, xTo, yTo)
48
+	@C# static void TCODLine::init(int xFrom, int yFrom, int xTo, int yTo)
49
+	@Lua tcod.line.init(xFrom,yFrom, xTo,yTo)
50
+	@Param xFrom,yFrom Coordinates of the line's starting point.
51
+	@Param xTo,yTo Coordinates of the line's ending point.
52
+	*/
53
+	static void init(int xFrom, int yFrom, int xTo, int yTo);
54
+	
55
+	/**
56
+	@PageName line
57
+	@FuncTitle Walking the line
58
+	@FuncDesc You can then step through each cell with this function. It returns true when you reach the line's ending point.
59
+	@Cpp static bool TCODLine::step (int * xCur, int * yCur)
60
+	@C bool TCOD_line_step (int * xCur, int * yCur)
61
+	@Py line_step () # returns x,y or None,None if finished
62
+	@C# static bool TCODLine::step(ref int xCur, ref int yCur)
63
+	@Lua tcod.line.step(x,y) -- returns lineEnd,x,y
64
+	@Param xCur,yCur the coordinates of the next cell on the line are stored here when the function returns
65
+	@CppEx 
66
+		// Going from point 5,8 to point 13,4
67
+		int x = 5, y = 8;
68
+		TCODLine::init(x,y,13,4);
69
+		do {
70
+		    // update cell x,y
71
+		} while (!TCODLine::step(&x,&y));
72
+	@CEx 
73
+		int x = 5, y = 8;
74
+		TCOD_line_init(x,y,13,4);
75
+		do {
76
+		    // update cell x,y 
77
+		} while (!TCOD_line_step(&x,&y));
78
+	@PyEx 
79
+		libtcod.line_init(5,8,13,4)
80
+		# update cell 5,8
81
+		x,y=libtcod.line_step()
82
+		while (not x is None) :
83
+		    # update cell x,y
84
+		x,y=libtcod.line_step()
85
+	@LuaEx
86
+		x=5
87
+		y=8
88
+		tcod.line.init(x,y,13,4)
89
+		repeat
90
+			-- update cell x,y
91
+			lineEnd,x,y = tcod.line.step(x,y)
92
+		until lineEnd		
93
+	*/	
94
+	static bool step(int *xCur, int *yCur);
95
+
96
+	/**
97
+	@PageName line
98
+	@FuncTitle Callback-based function
99
+	@FuncDesc The function returns false if the line has been interrupted by the callback (it returned false before the last point).
100
+	@Cpp
101
+		class TCODLIB_API TCODLineListener {
102
+			virtual bool putPoint (int x, int y) = 0;
103
+		};
104
+		static bool TCODLine::line (int xFrom, int yFrom, int xTo, int yTo, TCODLineListener * listener)
105
+	@C
106
+		typedef bool (*TCOD_line_listener_t) (int x, int y);
107
+		bool TCOD_line(int xFrom, int yFrom, int xTo, int yTo, TCOD_line_listener_t listener)
108
+	@Py
109
+		def line_listener(x,y) : # ...
110
+		line(xFrom, yFrom, xTo, yTo, listener)
111
+	@C# static bool line(int xFrom, int yFrom, int xTo, int yTo, TCODLineListener listener)
112
+	@Param xFrom,yFrom	Coordinates of the line's starting point.
113
+	@Param xTo,yTo	Coordinates of the line's ending point.
114
+	@Param listener	Callback called for each line's point. The function stops if the callback returns false.
115
+	@CppEx // Going from point 5,8 to point 13,4
116
+class MyLineListener : public TCODLineListener {
117
+    public:
118
+    bool putPoint (int x,int y) {
119
+        printf ("%d %d\n",x,y);
120
+        return true;
121
+    }
122
+};
123
+MyLineListener myListener;
124
+TCODLine::line(5,8,13,4,&myListener);
125
+	@CEx bool my_listener(int x,int y) {
126
+    printf ("%d %d\n",x,y);
127
+    return true;
128
+}
129
+TCOD_line_line(5,8,13,4,my_listener);
130
+	@PyEx def my_listener(x,y):
131
+    print x,y
132
+    return True
133
+libtcod.line_line(5,8,13,4,my_listener)	 
134
+	*/
135
+	static bool line(int xFrom, int yFrom, int xTo, int yTo, TCODLineListener *listener);
136
+};
137
+
138
+#endif
0 139
new file mode 100644
... ...
@@ -0,0 +1,63 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_BSP_H
29
+#define _TCOD_BSP_H
30
+
31
+typedef struct {
32
+	TCOD_tree_t tree; /* pseudo oop : bsp inherit tree */
33
+	int x,y,w,h; /* node position & size */
34
+	int position; /* position of splitting */
35
+	uint8 level; /* level in the tree */
36
+	bool horizontal; /* horizontal splitting ? */
37
+} TCOD_bsp_t;
38
+
39
+typedef bool (*TCOD_bsp_callback_t)(TCOD_bsp_t *node, void *userData);
40
+
41
+TCODLIB_API TCOD_bsp_t *TCOD_bsp_new();
42
+TCODLIB_API TCOD_bsp_t *TCOD_bsp_new_with_size(int x,int y,int w, int h);
43
+TCODLIB_API void TCOD_bsp_delete(TCOD_bsp_t *node);
44
+
45
+TCODLIB_API TCOD_bsp_t * TCOD_bsp_left(TCOD_bsp_t *node);
46
+TCODLIB_API TCOD_bsp_t * TCOD_bsp_right(TCOD_bsp_t *node);
47
+TCODLIB_API TCOD_bsp_t * TCOD_bsp_father(TCOD_bsp_t *node);
48
+
49
+TCODLIB_API bool TCOD_bsp_is_leaf(TCOD_bsp_t *node);
50
+TCODLIB_API bool TCOD_bsp_traverse_pre_order(TCOD_bsp_t *node, TCOD_bsp_callback_t listener, void *userData);
51
+TCODLIB_API bool TCOD_bsp_traverse_in_order(TCOD_bsp_t *node, TCOD_bsp_callback_t listener, void *userData);
52
+TCODLIB_API bool TCOD_bsp_traverse_post_order(TCOD_bsp_t *node, TCOD_bsp_callback_t listener, void *userData);
53
+TCODLIB_API bool TCOD_bsp_traverse_level_order(TCOD_bsp_t *node, TCOD_bsp_callback_t listener, void *userData);
54
+TCODLIB_API bool TCOD_bsp_traverse_inverted_level_order(TCOD_bsp_t *node, TCOD_bsp_callback_t listener, void *userData);
55
+TCODLIB_API bool TCOD_bsp_contains(TCOD_bsp_t *node, int x, int y);
56
+TCODLIB_API TCOD_bsp_t * TCOD_bsp_find_node(TCOD_bsp_t *node, int x, int y);
57
+TCODLIB_API void TCOD_bsp_resize(TCOD_bsp_t *node, int x,int y, int w, int h);
58
+TCODLIB_API void TCOD_bsp_split_once(TCOD_bsp_t *node, bool horizontal, int position);
59
+TCODLIB_API void TCOD_bsp_split_recursive(TCOD_bsp_t *node, TCOD_random_t randomizer, int nb, 
60
+		int minHSize, int minVSize, float maxHRatio, float maxVRatio);
61
+TCODLIB_API void TCOD_bsp_remove_sons(TCOD_bsp_t *node);
62
+
63
+#endif
0 64
new file mode 100644
... ...
@@ -0,0 +1,406 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_BSP_HPP
29
+#define _TCOD_BSP_HPP
30
+
31
+class TCODBsp;
32
+
33
+class TCODLIB_API ITCODBspCallback {
34
+public :
35
+	virtual ~ITCODBspCallback() {}
36
+	virtual bool visitNode(TCODBsp *node, void *userData) = 0;
37
+};
38
+
39
+/**
40
+ @PageName bsp
41
+ @PageCategory Roguelike toolkits
42
+ @PageTitle BSP toolkit
43
+ @PageDesc This toolkit allows to create and manipulate 2D Binary Space Partition trees. They can be used to split a rectangular region into non overlapping sub-regions.
44
+ */
45
+
46
+class TCODLIB_API TCODBsp : public TCODTree {
47
+public :
48
+	int x,y,w,h; // 
49
+	int position; // position of splitting
50
+	bool horizontal; // horizontal splitting ?
51
+	uint8 level; // level in the tree 
52
+	
53
+	/**
54
+	@PageName bsp_init
55
+	@PageFather bsp
56
+	@PageTitle Creating a BSP tree
57
+	@FuncTitle Creating the root node
58
+	@FuncDesc First, you have to create the root node of the tree. This node encompasses the whole rectangular region.
59
+	@Cpp TCODBsp::TCODBsp(int x,int y,int w, int h)
60
+	@C TCOD_bsp_t *TCOD_bsp_new_with_size(int x,int y,int w, int h)
61
+	@Py bsp_new_with_size(x,y,w, h)
62
+	@C# TCODBsp::TCODBsp(int x, int y, int w, int h)
63
+	@Param x,y,w,h	Top left corner position and size of the rectangular region covered by the BSP tree.
64
+	@CppEx TCODBsp *myBSP = new TCODBsp(0,0,50,50);
65
+	@CEx TCOD_bsp_t *my_bsp=TCOD_bsp_new_with_size(0,0,50,50);
66
+	@PyEx my_bsp=libtcod.bsp_new_with_size(0,0,50,50)
67
+	*/
68
+	TCODBsp() : level(0) {}
69
+	TCODBsp(int x,int y,int w, int h) : x(x),y(y),w(w),h(h),level(0) {}
70
+
71
+	/**
72
+	@PageName bsp_init
73
+	@FuncTitle Deleting a part of the tree
74
+	@FuncDesc You can delete a part of the tree, releasing resources for all sub nodes with :
75
+	@Cpp void TCODBsp::removeSons()
76
+	@C void TCOD_bsp_remove_sons(TCOD_bsp_t *node)
77
+	@Py bsp_remove_sons(node)
78
+	@C# TCODBsp::removeSons()
79
+	@Param node	In the C version, the node reference.
80
+	@CppEx 
81
+		TCODBsp *myBSP = new TCODBsp(0,0,50,50);
82
+		// create a tree
83
+		myBSP->splitRecursive(NULL,4,5,5,1.5f,1.5f); 
84
+		// clear it (keep only the root)
85
+		myBSP->removeSons();
86
+		// and rebuild another random tree
87
+		myBSP->splitRecursive(NULL,4,5,5,1.5f,1.5f); 
88
+	@CEx 
89
+		TCOD_bsp_t *my_bsp=TCOD_bsp_new_with_size(0,0,50,50);
90
+		TCOD_bsp_split_recursive(my_bsp,NULL,4,5,5,1.5f,1.5f);
91
+		TCOD_bsp_remove_sons(my_bsp);
92
+		TCOD_bsp_split_recursive(my_bsp,NULL,4,5,5,1.5f,1.5f);
93
+	@PyEx 
94
+		my_bsp=libtcod.bsp_new_with_size(0,0,50,50)
95
+		libtcod.bsp_split_recursive(my_bsp,0,4,5,5,1.5,1.5)
96
+		libtcod.bsp_remove_sons(my_bsp)
97
+		libtcod.bsp_split_recursive(my_bsp,0,4,5,5,1.5,1.5)
98
+	*/
99
+	void removeSons();
100
+
101
+	/**
102
+	@PageName bsp_init
103
+	@FuncTitle deleting the tree
104
+	@FuncDesc You can also completely delete the tree, including the root node to release every resource used :
105
+	@Cpp void TCODBsp::~TCODBsp()
106
+	@C void TCOD_bsp_delete(TCOD_bsp_t *node)
107
+	@Py bsp_delete(node)
108
+	@C# void TCODBsp::Dispose()
109
+	@Param node	In the C version, the node reference.
110
+	@CppEx 
111
+		TCODBsp *myBSP = new TCODBsp(0,0,50,50);
112
+		// create a tree
113
+		myBSP->splitRecursive(NULL,4,5,5,1.5f,1.5f); 
114
+		// use the tree ...
115
+		// delete the tree
116
+		delete myBSP; 
117
+	@CEx 
118
+		TCOD_bsp_t *my_bsp=TCOD_bsp_new_with_size(0,0,50,50);
119
+		TCOD_bsp_split_recursive(my_bsp,NULL,4,5,5,1.5f,1.5f);
120
+		// use the tree ... 
121
+		TCOD_bsp_delete(my_bsp);
122
+	@PyEx 
123
+		my_bsp=libtcod.bsp_new_with_size(0,0,50,50)
124
+		libtcod.bsp_split_recursive(my_bsp,0,4,5,5,1.5,1.5)
125
+		# use the tree ...
126
+		libtcod.bsp_delete(my_bsp)
127
+	*/
128
+	virtual ~TCODBsp();
129
+
130
+	/**
131
+	@PageName bsp_split
132
+	@PageFather bsp
133
+	@PageTitle Splitting the tree
134
+	@FuncTitle Splitting a node once
135
+	@FuncDesc Once you have the root node, you can split it into two smaller non-overlapping nodes.
136
+	@Cpp void TCODBsp::splitOnce(bool horizontal, int position)
137
+	@C void TCOD_bsp_split_once(TCOD_bsp_t *node, bool horizontal, int position)
138
+	@Py bsp_split_once(node, horizontal, position)
139
+	@C# void TCODBsp::splitOnce(bool horizontal, int position)
140
+	@Param node	In the C version, the root node created with TCOD_bsp_new_with_size, or a node obtained by splitting.
141
+	@Param horizontal	If true, the node will be splitted horizontally, else, vertically.
142
+	@Param position	Coordinate of the splitting position.
143
+		If horizontal is true, x <= position < x+w
144
+		Else, y <= position < y+h
145
+	@CppEx 
146
+		TCODBsp *myBSP = new TCODBsp(0,0,50,50);
147
+		myBSP->splitOnce(true,20); // horizontal split into two nodes : (0,0,50,20) and (0,20,50,30)
148
+	@CEx 
149
+		TCOD_bsp_t *my_bsp=TCOD_bsp_new_with_size(0,0,50,50);
150
+		TCOD_bsp_split_once(my_bsp,false,20); // vertical split into two nodes : (0,0,20,50) and (20,0,30,50)
151
+	@PyEx 
152
+		my_bsp=libtcod.bsp_new_with_size(0,0,50,50)
153
+		libtcod.bsp_split_once(my_bsp,False,20) # vertical split into two nodes : (0,0,20,50) and (20,0,30,50)
154
+	*/
155
+	void splitOnce(bool horizontal, int position);
156
+
157
+	/**
158
+	@PageName bsp_split
159
+	@FuncTitle Recursively splitting a node
160
+	@FuncDesc You can also recursively split the bsp. At each step, a random orientation (horizontal/vertical) and position are choosen :
161
+	@Cpp void TCODBsp::splitRecursive(TCODRandom *randomizer, int nb, int minHSize, int minVSize, float maxHRatio, float maxVRatio);
162
+	@C void TCOD_bsp_split_recursive(TCOD_bsp_t *node, TCOD_random_t randomizer, int nb, int minHSize, int minVSize, float maxHRatio, float maxVRatio)
163
+	@Py bsp_split_recursive(node, randomizer, nb, minHSize, minVSize, maxHRatio, maxVRatio)
164
+	@C# void TCODBsp::splitRecursive(TCODRandom randomizer, int nb, int minHSize, int minVSize, float maxHRatio, float maxVRatio)
165
+	@Param node	In the C version, the root node created with TCOD_bsp_new_with_size, or a node obtained by splitting.
166
+	@Param randomizer	The random number generator to use. Use NULL for the default one.
167
+	@Param nb	Number of recursion levels.
168
+	@Param minHSize, minVSize	minimum values of w and h for a node. A node is splitted only if the resulting sub-nodes are bigger than minHSize x minVSize
169
+	@Param maxHRatio, maxVRation	maximum values of w/h and h/w for a node. If a node does not conform, the splitting orientation is forced to reduce either the w/h or the h/w ratio. Use values near 1.0 to promote square nodes.
170
+	@CppEx 
171
+		// Do a 4 levels BSP tree (the region is splitted into a maximum of 2*2*2*2 sub-regions).
172
+		TCODBsp *myBSP = new TCODBsp(0,0,50,50);
173
+		myBSP->splitRecursive(NULL,4,5,5,1.5f,1.5f); 
174
+	@CEx 
175
+		TCOD_bsp_t *my_bsp=TCOD_bsp_new_with_size(0,0,50,50);
176
+		TCOD_bsp_split_recursive(my_bsp,NULL,4,5,5,1.5f,1.5f);
177
+	@PyEx 
178
+		my_bsp=libtcod.bsp_new_with_size(0,0,50,50)
179
+		libtcod.bsp_split_recursive(my_bsp,0,4,5,5,1.5,1.5)
180
+	*/
181
+	void splitRecursive(TCODRandom *randomizer, int nb, int minHSize, int minVSize, float maxHRatio, float maxVRatio);
182
+
183
+	/**
184
+	@PageName bsp_resize
185
+	@PageTitle Resizing a tree
186
+	@PageFather bsp
187
+	@FuncDesc This operation resets the size of the tree nodes without changing the splitting data (orientation/position). It should be called with the initial region size or a bigger size, else some splitting position may be out of the region.
188
+You can use it if you changed the nodes size and position while using the BSP tree, which happens typically when you use the tree to build a dungeon. You create rooms inside the tree leafs, then shrink the leaf to fit the room size. Calling resize on the root node with the original region size allows you to reset all nodes to their original size.
189
+	@Cpp void TCODBsp::resize(int x,int y, int w, int h)
190
+	@C void TCOD_bsp_resize(TCOD_bsp_t *node, int x,int y, int w, int h)
191
+	@Py bsp_resize(node,  x,y, w, h)
192
+	@C# void TCODBsp::resize(int x, int y, int w, int h)
193
+	@Param node	In the C version, the root node created with TCOD_bsp_new_with_size, or a node obtained by splitting.
194
+	@Param x,y,w,h	New position and size of the node. The original rectangular area covered by the node should be included in the new one to ensure that every splitting edge stay inside its node.
195
+	@CppEx 
196
+		// We create a BSP, do some processing that will modify the x,y,w,h fields of the tree nodes, then reset all the nodes to their original size.
197
+		TCODBsp *myBSP = new TCODBsp(0,0,50,50);
198
+		myBSP->splitRecursive(NULL,4,5,5,1.5f,1.5f); 
199
+		// ... do something with the tree here
200
+		myBSP->resize(0,0,50,50);
201
+	@CEx 
202
+		TCOD_bsp_t *my_bsp=TCOD_bsp_new_with_size(0,0,50,50);
203
+		TCOD_bsp_split_recursive(my_bsp,NULL,4,5,5,1.5f,1.5f);
204
+		// ... do something with the tree here 
205
+		TCOD_bsp_resize(my_bsp,0,0,50,50);
206
+	@PyEx 
207
+		my_bsp=libtcod.bsp_new_with_size(0,0,50,50)
208
+		libtcod.bsp_split_recursive(my_bsp,0,4,5,5,1.5,1.5)
209
+		# ... do something with the tree here 
210
+		libtcod.bsp_resize(my_bsp,0,0,50,50)
211
+	*/
212
+	void resize(int x,int y, int w, int h);
213
+
214
+	/**
215
+	@PageName bsp_read
216
+	@PageFather bsp
217
+	@PageTitle Reading information from the tree
218
+	@FuncDesc Once you have built a BSP tree, you can retrieve information from any node. The node gives you free access to its fields :
219
+	@Cpp 
220
+		class TCODBsp {
221
+		public :
222
+			int x,y,w,h; // 
223
+			int position; // position of splitting
224
+			bool horizontal; // horizontal splitting ?
225
+			uint8 level; // level in the tree 
226
+			...
227
+		}
228
+	@C 
229
+		typedef struct {
230
+			int x,y,w,h;
231
+			int position;
232
+			bool horizontal;
233
+			uint8 level;
234
+			...
235
+		} TCOD_bsp_t;
236
+	@C# 
237
+		class TCODBsp
238
+		{
239
+		  public int x { get; set; }
240
+		  public int y { get; set; }
241
+		  public int h { get; set; }
242
+		  public int w { get; set; }
243
+		  public int position { get; set; }
244
+		  public bool horizontal { get; set; }
245
+		  public byte level { get; set; }
246
+		}
247
+	@Param x,y,w,h	Rectangular region covered by this node.
248
+	@Param position	If this node is not a leaf, splitting position.
249
+	@Param horizontal	If this node is not a leaf, splitting orientation.
250
+	@Param level	Level in the BSP tree (0 for the root, 1 for the root's sons, ...).
251
+	*/
252
+
253
+	/**
254
+	@PageName bsp_read
255
+	@FuncTitle Navigate in the tree
256
+	@FuncDesc You can navigate from a node to its sons or its parent using one of those functions. Each function returns NULL if the corresponding node does not exists (if the node is not splitted for getLeft and getRight, and if the node is the root node for getFather).
257
+	@Cpp 
258
+		TCODBsp *TCODBsp::getLeft() const
259
+		TCODBsp *TCODBsp::getRight() const
260
+		TCODBsp *TCODBsp::getFather() const
261
+	@C 
262
+		TCOD_bsp_t * TCOD_bsp_left(TCOD_bsp_t *node)
263
+		TCOD_bsp_t * TCOD_bsp_right(TCOD_bsp_t *node)
264
+		TCOD_bsp_t * TCOD_bsp_father(TCOD_bsp_t *node)
265
+	@Py 
266
+		bsp_left(node)
267
+		bsp_right(node)
268
+		bsp_father(node)
269
+	@C# 
270
+		TCODBsp TCODBsp::getLeft()
271
+		TCODBsp TCODBsp::getRight()
272
+		TCODBsp TCODBsp::getFather()
273
+	@Param node	In the C version, the node reference.
274
+	*/
275
+	TCODBsp *getLeft() const {
276
+		return (TCODBsp *)sons;
277
+	}
278
+	TCODBsp *getRight() const {
279
+		return sons ? (TCODBsp *)(sons->next) : NULL;
280
+	}
281
+	TCODBsp *getFather() const {
282
+		return (TCODBsp *)father;
283
+	}
284
+
285
+	/**
286
+	@PageName bsp_read
287
+	@FuncTitle Checking if a node is a leaf
288
+	@FuncDesc You can know if a node is a leaf (not splitted, no sons) with this function :
289
+	@Cpp bool TCODBsp::isLeaf() const
290
+	@C bool TCOD_bsp_is_leaf(TCOD_bsp_t *node)
291
+	@Py bsp_is_leaf(node)
292
+	@C# bool TCODBsp::isLeaf()
293
+	*/
294
+	bool isLeaf() const { return sons == NULL ; }
295
+
296
+	/**
297
+	@PageName bsp_read
298
+	@FuncTitle Check if a cell is inside a node
299
+	@FuncDesc You can check if a map cell is inside a node.
300
+	@Cpp bool TCODBsp::contains(int cx, int cy) const
301
+	@C bool TCOD_bsp_contains(TCOD_bsp_t *node, int cx, int cy)
302
+	@Py bsp_contains(node, cx, cy)
303
+	@C# bool TCODBsp::contains(int x, int y)
304
+	@Param node	In the C version, the node reference.
305
+	@Param cx,cy	Map cell coordinates.
306
+	*/
307
+	bool contains(int x, int y) const;
308
+
309
+	/**
310
+	@PageName bsp_read
311
+	@FuncTitle Getting the node containing a cell
312
+	@FuncDesc You can search the tree for the smallest node containing a map cell. If the cell is outside the tree, the function returns NULL :
313
+	@Cpp TCODBsp *TCODBsp::findNode(int cx, int cy)
314
+	@C TCOD_bsp_t * TCOD_bsp_find_node(TCOD_bsp_t *node, int cx, int cy)
315
+	@Py bsp_find_node(node, cx, cy)
316
+	@C# TCODBsp TCODBsp::findNode(int x, int y)
317
+	@Param node	In the C version, the node reference.
318
+	@Param cx,cy	Map cell coordinates.
319
+	*/
320
+	TCODBsp *findNode(int x, int y);
321
+
322
+	/**
323
+	@PageName bsp_traverse
324
+	@PageFather bsp
325
+	@PageTitle Traversing the tree
326
+	@FuncDesc You can scan all the nodes of the tree and have a custom function called back for each node.
327
+		Each traversal function returns false if the traversal has been interrupted (a callback returned false).
328
+		* Pre-order : the callback is called for the current node, then for the left son, then for the right son.
329
+		* In-order : the callback is called for the left son, then for current node, then for the right son.
330
+		* Post-order : the callback is called for the left son, then for the right son, then for the current node.
331
+		* Level-order : the callback is called for the nodes level by level, from left to right.
332
+		* Inverted level-order : the callback is called in the exact inverse order as Level-order.
333
+		<table class="param">
334
+		<tbody><tr><th>Pre order</th><th>In order</th><th>Post order</th><th>Level order</th><th>Inverted level<br>order</th></tr>
335
+		<tr><td><img src="bsp_preorder.png"></td><td><img src="bsp_inorder.png"></td><td><img src="bsp_postorder.png"></td><td><img src="bsp_levelorder.png"></td><td><img src="bsp_invlevelorder.png"></td></tr>
336
+		</tbody></table>
337
+	@Cpp 
338
+		class ITCODBspCallback {
339
+		public :
340
+			virtual bool visitNode(TCODBsp *node, void *userData) = 0;
341
+		};
342
+		
343
+		bool TCODBsp::traversePreOrder(ITCODBspCallback *callback, void *userData)
344
+		bool TCODBsp::traverseInOrder(ITCODBspCallback *callback, void *userData)
345
+		bool TCODBsp::traversePostOrder(ITCODBspCallback *callback, void *userData)
346
+		bool TCODBsp::traverseLevelOrder(ITCODBspCallback *callback, void *userData)
347
+		bool TCODBsp::traverseInvertedLevelOrder(ITCODBspCallback *callback, void *userData)
348
+	@C 
349
+		typedef bool (*TCOD_bsp_callback_t)(TCOD_bsp_t *node, void *userData)
350
+		
351
+		bool TCOD_bsp_traverse_pre_order(TCOD_bsp_t *node, TCOD_bsp_callback_t callback, void *userData)
352
+		bool TCOD_bsp_traverse_in_order(TCOD_bsp_t *node, TCOD_bsp_callback_t callback, void *userData)
353
+		bool TCOD_bsp_traverse_post_order(TCOD_bsp_t *node, TCOD_bsp_callback_t callback, void *userData)
354
+		bool TCOD_bsp_traverse_level_order(TCOD_bsp_t *node, TCOD_bsp_callback_t callback, void *userData)
355
+		bool TCOD_bsp_traverse_inverted_level_order(TCOD_bsp_t *node, TCOD_bsp_callback_t callback, void *userData)
356
+	@Py 
357
+		def bsp_callback(node, userData) : # ...
358
+		
359
+		bsp_traverse_pre_order(node, callback, userData=0)
360
+		bsp_traverse_in_order(node, callback, userData=0)
361
+		bsp_traverse_post_order(node, callback, userData=0)
362
+		bsp_traverse_level_order(node, callback, userData=0)
363
+		bsp_traverse_inverted_level_order(node, callback, userData=0)
364
+	@C#
365
+		bool TCODBsp::traversePreOrder(ITCODBspCallback callback)
366
+		bool TCODBsp::traverseInOrder(ITCODBspCallback callback)
367
+		bool TCODBsp::traversePostOrder(ITCODBspCallback callback)
368
+		bool TCODBsp::traverseLevelOrder(ITCODBspCallback callback)
369
+		bool TCODBsp::traverseInvertedLevelOrder(ITCODBspCallback callback)
370
+	@Param node	In the C version, the node reference (generally, the root node).
371
+	@Param callback	The function to call for each node.
372
+		It receives the current node and the custom data as parameters
373
+		If it returns false, the traversal is interrupted.
374
+	@Param userData	Custom data to pass to the callback.
375
+	@CppEx 
376
+		class MyCallback : public ITCODBspCallback {
377
+		public :
378
+			bool visitNode(TCODBsp *node, void *userData) {
379
+				printf("node pos %dx%d size %dx%d level %d\n",node->x,node->y,node->w,node->h,node->level);
380
+				return true;
381
+			}
382
+		};
383
+		myBSP->traversePostOrder(new MyListener(),NULL);
384
+	@CEx 
385
+		bool my_callback(TCOD_bsp_t *node, void *userData) {
386
+			printf("node pos %dx%d size %dx%d level %d\n",node->x,node->y,node->w,node->h,node->level);
387
+			return true;
388
+		}
389
+		TCOD_bsp_traverse_post_order(my_bsp,my_callback,NULL);
390
+	@PyEx 
391
+		def my_callback(node, userData) :
392
+			print "node pos %dx%d size %dx%d level %d"%(node.x,node.y,node.w,node.h,node.level))
393
+			return True
394
+		libtcod.bsp_traverse_post_order(my_bsp,my_callback)
395
+	*/
396
+	bool traversePreOrder(ITCODBspCallback *listener, void *userData);
397
+	bool traverseInOrder(ITCODBspCallback *listener, void *userData);
398
+	bool traversePostOrder(ITCODBspCallback *listener, void *userData);
399
+	bool traverseLevelOrder(ITCODBspCallback *listener, void *userData);
400
+	bool traverseInvertedLevelOrder(ITCODBspCallback *listener, void *userData);
401
+protected :
402
+	TCODBsp(TCODBsp *father, bool left);
403
+
404
+};
405
+
406
+#endif
0 407
new file mode 100644
... ...
@@ -0,0 +1,322 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_COLOR_H
29
+#define _TCOD_COLOR_H
30
+
31
+typedef struct {
32
+	uint8 r,g,b;
33
+} TCOD_color_t;
34
+
35
+/* constructors */
36
+TCODLIB_API TCOD_color_t TCOD_color_RGB(uint8 r, uint8 g, uint8 b);
37
+TCODLIB_API TCOD_color_t TCOD_color_HSV(float h, float s, float v);
38
+/* basic operations */
39
+TCODLIB_API bool TCOD_color_equals (TCOD_color_t c1, TCOD_color_t c2);
40
+TCODLIB_API TCOD_color_t TCOD_color_add (TCOD_color_t c1, TCOD_color_t c2);
41
+TCODLIB_API TCOD_color_t TCOD_color_subtract (TCOD_color_t c1, TCOD_color_t c2);
42
+TCODLIB_API TCOD_color_t TCOD_color_multiply (TCOD_color_t c1, TCOD_color_t c2);
43
+TCODLIB_API TCOD_color_t TCOD_color_multiply_scalar (TCOD_color_t c1, float value);
44
+TCODLIB_API TCOD_color_t TCOD_color_lerp (TCOD_color_t c1, TCOD_color_t c2, float coef);
45
+/* HSV transformations */
46
+TCODLIB_API void TCOD_color_set_HSV (TCOD_color_t *c,float h, float s, float v);
47
+TCODLIB_API void TCOD_color_get_HSV (TCOD_color_t c,float * h, float * s, float * v);
48
+TCODLIB_API float TCOD_color_get_hue (TCOD_color_t c);
49
+TCODLIB_API void TCOD_color_set_hue (TCOD_color_t *c, float h);
50
+TCODLIB_API float TCOD_color_get_saturation (TCOD_color_t c);
51
+TCODLIB_API void TCOD_color_set_saturation (TCOD_color_t *c, float s);
52
+TCODLIB_API float TCOD_color_get_value (TCOD_color_t c);
53
+TCODLIB_API void TCOD_color_set_value (TCOD_color_t *c, float v);
54
+TCODLIB_API void TCOD_color_shift_hue (TCOD_color_t *c, float hshift);
55
+TCODLIB_API void TCOD_color_scale_HSV (TCOD_color_t *c, float scoef, float vcoef);
56
+/* color map */
57
+TCODLIB_API void TCOD_color_gen_map(TCOD_color_t *map, int nb_key, TCOD_color_t const *key_color, int const *key_index);
58
+
59
+/* color names */
60
+enum {
61
+	TCOD_COLOR_RED,
62
+	TCOD_COLOR_FLAME,
63
+	TCOD_COLOR_ORANGE,
64
+	TCOD_COLOR_AMBER,
65
+	TCOD_COLOR_YELLOW,
66
+	TCOD_COLOR_LIME,
67
+	TCOD_COLOR_CHARTREUSE,
68
+	TCOD_COLOR_GREEN,
69
+	TCOD_COLOR_SEA,
70
+	TCOD_COLOR_TURQUOISE,
71
+	TCOD_COLOR_CYAN,
72
+	TCOD_COLOR_SKY,
73
+	TCOD_COLOR_AZURE,
74
+	TCOD_COLOR_BLUE,
75
+	TCOD_COLOR_HAN,
76
+	TCOD_COLOR_VIOLET,
77
+	TCOD_COLOR_PURPLE,
78
+	TCOD_COLOR_FUCHSIA,
79
+	TCOD_COLOR_MAGENTA,
80
+	TCOD_COLOR_PINK,
81
+	TCOD_COLOR_CRIMSON,
82
+	TCOD_COLOR_NB
83
+};
84
+
85
+/* color levels */
86
+enum {
87
+	TCOD_COLOR_DESATURATED,
88
+	TCOD_COLOR_LIGHTEST,
89
+	TCOD_COLOR_LIGHTER,
90
+	TCOD_COLOR_LIGHT,
91
+	TCOD_COLOR_NORMAL,
92
+	TCOD_COLOR_DARK,
93
+	TCOD_COLOR_DARKER,
94
+	TCOD_COLOR_DARKEST,
95
+	TCOD_COLOR_LEVELS
96
+};
97
+
98
+/* color array */
99
+extern TCODLIB_API const TCOD_color_t  TCOD_colors[TCOD_COLOR_NB][TCOD_COLOR_LEVELS];
100
+
101
+/* grey levels */
102
+extern TCODLIB_API const TCOD_color_t TCOD_black;
103
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_grey;
104
+extern TCODLIB_API const TCOD_color_t TCOD_darker_grey;
105
+extern TCODLIB_API const TCOD_color_t TCOD_dark_grey;
106
+extern TCODLIB_API const TCOD_color_t TCOD_grey;
107
+extern TCODLIB_API const TCOD_color_t TCOD_light_grey;
108
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_grey;
109
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_grey;
110
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_gray;
111
+extern TCODLIB_API const TCOD_color_t TCOD_darker_gray;
112
+extern TCODLIB_API const TCOD_color_t TCOD_dark_gray;
113
+extern TCODLIB_API const TCOD_color_t TCOD_gray;
114
+extern TCODLIB_API const TCOD_color_t TCOD_light_gray;
115
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_gray;
116
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_gray;
117
+extern TCODLIB_API const TCOD_color_t TCOD_white;
118
+
119
+/* sepia */
120
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_sepia;
121
+extern TCODLIB_API const TCOD_color_t TCOD_darker_sepia;
122
+extern TCODLIB_API const TCOD_color_t TCOD_dark_sepia;
123
+extern TCODLIB_API const TCOD_color_t TCOD_sepia;
124
+extern TCODLIB_API const TCOD_color_t TCOD_light_sepia;
125
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_sepia;
126
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_sepia;
127
+
128
+/* standard colors */
129
+extern TCODLIB_API const TCOD_color_t TCOD_red;
130
+extern TCODLIB_API const TCOD_color_t TCOD_flame;
131
+extern TCODLIB_API const TCOD_color_t TCOD_orange;
132
+extern TCODLIB_API const TCOD_color_t TCOD_amber;
133
+extern TCODLIB_API const TCOD_color_t TCOD_yellow;
134
+extern TCODLIB_API const TCOD_color_t TCOD_lime;
135
+extern TCODLIB_API const TCOD_color_t TCOD_chartreuse;
136
+extern TCODLIB_API const TCOD_color_t TCOD_green;
137
+extern TCODLIB_API const TCOD_color_t TCOD_sea;
138
+extern TCODLIB_API const TCOD_color_t TCOD_turquoise;
139
+extern TCODLIB_API const TCOD_color_t TCOD_cyan;
140
+extern TCODLIB_API const TCOD_color_t TCOD_sky;
141
+extern TCODLIB_API const TCOD_color_t TCOD_azure;
142
+extern TCODLIB_API const TCOD_color_t TCOD_blue;
143
+extern TCODLIB_API const TCOD_color_t TCOD_han;
144
+extern TCODLIB_API const TCOD_color_t TCOD_violet;
145
+extern TCODLIB_API const TCOD_color_t TCOD_purple;
146
+extern TCODLIB_API const TCOD_color_t TCOD_fuchsia;
147
+extern TCODLIB_API const TCOD_color_t TCOD_magenta;
148
+extern TCODLIB_API const TCOD_color_t TCOD_pink;
149
+extern TCODLIB_API const TCOD_color_t TCOD_crimson;
150
+
151
+/* dark colors */
152
+extern TCODLIB_API const TCOD_color_t TCOD_dark_red;
153
+extern TCODLIB_API const TCOD_color_t TCOD_dark_flame;
154
+extern TCODLIB_API const TCOD_color_t TCOD_dark_orange;
155
+extern TCODLIB_API const TCOD_color_t TCOD_dark_amber;
156
+extern TCODLIB_API const TCOD_color_t TCOD_dark_yellow;
157
+extern TCODLIB_API const TCOD_color_t TCOD_dark_lime;
158
+extern TCODLIB_API const TCOD_color_t TCOD_dark_chartreuse;
159
+extern TCODLIB_API const TCOD_color_t TCOD_dark_green;
160
+extern TCODLIB_API const TCOD_color_t TCOD_dark_sea;
161
+extern TCODLIB_API const TCOD_color_t TCOD_dark_turquoise;
162
+extern TCODLIB_API const TCOD_color_t TCOD_dark_cyan;
163
+extern TCODLIB_API const TCOD_color_t TCOD_dark_sky;
164
+extern TCODLIB_API const TCOD_color_t TCOD_dark_azure;
165
+extern TCODLIB_API const TCOD_color_t TCOD_dark_blue;
166
+extern TCODLIB_API const TCOD_color_t TCOD_dark_han;
167
+extern TCODLIB_API const TCOD_color_t TCOD_dark_violet;
168
+extern TCODLIB_API const TCOD_color_t TCOD_dark_purple;
169
+extern TCODLIB_API const TCOD_color_t TCOD_dark_fuchsia;
170
+extern TCODLIB_API const TCOD_color_t TCOD_dark_magenta;
171
+extern TCODLIB_API const TCOD_color_t TCOD_dark_pink;
172
+extern TCODLIB_API const TCOD_color_t TCOD_dark_crimson;
173
+
174
+/* darker colors */
175
+extern TCODLIB_API const TCOD_color_t TCOD_darker_red;
176
+extern TCODLIB_API const TCOD_color_t TCOD_darker_flame;
177
+extern TCODLIB_API const TCOD_color_t TCOD_darker_orange;
178
+extern TCODLIB_API const TCOD_color_t TCOD_darker_amber;
179
+extern TCODLIB_API const TCOD_color_t TCOD_darker_yellow;
180
+extern TCODLIB_API const TCOD_color_t TCOD_darker_lime;
181
+extern TCODLIB_API const TCOD_color_t TCOD_darker_chartreuse;
182
+extern TCODLIB_API const TCOD_color_t TCOD_darker_green;
183
+extern TCODLIB_API const TCOD_color_t TCOD_darker_sea;
184
+extern TCODLIB_API const TCOD_color_t TCOD_darker_turquoise;
185
+extern TCODLIB_API const TCOD_color_t TCOD_darker_cyan;
186
+extern TCODLIB_API const TCOD_color_t TCOD_darker_sky;
187
+extern TCODLIB_API const TCOD_color_t TCOD_darker_azure;
188
+extern TCODLIB_API const TCOD_color_t TCOD_darker_blue;
189
+extern TCODLIB_API const TCOD_color_t TCOD_darker_han;
190
+extern TCODLIB_API const TCOD_color_t TCOD_darker_violet;
191
+extern TCODLIB_API const TCOD_color_t TCOD_darker_purple;
192
+extern TCODLIB_API const TCOD_color_t TCOD_darker_fuchsia;
193
+extern TCODLIB_API const TCOD_color_t TCOD_darker_magenta;
194
+extern TCODLIB_API const TCOD_color_t TCOD_darker_pink;
195
+extern TCODLIB_API const TCOD_color_t TCOD_darker_crimson;
196
+
197
+/* darkest colors */
198
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_red;
199
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_flame;
200
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_orange;
201
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_amber;
202
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_yellow;
203
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_lime;
204
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_chartreuse;
205
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_green;
206
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_sea;
207
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_turquoise;
208
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_cyan;
209
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_sky;
210
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_azure;
211
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_blue;
212
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_han;
213
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_violet;
214
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_purple;
215
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_fuchsia;
216
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_magenta;
217
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_pink;
218
+extern TCODLIB_API const TCOD_color_t TCOD_darkest_crimson;
219
+
220
+/* light colors */
221
+extern TCODLIB_API const TCOD_color_t TCOD_light_red;
222
+extern TCODLIB_API const TCOD_color_t TCOD_light_flame;
223
+extern TCODLIB_API const TCOD_color_t TCOD_light_orange;
224
+extern TCODLIB_API const TCOD_color_t TCOD_light_amber;
225
+extern TCODLIB_API const TCOD_color_t TCOD_light_yellow;
226
+extern TCODLIB_API const TCOD_color_t TCOD_light_lime;
227
+extern TCODLIB_API const TCOD_color_t TCOD_light_chartreuse;
228
+extern TCODLIB_API const TCOD_color_t TCOD_light_green;
229
+extern TCODLIB_API const TCOD_color_t TCOD_light_sea;
230
+extern TCODLIB_API const TCOD_color_t TCOD_light_turquoise;
231
+extern TCODLIB_API const TCOD_color_t TCOD_light_cyan;
232
+extern TCODLIB_API const TCOD_color_t TCOD_light_sky;
233
+extern TCODLIB_API const TCOD_color_t TCOD_light_azure;
234
+extern TCODLIB_API const TCOD_color_t TCOD_light_blue;
235
+extern TCODLIB_API const TCOD_color_t TCOD_light_han;
236
+extern TCODLIB_API const TCOD_color_t TCOD_light_violet;
237
+extern TCODLIB_API const TCOD_color_t TCOD_light_purple;
238
+extern TCODLIB_API const TCOD_color_t TCOD_light_fuchsia;
239
+extern TCODLIB_API const TCOD_color_t TCOD_light_magenta;
240
+extern TCODLIB_API const TCOD_color_t TCOD_light_pink;
241
+extern TCODLIB_API const TCOD_color_t TCOD_light_crimson;
242
+
243
+/* lighter colors */
244
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_red;
245
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_flame;
246
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_orange;
247
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_amber;
248
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_yellow;
249
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_lime;
250
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_chartreuse;
251
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_green;
252
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_sea;
253
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_turquoise;
254
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_cyan;
255
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_sky;
256
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_azure;
257
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_blue;
258
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_han;
259
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_violet;
260
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_purple;
261
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_fuchsia;
262
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_magenta;
263
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_pink;
264
+extern TCODLIB_API const TCOD_color_t TCOD_lighter_crimson;
265
+
266
+/* lightest colors */
267
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_red;
268
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_flame;
269
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_orange;
270
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_amber;
271
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_yellow;
272
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_lime;
273
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_chartreuse;
274
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_green;
275
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_sea;
276
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_turquoise;
277
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_cyan;
278
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_sky;
279
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_azure;
280
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_blue;
281
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_han;
282
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_violet;
283
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_purple;
284
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_fuchsia;
285
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_magenta;
286
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_pink;
287
+extern TCODLIB_API const TCOD_color_t TCOD_lightest_crimson;
288
+
289
+/* desaturated */
290
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_red;
291
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_flame;
292
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_orange;
293
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_amber;
294
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_yellow;
295
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_lime;
296
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_chartreuse;
297
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_green;
298
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_sea;
299
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_turquoise;
300
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_cyan;
301
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_sky;
302
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_azure;
303
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_blue;
304
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_han;
305
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_violet;
306
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_purple;
307
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_fuchsia;
308
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_magenta;
309
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_pink;
310
+extern TCODLIB_API const TCOD_color_t TCOD_desaturated_crimson;
311
+
312
+/* metallic */
313
+extern TCODLIB_API const TCOD_color_t TCOD_brass;
314
+extern TCODLIB_API const TCOD_color_t TCOD_copper;
315
+extern TCODLIB_API const TCOD_color_t TCOD_gold;
316
+extern TCODLIB_API const TCOD_color_t TCOD_silver;
317
+
318
+/* miscellaneous */
319
+extern TCODLIB_API const TCOD_color_t TCOD_celadon;
320
+extern TCODLIB_API const TCOD_color_t TCOD_peach;
321
+
322
+#endif
0 323
new file mode 100644
... ...
@@ -0,0 +1,690 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_COLOR_HPP
29
+#define _TCOD_COLOR_HPP
30
+
31
+// color constants uses to generate @ColorTable
32
+/**
33
+	@ColorCategory STANDARD COLORS
34
+	@Color red 255,0,0
35
+	@Color flame 255,63,0
36
+	@Color orange 255,127,0
37
+	@Color amber 255,191,0
38
+	@Color yellow 255,255,0,
39
+	@Color lime 191,255,0
40
+	@Color chartreuse 127,255,0
41
+	@Color green 0,255,0
42
+	@Color sea 0,255,127
43
+	@Color turquoise 0,255,191
44
+	@Color cyan 0,255,255
45
+	@Color sky 0,191,255
46
+	@Color azure 0,127,255
47
+	@Color blue 0,0,255
48
+	@Color han 63,0,255
49
+	@Color violet 127,0,255
50
+	@Color purple 191,0,255
51
+	@Color fuchsia 255,0,255
52
+	@Color magenta 255,0,191
53
+	@Color pink 255,0,127
54
+	@Color crimson 255,0,63
55
+	@ColorCategory METALLIC COLORS
56
+	@Color brass 191,151,96
57
+	@Color copper 196,136,124
58
+	@Color gold 229,191,0
59
+	@Color silver 203,203,203
60
+	@ColorCategory MISCELLANEOUS COLORS
61
+	@Color celadon 172,255,175
62
+	@Color peach 255,159,127
63
+	@ColorCategory GREYSCALE & SEPIA
64
+	@Color grey 127,127,127
65
+	@Color sepia 127,101,63
66
+	@ColorCategory BLACK AND WHITE
67
+	@Color black 0,0,0
68
+	@Color white 255,255,255
69
+*/
70
+
71
+/**
72
+	@PageName color
73
+	@PageCategory Core
74
+	@PageTitle Colors
75
+	@PageDesc The Doryen library uses 32bits colors. Thus, your OS desktop must use 32bits colors.
76
+A color is defined by its red, green and blue component between 0 and 255.
77
+You can use the following predefined colors (hover over a color to see its full name and R,G,B values):
78
+	@ColorTable
79
+	@CppEx 
80
+		TCODColor::desaturatedRed
81
+		TCODColor::lightestRed
82
+		TCODColor::lighterRed
83
+		TCODColor::lightRed
84
+		TCODColor::red
85
+		TCODColor::darkRed
86
+		TCODColor::darkerRed
87
+		TCODColor::darkestRed
88
+	@CEx 
89
+		TCOD_desaturated_red
90
+		TCOD_lightest_red
91
+		TCOD_lighter_red
92
+		TCOD_light_red
93
+		TCOD_red
94
+		TCOD_dark_red
95
+		TCOD_darker_red
96
+		TCOD_darkest_red
97
+	@PyEx 
98
+		libtcod.desaturated_red
99
+		libtcod.lightest_red
100
+		libtcod.lighter_red
101
+		libtcod.light_red
102
+		libtcod.red
103
+		libtcod.dark_red
104
+		libtcod.darker_red
105
+		libtcod.darkest_red
106
+	@C#Ex 
107
+		TCODColor::desaturatedRed
108
+		TCODColor::lightestRed
109
+		TCODColor::lighterRed
110
+		TCODColor::lightRed
111
+		TCODColor::red
112
+		TCODColor::darkRed
113
+		TCODColor::darkerRed
114
+		TCODColor::darkestRed
115
+	@LuaEx
116
+		tcod.color.desaturatedRed
117
+		tcod.color.lightestRed
118
+		tcod.color.lighterRed
119
+		tcod.color.lightRed
120
+		tcod.color.red
121
+		tcod.color.darkRed
122
+		tcod.color.darkerRed
123
+		tcod.color.darkestRed
124
+ */
125
+
126
+class TCODLIB_API TCODColor {
127
+public :
128
+	uint8 r,g,b;
129
+
130
+	TCODColor() : r(0),g(0),b(0) {}
131
+	/**
132
+	@PageName color
133
+	@FuncTitle Create your own colors
134
+	@FuncDesc You can create your own colours using a set of constructors, both for RGB and HSV values.
135
+	@CppEx 
136
+		TCODColor myColor(24,64,255); //RGB
137
+		TCODColor myOtherColor(321.0f,0.7f,1.0f); //HSV
138
+	@CEx 
139
+		TCOD_color_t my_color={24,64,255}; <span>/</span>* RGB *<span>/</span>
140
+		TCOD_color_t my_other_color = TCOD_color_RGB(24,64,255); <span>/</span>* RGB too *<span>/</span>
141
+		TCOD_color_t my_yet_another_color = TCOD_color_HSV(321.0f,0.7f,1.0f); <span>/</span>* HSV *<span>/</span>
142
+	@PyEx my_color=libtcod.Color(24,64,255)
143
+	@C#Ex TCODColor myColor = new TCODColor(24,64,255); //RGB
144
+	     TCODColor myColor = new TCODColor(321.0f,0.7f,1.0f); //HSV
145
+	@LuaEx myColor = tcod.Color(24,24,255)
146
+	*/
147
+	TCODColor(uint8 r, uint8 g, uint8 b): r(r), g(g), b(b) {}
148
+	TCODColor(int r, int g, int b): r(r), g(g), b(b) {}
149
+	TCODColor(const TCOD_color_t &col): r(col.r), g(col.g), b(col.b) {}
150
+	TCODColor(float h, float s, float v);
151
+
152
+	/**
153
+	@PageName color
154
+	@FuncTitle Compare two colors
155
+	@CppEx 
156
+		if (myColor == TCODColor::yellow) { ... }
157
+		if (myColor != TCODColor::white) { ... }
158
+	@CEx 
159
+		if (TCOD_color_equals(my_color,TCOD_yellow)) { ... }
160
+		if (!TCOD_color_equals(my_color,TCOD_white)) { ... }
161
+	@PyEx 
162
+		if my_color == libtcod.yellow : ...
163
+		if my_color != litbcod.white : ...
164
+	@C#Ex 
165
+		if (myColor.Equal(TCODColor.yellow)) { ... }
166
+		if (myColor.NotEqual(TCODColor.white)) { ... }
167
+	@LuaEx 
168
+		if myColor == tcod.color.yellow then ... end
169
+	*/
170
+	bool operator == (const TCODColor & c) const {
171
+		return (c.r == r && c.g == g && c.b == b);
172
+	}
173
+	bool operator != (const TCODColor & c) const {
174
+		return (c.r != r || c.g != g || c.b != b);
175
+	}
176
+
177
+	/**
178
+	@PageName color
179
+	@FuncTitle Multiply two colors
180
+	@FuncDesc c1 = c2 * c3 =>
181
+    c1.r = c2.r * c3.r / 255
182
+    c1.g = c2.g * c3.g / 255
183
+    c1.b = c2.b * c3.b / 255
184
+	darkishRed = darkGrey * red
185
+<table><tr><td style="background-color: rgb(96, 0, 0); width: 60px; height: 30px;"></td><td style="background-color: rgb(96, 96, 96); width: 60px;"></td><td style="background-color: rgb(255, 0, 0); width: 60px;"></td></tr></table>
186
+	@CppEx TCODColor myDarkishRed = TCODColor::darkGrey * TCODColor::lightRed;
187
+	@CEx TCOD_color_t my_darkish_red = TCOD_color_multiply(TCOD_dark_grey, TCOD_light_red);
188
+	@PyEx my_darkish_red = libtcod.dark_grey * libtcod.light_red
189
+	@C#Ex TCODColor myDarkishRed = TCODColor.darkGrey.Multiply(TCODColor.lightRed);
190
+	@LuaEx myDarkishRed = tcod.color.darkGrey * tcod.color.lightRed
191
+	*/
192
+	TCODColor operator * (const TCODColor & a) const {
193
+		TCODColor ret;
194
+		ret.r=(uint8)(((int)r)*a.r/255);
195
+		ret.g=(uint8)(((int)g)*a.g/255);
196
+		ret.b=(uint8)(((int)b)*a.b/255);
197
+		return ret;
198
+	}
199
+
200
+	/**
201
+	@PageName color
202
+	@FuncTitle Multiply a color by a float
203
+	@FuncDesc c1 = c2 * v =>
204
+    c1.r = CLAMP(0, 255, c2.r * v)
205
+    c1.g = CLAMP(0, 255, c2.g * v)
206
+    c1.b = CLAMP(0, 255, c2.b * v)
207
+	darkishRed = red * 0.5
208
+<table><tr><td style="background-color: rgb(128, 0, 0); width: 60px; height: 30px;"></td><td style="background-color: rgb(255, 0, 0); width: 60px;"></td><td style="width: 60px;"></td></tr></table>
209
+</tbody>
210
+	@CppEx TCODColor myDarkishRed = TCODColor::lightRed * 0.5f;
211
+	@CEx TCOD_color_t my_darkish_red = TCOD_color_multiply_scalar(TCOD_light_red, 0.5f);
212
+	@PyEx myDarkishRed = litbcod.light_red * 0.5
213
+	@C#Ex TCODColor myDarkishRed = TCODColor.lightRed.Multiply(0.5f);
214
+	@LuaEx myDarkishRed = tcod.color.lightRed * 0.5
215
+	*/
216
+	TCODColor operator *(float value) const {
217
+		TCOD_color_t ret;
218
+		int r,g,b;
219
+		r = (int)(this->r * value);
220
+		g = (int)(this->g * value);
221
+		b = (int)(this->b * value);
222
+		r = CLAMP(0,255,r);
223
+		g = CLAMP(0,255,g);
224
+		b = CLAMP(0,255,b);
225
+		ret.r=(uint8)r;
226
+		ret.g=(uint8)g;
227
+		ret.b=(uint8)b;
228
+		return ret;
229
+	}
230
+
231
+	/**
232
+	@PageName color
233
+	@FuncTitle Adding two colors
234
+	@FuncDesc c1 = c1 + c2 => c1.r = MIN(255, c1.r + c2.r)
235
+                  c1.g = MIN(255, c1.g + c2.g)
236
+                  c1.b = MIN(255, c1.b + c2.b)
237
+	lightishRed = red + darkGrey
238
+<table><tr><td style="background-color: rgb(255, 128, 128); width: 60px; height: 30px;"></td><td style="background-color: rgb(255, 0, 0); width: 60px;"></td><td style="background-color: rgb(128, 128, 128); width: 60px;"></td></tr></table>
239
+	@CppEx TCODColor myLightishRed = TCODColor::red + TCODColor::darkGrey
240
+	@CEx TCOD_color_t my_lightish_red = TCOD_color_add(TCOD_red, TCOD_dark_grey);
241
+	@PyEx myLightishRed = libtcod.red + libtcod.dark_grey
242
+	@C#Ex TCODColor myLightishRed = TCODColor.red.Plus(TCODColor.darkGrey)
243
+	@LuaEx myLightishRed = tcod.color.red + tcod.color.darkGrey
244
+	*/
245
+	TCODColor operator + (const TCODColor & a) const {
246
+		TCODColor ret;
247
+		int r=(int)(this->r)+a.r;
248
+		int g=(int)(this->g)+a.g;
249
+		int b=(int)(this->b)+a.b;
250
+		r = MIN(255,r);
251
+		g = MIN(255,g);
252
+		b = MIN(255,b);
253
+		ret.r=(uint8)r;
254
+		ret.g=(uint8)g;
255
+		ret.b=(uint8)b;
256
+		return ret;
257
+	}
258
+
259
+	/**
260
+	@PageName color
261
+	@FuncTitle Subtract two colors
262
+	@FuncDesc  c1 = c1 - c2 => c1.r = MAX(0, c1.r - c2.r)
263
+                  c1.g = MAX(0, c1.g - c2.g)
264
+                  c1.b = MAX(0, c1.b - c2.b)
265
+	redish = red - darkGrey
266
+<table><tr><td style="background-color: rgb(127, 0, 0); width: 60px; height: 30px;"></td><td style="background-color: rgb(255, 0, 0); width: 60px;"></td><td style="background-color: rgb(128, 128, 128); width: 60px;"></td></tr></table>
267
+	@CppEx TCODColor myRedish = TCODColor::red - TCODColor::darkGrey
268
+	@CEx TCOD_color_t my_redish = TCOD_color_subtract(TCOD_red, TCOD_dark_grey);
269
+	@PyEx myRedish = libtcod.red - libtcod.dark_grey
270
+	@C#Ex TCODColor myRedish = TCODColor.red.Minus(TCODColor.darkGrey)
271
+	@LuaEx myRedish = tcod.color.red - tcod.color.darkGrey
272
+	*/
273
+	TCODColor operator - (const TCODColor & a) const {
274
+		TCODColor ret;
275
+		int r=(int)(this->r)-a.r;
276
+		int g=(int)(this->g)-a.g;
277
+		int b=(int)(this->b)-a.b;
278
+		r = MAX(0,r);
279
+		g = MAX(0,g);
280
+		b = MAX(0,b);
281
+		ret.r=(uint8)r;
282
+		ret.g=(uint8)g;
283
+		ret.b=(uint8)b;
284
+		return ret;
285
+	}
286
+
287
+	/**
288
+	@PageName color
289
+	@FuncTitle Interpolate between two colors
290
+	@FuncDesc   c1 = lerp (c2, c3, coef) => c1.r = c2.r  + (c3.r - c2.r ) * coef
291
+                              c1.g = c2.g  + (c3.g - c2.g ) * coef
292
+                              c1.b = c2.b  + (c3.b - c2.b ) * coef
293
+coef should be between 0.0 and 1.0 but you can as well use other values
294
+<table><tr><td style="background-color: rgb(96, 96, 96); color: rgb(255, 255, 255);" align="center">coef == 0.0f</td><td style="background-color: rgb(96, 96, 96); width: 60px;"></td><td style="background-color: rgb(255, 0, 0); width: 60px;"></td></tr>
295
+	<tr><td style="background-color: rgb(135, 72, 72); color: rgb(255, 255, 255);" align="center">coef == 0.25f</td><td style="background-color: rgb(96, 96, 96); width: 60px;"></td><td style="background-color: rgb(255, 0, 0); width: 60px;"></td></tr>
296
+	<tr><td style="background-color: rgb(175, 48, 48); color: rgb(255, 255, 255);" align="center">coef == 0.5f</td><td style="background-color: rgb(96, 96, 96); width: 60px;"></td><td style="background-color: rgb(255, 0, 0); width: 60px;"></td></tr>
297
+
298
+	<tr><td style="background-color: rgb(215, 24, 24); color: rgb(255, 255, 255);" align="center">coef == 0.75f</td><td style="background-color: rgb(96, 96, 96); width: 60px;"></td><td style="background-color: rgb(255, 0, 0); width: 60px;"></td></tr>
299
+	<tr><td style="background-color: rgb(255, 0, 0); color: rgb(255, 255, 255);" align="center">coef == 1.0f</td><td style="background-color: rgb(96, 96, 96); width: 60px;"></td><td style="background-color: rgb(255, 0, 0); width: 60px;"></td></tr></table>
300
+	@CppEx TCODColor myColor = TCODColor::lerp ( TCODColor::darkGrey, TCODColor::lightRed,coef );
301
+	@CEx TCOD_color_t my_color = TCOD_color_lerp ( TCOD_dark_grey, TCOD_light_red,coef);
302
+	@PyEx my_color = libtcod.color_lerp ( libtcod.dark_grey, litbcod.light_red,coef)
303
+	@C#Ex TCODColor myColor = TCODColor.Interpolate( TCODColor.darkGrey, TCODColor.lightRed, coef );
304
+	@LuaEx myColor = tcod.color.Interpolate( tcod.color.darkGrey, tcod.color.lightRed, coef )
305
+	*/
306
+	static TCODColor lerp(const TCODColor &a, const TCODColor &b, float coef) {
307
+		TCODColor ret;
308
+		ret.r=(uint8)(a.r+(b.r-a.r)*coef);
309
+		ret.g=(uint8)(a.g+(b.g-a.g)*coef);
310
+		ret.b=(uint8)(a.b+(b.b-a.b)*coef);
311
+		return ret;
312
+	}
313
+
314
+	/**
315
+	@PageName color
316
+	@FuncTitle Define a color by its hue, saturation and value
317
+	@FuncDesc After this function is called, the r,g,b fields of the color are calculated according to the h,s,v parameters.
318
+	@Cpp void TCODColor::setHSV(float h, float s, float v)
319
+	@C void TCOD_color_set_HSV(TCOD_color_t *c,float h, float s, float v)
320
+	@Py color_set_hsv(c,h,s,v)
321
+	@C# void TCODColor::setHSV(float h, float s, float v)
322
+	@Lua Color:setHSV( h, s ,v )
323
+	@Param c In the C and python versions, the color to modify
324
+	@Param h,s,v Color components in the HSV space
325
+		0.0 <= h < 360.0
326
+		0.0 <= s <= 1.0
327
+		0.0 <= v <= 1.0
328
+	*/
329
+	void setHSV(float h, float s, float v);
330
+
331
+	/**
332
+	@PageName color
333
+	@FuncTitle Define a color's hue, saturation or lightness
334
+	@FuncDesc These functions set only a single component in the HSV color space.
335
+	@Cpp 
336
+		void TCODColor::setHue (float h)
337
+		void TCODColor::setSaturation (float s)
338
+		void TCODColor::setValue (float v)
339
+	@C 
340
+		void TCOD_color_set_hue (TCOD_color_t *c, float h)
341
+		void TCOD_color_set_saturation (TCOD_color_t *c, float s)
342
+		void TCOD_color_set_value (TCOD_color_t *c, float v)
343
+	@Lua 
344
+		Color:setHue(h)
345
+		Color:setSaturation(s)
346
+		Color:setValue(v)
347
+	@Param h,s,v	Color components in the HSV space
348
+	@Param c	In the C and python versions, the color to modify
349
+	*/
350
+	void setHue (float h);
351
+	void setSaturation (float s);
352
+	void setValue (float v);
353
+
354
+	/**
355
+	@PageName color
356
+	@FuncTitle Get a color hue, saturation and value components
357
+	@Cpp void TCODColor::getHSV(float *h, float *s, float *v) const
358
+	@C void TCOD_color_get_HSV(TCOD_color_t c,float * h, float * s, float * v)
359
+	@Py color_get_HSV(c) # returns [h,s,v]
360
+	@C# void TCODColor::getHSV(out float h, out float s, out float v)
361
+	@Lua Color:getHSV() -- returns h,s,v
362
+	@Param c	In the C and python versions, the TCOD_color_t from which to read.
363
+	@Param  h,s,v	Color components in the HSV space
364
+		0.0 <= h < 360.0
365
+		0.0 <= s <= 1.0
366
+		0.0 <= v <= 1.0
367
+	*/
368
+	void getHSV(float *h, float *s, float *v) const;
369
+
370
+	/**
371
+	@PageName color
372
+	@FuncTitle Get a color's hue, saturation or value
373
+	@FuncDesc Should you need to extract only one of the HSV components, these functions are what you should call. Note that if you need all three values, it's way less burdensome for the CPU to call TCODColor::getHSV().
374
+	@Cpp 
375
+		float TCODColor::getHue ()
376
+		float TCODColor::getSaturation ()
377
+		float TCODColor::getValue ()
378
+	@C 
379
+		float TCOD_color_get_hue (TCOD_color_t c)
380
+		float TCOD_color_get_saturation (TCOD_color_t c)
381
+		float TCOD_color_get_value (TCOD_color_t c)
382
+	@Lua
383
+		Color:getHue()
384
+		Color:getSaturation()
385
+		Color:getValue()
386
+	@C#
387
+		float TCODColor::getHue()
388
+		float TCODColor::getSaturation()
389
+		float TCODColor::getValue()
390
+	@Param c	the TCOD_color_t from which to read
391
+	*/
392
+	float getHue ();
393
+	float getSaturation ();
394
+	float getValue ();
395
+
396
+	/**
397
+	@PageName color
398
+	@FuncTitle Shift a color's hue up or down
399
+	@FuncDesc The hue shift value is the number of grades the color's hue will be shifted. The value can be negative for shift left, or positive for shift right.
400
+		Resulting values H < 0 and H >= 360 are handled automatically.
401
+	@Cpp void TCODColor::shiftHue (float hshift)
402
+	@C void TCOD_color_shift_hue (TCOD_color_t *c, float hshift)
403
+	@C# TCODColor::shiftHue(float hshift)
404
+	@Lua Color:shiftHue(hshift)
405
+	@Param c	The color to modify
406
+	@Param hshift	The hue shift value
407
+	*/
408
+	void shiftHue (float hshift);
409
+
410
+	/**
411
+	@PageName color
412
+	@FuncTitle Scale a color's saturation and value
413
+	@Cpp void TCODColor::scaleHSV (float sscale, float vscale)
414
+	@C void TCOD_color_scale_HSV (TCOD_color_t *c, float scoef, float vcoef)
415
+	@Py color_scale_HSV(c, scoef, vcoef)
416
+	@C# TCODColor::scaleHSV (float sscale, float vscale)
417
+	@Lua Color:scaleHSV(sscale,vscale)
418
+	@Param c	The color to modify
419
+	@Param sscale	saturation multiplier (1.0f for no change)
420
+	@Param vscale	value multiplier (1.0f for no change)
421
+	*/
422
+	void scaleHSV (float sscale, float vscale);
423
+
424
+	/**
425
+	@PageName color
426
+	@FuncTitle Generate a smooth color map
427
+	@FuncDesc You can define a color map from an array of color keys. Colors will be interpolated between the keys.
428
+	0 -> black
429
+	4 -> red
430
+	8 -> white
431
+	Result :
432
+	<table>
433
+	<tbody><tr><td class="code"><pre>map[0]</pre></td><td style="background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); width: 50px;" align="center">&nbsp;</td><td>black</td></tr>
434
+
435
+	<tr><td class="code"><pre>map[1]</pre></td><td style="background-color: rgb(63, 0, 0); color: rgb(255, 255, 255); width: 50px;" align="center">&nbsp;</td></tr>
436
+	<tr><td class="code"><pre>map[2]</pre></td><td style="background-color: rgb(127, 0, 0); color: rgb(255, 255, 255); width: 50px;" align="center">&nbsp;</td></tr>
437
+	<tr><td class="code"><pre>map[3]</pre></td><td style="background-color: rgb(191, 0, 0); color: rgb(255, 255, 255); width: 50px;" align="center">&nbsp;</td></tr>
438
+	<tr><td class="code"><pre>map[4]</pre></td><td style="background-color: rgb(255, 0, 0); color: rgb(255, 255, 255); width: 50px;" align="center">&nbsp;</td><td>red</td></tr>
439
+	<tr><td class="code"><pre>map[5]</pre></td><td style="background-color: rgb(255, 63, 63); color: rgb(255, 255, 255); width: 50px;" align="center">&nbsp;</td></tr>
440
+	<tr><td class="code"><pre>map[6]</pre></td><td style="background-color: rgb(255, 127, 127); color: rgb(255, 255, 255); width: 50px;" align="center">&nbsp;</td></tr>
441
+
442
+	<tr><td class="code"><pre>map[7]</pre></td><td style="background-color: rgb(255, 191, 191); color: rgb(255, 255, 255); width: 50px;" align="center">&nbsp;</td></tr>
443
+	<tr><td class="code"><pre>map[8]</pre></td><td style="background-color: rgb(255, 255, 255); color: rgb(255, 255, 255); width: 50px;" align="center">&nbsp;</td><td>white</td></tr>
444
+</tbody></table>
445
+	@Cpp static void genMap(TCODColor *map, int nbKey, TCODColor const *keyColor, int const *keyIndex)
446
+	@C void TCOD_gen_map(TCOD_color_t *map, int nb_key, TCOD_color_t const *key_color, int const *key_index)
447
+	@Py color_gen_map(keyColor,keyIndex) # returns an array of colors
448
+	@Param map	An array of colors to be filled by the function.
449
+	@Param nbKey	Number of color keys
450
+	@Param keyColor	Array of nbKey colors containing the color of each key
451
+	@Param keyIndex	Array of nbKey integers containing the index of each key.
452
+		If you want to fill the map array, keyIndex[0] must be 0 and keyIndex[nbKey-1] is the number of elements in map minus 1 but you can also use the function to fill only a part of the map array.
453
+	@CppEx 
454
+		int idx[] = { 0, 4, 8 }; // indexes of the keys
455
+		TCODColor col[] = { TCODColor( 0,0,0 ), TCODColor(255,0,0), TCODColor(255,255,255) }; // colors : black, red, white
456
+		TCODColor map[9];
457
+		TCODColor::genMap(map,3,col,idx);
458
+	@CEx 
459
+		int idx[] = { 0, 4, 8 }; // indexes of the keys
460
+		TCOD_color_t col[] = { { 0,0,0 }, {255,0,0}, {255,255,255} }; // colors : black, red, white
461
+		TCOD_color_t map[9];
462
+		TCOD_color_gen_map(map,3,col,idx);
463
+	@PyEx 
464
+		idx = [ 0, 4, 8 ] # indexes of the keys
465
+		col = [ libtcod.Color( 0,0,0 ), libtcod.Color( 255,0,0 ), libtcod.Color(255,255,255) ] # colors : black, red, white
466
+		map=libtcod.color_gen_map(col,idx)
467
+	*/
468
+	static void genMap(TCODColor *map, int nbKey, TCODColor const *keyColor, int const *keyIndex);
469
+
470
+	// color array
471
+	static const TCODColor colors[TCOD_COLOR_NB][TCOD_COLOR_LEVELS];
472
+
473
+	// grey levels
474
+	static const TCODColor black;
475
+	static const TCODColor darkestGrey;
476
+	static const TCODColor darkerGrey;
477
+	static const TCODColor darkGrey;
478
+	static const TCODColor grey;
479
+	static const TCODColor lightGrey;
480
+	static const TCODColor lighterGrey;
481
+	static const TCODColor lightestGrey;
482
+	static const TCODColor white;
483
+
484
+	//sepia
485
+	static const TCODColor darkestSepia;
486
+	static const TCODColor darkerSepia;
487
+	static const TCODColor darkSepia;
488
+	static const TCODColor sepia;
489
+	static const TCODColor lightSepia;
490
+	static const TCODColor lighterSepia;
491
+	static const TCODColor lightestSepia;
492
+
493
+	// standard colors
494
+	static const TCODColor red;
495
+  static const TCODColor flame;
496
+  static const TCODColor orange;
497
+  static const TCODColor amber;
498
+  static const TCODColor yellow;
499
+  static const TCODColor lime;
500
+  static const TCODColor chartreuse;
501
+  static const TCODColor green;
502
+  static const TCODColor sea;
503
+  static const TCODColor turquoise;
504
+  static const TCODColor cyan;
505
+  static const TCODColor sky;
506
+  static const TCODColor azure;
507
+  static const TCODColor blue;
508
+  static const TCODColor han;
509
+  static const TCODColor violet;
510
+  static const TCODColor purple;
511
+  static const TCODColor fuchsia;
512
+  static const TCODColor magenta;
513
+  static const TCODColor pink;
514
+  static const TCODColor crimson;
515
+
516
+	// dark colors
517
+	static const TCODColor darkRed;
518
+  static const TCODColor darkFlame;
519
+  static const TCODColor darkOrange;
520
+  static const TCODColor darkAmber;
521
+  static const TCODColor darkYellow;
522
+  static const TCODColor darkLime;
523
+  static const TCODColor darkChartreuse;
524
+  static const TCODColor darkGreen;
525
+  static const TCODColor darkSea;
526
+  static const TCODColor darkTurquoise;
527
+  static const TCODColor darkCyan;
528
+  static const TCODColor darkSky;
529
+  static const TCODColor darkAzure;
530
+  static const TCODColor darkBlue;
531
+  static const TCODColor darkHan;
532
+  static const TCODColor darkViolet;
533
+  static const TCODColor darkPurple;
534
+  static const TCODColor darkFuchsia;
535
+  static const TCODColor darkMagenta;
536
+  static const TCODColor darkPink;
537
+  static const TCODColor darkCrimson;
538
+
539
+	// darker colors
540
+	static const TCODColor darkerRed;
541
+  static const TCODColor darkerFlame;
542
+  static const TCODColor darkerOrange;
543
+  static const TCODColor darkerAmber;
544
+  static const TCODColor darkerYellow;
545
+  static const TCODColor darkerLime;
546
+  static const TCODColor darkerChartreuse;
547
+  static const TCODColor darkerGreen;
548
+  static const TCODColor darkerSea;
549
+  static const TCODColor darkerTurquoise;
550
+  static const TCODColor darkerCyan;
551
+  static const TCODColor darkerSky;
552
+  static const TCODColor darkerAzure;
553
+  static const TCODColor darkerBlue;
554
+  static const TCODColor darkerHan;
555
+  static const TCODColor darkerViolet;
556
+  static const TCODColor darkerPurple;
557
+  static const TCODColor darkerFuchsia;
558
+  static const TCODColor darkerMagenta;
559
+  static const TCODColor darkerPink;
560
+  static const TCODColor darkerCrimson;
561
+
562
+  // darkest colors
563
+  static const TCODColor darkestRed;
564
+  static const TCODColor darkestFlame;
565
+  static const TCODColor darkestOrange;
566
+  static const TCODColor darkestAmber;
567
+  static const TCODColor darkestYellow;
568
+  static const TCODColor darkestLime;
569
+  static const TCODColor darkestChartreuse;
570
+  static const TCODColor darkestGreen;
571
+  static const TCODColor darkestSea;
572
+  static const TCODColor darkestTurquoise;
573
+  static const TCODColor darkestCyan;
574
+  static const TCODColor darkestSky;
575
+  static const TCODColor darkestAzure;
576
+  static const TCODColor darkestBlue;
577
+  static const TCODColor darkestHan;
578
+  static const TCODColor darkestViolet;
579
+  static const TCODColor darkestPurple;
580
+  static const TCODColor darkestFuchsia;
581
+  static const TCODColor darkestMagenta;
582
+  static const TCODColor darkestPink;
583
+  static const TCODColor darkestCrimson;
584
+
585
+	// light colors
586
+	static const TCODColor lightRed;
587
+  static const TCODColor lightFlame;
588
+  static const TCODColor lightOrange;
589
+  static const TCODColor lightAmber;
590
+  static const TCODColor lightYellow;
591
+  static const TCODColor lightLime;
592
+  static const TCODColor lightChartreuse;
593
+  static const TCODColor lightGreen;
594
+  static const TCODColor lightSea;
595
+  static const TCODColor lightTurquoise;
596
+  static const TCODColor lightCyan;
597
+  static const TCODColor lightSky;
598
+  static const TCODColor lightAzure;
599
+  static const TCODColor lightBlue;
600
+  static const TCODColor lightHan;
601
+  static const TCODColor lightViolet;
602
+  static const TCODColor lightPurple;
603
+  static const TCODColor lightFuchsia;
604
+  static const TCODColor lightMagenta;
605
+  static const TCODColor lightPink;
606
+  static const TCODColor lightCrimson;
607
+
608
+  //lighter colors
609
+  static const TCODColor lighterRed;
610
+  static const TCODColor lighterFlame;
611
+  static const TCODColor lighterOrange;
612
+  static const TCODColor lighterAmber;
613
+  static const TCODColor lighterYellow;
614
+  static const TCODColor lighterLime;
615
+  static const TCODColor lighterChartreuse;
616
+  static const TCODColor lighterGreen;
617
+  static const TCODColor lighterSea;
618
+  static const TCODColor lighterTurquoise;
619
+  static const TCODColor lighterCyan;
620
+  static const TCODColor lighterSky;
621
+  static const TCODColor lighterAzure;
622
+  static const TCODColor lighterBlue;
623
+  static const TCODColor lighterHan;
624
+  static const TCODColor lighterViolet;
625
+  static const TCODColor lighterPurple;
626
+  static const TCODColor lighterFuchsia;
627
+  static const TCODColor lighterMagenta;
628
+  static const TCODColor lighterPink;
629
+  static const TCODColor lighterCrimson;
630
+
631
+  // lightest colors
632
+  static const TCODColor lightestRed;
633
+  static const TCODColor lightestFlame;
634
+  static const TCODColor lightestOrange;
635
+  static const TCODColor lightestAmber;
636
+  static const TCODColor lightestYellow;
637
+  static const TCODColor lightestLime;
638
+  static const TCODColor lightestChartreuse;
639
+  static const TCODColor lightestGreen;
640
+  static const TCODColor lightestSea;
641
+  static const TCODColor lightestTurquoise;
642
+  static const TCODColor lightestCyan;
643
+  static const TCODColor lightestSky;
644
+  static const TCODColor lightestAzure;
645
+  static const TCODColor lightestBlue;
646
+  static const TCODColor lightestHan;
647
+  static const TCODColor lightestViolet;
648
+  static const TCODColor lightestPurple;
649
+  static const TCODColor lightestFuchsia;
650
+  static const TCODColor lightestMagenta;
651
+  static const TCODColor lightestPink;
652
+  static const TCODColor lightestCrimson;
653
+
654
+	// desaturated colors
655
+  static const TCODColor desaturatedRed;
656
+  static const TCODColor desaturatedFlame;
657
+  static const TCODColor desaturatedOrange;
658
+  static const TCODColor desaturatedAmber;
659
+  static const TCODColor desaturatedYellow;
660
+  static const TCODColor desaturatedLime;
661
+  static const TCODColor desaturatedChartreuse;
662
+  static const TCODColor desaturatedGreen;
663
+  static const TCODColor desaturatedSea;
664
+  static const TCODColor desaturatedTurquoise;
665
+  static const TCODColor desaturatedCyan;
666
+  static const TCODColor desaturatedSky;
667
+  static const TCODColor desaturatedAzure;
668
+  static const TCODColor desaturatedBlue;
669
+  static const TCODColor desaturatedHan;
670
+  static const TCODColor desaturatedViolet;
671
+  static const TCODColor desaturatedPurple;
672
+  static const TCODColor desaturatedFuchsia;
673
+  static const TCODColor desaturatedMagenta;
674
+  static const TCODColor desaturatedPink;
675
+  static const TCODColor desaturatedCrimson;
676
+
677
+	// metallic
678
+	static const TCODColor brass;
679
+	static const TCODColor copper;
680
+	static const TCODColor gold;
681
+	static const TCODColor silver;
682
+
683
+	// miscellaneous
684
+	static const TCODColor celadon;
685
+	static const TCODColor peach;
686
+};
687
+
688
+TCODLIB_API TCODColor operator *(float value, const TCODColor &c);
689
+
690
+#endif
0 691
new file mode 100644
... ...
@@ -0,0 +1,125 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_CONSOLE_H
29
+#define _TCOD_CONSOLE_H
30
+
31
+#include "console_types.h"
32
+
33
+#define TCOD_BKGND_ALPHA(alpha) ((TCOD_bkgnd_flag_t)(TCOD_BKGND_ALPH|(((uint8)(alpha*255))<<8)))
34
+#define TCOD_BKGND_ADDALPHA(alpha) ((TCOD_bkgnd_flag_t)(TCOD_BKGND_ADDA|(((uint8)(alpha*255))<<8)))
35
+
36
+typedef void * TCOD_console_t;
37
+
38
+TCODLIB_API void TCOD_console_init_root(int w, int h, const char * title, bool fullscreen, TCOD_renderer_t renderer);
39
+TCODLIB_API void TCOD_console_set_window_title(const char *title);
40
+TCODLIB_API void TCOD_console_set_fullscreen(bool fullscreen);
41
+TCODLIB_API bool TCOD_console_is_fullscreen();
42
+TCODLIB_API bool TCOD_console_is_window_closed();
43
+TCODLIB_API bool TCOD_console_has_mouse_focus();
44
+TCODLIB_API bool TCOD_console_is_active();
45
+
46
+TCODLIB_API void TCOD_console_set_custom_font(const char *fontFile, int flags,int nb_char_horiz, int nb_char_vertic);
47
+TCODLIB_API void TCOD_console_map_ascii_code_to_font(int asciiCode, int fontCharX, int fontCharY);
48
+TCODLIB_API void TCOD_console_map_ascii_codes_to_font(int asciiCode, int nbCodes, int fontCharX, int fontCharY);
49
+TCODLIB_API void TCOD_console_map_string_to_font(const char *s, int fontCharX, int fontCharY);
50
+
51
+TCODLIB_API void TCOD_console_set_dirty(int x, int y, int w, int h);
52
+TCODLIB_API void TCOD_console_set_default_background(TCOD_console_t con,TCOD_color_t col);
53
+TCODLIB_API void TCOD_console_set_default_foreground(TCOD_console_t con,TCOD_color_t col);
54
+TCODLIB_API void TCOD_console_clear(TCOD_console_t con);
55
+TCODLIB_API void TCOD_console_set_char_background(TCOD_console_t con,int x, int y, TCOD_color_t col, TCOD_bkgnd_flag_t flag);
56
+TCODLIB_API void TCOD_console_set_char_foreground(TCOD_console_t con,int x, int y, TCOD_color_t col);
57
+TCODLIB_API void TCOD_console_set_char(TCOD_console_t con,int x, int y, int c);
58
+TCODLIB_API void TCOD_console_put_char(TCOD_console_t con,int x, int y, int c, TCOD_bkgnd_flag_t flag);
59
+TCODLIB_API void TCOD_console_put_char_ex(TCOD_console_t con,int x, int y, int c, TCOD_color_t fore, TCOD_color_t back);
60
+
61
+TCODLIB_API void TCOD_console_set_background_flag(TCOD_console_t con,TCOD_bkgnd_flag_t flag);
62
+TCODLIB_API TCOD_bkgnd_flag_t TCOD_console_get_background_flag(TCOD_console_t con);
63
+TCODLIB_API void TCOD_console_set_alignment(TCOD_console_t con,TCOD_alignment_t alignment);
64
+TCODLIB_API TCOD_alignment_t TCOD_console_get_alignment(TCOD_console_t con);
65
+TCODLIB_API void TCOD_console_print(TCOD_console_t con,int x, int y, const char *fmt, ...);
66
+TCODLIB_API void TCOD_console_print_ex(TCOD_console_t con,int x, int y, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt, ...);
67
+TCODLIB_API int TCOD_console_print_rect(TCOD_console_t con,int x, int y, int w, int h, const char *fmt, ...);
68
+TCODLIB_API int TCOD_console_print_rect_ex(TCOD_console_t con,int x, int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt, ...);
69
+TCODLIB_API int TCOD_console_get_height_rect(TCOD_console_t con,int x, int y, int w, int h, const char *fmt, ...);
70
+
71
+TCODLIB_API void TCOD_console_rect(TCOD_console_t con,int x, int y, int w, int h, bool clear, TCOD_bkgnd_flag_t flag);
72
+TCODLIB_API void TCOD_console_hline(TCOD_console_t con,int x,int y, int l, TCOD_bkgnd_flag_t flag);
73
+TCODLIB_API void TCOD_console_vline(TCOD_console_t con,int x,int y, int l, TCOD_bkgnd_flag_t flag);
74
+TCODLIB_API void TCOD_console_print_frame(TCOD_console_t con,int x,int y,int w,int h, bool empty, TCOD_bkgnd_flag_t flag, const char *fmt, ...);
75
+
76
+#ifndef NO_UNICODE
77
+/* unicode support */
78
+TCODLIB_API void TCOD_console_map_string_to_font_utf(const wchar_t *s, int fontCharX, int fontCharY);
79
+TCODLIB_API void TCOD_console_print_utf(TCOD_console_t con,int x, int y, const wchar_t *fmt, ...);
80
+TCODLIB_API void TCOD_console_print_ex_utf(TCOD_console_t con,int x, int y, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const wchar_t *fmt, ...);
81
+TCODLIB_API int TCOD_console_print_rect_utf(TCOD_console_t con,int x, int y, int w, int h, const wchar_t *fmt, ...);
82
+TCODLIB_API int TCOD_console_print_rect_ex_utf(TCOD_console_t con,int x, int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const wchar_t *fmt, ...);
83
+TCODLIB_API int TCOD_console_get_height_rect_utf(TCOD_console_t con,int x, int y, int w, int h, const wchar_t *fmt, ...);
84
+#endif
85
+
86
+
87
+TCODLIB_API TCOD_color_t TCOD_console_get_default_background(TCOD_console_t con);
88
+TCODLIB_API TCOD_color_t TCOD_console_get_default_foreground(TCOD_console_t con);
89
+TCODLIB_API TCOD_color_t TCOD_console_get_char_background(TCOD_console_t con,int x, int y);
90
+TCODLIB_API TCOD_color_t TCOD_console_get_char_foreground(TCOD_console_t con,int x, int y);
91
+TCODLIB_API int TCOD_console_get_char(TCOD_console_t con,int x, int y);
92
+
93
+TCODLIB_API void TCOD_console_set_fade(uint8 val, TCOD_color_t fade);
94
+TCODLIB_API uint8 TCOD_console_get_fade();
95
+TCODLIB_API TCOD_color_t TCOD_console_get_fading_color();
96
+
97
+TCODLIB_API void TCOD_console_flush();
98
+
99
+TCODLIB_API void TCOD_console_set_color_control(TCOD_colctrl_t con, TCOD_color_t fore, TCOD_color_t back);
100
+
101
+TCODLIB_API TCOD_key_t TCOD_console_check_for_keypress(int flags);
102
+TCODLIB_API TCOD_key_t TCOD_console_wait_for_keypress(bool flush);
103
+TCODLIB_API void TCOD_console_set_keyboard_repeat(int initial_delay, int interval);
104
+TCODLIB_API void TCOD_console_disable_keyboard_repeat();
105
+TCODLIB_API bool TCOD_console_is_key_pressed(TCOD_keycode_t key);
106
+
107
+/* ASCII paint file support */
108
+TCODLIB_API TCOD_console_t TCOD_console_from_file(const char *filename);
109
+TCODLIB_API bool TCOD_console_load_asc(TCOD_console_t con, const char *filename);
110
+TCODLIB_API bool TCOD_console_load_apf(TCOD_console_t con, const char *filename);
111
+TCODLIB_API bool TCOD_console_save_asc(TCOD_console_t con, const char *filename);
112
+TCODLIB_API bool TCOD_console_save_apf(TCOD_console_t con, const char *filename);
113
+
114
+TCODLIB_API TCOD_console_t TCOD_console_new(int w, int h);
115
+TCODLIB_API int TCOD_console_get_width(TCOD_console_t con);
116
+TCODLIB_API int TCOD_console_get_height(TCOD_console_t con);
117
+TCODLIB_API void TCOD_console_set_key_color(TCOD_console_t con,TCOD_color_t col);
118
+TCODLIB_API void TCOD_console_blit(TCOD_console_t src,int xSrc, int ySrc, int wSrc, int hSrc, TCOD_console_t dst, int xDst, int yDst, float foreground_alpha, float background_alpha);
119
+TCODLIB_API void TCOD_console_delete(TCOD_console_t console);
120
+
121
+TCODLIB_API void TCOD_console_credits();
122
+TCODLIB_API void TCOD_console_credits_reset();
123
+TCODLIB_API bool TCOD_console_credits_render(int x, int y, bool alpha);
124
+
125
+#endif
0 126
new file mode 100644
... ...
@@ -0,0 +1,1770 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_CONSOLE_HPP
29
+#define _TCOD_CONSOLE_HPP
30
+
31
+#include "console_types.h"
32
+
33
+/**
34
+	@PageName console
35
+	@PageCategory Core
36
+	@PageTitle Console
37
+	@PageDesc The console emulator handles the rendering of the game screen and the keyboard input.
38
+Classic real time game loop:
39
+	@Cpp
40
+		TCODConsole::initRoot(80,50,"my game",false);
41
+		TCODSystem::setFps(25); // limit framerate to 25 frames per second
42
+		while (!endGame && !TCODConsole::isWindowClosed()) {
43
+			TCOD_key_t key;
44
+			TCODSystem::checkForEvent(TCOD_EVENT_KEY_PRESS,&key,NULL);
45
+			updateWorld (key, TCODSystem::getLastFrameLength());
46
+			// updateWorld(TCOD_key_t key, float elapsed) (using key if key.vk != TCODK_NONE)
47
+			// use elapsed to scale any update that is time dependant.
48
+			// ... draw world+GUI on TCODConsole::root
49
+			TCODConsole::flush();
50
+		}
51
+	@Lua
52
+		tcod.console.initRoot(80,50,"my game", false)
53
+		root=libtcod.TCODConsole_root
54
+		tcod.system.setFps(25)
55
+		while not tcod.console.isWindowClosed() do
56
+			-- ... draw on root
57
+			tcod.console.flush()
58
+			key=tcod.console.checkForKeypress()
59
+			-- ... update world, using key and tcod.system.getLastFrameLength
60
+		end
61
+
62
+*/
63
+/**
64
+	@PageName console
65
+	@FuncDesc Classic turn by turn game loop:
66
+	@Cpp
67
+		TCODConsole::initRoot(80,50,"my game",false);
68
+		while (!endGame && !TCODConsole::isWindowClosed()) {
69
+			// ... draw on TCODConsole::root
70
+			TCODConsole::flush();
71
+			TCOD_key_t key;
72
+			TCODConsole::waitForEvent(TCOD_EVENT_KEY_PRESS,&key,NULL,true);
73
+			//... update world, using key
74
+		}
75
+*/
76
+
77
+class TCODLIB_API TCODConsole {
78
+public :
79
+	/**
80
+	@PageName console_init
81
+	@PageTitle Initializing the console
82
+	@PageFather console
83
+	*/
84
+
85
+	static TCODConsole *root;
86
+
87
+	/**
88
+	@PageName console_init_root
89
+	@PageTitle Creating the game window
90
+	@PageFather console_init
91
+	@Cpp static void TCODConsole::initRoot (int w, int h, const char * title, bool fullscreen = false, TCOD_renderer_t renderer = TCOD_RENDERER_SDL)
92
+	@C void TCOD_console_init_root (int w, int h, const char * title, bool fullscreen, TCOD_renderer_t renderer)
93
+	@Py console_init_root (w, h, title, fullscreen = False, renderer = RENDERER_SDL)
94
+	@C#
95
+		static void TCODConsole::initRoot(int w, int h, string title)
96
+		static void TCODConsole::initRoot(int w, int h, string title, bool fullscreen)
97
+		static void TCODConsole::initRoot(int w, int h, string title, bool fullscreen, TCODRendererType renderer)
98
+	@Lua
99
+		tcod.console.initRoot(w,h,title) -- fullscreen = false, renderer = SDL
100
+		tcod.console.initRoot(w,h,title,fullscreen) -- renderer = SDL
101
+		tcod.console.initRoot(w,h,title,fullscreen,renderer)
102
+		-- renderers : tcod.GLSL, tcod.OpenGL, tcod.SDL
103
+	@Param w,h size of the console(in characters). The default font in libtcod (./terminal.png) uses 8x8 pixels characters.
104
+		You can change the font by calling TCODConsole::setCustomFont before calling initRoot.
105
+	@Param title title of the window. It's not visible when you are in fullscreen.
106
+		Note 1 : you can dynamically change the window title with TCODConsole::setWindowTitle
107
+	@Param fullscreen wether you start in windowed or fullscreen mode.
108
+		Note 1 : you can dynamically change this mode with TCODConsole::setFullscreen
109
+		Note 2 : you can get current mode with TCODConsole::isFullscreen
110
+	@Param renderer which renderer to use. Possible values are :
111
+    * TCOD_RENDERER_GLSL : works only on video cards with pixel shaders
112
+    * TCOD_RENDERER_OPENGL : works on all video cards supporting OpenGL 1.4
113
+    * TCOD_RENDERER_SDL : should work everywhere!
114
+		Note 1: if you select a renderer that is not supported by the player's machine, libtcod scan the lower renderers until it finds a working one.
115
+		Note 2: on recent video cards, GLSL results in up to 900% increase of framerates in the true color sample compared to SDL renderer.
116
+		Note 3: whatever renderer you use, it can always be overriden by the player through the libtcod.cfg file.
117
+		Note 4: you can dynamically change the renderer after calling initRoot with TCODSystem::setRenderer.
118
+		Note 5: you can get current renderer with TCODSystem::getRenderer. It might be different from the one you set in initRoot in case it's not supported on the player's computer.
119
+	@CppEx TCODConsole::initRoot(80, 50, "The Chronicles Of Doryen v0.1");
120
+	@CEx TCOD_console_init_root(80, 50, "The Chronicles Of Doryen v0.1", false, TCOD_RENDERER_OPENGL);
121
+	@PyEx libtcod.console_init_root(80, 50, 'The Chronicles Of Doryen v0.1')
122
+	@LuaEx tcod.console.initRoot(80,50,"The Chronicles Of Doryen v0.1")
123
+	*/
124
+	static void initRoot(int w, int h, const char * title, bool fullscreen = false, TCOD_renderer_t renderer=TCOD_RENDERER_SDL);
125
+
126
+	/**
127
+	@PageName console_set_custom_font
128
+	@PageTitle Using a custom bitmap font
129
+	@PageFather console_init
130
+	@FuncTitle setCustomFont
131
+	@FuncDesc This function allows you to use a bitmap font (png or bmp) with custom character size or layout.
132
+		It should be called before initializing the root console with initRoot.
133
+		Once this function is called, you can define your own custom mappings using mapping functions
134
+		<h5>Different font layouts</h5>
135
+		<table>
136
+		<tr><td>ASCII_INROW</td><td>ASCII_INCOL</td><td>TCOD</td></tr>
137
+
138
+		<tr><td><img src='terminal8x8_gs_ro.png' /></td><td><img src='terminal8x8_gs_as.png' /></td><td><img src='terminal8x8_gs_tc.png' /></td></tr>
139
+		</table>
140
+		<ul>
141
+		<li>ascii, in columns : characters 0 to 15 are in the first column. The space character is at coordinates 2,0.</li>
142
+		<li>ascii, in rows : characters 0 to 15 are in the first row. The space character is at coordinates 0,2.</li>
143
+		<li>tcod : special mapping. Not all ascii values are mapped. The space character is at coordinates 0,0.</li>
144
+		</ul>
145
+		<h5>Different font types</h5>
146
+		<table>
147
+		<tr><td>standard<br />(non antialiased)</td><td>antialiased<br />(32 bits PNG)</td><td>antialiased<br />(greyscale)</td></tr>
148
+
149
+		<tr><td><img src='terminal.png' /></td><td><img src='terminal8x8_aa_as.png' /></td><td><img src='terminal8x8_gs_as2.png' /></td></tr>
150
+		</table>
151
+		<ul>
152
+		<li>standard : transparency is given by a key color automatically detected by looking at the color of the space character</li>
153
+		<li>32 bits : transparency is given by the png alpha layer. The font color does not matter but it must be desaturated</li>
154
+		<li>greyscale : transparency is given by the pixel value. You can use white characters on black background or black characters on white background. The background color is automatically detected by looking at the color of the space character</li>
155
+		</ul>
156
+		Examples of fonts can be found in libtcod's fonts directory. Check the Readme file there.
157
+	@Cpp static void TCODConsole::setCustomFont(const char *fontFile, int flags=TCOD_FONT_LAYOUT_ASCII_INCOL,int nbCharHoriz=0, int nbCharVertic=0)
158
+	@C void TCOD_console_set_custom_font(const char *fontFile, int flags,int nb_char_horiz, int nb_char_vertic)
159
+	@Py console_set_custom_font(fontFile, flags=FONT_LAYOUT_ASCII_INCOL,nb_char_horiz=0, nb_char_vertic=0)
160
+	@C#
161
+		static void TCODConsole::setCustomFont(string fontFile)
162
+		static void TCODConsole::setCustomFont(string fontFile, int flags)
163
+		static void TCODConsole::setCustomFont(string fontFile, int flags, int nbCharHoriz)
164
+		static void TCODConsole::setCustomFont(string fontFile, int flags, int nbCharHoriz, int nbCharVertic)
165
+	@Lua
166
+		tcod.console.setCustomFont(fontFile)
167
+		tcod.console.setCustomFont(fontFile, flags)
168
+		tcod.console.setCustomFont(fontFile, nbCharHoriz)
169
+		tcod.console.setCustomFont(fontFile, flags, nbCharHoriz, nbCharVertic)
170
+		-- flags : tcod.LayoutAsciiInColumn, tcod.LayoutAsciiInRow, tcod.LayoutTCOD, tcod.Greyscale
171
+	@Param fontFile Name of a .bmp or .png file containing the font.
172
+	@Param flags Used to define the characters layout in the bitmap and the font type :
173
+		TCOD_FONT_LAYOUT_ASCII_INCOL : characters in ASCII order, code 0-15 in the first column
174
+		TCOD_FONT_LAYOUT_ASCII_INROW : characters in ASCII order, code 0-15 in the first row
175
+		TCOD_FONT_LAYOUT_TCOD : simplified layout. See examples below.
176
+		TCOD_FONT_TYPE_GREYSCALE : create an anti-aliased font from a greyscale bitmap
177
+		For python, remove TCOD _ :
178
+		libtcod.FONT_LAYOUT_ASCII_INCOL
179
+	@Param nbCharHoriz,nbCharVertic Number of characters in the font.
180
+		Should be 16x16 for ASCII layouts, 32x8 for TCOD layout.
181
+		But you can use any other layout.
182
+		If set to 0, there are deduced from the font layout flag.
183
+	@CppEx
184
+		TCODConsole::setCustomFont("standard_8x8_ascii_in_col_font.bmp",TCOD_FONT_LAYOUT_ASCII_INCOL);
185
+		TCODConsole::setCustomFont("32bits_8x8_ascii_in_row_font.png",TCOD_FONT_LAYOUT_ASCII_INROW);
186
+		TCODConsole::setCustomFont("greyscale_8x8_tcod_font.png",TCOD_FONT_LAYOUT_TCOD | TCOD_FONT_TYPE_GREYSCALE);
187
+	@CEx
188
+		TCOD_console_set_custom_font("standard_8x8_ascii_in_col_font.bmp",TCOD_FONT_LAYOUT_ASCII_INCOL,16,16);
189
+		TCOD_console_set_custom_font("32bits_8x8_ascii_in_row_font.png",TCOD_FONT_LAYOUT_ASCII_INROW,32,8);
190
+		TCOD_console_set_custom_font("greyscale_8x8_tcod_font.png",TCOD_FONT_LAYOUT_TCOD | TCOD_FONT_TYPE_GREYSCALE,32,8);
191
+	@PyEx
192
+		libtcod.console_set_custom_font("standard_8x8_ascii_in_col_font.bmp",libtcod.FONT_LAYOUT_ASCII_INCOL)
193
+		libtcod.console_set_custom_font("32bits_8x8_ascii_in_row_font.png",libtcod.FONT_LAYOUT_ASCII_INROW)
194
+		libtcod.console_set_custom_font("greyscale_8x8_tcod_font.png",libtcod.FONT_LAYOUT_TCOD | libtcod.FONT_TYPE_GREYSCALE)
195
+	@LuaEx
196
+		tcod.console.setCustomFont("standard_8x8_ascii_in_col_font.bmp",tcod.LayoutAsciiInColumn);
197
+		tcod.console.setCustomFont("32bits_8x8_ascii_in_row_font.png",tcod.LayoutAsciiInRow);
198
+		tcod.console.setCustomFont("greyscale_8x8_tcod_font.png",tcod.LayoutTCOD + tcod.Greyscale);
199
+	*/
200
+	static void setCustomFont(const char *fontFile, int flags=TCOD_FONT_LAYOUT_ASCII_INCOL,int nbCharHoriz=0, int nbCharVertic=0);
201
+
202
+	/**
203
+	@PageName console_map
204
+	@PageTitle Using custom characters mapping
205
+	@PageFather console_init
206
+	@FuncTitle Mapping a single ASCII code to a character
207
+	@PageDesc These functions allow you to map characters in the bitmap font to ASCII codes.
208
+		They should be called after initializing the root console with initRoot.
209
+		You can dynamically change the characters mapping at any time, allowing to use several fonts in the same screen.
210
+	@Cpp static void TCODConsole::mapAsciiCodeToFont(int asciiCode, int fontCharX, int fontCharY)
211
+	@C void TCOD_console_map_ascii_code_to_font(int asciiCode, int fontCharX, int fontCharY)
212
+	@Py console_map_ascii_code_to_font(asciiCode, fontCharX, fontCharY)
213
+	@C# static void TCODConsole::mapAsciiCodeToFont(int asciiCode, int fontCharX, int fontCharY)
214
+	@Lua tcod.console.mapAsciiCodeToFont(asciiCode, fontCharX, fontCharY)
215
+	@Param asciiCode ASCII code to map.
216
+	@Param fontCharX,fontCharY Coordinate of the character in the bitmap font (in characters, not pixels).
217
+	*/
218
+	static void mapAsciiCodeToFont(int asciiCode, int fontCharX, int fontCharY);
219
+
220
+	/**
221
+	@PageName console_map
222
+	@FuncTitle Mapping consecutive ASCII codes to consecutive characters
223
+	@Cpp static void TCODConsole::mapAsciiCodesToFont(int firstAsciiCode, int nbCodes, int fontCharX, int fontCharY)
224
+	@C void TCOD_console_map_ascii_codes_to_font(int firstAsciiCode, int nbCodes, int fontCharX, int fontCharY)
225
+	@Py console_map_ascii_codes_to_font(firstAsciiCode, nbCodes, fontCharX, fontCharY)
226
+	@C# static void TCODConsole::mapAsciiCodesToFont(int firstAsciiCode, int nbCodes, int fontCharX, int fontCharY)
227
+	@Lua tcod.console.mapAsciiCodesToFont(firstAsciiCode, nbCodes, fontCharX, fontCharY)
228
+	@Param firstAsciiCode first ASCII code to map
229
+	@Param nbCodes number of consecutive ASCII codes to map
230
+	@Param fontCharX,fontCharY coordinate of the character in the bitmap font (in characters, not pixels) corresponding to the first ASCII code
231
+	*/
232
+	static void mapAsciiCodesToFont(int firstAsciiCode, int nbCodes, int fontCharX, int fontCharY);
233
+
234
+	/**
235
+	@PageName console_map
236
+	@FuncTitle Mapping ASCII code from a string to consecutive characters
237
+	@Cpp static void TCODConsole::mapStringToFont(const char *s, int fontCharX, int fontCharY)
238
+	@C void TCOD_console_map_string_to_font(const char *s, int fontCharX, int fontCharY)
239
+	@Py console_map_string_to_font(s, fontCharX, fontCharY)
240
+	@C# static void TCODConsole::mapStringToFont(string s, int fontCharX, int fontCharY)
241
+	@Lua tcod.console.mapStringToFont(s, fontCharX, fontCharY)
242
+	@Param s string containing the ASCII codes to map
243
+	@Param fontCharX,fontCharY coordinate of the character in the bitmap font (in characters, not pixels) corresponding to the first ASCII code in the string
244
+	*/
245
+	static void mapStringToFont(const char *s, int fontCharX, int fontCharY);
246
+
247
+	/**
248
+	@PageName console_fullscreen
249
+	@PageTitle Fullscreen mode
250
+	@PageFather console_init
251
+	@FuncTitle Getting the current mode
252
+	@FuncDesc This function returns true if the current mode is fullscreen.
253
+	@Cpp static bool TCODConsole::isFullscreen()
254
+	@C bool TCOD_console_is_fullscreen()
255
+	@Py console_is_fullscreen()
256
+	@C# static bool TCODConsole::isFullscreen()
257
+	@Lua tcod.console.isFullscreen()
258
+	*/
259
+	static bool isFullscreen();
260
+	/**
261
+	@PageName console_fullscreen
262
+	@FuncTitle Switching between windowed and fullscreen modes
263
+	@FuncDesc This function switches the root console to fullscreen or windowed mode.
264
+		Note that there is no predefined key combination to switch to/from fullscreen. You have to do this in your own code.
265
+	@Cpp static void TCODConsole::setFullscreen(bool fullscreen)
266
+	@C void TCOD_console_set_fullscreen(bool fullscreen)
267
+	@Py console_set_fullscreen(fullscreen)
268
+	@C# static void TCODConsole::setFullscreen(bool fullscreen)
269
+	@Lua tcod.console.setFullscreen(fullscreen)
270
+	@Param fullscreen true to switch to fullscreen mode.
271
+		false to switch to windowed mode.
272
+	@CppEx
273
+		TCOD_key_t key;
274
+		TCODConsole::checkForEvent(TCOD_EVENT_KEY_PRESS,&key,NULL);
275
+		if ( key.vk == TCODK_ENTER && key.lalt )
276
+			TCODConsole::setFullscreen(!TCODConsole::isFullscreen());
277
+	@CEx
278
+		TCOD_key_t key;
279
+		TCOD_console_check_for_event(TCOD_EVENT_KEY_PRESS,&key,NULL);
280
+		if ( key.vk == TCODK_ENTER && key.lalt )
281
+			TCOD_console_set_fullscreen(!TCOD_console_is_fullscreen());
282
+	@PyEx
283
+		key=Key()
284
+		libtcod.console_check_for_event(libtcod.EVENT_KEY_PRESS,key,0)
285
+		if key.vk == libtcod.KEY_ENTER and key.lalt :
286
+			libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
287
+	@LuaEx
288
+		key=tcod.console.checkForKeypress()
289
+		if key.KeyCode == tcod.Enter and key.LeftAlt then
290
+			tcod.console.setFullscreen(not tcod.console.isFullscreen())
291
+		end
292
+	*/
293
+	static void setFullscreen(bool fullscreen);
294
+
295
+	/**
296
+	@PageName console_window
297
+	@PageFather console_init
298
+	@PageTitle Communicate with the window manager
299
+	@FuncTitle Changing the window title
300
+	@FuncDesc This function dynamically changes the title of the game window.
301
+		Note that the window title is not visible while in fullscreen.
302
+	@Cpp static void TCODConsole::setWindowTitle(const char *title)
303
+ 	@C void TCOD_console_set_window_title(const char *title)
304
+	@Py console_set_window_title(title)
305
+	@C# static void TCODConsole::setWindowTitle(string title)
306
+	@Lua tcod.console.setWindowTitle(title)
307
+	@Param title New title of the game window
308
+	*/
309
+	static void setWindowTitle(const char *title);
310
+
311
+	/**
312
+	@PageName console_window
313
+	@FuncTitle Handling "close window" events
314
+	@FuncDesc When you start the program, this returns false. Once a "close window" event has been sent by the window manager, it will allways return true. You're supposed to exit cleanly the game.
315
+	@Cpp static bool TCODConsole::isWindowClosed()
316
+	@C bool TCOD_console_is_window_closed()
317
+	@Py console_is_window_closed()
318
+	@C# static bool TCODConsole::isWindowClosed()
319
+	@Lua tcod.console.isWindowClosed()
320
+	*/
321
+	static bool isWindowClosed();
322
+
323
+	/**
324
+	@PageName console_window
325
+	@FuncTitle Check if the mouse cursor is inside the game window
326
+	@FuncDesc Returns true if the mouse cursor is inside the game window area and the game window is the active application.
327
+	@Cpp static bool TCODConsole::hasMouseFocus()
328
+	@C bool TCOD_console_has_mouse_focus()
329
+	@Py console_has_mouse_focus()
330
+	*/
331
+	static bool hasMouseFocus();
332
+
333
+	/**
334
+	@PageName console_window
335
+	@FuncTitle Check if the game application is active
336
+	@FuncDesc Returns false if the game window is not the active window or is iconified.
337
+	@Cpp static bool TCODConsole::isActive()
338
+	@C bool TCOD_console_is_active()
339
+	@Py console_is_active()
340
+	*/
341
+	static bool isActive();
342
+
343
+	/**
344
+	@PageName console_credits
345
+	@PageTitle libtcod's credits
346
+	@PageFather console_init
347
+	@PageDesc Use these functions to display credits, as seen in the samples.
348
+	@FuncTitle Using a separate credit page
349
+	@FuncDesc You can print a "Powered by libtcod x.y.z" screen during your game startup simply by calling this function after initRoot.
350
+		The credits screen can be skipped by pressing any key.
351
+	@Cpp static void TCODConsole::credits()
352
+	@C void TCOD_console_credits()
353
+	@Py console_credits()
354
+	@C# static void TCODConsole::credits()
355
+	@Lua tcod.console.credits()
356
+	*/
357
+	static void credits();
358
+
359
+	/**
360
+	@PageName console_credits
361
+	@FuncTitle Embedding credits in an existing page
362
+	@FuncDesc You can also print the credits on one of your game screens (your main menu for example) by calling this function in your main loop.
363
+		This function returns true when the credits screen is finished, indicating that you no longer need to call it.
364
+	@Cpp static bool TCODConsole::renderCredits(int x, int y, bool alpha)
365
+	@C bool TCOD_console_credits_render(int x, int y, bool alpha)
366
+	@Py bool TCOD_console_credits_render(int x, int y, bool alpha)
367
+	@C# static bool TCODConsole::renderCredits(int x, int y, bool alpha)
368
+	@Lua tcod.console.renderCredits(x, y, alpha)
369
+	@Param x,y Position of the credits text in your root console
370
+	@Param alpha If true, credits are transparently added on top of the existing screen.
371
+		For this to work, this function must be placed between your screen rendering code and the console flush.
372
+	@CppEx
373
+      TCODConsole::initRoot(80,50,"The Chronicles Of Doryen v0.1",false); // initialize the root console
374
+      bool endCredits=false;
375
+      while ( ! TCODConsole::isWindowClosed() ) { // your game loop
376
+          // your game rendering here...
377
+          // render transparent credits near the center of the screen
378
+          if (! endCredits ) endCredits=TCODConsole::renderCredits(35,25,true);
379
+          TCODConsole::flush();
380
+      }
381
+	@CEx
382
+      TCOD_console_init_root(80,50,"The Chronicles Of Doryen v0.1",false);
383
+      bool end_credits=false;
384
+      while ( ! TCOD_console_is_window_closed() ) {
385
+          // your game rendering here...
386
+          // render transparent credits near the center of the screen
387
+          if (! end_credits ) end_credits=TCOD_console_credits_render(35,25,true);
388
+          TCOD_console_flush();
389
+      }
390
+	@PyEx
391
+      libtcod.console_init_root(80,50,"The Chronicles Of Doryen v0.1",False)
392
+      end_credits=False
393
+      while not libtcod.console_is_window_closed() :
394
+          // your game rendering here...
395
+          // render transparent credits near the center of the screen
396
+          if (not end_credits )  : end_credits=libtcod.console_credits_render(35,25,True)
397
+          libtcod.console_flush()
398
+	@LuaEx
399
+		tcod.console.initRoot(80,50,"The Chronicles Of Doryen v0.1") -- initialize the root console
400
+		endCredits=false
401
+		while not tcod.console.isWindowClosed() do -- your game loop
402
+			-- your game rendering here...
403
+			-- render transparent credits near the center of the screen
404
+			if not endCredits then endCredits=tcod.console.renderCredits(35,25,true) end
405
+			tcod.console.flush()
406
+		end
407
+	*/
408
+	static bool renderCredits(int x, int y, bool alpha);
409
+
410
+	/**
411
+	@PageName console_credits
412
+	@FuncTitle Restart the credits animation
413
+	@FuncDesc When using rederCredits, you can restart the credits animation from the begining before it's finished by calling this function.
414
+	@Cpp static void TCODConsole::resetCredits()
415
+	@C void TCOD_console_credits_reset()
416
+	@Py console_credits_reset()
417
+	@C# static void TCODConsole::resetCredits()
418
+	@Lua tcod.console.resetCredits()
419
+	*/
420
+	static void resetCredits();
421
+
422
+	/**
423
+	@PageName console_draw
424
+	@PageTitle Drawing on the root console
425
+	@PageFather console
426
+	*/
427
+
428
+	/**
429
+	@PageName console_draw_basic
430
+	@PageTitle Basic printing functions
431
+	@PageFather console_draw
432
+	@FuncTitle Setting the default background color
433
+	@FuncDesc This function changes the default background color for a console. The default background color is used by several drawing functions like clear, putChar, ...
434
+	@Cpp void TCODConsole::setDefaultBackground(TCODColor back)
435
+	@C void TCOD_console_set_default_background(TCOD_console_t con,TCOD_color_t back)
436
+	@Py console_set_default_background(con,back)
437
+	@C# void TCODConsole::setBackgroundColor(TCODColor back)
438
+	@Lua Console:setBackgroundColor(back)
439
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
440
+	@Param back the new default background color for this console
441
+	@CppEx TCODConsole::root->setDefaultBackground(myColor)
442
+	@CEx TCOD_console_set_default_background(NULL, my_color)
443
+	@PyEx litbcod.console_set_default_background(0, my_color)
444
+	@Lua libtcod.TCODConsole_root:setBackgroundColor( myColor )
445
+	*/
446
+	void setDefaultBackground(TCODColor back);
447
+
448
+	/**
449
+	@PageName console_draw_basic
450
+	@FuncTitle Setting the default foreground color
451
+	@FuncDesc This function changes the default foreground color for a console. The default foreground color is used by several drawing functions like clear, putChar, ...
452
+	@Cpp void TCODConsole::setDefaultForeground(TCODColor fore)
453
+	@C void TCOD_console_set_default_foreground(TCOD_console_t con,TCOD_color_t fore)
454
+	@Py console_set_default_foreground(con, fore)
455
+	@C# void TCODConsole::setForegroundColor(TCODColor fore)
456
+	@Lua Console:setForegroundColor(fore)
457
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
458
+	@Param fore the new default foreground color for this console
459
+	@CppEx TCODConsole::root->setDefaultForeground(myColor)
460
+	@CEx TCOD_console_set_default_foreground(NULL, my_color)
461
+	@PyEx litbcod.console_set_default_foreground(0, my_color)
462
+	@LuaEx libtcod.TCODConsole_root:setForegroundColor( myColor )
463
+	*/
464
+	void setDefaultForeground(TCODColor fore);
465
+
466
+	/**
467
+	@PageName console_draw_basic
468
+	@FuncTitle Clearing a console
469
+	@FuncDesc This function modifies all cells of a console :
470
+		* set the cell's background color to the console default background color
471
+		* set the cell's foreground color to the console default foreground color
472
+		* set the cell's ASCII code to 32 (space)
473
+	@Cpp void TCODConsole::clear()
474
+	@C void TCOD_console_clear(TCOD_console_t con)
475
+	@Py console_clear(con)
476
+	@C# void TCODConsole::clear()
477
+	@Lua Console:clear()
478
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
479
+	*/
480
+	void clear();
481
+
482
+	/**
483
+	@PageName console_draw_basic
484
+	@FuncTitle Setting the background color of a cell
485
+	@FuncDesc This function modifies the background color of a cell, leaving other properties (foreground color and ASCII code) unchanged.
486
+	@Cpp void TCODConsole::setCharBackground(int x, int y, const TCODColor &col, TCOD_bkgnd_flag_t flag = TCOD_BKGND_SET)
487
+	@C void TCOD_console_set_char_background(TCOD_console_t con,int x, int y, TCOD_color_t col, TCOD_bkgnd_flag_t flag)
488
+	@Py console_set_char_background(con, x,  y, col, flag=BKGND_SET)
489
+	@C#
490
+		void TCODConsole::setCharBackground(int x, int y, TCODColor col)
491
+		void TCODConsole::setCharBackground(int x, int y, TCODColor col, TCODBackgroundFlag flag)
492
+	@Lua
493
+		Console:setCharBackground(x, y, col)
494
+		Console:setCharBackground(x, y, col, flag)
495
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
496
+	@Param x,y coordinates of the cell in the console.
497
+		0 <= x < console width
498
+		0 <= y < console height
499
+	@Param col the background color to use. You can use color constants
500
+	@Param flag this flag defines how the cell's background color is modified. See <a href="console_bkgnd_flag_t.html">TCOD_bkgnd_flag_t</a>
501
+	*/
502
+	void setCharBackground(int x, int y, const TCODColor &col, TCOD_bkgnd_flag_t flag = TCOD_BKGND_SET);
503
+	/**
504
+	@PageName console_draw_basic
505
+	@FuncTitle Setting the foreground color of a cell
506
+	@FuncDesc This function modifies the foreground color of a cell, leaving other properties (background color and ASCII code) unchanged.
507
+	@Cpp void TCODConsole::setCharForeground(int x, int y, const TCODColor &col)
508
+	@C void TCOD_console_set_char_foreground(TCOD_console_t con,int x, int y, TCOD_color_t col)
509
+	@Py console_set_char_foreground(con, x, y, col)
510
+	@C# void TCODConsole::setCharForeground(int x, int y, TCODColor col)
511
+	@Lua Console:setCharForeground(x, y, col)
512
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
513
+	@Param x,y coordinates of the cell in the console.
514
+		0 <= x < console width
515
+		0 <= y < console height
516
+	@Param col the foreground color to use. You can use color constants
517
+	*/
518
+	void setCharForeground(int x, int y, const TCODColor &col);
519
+
520
+	/**
521
+	@PageName console_draw_basic
522
+	@FuncTitle Setting the ASCII code of a cell
523
+	@FuncDesc This function modifies the ASCII code of a cell, leaving other properties (background and foreground colors) unchanged.
524
+		Note that since a clear console has both background and foreground colors set to black for every cell, using setchar will produce black characters on black background. Use putchar instead.
525
+	@Cpp void TCODConsole::setChar(int x, int y, int c)
526
+	@C void TCOD_console_set_char(TCOD_console_t con,int x, int y, int c)
527
+	@Py console_set_char(con, x,  y, c)
528
+	@C# void TCODConsole::setChar(int x, int y, int c)
529
+	@Lua Console:setChar(x, y, c)
530
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
531
+	@Param x,y coordinates of the cell in the console.
532
+		0 <= x < console width
533
+		0 <= y < console height
534
+	@Param c the new ASCII code for the cell. You can use ASCII constants
535
+	*/
536
+	void setChar(int x, int y, int c);
537
+
538
+	/**
539
+	@PageName console_draw_basic
540
+	@FuncTitle Setting every property of a cell using default colors
541
+	@FuncDesc This function modifies every property of a cell :
542
+		* update the cell's background color according to the console default background color (see TCOD_bkgnd_flag_t).
543
+		* set the cell's foreground color to the console default foreground color
544
+		* set the cell's ASCII code to c
545
+	@Cpp void TCODConsole::putChar(int x, int y, int c, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT)
546
+	@C void TCOD_console_put_char(TCOD_console_t con,int x, int y, int c, TCOD_bkgnd_flag_t flag)
547
+	@Py console_put_char( con, x,  y, c, flag=BKGND_DEFAULT)
548
+	@C#
549
+		void TCODConsole::putChar(int x, int y, int c)
550
+		void TCODConsole::putChar(int x, int y, int c, TCODBackgroundFlag flag)
551
+	@Lua
552
+		Console:putChar(x, y, c)
553
+		Console:putChar(x, y, c, flag)
554
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
555
+	@Param x,y coordinates of the cell in the console.
556
+		0 <= x < console width
557
+		0 <= y < console height
558
+	@Param c the new ASCII code for the cell. You can use ASCII constants
559
+	@Param flag this flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t
560
+	*/
561
+	void putChar(int x, int y, int c, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT);
562
+
563
+	/**
564
+	@PageName console_draw_basic
565
+	@FuncTitle Setting every property of a cell using specific colors
566
+	@FuncDesc This function modifies every property of a cell :
567
+		* set the cell's background color to back.
568
+		* set the cell's foreground color to fore.
569
+		* set the cell's ASCII code to c.
570
+	@Cpp void TCODConsole::putCharEx(int x, int y, int c, const TCODColor & fore, const TCODColor & back)
571
+	@C void TCOD_console_put_char_ex(TCOD_console_t con,int x, int y, int c, TCOD_color_t fore, TCOD_color_t back)
572
+	@Py console_put_char_ex( con, x,  y, c, fore, back)
573
+	@C# void TCODConsole::putCharEx(int x, int y, int c, TCODColor fore, TCODColor back)
574
+	@Lua Console:putCharEx(x, y, c, fore, back)
575
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
576
+	@Param x,y coordinates of the cell in the console.
577
+		0 <= x < console width
578
+		0 <= y < console height
579
+	@Param c the new ASCII code for the cell. You can use ASCII constants
580
+	@Param fore,back new foreground and background colors for this cell
581
+	*/
582
+	void putCharEx(int x, int y, int c, const TCODColor &fore, const TCODColor &back);
583
+
584
+	/**
585
+	@PageName console_bkgnd_flag_t
586
+	@PageTitle Background effect flags
587
+	@PageFather console_draw
588
+	@PageDesc This flag is used by most functions that modify a cell background color. It defines how the console's current background color is used to modify the cell's existing background color :
589
+		TCOD_BKGND_NONE : the cell's background color is not modified.
590
+		TCOD_BKGND_SET : the cell's background color is replaced by the console's default background color : newbk = curbk.
591
+		TCOD_BKGND_MULTIPLY : the cell's background color is multiplied by the console's default background color : newbk = oldbk * curbk
592
+		TCOD_BKGND_LIGHTEN : newbk = MAX(oldbk,curbk)
593
+		TCOD_BKGND_DARKEN : newbk = MIN(oldbk,curbk)
594
+		TCOD_BKGND_SCREEN : newbk = white - (white - oldbk) * (white - curbk) // inverse of multiply : (1-newbk) = (1-oldbk)*(1-curbk)
595
+		TCOD_BKGND_COLOR_DODGE : newbk = curbk / (white - oldbk)
596
+		TCOD_BKGND_COLOR_BURN : newbk = white - (white - oldbk) / curbk
597
+		TCOD_BKGND_ADD : newbk = oldbk + curbk
598
+		TCOD_BKGND_ADDALPHA(alpha) : newbk = oldbk + alpha*curbk
599
+		TCOD_BKGND_BURN : newbk = oldbk + curbk - white
600
+		TCOD_BKGND_OVERLAY : newbk = curbk.x <= 0.5 ? 2*curbk*oldbk : white - 2*(white-curbk)*(white-oldbk)
601
+		TCOD_BKGND_ALPHA(alpha) : newbk = (1.0f-alpha)*oldbk + alpha*(curbk-oldbk)
602
+		TCOD_BKGND_DEFAULT : use the console's default background flag
603
+		Note that TCOD_BKGND_ALPHA and TCOD_BKGND_ADDALPHA are MACROS that needs a float parameter between (0.0 and 1.0). TCOD_BKGND_ALPH and TCOD_BKGND_ADDA should not be used directly (else they will have the same effect as TCOD_BKGND_NONE).
604
+		For python, remove TCOD_ : libtcod.BKGND_NONE
605
+		For C# : None, Set, Multiply, Lighten, Darken, Screen, ColodDodge, ColorBurn, Add, Burn Overlay, Default
606
+		With lua, use tcod.None, ..., tcod.Default, BUT tcod.console.Alpha(value) and tcod.console.AddAlpha(value)
607
+	*/
608
+
609
+	/**
610
+	@PageName console_print
611
+	@PageTitle String drawing functions
612
+	@PageFather console_draw
613
+	@FuncTitle Setting the default background flag
614
+	@FuncDesc This function defines the background mode (see TCOD_bkgnd_flag_t) for the console.
615
+		This default mode is used by several functions (print, printRect, ...)
616
+	@Cpp void TCODConsole::setBackgroundFlag(TCOD_bkgnd_flag_t flag)
617
+	@C void TCOD_console_set_background_flag(TCOD_console_t con,TCOD_bkgnd_flag_t flag)
618
+	@Py console_set_background_flag(con, flag)
619
+	@C# void TCODConsole::setBackgroundFlag(TCODBackgroundFlag flag)
620
+	@Lua Console:setBackgroundFlag(flag)
621
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
622
+	@Param flag this flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t
623
+	*/
624
+	void setBackgroundFlag(TCOD_bkgnd_flag_t flag);
625
+
626
+	/**
627
+	@PageName console_print
628
+	@FuncTitle Getting the default background flag
629
+	@FuncDesc This function returns the background mode (see TCOD_bkgnd_flag_t) for the console.
630
+		This default mode is used by several functions (print, printRect, ...)
631
+	@Cpp TCOD_bkgnd_flag_t TCODConsole::getBackgroundFlag() const
632
+	@C TCOD_bkgnd_flag_t TCOD_console_get_background_flag(TCOD_console_t con)
633
+	@Py console_get_background_flag(con)
634
+	@C# TCODBackgroundFlag TCODConsole::getBackgroundFlag()
635
+	@Lua Console:getBackgroundFlag()
636
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
637
+	*/
638
+	TCOD_bkgnd_flag_t getBackgroundFlag() const;
639
+
640
+	/**
641
+	@PageName console_print
642
+	@FuncTitle Setting the default alignment
643
+	@FuncDesc This function defines the default alignment (see TCOD_alignment_t) for the console.
644
+		This default alignment is used by several functions (print, printRect, ...).
645
+		Values for alignment : TCOD_LEFT, TCOD_CENTER, TCOD_RIGHT (in python, remove TCOD_ : libtcod.LEFT).
646
+		For C# and Lua : LeftAlignment, RightAlignment, CenterAlignment
647
+	@Cpp void TCODConsole::setAlignment(TCOD_alignment_t alignment)
648
+	@C void TCOD_console_set_alignment(TCOD_console_t con,TCOD_bkgnd_flag_t alignment)
649
+	@Py console_set_alignment(con, alignment)
650
+	@C# void TCODConsole::setAlignment(TCODAlignment alignment)
651
+	@Lua Console:setAlignment(alignment)
652
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
653
+	@Param alignment defines how the strings are printed on screen.
654
+	*/
655
+	void setAlignment(TCOD_alignment_t alignment);
656
+
657
+	/**
658
+	@PageName console_print
659
+	@FuncTitle Getting the default alignment
660
+	@FuncDesc This function returns the default alignment (see TCOD_alignment_t) for the console.
661
+		This default mode is used by several functions (print, printRect, ...).
662
+		Values for alignment : TCOD_LEFT, TCOD_CENTER, TCOD_RIGHT (in python, remove TCOD_ : libtcod.LEFT).
663
+		For C# and Lua : LeftAlignment, RightAlignment, CenterAlignment
664
+	@Cpp TCOD_alignment_t TCODConsole::getAlignment() const
665
+	@C TCOD_alignment_t TCOD_console_get_alignment(TCOD_console_t con)
666
+	@Py console_get_alignment(con)
667
+	@C# TCODAlignment TCODConsole::getAlignment()
668
+	@Lua Console:getAlignment()
669
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
670
+	*/
671
+	TCOD_alignment_t getAlignment() const;
672
+
673
+	/**
674
+	@PageName console_print
675
+	@FuncTitle Printing a string with default parameters
676
+	@FuncDesc This function print a string at a specific position using current default alignment, background flag, foreground and background colors.
677
+	@Cpp void TCODConsole::print(int x, int y, const char *fmt, ...)
678
+	@C void TCOD_console_print(TCOD_console_t con,int x, int y, const char *fmt, ...)
679
+	@Py console_print(con, x, y, fmt)
680
+	@C# void TCODConsole::print(int x, int y, string fmt)
681
+	@Lua Console:print(x, y, fmt)
682
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
683
+	@Param x,y coordinate of the character in the console, depending on the default alignment for this console :
684
+		* TCOD_LEFT : leftmost character of the string
685
+		* TCOD_CENTER : center character of the string
686
+		* TCOD_RIGHT : rightmost character of the string
687
+	@Param fmt printf-like format string, eventually followed by parameters. You can use control codes to change the colors inside the string, except in C#.
688
+	*/
689
+	void print(int x, int y, const char *fmt, ...);
690
+
691
+	/**
692
+	@PageName console_print
693
+	@FuncTitle Printing a string with specific alignment and background mode
694
+	@FuncDesc This function print a string at a specific position using specific alignment and background flag, but default foreground and background colors.
695
+	@Cpp void TCODConsole::printEx(int x, int y, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt, ...)
696
+	@C void TCOD_console_print_ex(TCOD_console_t con,int x, int y, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt, ...)
697
+	@Py console_print_ex(con, x, y, flag, alignment, fmt)
698
+	@C# void TCODConsole::printEx(int x, int y, TCODBackgroundFlag flag, TCODAlignment alignment, string fmt)
699
+	@Lua Console::printEx(x, y, flag, alignment, fmt)
700
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
701
+	@Param x,y coordinate of the character in the console, depending on the alignment :
702
+		* TCOD_LEFT : leftmost character of the string
703
+		* TCOD_CENTER : center character of the string
704
+		* TCOD_RIGHT : rightmost character of the string
705
+	@Param flag this flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t
706
+	@Param alignment defines how the strings are printed on screen.
707
+	@Param fmt printf-like format string, eventually followed by parameters. You can use control codes to change the colors inside the string, except in C#.
708
+	*/
709
+	void printEx(int x, int y, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt, ...);
710
+
711
+	/**
712
+	@PageName console_print
713
+	@FuncTitle Printing a string with default parameters and autowrap
714
+	@FuncDesc This function draws a string in a rectangle inside the console, using default colors, alignment and background mode.
715
+		If the string reaches the borders of the rectangle, carriage returns are inserted.
716
+		If h > 0 and the bottom of the rectangle is reached, the string is truncated. If h = 0, the string is only truncated if it reaches the bottom of the console.
717
+		The function returns the height (number of console lines) of the printed string.
718
+	@Cpp int TCODConsole::printRect(int x, int y, int w, int h, const char *fmt, ...)
719
+	@C int TCOD_console_print_rect(TCOD_console_t con,int x, int y, int w, int h, const char *fmt, ...)
720
+	@Py console_print_rect(con, x, y, w, h, fmt)
721
+	@C# int TCODConsole::printRect(int x, int y, int w, int h, string fmt)
722
+	@Lua Console:printRect(x, y, w, h, fmt)
723
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
724
+	@Param x,y coordinate of the character in the console, depending on the alignment :
725
+		* TCOD_LEFT : leftmost character of the string
726
+		* TCOD_CENTER : center character of the string
727
+		* TCOD_RIGHT : rightmost character of the string
728
+	@Param w,h size of the rectangle
729
+		x <= x+w < console width
730
+		y <= y+h < console height
731
+	@Param fmt printf-like format string, eventually followed by parameters. You can use control codes to change the colors inside the string, except in C#.
732
+	*/
733
+   	int printRect(int x, int y, int w, int h, const char *fmt, ...);
734
+
735
+	/**
736
+	@PageName console_print
737
+	@FuncTitle Printing a string with specific alignment and background mode and autowrap
738
+	@FuncDesc This function draws a string in a rectangle inside the console, using default colors, but specific alignment and background mode.
739
+		If the string reaches the borders of the rectangle, carriage returns are inserted.
740
+		If h > 0 and the bottom of the rectangle is reached, the string is truncated. If h = 0, the string is only truncated if it reaches the bottom of the console.
741
+		The function returns the height (number of console lines) of the printed string.
742
+	@Cpp int TCODConsole::printRectEx(int x, int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt, ...)
743
+	@C int TCOD_console_print_rect_ex(TCOD_console_t con,int x, int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt, ...)
744
+	@Py console_print_rect_ex(con, x, y, w, h, flag, alignment, fmt)
745
+	@C# int TCODConsole::printRectEx(int x, int y, int w, int h, TCODBackgroundFlag flag, TCODAlignment alignment, string fmt)
746
+	@Lua Console:printRectEx(x, y, w, h, flag, alignment, fmt)
747
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
748
+	@Param x,y coordinate of the character in the console, depending on the alignment :
749
+		* TCOD_LEFT : leftmost character of the string
750
+		* TCOD_CENTER : center character of the string
751
+		* TCOD_RIGHT : rightmost character of the string
752
+	@Param w,h size of the rectangle
753
+		x <= x+w < console width
754
+		y <= y+h < console height
755
+	@Param flag this flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t
756
+	@Param alignment defines how the strings are printed on screen.
757
+	@Param fmt printf-like format string, eventually followed by parameters. You can use control codes to change the colors inside the string, except in C#.
758
+	*/
759
+	int printRectEx(int x, int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt, ...);
760
+
761
+	/**
762
+	@PageName console_print
763
+	@FuncTitle Compute the height of an autowrapped string
764
+	@FuncDesc This function returns the expected height of an autowrapped string without actually printing the string with printRect or printRectEx
765
+	@Cpp int TCODConsole::getHeightRect(int x, int y, int w, int h, const char *fmt, ...)
766
+
767
+	@C int TCOD_console_get_height_rect(TCOD_console_t con,int x, int y, int w, int h, const char *fmt, ...)
768
+	@Py console_get_height_rect(con, x, y, w, h, fmt)
769
+	@C# int TCODConsole::getHeightRect(int x, int y, int w, int h, string fmt)
770
+	@Lua Console:getHeightRect(x, y, w, h, fmt)
771
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
772
+	@Param x,y coordinate of the rectangle upper-left corner in the console
773
+	@Param w,h size of the rectangle
774
+		x <= x+w < console width
775
+		y <= y+h < console height
776
+	@Param fmt printf-like format string, eventually followed by parameters. You can use control codes to change the colors inside the string, except in C#.
777
+	*/
778
+	int getHeightRect(int x, int y, int w, int h, const char *fmt, ...);
779
+
780
+	/**
781
+	@PageName console_print
782
+	@FuncTitle Changing the colors while printing a string
783
+	@FuncDesc If you want to draw a string using different colors for each word, the basic solution is to call a string printing function several times, changing the default colors between each call.
784
+		The TCOD library offers a simpler way to do this, allowing you to draw a string using different colors in a single call. For this, you have to insert color control codes in your string.
785
+		A color control code is associated with a color set (a foreground color and a background color). If you insert this code in your string, the next characters will use the colors associated with the color control code.
786
+		There are 5 predefined color control codes :
787
+		For python, remove TCOD_ : libtcod.COLCTRL_1
788
+			TCOD_COLCTRL_1
789
+			TCOD_COLCTRL_2
790
+			TCOD_COLCTRL_3
791
+			TCOD_COLCTRL_4
792
+			TCOD_COLCTRL_5
793
+		To associate a color with a code, use setColorControl.
794
+		To go back to the console's default colors, insert in your string the color stop control code :
795
+			TCOD_COLCTRL_STOP
796
+
797
+		You can also use any color without assigning it to a control code, using the generic control codes :
798
+			TCOD_COLCTRL_FORE_RGB
799
+			TCOD_COLCTRL_BACK_RGB
800
+
801
+		Those controls respectively change the foreground and background color used to print the string characters. In the string, you must insert the r,g,b components of the color (between 1 and 255. The value 0 is forbidden because it represents the end of the string in C/C++) immediately after this code.
802
+	@Cpp static void TCODConsole::setColorControl(TCOD_colctrl_t con, const TCODColor &fore, const TCODColor &back)
803
+	@C void TCOD_console_set_color_control(TCOD_colctrl_t con, TCOD_color_t fore, TCOD_color_t back)
804
+	@Py console_set_color_control(con,fore,back)
805
+	@C# Not supported directly, use getRGBColorControlString and getColorControlString.
806
+	@Lua Not supported
807
+	@Param con the color control TCOD_COLCTRL_x, 1<=x<=5
808
+	@Param fore foreground color when this control is activated
809
+	@Param back background color when this control is activated
810
+	@CppEx
811
+		// A string with a red over black word, using predefined color control codes
812
+		TCODConsole::setColorControl(TCOD_COLCTRL_1,TCODColor::red,TCODColor::black);
813
+		TCODConsole::root->print(1,1,"String with a %cred%c word.",TCOD_COLCTRL_1,TCOD_COLCTRL_STOP);
814
+		// A string with a red over black word, using generic color control codes
815
+		TCODConsole::root->print(1,1,"String with a %c%c%c%c%c%c%c%cred%c word.",
816
+	          TCOD_COLCTRL_FORE_RGB,255,1,1,TCOD_COLCTRL_BACK_RGB,1,1,1,TCOD_COLCTRL_STOP);
817
+		// A string with a red over black word, using generic color control codes
818
+		TCODConsole::root->print(1,1,"String with a %c%c%c%c%c%c%c%cred%c word.",
819
+	          TCOD_COLCTRL_FORE_RGB,255,1,1,TCOD_COLCTRL_BACK_RGB,1,1,1,TCOD_COLCTRL_STOP);
820
+	@CEx
821
+		// A string with a red over black word, using predefined color control codes
822
+		TCOD_console_set_color_control(TCOD_COLCTRL_1,red,black);
823
+		TCOD_console_print(NULL,1,1,"String with a %cred%c word.",TCOD_COLCTRL_1,TCOD_COLCTRL_STOP);
824
+		// A string with a red word (over default background color), using generic color control codes
825
+		TCOD_console_print(NULL,1,1,"String with a %c%c%c%cred%c word.",
826
+			TCOD_COLCTRL_FORE_RGB,255,1,1,TCOD_COLCTRL_STOP);
827
+		// A string with a red over black word, using generic color control codes
828
+		TCOD_console_print(NULL,1,1,"String with a %c%c%c%c%c%c%c%cred%c word.",
829
+			TCOD_COLCTRL_FORE_RGB,255,1,1,TCOD_COLCTRL_BACK_RGB,1,1,1,TCOD_COLCTRL_STOP);
830
+	@PyEx
831
+		# A string with a red over black word, using predefined color control codes
832
+		libtcod.console_set_color_control(libtcod.COLCTRL_1,litbcod.red,litbcod.black)
833
+		libtcod.console_print(0,1,1,"String with a %cred%c word."%(libtcod.COLCTRL_1,libtcod.COLCTRL_STOP))
834
+		# A string with a red word (over default background color), using generic color control codes
835
+		litbcod.console_print(0,1,1,"String with a %c%c%c%cred%c word."%(libtcod.COLCTRL_FORE_RGB,255,1,1,libtcod.COLCTRL_STOP))
836
+		# A string with a red over black word, using generic color control codes
837
+		libtcod.console_print(0,1,1,"String with a %c%c%c%c%c%c%c%cred%c word."%
838
+		        (libtcod.COLCTRL_FORE_RGB,255,1,1,libtcod.COLCTRL_BACK_RGB,1,1,1,libtcod.COLCTRL_STOP))
839
+
840
+	@C#Ex
841
+		TCODConsole.root.print(1,1,String.Format("String with a {0}red{1} word.",
842
+			TCODConsole.getRGBColorControlString(ColorControlForeground,TCODColor.red),
843
+			TCODConsole.getColorControlString(ColorControlStop));
844
+	*/
845
+	static void setColorControl(TCOD_colctrl_t con, const TCODColor &fore, const TCODColor &back);
846
+
847
+#ifndef NO_UNICODE
848
+	/**
849
+	@PageName console_print
850
+	@FuncTitle Unicode functions
851
+	@FuncDesc those functions are similar to their ASCII equivalent, but work with unicode strings (wchar_t in C/C++).
852
+		Note that unicode is not supported in the python wrapper.
853
+	@Cpp static void TCODConsole::mapStringToFont(const wchar_t *s, int fontCharX, int fontCharY)
854
+	@C void TCOD_console_map_string_to_font_utf(const wchar_t *s, int fontCharX, int fontCharY)
855
+	*/
856
+	static void mapStringToFont(const wchar_t *s, int fontCharX, int fontCharY);
857
+	/**
858
+	@PageName console_print
859
+	@Cpp void TCODConsole::print(int x, int y, const wchar_t *fmt, ...)
860
+	@C void TCOD_console_print_utf(TCOD_console_t con,int x, int y, const wchar_t *fmt, ...)
861
+	*/
862
+	void print(int x, int y, const wchar_t *fmt, ...);
863
+	/**
864
+	@PageName console_print
865
+	@Cpp void TCODConsole::printEx(int x, int y, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const wchar_t *fmt, ...)
866
+	@C void TCOD_console_print_ex_utf(TCOD_console_t con,int x, int y, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const wchar_t *fmt, ...)
867
+	*/
868
+	void printEx(int x, int y, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const wchar_t *fmt, ...);
869
+	/**
870
+	@PageName console_print
871
+	@Cpp int TCODConsole::printRect(int x, int y, int w, int h, const wchar_t *fmt, ...)
872
+	@C int TCOD_console_print_rect_utf(TCOD_console_t con,int x, int y, int w, int h, const wchar_t *fmt, ...)
873
+	*/
874
+   	int printRect(int x, int y, int w, int h, const wchar_t *fmt, ...);
875
+
876
+	/**
877
+	@PageName console_print
878
+	@Cpp int TCODConsole::printRectEx(int x, int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const wchar_t *fmt, ...)
879
+	@C int TCOD_console_print_rect_ex_utf(TCOD_console_t con,int x, int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const wchar_t *fmt, ...)
880
+	*/
881
+	int printRectEx(int x, int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const wchar_t *fmt, ...);
882
+
883
+	/**
884
+	@PageName console_print
885
+	@Cpp int TCODConsole::getHeightRect(int x, int y, int w, int h, const wchar_t *fmt, ...)
886
+	@C int TCOD_console_get_height_rect_utf(TCOD_console_t con,int x, int y, int w, int h, const wchar_t *fmt, ...)
887
+	*/
888
+	int getHeightRect(int x, int y, int w, int h, const wchar_t *fmt, ...);
889
+#endif
890
+
891
+	/**
892
+	@PageName console_advanced
893
+	@PageFather console_draw
894
+	@PageTitle Advanced printing functions
895
+	@FuncTitle Filling a rectangle with the background color
896
+	@FuncDesc Fill a rectangle inside a console. For each cell in the rectangle :
897
+		* set the cell's background color to the console default background color
898
+		* if clear is true, set the cell's ASCII code to 32 (space)
899
+	@Cpp void TCODConsole::rect(int x, int y, int w, int h, bool clear, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT)
900
+	@C void TCOD_console_rect(TCOD_console_t con,int x, int y, int w, int h, bool clear, TCOD_bkgnd_flag_t flag)
901
+	@Py console_rect(con,x,  y,  w, h, clear, flag=BKGND_DEFAULT)
902
+	@C#
903
+		void TCODConsole::rect(int x, int y, int w, int h, bool clear)
904
+		void TCODConsole::rect(int x, int y, int w, int h, bool clear, TCODBackgroundFlag flag)
905
+	@Lua
906
+		Console:rect(x, y, w, h, clear)
907
+		Console:rect(x, y, w, h, clear, flag)
908
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
909
+	@Param x,y coordinates of rectangle upper-left corner in the console.
910
+		0 <= x < console width
911
+		0 <= y < console height
912
+	@Param w,h size of the rectangle in the console.
913
+		x <= x+w < console width
914
+		y <= y+h < console height
915
+	@Param clear if true, all characters inside the rectangle are set to ASCII code 32 (space).
916
+		If false, only the background color is modified
917
+	@Param flag this flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t
918
+	*/
919
+	void rect(int x, int y, int w, int h, bool clear, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT);
920
+
921
+	/**
922
+	@PageName console_advanced
923
+	@FuncTitle Drawing an horizontal line
924
+	@FuncDesc Draws an horizontal line in the console, using ASCII code TCOD_CHAR_HLINE (196), and the console's default background/foreground colors.
925
+	@Cpp void TCODConsole::hline(int x,int y, int l, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT)
926
+	@C void TCOD_console_hline(TCOD_console_t con,int x,int y, int l, TCOD_bkgnd_flag_t flag)
927
+	@Py console_hline(con,x,y,l,flag=BKGND_DEFAULT)
928
+	@C#
929
+		void TCODConsole::hline(int x,int y, int l)
930
+		void TCODConsole::hline(int x,int y, int l, TCODBackgroundFlag flag)
931
+	@Lua
932
+		Console:hline(x,y, l)
933
+		Console:hline(x,y, l, flag)
934
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
935
+	@Param x,y Coordinates of the line's left end in the console.
936
+		0 <= x < console width
937
+		0 <= y < console height
938
+	@Param l The length of the line in cells 1 <= l <= console width - x
939
+	@Param flag this flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t
940
+	*/
941
+	void hline(int x,int y, int l, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT);
942
+
943
+	/**
944
+	@PageName console_advanced
945
+	@FuncTitle Drawing an vertical line
946
+	@FuncDesc Draws an vertical line in the console, using ASCII code TCOD_CHAR_VLINE (179), and the console's default background/foreground colors.
947
+	@Cpp void TCODConsole::vline(int x,int y, int l, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT)
948
+	@C void TCOD_console_vline(TCOD_console_t con,int x,int y, int l, TCOD_bkgnd_flag_t flag)
949
+	@Py console_vline(con,x,y,l,flag=BKGND_DEFAULT)
950
+	@C#
951
+		void TCODConsole::vline(int x,int y, int l)
952
+		void TCODConsole::vline(int x,int y, int l, TCODBackgroundFlag flag)
953
+	@Lua
954
+		Console:vline(x,y, l)
955
+		Console:vline(x,y, l, flag)
956
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
957
+	@Param x,y Coordinates of the line's upper end in the console.
958
+		0 <= x < console width
959
+		0 <= y < console height
960
+	@Param l The length of the line in cells 1 <= l <= console height - y
961
+	@Param flag this flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t
962
+	*/
963
+	void vline(int x,int y, int l, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT);
964
+
965
+	/**
966
+	@PageName console_advanced
967
+	@FuncTitle Drawing a window frame
968
+	@FuncDesc This function calls the rect function using the supplied background mode flag, then draws a rectangle with the console's default foreground color. If fmt is not NULL, it is printed on the top of the rectangle, using inverted colors.
969
+	@Cpp void TCODConsole::printFrame(int x,int y,int w,int h, bool clear=true, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT, const char *fmt=NULL, ...)
970
+	@C void TCOD_console_print_frame(TCOD_console_t con,int x,int y,int w,int h, bool clear, TCOD_bkgnd_flag_t flag, const char *fmt, ...)
971
+	@Py console_print_frame(con,x, y, w, h, clear=True, flag=BKGND_DEFAULT, fmt=0)
972
+	@C#
973
+		void TCODConsole::printFrame(int x,int y, int w,int h)
974
+		void TCODConsole::printFrame(int x,int y, int w,int h, bool clear)
975
+		void TCODConsole::printFrame(int x,int y, int w,int h, bool clear, TCODBackgroundFlag flag)
976
+		void TCODConsole::printFrame(int x,int y, int w,int h, bool clear, TCODBackgroundFlag flag, string fmt)
977
+	@Lua
978
+		Console:printFrame(x,y, w,h)
979
+		Console:printFrame(x,y, w,h, clear)
980
+		Console:printFrame(x,y, w,h, clear, flag)
981
+		Console:printFrame(x,y, w,h, clear, flag, fmt)
982
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
983
+	@Param x,y Coordinates of the rectangle's upper-left corner in the console.
984
+		0 <= x < console width
985
+		0 <= y < console height
986
+	@Param w,h size of the rectangle in the console.
987
+		x <= x+w < console width
988
+		y <= y+h < console height
989
+	@Param clear if true, all characters inside the rectangle are set to ASCII code 32 (space).
990
+		If false, only the background color is modified
991
+	@Param flag this flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t
992
+	@Param fmt if NULL, the funtion only draws a rectangle.
993
+		Else, printf-like format string, eventually followed by parameters. You can use control codes to change the colors inside the string.
994
+	*/
995
+	void printFrame(int x,int y,int w,int h, bool clear=true, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT, const char *fmt=NULL, ...);
996
+
997
+	/**
998
+	@PageName console_read
999
+	@PageTitle Reading the content of the console
1000
+	@PageFather console_draw
1001
+	@FuncTitle Get the console's width
1002
+	@FuncDesc This function returns the width of a console (either the root console or an offscreen console)
1003
+	@Cpp int TCODConsole::getWidth() const
1004
+	@C int TCOD_console_get_width(TCOD_console_t con)
1005
+	@Py console_get_width(con)
1006
+	@C# int TCODConsole::getWidth()
1007
+	@Lua Console:getWidth()
1008
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
1009
+	*/
1010
+	int getWidth() const;
1011
+
1012
+	/**
1013
+	@PageName console_read
1014
+	@FuncTitle Get the console's height
1015
+	@FuncDesc This function returns the height of a console (either the root console or an offscreen console)
1016
+	@Cpp int TCODConsole::getHeight() const
1017
+	@C int TCOD_console_get_height(TCOD_console_t con)
1018
+	@Py console_get_height(con)
1019
+	@C# int TCODConsole::getHeight()
1020
+	@Lua Console:getHeight()
1021
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
1022
+	*/
1023
+	int getHeight() const;
1024
+
1025
+	/**
1026
+	@PageName console_read
1027
+	@FuncTitle Reading the default background color
1028
+	@FuncDesc This function returns the default background color of a console.
1029
+	@Cpp TCODColor TCODConsole::getDefaultBackground() const
1030
+	@C TCOD_color_t TCOD_console_get_default_background(TCOD_console_t con)
1031
+	@Py console_get_default_background(con)
1032
+	@C# TCODColor TCODConsole::getBackgroundColor()
1033
+	@Lua Console:getBackgroundColor()
1034
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
1035
+	*/
1036
+	TCODColor getDefaultBackground() const;
1037
+
1038
+	/**
1039
+	@PageName console_read
1040
+	@FuncTitle Reading the default foreground color
1041
+	@FuncDesc This function returns the default foreground color of a console.
1042
+	@Cpp TCODColor TCODConsole::getDefaultForeground() const
1043
+	@C TCOD_color_t TCOD_console_get_default_foreground(TCOD_console_t con)
1044
+	@Py console_get_default_foreground(con)
1045
+	@C# TCODColor TCODConsole::getForegroundColor()
1046
+	@Lua Console:getForegroundColor()
1047
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
1048
+	*/
1049
+	TCODColor getDefaultForeground() const;
1050
+
1051
+	/**
1052
+	@PageName console_read
1053
+	@FuncTitle Reading the background color of a cell
1054
+	@FuncDesc This function returns the background color of a cell.
1055
+	@Cpp TCODColor TCODConsole::getCharBackground(int x, int y) const
1056
+	@C TCOD_color_t TCOD_console_get_char_background(TCOD_console_t con,int x, int y)
1057
+	@Py console_get_char_background(con,x,y)
1058
+	@C# TCODColor TCODConsole::getCharBackground(int x, int y)
1059
+	@Lua Console::getCharBackground(x, y)
1060
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
1061
+	@Param x,y coordinates of the cell in the console.
1062
+		0 <= x < console width
1063
+		0 <= y < console height
1064
+	*/
1065
+	TCODColor getCharBackground(int x, int y) const;
1066
+
1067
+	/**
1068
+	@PageName console_read
1069
+	@FuncTitle Reading the foreground color of a cell
1070
+	@FuncDesc This function returns the foreground color of a cell.
1071
+	@Cpp TCODColor TCODConsole::getCharForeground(int x, int y) const
1072
+	@C TCOD_color_t TCOD_console_get_char_foreground(TCOD_console_t con,int x, int y)
1073
+	@Py console_get_char_foreground(con,x,y)
1074
+	@C# TCODColor TCODConsole::getCharForeground(int x, int y)
1075
+	@Lua Console::getCharForeground(x, y)
1076
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
1077
+	@Param x,y coordinates of the cell in the console.
1078
+		0 <= x < console width
1079
+		0 <= y < console height
1080
+	*/
1081
+	TCODColor getCharForeground(int x, int y) const;
1082
+
1083
+	/**
1084
+	@PageName console_read
1085
+	@FuncTitle Reading the ASCII code of a cell
1086
+	@FuncDesc This function returns the ASCII code of a cell.
1087
+	@Cpp int TCODConsole::getChar(int x, int y) const
1088
+	@C int TCOD_console_get_char(TCOD_console_t con,int x, int y)
1089
+	@Py console_get_char(con,x,y)
1090
+	@C# int TCODConsole::getChar(int x, int y)
1091
+	@Lua Console::getChar(x, y)
1092
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
1093
+	@Param x,y coordinates of the cell in the console.
1094
+		0 <= x < console width
1095
+		0 <= y < console height
1096
+	*/
1097
+	int getChar(int x, int y) const;
1098
+
1099
+	/**
1100
+	@PageName console_fading
1101
+	@PageTitle Screen fading functions
1102
+	@PageFather console_draw
1103
+	@PageDesc Use these functions to easily fade to/from a color
1104
+	@FuncTitle Changing the fading parameters
1105
+	@FuncDesc This function defines the fading parameters, allowing to easily fade the game screen to/from a color. Once they are defined, the fading parameters are valid for ever. You don't have to call setFade for each rendered frame (unless you change the fading parameters).
1106
+	@Cpp static void TCODConsole::setFade(uint8 fade, const TCODColor &fadingColor)
1107
+	@C void TCOD_console_set_fade(uint8 fade, TCOD_color_t fadingColor)
1108
+	@Py console_set_fade(fade, fadingColor)
1109
+	@C# static void TCODConsole::setFade(byte fade, TCODColor fadingColor)
1110
+	@Lua tcod.console.setFade(fade, fadingColor)
1111
+	@Param fade the fading amount. 0 => the screen is filled with the fading color. 255 => no fading effect
1112
+	@Param fadingColor the color to use during the console flushing operation
1113
+	@CppEx
1114
+		for (int fade=255; fade >= 0; fade --) {
1115
+			TCODConsole::setFade(fade,TCODColor::black);
1116
+			TCODConsole::flush();
1117
+		}
1118
+	@CEx
1119
+		int fade;
1120
+		for (fade=255; fade >= 0; fade --) {
1121
+			TCOD_console_setFade(fade,TCOD_black);
1122
+			TCOD_console_flush();
1123
+		}
1124
+	@PyEx
1125
+		for fade in range(255,0) :
1126
+			libtcod.console_setFade(fade,libtcod.black)
1127
+			libtcod.console_flush()
1128
+	@LuaEx
1129
+		for fade=255,0,-1 do
1130
+			tcod.console.setFade(fade,tcod.color.black)
1131
+			tcod.console.flush()
1132
+		end
1133
+	*/
1134
+	static void setFade(uint8 fade, const TCODColor &fadingColor);
1135
+
1136
+	/**
1137
+	@PageName console_fading
1138
+	@FuncTitle Reading the fade amount
1139
+	@FuncDesc This function returns the current fade amount, previously defined by setFade.
1140
+	@Cpp static uint8 TCODConsole::getFade()
1141
+	@C uint8 TCOD_console_get_fade()
1142
+	@Py console_get_fade()
1143
+	@C# static byte TCODConsole::getFade()
1144
+	@Lua tcod.console.getFade()
1145
+	*/
1146
+	static uint8 getFade();
1147
+
1148
+	/**
1149
+	@PageName console_fading
1150
+	@FuncTitle Reading the fading color
1151
+	@FuncDesc This function returns the current fading color, previously defined by setFade.
1152
+	@Cpp static TCODColor TCODConsole::getFadingColor()
1153
+	@C TCOD_color_t TCOD_console_get_fading_color()
1154
+	@Py console_get_fading_color()
1155
+	@C# static TCODColor TCODConsole::getFadingColor()
1156
+	@Lua tcod.console.getFadingColor()
1157
+	*/
1158
+	static TCODColor getFadingColor();
1159
+
1160
+	/**
1161
+	@PageName console_flush
1162
+	@PageFather console
1163
+	@PageTitle Flushing the root console
1164
+	@FuncDesc Once the root console is initialized, you can use one of the printing functions to change the background colors, the foreground colors or the ASCII characters on the console.
1165
+		Once you've finished rendering the root console, you have to actually apply the updates to the screen with this function.
1166
+	@Cpp static void TCODConsole::flush()
1167
+	@C void TCOD_console_flush()
1168
+	@Py console_flush()
1169
+	@C# static void TCODConsole::flush()
1170
+	@Lua tcod.console.flush()
1171
+	*/
1172
+	static void flush();
1173
+
1174
+	/**
1175
+	@PageName console_ascii
1176
+	@PageTitle ASCII constants
1177
+	@PageFather console_draw
1178
+	@FuncDesc Some useful graphic characters in the terminal.bmp font. For the python version, remove TCOD_ from the constants. C# and Lua is in parenthesis :
1179
+		Single line walls:
1180
+		TCOD_CHAR_HLINE=196 (HorzLine)
1181
+		TCOD_CHAR_VLINE=179 (VertLine)
1182
+		TCOD_CHAR_NE=191 (NE)
1183
+		TCOD_CHAR_NW=218 (NW)
1184
+		TCOD_CHAR_SE=217 (SE)
1185
+		TCOD_CHAR_SW=192 (SW)
1186
+
1187
+		Double lines walls:
1188
+		TCOD_CHAR_DHLINE=205 (DoubleHorzLine)
1189
+		TCOD_CHAR_DVLINE=186 (DoubleVertLine)
1190
+		TCOD_CHAR_DNE=187 (DoubleNE)
1191
+		TCOD_CHAR_DNW=201 (DoubleNW)
1192
+		TCOD_CHAR_DSE=188 (DoubleSE)
1193
+		TCOD_CHAR_DSW=200 (DoubleSW)
1194
+
1195
+		Single line vertical/horizontal junctions (T junctions):
1196
+		TCOD_CHAR_TEEW=180 (TeeWest)
1197
+		TCOD_CHAR_TEEE=195 (TeeEast)
1198
+		TCOD_CHAR_TEEN=193 (TeeNorth)
1199
+		TCOD_CHAR_TEES=194 (TeeSouth)
1200
+
1201
+		Double line vertical/horizontal junctions (T junctions):
1202
+		TCOD_CHAR_DTEEW=185 (DoubleTeeWest)
1203
+		TCOD_CHAR_DTEEE=204 (DoubleTeeEast)
1204
+		TCOD_CHAR_DTEEN=202 (DoubleTeeNorth)
1205
+		TCOD_CHAR_DTEES=203 (DoubleTeeSouth)
1206
+
1207
+		Block characters:
1208
+		TCOD_CHAR_BLOCK1=176 (Block1)
1209
+		TCOD_CHAR_BLOCK2=177 (Block2)
1210
+		TCOD_CHAR_BLOCK3=178 (Block3)
1211
+
1212
+		Cross-junction between two single line walls:
1213
+		TCOD_CHAR_CROSS=197 (Cross)
1214
+
1215
+		Arrows:
1216
+		TCOD_CHAR_ARROW_N=24 (ArrowNorth)
1217
+		TCOD_CHAR_ARROW_S=25 (ArrowSouth)
1218
+		TCOD_CHAR_ARROW_E=26 (ArrowEast)
1219
+		TCOD_CHAR_ARROW_W=27 (ArrowWest)
1220
+
1221
+		Arrows without tail:
1222
+		TCOD_CHAR_ARROW2_N=30 (ArrowNorthNoTail)
1223
+		TCOD_CHAR_ARROW2_S=31 (ArrowSouthNoTail)
1224
+		TCOD_CHAR_ARROW2_E=16 (ArrowEastNoTail)
1225
+		TCOD_CHAR_ARROW2_W=17 (ArrowWestNoTail)
1226
+
1227
+		Double arrows:
1228
+		TCOD_CHAR_DARROW_H=29 (DoubleArrowHorz)
1229
+		TCOD_CHAR_ARROW_V=18 (DoubleArrowVert)
1230
+
1231
+		GUI stuff:
1232
+		TCOD_CHAR_CHECKBOX_UNSET=224
1233
+		TCOD_CHAR_CHECKBOX_SET=225
1234
+		TCOD_CHAR_RADIO_UNSET=9
1235
+		TCOD_CHAR_RADIO_SET=10
1236
+
1237
+		Sub-pixel resolution kit:
1238
+		TCOD_CHAR_SUBP_NW=226 (SubpixelNorthWest)
1239
+		TCOD_CHAR_SUBP_NE=227 (SubpixelNorthEast)
1240
+		TCOD_CHAR_SUBP_N=228 (SubpixelNorth)
1241
+		TCOD_CHAR_SUBP_SE=229 (SubpixelSouthEast)
1242
+		TCOD_CHAR_SUBP_DIAG=230 (SubpixelDiagonal)
1243
+		TCOD_CHAR_SUBP_E=231 (SubpixelEast)
1244
+		TCOD_CHAR_SUBP_SW=232 (SubpixelSouthWest)
1245
+
1246
+		Miscellaneous characters:
1247
+		TCOD_CHAR_SMILY = 1 (Smilie)
1248
+		TCOD_CHAR_SMILY_INV = 2 (SmilieInv)
1249
+		TCOD_CHAR_HEART = 3 (Heart)
1250
+		TCOD_CHAR_DIAMOND = 4 (Diamond)
1251
+		TCOD_CHAR_CLUB = 5 (Club)
1252
+		TCOD_CHAR_SPADE = 6 (Spade)
1253
+		TCOD_CHAR_BULLET = 7 (Bullet)
1254
+		TCOD_CHAR_BULLET_INV = 8 (BulletInv)
1255
+		TCOD_CHAR_MALE = 11 (Male)
1256
+		TCOD_CHAR_FEMALE = 12 (Female)
1257
+		TCOD_CHAR_NOTE = 13 (Note)
1258
+		TCOD_CHAR_NOTE_DOUBLE = 14 (NoteDouble)
1259
+		TCOD_CHAR_LIGHT = 15 (Light)
1260
+		TCOD_CHAR_EXCLAM_DOUBLE = 19 (ExclamationDouble)
1261
+		TCOD_CHAR_PILCROW = 20 (Pilcrow)
1262
+		TCOD_CHAR_SECTION = 21 (Section)
1263
+		TCOD_CHAR_POUND = 156 (Pound)
1264
+		TCOD_CHAR_MULTIPLICATION = 158 (Multiplication)
1265
+		TCOD_CHAR_FUNCTION = 159 (Function)
1266
+		TCOD_CHAR_RESERVED = 169 (Reserved)
1267
+		TCOD_CHAR_HALF = 171 (Half)
1268
+		TCOD_CHAR_ONE_QUARTER = 172 (OneQuarter)
1269
+		TCOD_CHAR_COPYRIGHT = 184 (Copyright)
1270
+		TCOD_CHAR_CENT = 189 (Cent)
1271
+		TCOD_CHAR_YEN = 190 (Yen)
1272
+		TCOD_CHAR_CURRENCY = 207 (Currency)
1273
+		TCOD_CHAR_THREE_QUARTERS = 243 (ThreeQuarters)
1274
+		TCOD_CHAR_DIVISION = 246 (Division)
1275
+		TCOD_CHAR_GRADE = 248 (Grade)
1276
+		TCOD_CHAR_UMLAUT = 249 (Umlaut)
1277
+		TCOD_CHAR_POW1 = 251 (Pow1)
1278
+		TCOD_CHAR_POW3 = 252 (Pow2)
1279
+		TCOD_CHAR_POW2 = 253 (Pow3)
1280
+		TCOD_CHAR_BULLET_SQUARE = 254 (BulletSquare)
1281
+	*/
1282
+
1283
+	/**
1284
+	@PageName console_input
1285
+	@PageTitle Handling user input
1286
+	@PageDesc The user handling functions allow you to get keyboard and mouse input from the user, either for turn by turn games (the function wait until the user press a key or a mouse button), or real time games (non blocking function).
1287
+	<b>WARNING : those functions also handle screen redraw event, so TCODConsole::flush function won't redraw screen if no user input function is called !</b>
1288
+	@PageFather console
1289
+	*/
1290
+
1291
+	/* deprecated as of 1.5.1 */
1292
+	static TCOD_key_t waitForKeypress(bool flush);
1293
+	/* deprecated as of 1.5.1 */
1294
+	static TCOD_key_t checkForKeypress(int flags=TCOD_KEY_RELEASED);
1295
+
1296
+	/**
1297
+	@PageName console_blocking_input
1298
+	@PageCategory Core
1299
+	@PageFather console_input
1300
+	@PageTitle Blocking user input
1301
+	@PageDesc This function stops the application until an event occurs.
1302
+	*/
1303
+
1304
+	/**
1305
+	@PageName console_non_blocking_input
1306
+	@PageTitle Non blocking user input
1307
+	@PageFather console_input
1308
+	@FuncDesc The prefered way to check for user input is to use checkForEvent below, but you can also get the status of any special key at any time with :
1309
+	@Cpp static bool TCODConsole::isKeyPressed(TCOD_keycode_t key)
1310
+	@C bool TCOD_console_is_key_pressed(TCOD_keycode_t key)
1311
+	@Py console_is_key_pressed(key)
1312
+	@C# static bool TCODConsole::isKeyPressed(TCODKeyCode key)
1313
+	@Lua tcod.console.isKeyPressed(key)
1314
+	@Param key Any key code defined in keycode_t except TCODK_CHAR (Char) and TCODK_NONE (NoKey)
1315
+	*/
1316
+	static bool isKeyPressed(TCOD_keycode_t key);
1317
+	/**
1318
+	@PageName console_keyboard_repeat
1319
+	@PageTitle Changing keyboard repeat delay
1320
+	@PageFather console_input
1321
+	@FuncDesc This function changes the keyboard repeat times.
1322
+	@Cpp static void TCODConsole::setKeyboardRepeat(int initialDelay, int interval)
1323
+	@C void TCOD_console_set_keyboard_repeat(int initial_delay, int interval)
1324
+	@Py console_set_keyboard_repeat(initial_delay, interval)
1325
+	@C# static void TCODConsole::setKeyboardRepeat(int initialDelay, int interval)
1326
+	@Lua tcod.console.setKeyboardRepeat(initialDelay, interval)
1327
+	@Param initialDelay delay in millisecond between the time when a key is pressed, and keyboard repeat begins. If 0, keyboard repeat is disabled
1328
+	@Param interval interval in millisecond between keyboard repeat events
1329
+	*/
1330
+	static void setKeyboardRepeat(int initialDelay,int interval);
1331
+	/**
1332
+	@PageName console_keyboard_repeat
1333
+	@FuncDesc You can also disable the keyboard repeat feature with this function (it's equivalent to setKeyboardRepeat(0,0) ).
1334
+	@Cpp static void TCODConsole::disableKeyboardRepeat()
1335
+	@C void TCOD_console_disable_keyboard_repeat()
1336
+	@Py console_disable_keyboard_repeat()
1337
+	@C# static void TCODConsole::disableKeyboardRepeat()
1338
+	@Lua tcod.console.disableKeyboardRepeat()
1339
+	*/
1340
+	static void disableKeyboardRepeat();
1341
+
1342
+	/**
1343
+	@PageName console_key_t
1344
+	@PageTitle 	Keyboard event structure
1345
+	@PageFather console_input
1346
+	@PageDesc This structure contains information about a key pressed/released by the user.
1347
+	@C
1348
+		typedef struct {
1349
+			TCOD_keycode_t vk;
1350
+			char c;
1351
+			bool pressed;
1352
+			bool lalt;
1353
+			bool lctrl;
1354
+			bool ralt;
1355
+			bool rctrl;
1356
+			bool shift;
1357
+		} TCOD_key_t;
1358
+	@Lua
1359
+		key.KeyCode
1360
+		key.Character
1361
+		key.Pressed
1362
+		key.LeftAlt
1363
+		key.LeftControl
1364
+		key.RightAlt
1365
+		key.RightControl
1366
+		key.Shift
1367
+	@Param vk An arbitrary value representing the physical key on the keyboard. Possible values are stored in the TCOD_keycode_t enum. If no key was pressed, the value is TCODK_NONE
1368
+	@Param c If the key correspond to a printable character, the character is stored in this field. Else, this field contains 0.
1369
+	@Param pressed true if the event is a key pressed, or false for a key released.
1370
+	@Param lalt This field represents the status of the left Alt key : true => pressed, false => released.
1371
+	@Param lctrl This field represents the status of the left Control key : true => pressed, false => released.
1372
+	@Param ralt This field represents the status of the right Alt key : true => pressed, false => released.
1373
+	@Param rctrl This field represents the status of the right Control key : true => pressed, false => released.
1374
+	@Param shift This field represents the status of the shift key : true => pressed, false => released.
1375
+	*/
1376
+
1377
+	/**
1378
+	@PageName console_mouse_t
1379
+	@PageTitle Mouse event structure
1380
+	@PageFather console_input
1381
+	@PageDesc This tructure contains information about a mouse move/press/release event.
1382
+	@C
1383
+		typedef struct {
1384
+		  int x,y;
1385
+		  int dx,dy;
1386
+		  int cx,cy;
1387
+		  int dcx,dcy;
1388
+		  bool lbutton;
1389
+		  bool rbutton;
1390
+		  bool mbutton;
1391
+		  bool lbutton_pressed;
1392
+		  bool rbutton_pressed;
1393
+		  bool mbutton_pressed;
1394
+		  bool wheel_up;
1395
+		  bool wheel_down;
1396
+		} TCOD_mouse_t;
1397
+	@Param x,y Absolute position of the mouse cursor in pixels relative to the window top-left corner.
1398
+	@Param dx,dy Movement of the mouse cursor since the last call in pixels.
1399
+	@Param cx,cy Coordinates of the console cell under the mouse cursor (pixel coordinates divided by the font size).
1400
+	@Param dcx,dcy Movement of the mouse since the last call in console cells (pixel coordinates divided by the font size).
1401
+	@Param lbutton true if the left button is pressed.
1402
+	@Param rbutton true if the right button is pressed.
1403
+	@Param mbutton true if the middle button (or the wheel) is pressed.
1404
+	@Param lbutton_pressed true if the left button was pressed and released.
1405
+	@Param rbutton_pressed true if the right button was pressed and released.
1406
+	@Param mbutton_pressed true if the middle button was pressed and released.
1407
+	@Param wheel_up true if the wheel was rolled up.
1408
+	@Param wheel_down true if the wheel was rolled down.
1409
+	*/
1410
+
1411
+	/**
1412
+	@PageName console_keycode_t
1413
+	@PageTitle 	Key codes
1414
+	@PageFather console_input
1415
+	@PageDesc TCOD_keycode_t is a libtcod specific code representing a key on the keyboard.
1416
+		For python, replace TCODK by KEY: libtcod.KEY_NONE. C# and Lua, the value is in parenthesis. Possible values are :
1417
+		When no key was pressed (see checkForEvent) : TCOD_NONE (NoKey)
1418
+		Special keys :
1419
+		TCODK_ESCAPE (Escape)
1420
+		TCODK_BACKSPACE (Backspace)
1421
+		TCODK_TAB (Tab)
1422
+		TCODK_ENTER (Enter)
1423
+		TCODK_SHIFT (Shift)
1424
+		TCODK_CONTROL (Control)
1425
+		TCODK_ALT (Alt)
1426
+		TCODK_PAUSE (Pause)
1427
+		TCODK_CAPSLOCK (CapsLock)
1428
+		TCODK_PAGEUP (PageUp)
1429
+		TCODK_PAGEDOWN (PageDown)
1430
+		TCODK_END (End)
1431
+		TCODK_HOME (Home)
1432
+		TCODK_UP (Up)
1433
+		TCODK_LEFT (Left)
1434
+		TCODK_RIGHT (Right)
1435
+		TCODK_DOWN (Down)
1436
+		TCODK_PRINTSCREEN (Printscreen)
1437
+		TCODK_INSERT (Insert)
1438
+		TCODK_DELETE (Delete)
1439
+		TCODK_LWIN (Lwin)
1440
+		TCODK_RWIN (Rwin)
1441
+		TCODK_APPS (Apps)
1442
+		TCODK_KPADD (KeypadAdd)
1443
+		TCODK_KPSUB (KeypadSubtract)
1444
+		TCODK_KPDIV (KeypadDivide)
1445
+		TCODK_KPMUL (KeypadMultiply)
1446
+		TCODK_KPDEC (KeypadDecimal)
1447
+		TCODK_KPENTER (KeypadEnter)
1448
+		TCODK_F1 (F1)
1449
+		TCODK_F2 (F2)
1450
+		TCODK_F3 (F3)
1451
+		TCODK_F4 (F4)
1452
+		TCODK_F5 (F5)
1453
+		TCODK_F6 (F6)
1454
+		TCODK_F7 (F7)
1455
+		TCODK_F8 (F8)
1456
+		TCODK_F9 (F9)
1457
+		TCODK_F10 (F10)
1458
+		TCODK_F11 (F11)
1459
+		TCODK_F12 (F12)
1460
+		TCODK_NUMLOCK (Numlock)
1461
+		TCODK_SCROLLLOCK (Scrolllock)
1462
+		TCODK_SPACE (Space)
1463
+
1464
+		numeric keys :
1465
+
1466
+		TCODK_0 (Zero)
1467
+		TCODK_1 (One)
1468
+		TCODK_2 (Two)
1469
+		TCODK_3 (Three)
1470
+		TCODK_4 (Four)
1471
+		TCODK_5 (Five)
1472
+		TCODK_6 (Six)
1473
+		TCODK_7 (Seven)
1474
+		TCODK_8 (Eight)
1475
+		TCODK_9 (Nine)
1476
+		TCODK_KP0 (KeypadZero)
1477
+		TCODK_KP1 (KeypadOne)
1478
+		TCODK_KP2 (KeypadTwo)
1479
+		TCODK_KP3 (KeypadThree)
1480
+		TCODK_KP4 (KeypadFour)
1481
+		TCODK_KP5 (KeypadFive)
1482
+		TCODK_KP6 (KeypadSix)
1483
+		TCODK_KP7 (KeypadSeven)
1484
+		TCODK_KP8 (KeypadEight)
1485
+		TCODK_KP9 (KeypadNine)
1486
+
1487
+		Any other (printable) key :
1488
+
1489
+		TCODK_CHAR (Char)
1490
+
1491
+		Codes starting with TCODK_KP represents keys on the numeric keypad (if available).
1492
+	*/
1493
+
1494
+	/**
1495
+	@PageName console_offscreen
1496
+	@PageFather console
1497
+	@PageTitle Using off-screen consoles
1498
+	@PageDesc The offscreen consoles allow you to draw on secondary consoles as you would do with the root console. You can then blit those secondary consoles on the root console. This allows you to use local coordinate space while rendering a portion of the final screen, and easily move components of the screen without modifying the rendering functions.
1499
+	@FuncTitle Creating an offscreen console
1500
+	@FuncDesc You can create as many off-screen consoles as you want by using this function. You can draw on them as you would do with the root console, but you cannot flush them to the screen. Else, you can blit them on other consoles, including the root console. See blit. The C version of this function returns a console handler that you can use in most console drawing functions.
1501
+	@Cpp TCODConsole::TCODConsole(int w, int h)
1502
+	@C TCOD_console_t TCOD_console_new(int w, int h)
1503
+	@Py console_new(w,h)
1504
+	@C# TCODConsole::TCODConsole(int w, int h)
1505
+	@Lua tcod.Console(w,h)
1506
+	@Param w,h the console size.
1507
+		0 < w
1508
+		0 < h
1509
+	@CppEx
1510
+		// Creating a 40x20 offscreen console, filling it with red and blitting it on the root console at position 5,5
1511
+		TCODConsole *offscreenConsole = new TCODConsole(40,20);
1512
+		offscreenConsole->setDefaultBackground(TCODColor::red);
1513
+		offscreenConsole->clear();
1514
+		TCODConsole::blit(offscreenConsole,0,0,40,20,TCODConsole::root,5,5,255);
1515
+	@CEx
1516
+		TCOD_console_t offscreen_console = TCOD_console_new(40,20);
1517
+		TCOD_console_set_default_background(offscreen_console,TCOD_red);
1518
+		TCOD_console_clear(offscreen_console);
1519
+		TCOD_console_blit(offscreen_console,0,0,40,20,NULL,5,5,255);
1520
+	@PyEx
1521
+		offscreen_console = libtcod.console_new(40,20)
1522
+		libtcod.console_set_background_color(offscreen_console,libtcod.red)
1523
+		libtcod.console_clear(offscreen_console)
1524
+		libtcod.console_blit(offscreen_console,0,0,40,20,0,5,5,255)
1525
+	@LuaEx
1526
+		-- Creating a 40x20 offscreen console, filling it with red and blitting it on the root console at position 5,5
1527
+		offscreenConsole = tcod.Console(40,20)
1528
+		offscreenConsole:setBackgroundColor(tcod.color.red)
1529
+		offscreenConsole:clear()
1530
+		tcod.console.blit(offscreenConsole,0,0,40,20,libtcod.TCODConsole_root,5,5,255)
1531
+	*/
1532
+	TCODConsole(int w, int h);
1533
+	
1534
+	/**
1535
+	@PageName console_offscreen
1536
+	@FuncTitle Creating an offscreen console from a .asc or .apf file
1537
+	@FuncDesc You can create an offscreen console from a file created with Ascii Paint with this constructor
1538
+	@Cpp TCODConsole::TCODConsole(const char *filename)
1539
+	@C TCOD_console_t TCOD_console_from_file(const char *filename)
1540
+	@Param filename path to the .asc or .apf file created with Ascii Paint
1541
+	@CppEx
1542
+		// Creating an offscreen console, filling it with data from the .asc file
1543
+		TCODConsole *offscreenConsole = new TCODConsole("myfile.asc");
1544
+	@CEx
1545
+		TCOD_console_t offscreen_console = TCOD_console_from_file("myfile.apf");
1546
+	*/
1547
+	TCODConsole(const char *filename);
1548
+
1549
+	/**
1550
+	@PageName console_offscreen
1551
+	@FuncTitle Loading an offscreen console from a .asc file
1552
+	@FuncDesc You can load data from a file created with Ascii Paint with this function. When needed, the console will be resized to fit the file size. The function returns false if it couldn't read the file.
1553
+	@Cpp bool TCODConsole::loadAsc(const char *filename)
1554
+	@C bool TCOD_console_load_asc(TCOD_console_t con, const char *filename)
1555
+	@Param con in the C and Python versions, the offscreen console handler
1556
+	@Param filename path to the .asc file created with Ascii Paint
1557
+	@CppEx
1558
+		// Creating a 40x20 offscreen console
1559
+		TCODConsole *offscreenConsole = new TCODConsole(40,20);
1560
+		// possibly resizing it and filling it with data from the .asc file
1561
+		offscreenConsole->loadAsc("myfile.asc");
1562
+	@CEx
1563
+		TCOD_console_t offscreen_console = TCOD_console_new(40,20);
1564
+		TCOD_console_load_asc(offscreen_console,"myfile.asc");
1565
+	*/
1566
+	bool loadAsc(const char *filename);
1567
+	/**
1568
+	@PageName console_offscreen
1569
+	@FuncTitle Loading an offscreen console from a .apf file
1570
+	@FuncDesc You can load data from a file created with Ascii Paint with this function. When needed, the console will be resized to fit the file size. The function returns false if it couldn't read the file.
1571
+	@Cpp bool TCODConsole::loadApf(const char *filename)
1572
+	@C bool TCOD_console_load_apf(TCOD_console_t con, const char *filename)
1573
+	@Param con in the C and Python versions, the offscreen console handler
1574
+
1575
+	@Param filename path to the .apf file created with Ascii Paint
1576
+
1577
+	@CppEx
1578
+		// Creating a 40x20 offscreen console
1579
+		TCODConsole *offscreenConsole = new TCODConsole(40,20);
1580
+		// possibly resizing it and filling it with data from the .apf file
1581
+		offscreenConsole->loadApf("myfile.apf");
1582
+	@CEx
1583
+		TCOD_console_t offscreen_console = TCOD_console_new(40,20);
1584
+		TCOD_console_load_apf(offscreen_console,"myfile.asc");
1585
+	*/
1586
+	bool loadApf(const char *filename);
1587
+
1588
+    /**
1589
+	@PageName console_offscreen
1590
+	@FuncTitle Saving a console to a .asc file
1591
+	@FuncDesc You can save data from a console to Ascii Paint format with this function. The function returns false if it couldn't write the file. This is the only ASC function that works also with the root console !
1592
+	@Cpp bool TCODConsole::saveAsc(const char *filename) const
1593
+	@C bool TCOD_console_save_asc(TCOD_console_t con, const char *filename)
1594
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
1595
+	@Param filename path to the .asc file to be created
1596
+	@CppEx
1597
+		console->saveAsc("myfile.asc");
1598
+	@CEx
1599
+		TCOD_console_save_asc(console,"myfile.asc");
1600
+	*/
1601
+	bool saveAsc(const char *filename) const;
1602
+
1603
+    /**
1604
+	@PageName console_offscreen
1605
+	@FuncTitle Saving a console to a .apf file
1606
+	@FuncDesc You can save data from a console to Ascii Paint format with this function. The function returns false if it couldn't write the file. This is the only ASC function that works also with the root console !
1607
+	@Cpp bool TCODConsole::saveApf(const char *filename) const
1608
+	@C bool TCOD_console_save_apf(TCOD_console_t con, const char *filename)
1609
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
1610
+	@Param filename path to the .apf file to be created
1611
+	@CppEx
1612
+		console->saveApf("myfile.apf");
1613
+	@CEx
1614
+		TCOD_console_save_apf(console,"myfile.apf");
1615
+	*/
1616
+	bool saveApf(const char *filename) const;
1617
+	
1618
+	/**
1619
+	@PageName console_offscreen
1620
+	@FuncTitle Blitting a console on another one
1621
+	@FuncDesc This function allows you to blit a rectangular area of the source console at a specific position on a destination console. It can also simulate alpha transparency with the fade parameter.
1622
+	@Cpp static void blit(const TCODConsole *src,int xSrc, int ySrc, int wSrc, int hSrc, TCODConsole *dst, int xDst, int yDst, float foregroundAlpha=1.0f, float backgroundAlpha=1.0f)
1623
+	@C void TCOD_console_blit(TCOD_console_t src,int xSrc, int ySrc, int wSrc, int hSrc, TCOD_console_t dst, int xDst, int yDst, float foreground_alpha, float background_alpha)
1624
+	@Py console_blit(src,xSrc,ySrc,xSrc,hSrc,dst,xDst,yDst,foregroundAlpha=1.0,backgroundAlpha=1.0)
1625
+	@C#
1626
+		static void TCODConsole::blit(TCODConsole src, int xSrc, int ySrc, int wSrc, int hSrc, TCODConsole dst, int xDst, int yDst)
1627
+		static void TCODConsole::blit(TCODConsole src, int xSrc, int ySrc, int wSrc, int hSrc, TCODConsole dst, int xDst, int yDst, float foreground_alpha)
1628
+		static void TCODConsole::blit(TCODConsole src, int xSrc, int ySrc, int wSrc, int hSrc, TCODConsole dst, int xDst, int yDst, float foreground_alpha, float background_alpha)
1629
+	@Lua
1630
+		tcod.console.blit(src, xSrc, ySrc, wSrc, hSrc, dst, xDst, yDst)
1631
+		tcod.console.blit(src, xSrc, ySrc, wSrc, hSrc, dst, xDst, yDst, foreground_alpha)
1632
+		tcod.console.blit(src, xSrc, ySrc, wSrc, hSrc, dst, xDst, yDst, foreground_alpha, background_alpha)
1633
+	@Param src The source console that must be blitted on another one.
1634
+	@Param xSrc,ySrc,wSrc,hSrc The rectangular area of the source console that will be blitted. If wSrc and/or hSrc == 0, the source console width/height are used
1635
+	@Param dst The destination console.
1636
+	@Param xDst,yDst Where to blit the upper-left corner of the source area in the destination console.
1637
+	@Param foregroundAlpha,backgroundAlpha Alpha transparency of the blitted console.
1638
+		0.0 => The source console is completely transparent. This function does nothing.
1639
+		1.0 => The source console is opaque. Its cells replace the destination cells.
1640
+		0 < fade < 1.0 => The source console is partially blitted, simulating real transparency.
1641
+	@CppEx
1642
+		// Cross-fading between two offscreen consoles. We use two offscreen consoles with the same size as the root console. We render a different screen on each offscreen console. When the user hits a key, we do a cross-fading from the first screen to the second screen.
1643
+		TCODConsole *off1 = new TCODConsole(80,50);
1644
+		TCODConsole *off2 = new TCODConsole(80,50);
1645
+		... print screen1 on off1
1646
+		... print screen2 of off2
1647
+		// render screen1 in the game window
1648
+		TCODConsole::blit(off1,0,0,80,50,TCODConsole::root,0,0);
1649
+		TCODConsole::flush();
1650
+		// wait or a keypress
1651
+		TCODConsole::waitForKeypress(true);
1652
+		// do a cross-fading from off1 to off2
1653
+		for (int i=1; i <= 255; i++) {
1654
+			TCODConsole::blit(off1,0,0,80,50,TCODConsole::root,0,0); // renders the first screen (opaque)
1655
+			TCODConsole::blit(off2,0,0,80,50,TCODConsole::root,0,0,i/255.0,i/255.0); // renders the second screen (transparent)
1656
+			TCODConsole::flush();
1657
+		}
1658
+	@CEx
1659
+		TCOD_console_t off1 = TCOD_console_new(80,50);
1660
+		TCOD_console_t off2 = TCOD_console_new(80,50);
1661
+		int i;
1662
+		... print screen1 on off1
1663
+		... print screen2 of off2
1664
+		// render screen1 in the game window
1665
+		TCOD_console_blit(off1,0,0,80,50,NULL,0,0,1.0,1.0);
1666
+		TCOD_console_flush();
1667
+		// wait or a keypress
1668
+		TCOD_console_wait_for_keypress(true);
1669
+		// do a cross-fading from off1 to off2
1670
+		for (i=1; i <= 255; i++) {
1671
+			TCOD_console_blit(off1,0,0,80,50,NULL,0,0,1.0,1.0); // renders the first screen (opaque)
1672
+			TCOD_console_blit(off2,0,0,80,50,NULL,0,0,i/255.0,i/255.0); // renders the second screen (transparent)
1673
+			TCOD_console_flush();
1674
+		}
1675
+	@PyEx
1676
+		off1 = libtcod.console_new(80,50)
1677
+		off2 = libtcod.console_new(80,50)
1678
+		... print screen1 on off1
1679
+		... print screen2 of off2
1680
+		# render screen1 in the game window
1681
+		libtcod.console_blit(off1,0,0,80,50,0,0,0)
1682
+		libtcod.console_flush()
1683
+		# wait or a keypress
1684
+		libtcod.console_wait_for_keypress(True)
1685
+		# do a cross-fading from off1 to off2
1686
+		for i in range(1,256) :
1687
+			litbcod.console_blit(off1,0,0,80,50,0,0,0) # renders the first screen (opaque)
1688
+			litbcod.console_blit(off2,0,0,80,50,0,0,0,i/255.0,i/255.0) # renders the second screen (transparent)
1689
+			litbcod.console_flush()
1690
+	@LuaEx
1691
+		-- Cross-fading between two offscreen consoles. We use two offscreen consoles with the same size as the root console. We render a different screen on each offscreen console. When the user hits a key, we do a cross-fading from the first screen to the second screen.
1692
+		off1 = tcod.Console(80,50)
1693
+		off2 = tcod.Console(80,50)
1694
+		... print screen1 on off1
1695
+		... print screen2 of off2
1696
+		-- render screen1 in the game window
1697
+		root=libtcod.TCODConsole_root
1698
+		tcod.console.blit(off1,0,0,80,50,root,0,0)
1699
+		tcod.console.flush()
1700
+		-- wait or a keypress
1701
+		tcod.console.waitForKeypress(true)
1702
+		-- do a cross-fading from off1 to off2
1703
+		for i=1,255,1 do
1704
+			tcod.console.blit(off1,0,0,80,50,root,0,0) -- renders the first screen (opaque)
1705
+			tcod.console.blit(off2,0,0,80,50,root,0,0,i/255,i/255) -- renders the second screen (transparent)
1706
+			tcod.console.flush()
1707
+		end
1708
+	*/
1709
+	static void blit(const TCODConsole *src,int xSrc, int ySrc, int wSrc, int hSrc, TCODConsole *dst, int xDst, int yDst, float foreground_alpha=1.0f, float background_alpha=1.0f);
1710
+	/**
1711
+	@PageName console_offscreen
1712
+	@FuncTitle Define a blit-transparent color
1713
+	@FuncDesc This function defines a transparent background color for an offscreen console. All cells with this background color are ignored by the blit operation. You can use it to blit only some parts of the console.
1714
+	@Cpp void TCODConsole::setKeyColor(const TCODColor &col)
1715
+	@C void TCOD_console_set_key_color(TCOD_console_t con,TCOD_color_t col)
1716
+	@Py console_set_key_color(con,col)
1717
+	@C# void TCODConsole::setKeyColor(TCODColor col)
1718
+	@Lua Console:setKeyColor(col)
1719
+	@Param con in the C and Python versions, the offscreen console handler or NULL for the root console
1720
+	@Param col the transparent background color
1721
+	*/
1722
+	void setKeyColor(const TCODColor &col);
1723
+	/**
1724
+	@PageName console_offscreen
1725
+	@FuncTitle Destroying an offscreen console
1726
+	@FuncDesc Use this function to destroy an offscreen console and release any resources allocated. Don't use it on the root console.
1727
+	@Cpp TCODConsole::~TCODConsole()
1728
+	@C void TCOD_console_delete(TCOD_console_t con)
1729
+	@Py console_delete(con)
1730
+	@C# void TCODConsole::Dispose()
1731
+	@Lua through garbage collector
1732
+	@Param con in the C and Python versions, the offscreen console handler
1733
+	@CppEx
1734
+		TCODConsole *off1 = new TCODConsole(80,50);
1735
+		... use off1
1736
+		delete off1; // destroy the offscreen console
1737
+	@CEx
1738
+		TCOD_console_t off1 = TCOD_console_new(80,50);
1739
+		... use off1
1740
+		TCOD_console_delete(off1); // destroy the offscreen console
1741
+	@PyEx
1742
+		off1 = libtcod.console_new(80,50)
1743
+		... use off1
1744
+		libtcod.console_delete(off1) # destroy the offscreen console
1745
+	@LuaEx
1746
+		off1 = tcod.Console(80,50)
1747
+		... use off1
1748
+		off1=nil -- release the reference
1749
+	*/
1750
+	virtual ~TCODConsole();
1751
+
1752
+	void setDirty(int x, int y, int w, int h);
1753
+
1754
+
1755
+	TCODConsole(TCOD_console_t con) : data(con) {}
1756
+
1757
+    // ctrl = TCOD_COLCTRL_1...TCOD_COLCTRL_5 or TCOD_COLCTRL_STOP
1758
+	static const char *getColorControlString( TCOD_colctrl_t ctrl );
1759
+	// ctrl = TCOD_COLCTRL_FORE_RGB or TCOD_COLCTRL_BACK_RGB
1760
+	static const char *getRGBColorControlString( TCOD_colctrl_t ctrl, const TCODColor & col );
1761
+
1762
+protected :
1763
+	friend class TCODLIB_API TCODImage;
1764
+	friend class TCODLIB_API TCODZip;
1765
+	friend class TCODLIB_API TCODText;
1766
+	TCODConsole();
1767
+	TCOD_console_t data;
1768
+};
1769
+
1770
+#endif
0 1771
new file mode 100644
... ...
@@ -0,0 +1,261 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_CONSOLE_TYPES_H
29
+#define _TCOD_CONSOLE_TYPES_H
30
+
31
+typedef enum {
32
+	TCODK_NONE,
33
+	TCODK_ESCAPE,
34
+	TCODK_BACKSPACE,
35
+	TCODK_TAB,
36
+	TCODK_ENTER,
37
+	TCODK_SHIFT,
38
+	TCODK_CONTROL,
39
+	TCODK_ALT,
40
+	TCODK_PAUSE,
41
+	TCODK_CAPSLOCK,
42
+	TCODK_PAGEUP,
43
+	TCODK_PAGEDOWN,
44
+	TCODK_END,
45
+	TCODK_HOME,
46
+	TCODK_UP,
47
+	TCODK_LEFT,
48
+	TCODK_RIGHT,
49
+	TCODK_DOWN,
50
+	TCODK_PRINTSCREEN,
51
+	TCODK_INSERT,
52
+	TCODK_DELETE,
53
+	TCODK_LWIN,
54
+	TCODK_RWIN,
55
+	TCODK_APPS,
56
+	TCODK_0,
57
+	TCODK_1,
58
+	TCODK_2,
59
+	TCODK_3,
60
+	TCODK_4,
61
+	TCODK_5,
62
+	TCODK_6,
63
+	TCODK_7,
64
+	TCODK_8,
65
+	TCODK_9,
66
+	TCODK_KP0,
67
+	TCODK_KP1,
68
+	TCODK_KP2,
69
+	TCODK_KP3,
70
+	TCODK_KP4,
71
+	TCODK_KP5,
72
+	TCODK_KP6,
73
+	TCODK_KP7,
74
+	TCODK_KP8,
75
+	TCODK_KP9,
76
+	TCODK_KPADD,
77
+	TCODK_KPSUB,
78
+	TCODK_KPDIV,
79
+	TCODK_KPMUL,
80
+	TCODK_KPDEC,
81
+	TCODK_KPENTER,
82
+	TCODK_F1,
83
+	TCODK_F2,
84
+	TCODK_F3,
85
+	TCODK_F4,
86
+	TCODK_F5,
87
+	TCODK_F6,
88
+	TCODK_F7,
89
+	TCODK_F8,
90
+	TCODK_F9,
91
+	TCODK_F10,
92
+	TCODK_F11,
93
+	TCODK_F12,
94
+	TCODK_NUMLOCK,
95
+	TCODK_SCROLLLOCK,
96
+	TCODK_SPACE,
97
+	TCODK_CHAR
98
+} TCOD_keycode_t;
99
+
100
+/* key data : special code or character */
101
+typedef struct {
102
+	TCOD_keycode_t vk; /*  key code */
103
+	char c; /* character if vk == TCODK_CHAR else 0 */
104
+	bool pressed ; /* does this correspond to a key press or key release event ? */
105
+	bool lalt ;
106
+	bool lctrl ;
107
+	bool ralt ;
108
+	bool rctrl ;
109
+	bool shift ;
110
+} TCOD_key_t;
111
+
112
+typedef enum {
113
+	/* single walls */
114
+	TCOD_CHAR_HLINE=196,
115
+	TCOD_CHAR_VLINE=179,
116
+	TCOD_CHAR_NE=191,
117
+	TCOD_CHAR_NW=218,
118
+	TCOD_CHAR_SE=217,
119
+	TCOD_CHAR_SW=192,
120
+	TCOD_CHAR_TEEW=180,
121
+	TCOD_CHAR_TEEE=195,
122
+	TCOD_CHAR_TEEN=193,
123
+	TCOD_CHAR_TEES=194,
124
+	TCOD_CHAR_CROSS=197,
125
+	/* double walls */
126
+	TCOD_CHAR_DHLINE=205,
127
+	TCOD_CHAR_DVLINE=186,
128
+	TCOD_CHAR_DNE=187,
129
+	TCOD_CHAR_DNW=201,
130
+	TCOD_CHAR_DSE=188,
131
+	TCOD_CHAR_DSW=200,
132
+	TCOD_CHAR_DTEEW=185,
133
+	TCOD_CHAR_DTEEE=204,
134
+	TCOD_CHAR_DTEEN=202,
135
+	TCOD_CHAR_DTEES=203,
136
+	TCOD_CHAR_DCROSS=206,
137
+	/* blocks */
138
+	TCOD_CHAR_BLOCK1=176,
139
+	TCOD_CHAR_BLOCK2=177,
140
+	TCOD_CHAR_BLOCK3=178,
141
+	/* arrows */
142
+	TCOD_CHAR_ARROW_N=24,
143
+	TCOD_CHAR_ARROW_S=25,
144
+	TCOD_CHAR_ARROW_E=26,
145
+	TCOD_CHAR_ARROW_W=27,
146
+	/* arrows without tail */
147
+	TCOD_CHAR_ARROW2_N=30,
148
+	TCOD_CHAR_ARROW2_S=31,
149
+	TCOD_CHAR_ARROW2_E=16,
150
+	TCOD_CHAR_ARROW2_W=17,
151
+	/* double arrows */
152
+	TCOD_CHAR_DARROW_H=29,
153
+	TCOD_CHAR_DARROW_V=18,
154
+	/* GUI stuff */
155
+	TCOD_CHAR_CHECKBOX_UNSET=224,
156
+	TCOD_CHAR_CHECKBOX_SET=225,
157
+	TCOD_CHAR_RADIO_UNSET=9,
158
+	TCOD_CHAR_RADIO_SET=10,
159
+	/* sub-pixel resolution kit */
160
+	TCOD_CHAR_SUBP_NW=226,
161
+	TCOD_CHAR_SUBP_NE=227,
162
+	TCOD_CHAR_SUBP_N=228,
163
+	TCOD_CHAR_SUBP_SE=229,
164
+	TCOD_CHAR_SUBP_DIAG=230,
165
+	TCOD_CHAR_SUBP_E=231,
166
+	TCOD_CHAR_SUBP_SW=232,
167
+	/* miscellaneous */
168
+	TCOD_CHAR_SMILIE = 1,
169
+	TCOD_CHAR_SMILIE_INV = 2,
170
+	TCOD_CHAR_HEART = 3,
171
+	TCOD_CHAR_DIAMOND = 4,
172
+	TCOD_CHAR_CLUB = 5,
173
+	TCOD_CHAR_SPADE = 6,
174
+	TCOD_CHAR_BULLET = 7,
175
+	TCOD_CHAR_BULLET_INV = 8,
176
+	TCOD_CHAR_MALE = 11,
177
+	TCOD_CHAR_FEMALE = 12,
178
+	TCOD_CHAR_NOTE = 13,
179
+	TCOD_CHAR_NOTE_DOUBLE = 14,
180
+	TCOD_CHAR_LIGHT = 15,
181
+	TCOD_CHAR_EXCLAM_DOUBLE = 19,
182
+	TCOD_CHAR_PILCROW = 20,
183
+	TCOD_CHAR_SECTION = 21,
184
+	TCOD_CHAR_POUND = 156,
185
+	TCOD_CHAR_MULTIPLICATION = 158,
186
+	TCOD_CHAR_FUNCTION = 159,
187
+	TCOD_CHAR_RESERVED = 169,
188
+	TCOD_CHAR_HALF = 171,
189
+	TCOD_CHAR_ONE_QUARTER = 172,
190
+	TCOD_CHAR_COPYRIGHT = 184,
191
+	TCOD_CHAR_CENT = 189,
192
+	TCOD_CHAR_YEN = 190,
193
+	TCOD_CHAR_CURRENCY = 207,
194
+	TCOD_CHAR_THREE_QUARTERS = 243,
195
+	TCOD_CHAR_DIVISION = 246,
196
+	TCOD_CHAR_GRADE = 248,
197
+	TCOD_CHAR_UMLAUT = 249,
198
+	TCOD_CHAR_POW1 = 251,
199
+	TCOD_CHAR_POW3 = 252,
200
+	TCOD_CHAR_POW2 = 253,
201
+	TCOD_CHAR_BULLET_SQUARE = 254,
202
+	/* diacritics */
203
+} TCOD_chars_t;
204
+
205
+typedef enum {
206
+	TCOD_COLCTRL_1 = 1,
207
+	TCOD_COLCTRL_2,
208
+	TCOD_COLCTRL_3,
209
+	TCOD_COLCTRL_4,
210
+	TCOD_COLCTRL_5,
211
+	TCOD_COLCTRL_NUMBER=5,
212
+	TCOD_COLCTRL_FORE_RGB,
213
+	TCOD_COLCTRL_BACK_RGB,
214
+	TCOD_COLCTRL_STOP
215
+} TCOD_colctrl_t;
216
+
217
+typedef enum {
218
+	TCOD_BKGND_NONE,
219
+	TCOD_BKGND_SET,
220
+	TCOD_BKGND_MULTIPLY,
221
+	TCOD_BKGND_LIGHTEN,
222
+	TCOD_BKGND_DARKEN,
223
+	TCOD_BKGND_SCREEN,
224
+	TCOD_BKGND_COLOR_DODGE,
225
+	TCOD_BKGND_COLOR_BURN,
226
+	TCOD_BKGND_ADD,
227
+	TCOD_BKGND_ADDA,
228
+	TCOD_BKGND_BURN,
229
+	TCOD_BKGND_OVERLAY,
230
+	TCOD_BKGND_ALPH,
231
+	TCOD_BKGND_DEFAULT
232
+} TCOD_bkgnd_flag_t;
233
+
234
+typedef enum {
235
+	TCOD_KEY_PRESSED=1,
236
+	TCOD_KEY_RELEASED=2,
237
+} TCOD_key_status_t;
238
+
239
+/* custom font flags */
240
+typedef enum {
241
+	TCOD_FONT_LAYOUT_ASCII_INCOL=1,
242
+	TCOD_FONT_LAYOUT_ASCII_INROW=2,
243
+	TCOD_FONT_TYPE_GREYSCALE=4,
244
+	TCOD_FONT_TYPE_GRAYSCALE=4,
245
+	TCOD_FONT_LAYOUT_TCOD=8,
246
+} TCOD_font_flags_t;
247
+
248
+typedef enum {
249
+	TCOD_RENDERER_GLSL,
250
+	TCOD_RENDERER_OPENGL,
251
+	TCOD_RENDERER_SDL,
252
+	TCOD_NB_RENDERERS,
253
+} TCOD_renderer_t;
254
+
255
+typedef enum {
256
+	TCOD_LEFT, 
257
+	TCOD_RIGHT, 
258
+	TCOD_CENTER 
259
+} TCOD_alignment_t;
260
+
261
+#endif /* _TCOD_CONSOLE_TYPES_H */
0 262
new file mode 100644
... ...
@@ -0,0 +1,58 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_FOV_H
29
+#define _TCOD_FOV_H
30
+
31
+typedef void *TCOD_map_t;
32
+
33
+#include "fov_types.h"
34
+
35
+/* allocate a new map */
36
+TCODLIB_API TCOD_map_t TCOD_map_new(int width, int height);
37
+/* set all cells as solid rock (cannot see through nor walk) */
38
+TCODLIB_API void TCOD_map_clear(TCOD_map_t map, bool transparent, bool walkable);
39
+/* copy a map to another, reallocating it when needed */
40
+TCODLIB_API void TCOD_map_copy(TCOD_map_t source, TCOD_map_t dest);
41
+/* change a cell properties */
42
+TCODLIB_API void TCOD_map_set_properties(TCOD_map_t map, int x, int y, bool is_transparent, bool is_walkable);
43
+/* destroy a map */
44
+TCODLIB_API void TCOD_map_delete(TCOD_map_t map);
45
+
46
+/* calculate the field of view (potentially visible cells from player_x,player_y) */
47
+TCODLIB_API void TCOD_map_compute_fov(TCOD_map_t map, int player_x, int player_y, int max_radius, bool light_walls, TCOD_fov_algorithm_t algo);
48
+/* check if a cell is in the last computed field of view */
49
+TCODLIB_API bool TCOD_map_is_in_fov(TCOD_map_t map, int x, int y);
50
+TCODLIB_API void TCOD_map_set_in_fov(TCOD_map_t map, int x, int y, bool fov);
51
+
52
+/* retrieve properties from the map */
53
+TCODLIB_API bool TCOD_map_is_transparent(TCOD_map_t map, int x, int y);
54
+TCODLIB_API bool TCOD_map_is_walkable(TCOD_map_t map, int x, int y);
55
+TCODLIB_API int TCOD_map_get_width(TCOD_map_t map);
56
+TCODLIB_API int TCOD_map_get_height(TCOD_map_t map);
57
+TCODLIB_API int TCOD_map_get_nb_cells(TCOD_map_t map);
58
+#endif
0 59
new file mode 100644
... ...
@@ -0,0 +1,257 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_FOV_HPP
29
+#define _TCOD_FOV_HPP
30
+
31
+#include "fov_types.h"
32
+
33
+class TCODPath;
34
+
35
+/**
36
+ @PageName fov
37
+ @PageCategory Roguelike toolkits
38
+ @PageTitle Field of view
39
+ @PageDesc This toolkit allows to easily calculate the potential visible set of map cells from the player position.
40
+A cell is potentially visible if the line of sight from the player to the cell in unobstructed.
41
+ */
42
+
43
+class TCODLIB_API TCODMap {
44
+	public :
45
+		/**
46
+		@PageName fov_init
47
+		@PageFather fov
48
+		@PageTitle Building the map
49
+		@FuncTitle Creating the map object
50
+		@FuncDesc First, you have to allocate a map of the same size as your dungeon.
51
+		@Cpp TCODMap::TCODMap (int width, int height)
52
+		@C TCOD_map_t TCOD_map_new (int width, int height)
53
+		@Py map_new (width, height)
54
+		@C# TCODMap::TCODMap(int width, int height)
55
+		@Param width, height	The size of the map (in map cells).
56
+		*/		
57
+		TCODMap(int width, int height);
58
+		
59
+		/**
60
+		@PageName fov_init
61
+		@PageFather fov
62
+		@FuncTitle Defining the cell properties
63
+		@FuncDesc Then, build your dungeon by defining which cells let the light pass (by default, all cells block the light) and which cells are walkable (by default, all cells are not-walkable).
64
+		@Cpp void TCODMap::setProperties (int x, int y, bool isTransparent, bool isWalkable)
65
+		@C void TCOD_map_set_properties (TCOD_map_t map, int x, int y, bool is_transparent, bool is_walkable)
66
+		@Py map_set_properties (map, x, y, is_transparent, is_walkable)
67
+		@C# void TCODMap::setProperties (int x, int y, bool isTransparent, bool isWalkable)
68
+		@Param map	In the C version, the map handler returned by the TCOD_map_new function.
69
+		@Param x, y	Coordinate of the cell that we want to update.
70
+		@Param isTransparent	If true, this cell will let the light pass else it will block the light.
71
+		@Param isWalkable	If true, creatures can walk true this cell (it is not a wall).
72
+		*/		
73
+		void setProperties(int x,int y, bool isTransparent, bool isWalkable);
74
+		
75
+		/**
76
+		@PageName fov_init
77
+		@PageFather fov
78
+		@FuncTitle Clearing the map
79
+		@FuncDesc You can clear an existing map (setting all cells to the chosen walkable/transparent values) with:
80
+		@Cpp void TCODMap::clear (bool transparent = false, bool walkable = false)
81
+		@C void TCOD_map_clear (TCOD_map_t map, bool transparent, bool walkable)
82
+		@Py map_clear (map, transparent = False, walkable = False)
83
+		@C#
84
+			void TCODMap::clear()
85
+			void TCODMap::clear(bool transparent)
86
+			void TCODMap::clear(bool transparent, bool walkable)
87
+		@Param map	In the C version, the map handler returned by the TCOD_map_new function.
88
+		@Param walkable	Whether the cells should be walkable.
89
+		@Param transparent	Whether the cells should be transparent.
90
+		*/		
91
+		void clear(bool transparent=false, bool walkable=false);
92
+		
93
+		/**
94
+		@PageName fov_init
95
+		@PageFather fov
96
+		@FuncTitle Copying a map
97
+		@FuncDesc You can copy an existing map into another. You have to allocate the destination map first.
98
+		@Cpp void TCODMap::copy (const TCODMap * source)
99
+		@C void TCOD_map_copy (TCOD_map_t source, TCOD_map_t dest)
100
+		@Py map_copy (source, dest)
101
+		@C# void TCODMap::copy (TCODMap source)
102
+		@Param source	The map containing the source data.
103
+		@Param dest	In C and python version, the map where data is copied.
104
+		@CppEx 
105
+			TCODMap * map = new TCODMap(50,50); // allocate the map
106
+			map->setProperties(10,10,true,true); // set a cell as 'empty'
107
+			TCODMap * map2 = new TCODMap(10,10); // allocate another map
108
+			map2->copy(map); // copy map data into map2, reallocating it to 50x50
109
+		@CEx 
110
+			TCOD_map_t map = TCOD_map_new(50,50);
111
+			TCOD_map_t map2 = TCOD_map_new(10,10);
112
+			TCOD_map_set_properties(map,10,10,true,true);
113
+			TCOD_map_copy(map,map2);
114
+		@PyEx 
115
+			map = libtcod.map_new(50,50)
116
+			map2 = libtcod.map_new(10,10)
117
+			libtcod.map_set_properties(map,10,10,True,True)
118
+			libtcod.map_copy(map,map2)
119
+		*/		
120
+		void copy (const TCODMap *source);
121
+
122
+		/**
123
+		@PageName fov_compute
124
+		@PageTitle Computing the field of view
125
+		@PageFather fov
126
+		@FuncDesc Once your map is allocated and empty cells have been defined, you can calculate the field of view with :
127
+			<div class="code"><pre>typedef enum { FOV_BASIC, 
128
+               FOV_DIAMOND, 
129
+               FOV_SHADOW, 
130
+               FOV_PERMISSIVE_0,FOV_PERMISSIVE_1,FOV_PERMISSIVE_2,FOV_PERMISSIVE_3,
131
+               FOV_PERMISSIVE_4,FOV_PERMISSIVE_5,FOV_PERMISSIVE_6,FOV_PERMISSIVE_7,FOV_PERMISSIVE_8, 
132
+               FOV_RESTRICTIVE,
133
+               NB_FOV_ALGORITHMS } TCOD_fov_algorithm_t;
134
+            </pre></div>
135
+			* FOV_BASIC : classic libtcod fov algorithm (ray casted from the player to all the cells on the submap perimeter)
136
+			* FOV_DIAMOND : based on <a href="http://www.geocities.com/temerra/los_rays.html">this</a> algorithm
137
+			* FOV_SHADOW : based on <a href="http://roguebasin.roguelikedevelopment.org/index.php?title=FOV_using_recursive_shadowcasting">this</a> algorithm
138
+			* FOV_PERMISSIVE_x : based on <a href="http://roguebasin.roguelikedevelopment.org/index.php?title=Precise_Permissive_Field_of_View">this</a> algorithm
139
+			Permissive has a variable permissiveness parameter. You can either use the constants FOV_PERMISSIVE_x, x between 0 (the less permissive) and 8 (the more permissive), or using the macro FOV_PERMISSIVE(x). 
140
+			* FOV_RESTRICTIVE : Mingos' Restrictive Precise Angle Shadowcasting (MRPAS). Original implementation <a href="http://umbrarumregnum.110mb.com/download/mrpas">here</a>. Comparison of the algorithms :
141
+			Check <a href="http://roguecentral.org/libtcod/fov/fov.pdf">this</a>.
142
+		@Cpp void TCODMap::computeFov(int playerX,int playerY, int maxRadius=0,bool light_walls = true, TCOD_fov_algorithm_t algo = FOV_BASIC)
143
+		@C void TCOD_map_compute_fov(TCOD_map_t map, int player_x, int player_y, int max_radius, bool light_walls, TCOD_fov_algorithm_t algo)
144
+		@Py map_compute_fov(map, player_x, player_y, max_radius=0, light_walls=True, algo=FOV_BASIC )
145
+		@C# 
146
+			void TCODMap::computeFov(int playerX, int playerY)
147
+			void TCODMap::computeFov(int playerX, int playerY, int maxRadius)
148
+			void TCODMap::computeFov(int playerX, int playerY, int maxRadius,bool light_walls)
149
+			void TCODMap::computeFov(int playerX, int playerY, int maxRadius,bool light_walls, TCODFOVTypes algo)
150
+		@Param map	In the C version, the map handler returned by the TCOD_map_new function.
151
+		@Param player_x,player_y	Position of the player in the map.
152
+			0 <= player_x < map width.
153
+			0 <= player_y < map height.
154
+		@Param maxRadius	If > 0, the fov is only computed up to maxRadius cells away from the player. Else, the range is unlimited.
155
+		@Param light_walls	Wether the wall cells near ground cells in fov must be in fov too.
156
+		@Param algo	FOV algorithm to use.
157
+		@CppEx 
158
+			TCODMap *map = new TCODMap(50,50); // allocate the map
159
+			map->setProperties(10,10,true,true); // set a cell as 'empty'
160
+			map->computeFov(10,10); // calculate fov from the cell 10x10 (basic raycasting, unlimited range, walls lighting on)
161
+		@CEx 
162
+			TCOD_map_t map = TCOD_map_new(50,50);
163
+			TCOD_map_set_properties(map,10,10,true,true);
164
+			TCOD_map_compute_fov(map,10,10,0,true,FOV_SHADOW); // using shadow casting
165
+		@PyEx 
166
+			map = libtcod.map_new(50,50)
167
+			libtcod.map_set_properties(map,10,10,True,True)
168
+			libtcod.map_compute_fov(map,10,10,0,True,libtcod.FOV_PERMISSIVE(2)) 
169
+		*/
170
+		void computeFov(int playerX,int playerY, int maxRadius = 0,bool light_walls = true, TCOD_fov_algorithm_t algo = FOV_BASIC);
171
+
172
+		/**
173
+		@PageName fov_get
174
+		@PageFather fov
175
+		@PageTitle Reading fov information
176
+		@FuncTitle Checking if a cell is in fov
177
+		@FuncDesc Once your computed the field of view, you can know if a cell is visible with :
178
+		@Cpp bool TCODMap::isInFov(int x, int y) const
179
+		@C bool TCOD_map_is_in_fov(TCOD_map_t map, int x, int y)
180
+		@Py map_is_in_fov(map, x, y)
181
+		@C# bool TCODMap::isInFov(int x, int y)
182
+		@Param map	In the C version, the map handler returned by the TCOD_map_new function.
183
+		@Param x,y	Coordinates of the cell we want to check.
184
+			0 <= x < map width.
185
+			0 <= y < map height.
186
+		@CppEx 
187
+			TCODMap *map = new TCODMap(50,50); // allocate the map
188
+			map->setProperties(10,10,true,true); // set a cell as 'empty'
189
+			map->computeFov(10,10); // calculate fov from the cell 10x10
190
+			bool visible=map->isInFov(10,10); // is the cell 10x10 visible ?      
191
+		@CEx 
192
+			TCOD_map_t map = TCOD_map_new(50,50);
193
+			TCOD_map_set_properties(map,10,10,true,true);
194
+			TCOD_map_compute_fov(map,10,10);
195
+			bool visible = TCOD_map_is_in_fov(map,10,10);
196
+		@PyEx 
197
+			map = libtcod.map_new(50,50)
198
+			libtcod.map_set_properties(map,10,10,True,True)
199
+			libtcod.map_compute_fov(map,10,10)
200
+			visible = libtcod.map_is_in_fov(map,10,10)
201
+		*/		
202
+   		bool isInFov(int x,int y) const;
203
+   		/**
204
+   		@PageName fov_get
205
+   		@FuncTitle Checking a cell transparency/walkability
206
+   		@FuncDesc You can also retrieve transparent/walkable informations with :
207
+		@Cpp 
208
+			bool TCODMap::isTransparent(int x, int y) const
209
+			bool TCODMap::isWalkable(int x, int y) const
210
+		@C 
211
+			bool TCOD_map_is_transparent(TCOD_map_t map, int x, int y)
212
+			bool TCOD_map_is_walkable(TCOD_map_t map, int x, int y)
213
+		@Py 
214
+			map_is_transparent(map, x, y)
215
+			map_is_walkable(map, x, y)
216
+		@C# 
217
+			bool TCODMap::isTransparent(int x, int y)
218
+			bool TCODMap::isWalkable(int x, int y)
219
+		@Param map	In the C version, the map handler returned by the TCOD_map_new function.
220
+		@Param x,y	Coordinates of the cell we want to check.
221
+			0 <= x < map width.
222
+			0 <= y < map height.
223
+		*/   		
224
+		bool isTransparent(int x, int y) const;
225
+		bool isWalkable(int x, int y) const;
226
+
227
+   		/**
228
+   		@PageName fov_get
229
+   		@FuncTitle Getting the map size
230
+   		@FuncDesc You can retrieve the map size with :
231
+		@Cpp 
232
+			int TCODMap::getWidth() const
233
+			int TCODMap::getHeight() const
234
+		@C 
235
+			int TCOD_map_get_width(TCOD_map_t map)
236
+			int TCOD_map_get_height(TCOD_map_t map)
237
+		@Py 
238
+			map_get_width(map)
239
+			map_get_height(map)
240
+		@C#
241
+			int TCODMap::getWidth()
242
+			int TCODMap::getHeight()
243
+		@Param map	In the C version, the map handler returned by the TCOD_map_new function.
244
+		*/   		
245
+   		int getWidth() const;
246
+		int getHeight() const;
247
+
248
+		virtual ~TCODMap();
249
+		void setInFov(int x,int y, bool fov);
250
+		int getNbCells() const;
251
+		friend class TCODLIB_API TCODPath;
252
+		friend class TCODLIB_API TCODDijkstra;
253
+//	protected :
254
+		TCOD_map_t data;
255
+};
256
+
257
+#endif
0 258
new file mode 100644
... ...
@@ -0,0 +1,54 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_FOV_TYPES_H
29
+#define _TCOD_FOV_TYPES_H
30
+
31
+/* FOV_BASIC : http://roguebasin.roguelikedevelopment.org/index.php?title=Ray_casting
32
+   FOV_DIAMOND : http://www.geocities.com/temerra/los_rays.html
33
+   FOV_SHADOW : http://roguebasin.roguelikedevelopment.org/index.php?title=FOV_using_recursive_shadowcasting
34
+   FOV_PERMISSIVE : http://roguebasin.roguelikedevelopment.org/index.php?title=Precise_Permissive_Field_of_View
35
+   FOV_RESTRICTIVE : Mingos' Restrictive Precise Angle Shadowcasting (contribution by Mingos) */
36
+
37
+typedef enum {
38
+	FOV_BASIC,
39
+	FOV_DIAMOND,
40
+	FOV_SHADOW,
41
+	FOV_PERMISSIVE_0,
42
+	FOV_PERMISSIVE_1,
43
+	FOV_PERMISSIVE_2,
44
+	FOV_PERMISSIVE_3,
45
+	FOV_PERMISSIVE_4,
46
+	FOV_PERMISSIVE_5,
47
+	FOV_PERMISSIVE_6,
48
+	FOV_PERMISSIVE_7,
49
+	FOV_PERMISSIVE_8,
50
+	FOV_RESTRICTIVE,
51
+	NB_FOV_ALGORITHMS } TCOD_fov_algorithm_t;
52
+#define FOV_PERMISSIVE(x) ((TCOD_fov_algorithm_t)(FOV_PERMISSIVE_0 + (x)))
53
+
54
+#endif /* _TCOD_FOV_TYPES_H */
0 55
new file mode 100644
... ...
@@ -0,0 +1,70 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_HEIGHTMAP_H
28
+#define _TCOD_HEIGHTMAP_H
29
+
30
+typedef struct {
31
+	int w,h;
32
+	float *values;
33
+} TCOD_heightmap_t;
34
+
35
+TCODLIB_API TCOD_heightmap_t *TCOD_heightmap_new(int w,int h);
36
+TCODLIB_API void TCOD_heightmap_delete(TCOD_heightmap_t *hm);
37
+
38
+TCODLIB_API float TCOD_heightmap_get_value(const TCOD_heightmap_t *hm, int x, int y);
39
+TCODLIB_API float TCOD_heightmap_get_interpolated_value(const TCOD_heightmap_t *hm, float x, float y);
40
+TCODLIB_API void TCOD_heightmap_set_value(TCOD_heightmap_t *hm, int x, int y, float value);
41
+TCODLIB_API float TCOD_heightmap_get_slope(const TCOD_heightmap_t *hm, int x, int y);
42
+TCODLIB_API void TCOD_heightmap_get_normal(const TCOD_heightmap_t *hm, float x, float y, float n[3], float waterLevel);
43
+TCODLIB_API int TCOD_heightmap_count_cells(const TCOD_heightmap_t *hm, float min, float max);
44
+TCODLIB_API bool TCOD_heightmap_has_land_on_border(const TCOD_heightmap_t *hm, float waterLevel);
45
+TCODLIB_API void TCOD_heightmap_get_minmax(const TCOD_heightmap_t *hm, float *min, float *max);
46
+
47
+TCODLIB_API void TCOD_heightmap_copy(const TCOD_heightmap_t *hm_source,TCOD_heightmap_t *hm_dest);
48
+TCODLIB_API void TCOD_heightmap_add(TCOD_heightmap_t *hm, float value);
49
+TCODLIB_API void TCOD_heightmap_scale(TCOD_heightmap_t *hm, float value);
50
+TCODLIB_API void TCOD_heightmap_clamp(TCOD_heightmap_t *hm, float min, float max);
51
+TCODLIB_API void TCOD_heightmap_normalize(TCOD_heightmap_t *hm, float min, float max);
52
+TCODLIB_API void TCOD_heightmap_clear(TCOD_heightmap_t *hm);
53
+TCODLIB_API void TCOD_heightmap_lerp_hm(const TCOD_heightmap_t *hm1, const TCOD_heightmap_t *hm2, TCOD_heightmap_t *hmres, float coef);
54
+TCODLIB_API void TCOD_heightmap_add_hm(const TCOD_heightmap_t *hm1, const TCOD_heightmap_t *hm2, TCOD_heightmap_t *hmres);
55
+TCODLIB_API void TCOD_heightmap_multiply_hm(const TCOD_heightmap_t *hm1, const TCOD_heightmap_t *hm2, TCOD_heightmap_t *hmres);
56
+
57
+TCODLIB_API void TCOD_heightmap_add_hill(TCOD_heightmap_t *hm, float hx, float hy, float hradius, float hheight);
58
+TCODLIB_API void TCOD_heightmap_dig_hill(TCOD_heightmap_t *hm, float hx, float hy, float hradius, float hheight);
59
+TCODLIB_API void TCOD_heightmap_dig_bezier(TCOD_heightmap_t *hm, int px[4], int py[4], float startRadius, float startDepth, float endRadius, float endDepth);
60
+TCODLIB_API void TCOD_heightmap_rain_erosion(TCOD_heightmap_t *hm, int nbDrops,float erosionCoef,float sedimentationCoef,TCOD_random_t rnd);
61
+/* TCODLIB_API void TCOD_heightmap_heat_erosion(TCOD_heightmap_t *hm, int nbPass,float minSlope,float erosionCoef,float sedimentationCoef,TCOD_random_t rnd); */
62
+TCODLIB_API void TCOD_heightmap_kernel_transform(TCOD_heightmap_t *hm, int kernelsize, const int *dx, const int *dy, const float *weight, float minLevel,float maxLevel);
63
+TCODLIB_API void TCOD_heightmap_add_voronoi(TCOD_heightmap_t *hm, int nbPoints, int nbCoef, const float *coef,TCOD_random_t rnd);
64
+TCODLIB_API void TCOD_heightmap_mid_point_displacement(TCOD_heightmap_t *hm, TCOD_random_t rnd, float roughness);
65
+TCODLIB_API void TCOD_heightmap_add_fbm(TCOD_heightmap_t *hm, TCOD_noise_t noise,float mulx, float muly, float addx, float addy, float octaves, float delta, float scale); 
66
+TCODLIB_API void TCOD_heightmap_scale_fbm(TCOD_heightmap_t *hm, TCOD_noise_t noise,float mulx, float muly, float addx, float addy, float octaves, float delta, float scale); 
67
+TCODLIB_API void TCOD_heightmap_islandify(TCOD_heightmap_t *hm, float seaLevel,TCOD_random_t rnd);
68
+
69
+#endif
70
+
0 71
new file mode 100644
... ...
@@ -0,0 +1,500 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_HEIGHTMAP_HPP
28
+#define _TCOD_HEIGHTMAP_HPP
29
+
30
+/**
31
+ @PageName heightmap
32
+ @PageCategory Roguelike toolkits
33
+ @PageTitle Heightmap toolkit
34
+ @PageDesc This toolkit allows to create a 2D grid of float values using various algorithms.
35
+
36
+The code using the heightmap toolkit can be automatically generated with the heightmap tool (hmtool) included in the libtcod package.
37
+ */
38
+class TCODLIB_API TCODHeightMap {
39
+public :
40
+	int w,h;
41
+	float *values;
42
+
43
+	/**
44
+	@PageName heightmap_init
45
+	@PageFather heightmap
46
+	@PageTitle Creating a heightmap
47
+	@FuncTitle Creating an empty map
48
+	@FuncDesc As with other modules, you have to create a heightmap object first :
49
+		Note that whereas most other modules use opaque structs, the TCOD_heightmap_t fields can be freely accessed. Thus, the TCOD_heightmap_new function returns a TCOD_heightmap_t pointer, not a TCOD_heightmap_t. The w and h fields should not be modified after the heightmap creation. The newly created heightmap is filled with 0.0 values.
50
+	@Cpp TCODHeightMap::TCODHeightMap(int w, int h)
51
+	@C
52
+		typedef struct {
53
+			int w,h;
54
+			float *values;
55
+		} TCOD_heightmap_t;
56
+		TCOD_heightmap_t *TCOD_heightmap_new(int w,int h)
57
+	@Py heightmap_new(w,h)
58
+	@C# TCODHeightMap::TCODHeightMap(int w, int h)
59
+	@Param w,h	The width and height of the heightmap.
60
+	@CppEx TCODHeightMap myMap(50,50);
61
+	@CEx TCOD_heightmap_t *my_map=TCOD_heightmap_new(50,50);
62
+	@PyEx
63
+		map=libtcod.heightmap_new(50,50)
64
+		print map.w, map.h
65
+	*/
66
+	TCODHeightMap(int w, int h);
67
+
68
+	/**
69
+	@PageName heightmap_init
70
+	@FuncTitle Destroying a heightmap
71
+	@FuncDesc To release the resources used by a heightmap, destroy it with :
72
+	@Cpp TCODHeightMap::~TCODHeightMap()
73
+	@C void TCOD_heightmap_delete(TCOD_heightmap_t *hm)
74
+	@Py heightmap_delete(hm)
75
+	@C# void TCODHeightMap::Dispose()
76
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
77
+	*/
78
+	virtual ~TCODHeightMap();
79
+
80
+	/**
81
+	@PageName heightmap_base
82
+	@PageFather heightmap
83
+	@PageTitle Basic operations
84
+	@PageDesc Those are simple operations applied either on a single map cell or on every map cell.
85
+	@FuncTitle Setting a cell value
86
+	@FuncDesc Once the heightmap has been created, you can do some basic operations on the values inside it.
87
+		You can set a single value :
88
+	@Cpp void TCODHeightMap::setValue(int x, int y, float v)
89
+	@C void TCOD_heightmap_set_value(TCOD_heightmap_t *hm, int x, int y, float value)
90
+	@Py heightmap_set_value(hm, x, y, value)
91
+	@C# void TCODHeightMap::setValue(int x, int y, float v)
92
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
93
+	@Param x,y	Coordinates of the cells to modify inside the map.
94
+		0 <= x < map width
95
+		0 <= y < map height
96
+	@Param value	The new value of the map cell.
97
+	*/
98
+	inline void setValue(int x, int y, float v) {
99
+		values[x+y*w]=v;
100
+	}
101
+
102
+	/**
103
+	@PageName heightmap_base
104
+	@FuncTitle Adding a float value to all cells
105
+	@Cpp void TCODHeightMap::add(float value)
106
+	@C void TCOD_heightmap_add(TCOD_heightmap_t *hm, float value)
107
+	@Py heightmap_add(hm, value)
108
+	@C# void TCODHeightMap::add(float value)
109
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
110
+	@Param value	Value to add to every cell.
111
+	*/
112
+	void add(float f);
113
+
114
+	/**
115
+	@PageName heightmap_base
116
+	@FuncTitle Multiplying all values by a float
117
+	@Cpp void TCODHeightMap::scale(float value)
118
+	@C void TCOD_heightmap_scale(TCOD_heightmap_t *hm, float value)
119
+	@Py heightmap_scale(hm, value)
120
+	@C# void TCODHeightMap::scale(float value)
121
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
122
+	@Param value	Every cell's value is multiplied by this value.
123
+	*/
124
+	void scale(float f);
125
+
126
+	/**
127
+	@PageName heightmap_base
128
+	@FuncTitle Resetting all values to 0.0
129
+	@Cpp void TCODHeightMap::clear()
130
+	@C void TCOD_heightmap_clear(TCOD_heightmap_t *hm)
131
+	@Py heightmap_clear(hm)
132
+	@C# void TCODHeightMap::clear()
133
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
134
+	*/
135
+	void clear(); // resets all values to 0.0
136
+
137
+	/**
138
+	@PageName heightmap_base
139
+	@FuncTitle Clamping all values
140
+	@Cpp void TCODHeightMap::clamp(float min, float max)
141
+	@C void TCOD_heightmap_clamp(TCOD_heightmap_t *hm, float min, float max)
142
+	@Py heightmap_clamp(hm, mi, ma)
143
+	@C# void TCODHeightMap::clamp(float min, float max)
144
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
145
+	@Param min,max	Every cell value is clamped between min and max.
146
+		min < max
147
+	*/
148
+	void clamp(float min, float max);
149
+
150
+	/**
151
+	@PageName heightmap_base
152
+	@FuncTitle Copying values from another heightmap
153
+	@Cpp void TCODHeightMap::copy(const TCODHeightMap *source)
154
+	@C void TCOD_heightmap_copy(const TCOD_heightmap_t *source,TCOD_heightmap_t *dest)
155
+	@Py heightmap_copy(source,dest)
156
+	@C# void TCODHeightMap::copy(TCODHeightMap source)
157
+	@Param source	Each cell value from the source heightmap is copied in the destination (this for C++) heightmap.
158
+		The source and destination heightmap must have the same width and height.
159
+	@Param dest	In the C and python versions, the address of the destination heightmap.
160
+	*/
161
+	void copy(const TCODHeightMap *source);
162
+
163
+	/**
164
+	@PageName heightmap_base
165
+	@FuncTitle Normalizing values
166
+	@Cpp void TCODHeightMap::normalize(float min=0.0f, float max=1.0f)
167
+	@C void TCOD_heightmap_normalize(TCOD_heightmap_t *hm, float min, float max)
168
+	@Py heightmap_normalize(hm, mi=0.0, ma=1.0)
169
+	@C#
170
+		void TCODHeightMap::normalize()
171
+		void TCODHeightMap::normalize(float min)
172
+		void TCODHeightMap::normalize(float min, float max)
173
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
174
+	@Param min,max	The whole heightmap is translated and scaled so that the lowest cell value becomes min and the highest cell value becomes max
175
+		min < max
176
+	*/
177
+	void normalize(float newMin=0.0f, float newMax=1.0f); // scales the values to the range [newMin;newMax]
178
+
179
+	/**
180
+	@PageName heightmap_base
181
+	@FuncTitle Doing a lerp operation between two heightmaps
182
+	@Cpp void TCODHeightMap::lerp(const TCODHeightMap *a, const TCODHeightMap *b,float coef)
183
+	@C void TCOD_heightmap_lerp_hm(const TCOD_heightmap_t *a, const TCOD_heightmap_t *b, TCOD_heightmap_t *res, float coef)
184
+	@Py heightmap_lerp_hm(a, b, res, coef)
185
+	@C# void TCODHeightMap::lerp(TCODHeightMap a, TCODHeightMap b, float coef)
186
+	@Param a	First heightmap in the lerp operation.
187
+	@Param b	Second heightmap in the lerp operation.
188
+	@Param coef	lerp coefficient.
189
+		For each cell in the destination map (this for C++), value = a.value + (b.value - a.value) * coef
190
+	@Param res	In the C and python versions, the address of the destination heightmap.
191
+	*/
192
+	void lerp(const TCODHeightMap *a, const TCODHeightMap *b,float coef);
193
+
194
+	/**
195
+	@PageName heightmap_base
196
+	@FuncTitle Adding two heightmaps
197
+	@Cpp void TCODHeightMap::add(const TCODHeightMap *a, const TCODHeightMap *b)
198
+	@C void TCOD_heightmap_add_hm(const TCOD_heightmap_t *a, const TCOD_heightmap_t *b, TCOD_heightmap_t *res)
199
+	@Py heightmap_add_hm(a, b, res)
200
+	@C# void TCODHeightMap::add(TCODHeightMap a, TCODHeightMap b)
201
+	@Param a	First heightmap.
202
+	@Param b	Second heightmap. For each cell in the destination map (this for C++), value = a.value + b.value
203
+	@Param res	In the C and python versions, the address of the destination heightmap.
204
+	*/
205
+	void add(const TCODHeightMap *a, const TCODHeightMap *b);
206
+
207
+	/**
208
+	@PageName heightmap_base
209
+	@FuncTitle Multiplying two heightmaps
210
+	@Cpp void TCODHeightMap::multiply(const TCODHeightMap *a, const TCODHeightMap *b)
211
+	@C void TCOD_heightmap_multiply_hm(const TCOD_heightmap_t *a, const TCOD_heightmap_t *b, TCOD_heightmap_t *res)
212
+	@Py heightmap_multiply_hm(a, b, res)
213
+	@C# void TCODHeightMap::multiply(TCODHeightMap a, TCODHeightMap b)
214
+	@Param a	First heightmap.
215
+	@Param b	Second heightmap. For each cell in the destination map (this for C++), value = a.value * b.value
216
+	@Param res	In the C and python versions, the address of the destination heightmap.
217
+	*/
218
+	void multiply(const TCODHeightMap *a, const TCODHeightMap *b);
219
+
220
+	/**
221
+	@PageName heightmap_modify
222
+	@PageFather heightmap
223
+	@PageTitle Modifying the heightmap
224
+	@PageDesc Those are advanced operations involving several or all map cells.
225
+	@FuncTitle Add hills
226
+	@FuncDesc This function adds a hill (a half spheroid) at given position.
227
+	@Cpp void TCODHeightMap::addHill(float x, float y, float radius, float height)
228
+	@C void TCOD_heightmap_add_hill(TCOD_heightmap_t *hm, float x, float y, float radius, float height)
229
+	@Py heightmap_add_hill(hm, x, y, radius, height)
230
+	@C# void TCODHeightMap::addHill(float x, float y, float radius, float height)
231
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
232
+	@Param x,y	Coordinates of the center of the hill.
233
+		0 <= x < map width
234
+		0 <= y < map height
235
+	@Param radius	The hill radius.
236
+	@Param height	The hill height. If height == radius or -radius, the hill is a half-sphere.
237
+	*/
238
+	void addHill(float x, float y, float radius, float height); // adds a hill (half sphere) at given position
239
+
240
+	/**
241
+	@PageName heightmap_modify
242
+	@FuncTitle Dig hills
243
+	@FuncDesc This function takes the highest value (if height > 0) or the lowest (if height < 0) between the map and the hill.
244
+		It's main goal is to carve things in maps (like rivers) by digging hills along a curve.
245
+	@Cpp void TCODHeightMap::digHill(float hx, float hy, float hradius, float height)
246
+	@C void TCOD_heightmap_dig_hill(TCOD_heightmap_t *hm, float x, float y, float radius, float height)
247
+	@Py heightmap_dig_hill(hm, x, y, radius, height)
248
+	@C# void TCODHeightMap::digHill(float hx, float hy, float hradius, float height)
249
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
250
+	@Param x,y	Coordinates of the center of the hill.
251
+		0 <= x < map width
252
+		0 <= y < map height
253
+	@Param radius	The hill radius.
254
+	@Param height	The hill height. Can be < 0 or > 0
255
+	*/
256
+	void digHill(float hx, float hy, float hradius, float height);
257
+
258
+	/**
259
+	@PageName heightmap_modify
260
+	@FuncTitle Simulate rain erosion
261
+	@FuncDesc This function simulates the effect of rain drops on the terrain, resulting in erosion patterns.
262
+	@Cpp void TCODHeightMap::rainErosion(int nbDrops,float erosionCoef,float sedimentationCoef,TCODRandom *rnd)
263
+	@C void TCOD_heightmap_rain_erosion(TCOD_heightmap_t *hm, int nbDrops,float erosionCoef,float sedimentationCoef,TCOD_random_t rnd)
264
+	@Py heightmap_rain_erosion(hm, nbDrops,erosionCoef,sedimentationCoef,rnd=0)
265
+	@C# void TCODHeightMap::rainErosion(int nbDrops, float erosionCoef, float sedimentationCoef, TCODRandom rnd)
266
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
267
+	@Param nbDrops	Number of rain drops to simulate. Should be at least width * height.
268
+	@Param erosionCoef	Amount of ground eroded on the drop's path.
269
+	@Param sedimentationCoef	Amount of ground deposited when the drops stops to flow
270
+	@Param rnd	RNG to use, NULL for default generator.
271
+	*/
272
+	void rainErosion(int nbDrops,float erosionCoef,float sedimentationCoef,TCODRandom *rnd);
273
+
274
+	/**
275
+	@PageName heightmap_modify
276
+	@FuncTitle Do a generic transformation
277
+	@FuncDesc This function allows you to apply a generic transformation on the map, so that each resulting cell value is the weighted sum of several neighbour cells. This can be used to smooth/sharpen the map. See examples below for a simple horizontal smoothing kernel : replace value(x,y) with 0.33*value(x-1,y) + 0.33*value(x,y) + 0.33*value(x+1,y).To do this, you need a kernel of size 3 (the sum involves 3 surrounding cells). The dx,dy array will contain :
278
+	dx=-1,dy = 0 for cell x-1,y
279
+	dx=1,dy=0 for cell x+1,y
280
+	dx=0,dy=0 for current cell (x,y)
281
+	The weight array will contain 0.33 for each cell.
282
+	@Cpp void TCODHeightMap::kernelTransform(int kernelSize, int *dx, int *dy, float *weight, float minLevel,float maxLevel)
283
+	@C void TCOD_heightmap_kernel_transform(TCOD_heightmap_t *hm, int kernelsize, int *dx, int *dy, float *weight, float minLevel,float maxLevel)
284
+	@Py heightmap_kernel_transform(hm, kernelsize, dx, dy, weight, minLevel,maxLevel)
285
+	@C# void TCODHeightMap::kernelTransform(int kernelSize, int[] dx, int[] dy, float[] weight, float minLevel, float maxLevel)
286
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
287
+		kernelSize	Number of neighbour cells involved.
288
+	@Param dx,dy	Array of kernelSize cells coordinates. The coordinates are relative to the current cell (0,0) is current cell, (-1,0) is west cell, (0,-1) is north cell, (1,0) is east cell, (0,1) is south cell, ...
289
+	@Param weight	Array of kernelSize cells weight. The value of each neighbour cell is scaled by its corresponding weight
290
+	@Param minLevel	The transformation is only applied to cells which value is >= minLevel.
291
+	@Param maxLevel	The transformation is only applied to cells which value is <= maxLevel.
292
+	@CEx
293
+		int dx [] = {-1,1,0};
294
+		int dy[] = {0,0,0};
295
+		float weight[] = {0.33f,0.33f,0.33f};
296
+		TCOD_heightMap_kernel_transform(heightmap,3,dx,dy,weight,0.0f,1.0f);
297
+	@CppEx
298
+		int dx [] = {-1,1,0};
299
+		int dy[] = {0,0,0};
300
+		float weight[] = {0.33f,0.33f,0.33f};
301
+		heightmap->kernelTransform(heightmap,3,dx,dy,weight,0.0f,1.0f);
302
+	*/
303
+	void kernelTransform(int kernelSize, const int *dx, const int *dy, const float *weight, float minLevel,float maxLevel);
304
+
305
+	/**
306
+	@PageName heightmap_modify
307
+	@FuncTitle Add a Voronoi diagram
308
+	@FuncDesc This function adds values from a Voronoi diagram to the map.
309
+	@Cpp void TCODHeightMap::addVoronoi(int nbPoints, int nbCoef, float *coef,TCODRandom *rnd)
310
+	@C void TCOD_heightmap_add_voronoi(TCOD_heightmap_t *hm, int nbPoints, int nbCoef, float *coef,TCOD_random_t rnd)
311
+	@Py heightmap_add_voronoi(hm, nbPoints, nbCoef, coef,rnd=0)
312
+	@C# void TCODHeightMap::addVoronoi(int nbPoints, int nbCoef, float[] coef, TCODRandom rnd)
313
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
314
+	@Param nbPoints	Number of Voronoi sites.
315
+	@Param nbCoef	The diagram value is calculated from the nbCoef closest sites.
316
+	@Param coef	The distance to each site is scaled by the corresponding coef.
317
+		Closest site : coef[0], second closest site : coef[1], ...
318
+	@Param rnd	RNG to use, NULL for default generator.
319
+	*/
320
+	void addVoronoi(int nbPoints, int nbCoef, const float *coef,TCODRandom *rnd);
321
+
322
+	/**
323
+	@PageName heightmap_modify
324
+	@FuncTitle Add a fbm
325
+		This function adds values from a simplex fbm function to the map.
326
+	@Cpp void TCODHeightMap::addFbm(TCODNoise *noise,float mulx, float muly, float addx, float addy, float octaves, float delta, float scale)
327
+	@C void TCOD_heightmap_add_fbm(TCOD_heightmap_t *hm, TCOD_noise_t noise,float mulx, float muly, float addx, float addy, float octaves, float delta, float scale)
328
+	@Py heightmap_add_fbm(hm, noise,mulx, muly, addx, addy, octaves, delta, scale)
329
+	@C# void TCODHeightMap::addFbm(TCODNoise noise, float mulx, float muly, float addx, float addy, float octaves, float delta, float scale)
330
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
331
+	@Param noise	The 2D noise to use.
332
+	@Param mulx, muly / addx, addy	The noise coordinate for map cell (x,y) are (x + addx)*mulx / width , (y + addy)*muly / height.
333
+		Those values allow you to scale and translate the noise function over the heightmap.
334
+	@Param octaves	Number of octaves in the fbm sum.
335
+	@Param delta / scale	The value added to the heightmap is delta + noise * scale.
336
+	@Param noise is between -1.0 and 1.0
337
+	*/
338
+	void addFbm(TCODNoise *noise,float mulx, float muly, float addx, float addy, float octaves, float delta, float scale);
339
+
340
+	/**
341
+	@PageName heightmap_modify
342
+	@FuncTitle Scale with a fbm
343
+	@FuncDesc This function works exactly as the previous one, but it multiplies the resulting value instead of adding it to the heightmap.
344
+	@Cpp void TCODHeightMap::scaleFbm(TCODNoise *noise,float mulx, float muly, float addx, float addy, float octaves, float delta, float scale)
345
+	@C void TCOD_heightmap_scale_fbm(TCOD_heightmap_t *hm, TCOD_noise_t noise,float mulx, float muly, float addx, float addy, float octaves, float delta, float scale)
346
+	@Py heightmap_scale_fbm(hm, noise,mulx, muly, addx, addy, octaves, delta, scale)
347
+	@C# void TCODHeightMap::scaleFbm(TCODNoise noise, float mulx, float muly, float addx, float addy, float octaves, float delta, float scale)
348
+	*/
349
+	void scaleFbm(TCODNoise *noise,float mulx, float muly, float addx, float addy, float octaves, float delta, float scale);
350
+
351
+	/**
352
+	@PageName heightmap_modify
353
+	@FuncTitle Dig along a Bezier curve
354
+	@FuncDesc This function carve a path along a cubic Bezier curve using the digHill function.
355
+		Could be used for roads/rivers/...
356
+		Both radius and depth can vary linearly along the path.
357
+	@Cpp void TCODHeightMap::digBezier(int px[4], int py[4], float startRadius, float startDepth, float endRadius, float endDepth)
358
+	@C void TCOD_heightmap_dig_bezier(TCOD_heightmap_t *hm, int px[4], int py[4], float startRadius, float startDepth, float endRadius, float endDepth)
359
+	@Py heightmap_dig_bezier(hm, px, py,  startRadius,  startDepth, endRadius, endDepth)
360
+	@C# void TCODHeightMap::digBezier(int[] px, int[] py, float startRadius, float startDepth, float endRadius, float endDepth)
361
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
362
+	@Param px,py	The coordinates of the 4 Bezier control points.
363
+	@Param startRadius	The path radius in map cells at point P0. Might be < 1.0
364
+	@Param startDepth	The path depth at point P0.
365
+	@Param endRadius	The path radius in map cells at point P3. Might be < 1.0
366
+	@Param endDepth	The path depth at point P3.
367
+	*/
368
+	void digBezier(int px[4], int py[4], float startRadius, float startDepth, float endRadius, float endDepth);
369
+
370
+	/**
371
+	@PageName heightmap_read
372
+	@PageFather heightmap
373
+	@PageTitle Reading data from the heightmap
374
+	@PageDesc Those functions return raw or computed information about the heightmap.
375
+	@FuncTitle Get the value of a cell
376
+	@FuncDesc This function returns the height value of a map cell.
377
+	@Cpp float TCODHeightMap::getValue(int x, int y) const
378
+	@C float TCOD_heightmap_get_value(const TCOD_heightmap_t *hm, int x, int y)
379
+	@Py heightmap_get_value(hm,  x, y)
380
+	@C# float TCODHeightMap::getValue(int x, int y)
381
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
382
+	@Param x,y	Coordinates of the map cell.
383
+		0 <= x < map width
384
+		0 <= y < map height
385
+	*/
386
+	inline float getValue(int x, int y) const {
387
+		return values[x+y*w];
388
+	}
389
+
390
+	/**
391
+	@PageName heightmap_read
392
+	@FuncTitle  Interpolate the height
393
+	@FuncDesc This function returns the interpolated height at non integer coordinates.
394
+	@Cpp float TCODHeightMap::getInterpolatedValue(float x, float y) const
395
+	@C float TCOD_heightmap_get_interpolated_value(const TCOD_heightmap_t *hm, float x, float y)
396
+	@Py heightmap_get_interpolated_value(hm, x, y)
397
+	@C# float TCODHeightMap::getInterpolatedValue(float x, float y)
398
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
399
+	@Param x,y	Coordinates of the map cell.
400
+		0 <= x < map width
401
+		0 <= y < map height
402
+	*/
403
+	float getInterpolatedValue(float x, float y) const;
404
+
405
+	/**
406
+	@PageName heightmap_read
407
+	@FuncTitle Get the map slope
408
+	@FuncDesc This function returns the slope between 0 and PI/2 at given coordinates.
409
+	@Cpp float TCODHeightMap::getSlope(int x, int y) const
410
+	@C float TCOD_heightmap_get_slope(const TCOD_heightmap_t *hm, int x, int y)
411
+	@Py heightmap_get_slope(hm, x, y)
412
+	@C# float TCODHeightMap::getSlope(int x, int y)
413
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
414
+	@Param x,y	Coordinates of the map cell.
415
+		0 <= x < map width
416
+		0 <= y < map height
417
+	*/
418
+	float getSlope(int x, int y) const; // returns the slope in radian between 0 and PI/2
419
+
420
+	/**
421
+	@PageName heightmap_read
422
+	@FuncTitle Get the map normal
423
+	@FuncDesc This function returns the map normal at given coordinates.
424
+	@Cpp void TCODHeightMap::getNormal(float x, float y,float n[3], float waterLevel=0.0f) const
425
+	@C void TCOD_heightmap_get_normal(const TCOD_heightmap_t *hm, float x, float y, float n[3], float waterLevel)
426
+	@Py heightmap_get_normal(hm, x, y, waterLevel) # returns nx,ny,nz
427
+	@C# void TCODHeightMap::getNormal(float x, float y, float[] n, float waterLevel)
428
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
429
+	@Param x,y	Coordinates of the map cell.
430
+		0 <= x < map width
431
+		0 <= y < map height
432
+	@Param n	The function stores the normalized normal vector in this array.
433
+	@Param waterLevel	The map height is clamped at waterLevel so that the sea is flat.
434
+	*/
435
+	void getNormal(float x, float y,float n[3], float waterLevel=0.0f) const; // returns the surface normal or (0,0,1) if beyond water level.
436
+
437
+	/**
438
+	@PageName heightmap_read
439
+	@FuncTitle Count the map cells inside a height range
440
+	@FuncDesc This function returns the number of map cells which value is between min and max.
441
+	@Cpp int TCODHeightMap::countCells(float min,float max) const
442
+	@C int TCOD_heightmap_count_cells(const TCOD_heightmap_t *hm, float min, float max)
443
+	@Py heightmap_count_cells(hm, min, max)
444
+	@C# int TCODHeightMap::countCells(float min, float max)
445
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
446
+	@Param min,max	Only cells which value is >=min and <= max are counted.
447
+	*/
448
+	int countCells(float min,float max) const;
449
+
450
+	/**
451
+	@PageName heightmap_read
452
+	@FuncTitle Check if the map is an island
453
+	@FuncDesc This function checks if the cells on the map border are below a certain height.
454
+	@Cpp bool TCODHeightMap::hasLandOnBorder(float waterLevel) const
455
+	@C bool TCOD_heightmap_has_land_on_border(const TCOD_heightmap_t *hm, float waterLevel)
456
+	@Py heightmap_has_land_on_border(hm, waterLevel)
457
+	@C# bool TCODHeightMap::hasLandOnBorder(float waterLevel)
458
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
459
+	@Param waterLevel	Return true only if no border cell is > waterLevel.
460
+	*/
461
+	bool hasLandOnBorder(float waterLevel) const;
462
+
463
+	/**
464
+	@PageName heightmap_read
465
+	@FuncTitle Get the map min and max values
466
+	@FuncDesc This function calculates the min and max of all values inside the map.
467
+	@Cpp void TCODHeightMap::getMinMax(float *min, float *max) const
468
+	@C void TCOD_heightmap_get_minmax(const TCOD_heightmap_t *hm, float *min, float *max)
469
+	@Py heightmap_get_minmax(hm) # returns min,max
470
+	@C# void TCODHeightMap::getMinMax(out float min, out float max)
471
+	@Param hm	In the C version, the address of the heightmap struct returned by the creation function.
472
+	@Param min, max	The min and max values are returned in these variables.
473
+	*/
474
+	void getMinMax(float *min, float *max) const;
475
+
476
+//	void heatErosion(int nbPass,float minSlope,float erosionCoef,float sedimentationCoef,TCODRandom *rnd);
477
+	/**
478
+	@PageName heightmap_modify
479
+	@FuncTitle Generate a map with mid-point displacement
480
+	@FuncDesc This algorithm generates a realistic fractal heightmap using the <a href="http://en.wikipedia.org/wiki/Diamond-square_algorithm">diamond-square</a> (or random midpoint displacement) algorithm.
481
+		The roughness range should be comprised between 0.4 and 0.6. The image below show the same map with roughness varying from 0.4 to 0.6.
482
+		<img src="midpoint.png" />
483
+		It's also a good habit to normalize the map after using this algorithm to avoid unexpected heights.
484
+
485
+	@Cpp void TCODHeightMap::midPointDisplacement(TCODRandom *rng=NULL,float roughness=0.45f)
486
+	@C void TCOD_heightmap_mid_point_displacement(TCOD_heightmap_t *hm, TCOD_random_t rnd, float roughness)
487
+	@Py heightmap_mid_point_displacement(hm, rng, roughness)
488
+	@Param hm	In the C and python version, the adress of the heightmap struct returned by the creation function.
489
+	@Param rng	Random number generation to use, or NULL/0 to use the default one.
490
+	@Param roughness	Map roughness.
491
+	*/
492
+	void midPointDisplacement(TCODRandom *rnd = NULL, float roughness=0.45f);
493
+	void islandify(float seaLevel,TCODRandom *rnd); // lowers the terrain near the heightmap borders
494
+	// TODO : checks island connectivity with floodfill
495
+private :
496
+//	void setMPDHeight(TCODRandom *rnd,int x,int y, float z, float offset);
497
+//	void setMDPHeightSquare(TCODRandom *rnd,int x, int y, int initsz, int sz,float offset);
498
+};
499
+
500
+#endif
0 501
new file mode 100644
... ...
@@ -0,0 +1,155 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+/* This file contains no code. It's only an input for doctcod */
29
+
30
+/**
31
+	@PageName compile_libtcod
32
+	@PageCategory Howtos
33
+	@PageTitle How to compile libtcod
34
+	@PageDesc This page contains howtos about how to get the latest libtcod source code and compile it.
35
+*/
36
+
37
+/**
38
+	@PageName compile_libtcod_mingw
39
+	@PageFather compile_libtcod
40
+	@PageTitle On Windows with Mingw
41
+	@PageDesc <h4>Mingw installation</h4>
42
+	Download the latest version of Mingw from this adress :
43
+	<a href="http://sourceforge.net/projects/mingw/files/">http://sourceforge.net/projects/mingw/files/</a>
44
+
45
+	The latest installer should be at the top of the page with a name starting with mingw-get-inst..
46
+
47
+	<img src="mingw1.png" />
48
+
49
+	Download and run the program. Follow the installation steps. Be sure to check the "Use pre-packaged repository" option :
50
+
51
+	<img src="mingw2.png" />
52
+
53
+	The latest version might be less stable and might not work with a precompiled libtcod.
54
+
55
+	When you arrive at the component selection screen, check C compiler, C++ compiler and MSys system :
56
+
57
+	<img src="mingw3.png" />
58
+
59
+	Keep on following the installation steps until the installation is finished. Now you have a "Mingw Shell" program in your start menu. This is the terminal you will use to compile and debug your game.
60
+
61
+	<h4>TortoiseHg installation</h4>
62
+	In order to get the latest version of libtcod, you need a mercurial client.
63
+	Go to the download page and grab the client corresponding to your version of Windows :
64
+	<a href="http://tortoisehg.bitbucket.org/download/index.html">http://tortoisehg.bitbucket.org/download/index.html</a>
65
+
66
+	Follow the installation wizard using the default configuration. Once the installation is finished, restart your computer.
67
+
68
+	Now you should be able to use mercurial (hg) from the Mingw Shell. To check if everything is ok, start a shell and type "which hg" :
69
+
70
+	<img src="mingw4.png" />
71
+
72
+	<h4>Getting libtcod source code</h4>
73
+	In Mingw Shell, type :
74
+	<pre name="code" class="brush: bash">hg clone https://bitbucket.org/jice/libtcod</pre>
75
+
76
+	This might take some time so grab a beer. Once it's finished, a libtcod directory has been created.
77
+	You can check the documentation (the same you're currently reading) in libtcod/doc/index2.html.
78
+	The headers are in libtcod/include.
79
+	The source code in libtcod/src.
80
+
81
+	<h4>Compiling libtcod</h4>
82
+	Go in libtcod's main directory :
83
+	<pre name="code" class="brush: bash">cd libtcod</pre>
84
+	And start the compilation :
85
+	<pre name="code" class="brush: bash">make -f makefiles/makefile-mingw</pre>
86
+	The compilation make take a few seconds depending on your CPU speed. Once it's finished, compile the samples :
87
+	<pre name="code" class="brush: bash">make -f makefiles/makefile-samples-mingw</pre>
88
+	Check that everything is ok by running the samples :
89
+	<pre name="code" class="brush: bash">./samples_cpp</pre>
90
+*/
91
+
92
+/**
93
+	@PageName compile_libtcod_linux
94
+	@PageFather compile_libtcod
95
+	@PageTitle On Linux
96
+	@PageDesc  <h4>Linux compilation</h4>
97
+	On a freshly installed Ubuntu :
98
+	Get the tools :
99
+	<pre name="code" class="brush: bash">sudo apt-get install gcc g++ make upx electric-fence libsdl1.2-dev mercurial</pre>
100
+
101
+	Get the latest sources :
102
+	<pre name="code" class="brush: bash">hg clone https://bitbucket.org/jice/libtcod</pre>
103
+
104
+	Compile the library :
105
+	<pre name="code" class="brush: bash">cd libtcod/</pre>
106
+	<pre name="code" class="brush: bash">make -f makefiles/makefile-linux clean all</pre>
107
+
108
+	Compile the samples :
109
+	<pre name="code" class="brush: bash">make -f makefiles/makefile-samples-linux</pre>
110
+
111
+	Enjoy :
112
+	<pre name="code" class="brush: bash">./samples_cpp</pre>
113
+*/
114
+
115
+/**
116
+	@PageName compile_libtcod_codelite
117
+	@PageFather compile_libtcod
118
+	@PageTitle Using CodeLite
119
+	@PageDesc TODO
120
+*/
121
+
122
+/**
123
+	@PageName compile_libtcod_haiku
124
+	@PageFather compile_libtcod
125
+	@PageTitle On Haiku
126
+	@PageDesc TODO
127
+*/
128
+
129
+/**
130
+	@PageName start_project
131
+	@PageCategory Howtos
132
+	@PageTitle How to start a project
133
+	@PageDesc This page contains howtos about how to create a project from scratch
134
+*/
135
+
136
+/**
137
+	@PageName start_mingw
138
+	@PageFather start_project
139
+	@PageTitle On Windows with Mingw
140
+	@PageDesc TODO
141
+*/
142
+
143
+/**
144
+	@PageName start_linux
145
+	@PageFather start_project
146
+	@PageTitle On Linux
147
+	@PageDesc TODO
148
+*/
149
+
150
+/**
151
+	@PageName start_codelite
152
+	@PageFather start_project
153
+	@PageTitle Using CodeLite
154
+	@PageDesc TODO
155
+*/
0 156
new file mode 100644
... ...
@@ -0,0 +1,54 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+typedef void *TCOD_image_t;
29
+
30
+TCODLIB_API TCOD_image_t TCOD_image_new(int width, int height);
31
+TCODLIB_API TCOD_image_t TCOD_image_from_console(TCOD_console_t console);
32
+TCODLIB_API void TCOD_image_refresh_console(TCOD_image_t image, TCOD_console_t console);
33
+TCODLIB_API TCOD_image_t TCOD_image_load(const char *filename);
34
+TCODLIB_API void TCOD_image_clear(TCOD_image_t image, TCOD_color_t color);
35
+TCODLIB_API void TCOD_image_invert(TCOD_image_t image);
36
+TCODLIB_API void TCOD_image_hflip(TCOD_image_t image);
37
+TCODLIB_API void TCOD_image_rotate90(TCOD_image_t image, int numRotations);
38
+TCODLIB_API void TCOD_image_vflip(TCOD_image_t image);
39
+TCODLIB_API void TCOD_image_scale(TCOD_image_t image, int neww, int newh);
40
+TCODLIB_API void TCOD_image_save(TCOD_image_t image, const char *filename);
41
+TCODLIB_API void TCOD_image_get_size(TCOD_image_t image, int *w,int *h);
42
+TCODLIB_API TCOD_color_t TCOD_image_get_pixel(TCOD_image_t image,int x, int y);
43
+TCODLIB_API int TCOD_image_get_alpha(TCOD_image_t image,int x, int y);
44
+TCODLIB_API TCOD_color_t TCOD_image_get_mipmap_pixel(TCOD_image_t image,float x0,float y0, float x1, float y1);
45
+TCODLIB_API void TCOD_image_put_pixel(TCOD_image_t image,int x, int y,TCOD_color_t col);
46
+TCODLIB_API void TCOD_image_blit(TCOD_image_t image, TCOD_console_t console, float x, float y, 
47
+	TCOD_bkgnd_flag_t bkgnd_flag, float scalex, float scaley, float angle);
48
+TCODLIB_API void TCOD_image_blit_rect(TCOD_image_t image, TCOD_console_t console, int x, int y, int w, int h, 
49
+	TCOD_bkgnd_flag_t bkgnd_flag);
50
+TCODLIB_API void TCOD_image_blit_2x(TCOD_image_t image, TCOD_console_t dest, int dx, int dy, int sx, int sy, int w, int h);
51
+TCODLIB_API void TCOD_image_delete(TCOD_image_t image);
52
+TCODLIB_API void TCOD_image_set_key_color(TCOD_image_t image, TCOD_color_t key_color);
53
+TCODLIB_API bool TCOD_image_is_pixel_transparent(TCOD_image_t image, int x, int y);
54
+
0 55
new file mode 100644
... ...
@@ -0,0 +1,440 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+class TCODLIB_API TCODImage {
29
+public :
30
+	/**
31
+	@PageName image
32
+	@PageTitle Image toolkit
33
+	@PageCategory Base toolkits
34
+	@PageDesc This toolkit contains some image manipulation utilities.	
35
+	*/	
36
+	
37
+	/**
38
+	@PageName image_create
39
+	@PageTitle Creating an image
40
+	@PageFather image
41
+	@FuncTitle Creating an empty image
42
+	@FuncDesc You can create an image of any size, filled with black with this function.
43
+	@Cpp TCODImage::TCODImage(int width, int height)
44
+	@C TCOD_image_t TCOD_image_new(int width, int height)
45
+	@Py image_new( width, height)
46
+	@C# TCODImage::TCODImage(int width, int height)
47
+	@Param width,height	Size of the image in pixels.
48
+	@CppEx TCODImage *pix = new TCODImage(80,50);
49
+	@CEx TCOD_image_t pix = TCOD_image_new(80,50);
50
+	@PyEx pix = litbcod.image_new(80,50)	
51
+	*/	
52
+	TCODImage(int width, int height);
53
+
54
+	/**
55
+	@PageName image_create
56
+	@FuncTitle Loading a .bmp or .png image
57
+	@FuncDesc You can read data from a .bmp or .png file (for example to draw an image using the background color of the console cells).
58
+		Note that only 24bits and 32bits PNG files are currently supported.
59
+	@Cpp TCODImage::TCODImage(const char *filename)
60
+	@C TCOD_image_t TCOD_image_load(const char *filename)
61
+	@Py image_load(filename)
62
+	@C# TCODImage::TCODImage(string filename)
63
+	@Param filename Name of the .bmp or .png file to load.
64
+	@CppEx TCODImage *pix = new TCODImage("mypic.bmp");
65
+	@CEx TCOD_image_t pix = TCOD_image_load("mypic.bmp");
66
+	@PyEx pix = libtcod.image_load("mypic.bmp")	
67
+	*/	
68
+	TCODImage(const char *filename);
69
+	
70
+	/**
71
+	@PageName image_create
72
+	@FuncTitle Creating an image from a console
73
+	@FuncDesc You can create an image from any console (either the root console or an offscreen console).
74
+		The image size will depend on the console size and the font characters size.
75
+		You can then save the image to a file with the save function.
76
+	@Cpp TCODImage::TCODImage(const TCODConsole *console)
77
+	@C TCOD_image_t TCOD_image_from_console(TCOD_console_t console)
78
+	@Py image_from_console(console)
79
+	@C# TCODImage::TCODImage(TCODConsole console)
80
+	@Param console The console to convert. In the C version, use NULL for the root console.
81
+	@CppEx TCODImage *pix = new TCODImage(TCODConsole::root);
82
+	@CEx TCOD_image_t pix = TCOD_image_from_console(NULL);
83
+	@PyEx pix = libtcod.image_from_console(0)
84
+	*/	
85
+	TCODImage(const TCODConsole *console);
86
+	
87
+	/**
88
+	@PageName image_create
89
+	@FuncTitle refreshing an image created from a console
90
+	@FuncDesc If you need to refresh the image with the console's new content, you don't have to delete it and create another one. Instead, use this function. Note that you must use the same console that was used in the TCOD_image_from_console call (or at least a console with the same size).
91
+	@Cpp void TCODImage::refreshConsole(const TCODConsole *console)
92
+	@C void TCOD_image_refresh_console(TCOD_image_t image, TCOD_console_t console)
93
+	@Py image_refresh_console(image, console)
94
+	@C# void TCODImage::refreshConsole(TCODConsole console)
95
+	@Param image In the C version, the image created with TCOD_image_from_console.
96
+	@Param console The console to capture. In the C version, use NULL for the root console.
97
+	@CppEx 
98
+		TCODImage *pix = new TCODImage(TCODConsole::root); // create an image from the root console
99
+		// ... modify the console
100
+		pix->refreshConsole(TCODConsole::root); // update the image with the console's new content
101
+	@CEx 
102
+		TCOD_image_t pix = TCOD_image_from_console(NULL);
103
+		// ... modify the console .. 
104
+		TCOD_image_refresh_console(pix,NULL);
105
+	@PyEx 
106
+		pix = libtcod.image_from_console(0)
107
+		# ... modify the console .. 
108
+		libtcod.image_refresh_console(pix,0)
109
+	*/
110
+	void refreshConsole(const TCODConsole *console);
111
+
112
+	/**
113
+	@PageName image_read
114
+	@PageTitle Reading data from a TCODImage
115
+	@PageFather image
116
+	@FuncTitle Getting the size of an image
117
+	@FuncDesc You can read the size of an image in pixels with this function.
118
+	@Cpp void TCODImage::getSize(int *w,int *h) const
119
+	@C void TCOD_image_get_size(TCOD_image_t image, int *w,int *h)
120
+	@Py image_get_size(image) # returns w,h
121
+	@C# void TCODImage::getSize(out int w, out int h)
122
+	@Param image In the C version, the image handler, obtained with the load function.
123
+	@Param w,h When the function returns, those variables contain the size of the image.
124
+	@CppEx 
125
+		TCODImage *pix = new TCODImage(80,50);
126
+		int w,h;
127
+		pix->getSize(&w,&h); // w = 80, h = 50
128
+	@CEx 
129
+		TCOD_image_t pix = TCOD_image_new(80,50);
130
+		int w,h;
131
+		TCOD_image_get_size(pix,&w,&h); // w = 80, h = 50
132
+	@PyEx 
133
+		pix = libtcod.image_new(80,50)
134
+		w,h=libtcod.image_get_size(pix)
135
+		# w = 80, h = 50 
136
+	*/		
137
+	void getSize(int *w,int *h) const;
138
+
139
+	/**
140
+	@PageName image_read
141
+	@FuncTitle Getting the color of a pixel
142
+	@FuncDesc You can read the colors from an image with this function.
143
+	@Cpp TCODColor TCODImage::getPixel(int x, int y) const
144
+	@C TCOD_color_t TCOD_image_get_pixel(TCOD_image_t image,int x, int y)
145
+	@Py image_get_pixel(image, x, y)
146
+	@C# TCODColor TCODImage::getPixel(int x, int y)
147
+	@Param image In the C and python version, the image handler, obtained with the load function.
148
+	@Param x,y The pixel coordinates inside the image.
149
+		0 <= x < width
150
+		0 <= y < height
151
+	@CppEx 
152
+		TCODImage *pix = new TCODImage(80,50);
153
+		TCODColor col=pix->getPixel(40,25);
154
+	@CEx 
155
+		TCOD_image_t pix = TCOD_image_new(80,50);
156
+		TCOD_color_t col=TCOD_image_get_pixel(pix,40,25);
157
+	@PyEx 
158
+		pix = litbcod.image_new(80,50)
159
+		col=litbcod.image_get_pixel(pix,40,25)
160
+	*/
161
+	TCODColor getPixel(int x, int y) const;
162
+
163
+	/**
164
+	@PageName image_read
165
+	@FuncTitle Getting the alpha value of a pixel
166
+	@FuncDesc If you have set a key color for this image with setKeyColor, or if this image was created from a 32 bits PNG file (with alpha layer), you can get the pixel transparency with this function. This function returns a value between 0 (transparent pixel) and 255 (opaque pixel).
167
+	@Cpp int TCODImage::getAlpha(int x, int y) const
168
+	@C int TCOD_image_get_alpha(TCOD_image_t image, int x, int y)
169
+	@Py image_get_alpha(image, x, y)
170
+	@C# int TCODImage::getAlpha(int x, int y)
171
+	@Param image In the C and python version, the image handler, obtained with the load function.
172
+	@Param x,y The pixel coordinates inside the image.
173
+		0 <= x < width
174
+		0 <= y < height
175
+	*/
176
+	int getAlpha(int x,int y) const;
177
+
178
+	/**
179
+	@PageName image_read
180
+	@FuncTitle Checking if a pixel is transparent
181
+	@FuncDesc You can use this simpler version (for images with alpha layer, returns true only if alpha == 0) :
182
+	@Cpp bool TCODImage::isPixelTransparent(int x,int y) const
183
+	@C bool TCOD_image_is_pixel_transparent(TCOD_image_t image,int x, int y)
184
+	@Py image_is_pixel_transparent(image, x, y)
185
+	@C# bool TCODImage::isPixelTransparent(int x,int y)
186
+	@Param image In the C and python version, the image handler, obtained with the load function.
187
+	@Param x,y The pixel coordinates inside the image.
188
+		0 <= x < width
189
+		0 <= y < height
190
+	*/
191
+   	bool isPixelTransparent(int x, int y) const;
192
+
193
+	/**
194
+	@PageName image_read
195
+	@FuncTitle Getting the average color of a part of the image
196
+	@FuncDesc This method uses mipmaps to get the average color of an arbitrary rectangular region of the image.
197
+		It can be used to draw a scaled-down version of the image. It's used by libtcod's blitting functions.
198
+	@Cpp TCODColor TCODImage::getMipmapPixel(float x0,float y0, float x1, float y1)
199
+	@C TCOD_color_t TCOD_image_get_mipmap_pixel(TCOD_image_t image,float x0,float y0, float x1, float y1)
200
+	@Py image_get_mipmap_pixel(image,x0,y0, x1, y1)
201
+	@C# TCODColor TCODImage::getMipmapPixel(float x0,float y0, float x1, float y1)
202
+	@Param image	In the C version, the image handler, obtained with the load function.
203
+	@Param x0,y0	Coordinates in pixels of the upper-left corner of the region.
204
+		0.0 <= x0 < x1
205
+		0.0 <= y0 < y1
206
+	@Param x1,y1	Coordinates in pixels of the lower-right corner of the region.
207
+		x0 < x1 < width
208
+		y0 < y1 < height
209
+	@CppEx 
210
+		// Get the average color of a 5x5 "superpixel" in the center of the image.
211
+		TCODImage *pix = new TCODImage(80,50);
212
+		TCODColor col=pix->getMipMapPixel(37.5f, 22.5f, 42.5f, 28.5f);
213
+	@CEx 
214
+		TCOD_image_t pix = TCOD_image_new(80,50);
215
+		TCOD_color_t col=TCOD_image_get_mipmap_pixel(pix,37.5f, 22.5f, 42.5f, 28.5f);
216
+	@PyEx
217
+		pix = libtcod.image_new(80,50)
218
+		col=libtcod.image_get_mipmap_pixel(pix,37.5, 22.5, 42.5, 28.5)
219
+	*/
220
+   	TCODColor getMipmapPixel(float x0,float y0, float x1, float y1);
221
+
222
+	/**
223
+	@PageName image_update
224
+	@PageTitle Updating an image
225
+	@PageFather image
226
+	@FuncTitle Filling an image with a color
227
+	@FuncDesc You can fill the whole image with a color with :
228
+	@Cpp void TCODImage::clear(const TCODColor color)
229
+	@C void TCOD_image_clear(TCOD_image_t image, TCOD_color_t color)
230
+	@Py image_clear(image,color)
231
+	@C# void TCODImage::clear(TCODColor color)
232
+	@Param image	In the C and python version, the image to fill.
233
+	@Param color	The color to use.
234
+	*/
235
+	void clear(const TCODColor col);
236
+
237
+	/**
238
+	@PageName image_update
239
+	@FuncTitle 	Changing the color of a pixel
240
+	@Cpp TCODColor TCODImage::putPixel(int x, int y, const TCODColor col)
241
+	@C void TCOD_image_put_pixel(TCOD_image_t image,int x, int y,TCOD_color_t col)
242
+	@Py image_put_pixel(image,x, y,col)
243
+	@C# TCODColor TCODImage::putPixel(int x, int y, TCODColor col)
244
+	@Param image	In the C version, the image handler, obtained with the load function.
245
+	@Param x,y	The pixel coordinates inside the image.
246
+		0 <= x < width
247
+		0 <= y < height
248
+	@Param col	The new color of the pixel.
249
+	*/
250
+	void putPixel(int x, int y, const TCODColor col);
251
+	
252
+	/**
253
+	@PageName image_update
254
+	@FuncTitle Scaling an image
255
+	@FuncDesc You can resize an image and scale its content. If neww < oldw or newh < oldh, supersampling is used to scale down the image. Else the image is scaled up using nearest neightbor.
256
+	@Cpp void TCODImage::scale(int neww, int newh)
257
+	@C void TCOD_image_scale(TCOD_image_t image,int neww, int newh)
258
+	@Py image_scale(image, neww,newh)
259
+	@C# void TCODImage::scale(int neww, int newh)
260
+	@Param image	In the C and python version, the image handler, obtained with the load function.
261
+	@Param neww,newh	The new size of the image.
262
+	*/
263
+	void scale(int neww, int newh);
264
+
265
+	/**
266
+	@PageName image_update
267
+	@FuncTitle Flipping the image horizontally
268
+	@Cpp void TCODImage::hflip()
269
+	@C void TCOD_image_hflip(TCOD_image_t image)
270
+	@Py image_hflip(image)
271
+	@C# void TCODImage::hflip()
272
+	@Param image	In the C and python version, the image handler, obtained with the load function.
273
+	*/
274
+	void hflip();
275
+
276
+    /**
277
+	@PageName image_update
278
+	@FuncTitle Flipping the image vertically
279
+	@Cpp void TCODImage::vflip()
280
+	@C void TCOD_image_vflip(TCOD_image_t image)
281
+	@Py image_vflip(image)
282
+	@C# void TCODImage::vflip()
283
+	@Param image	In the C and python version, the image handler, obtained with the load function.
284
+	*/
285
+	void vflip();
286
+
287
+    /**
288
+	@PageName image_update
289
+	@FuncTitle Rotating the image clockwise
290
+	@FuncDesc Rotate the image clockwise by increment of 90 degrees. 
291
+	@Cpp void TCODImage::rotate90(int numRotations=1)
292
+	@C void TCOD_image_rotate90(TCOD_image_t image, int numRotations)
293
+	@Py image_rotate90(image, num=1)
294
+	@C# void TCODImage::rotate90(int numRotations)
295
+	@Param image	In the C and python version, the image handler, obtained with the load function.
296
+	@Param numRotations	Number of 90 degrees rotations. Should be between 1 and 3.
297
+	*/
298
+	void rotate90(int numRotations=1);
299
+
300
+    /**
301
+	@PageName image_update
302
+	@FuncTitle Inverting the colors of the image
303
+	@Cpp void TCODImage::invert()
304
+	@C void TCOD_image_invert(TCOD_image_t image)
305
+	@Py image_invert(image)
306
+	@C# void TCODImage::invert()
307
+	@Param image	In the C and python version, the image handler, obtained with the load function.
308
+	*/
309
+	void invert();
310
+
311
+	/**
312
+	@PageName image_save
313
+	@PageFather image
314
+	@PageTitle Saving an image to a bmp or png file.
315
+	@PageDesc You can save an image to a 24 bits .bmp or .png file.
316
+	@Cpp void TCODImage::save(const char *filename)
317
+	@C void TCOD_image_save(TCOD_image_t image, const char *filename)
318
+	@Py image_save(image, filename)
319
+	@C# void TCODImage::save(string filename)
320
+	@Param image	In the C version, the image handler, obtained with any image creation function.
321
+	@Param filename	Name of the .bmp or .png file.
322
+	@CppEx 
323
+		TCODImage *pix = new TCODImage(10,10);
324
+		pix->save("mypic.bmp");
325
+	@CEx 
326
+		TCOD_image_t pix = TCOD_image_from_console(my_offscreen_console);
327
+		TCOD_image_save(pix,"mypic.bmp");
328
+	@PyEx 
329
+		pix = libtcod.image_from_console(my_offscreen_console)
330
+		libtcod.image_save(pix,"mypic.bmp")
331
+	  */	
332
+	void save(const char *filename) const;
333
+
334
+	/**
335
+	@PageName image_blit
336
+	@PageFather image
337
+	@PageTitle Blitting an image on a console
338
+	@FuncTitle Standard blitting
339
+	@FuncDesc This function blits a rectangular part of the image on a console without scaling it or rotating it. Each pixel of the image fills a console cell.
340
+	@Cpp void TCODImage::blitRect(TCODConsole *console, int x, int y, int w=-1, int h=-1, TCOD_bkgnd_flag_t bkgnd_flag = TCOD_BKGND_SET ) const
341
+	@C void TCOD_image_blit_rect(TCOD_image_t image, TCOD_console_t console, int x, int y, int w, int h, TCOD_bkgnd_flag_t bkgnd_flag)
342
+	@Py image_blit_rect(image, console, x, y, w, h, bkgnd_flag)
343
+	@C# 
344
+		void TCODImage::blitRect(TCODConsole console, int x, int y) 
345
+		void TCODImage::blitRect(TCODConsole console, int x, int y, int w)
346
+		void TCODImage::blitRect(TCODConsole console, int x, int y, int w, int h)
347
+		void TCODImage::blitRect(TCODConsole console, int x, int y, int w, int h, TCODBackgroundFlag bkgnd_flag)	
348
+	@Param image	In the C version, the image handler, obtained with the load function.
349
+	@Param console	The console on which the image will be drawn. In the C version, use NULL for the root console.
350
+	@Param x,y	Coordinates in the console of the upper-left corner of the image.
351
+	@Param w,h	Dimension of the image on the console. Use -1,-1 to use the image size.
352
+	@Param flag	This flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t.	
353
+	*/	
354
+	void blitRect(TCODConsole *console, int x, int y, int w=-1, int h=-1, TCOD_bkgnd_flag_t bkgnd_flag = TCOD_BKGND_SET ) const;
355
+	
356
+	/**
357
+	@PageName image_blit
358
+	@FuncTitle Blitting with scaling and/or rotation
359
+	@FuncDesc This function allows you to specify the floating point coordinates of the center
360
+		of the image, its scale and its rotation angle.
361
+	@Cpp void TCODImage::blit(TCODConsole *console, float x, float y, TCOD_bkgnd_flag_t bkgnd_flag = TCOD_BKGND_SET, float scalex=1.0f, float scaley=1.0f, float angle=0.0f) const
362
+	@C void TCOD_image_blit(TCOD_image_t image, TCOD_console_t console, int x, int y, TCOD_bkgnd_flag_t bkgnd_flag, float scalex, float scaley, float angle)
363
+	@Py image_blit(image, console, x, y, bkgnd_flag, scalex, scaley, angle)
364
+	@C#
365
+		void TCODImage::blit(TCODConsole console, float x, float y)
366
+		void TCODImage::blit(TCODConsole console, float x, float y, TCODBackgroundFlag bkgnd_flag)
367
+		void TCODImage::blit(TCODConsole console, float x, float y, TCODBackgroundFlag bkgnd_flag, float scalex)
368
+		void TCODImage::blit(TCODConsole console, float x, float y, TCODBackgroundFlag bkgnd_flag, float scalex, float scaley)
369
+		void TCODImage::blit(TCODConsole console, float x, float y, TCODBackgroundFlag bkgnd_flag, float scalex, float scaley, float angle)
370
+	@Param image	In the C version, the image handler, obtained with the load function.
371
+	@Param console	The console on which the image will be drawn. In the C version, use NULL for the root console.
372
+	@Param x,y	Coordinates in the console of the center of the image.
373
+	@Param flag	This flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t.
374
+	@Param scalex,scaley	Scale coefficient. Must be > 0.0.
375
+	@Param angle	Rotation angle in radians.
376
+	*/	
377
+	void blit(TCODConsole *console, float x, float y, TCOD_bkgnd_flag_t bkgnd_flag = TCOD_BKGND_SET, float scalex=1.0f, float scaley=1.0f, float angle=0.0f) const;
378
+	/**
379
+	@PageName image_blit
380
+	@FuncTitle Blitting with a mask
381
+	@FuncDesc When blitting an image, you can define a key color that will be ignored by the blitting function. This makes it possible to blit non rectangular images or images with transparent pixels.
382
+	@Cpp void TCODImage::setKeyColor(const TCODColor keyColor)
383
+	@C void TCOD_image_set_key_color(TCOD_image_t image, TCOD_color_t keyColor)
384
+	@Py image_set_key_color(image, keyColor)
385
+	@C# void TCODImage::setKeyColor(TCODColor keyColor)
386
+	@Param image	In the C and python version, the image handler, obtained with the load function.
387
+	@Param color	Pixels with this color will be skipped by blitting functions.
388
+	@CppEx 
389
+		TCODImage *pix = TCODImage("mypix.bmp");
390
+		pix->setKeyColor(TCODColor::red);
391
+		// blitting the image, omitting red pixels
392
+		pix->blitRect(TCODConsole::root,40,25);
393
+	@CEx 
394
+		TCOD_image_t pix = TCOD_image_new(10,10);
395
+		TCOD_image_set_key_color(pix,TCOD_red);
396
+		TCOD_image_blit_rect(pix,NULL,40,25,5,5,TCOD_BKGND_SET);
397
+	@PyEx 
398
+		pix = libtcod.image_new(10,10)
399
+		libtcod.image_set_key_color(pix,libtcod.red)
400
+		libtcod.image_blit_rect(pix,0,40,25,5,5,libtcod.BKGND_SET)
401
+	*/	
402
+	void setKeyColor(const TCODColor keyColor);
403
+	
404
+	/**
405
+	@PageName image_blit
406
+	@FuncTitle Blitting with subcell resolution
407
+	@FuncDesc Eventually, you can use some special characters in the libtcod fonts :
408
+		<img src="subcell.png">
409
+		to double the console resolution using this blitting function.
410
+		<table><tr><td> 
411
+		Comparison before/after subcell resolution in TCOD :<br /> 
412
+		<img src="subcell_comp.png"></td><td> 
413
+		Pyromancer ! screenshot, making full usage of subcell resolution :<br /> 
414
+		<img src="subcell_pyro.png"></td></tr></table>
415
+	@Cpp void TCODImage::blit2x(TCODConsole *dest, int dx, int dy, int sx=0, int sy=0, int w=-1, int h=-1 ) const;
416
+	@C void TCOD_image_blit_2x(TCOD_image_t image, TCOD_console_t dest, int dx, int dy, int sx, int sy, int w, int h);
417
+	@Py image_blit_2x(image, dest, dx, dy, sx=0, sy=0, w=-1, h=-1)
418
+	@C#
419
+		void TCODImage::blit2x(TCODConsole dest, int dx, int dy);
420
+		void TCODImage::blit2x(TCODConsole dest, int dx, int dy, int sx);
421
+		void TCODImage::blit2x(TCODConsole dest, int dx, int dy, int sx, int sy);
422
+		void TCODImage::blit2x(TCODConsole dest, int dx, int dy, int sx, int sy, int w);
423
+		void TCODImage::blit2x(TCODConsole dest, int dx, int dy, int sx, int sy, int w, int h);
424
+	@Param image	In the C and python version, the image handler, obtained with the load function.
425
+	@Param dest	The console of which the image will be blited. Foreground, background and character data will be overwritten.
426
+	@Param dx,dy	Coordinate of the console cell where the upper left corner of the blitted image will be.
427
+	@Param sx,sy,w,h	Part of the image to blit. Use -1 in w and h to blit the whole image.
428
+	*/	
429
+	void blit2x(TCODConsole *dest, int dx, int dy, int sx=0, int sy=0, int w=-1, int h=-1) const;
430
+
431
+	TCODImage(TCOD_image_t img) : data(img), deleteData(false) {}
432
+	virtual ~TCODImage();
433
+
434
+protected :
435
+	friend class TCODLIB_API TCODSystem;
436
+	friend class TCODLIB_API TCODZip;
437
+	void *data;
438
+	bool deleteData;
439
+};
440
+
0 441
new file mode 100644
... ...
@@ -0,0 +1,101 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_LEX_H
29
+#define _TCOD_LEX_H
30
+/*
31
+ * This is a libtcod internal module.
32
+ * Use at your own risks...
33
+ */
34
+
35
+#define TCOD_LEX_FLAG_NOCASE 1
36
+#define TCOD_LEX_FLAG_NESTING_COMMENT 2
37
+#define TCOD_LEX_FLAG_TOKENIZE_COMMENTS 4
38
+
39
+#define TCOD_LEX_ERROR -1
40
+#define TCOD_LEX_UNKNOWN 0
41
+#define TCOD_LEX_SYMBOL 1
42
+#define TCOD_LEX_KEYWORD 2
43
+#define TCOD_LEX_IDEN 3
44
+#define TCOD_LEX_STRING 4
45
+#define TCOD_LEX_INTEGER 5
46
+#define TCOD_LEX_FLOAT 6
47
+#define TCOD_LEX_CHAR 7
48
+#define TCOD_LEX_EOF 8
49
+#define TCOD_LEX_COMMENT 9
50
+
51
+#define TCOD_LEX_MAX_SYMBOLS 100
52
+#define TCOD_LEX_SYMBOL_SIZE 5
53
+#define TCOD_LEX_MAX_KEYWORDS 100
54
+#define TCOD_LEX_KEYWORD_SIZE 20
55
+
56
+typedef struct {
57
+	int file_line, token_type, token_int_val, token_idx;
58
+	float token_float_val;
59
+	char *tok;
60
+    int toklen;
61
+	char lastStringDelim;
62
+	char *pos;
63
+	char *buf;
64
+	char *filename;
65
+	char *last_javadoc_comment;
66
+	/* private stuff */
67
+	int nb_symbols, nb_keywords, flags;
68
+	char symbols[ TCOD_LEX_MAX_SYMBOLS][ TCOD_LEX_SYMBOL_SIZE ], 
69
+	keywords[ TCOD_LEX_MAX_KEYWORDS ][ TCOD_LEX_KEYWORD_SIZE ];
70
+	const char *simpleCmt;
71
+	const char *cmtStart, *cmtStop, *javadocCmtStart;
72
+	const char *stringDelim;
73
+	bool javadoc_read;
74
+	bool allocBuf;
75
+	bool savept; /* is this object a savepoint (no free in destructor) */	
76
+} TCOD_lex_t;
77
+
78
+TCODLIB_API TCOD_lex_t *TCOD_lex_new_intern();
79
+TCODLIB_API TCOD_lex_t *TCOD_lex_new(const char **symbols, const char **keywords, const char *simpleComment, 
80
+		const char *commentStart, const char *commentStop, const char *javadocCommentStart, const char *stringDelim, int flags);
81
+TCODLIB_API void TCOD_lex_delete(TCOD_lex_t *lex);
82
+
83
+TCODLIB_API void TCOD_lex_set_data_buffer(TCOD_lex_t *lex,char *dat);
84
+TCODLIB_API bool TCOD_lex_set_data_file(TCOD_lex_t *lex,const char *filename);
85
+
86
+TCODLIB_API int TCOD_lex_parse(TCOD_lex_t *lex);
87
+TCODLIB_API int TCOD_lex_parse_until_token_type(TCOD_lex_t *lex,int token_type);
88
+TCODLIB_API int TCOD_lex_parse_until_token_value(TCOD_lex_t *lex,const char *token_value);
89
+
90
+TCODLIB_API bool TCOD_lex_expect_token_type(TCOD_lex_t *lex,int token_type);
91
+TCODLIB_API bool TCOD_lex_expect_token_value(TCOD_lex_t *lex,int token_type,const char *token_value);
92
+
93
+TCODLIB_API void TCOD_lex_savepoint(TCOD_lex_t *lex,TCOD_lex_t *savept);
94
+TCODLIB_API void TCOD_lex_restore(TCOD_lex_t *lex,TCOD_lex_t *savept);
95
+TCODLIB_API char *TCOD_lex_get_last_javadoc(TCOD_lex_t *lex);
96
+TCODLIB_API const char *TCOD_lex_get_token_name(int token_type);
97
+TCODLIB_API char *TCOD_lex_get_last_error();
98
+
99
+TCODLIB_API int TCOD_lex_hextoint(char c);
100
+
101
+#endif
0 102
new file mode 100644
... ...
@@ -0,0 +1,73 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_LEX_HPP
29
+#define _TCOD_LEX_HPP
30
+/*
31
+ * This is a libtcod internal module.
32
+ * Use at your own risks...
33
+ */
34
+ 
35
+class TCODLIB_API TCODLex {
36
+public :
37
+	TCODLex();
38
+	TCODLex( const char **symbols, const char **keywords, const char *simpleComment="//", 
39
+		const char *commentStart="/*", const char *commentStop="*/", const char *javadocCommentStart="/**", 
40
+		const char *stringDelim="\"", int flags=TCOD_LEX_FLAG_NESTING_COMMENT);
41
+	~TCODLex();
42
+
43
+	void setDataBuffer(char *dat);
44
+	bool setDataFile(const char *filename);
45
+
46
+	int parse(void);
47
+	int parseUntil(int tokenType);
48
+	int parseUntil(const char *tokenValue);
49
+
50
+	bool expect(int tokenType);
51
+	bool expect(int tokenType,const char *tokenValue);
52
+
53
+	void savepoint(TCODLex *savept);
54
+	void restore(TCODLex *savept);
55
+	char *getLastJavadoc();
56
+
57
+	int getFileLine() { return ((TCOD_lex_t *)data)->file_line; }
58
+	int getTokenType() { return ((TCOD_lex_t *)data)->token_type; }
59
+	int getTokenIntVal() { return ((TCOD_lex_t *)data)->token_int_val; }
60
+	int getTokenIdx() { return ((TCOD_lex_t *)data)->token_idx; }
61
+	float getTokenFloatVal() { return ((TCOD_lex_t *)data)->token_float_val; }
62
+	char *getToken() { return ((TCOD_lex_t *)data)->tok; }
63
+	char getStringLastDelimiter() { return ((TCOD_lex_t *)data)->lastStringDelim; }
64
+	char *getPos() { return ((TCOD_lex_t *)data)->pos; }
65
+	char *getBuf() { return ((TCOD_lex_t *)data)->buf; }
66
+	char *getFilename() { return ((TCOD_lex_t *)data)->filename; }
67
+	char *getLastJavadocComment() { return ((TCOD_lex_t *)data)->last_javadoc_comment; }
68
+	static const char *getTokenName(int tokenType) { return TCOD_lex_get_token_name(tokenType); }
69
+protected :
70
+	void *data;
71
+};
72
+
73
+#endif
0 74
new file mode 100644
... ...
@@ -0,0 +1,202 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _LIBTCOD_H
29
+#define _LIBTCOD_H
30
+
31
+/* uncomment to disable unicode support */
32
+/*#define NO_UNICODE */
33
+
34
+/* uncomment to disable opengl support */
35
+/*#define NO_OPENGL */
36
+
37
+/* os identification
38
+   TCOD_WINDOWS : OS is windows
39
+   TCOD_LINUX : OS is Linux
40
+   TCOD_MACOSX : OS is Mac OS X 
41
+   TCOD_HAIKU : OS is Haiku */
42
+
43
+/* compiler identification
44
+   TCOD_VISUAL_STUDIO : compiler is Microsoft Visual Studio
45
+   TCOD_MINGW32 : compiler is Mingw32
46
+   TCOD_GCC : compiler is gcc/g++ */
47
+
48
+/* word size
49
+   TCOD_64BITS : 64 bits OS
50
+   TCOD_WIN64 : 64 bits Windows
51
+   TCOD_WIN32 : 32 bits Windows
52
+   TCOD_LINUX64 : 64 bits Linux
53
+   TCOD_LINUX32 : 32 bits Linux
54
+   TCOD_FREEBSD64 : 64 bits FreeBSD
55
+   TCOD_FREEBSD32 : 32 bits FreeBSD */
56
+
57
+#if defined( _MSC_VER )
58
+#  define TCOD_VISUAL_STUDIO
59
+#  define TCOD_WINDOWS
60
+#  ifdef _WIN64
61
+#    define TCOD_WIN64
62
+#    define TCOD_64BITS
63
+#  else
64
+#    define TCOD_WIN32
65
+#  endif
66
+#elif defined( __MINGW32__ )
67
+#  define TCOD_WINDOWS
68
+#  define TCOD_MINGW32
69
+#  define TCOD_WIN32
70
+#elif defined( __HAIKU__ )
71
+#  define TCOD_HAIKU
72
+#  define TCOD_GCC
73
+#  if __WORDSIZE == 64
74
+#    define TCOD_64BITS
75
+#  endif
76
+#elif defined( __linux )
77
+#  define TCOD_LINUX
78
+#  define TCOD_GCC
79
+#  if __WORDSIZE == 64
80
+#    define TCOD_LINUX64
81
+#    define TCOD_64BITS
82
+#  else
83
+#    define TCOD_LINUX32
84
+#  endif
85
+#elif defined( __FreeBSD__ )
86
+#  define TCOD_FREEBSD
87
+#  define TCOD_GCC
88
+#  if __WORDSIZE == 64
89
+#    define TCOD_FREEBSD64
90
+#    define TCOD_64BITS
91
+#  else
92
+#    define TCOD_FREEBSD32
93
+#  endif
94
+#elif defined (__APPLE__) && defined (__MACH__)
95
+#  define TCOD_MACOSX
96
+#  define TCOD_GCC
97
+#endif
98
+
99
+/* unicode rendering functions support */
100
+#ifndef NO_UNICODE
101
+#include <wchar.h>
102
+#endif
103
+
104
+/* This is a hack. SDL by default want you to rename your main statement, and insert it's own first
105
+   It does that to handle some init code. However, libtcod handles that for you. If we did this
106
+   wrappers like libtcod-net would be hosed, since there is no main statement there. */
107
+#ifdef TCOD_MACOSX 
108
+#define _SDL_main_h
109
+#include "SDL/SDL.h"
110
+#endif
111
+
112
+/* base types */
113
+typedef unsigned char uint8;
114
+typedef char int8;
115
+typedef unsigned short uint16;
116
+typedef short int16;
117
+typedef unsigned int uint32;
118
+typedef int int32;
119
+/* int with the same size as a pointer (32 or 64 depending on OS) */
120
+typedef long intptr;
121
+typedef unsigned long uintptr;
122
+
123
+#define TCOD_HEXVERSION 0x010600
124
+#define TCOD_STRVERSION "1.6.0"
125
+#define TCOD_TECHVERSION 0x01060000
126
+
127
+/* bool support for C */
128
+#ifndef __cplusplus
129
+#ifndef bool
130
+typedef uint8 bool;
131
+#define false ((bool)0)
132
+#define true ((bool)1)
133
+#endif
134
+#else
135
+/* in C++ all C functions prototypes should use uint8 instead of bool */
136
+#define bool uint8
137
+#endif
138
+
139
+/* DLL export */
140
+#ifdef TCOD_WINDOWS
141
+#ifdef LIBTCOD_EXPORTS
142
+#define TCODLIB_API __declspec(dllexport)
143
+#else
144
+#define TCODLIB_API __declspec(dllimport)
145
+#endif
146
+#else
147
+#define TCODLIB_API
148
+#endif
149
+
150
+#ifdef __cplusplus
151
+extern "C" {
152
+#endif
153
+
154
+/* ansi C lacks support for those functions */
155
+TCODLIB_API char *TCOD_strdup(const char *s);
156
+TCODLIB_API int TCOD_strcasecmp(const char *s1, const char *s2);
157
+TCODLIB_API int TCOD_strncasecmp(const char *s1, const char *s2, size_t n);
158
+
159
+#if defined(TCOD_WINDOWS)
160
+char *strcasestr (const char *haystack, const char *needle);
161
+#endif
162
+#if defined(TCOD_LINUX) || defined(TCOD_HAIKU) || defined(TCOD_FREEBSD) || defined(TCOD_MACOSX)
163
+#define vsnwprintf vswprintf
164
+#endif
165
+#ifdef TCOD_WINDOWS
166
+#define vsnwprintf _vsnwprintf
167
+#endif
168
+
169
+/******************************************
170
+ utility macros
171
+ ******************************************/
172
+#define MAX(a,b) ((a)<(b)?(b):(a))
173
+#define MIN(a,b) ((a)>(b)?(b):(a))
174
+#define ABS(a) ((a)<0?-(a):(a))
175
+#define CLAMP(a, b, x)		((x) < (a) ? (a) : ((x) > (b) ? (b) : (x)))
176
+#define LERP(a, b, x) ( (a) + (x) * ((b) - (a)) )
177
+
178
+#include "list.h"
179
+#include "color.h"
180
+#include "console.h"
181
+#include "image.h"
182
+#include "mouse.h"
183
+#include "sys.h"
184
+#include "mersenne.h"
185
+#include "bresenham.h"
186
+#include "noise.h"
187
+#include "fov.h"
188
+#include "path.h"
189
+#include "lex.h"
190
+#include "parser.h"
191
+#include "tree.h"
192
+#include "bsp.h"
193
+#include "heightmap.h"
194
+#include "zip.h"
195
+#include "namegen.h"
196
+#include "txtfield.h"
197
+#ifdef __cplusplus
198
+#undef bool
199
+}
200
+#endif
201
+
202
+#endif
0 203
new file mode 100644
... ...
@@ -0,0 +1,51 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _LIBTCOD_HPP
29
+#define _LIBTCOD_HPP
30
+
31
+#include "libtcod.h"
32
+#include "list.hpp"
33
+#include "color.hpp"
34
+#include "console.hpp"
35
+#include "image.hpp"
36
+#include "sys.hpp"
37
+#include "mersenne.hpp"
38
+#include "mouse.hpp"
39
+#include "bresenham.hpp"
40
+#include "noise.hpp"
41
+#include "fov.hpp"
42
+#include "path.hpp"
43
+#include "lex.hpp"
44
+#include "parser.hpp"
45
+#include "tree.hpp"
46
+#include "bsp.hpp"
47
+#include "heightmap.hpp"
48
+#include "zip.hpp"
49
+#include "namegen.hpp"
50
+#include "txtfield.hpp"
51
+#endif
0 52
new file mode 100644
... ...
@@ -0,0 +1,531 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCODLIB_INT_H
29
+#define _TCODLIB_INT_H
30
+#include <stdarg.h>
31
+#include <assert.h>
32
+#if defined (__HAIKU__) || defined(__ANDROID__)
33
+#include <SDL.h>
34
+#include <android/log.h>
35
+#elif defined (TCOD_SDL2)
36
+#include <SDL2/SDL.h>
37
+#else
38
+#include <SDL/SDL.h>
39
+#endif
40
+
41
+/* tcodlib internal stuff */
42
+#ifdef __cplusplus
43
+extern "C" {
44
+#endif
45
+
46
+/* a cell in the console */
47
+typedef struct {
48
+	int c;		/* character ascii code */
49
+	int cf;		/* character number in font */
50
+	TCOD_color_t fore;	/* foreground color */
51
+	TCOD_color_t back;	/* background color */
52
+	uint8 dirt;	/* cell modified since last flush ? */
53
+} char_t;
54
+
55
+/* TCODConsole non public data */
56
+typedef struct {
57
+	char_t *buf; /* current console */
58
+	char_t *oldbuf; /* console for last frame */
59
+	/* console width and height (in characters,not pixels) */
60
+	int w,h;
61
+	/* default background operator for print & print_rect functions */
62
+	TCOD_bkgnd_flag_t bkgnd_flag;
63
+	/* default alignment for print & print_rect functions */
64
+	TCOD_alignment_t alignment;
65
+	/* foreground (text), background and key colors */
66
+	TCOD_color_t fore,back,key;
67
+	uint8 fade;
68
+	bool haskey; /* a key color has been defined */
69
+} TCOD_console_data_t;
70
+
71
+/* fov internal stuff */
72
+typedef struct {
73
+	bool transparent:1;
74
+	bool walkable:1;
75
+	bool fov:1;
76
+} cell_t;
77
+typedef struct {
78
+	int width;
79
+	int height;
80
+	int nbcells;
81
+	cell_t *cells;
82
+} map_t;
83
+
84
+/* pseudorandom number generator toolkit */
85
+typedef struct {
86
+	/* algorithm identifier */
87
+	TCOD_random_algo_t algo;
88
+	/* distribution */
89
+	TCOD_distribution_t distribution;
90
+	/* Mersenne Twister stuff */
91
+	uint32 mt[624];
92
+	int cur_mt;
93
+	/* Complementary-Multiply-With-Carry stuff */
94
+	/* shared with Generalised Feedback Shift Register */
95
+	uint32 Q[4096], c;
96
+    int cur;
97
+} mersenne_data_t;
98
+
99
+typedef struct {
100
+	/* number of characters in the bitmap font */
101
+	int fontNbCharHoriz;
102
+	int fontNbCharVertic;
103
+	/* font type and layout */
104
+	bool font_tcod_layout;
105
+	bool font_in_row;
106
+	bool font_greyscale;
107
+	/* character size in font */
108
+	int font_width;
109
+	int font_height;
110
+	char font_file[512];
111
+	char window_title[512];
112
+	/* ascii code to tcod layout converter */
113
+	int *ascii_to_tcod;
114
+	/* whether each character in the font is a colored tile */
115
+	bool *colored;
116
+	/* the root console */
117
+	TCOD_console_data_t *root;
118
+	/* nb chars in the font */
119
+	int max_font_chars;
120
+	/* fullscreen data */
121
+	bool fullscreen;
122
+	int fullscreen_offsetx;
123
+	int fullscreen_offsety;
124
+	/* asked by the user */
125
+	int fullscreen_width;
126
+	int fullscreen_height;
127
+	/* actual resolution */
128
+	int actual_fullscreen_width;
129
+	int actual_fullscreen_height;
130
+	/* renderer to use */
131
+	TCOD_renderer_t renderer;
132
+	/* user post-processing callback */
133
+	SDL_renderer_t sdl_cbk;
134
+	/* fading data */
135
+	TCOD_color_t fading_color;
136
+	uint8 fade;
137
+	/* application window was closed */
138
+	bool is_window_closed;
139
+	/* application has mouse focus */
140
+	bool app_has_mouse_focus;
141
+	/* application is active (not iconified) */
142
+	bool app_is_active;
143
+} TCOD_internal_context_t;
144
+
145
+extern TCOD_internal_context_t TCOD_ctx;
146
+
147
+#if defined(__ANDROID__) && !defined(NDEBUG)
148
+#include <android/log.h>
149
+#ifdef printf
150
+#undef printf
151
+#endif
152
+#ifdef vprintf
153
+#undef vprintf
154
+#endif
155
+#define printf(args...) __android_log_print(ANDROID_LOG_INFO, "libtcod", ## args)
156
+#define vprintf(args...) __android_log_vprint(ANDROID_LOG_INFO, "libtcod", ## args)
157
+
158
+#ifdef assert
159
+#undef assert
160
+#endif
161
+#define assert(cond) if(!(cond)) __android_log_assert(#cond, "libtcod", "assertion failed: %s", #cond)
162
+#endif
163
+
164
+#ifdef NDEBUG
165
+#define TCOD_IF(x) if (x)
166
+#define TCOD_IFNOT(x) if (!(x))
167
+#define TCOD_ASSERT(x)
168
+#define TCOD_LOG(x)
169
+#else
170
+#define TCOD_IF(x) assert(x);
171
+#define TCOD_IFNOT(x) assert(x); if (0)
172
+#define TCOD_ASSERT(x) assert(x)
173
+#define TCOD_LOG(x) printf x
174
+#endif
175
+
176
+#ifndef NO_OPENGL
177
+/* opengl utilities */
178
+void TCOD_opengl_init_attributes();
179
+bool TCOD_opengl_init_state(int conw, int conh, void *font_tex);
180
+bool TCOD_opengl_init_shaders();
181
+bool TCOD_opengl_render(int oldFade, bool *ascii_updated, char_t *console_buffer, char_t *prev_console_buffer);
182
+void TCOD_opengl_swap();
183
+void * TCOD_opengl_get_screen();
184
+#endif
185
+
186
+/* fov internal stuff */
187
+void TCOD_map_compute_fov_circular_raycasting(TCOD_map_t map, int player_x, int player_y, int max_radius, bool light_walls);
188
+void TCOD_map_compute_fov_diamond_raycasting(TCOD_map_t map, int player_x, int player_y, int max_radius, bool light_walls);
189
+void TCOD_map_compute_fov_recursive_shadowcasting(TCOD_map_t map, int player_x, int player_y, int max_radius, bool light_walls);
190
+void TCOD_map_compute_fov_permissive2(TCOD_map_t map, int player_x, int player_y, int max_radius, bool light_walls, int fovType);
191
+void TCOD_map_compute_fov_restrictive_shadowcasting(TCOD_map_t map, int player_x, int player_y, int max_radius, bool light_walls);
192
+void TCOD_map_postproc(map_t *map,int x0,int y0, int x1, int y1, int dx, int dy);
193
+
194
+/* TCODConsole non public methods*/
195
+bool TCOD_console_init(TCOD_console_t con,const char *title, bool fullscreen);
196
+int TCOD_console_print_internal(TCOD_console_t con,int x,int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t align, char *msg, bool can_split, bool count_only);
197
+int TCOD_console_stringLength(const unsigned char *s);
198
+unsigned char * TCOD_console_forward(unsigned char *s,int l);
199
+char *TCOD_console_vsprint(const char *fmt, va_list ap);
200
+char_t *TCOD_console_get_buf(TCOD_console_t con);
201
+/* fatal errors */
202
+void TCOD_fatal(const char *fmt, ...);
203
+void TCOD_fatal_nopar(const char *msg);
204
+
205
+/* TCODSystem non public methods */
206
+TCODLIB_API void TCOD_sys_startup();
207
+bool TCOD_sys_init(int w,int h, char_t *buf, char_t *oldbuf, bool fullscreen);
208
+void TCOD_sys_set_custom_font(const char *font_name,int nb_ch, int nb_cv,int flags);
209
+void TCOD_sys_map_ascii_to_font(int asciiCode, int fontCharX, int fontCharY);
210
+void *TCOD_sys_create_bitmap_for_console(TCOD_console_t console);
211
+void TCOD_sys_save_bitmap(void *bitmap, const char *filename);
212
+void *TCOD_sys_create_bitmap(int width, int height, TCOD_color_t *buf);
213
+void TCOD_sys_delete_bitmap(void *bitmap);
214
+void TCOD_sys_console_to_bitmap(void *bitmap, int console_width, int console_height, char_t *console_buffer, char_t *prev_console_buffer);
215
+void TCOD_sys_set_keyboard_repeat(int initial_delay, int interval);
216
+TCODLIB_API void *TCOD_sys_get_surface(int width, int height, bool alpha);
217
+void TCOD_sys_save_fps();
218
+void TCOD_sys_restore_fps();
219
+
220
+/* switch fullscreen mode */
221
+void TCOD_sys_set_fullscreen(bool fullscreen);
222
+void TCOD_sys_set_clear_screen();
223
+void TCOD_sys_set_scale_factor(float value);
224
+void TCOD_sys_convert_console_to_screen_coords(int cx, int cy, int *sx, int *sy);
225
+void TCOD_sys_convert_screen_to_console_coords(int sx, int sy, int *cx, int *cy);
226
+void TCOD_sys_flush(bool render);
227
+TCOD_key_t TCOD_sys_check_for_keypress(int flags);
228
+TCOD_key_t TCOD_sys_wait_for_keypress(bool flush);
229
+bool TCOD_sys_is_key_pressed(TCOD_keycode_t key);
230
+void TCOD_sys_set_window_title(const char *title);
231
+/* close the window */
232
+void TCOD_sys_term();
233
+
234
+/* UTF-8 stuff */
235
+#ifndef NO_UNICODE
236
+wchar_t *TCOD_console_vsprint_utf(const wchar_t *fmt, va_list ap);
237
+int TCOD_console_print_internal_utf(TCOD_console_t con,int x,int y, int rw, int rh, TCOD_bkgnd_flag_t flag,
238
+	TCOD_alignment_t align, wchar_t *msg, bool can_split, bool count_only);
239
+#endif
240
+
241
+/* image manipulation */
242
+TCODLIB_API void *TCOD_sys_load_image(const char *filename);
243
+void TCOD_sys_get_image_size(const void *image, int *w,int *h);
244
+TCOD_color_t TCOD_sys_get_image_pixel(const void *image,int x, int y);
245
+int TCOD_sys_get_image_alpha(const void *image,int x, int y);
246
+bool TCOD_sys_check_magic_number(const char *filename, int size, uint8 *data);
247
+
248
+/* TCOD_list nonpublic methods */
249
+void TCOD_list_set_size(TCOD_list_t l, int size);
250
+
251
+/*
252
+	SDL12/SDL2 abstraction layer
253
+*/
254
+typedef struct {
255
+	/* get a fullscreen mode suitable for the console */
256
+	void (*get_closest_mode)(int *w, int *h);
257
+	/* render the console on a surface/texture */
258
+	void (*render)(void *vbitmap, int console_width, int console_height, char_t *console_buffer, char_t *prev_console_buffer);
259
+	/* create a new surface */
260
+	SDL_Surface *(*create_surface) (int width, int height, bool with_alpha);
261
+	/* create the game window */
262
+	void (*create_window)(int w, int h, bool fullscreen);
263
+	/* switch fullscreen on/off */
264
+	void (*set_fullscreen)(bool fullscreen);
265
+	/* change the game window title */
266
+	void (*set_window_title)(const char *title);
267
+	/* save game screenshot */
268
+	void (*save_screenshot)(const char *filename);
269
+	/* get desktop resolution */
270
+	void (*get_current_resolution)(int *w, int *h);
271
+	/* change the mouse cursor position */
272
+	void (*set_mouse_position)(int x, int y);
273
+	/* android compatible file access functions */
274
+	bool (*file_read)(const char *filename, unsigned char **buf, size_t *size);
275
+	bool (*file_exists)(const char * filename);
276
+	bool (*file_write)(const char *filename, unsigned char *buf, uint32 size);
277
+	/* clean stuff */
278
+	void (*term)();
279
+} TCOD_SDL_driver_t;
280
+
281
+/* defined in TCOD_sys_sdl12_c.c and TCOD_sys_sdl2_c.c */
282
+TCOD_SDL_driver_t *SDL_implementation_factory();
283
+void find_resolution();
284
+void TCOD_sys_init_screen_offset();
285
+extern SDL_Surface* screen;
286
+extern int oldFade;
287
+extern bool *ascii_updated;
288
+extern bool any_ascii_updated;
289
+extern SDL_Surface* charmap;
290
+typedef struct {
291
+	float force_recalc;
292
+	float last_scale_xc, last_scale_yc;
293
+	float last_scale_factor;
294
+	float last_fullscreen;
295
+
296
+	float min_scale_factor;
297
+
298
+	float src_height_width_ratio;
299
+	float dst_height_width_ratio;
300
+	int src_x0, src_y0;
301
+	int src_copy_width, src_copy_height;
302
+	int src_proportionate_width, src_proportionate_height;
303
+	int dst_display_width, dst_display_height;
304
+	int dst_offset_x, dst_offset_y;
305
+	int surface_width, surface_height;
306
+} scale_data_t;
307
+extern scale_data_t scale_data;
308
+#ifdef TCOD_SDL2
309
+extern float scale_factor;
310
+extern SDL_Window* window;
311
+extern SDL_Renderer* renderer;
312
+#endif
313
+
314
+/* color values */
315
+#define TCOD_BLACK 0,0,0
316
+#define TCOD_DARKEST_GREY 31,31,31
317
+#define TCOD_DARKER_GREY 63,63,63
318
+#define TCOD_DARK_GREY 95,95,95
319
+#define TCOD_GREY 127,127,127
320
+#define TCOD_LIGHT_GREY 159,159,159
321
+#define TCOD_LIGHTER_GREY 191,191,191
322
+#define TCOD_LIGHTEST_GREY 223,223,223
323
+#define TCOD_WHITE 255,255,255
324
+
325
+#define TCOD_DARKEST_SEPIA 31,24,15
326
+#define TCOD_DARKER_SEPIA 63,50,31
327
+#define TCOD_DARK_SEPIA 94,75,47
328
+#define TCOD_SEPIA 127,101,63
329
+#define TCOD_LIGHT_SEPIA 158,134,100
330
+#define TCOD_LIGHTER_SEPIA 191,171,143
331
+#define TCOD_LIGHTEST_SEPIA 222,211,195
332
+
333
+/* desaturated */
334
+#define TCOD_DESATURATED_RED 127,63,63
335
+#define TCOD_DESATURATED_FLAME 127,79,63
336
+#define TCOD_DESATURATED_ORANGE 127,95,63
337
+#define TCOD_DESATURATED_AMBER 127,111,63
338
+#define TCOD_DESATURATED_YELLOW 127,127,63
339
+#define TCOD_DESATURATED_LIME 111,127,63
340
+#define TCOD_DESATURATED_CHARTREUSE 95,127,63
341
+#define TCOD_DESATURATED_GREEN 63,127,63
342
+#define TCOD_DESATURATED_SEA 63,127,95
343
+#define TCOD_DESATURATED_TURQUOISE 63,127,111
344
+#define TCOD_DESATURATED_CYAN 63,127,127
345
+#define TCOD_DESATURATED_SKY 63,111,127
346
+#define TCOD_DESATURATED_AZURE 63,95,127
347
+#define TCOD_DESATURATED_BLUE 63,63,127
348
+#define TCOD_DESATURATED_HAN 79,63,127
349
+#define TCOD_DESATURATED_VIOLET 95,63,127
350
+#define TCOD_DESATURATED_PURPLE 111,63,127
351
+#define TCOD_DESATURATED_FUCHSIA 127,63,127
352
+#define TCOD_DESATURATED_MAGENTA 127,63,111
353
+#define TCOD_DESATURATED_PINK 127,63,95
354
+#define TCOD_DESATURATED_CRIMSON 127,63,79
355
+
356
+/* lightest */
357
+#define TCOD_LIGHTEST_RED 255,191,191
358
+#define TCOD_LIGHTEST_FLAME 255,207,191
359
+#define TCOD_LIGHTEST_ORANGE 255,223,191
360
+#define TCOD_LIGHTEST_AMBER 255,239,191
361
+#define TCOD_LIGHTEST_YELLOW 255,255,191
362
+#define TCOD_LIGHTEST_LIME 239,255,191
363
+#define TCOD_LIGHTEST_CHARTREUSE 223,255,191
364
+#define TCOD_LIGHTEST_GREEN 191,255,191
365
+#define TCOD_LIGHTEST_SEA 191,255,223
366
+#define TCOD_LIGHTEST_TURQUOISE 191,255,239
367
+#define TCOD_LIGHTEST_CYAN 191,255,255
368
+#define TCOD_LIGHTEST_SKY 191,239,255
369
+#define TCOD_LIGHTEST_AZURE 191,223,255
370
+#define TCOD_LIGHTEST_BLUE 191,191,255
371
+#define TCOD_LIGHTEST_HAN 207,191,255
372
+#define TCOD_LIGHTEST_VIOLET 223,191,255
373
+#define TCOD_LIGHTEST_PURPLE 239,191,255
374
+#define TCOD_LIGHTEST_FUCHSIA 255,191,255
375
+#define TCOD_LIGHTEST_MAGENTA 255,191,239
376
+#define TCOD_LIGHTEST_PINK 255,191,223
377
+#define TCOD_LIGHTEST_CRIMSON 255,191,207
378
+
379
+/* lighter */
380
+#define TCOD_LIGHTER_RED 255,127,127
381
+#define TCOD_LIGHTER_FLAME 255,159,127
382
+#define TCOD_LIGHTER_ORANGE 255,191,127
383
+#define TCOD_LIGHTER_AMBER 255,223,127
384
+#define TCOD_LIGHTER_YELLOW 255,255,127
385
+#define TCOD_LIGHTER_LIME 223,255,127
386
+#define TCOD_LIGHTER_CHARTREUSE 191,255,127
387
+#define TCOD_LIGHTER_GREEN 127,255,127
388
+#define TCOD_LIGHTER_SEA 127,255,191
389
+#define TCOD_LIGHTER_TURQUOISE 127,255,223
390
+#define TCOD_LIGHTER_CYAN 127,255,255
391
+#define TCOD_LIGHTER_SKY 127,223,255
392
+#define TCOD_LIGHTER_AZURE 127,191,255
393
+#define TCOD_LIGHTER_BLUE 127,127,255
394
+#define TCOD_LIGHTER_HAN 159,127,255
395
+#define TCOD_LIGHTER_VIOLET 191,127,255
396
+#define TCOD_LIGHTER_PURPLE 223,127,255
397
+#define TCOD_LIGHTER_FUCHSIA 255,127,255
398
+#define TCOD_LIGHTER_MAGENTA 255,127,223
399
+#define TCOD_LIGHTER_PINK 255,127,191
400
+#define TCOD_LIGHTER_CRIMSON 255,127,159
401
+
402
+/* light */
403
+#define TCOD_LIGHT_RED 255,63,63
404
+#define TCOD_LIGHT_FLAME 255,111,63
405
+#define TCOD_LIGHT_ORANGE 255,159,63
406
+#define TCOD_LIGHT_AMBER 255,207,63
407
+#define TCOD_LIGHT_YELLOW 255,255,63
408
+#define TCOD_LIGHT_LIME 207,255,63
409
+#define TCOD_LIGHT_CHARTREUSE 159,255,63
410
+#define TCOD_LIGHT_GREEN 63,255,63
411
+#define TCOD_LIGHT_SEA 63,255,159
412
+#define TCOD_LIGHT_TURQUOISE 63,255,207
413
+#define TCOD_LIGHT_CYAN 63,255,255
414
+#define TCOD_LIGHT_SKY 63,207,255
415
+#define TCOD_LIGHT_AZURE 63,159,255
416
+#define TCOD_LIGHT_BLUE 63,63,255
417
+#define TCOD_LIGHT_HAN 111,63,255
418
+#define TCOD_LIGHT_VIOLET 159,63,255
419
+#define TCOD_LIGHT_PURPLE 207,63,255
420
+#define TCOD_LIGHT_FUCHSIA 255,63,255
421
+#define TCOD_LIGHT_MAGENTA 255,63,207
422
+#define TCOD_LIGHT_PINK 255,63,159
423
+#define TCOD_LIGHT_CRIMSON 255,63,111
424
+
425
+/* normal */
426
+#define TCOD_RED 255,0,0
427
+#define TCOD_FLAME 255,63,0
428
+#define TCOD_ORANGE 255,127,0
429
+#define TCOD_AMBER 255,191,0
430
+#define TCOD_YELLOW 255,255,0
431
+#define TCOD_LIME 191,255,0
432
+#define TCOD_CHARTREUSE 127,255,0
433
+#define TCOD_GREEN 0,255,0
434
+#define TCOD_SEA 0,255,127
435
+#define TCOD_TURQUOISE 0,255,191
436
+#define TCOD_CYAN 0,255,255
437
+#define TCOD_SKY 0,191,255
438
+#define TCOD_AZURE 0,127,255
439
+#define TCOD_BLUE 0,0,255
440
+#define TCOD_HAN 63,0,255
441
+#define TCOD_VIOLET 127,0,255
442
+#define TCOD_PURPLE 191,0,255
443
+#define TCOD_FUCHSIA 255,0,255
444
+#define TCOD_MAGENTA 255,0,191
445
+#define TCOD_PINK 255,0,127
446
+#define TCOD_CRIMSON 255,0,63
447
+
448
+/* dark */
449
+#define TCOD_DARK_RED 191,0,0
450
+#define TCOD_DARK_FLAME 191,47,0
451
+#define TCOD_DARK_ORANGE 191,95,0
452
+#define TCOD_DARK_AMBER 191,143,0
453
+#define TCOD_DARK_YELLOW 191,191,0
454
+#define TCOD_DARK_LIME 143,191,0
455
+#define TCOD_DARK_CHARTREUSE 95,191,0
456
+#define TCOD_DARK_GREEN 0,191,0
457
+#define TCOD_DARK_SEA 0,191,95
458
+#define TCOD_DARK_TURQUOISE 0,191,143
459
+#define TCOD_DARK_CYAN 0,191,191
460
+#define TCOD_DARK_SKY 0,143,191
461
+#define TCOD_DARK_AZURE 0,95,191
462
+#define TCOD_DARK_BLUE 0,0,191
463
+#define TCOD_DARK_HAN 47,0,191
464
+#define TCOD_DARK_VIOLET 95,0,191
465
+#define TCOD_DARK_PURPLE 143,0,191
466
+#define TCOD_DARK_FUCHSIA 191,0,191
467
+#define TCOD_DARK_MAGENTA 191,0,143
468
+#define TCOD_DARK_PINK 191,0,95
469
+#define TCOD_DARK_CRIMSON 191,0,47
470
+
471
+/* darker */
472
+#define TCOD_DARKER_RED 127,0,0
473
+#define TCOD_DARKER_FLAME 127,31,0
474
+#define TCOD_DARKER_ORANGE 127,63,0
475
+#define TCOD_DARKER_AMBER 127,95,0
476
+#define TCOD_DARKER_YELLOW 127,127,0
477
+#define TCOD_DARKER_LIME 95,127,0
478
+#define TCOD_DARKER_CHARTREUSE 63,127,0
479
+#define TCOD_DARKER_GREEN 0,127,0
480
+#define TCOD_DARKER_SEA 0,127,63
481
+#define TCOD_DARKER_TURQUOISE 0,127,95
482
+#define TCOD_DARKER_CYAN 0,127,127
483
+#define TCOD_DARKER_SKY 0,95,127
484
+#define TCOD_DARKER_AZURE 0,63,127
485
+#define TCOD_DARKER_BLUE 0,0,127
486
+#define TCOD_DARKER_HAN 31,0,127
487
+#define TCOD_DARKER_VIOLET 63,0,127
488
+#define TCOD_DARKER_PURPLE 95,0,127
489
+#define TCOD_DARKER_FUCHSIA 127,0,127
490
+#define TCOD_DARKER_MAGENTA 127,0,95
491
+#define TCOD_DARKER_PINK 127,0,63
492
+#define TCOD_DARKER_CRIMSON 127,0,31
493
+
494
+/* darkest */
495
+#define TCOD_DARKEST_RED 63,0,0
496
+#define TCOD_DARKEST_FLAME 63,15,0
497
+#define TCOD_DARKEST_ORANGE 63,31,0
498
+#define TCOD_DARKEST_AMBER 63,47,0
499
+#define TCOD_DARKEST_YELLOW 63,63,0
500
+#define TCOD_DARKEST_LIME 47,63,0
501
+#define TCOD_DARKEST_CHARTREUSE 31,63,0
502
+#define TCOD_DARKEST_GREEN 0,63,0
503
+#define TCOD_DARKEST_SEA 0,63,31
504
+#define TCOD_DARKEST_TURQUOISE 0,63,47
505
+#define TCOD_DARKEST_CYAN 0,63,63
506
+#define TCOD_DARKEST_SKY 0,47,63
507
+#define TCOD_DARKEST_AZURE 0,31,63
508
+#define TCOD_DARKEST_BLUE 0,0,63
509
+#define TCOD_DARKEST_HAN 15,0,63
510
+#define TCOD_DARKEST_VIOLET 31,0,63
511
+#define TCOD_DARKEST_PURPLE 47,0,63
512
+#define TCOD_DARKEST_FUCHSIA 63,0,63
513
+#define TCOD_DARKEST_MAGENTA 63,0,47
514
+#define TCOD_DARKEST_PINK 63,0,31
515
+#define TCOD_DARKEST_CRIMSON 63,0,15
516
+
517
+/* metallic */
518
+#define TCOD_BRASS 191,151,96
519
+#define TCOD_COPPER 197,136,124
520
+#define TCOD_GOLD 229,191,0
521
+#define TCOD_SILVER 203,203,203
522
+
523
+/* miscellaneous */
524
+#define TCOD_CELADON 172,255,175
525
+#define TCOD_PEACH 255,159,127
526
+
527
+#ifdef __cplusplus
528
+}
529
+#endif
530
+#endif
531
+
0 532
new file mode 100644
... ...
@@ -0,0 +1,57 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_LIST_H
29
+#define _TCOD_LIST_H
30
+
31
+typedef void *TCOD_list_t;
32
+
33
+TCODLIB_API TCOD_list_t TCOD_list_new();
34
+TCODLIB_API TCOD_list_t TCOD_list_allocate(int nb_elements);
35
+TCODLIB_API TCOD_list_t TCOD_list_duplicate(TCOD_list_t l);
36
+TCODLIB_API void TCOD_list_delete(TCOD_list_t l);
37
+TCODLIB_API void TCOD_list_push(TCOD_list_t l, const void * elt);
38
+TCODLIB_API void * TCOD_list_pop(TCOD_list_t l);
39
+TCODLIB_API void * TCOD_list_peek(TCOD_list_t l);
40
+TCODLIB_API void TCOD_list_add_all(TCOD_list_t l, TCOD_list_t l2);
41
+TCODLIB_API void * TCOD_list_get(TCOD_list_t l,int idx);
42
+TCODLIB_API void TCOD_list_set(TCOD_list_t l,const void *elt, int idx);
43
+TCODLIB_API void ** TCOD_list_begin(TCOD_list_t l);
44
+TCODLIB_API void ** TCOD_list_end(TCOD_list_t l);
45
+TCODLIB_API void TCOD_list_reverse(TCOD_list_t l);
46
+TCODLIB_API void **TCOD_list_remove_iterator(TCOD_list_t l, void **elt);
47
+TCODLIB_API void TCOD_list_remove(TCOD_list_t l, const void * elt);
48
+TCODLIB_API void **TCOD_list_remove_iterator_fast(TCOD_list_t l, void **elt);
49
+TCODLIB_API void TCOD_list_remove_fast(TCOD_list_t l, const void * elt);
50
+TCODLIB_API bool TCOD_list_contains(TCOD_list_t l,const void * elt);
51
+TCODLIB_API void TCOD_list_clear(TCOD_list_t l);
52
+TCODLIB_API void TCOD_list_clear_and_delete(TCOD_list_t l);
53
+TCODLIB_API int TCOD_list_size(TCOD_list_t l);
54
+TCODLIB_API void ** TCOD_list_insert_before(TCOD_list_t l,const void *elt,int before);
55
+TCODLIB_API bool TCOD_list_is_empty(TCOD_list_t l);
56
+
57
+#endif
0 58
new file mode 100644
... ...
@@ -0,0 +1,616 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_LIST_HPP
29
+#define _TCOD_LIST_HPP
30
+
31
+#include <string.h> // memcpy
32
+#include <stdlib.h> // NULL
33
+
34
+/**
35
+ @PageName list
36
+ @PageCategory Base toolkits
37
+ @PageTitle All purposes container
38
+ @PageDesc This is a fast, lightweight and generic container, that provides array, list and stack paradigms.
39
+Note that this module has no python wrapper. Use python built-in containers instead.
40
+ */
41
+
42
+// fast & lightweight list template
43
+template <class T> class TCODList {
44
+	T *array;
45
+	int fillSize;
46
+	int allocSize;
47
+
48
+public :
49
+	/**
50
+	@PageName list_create
51
+	@PageFather list
52
+	@PageTitle Creating a list
53
+	@FuncTitle Using the default constructor
54
+	@FuncDesc You can create an empty list with the default constructor. The C version returns a handler on the list.
55
+	@Cpp template <class T> TCODList::TCODList()
56
+	@C TCOD_list_t TCOD_list_new()
57
+	@CppEx 
58
+		TCODList<int> intList;
59
+		TCODList<float> *floatList = new TCODList<float>();
60
+	@CEx 
61
+		TCOD_list_t intList = TCOD_list_new();
62
+		TCOD_list_t floatList = TCOD_list_new();
63
+	*/
64
+	TCODList() {
65
+		array=NULL;
66
+		fillSize=allocSize=0;
67
+	}
68
+
69
+	/**
70
+	@PageName list_create
71
+	@FuncTitle Duplicating an existing list
72
+	@FuncDesc You can create a list by duplicating an existing list.
73
+	@Cpp template <class T> TCODList::TCODList(const TCODList &l)
74
+	@C TCOD_list_t TCOD_list_duplicate(TCOD_list_t l)
75
+	@Param l	Existing list to duplicate.
76
+	@CppEx 
77
+		TCODList<int> intList;
78
+		intList.push(3);
79
+		intList.push(5);
80
+		TCODList<int> intList2(intList); // intList2 contains two elements : 3 and 5
81
+	@CEx 
82
+		TCOD_list_t intList = TCOD_list_new();
83
+		TCOD_list_push(intList,(const void *)3);
84
+		TCOD_list_push(intList,(const void *)5);
85
+		TCOD_list_t intList2 = TCOD_list_duplicate(intList); // intList2 contains two elements : 3 and 5
86
+	*/
87
+	TCODList(const TCOD_list_t l) {
88
+		array=NULL;
89
+		fillSize=allocSize=0;
90
+		for ( void **it=TCOD_list_begin(l); it != TCOD_list_end(l); it++ ) {
91
+			push(*((T *)(it)));
92
+		}
93
+	}
94
+	TCODList(const TCODList<T> &l2) {
95
+		array=NULL;
96
+		fillSize=allocSize=0;
97
+		*this = l2;
98
+	}
99
+
100
+	/**
101
+	@PageName list_create
102
+	@FuncTitle Preallocating memory
103
+	@FuncDesc You can also create an empty list and pre-allocate memory for elements. Use this if you know the list size and want the memory to fit it perfectly.
104
+	@Cpp template <class T> TCODList::TCODList(int nbElements)
105
+	@C TCOD_list_t TCOD_list_allocate(int nbElements)
106
+	@Param nbElements	Allocate memory for nbElements.
107
+	@CppEx TCODList<int> intList(5); // create an empty list, pre-allocate memory for 5 elements
108
+	@CEx TCOD_list_t intList = TCOD_list_allocate(5);
109
+	*/
110
+	TCODList(int nbElements) {
111
+		fillSize=0;
112
+		allocSize=nbElements;
113
+		array=new T[ nbElements ];
114
+	}
115
+
116
+	/**
117
+	@PageName list_create
118
+	@FuncTitle Deleting a list
119
+	@FuncDesc You can delete a list, freeing any allocated resources. Note that deleting the list does not delete it's elements. You have to use clearAndDelete before deleting the list if you want to destroy the elements too.
120
+	@Cpp virtual template <class T> TCODList::~TCODList()
121
+	@C void TCOD_list_delete(TCOD_list_t l)
122
+	@Param l	In the C version, the list handler, returned by a constructor.
123
+	@CppEx 
124
+		TCODList<int> *intList = new TCODList<int>(); // allocate a new empty list
125
+		intList->push(5); // the list contains 1 element at position 0, value = 5
126
+		delete intList; // destroy the list
127
+	@CEx 
128
+		TCOD_list_t intList = TCOD_list_new();
129
+		TCOD_list_push(intList,(const void *)5);
130
+		TCOD_list_delete(intList);
131
+	*/
132
+	virtual ~TCODList() {
133
+		if ( array ) delete [] array;
134
+	}
135
+
136
+	/**
137
+	@PageName list_array
138
+	@PageTitle Basic array operations
139
+	@PageFather list
140
+	@FuncTitle Setting an element
141
+	@FuncDesc You can assign a value with set. If needed, the array will allocate new elements up to idx.
142
+	@Cpp template <class T> void TCODList::set(const T elt, int idx)
143
+	@C void TCOD_list_set(TCOD_list_t l,const void *elt, int idx)
144
+	@Param elt	Element to put in the array.
145
+	@Param idx	Index of the element.
146
+		0 <= idx
147
+	@Param l	In the C version, the handler, returned by a constructor.
148
+	@CppEx 
149
+		TCODList<int> intList; // the array is empty (contains 0 elements)
150
+		intList.set(5,0); // the array contains 1 element at position 0, value = 5
151
+		intList.set(7,2); // the array contains 3 elements : 5, 0, 7
152
+	@CEx 
153
+		TCOD_list_t intList = TCOD_list_new();
154
+		TCOD_list_set(intList,(const void *)5,0);
155
+		TCOD_list_set(intList,(const void *)7,2);
156
+	*/
157
+	void set(const T elt, int idx) {
158
+		if ( idx < 0 ) return;
159
+		while ( allocSize < idx+1 ) allocate();
160
+		array[idx] = elt;
161
+		if ( idx+1 > fillSize ) fillSize = idx+1;
162
+	}
163
+
164
+	/**
165
+	@PageName list_array
166
+	@FuncTitle Getting an element value
167
+	@FuncDesc You can retrieve a value with get.
168
+	@Cpp template <class T> T TCODList::get(int idx) const
169
+	@C void * TCOD_list_get(TCOD_list_t l,int idx)
170
+	@Param idx	Index of the element.
171
+		0 <= idx < size of the array
172
+	@Param l	In the C version, the handler, returned by a constructor.
173
+	@CppEx 
174
+		TCODList<int> intList;
175
+		intList.set(5,0);
176
+		int val = intList.get(0); // val == 5
177
+	@CEx 
178
+		TCOD_list_t intList = TCOD_list_new();
179
+		TCOD_list_set(intList,(const void *)5,0);
180
+		int val = (int)TCOD_list_get(intList,0); // val == 5
181
+	*/
182
+	T get(int idx) const {
183
+		return array[idx];
184
+	}
185
+
186
+	/**
187
+	@PageName list_array
188
+	@FuncTitle Checking if a list is empty
189
+	@Cpp template <class T> bool TCODList::isEmpty() const
190
+	@C bool TCOD_list_is_empty(TCOD_list_t l)
191
+	@Param l	In the C version, the handler, returned by a constructor.
192
+	@CppEx 
193
+		TCODList<int> intList;
194
+		bool empty=intList.isEmpty(); // empty == true
195
+		intList.set(3,0);
196
+		empty=intList.isEmpty(); // empty == false
197
+	@CEx 
198
+		TCOD_list_t intList = TCOD_list_new();
199
+		bool empty=TCOD_list_is_empty(intList); // empty == true 
200
+		TCOD_list_set(intList,(const void *)5,0);
201
+		empty=TCOD_list_is_empty(intList); // empty == false 
202
+	*/
203
+	bool isEmpty() const {
204
+		return ( fillSize == 0 );
205
+	}
206
+
207
+	/**
208
+	@PageName list_array
209
+	@FuncTitle Getting the list size
210
+	@Cpp template <class T> int TCODList::size() const
211
+	@C int TCOD_list_size(TCOD_list_t l)
212
+	@Param l	In the C version, the handler, returned by a constructor.
213
+	@CppEx 
214
+		TCODList<int> intList;
215
+		int size=intList.size(); // size == 0
216
+		intList.set(3,0);
217
+		size=intList.size(); // size == 1
218
+	@CEx 
219
+		TCOD_list_t intList = TCOD_list_new();
220
+		int size=TCOD_list_size(intList); // size == 0 
221
+		TCOD_list_set(intList,(const void *)5,0);
222
+		size=TCOD_list_size(intList); // size == 1 
223
+	*/
224
+	int size() const {
225
+		return fillSize;
226
+	}
227
+
228
+	/**
229
+	@PageName list_array
230
+	@FuncTitle Checking if an element is in the list
231
+	@Cpp template <class T> bool TCODList::contains(const T elt) const
232
+	@C bool TCOD_list_contains(TCOD_list_t l,const void * elt)
233
+	@Param elt	The element.
234
+	@Param l	In the C version, the handler, returned by a constructor.
235
+	@CppEx 
236
+		TCODList<int> intList;
237
+		intList.set(3,0);
238
+		bool has3 = intList.contains(3); // has3 == true
239
+		bool has4 = intList.contains(4); // has4 == false
240
+	@CEx 
241
+		TCOD_list_t intList = TCOD_list_new();
242
+		TCOD_list_set(intList,(const void *)3,0);
243
+		bool has3 = TCOD_list_contains(intList,(const void *)3); // has3 == true 
244
+		bool has4 = TCOD_list_contains(intList,(const void *)4); // has4 == false 
245
+	*/
246
+	bool contains(const T elt) const {
247
+		for ( T* curElt = begin(); curElt != end(); curElt ++) {
248
+			if ( *curElt == elt ) return true;
249
+		}
250
+		return false;
251
+	}
252
+
253
+	/**
254
+	@PageName list_list
255
+	@PageFather list
256
+	@PageTitle Basic list operations
257
+	@FuncTitle Insert an element in the list
258
+	@Cpp template <class T> void TCODList::insertBefore(const T elt,int before)
259
+	@C void TCOD_list_insert_before(TCOD_list_t l,const void *elt,int before)
260
+	@Param elt	Element to insert in the list.
261
+	@Param idx	Index of the element after the insertion.
262
+		0 <= idx < list size
263
+	@Param l	In the C version, the list handler, returned by a constructor.
264
+	@CppEx 
265
+		TCODList<int> intList; // the list is empty (contains 0 elements)
266
+		intList.set(0,5); // the list contains 1 element at position 0, value = 5
267
+		intList.insertBefore(2,0); // the list contains 2 elements : 2,5
268
+	@CEx 
269
+		TCOD_list_t intList = TCOD_list_new();
270
+		TCOD_list_set(intList,0,(const void *)5);
271
+		TCOD_list_insert_before(intList,(const void *)2,0);
272
+	*/
273
+	T * insertBefore(const T elt,int before) {
274
+		if ( fillSize+1 >= allocSize ) allocate();
275
+		for (int idx=fillSize; idx > before; idx--) {
276
+			array[idx]=array[idx-1];
277
+		}
278
+		array[before]=elt;
279
+		fillSize++;
280
+		return &array[before];
281
+	}
282
+
283
+	/**
284
+	@PageName list_list
285
+	@FuncTitle Removing an element from the list
286
+	@FuncDesc The _fast versions replace the element to remove with the last element of the list. They're faster, but do not preserve the list order.
287
+	@Cpp 
288
+		template <class T> void TCODList::remove(const T elt)
289
+		template <class T> void TCODList::removeFast(const T elt)
290
+	@C 
291
+		void TCOD_list_remove(TCOD_list_t l, const void * elt)
292
+		void TCOD_list_remove_fast(TCOD_list_t l, const void * elt)
293
+	@Param elt	The element to remove
294
+	@Param l	In the C version, the list handler, returned by a constructor.
295
+	@CppEx 
296
+		TCODList<int> intList; // the list is empty (contains 0 elements)
297
+		intList.set(0,5); // the list contains 1 element at position 0, value = 5
298
+		intList.remove(5); // the list is empty
299
+	@CEx 
300
+		TCOD_list_t intList = TCOD_list_new();
301
+		TCOD_list_set(intList,0,(const void *)5);
302
+		TCOD_list_remove(intList,(const void *)5);
303
+	*/
304
+	void remove(const T elt) {
305
+		for ( T* curElt = begin(); curElt != end(); curElt ++) {
306
+			if ( *curElt == elt ) {
307
+				remove(curElt);
308
+				return;
309
+			}
310
+		}
311
+	}
312
+	void removeFast(const T elt) {
313
+		for ( T* curElt = begin(); curElt != end(); curElt ++) {
314
+			if ( *curElt == elt ) {
315
+				removeFast(curElt);
316
+				return;
317
+			}
318
+		}
319
+	}
320
+
321
+	/**
322
+	@PageName list_list
323
+	@FuncTitle Concatenating two lists
324
+	@FuncDesc You can concatenate two lists. Every element of l2 will be added to current list (or l in the C version) :
325
+	@Cpp template <class T> void TCODList::addAll(const TCODList &l2)
326
+	@C void TCOD_list_add_all(TCOD_list_t l, TCOD_list_t l2)
327
+	@Param l	The list inside which elements will be added.
328
+	@Param l2	the list handler containing elements to insert.
329
+	@CppEx 
330
+		TCODList<int> intList;
331
+		intList.set(1,3); // intList contains 2 elements : 0, 3
332
+		TCODList<int> intList2; // intList2 is empty
333
+		intList2.set(0,1); // intList2 contains 1 element : 1
334
+		intList2.addAll(intList); // intList2 contains 3 elements : 1, 0, 3
335
+	@CEx 
336
+		TCOD_list_t intList = TCOD_list_new();
337
+		TCOD_list_set(intList,1,(const void *)3);
338
+		TCOD_list_t intList2 = TCOD_list_new();
339
+		TCOD_list_set(intList2,0,(const void *)1);
340
+		TCOD_list_add_all(intList2,intList);
341
+	*/
342
+	void addAll(const TCODList<T> &l2) {
343
+		for (T *t=l2.begin(); t!= l2.end(); t++) {
344
+			push(*t);
345
+		}
346
+	}
347
+
348
+	/**
349
+	@PageName list_list
350
+	@FuncTitle Emptying a list
351
+	@Cpp template <class T> void TCODList::clear()
352
+	@C void TCOD_list_clear(TCOD_list_t l)
353
+	@Param l	In the C version, the list handler, returned by a constructor.
354
+	@CppEx 
355
+		TCODList<int> intList;
356
+		intList.set(0,3); // intList contains 1 element
357
+		intList.clear(); // intList is empty
358
+	@CEx 
359
+		TCOD_list_t intList = TCOD_list_new();
360
+		TCOD_list_set(intList,0,(const void *)5);
361
+		TCOD_list_clear(intList);
362
+	*/
363
+	void clear() {
364
+		fillSize=0;
365
+	}
366
+	/**
367
+	@PageName list_list
368
+	@FuncTitle Emptying a list and destroying its elements
369
+	@FuncDesc For lists containing pointers, you can clear the list and delete (or free for C) the elements :
370
+	@Cpp template <class T> void TCODList::clearAndDelete()
371
+	@C void TCOD_list_clear_and_delete(TCOD_list_t l)
372
+	@Param l	In the C version, the list handler, returned by a constructor.
373
+	@CppEx 
374
+		TCODList<MyClass *> intList;
375
+		MyClass * cl=new MyClass(); // new instance of MyClass allocated here
376
+		intList.set(0,cl); 
377
+		intList.clear(); // the list is empty. cl is always valid
378
+		intList.set(0,cl); 
379
+		intList.clearAndDelete(); // the list is empty. delete cl has been called. The address cl is no longer valid.
380
+	@C 
381
+		TCOD_list_t intList = TCOD_list_new();
382
+		void *data=calloc(10,1); // some memory allocation here 
383
+		TCOD_list_set(intList,0,(const void *)data);
384
+		TCOD_list_clear(intList); // the list is empty, but data is always valid 
385
+		TCOD_list_set(intList,0,(const void *)data);
386
+		TCOD_list_clear_and_delete(intList); // the list is empty, free(data) has been called. The address data is no longer valid 
387
+	*/
388
+	void clearAndDelete() {
389
+		for ( T* curElt = begin(); curElt != end(); curElt ++ ) {
390
+			delete (*curElt);
391
+		}
392
+		fillSize=0;
393
+	}
394
+
395
+	/**
396
+	@PageName list_list
397
+	@FuncTitle Reversing a list
398
+	@FuncDesc This function reverses the order of the elements in the list.</b>
399
+	@Cpp 
400
+		void TCODList::reverse()
401
+	@C 
402
+		void TCOD_list_reverse(TCOD_list_t l)
403
+	@Param l	In the C version, the list handler, returned by a constructor.
404
+	@CppEx 
405
+		TCODList<int> intList; // the list is empty (contains 0 elements)
406
+		intList.push(5); // the list contains 1 element at position 0, value = 5
407
+		intList.push(2); // the list contains 2 elements : 5,2
408
+		intList.reverse(); // now order is 2,5
409
+	@CEx 
410
+		TCOD_list_t intList = TCOD_list_new();
411
+		TCOD_list_push(intList,(const void *)5);
412
+		TCOD_list_push(intList,(const void *)2);
413
+		TCOD_list_reverse();
414
+	*/
415
+	void reverse() {
416
+		T* head = begin();
417
+		T* tail = end();
418
+		while ( head < tail ) {
419
+			T tmp = *head;
420
+			*head=*tail;
421
+			*tail=tmp;
422
+			head++;
423
+			tail--;
424
+		}
425
+	}
426
+
427
+	/**
428
+	@PageName list_stack
429
+	@PageTitle Basic stack operations
430
+	@PageFather list
431
+	@FuncTitle Pushing an element on the stack
432
+	@FuncDesc You can push an element on the stack (append it to the end of the list) :
433
+	@Cpp template <class T> void TCODList::push(const T elt) 
434
+	@C void TCOD_list_push(TCOD_list_t l, const void * elt)
435
+	@Param elt	Element to append to the list.
436
+	@Param l	In the C version, the list handler, returned by a constructor.
437
+	@CppEx 
438
+		TCODList<int> intList; // the list is empty (contains 0 elements)
439
+		intList.push(5); // the list contains 1 element at position 0, value = 5
440
+		intList.push(2); // the list contains 2 elements : 5,2
441
+	@CEx 
442
+		TCOD_list_t intList = TCOD_list_new();
443
+		TCOD_list_push(intList,(const void *)5);
444
+		TCOD_list_push(intList,(const void *)2);
445
+	*/
446
+	void push(const T elt) {
447
+		if ( fillSize+1 >= allocSize ) allocate();
448
+		array[fillSize++] = elt;
449
+	}
450
+
451
+	/**
452
+	@PageName list_stack
453
+	@FuncTitle Poping an element from the stack
454
+	@FuncDesc You can pop an element from the stack (remove the last element of the list).
455
+	@Cpp template <class T> T TCODList::pop()
456
+	@C void * TCOD_list_pop(TCOD_list_t l)
457
+	@Param l	In the C version, the list handler, returned by a constructor.
458
+	@CppEx 
459
+		TCODList<int> intList; // the list is empty (contains 0 elements)
460
+		intList.push(5); // the list contains 1 element at position 0, value = 5
461
+		intList.push(2); // the list contains 2 elements : 5,2
462
+		int val = intList.pop(); // val == 2, the list contains 1 element : 5
463
+		val = intList.pop(); // val == 5, the list is empty
464
+	@CEx 
465
+		TCOD_list_t intList = TCOD_list_new();
466
+		TCOD_list_push(intList,(const void *)5);
467
+		TCOD_list_push(intList,(const void *)2);
468
+		int val = (int)TCOD_list_pop(intList);
469
+		val = (int)TCOD_list_pop(intList);
470
+	*/
471
+	T pop() {
472
+		if ( fillSize == 0 ) return (T)0;
473
+		return array[--fillSize];
474
+	}
475
+
476
+	/**
477
+	@PageName list_stack
478
+	@FuncTitle Peeking the last element of the stack
479
+	@FuncDesc You can read the last element of the stack without removing it :
480
+	@Cpp template <class T> T TCODList::peek() const
481
+	@C void * TCOD_list_peek(TCOD_list_t l)
482
+	@Param l	In the C version, the list handler, returned by a constructor.
483
+	@CppEx 
484
+		TCODList<int> intList;
485
+		intList.push(3); // intList contains 1 elements : 3
486
+		int val = intList.peek(); // val == 3, inList contains 1 elements : 3
487
+		intList.push(2); // intList contains 2 elements : 3, 2
488
+		val = intList.peek(); // val == 2, inList contains 2 elements : 3, 2
489
+	@CEx 
490
+		TCOD_list_t intList = TCOD_list_new();
491
+		TCOD_list_push(intList,(const void *)3);
492
+		int val = (int)TCOD_list_peek(intList);
493
+		TCOD_list_push(intList,(const void *)2);
494
+		val = (int)TCOD_list_peek(intList);
495
+	*/
496
+	T peek() const {
497
+		if ( fillSize == 0 ) return (T)0;
498
+		return array[fillSize-1];
499
+	}
500
+
501
+	/**
502
+	@PageName list_iterator
503
+	@PageFather list
504
+	@PageTitle Iterators
505
+	@FuncDesc You can iterate through the elements of the list using an iterator. begin() returns the address of the first element of the list. You go to the next element using the increment operator ++. When the iterator's value is equal to end(), you've gone through all the elements. <b>Warning ! You cannot insert elements in the list while iterating through it. Inserting elements can result in reallocation of the list and your iterator will not longer be valid.</b>
506
+	@Cpp 
507
+		template <class T> T * TCODList::begin() const
508
+		template <class T> T * TCODList::end() const
509
+	@C 
510
+		void ** TCOD_list_begin(TCOD_list_t l)
511
+		void ** TCOD_list_end(TCOD_list_t l)
512
+	@Param l	In the C version, the list handler, returned by a constructor.
513
+	@CppEx 
514
+		TCODList<int> intList; // the list is empty (contains 0 elements)
515
+		intList.push(5); // the list contains 1 element at position 0, value = 5
516
+		intList.push(2); // the list contains 2 elements : 5,2
517
+		for ( int * iterator = intList.begin(); iterator != intList.end(); iterator ++ ) {
518
+			int currentValue=*iterator;
519
+			printf("value : %d\n", currentValue );
520
+		}
521
+	@CEx 
522
+		TCOD_list_t intList = TCOD_list_new();
523
+		TCOD_list_push(intList,(const void *)5);
524
+		TCOD_list_push(intList,(const void *)2);
525
+		for ( int * iterator = (int *)TCOD_list_begin(intList); iterator != (int *)TCOD_list_end(intList); iterator ++ ) {
526
+			int currentValue=*iterator;
527
+			printf("value : %d\n", currentValue );
528
+		}
529
+	*/
530
+	T * begin() const {
531
+		if ( fillSize == 0 ) return (T *)NULL;
532
+		return &array[0];
533
+	}
534
+	T * end() const {
535
+		if ( fillSize == 0 ) return (T *)NULL;
536
+		return &array[fillSize];
537
+	}
538
+
539
+	/**
540
+	@PageName list_iterator
541
+	@FuncDesc You can remove an element from the list while iterating. The element at the iterator position will be removed. The function returns the new iterator. The _fast versions replace the element to remove with the last element of the list. They're faster, but do not preserve the list order.
542
+	@Cpp 
543
+		template <class T> T *TCODList::remove(T *iterator)
544
+		template <class T> T *TCODList::removeFast(T *iterator)
545
+	@C 
546
+		void **TCOD_list_remove_iterator(TCOD_list_t l, void **iterator)
547
+		void **TCOD_list_remove_iterator_fast(TCOD_list_t l, void **iterator)
548
+	@Param iterator	The list iterator.
549
+	@Param l	In the C version, the list handler, returned by a constructor.
550
+	@CppEx 
551
+		TCODList<int> intList; // the list is empty (contains 0 elements)
552
+		intList.push(5); // the list contains 1 element at position 0, value = 5
553
+		intList.push(2); // the list contains 2 elements : 5,2
554
+		intList.push(3); // the list contains 3 elements : 5,2,3
555
+		for ( int * iterator = intList.begin(); iterator != intList.end(); iterator ++ ) {
556
+			int currentValue=*iterator;
557
+			if ( currentValue == 2 ) {
558
+				// remove this value from the list and keep iterating on next element (value == 3)
559
+				iterator = intList.remove(iterator);
560
+			}
561
+			printf("value : %d\n", currentValue ); // all 3 values will be printed : 5,2,3
562
+		}
563
+		// now the list contains only two elements : 5,3
564
+	@CEx 
565
+		TCOD_list_t intList = TCOD_list_new();
566
+		TCOD_list_push(intList,(const void *)5);
567
+		TCOD_list_push(intList,(const void *)2);
568
+		TCOD_list_push(intList,(const void *)3);
569
+		for ( int * iterator = (int *)TCOD_list_begin(intList); iterator != (int *)TCOD_list_end(intList); iterator ++ ) {
570
+			int currentValue=*iterator;
571
+			if ( currentValue == 2 ) {
572
+				iterator = (int *)TCOD_list_remove_iterator(intList,(void **)iterator);
573
+			}
574
+			printf("value : %d\n", currentValue );
575
+		}
576
+	*/
577
+	T *remove(T *elt) {
578
+		for ( T* curElt = elt; curElt < end()-1; curElt ++) {
579
+			*curElt = *(curElt+1);
580
+		}
581
+		fillSize--;
582
+		if ( fillSize == 0 ) return ((T *)NULL)-1;
583
+		else return elt-1;
584
+	}
585
+	T *removeFast(T *elt) {
586
+		*elt = array[fillSize-1];
587
+		fillSize--;
588
+		if ( fillSize == 0 ) return ((T *)NULL)-1;
589
+		else return elt-1;
590
+	}
591
+
592
+	TCODList<T> & operator = (TCODList<T> const & l2) {
593
+		while ( allocSize < l2.allocSize ) allocate();
594
+		fillSize=l2.fillSize;
595
+		int i=0;
596
+		for (T *t=l2.begin(); t != l2.end(); t++) {
597
+			array[i++]=*t;
598
+		}
599
+		return *this;
600
+	}  
601
+
602
+protected :
603
+	void allocate() {
604
+		int newSize = allocSize * 2;
605
+		if ( newSize == 0 ) newSize = 16;
606
+		T *newArray = new T[ newSize ];
607
+		if ( array ) {
608
+			if ( fillSize > 0 ) memcpy(newArray, array, sizeof(T)*fillSize);
609
+			delete [] array;
610
+		}
611
+		array=newArray;
612
+		allocSize=newSize;
613
+	}
614
+};
615
+
616
+#endif
0 617
new file mode 100644
... ...
@@ -0,0 +1,56 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_RANDOM_H
29
+#define _TCOD_RANDOM_H
30
+
31
+#include "mersenne_types.h"
32
+
33
+typedef void *TCOD_random_t;
34
+
35
+TCODLIB_API TCOD_random_t TCOD_random_get_instance(void);
36
+TCODLIB_API TCOD_random_t TCOD_random_new(TCOD_random_algo_t algo);
37
+TCODLIB_API TCOD_random_t TCOD_random_save(TCOD_random_t mersenne);
38
+TCODLIB_API void TCOD_random_restore(TCOD_random_t mersenne, TCOD_random_t backup);
39
+TCODLIB_API TCOD_random_t TCOD_random_new_from_seed(TCOD_random_algo_t algo, uint32 seed);
40
+TCODLIB_API void TCOD_random_delete(TCOD_random_t mersenne);
41
+
42
+TCODLIB_API void TCOD_random_set_distribution (TCOD_random_t mersenne, TCOD_distribution_t distribution);
43
+
44
+TCODLIB_API int TCOD_random_get_int (TCOD_random_t mersenne, int min, int max);
45
+TCODLIB_API float TCOD_random_get_float (TCOD_random_t mersenne, float min, float max);
46
+TCODLIB_API double TCOD_random_get_double (TCOD_random_t mersenne, double min, double max);
47
+
48
+TCODLIB_API int TCOD_random_get_int_mean (TCOD_random_t mersenne, int min, int max, int mean);
49
+TCODLIB_API float TCOD_random_get_float_mean (TCOD_random_t mersenne, float min, float max, float mean);
50
+TCODLIB_API double TCOD_random_get_double_mean (TCOD_random_t mersenne, double min, double max, double mean);
51
+
52
+TCODLIB_API TCOD_dice_t TCOD_random_dice_new (const char * s);
53
+TCODLIB_API int TCOD_random_dice_roll (TCOD_random_t mersenne, TCOD_dice_t dice);
54
+TCODLIB_API int TCOD_random_dice_roll_s (TCOD_random_t mersenne, const char * s);
55
+
56
+#endif
0 57
new file mode 100644
... ...
@@ -0,0 +1,400 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_RANDOM_HPP
29
+#define _TCOD_RANDOM_HPP
30
+
31
+#include "mersenne_types.h"
32
+
33
+/**
34
+ @PageName random
35
+ @PageCategory Base toolkits
36
+ @PageTitle Pseudorandom number generator
37
+ @PageDesc This toolkit is an implementation of two fast and high quality pseudorandom number generators:
38
+* a Mersenne twister generator,
39
+* a Complementary-Multiply-With-Carry generator.
40
+CMWC is faster than MT (see table below) and has a much better period (1039460 vs. 106001). It is the default algo since libtcod 1.5.0.
41
+
42
+Relative performances in two independent tests (lower is better) :
43
+<table class="param">
44
+    <tr>
45
+      <th>Algorithm</th>
46
+      <th>Numbers generated</th>
47
+      <th>Perf (1)</th>
48
+      <th>Perf (2)</th>
49
+    </tr>
50
+    <tr class="hilite">
51
+      <td>MT</td>
52
+      <td>integer</td>
53
+      <td>62</td>
54
+      <td>50</td>
55
+    </tr>
56
+    <tr>
57
+      <td>MT</td>
58
+      <td>float</td>
59
+      <td>54</td>
60
+      <td>45</td>
61
+    </tr>
62
+    <tr class="hilite">
63
+      <td>CMWC</td>
64
+      <td>integer</td>
65
+      <td>21</td>
66
+      <td>34</td>
67
+    </tr>
68
+    <tr>
69
+      <td>CMWC</td>
70
+      <td>float</td>
71
+      <td>32</td>
72
+      <td>27</td>
73
+    </tr>
74
+</table>
75
+
76
+<h6>For python users:</h6>
77
+Python already has great builtin random generators. But some parts of the Doryen library (noise, heightmap, ...) uses RNG as parameters. If you intend to use those functions, you must provide a RNG created with the library.
78
+
79
+<h6>For C# users:</h6>
80
+.NET already has great builtin random generators. But some parts of the Doryen library (noise, heightmap, ...) uses RNG as parameters. If you intend to use those functions, you must provide a RNG created with the library.
81
+ */
82
+
83
+class TCODLIB_API TCODRandom {
84
+	public :
85
+		/**
86
+		@PageName random_init
87
+		@PageFather random
88
+		@PageTitle Creating a generator
89
+		@FuncTitle Default generator
90
+		@FuncDesc The simplest way to get random number is to use the default generator. The first time you get this generator, it is initialized by calling TCOD_random_new. Then, on successive calls, this function returns the same generator (singleton pattern).
91
+		@Cpp static TCODRandom * TCODRandom::getInstance (void)
92
+		@C TCOD_random_t TCOD_random_get_instance (void)
93
+		@Py random_get_instance ()
94
+		@C# static TCODRandom TCODRandom::getInstance()
95
+		@Param algo	The PRNG algorithm the generator should be using. Possible values are:
96
+			* TCOD_RNG_MT for Mersenne Twister,
97
+			* TCOD_RNG_CMWC for Complementary Multiply-With-Carry.
98
+		*/
99
+		static TCODRandom * getInstance(void);
100
+
101
+		/**
102
+		@PageName random_init
103
+		@FuncTitle Generators with random seeds
104
+		@FuncDesc You can also create as many generators as you want with a random seed (the number of seconds since Jan 1 1970 at the time the constructor is called). Warning ! If you call this function several times in the same second, it will return the same generator.
105
+		@Cpp TCODRandom::TCODRandom (TCOD_random_algo_t algo = TCOD_RNG_CMWC)
106
+		@C TCOD_random_t TCOD_random_new (TCOD_random_algo_t algo)
107
+		@Py random_new (algo = RNG_CMWC)
108
+		@C#
109
+			TCODRandom::TCODRandom() // Defaults to ComplementaryMultiplyWithCarry
110
+			TCODRandom::TCODRandom(TCODRandomType algo)
111
+		@Param algo	The PRNG algorithm the generator should be using.
112
+		*/
113
+		TCODRandom(TCOD_random_algo_t algo = TCOD_RNG_CMWC, bool allocate = true);
114
+
115
+		/**
116
+		@PageName random_init
117
+		@FuncTitle Generators with user defined seeds
118
+		@FuncDesc Finally, you can create generators with a specific seed. Those allow you to get a reproducible set of random numbers. You can for example save a dungeon in a file by saving only the seed used for its generation (provided you have a determinist generation algorithm)
119
+		@Cpp TCODRandom::TCODRandom (uint32 seed, TCOD_random_algo_t algo = TCOD_RNG_CMWC);
120
+		@C TCOD_random_t TCOD_random_new_from_seed (TCOD_random_algo_t algo, uint32 seed);
121
+		@Py random_new_from_seed(seed, algo=RNG_CMWC)
122
+		@C#
123
+			TCODRandom::TCODRandom(uint32 seed) // Defaults to ComplementaryMultiplyWithCarry
124
+			TCODRandom::TCODRandom(uint32 seed, TCODRandomType algo)
125
+		@Param seed	The 32 bits seed used to initialize the generator. Two generators created with the same seed will generate the same set of pseudorandom numbers.
126
+		@Param algo	The PRNG algorithm the generator should be using.
127
+		@CppEx
128
+			// default generator
129
+			TCODRandom * default = TCODRandom::getInstance();
130
+			// another random generator
131
+			TCODRandom * myRandom = new TCODRandom();
132
+			// a random generator with a specific seed
133
+			TCODRandom * myDeterministRandom = new TCODRandom(0xdeadbeef);
134
+        @CEx
135
+			// default generator
136
+			TCOD_random_t default = TCOD_random_get_instance();
137
+			// another random generator
138
+			TCOD_random_t my_random = TCOD_random_new(TCOD_RNG_CMWC);
139
+			// a random generator with a specific seed
140
+			TCOD_random_t my_determinist_random = TCOD_random_new_from_seed(TCOD_RNG_CMWC,0xdeadbeef);
141
+		@PyEx
142
+			# default generator
143
+			default = libtcod.random_get_instance()
144
+			# another random generator
145
+			my_random = libtcod.random_new()
146
+			# a random generator with a specific seed
147
+			my_determinist_random = libtcod.random_new_from_seed(0xdeadbeef)
148
+		*/
149
+		TCODRandom(uint32 seed, TCOD_random_algo_t algo = TCOD_RNG_CMWC);
150
+
151
+		/**
152
+		@PageName random_init
153
+		@FuncTitle Destroying a RNG
154
+		@FuncDesc To release ressources used by a generator, use those functions :
155
+			NB : do not delete the default random generator !
156
+		@Cpp TCODRandom::~TCODRandom()
157
+		@C void TCOD_random_delete(TCOD_random_t mersenne)
158
+		@Py random_delete(mersenne)
159
+		@C# void TCODRandom::Dispose()
160
+		@Param mersenne	In the C and Python versions, the generator handler, returned by the initialization functions.
161
+		@CppEx
162
+			// create a generator
163
+			TCODRandom *rnd = new TCODRandom();
164
+			// use it
165
+			...
166
+			// destroy it
167
+			delete rnd;
168
+		@CEx
169
+			// create a generator
170
+			TCOD_random_t rnd = TCOD_random_new();
171
+			// use it
172
+			...
173
+			// destroy it
174
+			TCOD_random_delete(rnd);
175
+		@PyEx
176
+			# create a generator
177
+			rnd = libtcod.random_new()
178
+			# use it
179
+			...
180
+			# destroy it
181
+			libtcod.random_delete(rnd)
182
+		*/
183
+		virtual ~TCODRandom();
184
+
185
+		/**
186
+		@PageName random_distro
187
+		@PageFather random
188
+		@PageTitle Using a generator
189
+		@FuncTitle Setting the default RNG distribution
190
+		@FuncDesc Random numbers can be obtained using several different distributions. Linear is default, but if you wish to use one of the available Gaussian distributions, you can use this function to tell libtcod which is your preferred distribution. All random number getters will then use that distribution automatically to fetch your random numbers.
191
+The distributions available are as follows:
192
+1. TCOD_DISTRIBUTION_LINEAR
193
+This is the default distribution. It will return a number from a range min-max. The numbers will be evenly distributed, ie, each number from the range has the exact same chance of being selected.
194
+2. TCOD_DISTRIBUTION_GAUSSIAN
195
+This distribution does not have minimum and maximum values. Instead, a mean and a standard deviation are used. The mean is the central value. It will appear with the greatest frequency. The farther away from the mean, the less the probability of appearing the possible results have. Although extreme values are possible, 99.7% of the results will be within the radius of 3 standard deviations from the mean. So, if the mean is 0 and the standard deviation is 5, the numbers will mostly fall in the (-15,15) range.
196
+3. TCOD_DISTRIBUTION_GAUSSIAN_RANGE
197
+This one takes minimum and maximum values. Under the hood, it computes the mean (which falls right between the minimum and maximum) and the standard deviation and applies a standard Gaussian distribution to the values. The difference is that the result is always guaranteed to be in the min-max range.
198
+4. TCOD_DISTRIBUTION_GAUSSIAN_INVERSE
199
+Essentially, this is the same as TCOD_DISTRIBUTION_GAUSSIAN. The difference is that the values near +3 and -3 standard deviations from the mean have the highest possibility of appearing, while the mean has the lowest.
200
+5. TCOD_DISTRIBUTION_GAUSSIAN_RANGE_INVERSE
201
+Essentially, this is the same as TCOD_DISTRIBUTION_GAUSSIAN_RANGE, but the min and max values have the greatest probability of appearing, while the values between them, the lowest.
202
+
203
+There exist functions to also specify both a min-max range AND a custom mean, which can be any value (possibly either min or max, but it can even be outside that range). In case such a function is used, the distributions will trigger a slihtly different behaviour:
204
+* TCOD_DISTRIBUTION_LINEAR
205
+* TCOD_DISTRIBUTION_GAUSSIAN
206
+* TCOD_DISTRIBUTION_GAUSSIAN_RANGE
207
+In these cases, the selected mean will have the highest probability of appearing.
208
+
209
+* TCOD_DISTRIBUTION_GAUSSIAN_INVERSE
210
+* TCOD_DISTRIBUTION_GAUSSIAN_RANGE_INVERSE
211
+In these cases, the selected mean will appear with the lowest frequency.
212
+		@Cpp void TCODRandom::setDistribution(TCOD_distribution_t distribution)
213
+		@C void TCOD_random_set_distribution(TCOD_random_t mersenne, TCOD_distribution_t distribution)
214
+		@Py
215
+		@C#
216
+		@Param mersenne	In the C and Python versions, the generator handler, returned by the initialization functions. If NULL, the default generator is used..
217
+		@Param distribution The distribution constant from the available set:<ul><li>TCOD_DISTRIBUTION_LINEAR</li><li>TCOD_DISTRIBUTION_GAUSSIAN</li><li>TCOD_DISTRIBUTION_GAUSSIAN_RANGE</li><li>TCOD_DISTRIBUTION_GAUSSIAN_INVERSE</li><li>TCOD_DISTRIBUTION_GAUSSIAN_RANGE_INVERSE</li></ul>
218
+		*/
219
+		inline void setDistribution (TCOD_distribution_t distribution) { TCOD_random_set_distribution(data,distribution); }
220
+
221
+		/**
222
+		@PageName random_use
223
+		@PageFather random
224
+		@PageTitle Using a generator
225
+		@FuncTitle Getting an integer
226
+		@FuncDesc Once you obtained a generator (using one of those methods), you can get random numbers using the following functions, using either the explicit or simplified API where applicable:
227
+		@Cpp
228
+			//explicit API:
229
+			int TCODRandom::getInt(int min, int max, int mean = 0)
230
+
231
+			//simplified API:
232
+			int TCODRandom::get(int min, int max, int mean = 0)
233
+		@C
234
+			int TCOD_random_get_int(TCOD_random_t mersenne, int min, int max)
235
+			int TCOD_random_get_int_mean(TCOD_random_t mersenne, int min, int max, int mean)
236
+		@Py
237
+		@C#
238
+		@Param mersenne	In the C and Python versions, the generator handler, returned by the initialization functions. If NULL, the default generator is used..
239
+		@Param min,max	Range of values returned. Each time you call this function, you get a number between (including) min and max
240
+		@Param mean This is used to set a custom mean, ie, not min+((max-min)/2). It can even be outside of the min-max range. Using a mean will force the use of a weighted (Gaussian) distribution, even if linear is set.
241
+		*/
242
+		inline int getInt (int min, int max, int mean = 0) { return (mean <= 0) ? TCOD_random_get_int(data,min,max) : TCOD_random_get_int_mean(data,min,max,mean); }
243
+		inline int get (int min, int max, int mean = 0) { return (mean <= 0) ? TCOD_random_get_int(data,min,max) : TCOD_random_get_int_mean(data,min,max,mean); }
244
+
245
+		/**
246
+		@PageName random_use
247
+		@FuncTitle Getting a float
248
+		@FuncDesc To get a random floating point number, using either the explicit or simplified API where applicable
249
+		@Cpp
250
+			//explicit API:
251
+			float TCODRandom::getFloat(float min, float max, float mean = 0.0f)
252
+
253
+			//simplified API:
254
+			float TCODRandom::get(float min, float max, float mean = 0.0f)
255
+		@C
256
+			float TCOD_random_get_float(TCOD_random_t mersenne, float min, float max)
257
+			float TCOD_random_get_float_mean(TCOD_random_t mersenne, float min, float max, float mean)
258
+		@Py random_get_float(mersenne, mi, ma)
259
+		@C# float TCODRandom::getFloat(float min, float max)
260
+		@Param mersenne	In the C and Python versions, the generator handler, returned by the initialization functions. If NULL, the default generator is used.
261
+		@Param min,max	Range of values returned. Each time you call this function, you get a number between (including) min and max
262
+		@Param mean This is used to set a custom mean, ie, not min+((max-min)/2). It can even be outside of the min-max range. Using a mean will force the use of a weighted (Gaussian) distribution, even if linear is set.
263
+		@CppEx
264
+			// default generator
265
+			TCODRandom * default = TCODRandom::getInstance();
266
+			int aRandomIntBetween0And1000 = default->getInt(0,1000);
267
+			int anotherRandomInt = default->get(0,1000);
268
+			// another random generator
269
+			TCODRandom *myRandom = new TCODRandom();
270
+			float aRandomFloatBetween0And1000 = myRandom->getFloat(0.0f,1000.0f);
271
+			float anotherRandomFloat = myRandom->get(0.0f,1000.0f);
272
+		@CEx
273
+			// default generator
274
+			int a_random_int_between_0_and_1000 = TCOD_random_get_float(NULL,0,1000);
275
+			// another random generator
276
+			TCOD_random_t my_random = TCOD_random_new();
277
+			float a_random_float_between_0_and_1000 = TCOD_random_get_float(my_random,0.0f,1000.0f);
278
+		@PyEx
279
+			# default generator
280
+			a_random_int_between_0_and_1000 = libtcod.random_get_float(0,0,1000)
281
+			# another random generator
282
+			my_random = libtcod.random_new()
283
+			a_random_float_between_0_and_1000 = libtcod.random_get_float(my_random,0.0,1000.0)
284
+		*/
285
+		inline float getFloat (float min, float max, float mean = 0.0f) { return (mean <= 0) ? TCOD_random_get_float(data,min,max) : TCOD_random_get_float_mean(data,min,max,mean); }
286
+		inline float get (float min, float max, float mean = 0.0f) { return (mean <= 0.0f) ? TCOD_random_get_float(data,min,max) : TCOD_random_get_float_mean(data,min,max,mean); }
287
+
288
+		/**
289
+		@PageName random_use
290
+		@FuncTitle Getting a double
291
+		@FuncDesc To get a random double precision floating point number, using either the explicit or simplified API where applicable
292
+		@Cpp
293
+			//explicit API:
294
+			double TCODRandom::getDouble(double min, double max, double mean = 0.0f)
295
+
296
+			//simplified API:
297
+			double TCODRandom::get(double min, double max, double mean = 0.0f)
298
+		@C
299
+			double TCOD_random_get_double(TCOD_random_t mersenne, double min, double max)
300
+			double TCOD_random_get_double_mean(TCOD_random_t mersenne, double min, double max, double mean)
301
+		@Py
302
+		@C#
303
+		@Param mersenne	In the C and Python versions, the generator handler, returned by the initialization functions. If NULL, the default generator is used.
304
+		@Param min,max	Range of values returned. Each time you call this function, you get a number between (including) min and max
305
+		@Param mean This is used to set a custom mean, ie, not min+((max-min)/2). It can even be outside of the min-max range. Using a mean will force the use of a weighted (Gaussian) distribution, even if linear is set.
306
+		@CppEx
307
+			// default generator
308
+			TCODRandom * default = TCODRandom::getInstance();
309
+			int aRandomIntBetween0And1000 = default->getInt(0,1000);
310
+			int anotherRandomInt = default->get(0,1000);
311
+			// another random generator
312
+			TCODRandom *myRandom = new TCODRandom();
313
+			float aRandomFloatBetween0And1000 = myRandom->getFloat(0.0f,1000.0f);
314
+			float anotherRandomFloat = myRandom->get(0.0f,1000.0f);
315
+		@CEx
316
+			// default generator
317
+			int a_random_int_between_0_and_1000 = TCOD_random_get_float(NULL,0,1000);
318
+			// another random generator
319
+			TCOD_random_t my_random = TCOD_random_new();
320
+			float a_random_float_between_0_and_1000 = TCOD_random_get_float(my_random,0.0f,1000.0f);
321
+		@PyEx
322
+			# default generator
323
+			a_random_int_between_0_and_1000 = libtcod.random_get_float(0,0,1000)
324
+			# another random generator
325
+			my_random = libtcod.random_new()
326
+			a_random_float_between_0_and_1000 = libtcod.random_get_float(my_random,0.0,1000.0)
327
+		*/
328
+		inline double getDouble (double min, double max, double mean = 0.0) { return (mean <= 0) ? TCOD_random_get_double(data,min,max) : TCOD_random_get_double_mean(data,min,max,mean); }
329
+		inline double get (double min, double max, double mean = 0.0f) { return (mean <= 0.0) ? TCOD_random_get_double(data,min,max) : TCOD_random_get_double_mean(data,min,max,mean); }
330
+
331
+		/**
332
+		@PageName random_use
333
+		@FuncTitle Saving a RNG state
334
+		@FuncDesc You can save the state of a generator with :
335
+		@Cpp TCODRandom *TCODRandom::save() const
336
+		@C TCOD_random_t TCOD_random_save(TCOD_random_t mersenne)
337
+		@Py random_save(mersenne)
338
+		@C# TCODRandom TCODRandom::save()
339
+		@Param mersenne	In the C and Python versions, the generator handler, returned by the initialization functions. If NULL, the default generator is used.
340
+		*/
341
+		TCODRandom * save() const;
342
+
343
+		/**
344
+		@PageName random_use
345
+		@FuncTitle Restoring a saved state
346
+		@FuncDesc And restore it later. This makes it possible to get the same serie of number several times with a single generator.
347
+		@Cpp void TCODRandom::restore(const TCODRandom *backup)
348
+		@C void TCOD_random_restore(TCOD_random_t mersenne, TCOD_random_t backup)
349
+		@Py random_restore(mersenne, backup)
350
+		@C# void TCODRandom::restore(TCODRandom backup)
351
+		@Param mersenne	In the C and Python versions, the generator handler, returned by the initialization functions. If NULL, the default generator is used.
352
+		@CppEx
353
+			// default generator
354
+			TCODRandom * default = TCODRandom::getInstance();
355
+			// save the state
356
+			TCODRandom *backup=default->save();
357
+			// get a random number (or several)
358
+			int number1 = default->getInt(0,1000);
359
+			// restore the state
360
+			default->restore(backup);
361
+			// get a random number
362
+			int number2 = default->getInt(0,1000);
363
+			// => number1 == number2
364
+		@CEx
365
+			// save default generator state
366
+			TCOD_random_t backup=TCOD_random_save(NULL);
367
+			// get a random number
368
+			int number1 = TCOD_random_get_float(NULL,0,1000);
369
+			// restore the state
370
+			TCOD_random_restore(NULL,backup);
371
+			// get a random number
372
+			int number2 = TCOD_random_get_float(NULL,0,1000);
373
+			// number1 == number2
374
+		@PyEx
375
+			# save default generator state
376
+			backup=libtcod.random_save(0)
377
+			# get a random number
378
+			number1 = libtcod.random_get_float(0,0,1000)
379
+			# restore the state
380
+			libtcod.random_restore(0,backup)
381
+			# get a random number
382
+			number2 = libtcod.random_get_float(0,0,1000)
383
+			# number1 == number2
384
+		*/
385
+		void restore(const TCODRandom *backup);
386
+
387
+		//dice
388
+		inline TCOD_dice_t dice (const char * s) { return TCOD_random_dice_new(s); }
389
+		inline int diceRoll (TCOD_dice_t dice) { return TCOD_random_dice_roll(data,dice); }
390
+		inline int diceRoll (const char * s) { return TCOD_random_dice_roll(data,TCOD_random_dice_new(s)); }
391
+
392
+	protected :
393
+		friend class TCODLIB_API TCODNoise;
394
+		friend class TCODLIB_API TCODHeightMap;
395
+		friend class TCODLIB_API TCODNamegen;
396
+		friend class TCODNameGenerator;	// Used for SWIG interface, does NOT need TCODLIB_API
397
+		TCOD_random_t data;
398
+};
399
+
400
+#endif
0 401
new file mode 100644
... ...
@@ -0,0 +1,53 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_RANDOM_TYPES_H
29
+#define _TCOD_RANDOM_TYPES_H
30
+
31
+/* dice roll */
32
+typedef struct {
33
+	int nb_rolls;
34
+	int nb_faces;
35
+	float multiplier;
36
+	float addsub;
37
+} TCOD_dice_t;
38
+
39
+/* PRNG algorithms */
40
+typedef enum {
41
+    TCOD_RNG_MT,
42
+    TCOD_RNG_CMWC
43
+} TCOD_random_algo_t;
44
+
45
+typedef enum {
46
+	TCOD_DISTRIBUTION_LINEAR,
47
+	TCOD_DISTRIBUTION_GAUSSIAN,
48
+	TCOD_DISTRIBUTION_GAUSSIAN_RANGE,
49
+	TCOD_DISTRIBUTION_GAUSSIAN_INVERSE,
50
+	TCOD_DISTRIBUTION_GAUSSIAN_RANGE_INVERSE
51
+} TCOD_distribution_t;
52
+
53
+#endif /* _TCOD_RANDOM_TYPES_H */
0 54
new file mode 100644
... ...
@@ -0,0 +1,39 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_MOUSE_H
29
+#define _TCOD_MOUSE_H
30
+
31
+#include "mouse_types.h"
32
+
33
+TCODLIB_API void TCOD_mouse_show_cursor(bool visible);
34
+TCODLIB_API TCOD_mouse_t TCOD_mouse_get_status();
35
+TCODLIB_API bool TCOD_mouse_is_cursor_visible();
36
+TCODLIB_API void TCOD_mouse_move(int x, int y);
37
+TCODLIB_API void TCOD_mouse_includes_touch(bool enable);
38
+
39
+#endif
0 40
new file mode 100644
... ...
@@ -0,0 +1,76 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_MOUSE_HPP
29
+#define _TCOD_MOUSE_HPP
30
+
31
+#include "mouse_types.h"
32
+
33
+class TCODLIB_API TCODMouse {
34
+public :
35
+	/**
36
+	@PageName mouse
37
+	@PageTitle Mouse support
38
+	@PageCategory Base toolkits
39
+	@FuncTitle Display and hide the mouse cursor
40
+	@FuncDesc By default, the mouse cursor in visible in windowed mode, hidden in fullscreen mode. You can change it with:
41
+	@Cpp static void TCODMouse::showCursor (bool visible)
42
+	@C void TCOD_mouse_show_cursor (bool visible)
43
+	@Py mouse_show_cursor (visible)
44
+	@C# void TCODMouse::showCursor(bool visible)
45
+	@Param visible	If true, this function turns the mouse cursor on. Else it turns the mouse cursor off.
46
+	*/
47
+	static void showCursor(bool visible);
48
+
49
+	/**
50
+	@PageName mouse
51
+	@FuncTitle Getting the cursor status
52
+	@FuncDesc You can get the current cursor status (hidden or visible) with:
53
+	@Cpp static bool TCODMouse::isCursorVisible (void)
54
+	@C bool TCOD_mouse_is_cursor_visible (void)
55
+	@Py mouse_is_cursor_visible ()
56
+	@C# bool TCODMouse::isCursorVisible()
57
+	*/
58
+	static bool isCursorVisible();
59
+
60
+	/**
61
+	@PageName mouse
62
+	@FuncTitle Setting the mouse cursor's position
63
+	@FuncDesc You can set the cursor position (in pixel coordinates, where [0,0] is the window's top left corner) with:
64
+	@Cpp static void TCODMouse::move (int x, int y)
65
+	@C void TCOD_mouse_move (int x, int y)
66
+	@Py mouse_move (x, y)
67
+	@C# void TCODMouse::moveMouse(int x, int y)
68
+	@Param x,y	New coordinates of the mouse cursor in pixels.
69
+	*/
70
+	static void move(int x, int y);
71
+
72
+	/* deprecated as of 1.5.1 */	
73
+	static TCOD_mouse_t getStatus();
74
+};
75
+
76
+#endif
0 77
new file mode 100644
... ...
@@ -0,0 +1,47 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_MOUSE_TYPES_H
29
+#define _TCOD_MOUSE_TYPES_H
30
+
31
+/* mouse data */
32
+typedef struct {
33
+  int x,y; /* absolute position */
34
+  int dx,dy; /* movement since last update in pixels */
35
+  int cx,cy; /* cell coordinates in the root console */
36
+  int dcx,dcy; /* movement since last update in console cells */
37
+  bool lbutton ; /* left button status */
38
+  bool rbutton ; /* right button status */
39
+  bool mbutton ; /* middle button status */
40
+  bool lbutton_pressed ; /* left button pressed event */ 
41
+  bool rbutton_pressed ; /* right button pressed event */ 
42
+  bool mbutton_pressed ; /* middle button pressed event */ 
43
+  bool wheel_up ; /* wheel up event */
44
+  bool wheel_down ; /* wheel down event */
45
+} TCOD_mouse_t;
46
+
47
+#endif /* _TCOD_MOUSE_TYPES_H */
0 48
new file mode 100644
... ...
@@ -0,0 +1,49 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+* Mingos' NameGen
29
+* This file was written by Dominik "Mingos" Marczuk.
30
+*/
31
+
32
+#ifndef _TCOD_NAMEGEN_H
33
+#define _TCOD_NAMEGEN_H
34
+
35
+/* the generator typedef */
36
+typedef void * TCOD_namegen_t;
37
+
38
+/* parse a file with syllable sets */
39
+TCODLIB_API void TCOD_namegen_parse (const char * filename, TCOD_random_t random);
40
+/* generate a name */
41
+TCODLIB_API char * TCOD_namegen_generate (char * name, bool allocate);
42
+/* generate a name using a custom generation rule */
43
+TCODLIB_API char * TCOD_namegen_generate_custom (char * name, char * rule, bool allocate);
44
+/* retrieve the list of all available syllable set names */
45
+TCODLIB_API TCOD_list_t TCOD_namegen_get_sets (void);
46
+/* delete a generator */
47
+TCODLIB_API void TCOD_namegen_destroy (void);
48
+
49
+#endif
0 50
new file mode 100644
... ...
@@ -0,0 +1,290 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+* Mingos' NameGen
29
+* This file was written by Dominik "Mingos" Marczuk.
30
+*/
31
+
32
+#ifndef _TCOD_NAMEGEN_HPP
33
+#define _TCOD_NAMEGEN_HPP
34
+
35
+/**
36
+ @PageName namegen
37
+ @PageCategory Roguelike toolkits
38
+ @PageTitle Name generator
39
+ @PageDesc This tool allows to generate random names out of custom made syllable sets.
40
+ */
41
+class TCODLIB_API TCODNamegen {
42
+	public:
43
+		/**
44
+		@PageName namegen_init
45
+		@PageFather namegen
46
+		@PageTitle Creating a generator
47
+		@FuncDesc In order to be able to generate names, the name generator needs to be fed proper data. It will then be ready to generate random names defined in the file(s) it is fed. Syllable set parsing is achieved via the following.
48
+			Note 1: Each file will be parsed once only. If, for some reason, you would like to parse the same file twice, you will need to destroy the generator first, which will empty the list of parsed files along with erasing all the data retrieved from those files.
49
+			
50
+			Note 2: The generator can be fed data multiple times if you have it in separate files. Just make sure the structure names in them aren't duplicated, otherwise they will be silently ignored.
51
+			
52
+			Note 3: In the C++ version, you are not obliged to specify the random number generator. If you skip it in the function call, the generator will assume you would like to use an instance of the default generator.
53
+
54
+		@Cpp static void TCODNamegen::parse (const char * filename, TCODRandom * random = NULL)
55
+		@C void TCOD_namegen_parse (const char * filename, TCOD_random_t random)
56
+		@Py namegen_parse (filename, random = 0)
57
+		@C#
58
+			static void TCODNameGenerator::parse(string filename)
59
+			static void TCODNameGenerator::parse(string filename, TCODRandom random)
60
+		@Param filename 	The file where the desired syllable set is saved, along with its relative parh, for instance, "data/names.txt".
61
+		@Param random 	A random number generator object. Use NULL for the default random number generator
62
+		@CppEx 
63
+			TCODNamegen::parse("data/names.txt",TCODRandom::getInstance());
64
+			TCODNamegen::parse("data/names2.txt");
65
+		@CEx TCOD_namegen_parse("data/names.txt",TCOD_random_get_instance());
66
+		@PyEx libtcod.namegen_parse('data/names.txt')
67
+		*/
68
+		static void parse (const char * filename, TCODRandom * random = NULL);
69
+
70
+		/**
71
+		@PageName namegen_init
72
+		@FuncTitle Destroying a generator
73
+		@FuncDesc To release the resources used by a name generator, you may call:
74
+			This will free all memory used by the generator. In order to generate a name again, you have to parse a file again. 
75
+		@Cpp static void TCODNamegen::destroy (void)
76
+		@C void TCOD_namegen_destroy (void)
77
+		@Py namegen_destroy ()
78
+		@C# static void TCODNameGenerator::destroy()
79
+		*/
80
+		static void destroy (void);
81
+
82
+		/**
83
+		@PageName namegen_generate
84
+		@PageTitle Generating a name
85
+		@PageFather namegen
86
+		@FuncTitle Generating a default name
87
+		@FuncDesc The following will output a random name generated using one of the generation rules specified in the syllable set:
88
+			Should you choose to allocate memory for the output, you need to remember to deallocate it once you don't need the name anymore using the free() function. This applies to C++ as well (delete won't work - you have to use free()).
89
+			
90
+			On the other hand, should you choose not to allocate memory, be aware that subsequent calls will overwrite the previously returned pointer, so make sure to copy the output using strcpy(), strdup() or other means of your choosing.
91
+			
92
+			The name you specify needs to be in one of the files the generator has previously parsed (see Creating a generator). If such a name doesn't exist, a warning will be displayed and NULL will be returned.
93
+		@Cpp static char * TCODNamegen::generate (char * name, bool allocate = false)
94
+		@C char * TCOD_namegen_generate (char * name, bool allocate)
95
+		@Py namegen_generate (name, allocate = 0)
96
+		@C# string TCODNameGenerator::generate (string name)
97
+		@Param name 	The structure name you wish to refer to, for instance, "celtic female".
98
+			For more about how structure names work, please refer to <a href="namegen_file.html">those</a> <a href="parser_format.html">chapters</a>.
99
+		@Param allocate 	Whether memory should be allocated for the output or not.
100
+		@CppEx 
101
+			TCODNamegen::parse("data/names.txt",TCODRandom::getInstance());
102
+			char * myName = TCODNamegen::generate("fantasy female");
103
+		@CEx 
104
+			TCOD_namegen_parse("data/names.txt",TCOD_random_get_instance());
105
+			char * my_name = TCOD_namegen_generate("Celtic male",false);
106
+		@PyEx 
107
+			libtcod.namegen_parse('data/names.txt')
108
+			name = libtcod.namegen_generate('Nordic female')
109
+		*/
110
+		static char * generate (char * name, bool allocate = false);
111
+
112
+		/**
113
+		@PageName namegen_generate
114
+		@FuncTitle Generating a custom name
115
+		@FuncDesc It is also possible to generate a name using custom generation rules. This overrides the random choice of a generation rule from the syllable set. Please refer to chapter 16.5 to learn about the name generation rules syntax.
116
+		@Cpp static char * TCODNamegen::generateCustom (char * name, char * rule, bool allocate = false)
117
+		@C char * TCOD_namegen_generate_custom (char * name, char * rule, bool allocate)
118
+		@Py namegen_generate_custom (name, rule, allocate = 0)
119
+		@C# string TCODNameGenerator::generateCustom (string name, string rule)
120
+		@Param name 	The structure name you wish to refer to, for instance, "celtic female".
121
+			For more about how structure names work, please refer to <a href="namegen_file.html">those</a> <a href="parser_format.html">chapters</a>.
122
+		@Param rule 	The name generation rule. See <a href="namegen_file.html">this chapter</a> for more details.
123
+		@Param allocate 	Whether memory should be allocated for the output or not.
124
+		@CppEx 
125
+			TCODNamegen::parse("data/names.txt",TCODRandom::getInstance());
126
+			char * myName = TCODNamegen::generateCustom("Nordic male","$s$e");
127
+		@CEx 
128
+			TCOD_namegen_parse("data/names.txt",TCOD_random_get_instance());
129
+			char * my_name = TCOD_namegen_generate_custom("Mesopotamian female","$s$e",false);
130
+		@PyEx 
131
+			libtcod.namegen_parse('data/names.txt')
132
+			name = libtcod.namegen_generate_custom('Nordic female','$s$e')
133
+		*/
134
+		static char * generateCustom (char * name, char * rule, bool allocate = false);
135
+
136
+		/**
137
+		@PageName namegen_generate
138
+		@FuncTitle Retrieving available set names
139
+		@FuncDesc If you wish to check the sylable set names that are currently available, you may call:
140
+		This will create a list with all the available syllable set names. Remember to delete that list after you don't need it anymore!
141
+		@Cpp static TCODList TCODNamegen::getSets ()
142
+		@C TCOD_list_t TCOD_namegen_get_sets ()
143
+		@Py namegen_get_sets ()
144
+		@C# static IEnumerable<string> TCODNameGenerator::getSets()
145
+		*/
146
+		static TCOD_list_t getSets (void);
147
+
148
+		/**
149
+		@PageName namegen_file
150
+		@PageFather namegen
151
+		@PageTitle Syllable set configuration
152
+		@PageDesc Configuring the syllable set is vital to obtaining high quality randomly generated names. Please refer to the following subchapters for detailed information:
153
+		*/
154
+
155
+		/**
156
+		@PageName namegen_file_1
157
+		@PageFather namegen_file
158
+		@PageTitle  Syllable set basic structure
159
+		@PageDesc The syllable sets need to be written in one or more text files that will be opened and parsed by the generator.
160
+
161
+The data uses a standard TCODParser file and data should be inserted according to the general rules of creating a configuration file. For more information, please refer to <a href="parser_format.html">The libtcod config file format</a>.
162
+
163
+The structure type that's defined in the generator is "name". This structure type must also be accompanied by a structure name. It will be used for identification purposes in the generator. For instance, if you use a structure name "fantasy female", you will be able to access this syllable set by creating a generator using "fantasy female" syllables. In the initialisation function, this is the "const char * name" argument.
164
+
165
+The structure contains different members, all of which must be of TCOD_TYPE_STRING type. The tokens inside the strings, be them phonemes or syllables, form a single string, but are separated with separator characters. Characters used for token separation are all characters that are not Latin upper- or lowercase characters, dashes or apostrophes. A comma, a space or a comma+space are all perfectly valid, human-readable separators. In order to use a character inside a string that would normally be considered a separator, precede it with a slash (eg. "/:", "/.", "/!", etc.). An exception to this rule is the space character, which can also be achieved by using an underscore (eg. "the_Great").
166
+
167
+The structure members that may thus be defined are:
168
+<div class="code"><p>phonemesVocals
169
+phonemesConsonants
170
+syllablesPre
171
+syllablesStart
172
+syllablesMiddle
173
+syllablesEnd
174
+syllablesPost
175
+</p></div>
176
+
177
+All of those strings are considered optional. However, if you don't define a string, but reference it in the name generation rules, you will see a warning displayed on stderr about missing data.
178
+		*/
179
+
180
+		/**
181
+		@PageName namegen_file_2
182
+		@PageFather namegen_file
183
+		@PageTitle  Illegal strings
184
+		@PageDesc Another optional property is
185
+<div class="code"><p>illegal</p></div>
186
+
187
+This property contains strings that are considered illegal and thus not desired in your names. Should a generated name contain any of the tokens specified in this string, it will be discarded and replaced by a new one. Illegal strings may be as short as single characters or as long as entire names. However, it is best to create a syllable set that generates very few names that sound bad. Otherwise, the illegal list might become very long.
188
+
189
+Be aware that the generator will automatically correct or reject certain words, so you don't need to place every undesired possibility in this string.
190
+
191
+The generator will correct the following:
192
+
193
+    * leading spaces ("_NAME")
194
+    * ending spaces ("NAME_")
195
+    * double spaces ("NAME1__NAME2")
196
+
197
+It will generate a new name in the following cases:
198
+
199
+    * triple characters ("Raaagnar")
200
+    * two-character adjacent repetitions ("Bobofur" is wrong, but "Bombofur" is OK)
201
+    * three-character (or more) repetitions, whether adjacent or not ("Bombombur", "Dagbjoerdag", "Gwaerdygwaern")
202
+
203
+Remember that all of this is case-insensitive, so you don't need to care about uppercase/lowercase distinction in your illegal strings.
204
+		*/
205
+
206
+		/**
207
+		@PageName namegen_file_3
208
+		@PageFather namegen_file
209
+		@PageTitle Rules
210
+		@PageDesc There's one last string that's contained within the structure:
211
+<div class="code"><p>rules</p></div>
212
+
213
+It is mandatory, so not defining it will trigger an error. It defines how the generator should join the supplied data in order to generate a name. This string uses a syntax of its own, which is also used when specifying a rule when generating a custom name (see chapter 16.2).
214
+
215
+The rules are parsed pretty much the same way as all other strings, so all rules regarding separators and special characters apply as well. However, you can additionally use a set of wildcards and frequency markers. Each wildcard is preceded by the dollar sign ('$'), while frequency markers are preceded by the per cent sign ('%'). Here's the complete wildcard list:
216
+<table class="param">
217
+<tbody><tr><th>Wildcard</th><th>Example</th><th>Description</th></tr>
218
+<tr class="hilite"><td>$[INT]P</td><td>$P, $25P</td><td>Use a random Pre syllable.<br>The optional integer value denotes the per cent chance of adding the syllable.</td></tr>
219
+<tr><td>$[INT]s</td><td>$s, $25s</td><td>Use a random Start syllable.</td></tr>
220
+<tr class="hilite"><td>$[INT]m</td><td>$m, $25m</td><td>Use a random Middle syllable.</td></tr>
221
+
222
+<tr><td>$[INT]e</td><td>$e, $25e</td><td>Use a random End syllable.</td></tr>
223
+<tr class="hilite"><td>$[INT]p</td><td>$p, $25p</td><td>Use a random Post syllable.</td></tr>
224
+<tr><td>$[INT]v</td><td>$v, $25v</td><td>Use a random vocal.</td></tr>
225
+<tr class="hilite"><td>$[INT]c</td><td>$c, $25c</td><td>Use a random consonant.</td></tr>
226
+<tr><td>$[INT]?</td><td>$?, $25?</td><td>Use a random phoneme (vocal or consonant).</td></tr>
227
+
228
+<tr class="hilite"><td>%INT</td><td>%50, %25</td><td>Frequency marker. Denotes the per cent chance for the rule to be accepted if it's picked.<br>If the rule is not accepted, another roll is made to choose a name generation rule.<br>It's used to reduce the frequency a given rule is chosen with.<br>This marker may only appear at the beginning of a rule.</td></tr>
229
+</tbody></table>
230
+		*/
231
+
232
+		/**
233
+		@PageName namegen_file_4
234
+		@PageFather namegen_file
235
+		@PageTitle Example structure
236
+		@PageDesc Consider this example structure. It does not contain syllables, but rather full names.
237
+<div class="code"><p>name "king" {
238
+  syllablesStart = "Alexander, Augustus, Casimir, Henry, John, Louis, Sigismund,"
239
+    "Stanislao, Stephen, Wenceslaus"
240
+  syllablesMiddle = "I, II, III, IV, V"
241
+  syllablesEnd = "Bathory, Herman, Jogaila, Lambert, of_Bohemia, of_France,"
242
+    "of_Hungary, of_Masovia, of_Poland, of_Valois, of_Varna, Probus,"
243
+    "Spindleshanks, Tanglefoot, the_Bearded, the_Black, the_Bold, the_Brave,"
244
+    "the_Chaste, the_Curly, the_Elbow-high, the_Exile, the_Great,"
245
+    "the_Jagiellonian, the_Just, the_Old, the_Pious, the_Restorer, the_Saxon,"
246
+    "the_Strong, the_Wheelwright, the_White, Vasa, Wrymouth"
247
+  rules = "%50$s, $s_$m, $s_$50m_$e"
248
+}</p></div>
249
+
250
+The above structure only uses three syllable lists and has three different rules. Let's analyse them one by one.
251
+
252
+%50$s - this will simply output a random Start syllable, but this rule is not intended to be picked with the same frequency as the others, so the frequency marker at the beginning ("%50") ensures that 50% of the time this syllable will be rejected and a different one will be picked.
253
+
254
+$s_$m - this will output a Start syllable and a Middle syllable, separated with a space.
255
+
256
+$s_$50m_$e - This will output a Start syllable, followed by a Middle syllable, followed by an End sylable, all separated with spaces. However, the Middle syllable has only 50% chance of appearing at all, so 50% of the time the rule will actually produce a Start syllable followed directly by an End syllable, separated with a space.
257
+
258
+As you may have noticed, the third rule may produce a double space if the Middle syllable is not chosen. You do not have to worry about such cases, as the generator will automatically reduce all double spaces to single spaces, and leading/ending spaces will be removed completely.
259
+
260
+Output from this example set would contain kings' names based on the names of real monarchs of Poland. Have a look at the sample:
261
+<div class="code"><p>Alexander IV
262
+Alexander
263
+Sigismund
264
+Stanislao V
265
+Stanislao
266
+Henry I of Poland
267
+Augustus V
268
+Stanislao I the Pious
269
+Sigismund IV the Brave
270
+John the Great
271
+Henry the Old
272
+John the Bold
273
+Stanislao II the Saxon
274
+Wenceslaus of France
275
+John Probus
276
+Louis V
277
+Wenceslaus Lambert
278
+Stanislao Spindleshanks
279
+Henry Herman
280
+Alexander the Old
281
+Louis V the Curly
282
+Wenceslaus II
283
+Augustus IV
284
+Alexander V
285
+Augustus Probus
286
+</p></div>
287
+		*/
288
+};
289
+
290
+#endif
0 291
new file mode 100644
... ...
@@ -0,0 +1,56 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_PERLIN_H
29
+#define _TCOD_PERLIN_H
30
+
31
+typedef void *TCOD_noise_t;
32
+
33
+typedef enum {
34
+	TCOD_NOISE_PERLIN = 1,
35
+	TCOD_NOISE_SIMPLEX = 2,
36
+	TCOD_NOISE_WAVELET = 4,
37
+	TCOD_NOISE_DEFAULT = 0
38
+} TCOD_noise_type_t;
39
+
40
+#include "noise_defaults.h"
41
+
42
+/* create a new noise object */
43
+TCODLIB_API TCOD_noise_t TCOD_noise_new(int dimensions, float hurst, float lacunarity, TCOD_random_t random);
44
+
45
+/* simplified API */
46
+TCODLIB_API void TCOD_noise_set_type (TCOD_noise_t noise, TCOD_noise_type_t type);
47
+TCODLIB_API float TCOD_noise_get_ex (TCOD_noise_t noise, float *f, TCOD_noise_type_t type);
48
+TCODLIB_API float TCOD_noise_get_fbm_ex (TCOD_noise_t noise, float *f, float octaves, TCOD_noise_type_t type);
49
+TCODLIB_API float TCOD_noise_get_turbulence_ex (TCOD_noise_t noise, float *f, float octaves, TCOD_noise_type_t type);
50
+TCODLIB_API float TCOD_noise_get (TCOD_noise_t noise, float *f);
51
+TCODLIB_API float TCOD_noise_get_fbm (TCOD_noise_t noise, float *f, float octaves);
52
+TCODLIB_API float TCOD_noise_get_turbulence (TCOD_noise_t noise, float *f, float octaves);
53
+/* delete the noise object */
54
+TCODLIB_API void TCOD_noise_delete(TCOD_noise_t noise);
55
+
56
+#endif
0 57
new file mode 100644
... ...
@@ -0,0 +1,323 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_PERLIN_HPP
29
+#define _TCOD_PERLIN_HPP
30
+
31
+#include "noise_defaults.h"
32
+
33
+/**
34
+ @PageName noise
35
+ @PageCategory Base toolkits
36
+ @PageTitle Noise generator
37
+ @PageDesc This toolkit provides several functions to generate Perlin noise and other derived noises. It can handle noise functions from 1 to 4 dimensions.
38
+ @FuncDesc
39
+	Usage example:
40
+	1D noise : the variation of a torch intensity
41
+	2D fbm : heightfield generation or clouds
42
+	3D fbm : animated smoke
43
+	If you don't know what is Perlin noise and derived functions, or what is the influence of the different fractal parameters, check the Perlin noise sample included with the library.
44
+	<table width="800px" class="none">
45
+		<tr><td align="center">Simplex noise, fbm, turbulence</td>
46
+		<td align="center"><img border="1" src="simplex.png"></td>
47
+		<td align="center"><img border="1" src="fbm_simplex.png"></td>
48
+		<td align="center"><img border="1" src="turbulence_simplex.png"></td></tr>
49
+		<tr><td align="center">Perlin noise, fbm, turbulence</td>
50
+		<td align="center"><img border="1" src="perlin.png"></td>
51
+		<td align="center"><img border="1" src="fbm_perlin.png"></td>
52
+		<td align="center"><img border="1" src="turbulence_perlin.png"></td></tr>
53
+		<tr><td align="center">Wavelet noise, fbm, turbulence</td>
54
+		<td align="center"><img border="1" src="wavelet.png"></td>
55
+		<td align="center"><img border="1" src="fbm_wavelet.png"></td>
56
+		<td align="center"><img border="1" src="turbulence_wavelet.png"></td></tr>
57
+	</table>
58
+	<h6>Noise functions relative times</h6>
59
+
60
+	For example, in 4D, Perlin noise is 17 times slower than simplex noise.
61
+	<table border="1">
62
+		<tr><td></td><td>1D</td><td>2D</td><td>3D</td><td>4D</td></tr>
63
+		<tr><td>simplex</td><td>1</td><td>1</td><td>1</td><td>1</td></tr>
64
+		<tr><td>Perlin</td><td>1.3</td><td>4</td><td>5</td><td>17</td></tr>
65
+		<tr><td>wavelet</td><td>53</td><td>32</td><td>14</td><td>X</td></tr>
66
+	</table>
67
+ */
68
+class TCODLIB_API TCODNoise {
69
+	public :
70
+		/**
71
+		@PageName noise_init
72
+		@PageFather noise
73
+		@PageTitle Creating a noise generator
74
+		@FuncDesc Those functions initialize a noise generator from a number of dimensions (from 1 to 4), some fractal parameters and a random number generator.
75
+			The C++ version provides several constructors. When the hurst and lacunarity parameters are omitted, default values (TCOD_NOISE_DEFAULT_HURST = 0.5f and TCOD_NOISE_DEFAULT_LACUNARITY = 2.0f) are used.
76
+		@Cpp
77
+			TCODNoise::TCODNoise(int dimensions, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT)
78
+			TCODNoise::TCODNoise(int dimensions, TCODRandom *random, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT)
79
+			TCODNoise::TCODNoise(int dimensions, float hurst, float lacunarity, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT)
80
+			TCODNoise::TCODNoise(int dimensions, float hurst, float lacunarity, TCODRandom *random, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT)
81
+		@C TCOD_noise_t TCOD_noise_new(int dimensions, float hurst, float lacunarity, TCOD_random_t random)
82
+		@Py noise_new(dimensions, hurst=TCOD_NOISE_DEFAULT_HURST, lacunarity=TCOD_NOISE_DEFAULT_LACUNARITY, random=0)
83
+		@C#
84
+			TCODNoise::TCODNoise(int dimensions)
85
+			TCODNoise::TCODNoise(int dimensions, TCODRandom random)
86
+			TCODNoise::TCODNoise(int dimensions, float hurst, float lacunarity)
87
+			TCODNoise::TCODNoise(int dimensions, float hurst, float lacunarity, TCODRandom random)
88
+		@Param dimensions	From 1 to 4.
89
+		@Param hurst	For fractional brownian motion and turbulence, the fractal Hurst exponent. You can use the default value TCOD_NOISE_DEFAULT_HURST = 0.5f.
90
+		@Param lacunarity	For fractional brownian motion and turbulence, the fractal lacunarity. You can use the default value TCOD_NOISE_DEFAULT_LACUNARITY = 2.0f.
91
+		@Param random	A random number generator obtained with the Mersenne twister toolkit or NULL to use the default random number generator.
92
+		@CppEx
93
+			// 1 dimension generator
94
+			TCODNoise * noise1d = new TCODNoise(1);
95
+			// 2D noise with a predefined random number generator
96
+			TCODRandom *myRandom = new TCODRandom();
97
+			TCODNoise *noise2d = new TCODNoise(2,myRandom);
98
+			// a 3D noise generator with a specific fractal parameters
99
+			TCODNoise *noise3d = new TCODNoise(3,0.7f,1.4f);
100
+		@CEx
101
+			// 1 dimension generator
102
+			TCOD_noise_t noise1d = TCOD_noise_new(1,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
103
+			// 2D noise with a predefined random number generator
104
+			TCOD_random_t my_random = TCOD_random_new();
105
+			TCOD_noise_t noise2d = TCOD_noise_new(2,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,my_random);
106
+			// a 3D noise generator with a specific fractal parameters
107
+			TCOD_noise_t noise3d = TCOD_noise_new(3,0.7f, 1.4f,NULL);
108
+		@PyEx
109
+			# 1 dimension generator
110
+			noise1d = libtcod.noise_new(1)
111
+			# 2D noise with a predefined random number generator
112
+			my_random = libtcod.random_new();
113
+			noise2d = libtcod.noise_new(2,libtcod.NOISE_DEFAULT_HURST, libtcod.NOISE_DEFAULT_LACUNARITY,my_random)
114
+			# a 3D noise generator with a specific fractal parameters
115
+			noise3d = libtcod.noise_new(3, 0.7, 1.4)
116
+		*/
117
+		TCODNoise(int dimensions, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT);
118
+		TCODNoise(int dimensions, TCODRandom *random, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT);
119
+		TCODNoise(int dimensions, float hurst, float lacunarity, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT);
120
+		TCODNoise(int dimensions, float hurst, float lacunarity, TCODRandom *random, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT);
121
+
122
+		/**
123
+		@PageName noise_init
124
+		@FuncDesc To release ressources used by a generator, use those functions :
125
+		@Cpp TCODNoise::~TCODNoise()
126
+		@C void TCOD_noise_delete(TCOD_noise_t noise)
127
+		@Py noise_delete(noise)
128
+		@C# void TCODNoise::Dispose()
129
+		@Param noise	In the C and python versions, the generator handler, returned by the initialization function.
130
+		@CppEx
131
+			// create a generator
132
+			TCODNoise *noise = new TCODNoise(2);
133
+			// use it
134
+			...
135
+			// destroy it
136
+			delete noise;
137
+		@CEx
138
+			// create a generator
139
+			TCOD_noise_t noise = TCOD_noise_new(2,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAUT_LACUNARITY, NULL);
140
+			// use it
141
+			...
142
+			// destroy it
143
+			TCOD_noise_delete(noise);
144
+		@PyEx
145
+			# create a generator
146
+			noise = libtcod.noise_new(2,litbcod.NOISE_DEFAULT_HURST, litbcod.NOISE_DEFAUT_LACUNARITY, 0)
147
+			# use it
148
+			...
149
+			# destroy it
150
+			litbcod.noise_delete(noise)
151
+		*/
152
+		virtual ~TCODNoise();
153
+
154
+   		/**
155
+   		@PageName noise_setType
156
+		@PageFather noise
157
+		@PageTitle Choosing a noise type
158
+		@FuncTitle Choosing a noise type
159
+		@FuncDesc Use this function to define the default algorithm used by the noise functions. 
160
+			The default algorithm is simplex. It's much faster than Perlin, especially in 4 dimensions. It has a better contrast too.
161
+		@Cpp void TCODNoise::setType(TCOD_noise_type_t type)
162
+		@C void TCOD_noise_set_type(TCOD_noise_t noise, TCOD_noise_type_t type)
163
+		@Py noise_set_type(noise, type)
164
+		@C# void TCODNoise::setType(type)
165
+		@Param noise	In the C version, the generator handler, returned by the initialization function.
166
+		@Param type		The algorithm to use, either TCOD_NOISE_SIMPLEX, TCOD_NOISE_PERLIN or TCOD_NOISE_WAVELET.
167
+		@CppEx
168
+			TCODNoise * noise1d = new TCODNoise(1);
169
+			noise1d->setType(TCOD_NOISE_PERLIN);
170
+		@CEx
171
+			TCOD_noise_t noise1d = TCOD_noise_new(1,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
172
+			TCOD_noise_set_type(noise1d,TCOD_NOISE_PERLIN);
173
+		@PyEx
174
+			noise1d = libtcod.noise_new(1)
175
+			libtcod.noise_set_type(noise1d,libtcod.NOISE_PERLIN)
176
+   		*/
177
+		void setType (TCOD_noise_type_t type);
178
+   		/**
179
+   		@PageName noise_get
180
+		@PageFather noise
181
+		@PageTitle Getting flat noise
182
+		@FuncDesc This function returns the noise function value between -1.0 and 1.0 at given coordinates.
183
+		@Cpp float TCODNoise::get(float *f, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT)
184
+		@C	float TCOD_noise_get(TCOD_noise_t noise, float *f)
185
+float TCOD_noise_get_ex(TCOD_noise_t noise, float *f, TCOD_noise_type_t type)
186
+		@Py noise_get(noise, f, type=NOISE_DEFAULT)
187
+		@C# float TCODNoise::get(float[] f, type=NoiseDefault)
188
+		@Param noise	In the C version, the generator handler, returned by the initialization function.
189
+		@Param f	An array of coordinates, depending on the generator dimensions (between 1 and 4). The same array of coordinates will always return the same value.
190
+		@Param type	The algorithm to use. If not defined, use the default one (set with setType or simplex if not set) 
191
+		@CppEx
192
+			// 1d noise
193
+			TCODNoise * noise1d = new TCODNoise(1);
194
+			float p=0.5f;
195
+			// get a 1d simplex value
196
+			float value = noise1d->get(&p);
197
+			// 2d noise
198
+			TCODNoise * noise2d = new TCODNoise(2);
199
+			float p[2]={0.5f,0.7f};
200
+			// get a 2D Perlin value
201
+			float value = noise2d->get(p, TCOD_NOISE_PERLIN);
202
+		@CEx
203
+			// 1d noise
204
+			TCOD_noise_t noise1d = TCOD_noise_new(1,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
205
+			float p=0.5f;
206
+			// get a 1d simplex value
207
+			float value = TCOD_noise_get(noise1d,&p);
208
+			// 2d noise
209
+			TCOD_noise_t noise2d = TCOD_noise_new(2,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
210
+			float p[2]={0.5f,0.7f};
211
+			// get a 2d perlin value
212
+			float value = TCOD_noise_get_ex(noise2d,p,TCOD_NOISE_PERLIN);
213
+		@PyEx
214
+			# 1d noise
215
+			noise1d = libtcod.noise_new(1)
216
+			# get a 1d simplex value
217
+			value = libtcod.noise_get(noise1d,[0.5])
218
+			# 2d noise
219
+			noise2d = libtcod.noise_new(2)
220
+			# get a 2d perlin value
221
+			value = libtcod.noise_get(noise2d,[0.5,0.7], libtcod.NOISE_PERLIN)
222
+   		*/
223
+		float get(float *f, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT);
224
+		/**
225
+		@PageName noise_get_fbm
226
+		@PageFather noise
227
+		@PageTitle Getting fbm noise
228
+		@FuncDesc This function returns the fbm function value between -1.0 and 1.0 at given coordinates, using fractal hurst and lacunarity defined when the generator has been created.
229
+		@Cpp float TCODNoise::getFbm(float *f, float octaves, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT)
230
+		@C	float TCOD_noise_get_fbm(TCOD_noise_t noise, float *f, float octaves)
231
+float TCOD_noise_get_fbm(TCOD_noise_t noise, float *f, float octaves, TCOD_noise_type_t type)
232
+		@Py noise_get_fbm(noise, f, octaves, type=NOISE_DEFAULT)
233
+		@C# float TCODNoise::getBrownianMotion(float[] f, float octaves, type=NoiseDefault)
234
+		@Param noise	In the C version, the generator handler, returned by the initialization function.
235
+		@Param f	An array of coordinates, depending on the generator dimensions (between 1 and 4). The same array of coordinates will always return the same value.
236
+		@Param octaves	Number of iterations. Must be < TCOD_NOISE_MAX_OCTAVES = 128
237
+		@Param type	The algorithm to use. If not defined, use the default one (set with setType or simplex if not set) 
238
+		@CppEx
239
+			// 1d fbm
240
+			TCODNoise * noise1d = new TCODNoise(1);
241
+			float p=0.5f;
242
+			// get a 1d simplex fbm
243
+			float value = noise1d->getFbm(&p,32.0f);
244
+			// 2d fbm
245
+			TCODNoise * noise2d = new TCODNoise(2);
246
+			float p[2]={0.5f,0.7f};
247
+			// get a 2d perlin fbm
248
+			float value = noise2d->getFbm(p,32.0f, TCOD_NOISE_PERLIN);
249
+		@CEx
250
+			// 1d fbm
251
+			TCOD_noise_t noise1d = TCOD_noise_new(1,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
252
+			float p=0.5f;
253
+			// get a 1d simplex fbm
254
+			float value = TCOD_noise_get_fbm(noise1d,&p,32.0f);
255
+			// 2d fbm
256
+			TCOD_noise_t noise2d = TCOD_noise_new(2,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
257
+			float p[2]={0.5f,0.7f};
258
+			// get a 2d perlin fbm
259
+			float value = TCOD_noise_get_fbm_ex(noise2d,p,32.0f,TCOD_NOISE_PERLIN);
260
+		@PyEx
261
+			# 1d noise
262
+			noise1d = libtcod.noise_new(1)
263
+			# 1d simplex fbm
264
+			value = libtcod.noise_get_fbm(noise1d,[0.5],32.0)
265
+			# 2d noise
266
+			noise2d = libtcod.noise_new(2)
267
+			# 2d perlin fbm
268
+			value = libtcod.noise_get_fbm(noise2d,[0.5,0.7],32.0, libtcod.NOISE_PERLIN)
269
+		*/
270
+		float getFbm(float *f, float octaves, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT);
271
+		/**
272
+		@PageName noise_get_turbulence
273
+		@PageFather noise
274
+		@PageTitle Getting turbulence
275
+		@FuncDesc This function returns the turbulence function value between -1.0 and 1.0 at given coordinates, using fractal hurst and lacunarity defined when the generator has been created.
276
+		@Cpp float TCODNoise::getTurbulence(float *f, float octaves, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT)
277
+		@C	float TCOD_noise_get_turbulence(TCOD_noise_t noise, float *f, float octaves)
278
+float TCOD_noise_get_turbulence_ex(TCOD_noise_t noise, float *f, float octaves, TCOD_noise_type_t)
279
+		@Py noise_get_turbulence(noise, f, octaves, type=NOISE_DEFAULT)
280
+		@C# float TCODNoise::getTurbulence(float[] f, float octaves, type=NoiseDefault)
281
+		@Param noise	In the C version, the generator handler, returned by the initialization function.
282
+		@Param f	An array of coordinates, depending on the generator dimensions (between 1 and 4). The same array of coordinates will always return the same value.
283
+		@Param octaves	Number of iterations. Must be < TCOD_NOISE_MAX_OCTAVES = 128
284
+		@CppEx
285
+			// 1d fbm
286
+			TCODNoise * noise1d = new TCODNoise(1);
287
+			float p=0.5f;
288
+			// a 1d simplex turbulence
289
+			float value = noise1d->getTurbulence(&p,32.0f);
290
+			// 2d fbm
291
+			TCODNoise * noise2d = new TCODNoise(2);
292
+			float p[2]={0.5f,0.7f};
293
+			// a 2d perlin turbulence
294
+			float value = noise2d->getTurbulence(p,32.0f, TCOD_NOISE_PERLIN);
295
+		@CEx
296
+			// 1d fbm
297
+			TCOD_noise_t noise1d = TCOD_noise_new(1,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
298
+			float p=0.5f;
299
+			// a 1d simplex turbulence
300
+			float value = TCOD_noise_get_turbulence(noise1d,&p,32.0f);
301
+			// 2d fbm
302
+			TCOD_noise_t noise2d = TCOD_noise_new(2,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
303
+			float p[2]={0.5f,0.7f};
304
+			// a 2d perlin turbulence
305
+			float value = TCOD_noise_get_turbulence_ex(noise2d,p,32.0f, TCOD_NOISE_PERLIN);
306
+		@PyEx
307
+			# 1d noise
308
+			noise1d = libtcod.noise_new(1)
309
+			# 1d simplex turbulence
310
+			value = libtcod.noise_get_turbulence(noise1d,[0.5],32.0)
311
+			# 2d noise
312
+			noise2d = libtcod.noise_new(2)
313
+			# 2d perlin turbulence
314
+			value = libtcod.noise_get_turbulence(noise2d,[0.5,0.7],32.0,libtcod.NOISE_PERLIN)
315
+		*/
316
+		float getTurbulence(float *f, float octaves, TCOD_noise_type_t type = TCOD_NOISE_DEFAULT);
317
+
318
+	protected :
319
+		friend class TCODLIB_API TCODHeightMap;
320
+		TCOD_noise_t data;
321
+};
322
+
323
+#endif
0 324
new file mode 100644
... ...
@@ -0,0 +1,9 @@
1
+#ifndef _TCOD_NOISE_DEFAULTS
2
+#define _TCOD_NOISE_DEFAULTS
3
+
4
+#define TCOD_NOISE_MAX_OCTAVES			128
5
+#define TCOD_NOISE_MAX_DIMENSIONS		4
6
+#define TCOD_NOISE_DEFAULT_HURST        0.5f
7
+#define TCOD_NOISE_DEFAULT_LACUNARITY   2.0f
8
+
9
+#endif /* _TCOD_NOISE_DEFAULTS */
0 10
new file mode 100644
... ...
@@ -0,0 +1,171 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_PARSER_H
29
+#define _TCOD_PARSER_H
30
+
31
+/* generic type */
32
+typedef enum {
33
+	TCOD_TYPE_NONE,
34
+	TCOD_TYPE_BOOL,
35
+	TCOD_TYPE_CHAR,
36
+	TCOD_TYPE_INT,
37
+	TCOD_TYPE_FLOAT,
38
+	TCOD_TYPE_STRING,
39
+	TCOD_TYPE_COLOR,
40
+	TCOD_TYPE_DICE,
41
+	TCOD_TYPE_VALUELIST00,
42
+	TCOD_TYPE_VALUELIST01,
43
+	TCOD_TYPE_VALUELIST02,
44
+	TCOD_TYPE_VALUELIST03,
45
+	TCOD_TYPE_VALUELIST04,
46
+	TCOD_TYPE_VALUELIST05,
47
+	TCOD_TYPE_VALUELIST06,
48
+	TCOD_TYPE_VALUELIST07,
49
+	TCOD_TYPE_VALUELIST08,
50
+	TCOD_TYPE_VALUELIST09,
51
+	TCOD_TYPE_VALUELIST10,
52
+	TCOD_TYPE_VALUELIST11,
53
+	TCOD_TYPE_VALUELIST12,
54
+	TCOD_TYPE_VALUELIST13,
55
+	TCOD_TYPE_VALUELIST14,
56
+	TCOD_TYPE_VALUELIST15,
57
+	TCOD_TYPE_CUSTOM00,
58
+	TCOD_TYPE_CUSTOM01,
59
+	TCOD_TYPE_CUSTOM02,
60
+	TCOD_TYPE_CUSTOM03,
61
+	TCOD_TYPE_CUSTOM04,
62
+	TCOD_TYPE_CUSTOM05,
63
+	TCOD_TYPE_CUSTOM06,
64
+	TCOD_TYPE_CUSTOM07,
65
+	TCOD_TYPE_CUSTOM08,
66
+	TCOD_TYPE_CUSTOM09,
67
+	TCOD_TYPE_CUSTOM10,
68
+	TCOD_TYPE_CUSTOM11,
69
+	TCOD_TYPE_CUSTOM12,
70
+	TCOD_TYPE_CUSTOM13,
71
+	TCOD_TYPE_CUSTOM14,
72
+	TCOD_TYPE_CUSTOM15,
73
+	TCOD_TYPE_LIST=1024
74
+} TCOD_value_type_t;
75
+
76
+/* generic value */
77
+typedef union {
78
+	bool b;
79
+	char c;
80
+	int32 i;
81
+	float f;
82
+	char *s;
83
+	TCOD_color_t col;
84
+	TCOD_dice_t dice;
85
+	TCOD_list_t list;
86
+	void *custom;
87
+} TCOD_value_t;
88
+
89
+/* parser structures */
90
+typedef void *TCOD_parser_struct_t;
91
+TCODLIB_API const char *TCOD_struct_get_name(TCOD_parser_struct_t def);
92
+TCODLIB_API void TCOD_struct_add_property(TCOD_parser_struct_t def, const char *name,TCOD_value_type_t type, bool mandatory);
93
+TCODLIB_API void TCOD_struct_add_list_property(TCOD_parser_struct_t def, const char *name,TCOD_value_type_t type, bool mandatory);
94
+TCODLIB_API void TCOD_struct_add_value_list(TCOD_parser_struct_t def,const char *name, const char **value_list, bool mandatory);
95
+TCODLIB_API void TCOD_struct_add_value_list_sized(TCOD_parser_struct_t def,const char *name, const char **value_list, int size, bool mandatory);
96
+TCODLIB_API void TCOD_struct_add_flag(TCOD_parser_struct_t def,const char *propname);
97
+TCODLIB_API void TCOD_struct_add_structure(TCOD_parser_struct_t def,TCOD_parser_struct_t sub_structure);
98
+TCODLIB_API bool TCOD_struct_is_mandatory(TCOD_parser_struct_t def,const char *propname);
99
+TCODLIB_API TCOD_value_type_t TCOD_struct_get_type(TCOD_parser_struct_t def, const char *propname);
100
+
101
+
102
+/* parser listener */
103
+typedef struct {
104
+	bool (*new_struct)(TCOD_parser_struct_t str,const char *name);
105
+	bool (*new_flag)(const char *name);
106
+	bool (*new_property)(const char *propname, TCOD_value_type_t type, TCOD_value_t value);
107
+	bool (*end_struct)(TCOD_parser_struct_t str, const char *name);
108
+	void (*error)(const char *msg);
109
+} TCOD_parser_listener_t;
110
+
111
+/* a custom type parser */
112
+typedef TCOD_value_t (*TCOD_parser_custom_t)(TCOD_lex_t *lex, TCOD_parser_listener_t *listener, TCOD_parser_struct_t str, char *propname);
113
+
114
+/* the parser */
115
+typedef void *TCOD_parser_t;
116
+
117
+TCODLIB_API TCOD_parser_t TCOD_parser_new();
118
+TCODLIB_API TCOD_parser_struct_t TCOD_parser_new_struct(TCOD_parser_t parser, char *name);
119
+TCODLIB_API TCOD_value_type_t TCOD_parser_new_custom_type(TCOD_parser_t parser,TCOD_parser_custom_t custom_type_parser);
120
+TCODLIB_API void TCOD_parser_run(TCOD_parser_t parser, const char *filename, TCOD_parser_listener_t *listener);
121
+TCODLIB_API void TCOD_parser_delete(TCOD_parser_t parser);
122
+/* error during parsing. can be called by the parser listener */
123
+TCODLIB_API void TCOD_parser_error(const char *msg, ...);
124
+/* default parser listener */
125
+TCODLIB_API bool TCOD_parser_has_property(TCOD_parser_t parser, const char *name);
126
+TCODLIB_API bool TCOD_parser_get_bool_property(TCOD_parser_t parser, const char *name);
127
+TCODLIB_API int TCOD_parser_get_char_property(TCOD_parser_t parser, const char *name);
128
+TCODLIB_API int TCOD_parser_get_int_property(TCOD_parser_t parser, const char *name);
129
+TCODLIB_API float TCOD_parser_get_float_property(TCOD_parser_t parser, const char *name);
130
+TCODLIB_API const char * TCOD_parser_get_string_property(TCOD_parser_t parser, const char *name);
131
+TCODLIB_API TCOD_color_t TCOD_parser_get_color_property(TCOD_parser_t parser, const char *name);
132
+TCODLIB_API TCOD_dice_t TCOD_parser_get_dice_property(TCOD_parser_t parser, const char *name);
133
+TCODLIB_API void TCOD_parser_get_dice_property_py(TCOD_parser_t parser, const char *name, TCOD_dice_t *dice);
134
+TCODLIB_API void * TCOD_parser_get_custom_property(TCOD_parser_t parser, const char *name);
135
+TCODLIB_API TCOD_list_t TCOD_parser_get_list_property(TCOD_parser_t parser, const char *name, TCOD_value_type_t type);
136
+
137
+/* parser internals (may be used by custom type parsers) */
138
+/* parser structures */
139
+typedef struct {
140
+	char *name; /* entity type name */
141
+	/* list of flags */
142
+	TCOD_list_t flags;
143
+	/* list of properties (name, type, mandatory) */
144
+	TCOD_list_t props;
145
+	/* list of value lists */
146
+	TCOD_list_t lists;
147
+	/* list of sub-structures */
148
+	TCOD_list_t structs;
149
+} TCOD_struct_int_t;
150
+/* the parser */
151
+typedef struct {
152
+	/* list of structures */
153
+	TCOD_list_t structs;
154
+	/* list of custom type parsers */
155
+	TCOD_parser_custom_t customs[16];
156
+	/* fatal error occured */
157
+	bool fatal;
158
+	/* list of properties if default listener is used */
159
+	TCOD_list_t props;
160
+} TCOD_parser_int_t;
161
+TCODLIB_API TCOD_value_t TCOD_parse_bool_value();
162
+TCODLIB_API TCOD_value_t TCOD_parse_char_value();
163
+TCODLIB_API TCOD_value_t TCOD_parse_integer_value();
164
+TCODLIB_API TCOD_value_t TCOD_parse_float_value();
165
+TCODLIB_API TCOD_value_t TCOD_parse_string_value();
166
+TCODLIB_API TCOD_value_t TCOD_parse_color_value();
167
+TCODLIB_API TCOD_value_t TCOD_parse_dice_value();
168
+TCODLIB_API TCOD_value_t TCOD_parse_value_list_value(TCOD_struct_int_t *def,int listnum);
169
+TCODLIB_API TCOD_value_t TCOD_parse_property_value(TCOD_parser_int_t *parser, TCOD_parser_struct_t def, char *propname, bool list);
170
+
171
+#endif
0 172
new file mode 100644
... ...
@@ -0,0 +1,672 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_PARSER_HPP
29
+#define _TCOD_PARSER_HPP
30
+
31
+/**
32
+@PageName parser
33
+@PageTitle File parser
34
+@PageCategory Base toolkits
35
+@PageDesc This toolkit provides an easy way to parse complex text configuration files. It has two main advantages compared to a standard XML SAX parser:
36
+	* The configuration file format is more human readable than XML
37
+	* The parser knows some data types that it automatically converts to C variables (see <a href="parser_types.html">Standard data types</a>)
38
+*/
39
+
40
+/**
41
+@PageName parser_format
42
+@PageFather parser
43
+@PageTitle The libtcod config file format
44
+@FuncTitle Comments
45
+@FuncDesc Your file can contain single line or multi-line comments :
46
+<div class="code"><pre>// This is a single line comment
47
+/<span>*</span>
48
+   This is a
49
+   multi-line comment
50
+*<span>/</span>
51
+</pre></div>
52
+Multi-line comments can be nested :
53
+<div class="code"><pre>/<span>*</span>
54
+   This is a
55
+   multi-line comment containing another
56
+   /<span>*</span>
57
+&nbsp;&nbsp;&nbsp;&nbsp;multi-line
58
+&nbsp;&nbsp;&nbsp;&nbsp;comment
59
+   *<span>/</span>
60
+*<span>/</span>
61
+</pre></div>
62
+The parser is not sensible to space characters, tabulations or carriage return except inside strings.
63
+*/
64
+/**
65
+@PageName parser_format
66
+@FuncTitle Structures
67
+@FuncDesc The libtcod config file format is basically a list of structures. A structure has a type, an optional name and contains properties. The type of the structure defines which properties are allowed / mandatory.
68
+<div class="code"><pre>item_type "blade" {            // structure's type : 'item_type'. structure's name : 'blade'
69
+	cost=300                   // an integer property
70
+	weight=3.5                 // a float property
71
+	deal_damage=true           // a boolean property
72
+	damages="3d6+2"            // a dice property
73
+	col="#FF0000"              // a color property, using #RRGGBB syntax
74
+	damaged_color="128,96,96"  // another color property, using rrr,ggg,bbb syntax
75
+	damage_type="slash"        // a string property
76
+	description="This is a long"
77
+	            "description." // a multi-line string property
78
+	abstract                   // a flag (simplified boolean property)
79
+        intList= [ 1,2,3 ]         // a list of int values
80
+        floatList= [ 1.0,2,3.5 ]   // a list of float values
81
+        stringList= [ "string1","string2","string3" ]         // a list of string values
82
+}
83
+</pre></div>
84
+A structure can also contain other structures either of the same type, or structures of another type :
85
+<div class="code"><pre>item_type "blade" {
86
+	item_type "one-handed blades" {
87
+		// the item_type "blade" contains another item_type named "one-handed blades"
88
+	}
89
+	item_type "two-handed blades" {
90
+		// the item_type "blade" contains another item_type named "two-handed blades"
91
+	}
92
+	feature "damage" {
93
+		// the item_type "blade" contains another structure, type "feature", name "damage"
94
+	}
95
+}
96
+</pre></div>
97
+Sometimes, you don't know the list of properties at compile-time. Fortunately, since libtcod 1.5.1, you can add auto-declaring properties in the file, using one of the type keywords :
98
+<div class="code"><pre>item_type "blade" {
99
+	bool deal_damage=true
100
+	char character='D'
101
+	int cost=300
102
+	float weight=3.5
103
+	string damage_type="slash"
104
+	color col="#FF0000"
105
+	dice damages="3d6+2"
106
+	int[] intList= [ 1,2,3 ]
107
+	float[] floatList= [ 1.0,2,3.5 ]
108
+	string[] stringList= [ "string1","string2","string3" ]
109
+}
110
+</pre></div>
111
+The properties declared with this syntax were not previously declared for the structure item_type. But since the type is specified, the parser won't reject them. Instead, it will add the property declaration to the structure dynamically (when it parses the file).
112
+You can also dynamically create new structures and sub-structures with the struct keyword :
113
+<div class="code"><pre>item_type "blade" {
114
+    struct component {
115
+	    string name="blade"
116
+		float weight=1.0
117
+	}
118
+}
119
+</div>
120
+With this syntax, you don't need to declare the "component" structure at all in the parser. It will be dynamically registered as the file is parsed.
121
+*/
122
+
123
+class TCODLIB_API TCODParser;
124
+class TCODLIB_API TCODParserStruct;
125
+class TCODLIB_API ITCODParserListener;
126
+
127
+class TCODLIB_API TCODParser {
128
+public :
129
+	/**
130
+	@PageName parser_str
131
+	@PageTitle Defining the file syntax
132
+	@PageFather parser
133
+	@FuncTitle Creating a parser
134
+	@FuncDesc Use this function to create a generic parser. Then you'll specialize this parser by defining the structures it can read.
135
+	@Cpp TCODParser::TCODParser()
136
+	@C TCOD_parser_t TCOD_parser_new()
137
+	@Py parser_new()
138
+	*/
139
+	TCODParser();
140
+
141
+	/**
142
+	@PageName parser_str
143
+	@FuncTitle Registering a new structure type
144
+	@Cpp TCODParserStruct *TCODParser::newStructure(const char *name)
145
+	@C TCOD_parser_struct_t TCOD_parser_new_struct(TCOD_parser_t parser, char *name)
146
+	@Py parser_new_struct(parser, name)
147
+	@Param parser	In the C version, the parser handler, returned by TCOD_parser_new.
148
+	@Param name	The name of the structure type (in the example, this would be "item_type").
149
+	@CppEx
150
+		TCODParser parser();
151
+		TCODParserStruct *itemTypeStruct = parser.newStructrue("item_type");
152
+	@CEx
153
+		TCOD_parser_t parser = TCOD_parser_new();
154
+		TCOD_parser_struct_t item_type_struct = TCOD_parser_new_struct(parser, "item_type");
155
+	@PyEx
156
+		parser=libtcod.parser_new()
157
+		item_type_struct = libtcod.parser_new_struct(parser, "item_type")
158
+	*/
159
+	TCODParserStruct *newStructure(const char *name);
160
+
161
+	// register a new custom type
162
+	TCOD_value_type_t newCustomType(TCOD_parser_custom_t custom_type_parser);
163
+
164
+	/**
165
+	@PageName parser_run
166
+	@PageFather parser
167
+	@PageTitle Running the parser
168
+	@FuncTitle Running the parser
169
+	@FuncDesc Once you defined all the structure types and created your listener, you can start the actual parsing of the file :
170
+	@Cpp void TCODParser::run(const char *filename, ITCODParserListener *listener = NULL)
171
+	@C void TCOD_parser_run(TCOD_parser_t parser, const char *filename, TCOD_parser_listener_t *listener)
172
+	@Py parser_run(parser, filename, listener=0)
173
+	@Param parser	In the C version, the parser handler, returned by TCOD_parser_new.
174
+	@Param filename	The name of the text file to parse, absolute or relative to current directory.
175
+	@Param listener	The listener containing the callbacks. Use NULL for the default listener
176
+	@Cpp myParser.run("config.txt",new MyListener());
177
+	@C TCOD_parser_run(my_parser,"config.txt", my_listener);
178
+	@Py libtcod.parser_run(my_parser,"config.txt", MyListener())
179
+	*/
180
+	void run(const char *filename, ITCODParserListener *listener = NULL);
181
+
182
+	/**
183
+	@PageName parser_run
184
+	@FuncTitle Destroying the parser
185
+	@FuncDesc Once you've done with the file parsing, you can release the resources used by the parser :
186
+	@Cpp TCODParser::~TCODParser()
187
+	@C void TCOD_parser_delete(TCOD_parser_t parser)
188
+	@Py parser_delete(parser)
189
+	@Param parser	In the C version, the parser handler, returned by TCOD_parser_new.
190
+	*/
191
+
192
+	// error during parsing. can be called by the parser listener
193
+	void error(const char *msg, ...);
194
+#ifdef TCOD_VISUAL_STUDIO
195
+    // silly stuff to avoid VS warning
196
+	#pragma warning(disable: 4251)
197
+#endif
198
+	TCODList<TCODParserStruct *> defs;
199
+#ifdef TCOD_VISUAL_STUDIO
200
+	// restore warning again
201
+	#pragma warning(default: 4251)
202
+#endif
203
+
204
+	bool hasProperty(const char *name) const;
205
+	bool getBoolProperty(const char *name) const;
206
+	int getIntProperty(const char *name) const;
207
+	int getCharProperty(const char *name) const;
208
+	float getFloatProperty(const char *name) const;
209
+	TCODColor getColorProperty(const char *name) const;
210
+	TCOD_dice_t getDiceProperty(const char *name) const;
211
+	const char * getStringProperty(const char *name) const;
212
+	void * getCustomProperty(const char *name) const;
213
+	TCOD_list_t getListProperty(const char *name, TCOD_value_type_t type) const;
214
+private :
215
+	bool parseEntity(TCODParserStruct *def, ITCODParserListener *listener);
216
+	TCOD_parser_t data;
217
+};
218
+
219
+// a parser structure
220
+class TCODLIB_API TCODParserStruct {
221
+public :
222
+	/**
223
+	@PageName parser_str
224
+	@FuncTitle Adding a new flag
225
+	@FuncDesc Use this function to add a flag property to a structure type. A flag is a simplified boolean property. It cannot be mandatory: either it's present and it's true, or it's absent and it's false.<br />Note that in the C++ version, the function returns its parent object, allowing for chaining.
226
+	@Cpp TCODParserStruct* TCODParserStruct::addFlag(const char *name)
227
+	@C void TCOD_struct_add_flag(TCOD_parser_struct_t str,char *name)
228
+	@Py struct_add_flag(str,name)
229
+	@Param str	In the C version, the structure handler, returned by TCOD_parser_new_struct.
230
+	@Param name	The name of the flag (in the example, this would be "abstract").
231
+	@CppEx itemTypeStruct->addFlag("abstract")->addFlag("static");
232
+	@CEx TCOD_struct_add_flag(item_type_struct, "abstract");
233
+	@PyEx libtcod.struct_add_flag(item_type_struct, "abstract")
234
+	*/
235
+	TCODParserStruct* addFlag(const char *propname);
236
+
237
+	/**
238
+	@PageName parser_str
239
+	@FuncTitle Adding a new property
240
+	@FuncDesc Use this function to add a standard property to a structure type. Check standard property types here.<br />Note that in the C++ version, the function returns its parent object, allowing for chaining.
241
+	@Cpp TCODParserStruct* TCODParserStruct::addProperty(const char *name, TCOD_value_type_t type, bool mandatory)
242
+	@C void TCOD_struct_add_property(TCOD_parser_struct_t str, char *name, TCOD_value_type_t type, bool mandatory)
243
+	@Py struct_add_property(str, name, type, mandatory)
244
+	@Param str	In the C version, the structure handler, returned by TCOD_parser_new_struct.
245
+	@Param name	The name of the property (in the example, this would be "cost" or "damage" or ...).
246
+	@Param type	The type of the property. It can be a standard type (see <a href="parser_types.html">this</a>).
247
+	@Param mandatory	Is this property mandatory? If true and the property is not defined in the file, the parser will raise an error.
248
+	@CppEx
249
+		itemTypeStruct->addProperty("cost",TCOD_TYPE_INT,true)
250
+		    ->addProperty("weight",TCOD_TYPE_FLOAT,true)
251
+		    ->addProperty("deal_damage",TCOD_TYPE_BOOL,true)
252
+		    ->addProperty("damaged_color",TCOD_TYPE_COLOR,true);
253
+	@CEx
254
+		TCOD_struct_add_property(item_type_struct, "cost", TCOD_TYPE_INT, true);
255
+		TCOD_struct_add_property(item_type_struct, "damages", TCOD_TYPE_DICE, true);
256
+		TCOD_struct_add_property(item_type_struct, "color", TCOD_TYPE_COLOR, true);
257
+		TCOD_struct_add_property(item_type_struct, "damaged_color", TCOD_TYPE_COLOR, true);
258
+	@PyEx
259
+		libtcod.struct_add_property(item_type_struct, "cost", libtcod.TYPE_INT, True)
260
+		libtcod.struct_add_property(item_type_struct, "damages", libtcod.TYPE_DICE, True)
261
+		libtcod.struct_add_property(item_type_struct, "color", libtcod.TYPE_COLOR, True)
262
+		libtcod.struct_add_property(item_type_struct, "damaged_color", libtcod.TYPE_COLOR, True)
263
+	*/
264
+	TCODParserStruct* addProperty(const char *propname, TCOD_value_type_t type, bool mandatory);
265
+
266
+	/**
267
+	@PageName parser_str
268
+	@FuncTitle Adding a new value-list property
269
+	@FuncDesc A value-list property is a string property for which we define the list of allowed values. The parser will raise an error if the file contains an unauthorized value for this property.
270
+		The first value-list property that you add to a structure type will have the TCOD_TYPE_VALUELIST00 type. The next TCOD_TYPE_VALUELIST01. You can define up to 16 value list property for each structure type. The last one has the type TCOD_TYPE_VALUELIST15.
271
+		You must provide a value list as a NULL terminated array of strings.<br />Note that in the C++ version, the function returns its parent object, allowing for chaining.
272
+	@Cpp TCODParserStruct* TCODParserStruct::addValueList(const char *name, const char **value_list, bool mandatory)
273
+	@C void TCOD_struct_add_value_list(TCOD_parser_struct_t str, char *name, char **value_list, bool mandatory)
274
+	@Py struct_add_value_list(str, name, value_list, mandatory)
275
+	@Param str	In the C version, the structure handler, returned by TCOD_parser_new_struct.
276
+	@Param name	The name of the property (in the example, this would be "damage_type").
277
+	@Param value_list	The list of allowed strings.
278
+	@Param mandatory	Is this property mandatory ? If true and the property is not defined in the file, the parser will raise an error.
279
+	@CppEx
280
+		static const char *damageTypes[] = { "slash", "pierce", "bludgeon", NULL }; // note the ending NULL
281
+		itemTypeStruct->addValueList("damage_type", damageTypes, true);
282
+	@CEx
283
+		static const char *damage_types[] = { "slash", "pierce", "bludgeon", NULL };
284
+		TCOD_struct_add_value_list(item_type_struct, "damage_type", damage_types, true);
285
+	@PyEx
286
+		damage_types = [ "slash", "pierce", "bludgeon" ]
287
+		litbcod.struct_add_value_list(item_type_struct, "damage_type", damage_types, True)
288
+	*/
289
+	TCODParserStruct* addValueList(const char *propname, const char **value_list, bool mandatory);
290
+
291
+	/**
292
+	@PageName parser_str
293
+	@FuncTitle Adding a new list property
294
+	@FuncDesc Use this function to add a list property to a structure type.<br />Note that in the C++ version, the function returns its parent object, allowing for chaining.
295
+	@Cpp TCODParserStruct* TCODParserStruct::addListProperty(const char *name, TCOD_value_type_t type, bool mandatory)
296
+	@C void TCOD_struct_add_list_property(TCOD_parser_struct_t str, char *name, TCOD_value_type_t type, bool mandatory)
297
+	@Py struct_add_list_property(str, name, type, mandatory)
298
+	@Param str	In the C version, the structure handler, returned by TCOD_parser_new_struct.
299
+	@Param name	The name of the property (in the example, this would be "cost" or "damages" or ...).
300
+	@Param type	The type of the list elements. It must be a standard type (see <a href="parser_types.html">this</a>). It cannot be TCOD_TYPE_LIST.
301
+	@Param mandatory	Is this property mandatory ? If true and the property is not defined in the file, the parser will raise an error.
302
+	@CppEx
303
+		itemTypeStruct->addListProperty("intList",TCOD_TYPE_INT,true)
304
+		    ->addListProperty("floatList",TCOD_TYPE_FLOAT,true)
305
+		    ->addListProperty("stringList",TCOD_TYPE_STRING,true);
306
+	@CEx
307
+		TCOD_struct_add_list_property(item_type_struct, "intList", TCOD_TYPE_INT, true);
308
+		TCOD_struct_add_list_property(item_type_struct, "floatList", TCOD_TYPE_FLOAT, true);
309
+		TCOD_struct_add_list_property(item_type_struct, "stringList", TCOD_TYPE_STRING, true);
310
+	@PyEx
311
+		libtcod.struct_add_list_property(item_type_struct, "intList", libtcod.TYPE_INT, True)
312
+		libtcod.struct_add_list_property(item_type_struct, "floatList", libtcod.TYPE_FLOAT, True)
313
+		libtcod.struct_add_list_property(item_type_struct, "stringList", libtcod.TYPE_STRING, True)
314
+	*/
315
+	TCODParserStruct* addListProperty(const char *propname, TCOD_value_type_t type, bool mandatory);
316
+
317
+	/**
318
+	@PageName parser_str
319
+	@FuncTitle Adding a sub-structure
320
+	@FuncDesc A structure can contain others structures. You can tell the parser which structures are allowed inside one structure type with this function.<br />Note that in the C++ version, the function returns its parent object, allowing for chaining.
321
+	@Cpp TCODParserStruct* TCODParserStruct::addStructure(TCODParserStruct *sub_structure)
322
+	@C void TCOD_struct_add_structure(TCOD_parser_struct_t str, TCOD_parser_struct_t sub_structure)
323
+	@Py struct_add_structure(str, sub_structure)
324
+	@Param str	In the C version, the structure handler, returned by TCOD_parser_new_struct.
325
+	@Param sub_structure	The structure type that can be embedded.
326
+	@CppEx
327
+		// The item_type structure can contain itself
328
+		itemTypeStruct->addStructure(itemTypeStruct);
329
+	@CEx TCOD_struct_add_value_list(item_type_struct, item_type_struct);
330
+	@PyEx libtcod.struct_add_value_list(item_type_struct, item_type_struct)
331
+	*/
332
+	TCODParserStruct* addStructure(TCODParserStruct *sub_entity);
333
+
334
+	/**
335
+	@PageName parser_str
336
+	@FuncTitle Getting a structure type's name
337
+	@FuncDesc You can retrieve the name of the structure type with these functions. Warning ! Do not confuse the structure type's name with the structure's name :
338
+		<div class="code"><p>item_type "sword" { ... }</p></div>
339
+		Here, the structure type's name is "item_type", the structure name is "sword". Obviously, the structure name cannot be retrieved from the TCODParserStruct object because it's only known at "runtime" (while parsing the file).
340
+	@Cpp const char *TCODParserStruct::getName() const
341
+	@C const char *TCOD_struct_get_name(TCOD_parser_struct_t str)
342
+	@Py struct_get_name(str)
343
+	@Param str	In the C version, the structure handler, returned by TCOD_parser_new_struct.
344
+	@CppEx const char *structName = itemTypeStruct->getName(); // returns "item_type"
345
+	@CEx const char *struct_name = TCOD_struct_get_name(item_type_struct);
346
+	@PyEx struct_name = libtcod.struct_get_name(item_type_struct)
347
+	*/
348
+	const char *getName() const;
349
+
350
+	/**
351
+	@PageName parser_str
352
+	@FuncTitle Checking if a property is mandatory
353
+	@FuncDesc You can know if a property is mandatory :
354
+	@Cpp bool TCODParserStruct::isPropertyMandatory(const char *name) const
355
+	@C bool TCOD_struct_is_mandatory(TCOD_parser_struct_t str,const char *name)
356
+	@Py struct_is_mandatory(str,name)
357
+	@Param str	In the C version, the structure handler, returned by TCOD_parser_new_struct.
358
+	@Param name	The name of the property, as defined when you called addProperty or addValueList or addListProperty.
359
+	@CppEx bool costMandatory = itemTypeStruct->isPropertyMandatory("cost");
360
+	@CEx bool cost_mandatory = TCOD_struct_is_mandatory(item_type_struct, "cost");
361
+	@PyEx cost_mandatory = libtcod.struct_is_mandatory(item_type_struct, "cost")
362
+	*/
363
+	bool isPropertyMandatory(const char *propname) const;
364
+
365
+	/**
366
+	@PageName parser_str
367
+	@FuncTitle Retrieving the type of a property
368
+	@FuncDesc You get the type of a property :
369
+		In the case of a list property, the value returned is a bitwise or of TCOD_TYPE_LIST and the list element's type. For example, for a list of int, it will return TCOD_TYPE_LIST | TCOD_TYPE_INT.
370
+	@Cpp TCOD_value_type_t TCODParserStruct::getPropertyType(const char *name) const
371
+	@C TCOD_value_type_t TCOD_struct_get_type(TCOD_parser_struct_t str, const char *name)
372
+	@Py struct_get_type(str, name)
373
+	@Param str	In the C version, the structure handler, returned by TCOD_parser_new_struct.
374
+	@Param name	The name of the property, as defined when you called addProperty or addValueList or addListProperty.
375
+	@CppEx
376
+		TCOD_value_type_t costType = itemTypeStruct->getPropertyType("cost"); // returns TCOD_TYPE_INT
377
+		TCOD_value_type_t intListType = itemTypeStruct->getPropertyType("intList"); // returns TCOD_TYPE_LIST|TCOD_TYPE_INT
378
+	@CEx TCOD_value_type_t cost_type = TCOD_struct_get_type(item_type_struct, "cost");
379
+	@PyEx cost_type = libtcod.struct_get_type(item_type_struct, "cost")
380
+	*/
381
+	TCOD_value_type_t getPropertyType(const char *propname) const;
382
+
383
+// private stuff
384
+	TCOD_parser_struct_t data;
385
+};
386
+
387
+/**
388
+ @PageName parser_run
389
+ @FuncTitle Creating a listener
390
+ @FuncDesc For basic config files, you don't have to write a listener. Instead, use the default listener. The parser uses a SAX-like approach during the parsing of the file. This means that the whole file is not stored in memory in a tree structure. Instead, it works like a stream parser and raises events. Each event has an associated callback that is provided by a listener :
391
+ @Cpp
392
+	class ITCODParserListener {
393
+	public :
394
+		virtual bool parserNewStruct(TCODParser *parser,const TCODParserStruct *str,const char *name)=0;
395
+		virtual bool parserFlag(TCODParser *parser,const char *name)=0;
396
+		virtual bool parserProperty(TCODParser *parser,const char *name, TCOD_value_type_t type, TCOD_value_t value)=0;
397
+		virtual bool parserEndStruct(TCODParser *parser,const TCODParserStruct *str, const char *name)=0;
398
+		virtual void error(const char *msg) = 0;
399
+	};
400
+ @C
401
+	typedef struct {
402
+		bool (*new_struct)(TCOD_parser_struct_t str,const char *name);
403
+		bool (*new_flag)(const char *name);
404
+		bool (*new_property)(const char *name, TCOD_value_type_t type, TCOD_value_t value);
405
+		bool (*end_struct)(TCOD_parser_struct_t str, const char *name);
406
+		void (*error)(const char *msg);
407
+	} TCOD_parser_listener_t;
408
+ @Py
409
+	class ParserListener :
410
+		def new_struct(str,name) : ...
411
+		def new_flag(name) : ...
412
+		def new_property(name,type,value) : ...
413
+		def end_struct(self, struct, name) : ...
414
+		def error(msg) : ...
415
+*/
416
+/**
417
+ @PageName parser_run
418
+ @FuncDesc Before running the parser, you have to build a listener :
419
+ @Cpp
420
+	class MyListener : public ITCODParserListener {
421
+		bool parserNewStruct(TCODParser *parser,const TCODParserStruct *str,const char *name) {
422
+			printf ("new structure type '%s' with name '%s'\n",str->getname(),name ? name : "NULL");
423
+			return true;
424
+		}
425
+		bool parserFlag(TCODParser *parser,const char *name) {
426
+			printf ("found new flag '%s'\n",name);
427
+			return true;
428
+		}
429
+		bool parserProperty(TCODParser *parser,const char *name, TCOD_value_type_t type, TCOD_value_t value) {
430
+			printf ("found new property '%s'\n",name);
431
+			return true;
432
+		}
433
+		bool parserEndStruct(TCODParser *parser,const TCODParserStruct *str,const char *name) {
434
+			printf ("end of structure type '%s'\n",name);
435
+			return true;
436
+		}
437
+		void error(char *msg) {
438
+			fprintf(stderr,msg);
439
+			exit(1);
440
+		}
441
+	};
442
+ @C
443
+	bool my_parser_new_struct(TCOD_parser_struct_t str, const char *name) {
444
+		printf ("new structure type '%s' with name '%s'\n",TCOD_struct_get_name(str),name ? name : "NULL");
445
+		return true;
446
+	}
447
+	bool my_parser_flag(const char *name) {
448
+		printf ("found new flag '%s'\n",name);
449
+		return true;
450
+	}
451
+	bool my_parser_property(const char *name, TCOD_value_type_t type, TCOD_value_t value) {
452
+		printf ("found new property '%s'\n",name);
453
+		return true;
454
+	}
455
+	bool my_parser_end_struct(TCOD_parser_struct_t str, const char *name) {
456
+		printf ("end of structure type '%s'\n",name);
457
+		return true;
458
+	}
459
+	void my_parser_error(const char *msg) {
460
+		fprintf(stderr,msg);
461
+		exit(1);
462
+	}
463
+	TCOD_parser_listener_t my_listener = {
464
+		my_parser_new_struct,
465
+		my_parser_flag,
466
+		my_parser_property,
467
+		my_parser_end_struct,
468
+		my_parser_error
469
+	};
470
+ @Py
471
+    class MyListener:
472
+        def new_struct(self, struct, name):
473
+            print 'new structure type', libtcod.struct_get_name(struct),
474
+                  ' named ', name
475
+            return True
476
+        def new_flag(self, name):
477
+            print 'new flag named ', name
478
+            return True
479
+        def new_property(self,name, typ, value):
480
+            type_names = ['NONE', 'BOOL', 'CHAR', 'INT', 'FLOAT', 'STRING',
481
+                          'COLOR', 'DICE']
482
+            if typ == libtcod.TYPE_COLOR :
483
+                print 'new property named ', name,' type ',type_names[typ],
484
+                      ' value ', value.r, value.g, value.b
485
+            elif typ == libtcod.TYPE_DICE :
486
+                print 'new property named ', name,' type ',type_names[typ],
487
+                      ' value ', value.nb_rolls, value.nb_faces,
488
+                      value.multiplier, value.addsub
489
+            else:
490
+                print 'new property named ', name,' type ',type_names[typ],
491
+                      ' value ', value
492
+            return True
493
+        def end_struct(self, struct, name):
494
+            print 'end structure type', libtcod.struct_get_name(struct),
495
+                  ' named ', name
496
+            return True
497
+        def error(self,msg):
498
+            print 'error : ', msg
499
+            return True
500
+ */
501
+
502
+// sax event listener
503
+class TCODLIB_API ITCODParserListener {
504
+public :
505
+	virtual ~ITCODParserListener(){}
506
+	/**
507
+	@PageName parser_run
508
+	@FuncTitle Handling 'newStruct' events
509
+	@FuncDesc This callback is called each time the parser find a new structure declaration in the file. Example :
510
+<div class="code"><pre>item_type "blade" { // <= newStruct event here
511
+	...
512
+}
513
+</pre></div>
514
+It must return true if everything is right, false if there is an error and the parser must exit.
515
+	@Cpp bool ITCODParserListener::parserNewStruct(TCODParser *parser,TCODParserStruct *str,const char *name)
516
+	@C bool new_struct(TCOD_parser_struct_t str,const char *name)
517
+	@Py new_struct(str,name)
518
+	@Param parser	In the C++ version, the parser object, returned by TCODParser constructor. It's used for error handling.
519
+	@Param str	The structure type. Can be used to retrieve the type's name with getName. In the example above, this would be "item_type".
520
+	@Param name	The name of the structure or NULL if no name is present in the file. In the example above, this would be "blade".
521
+	*/
522
+	virtual bool parserNewStruct(TCODParser *parser,const TCODParserStruct *str,const char *name)=0;
523
+
524
+	/**
525
+	@PageName parser_run
526
+	@FuncTitle Handling 'newFlag' events
527
+	@FuncDesc This callback is called each time the parser find a new flag in the file. Example :
528
+<div class="code"><pre>item_type "blade" {
529
+	abstract  // <= newFlag event here
530
+}
531
+</pre></div>
532
+It must return true if everything is right, false if there is an error and the parser must exit.
533
+	@Cpp bool ITCODParserListener::parserFlag(TCODParser *parser,const char *name)
534
+	@C bool new_flag(const char *name)
535
+	@Py new_flag(name)
536
+	@Param parser	In the C++ version, the parser object, returned by TCODParser constructor. It's used for error handling.
537
+	@Param name	The name of the flag. In the example, this would be "abstract".
538
+	*/
539
+	virtual bool parserFlag(TCODParser *parser,const char *name)=0;
540
+
541
+	/**
542
+	@PageName parser_run
543
+	@FuncTitle Handling 'newProperty' events
544
+	@FuncDesc This callback is called each time the parser find a new property in the file. Example :
545
+<div class="code"><pre>item_type "blade" {
546
+	abstract
547
+	cost=300 // <= newProperty event here
548
+}
549
+</pre></div>
550
+It must return true if everything is right, false if there is an error and the parser must exit.
551
+	@Cpp bool ITCODParserListener::parserProperty(TCODParser *parser,const char *name, TCOD_value_type_t type, TCOD_value_t value)
552
+	@C bool new_property(const char *name, TCOD_value_type_t type, TCOD_value_t value)
553
+	@Py new_property(name,type,value)
554
+	@Param parser	In the C++ version, the parser object, returned by TCODParser constructor. It's used for error handling.
555
+	@Param name	The name of the property. In the example, this would be "cost".
556
+	@Param type	The type of the property as defined when you called addProperty or addValueList. In the example, this would be TCOD_TYPE_INT.
557
+	@Param value	The value of the property, stored in a generic value structure. In the example, we would have value.i == 300.
558
+In the case of a value-list property, the type would reflect the list id (between TCOD_TYPE_VALUELIST00 and TCOD_TYPE_VALUELIST15) and value.s would contain the actual string.
559
+	*/
560
+	virtual bool parserProperty(TCODParser *parser,const char *propname, TCOD_value_type_t type, TCOD_value_t value)=0;
561
+
562
+	/**
563
+	@PageName parser_run
564
+	@FuncTitle Handling 'endStruct' events
565
+	@FuncDesc This callback is called each time the parser find the end of a structure declaration in the file. Example :
566
+<div class="code"><pre>item_type "blade" {
567
+	...
568
+} // <= endStruct event here
569
+</pre></div>
570
+It must return true if everything is right, false if there is an error and the parser must exit.
571
+	@Cpp bool ITCODParserListener::parserEndStruct(TCODParser *parser,TCODParserStruct *str,const char *name)
572
+	@C bool end_struct(TCOD_parser_struct_t str,const char *name)
573
+	@Py end_struct(str,name)
574
+	@Param parser	In the C++ version, the parser object, returned by TCODParser constructor. It's used for error handling.
575
+	@Param str	The structure type. Can be used to retrieve the type's name with getName. In the example above, this would be "item_type".
576
+	@Param name	The name of the structure or NULL if no name is present in the file. In the example above, this would be "blade".
577
+	*/
578
+	virtual bool parserEndStruct(TCODParser *parser,const TCODParserStruct *str, const char *name)=0;
579
+
580
+	/**
581
+	@PageName parser_run
582
+	@FuncTitle Handling errors
583
+	@FuncDesc There are two kind of errors :
584
+    * Errors that are detected by the parser itself (malformed file, bad value syntax for a property, missing mandatory property in a structure, ...).
585
+    * Errors that you detect in your callbacks.
586
+	When the parser finds an error in the file, it will call the error callback and stop :
587
+	@Cpp void ITCODParserListener::error(const char *msg)
588
+	@C void error(const char *msg)
589
+	@Py error(msg)
590
+	@Param msg	The error message from the parser with the file name and the line number.
591
+	*/
592
+
593
+	/**
594
+	@PageName parser_run
595
+	@FuncDesc If you find an error in your callback, you have to call the parser error function. It will add the file name and line number to your error message, and then call your error callback :
596
+The code in the example below will result in your error callback called with the following string :
597
+"error in &lt;filename&gt; line &lt;line_number&gt; : Bad cost value %d. Cost must be between 0 and 1000"
598
+	@Cpp void TCODParser::error(const char *msg, ...)
599
+	@C void TCOD_parser_error(const char *msg, ...)
600
+	@Py parser_error(msg)
601
+	@Param msg	printf-like format string for your error message.
602
+	@CppEx parser->error("Bad cost value %d. Cost must be between 0 and 1000", value.i);
603
+	@CEx TCOD_parser_error("Bad cost value %d. Cost must be between 0 and 1000", value.i);
604
+	@PyEx libtcod.parser_error("Bad cost value %d. Cost must be between 0 and 1000"%( value ))
605
+	*/
606
+	virtual void error(const char *msg) = 0;
607
+};
608
+
609
+/**
610
+ @PageName parser_types
611
+ @PageFather parser
612
+ @PageTitle Standard types
613
+ @FuncDesc The parser can parse natively several data types. It stores them in a generic union :
614
+ @C
615
+	typedef struct {
616
+		int nb_rolls;
617
+		int nb_faces;
618
+		float multiplier;
619
+		float addsub;
620
+	} TCOD_dice_t;
621
+
622
+	typedef union {
623
+		bool b;
624
+		char c;
625
+		int32 i;
626
+		float f;
627
+		char *s;
628
+		TCOD_color_t col;
629
+		TCOD_dice_t dice;
630
+		TCOD_list_t list;
631
+		void *custom;
632
+	} TCOD_value_t;
633
+*/
634
+/**
635
+ @PageName parser_types
636
+ @FuncDesc Possible types are defined by the TCOD_value_type_t enumeration :
637
+For python, remove TCOD_ : libtcod.TYPE_BOOL
638
+<table class="param">
639
+<tbody><tr><th>TCOD_value_type_t</th><th>Value in file</th><th>TCOD_value_t</th></tr>
640
+
641
+<tr><td>TCOD_TYPE_BOOL</td><td>true<br>false</td><td>value.b == true/false</td></tr>
642
+<tr><td>TCOD_TYPE_CHAR</td><td>decimal notation : 0 .. 255<br>
643
+hexadecimal notation : 0x00 .. 0xff <br>
644
+char notation : 'a' ';' ...<br>
645
+Special characters :<br>
646
+'\n' : carriage return (ascii 13)<br>
647
+'\t' : tabulation (ascii 9)<br>
648
+
649
+'\r' : line feed (ascii 10)<br>
650
+'\\' : antislash (ascii 92)<br>
651
+'\"' : double-quote (ascii 34)<br>
652
+'\'' : simple quote (ascii 39)<br>
653
+'\xHH' : hexadecimal value, same as 0xHH, HH between 0 and FF<br>
654
+'\NNN' : octal value, NNN between 0 and 377<br>
655
+</td><td>value.c == The corresponding ascii code</td></tr>
656
+<tr><td>TCOD_TYPE_INT</td><td>decimal notation : -2147483648 .. 2147483647<br>hexadecimal notation : 0x0 .. 0xFFFFFFFF</td><td>value.i == the integer value</td></tr>
657
+
658
+<tr><td>TCOD_TYPE_FLOAT</td><td>Any format parsable by atof. Examples:<br>3.14159<br>1.25E-3</td><td>value.f == the float value</td></tr>
659
+<tr><td>TCOD_TYPE_STRING</td><td>A double-quote delimited string :<br>"This is a string"<br>Support the same special characters as TCOD_TYPE_CHAR.</td><td>value.s == the corresponding string.<br>Warning ! If you want to store this string, you have to duplicate it (with strdup) as it will be overwritten by the parser</td></tr>
660
+<tr><td>TCOD_TYPE_COLOR</td><td>decimal notation : "16,32,64"<br>hexadecimal notation : "#102040"</td><td>value.col == the color.</td></tr>
661
+
662
+<tr><td>TCOD_TYPE_DICE</td><td>[multiplier (x|*)] nb_rolls (d|D) nb_faces [(+|-) addsub] :<br>"3d6"<br>"3D6+2"<br>"0.5x3d6-2"<br>"2*3d8"</td><td>value.dice == the dice components</td></tr>
663
+<tr><td>TCOD_TYPE_VALUELISTxx</td><td>Same as TCOD_TYPE_STRING</td><td>value.s == the string value from the value list</td></tr>
664
+<tr><td>TCOD_TYPE_LIST</td><td>[ &lt;value1&gt;,&lt;value2&gt;,... ]</td><td>value.list == the TCOD_list_t containing the elements</td></tr>
665
+
666
+</tbody></table>
667
+
668
+To define a list type, use the appropriate function (TCODParserStruct::addListProperty / TCOD_parser_add_list_property) and specify the type of the elements in the list. Lists of list are not supported.
669
+ */
670
+
671
+
672
+#endif
0 673
new file mode 100644
... ...
@@ -0,0 +1,63 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_PATH_H
29
+#define _TCOD_PATH_H
30
+
31
+typedef float (*TCOD_path_func_t)( int xFrom, int yFrom, int xTo, int yTo, void *user_data );
32
+typedef void *TCOD_path_t;
33
+
34
+TCODLIB_API TCOD_path_t TCOD_path_new_using_map(TCOD_map_t map, float diagonalCost);
35
+TCODLIB_API TCOD_path_t TCOD_path_new_using_function(int map_width, int map_height, TCOD_path_func_t func, void *user_data, float diagonalCost);
36
+
37
+TCODLIB_API bool TCOD_path_compute(TCOD_path_t path, int ox,int oy, int dx, int dy);
38
+TCODLIB_API bool TCOD_path_walk(TCOD_path_t path, int *x, int *y, bool recalculate_when_needed);
39
+TCODLIB_API bool TCOD_path_is_empty(TCOD_path_t path);
40
+TCODLIB_API int TCOD_path_size(TCOD_path_t path);
41
+TCODLIB_API void TCOD_path_reverse(TCOD_path_t path);
42
+TCODLIB_API void TCOD_path_get(TCOD_path_t path, int index, int *x, int *y);
43
+TCODLIB_API void TCOD_path_get_origin(TCOD_path_t path, int *x, int *y);
44
+TCODLIB_API void TCOD_path_get_destination(TCOD_path_t path, int *x, int *y);
45
+TCODLIB_API void TCOD_path_delete(TCOD_path_t path);
46
+
47
+/* Dijkstra stuff - by Mingos*/
48
+
49
+typedef void *TCOD_dijkstra_t;
50
+
51
+TCODLIB_API TCOD_dijkstra_t TCOD_dijkstra_new (TCOD_map_t map, float diagonalCost);
52
+TCODLIB_API TCOD_dijkstra_t TCOD_dijkstra_new_using_function(int map_width, int map_height, TCOD_path_func_t func, void *user_data, float diagonalCost);
53
+TCODLIB_API void TCOD_dijkstra_compute (TCOD_dijkstra_t dijkstra, int root_x, int root_y);
54
+TCODLIB_API float TCOD_dijkstra_get_distance (TCOD_dijkstra_t dijkstra, int x, int y);
55
+TCODLIB_API bool TCOD_dijkstra_path_set (TCOD_dijkstra_t dijkstra, int x, int y);
56
+TCODLIB_API bool TCOD_dijkstra_is_empty(TCOD_dijkstra_t path);
57
+TCODLIB_API int TCOD_dijkstra_size(TCOD_dijkstra_t path);
58
+TCODLIB_API void TCOD_dijkstra_reverse(TCOD_dijkstra_t path);
59
+TCODLIB_API void TCOD_dijkstra_get(TCOD_dijkstra_t path, int index, int *x, int *y);
60
+TCODLIB_API bool TCOD_dijkstra_path_walk (TCOD_dijkstra_t dijkstra, int *x, int *y);
61
+TCODLIB_API void TCOD_dijkstra_delete (TCOD_dijkstra_t dijkstra);
62
+
63
+#endif
0 64
new file mode 100644
... ...
@@ -0,0 +1,552 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_PATH_HPP
29
+#define _TCOD_PATH_HPP
30
+
31
+class TCODLIB_API ITCODPathCallback {
32
+public :
33
+	virtual ~ITCODPathCallback() {}
34
+	virtual float getWalkCost( int xFrom, int yFrom, int xTo, int yTo, void *userData ) const = 0;
35
+};
36
+
37
+/**
38
+ @PageName path
39
+ @PageTitle Path finding
40
+ @PageCategory Roguelike toolkits
41
+ @PageDesc This toolkit allows to easily calculate the optimal path between two points in your dungeon by using either the <a href="http://en.wikipedia.org/wiki/A*">A* algorithm</a> or <a href="http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm">Dijkstra's algorithm</a>.
42
+Please note that the paths generated with the two algorithms may differ slightly. Due to how they're implemented, A* will usually prefer diagonal moves over orthogonal, while Dijkstra will have the opposite preference. In other words, paths from point X to point Y will look like this:
43
+<div class="code"><pre>
44
+Dijkstra:      A*:
45
+..........   ..........
46
+.X........   .X*.......
47
+..*.......   ...**.....
48
+...*......   .....**...
49
+....****Y.   .......*Y.
50
+..........   ..........
51
+</pre></div>
52
+ */
53
+class TCODLIB_API TCODPath {
54
+public :
55
+	/**
56
+	@PageName path_init
57
+	@PageFather path
58
+	@PageTitle Creating a path
59
+	@FuncTitle Allocating a pathfinder from a map
60
+	@FuncDesc First, you have to allocate a path using a map from <a href="fov.html">the Field of view module</a>.
61
+	@Cpp
62
+		TCODPath::TCODPath(const TCODMap *map, float diagonalCost=1.41f)
63
+		TCODDijkstra::TCODDijkstra(const TCODMap *map, float diagonalCost=1.41f)
64
+	@C 
65
+		TCOD_path_t TCOD_path_new_using_map(TCOD_map_t map, float diagonalCost)
66
+		TCOD_dijkstra_t TCOD_dijkstra_new(TCOD_map_t map, float diagonalCost)
67
+	@Py 
68
+		path_new_using_map(map, diagonalCost=1.41)
69
+		dijkstra_new(map, diagonalCost=1.41)
70
+	@C#
71
+		TCODPath(TCODMap map, float diagonalCost)
72
+		TCODPath(TCODMap map)
73
+		TCODDijkstra(TCODMap map, float diagonalCost)
74
+		TCODDijkstra(TCODMap map)
75
+	@Param map	The map. The path finder will use the 'walkable' property of the cells to find a path.
76
+	@Param diagonalCost	Cost of a diagonal movement compared to an horizontal or vertical movement. On a standard cartesian map, it should be sqrt(2) (1.41f).
77
+		It you want the same cost for all movements, use 1.0f.
78
+		If you don't want the path finder to use diagonal movements, use 0.0f.
79
+	@CppEx 
80
+		// A* :
81
+		TCODMap *myMap = new TCODMap(50,50);
82
+		TCODPath *path = new TCODPath(myMap); // allocate the path
83
+		// Dijkstra:
84
+		TCODMap *myMap = new TCODMap(50,50);
85
+		TCODDijkstra *dijkstra = new TCODDijkstra(myMap); // allocate the path
86
+	@CEx 
87
+		// A* :
88
+		TCOD_map_t my_map=TCOD_map_new(50,50,true);
89
+		TCOD_path_t path = TCOD_path_new_using_map(my_map,1.41f);
90
+		// Dijkstra :
91
+		TCOD_map_t my_map=TCOD_map_new(50,50,true);
92
+		TCOD_dijkstra_t dijk = TCOD_dijkstra_new(my_map,1.41f);
93
+	@PyEx 
94
+		# A* :
95
+		my_map=libtcod.map_new(50,50,True)
96
+		path = libtcod.path_new_using_map(my_map)
97
+		# Dijkstra
98
+		my_map=libtcod.map_new(50,50,True)
99
+		dijk = libtcod.dijkstra_new(my_map) 	
100
+	*/	
101
+	TCODPath(const TCODMap *map, float diagonalCost=1.41f);
102
+	/**
103
+	@PageName path_init
104
+	@FuncTitle Allocating a pathfinder using a callback
105
+	@FuncDesc Since the walkable status of a cell may depend on a lot of parameters (the creature type, the weather, the terrain type...), you can also create a path by providing a function rather than relying on a TCODMap.
106
+	@Cpp 
107
+		// Callback :
108
+		class ITCODPathCallback {
109
+			public: virtual float getWalkCost( int xFrom, int yFrom, int xTo, int yTo, void *userData ) const = 0;
110
+		};
111
+		// A* constructor:
112
+		TCODPath::TCODPath(int width, int height, const ITCODPathCallback *callback, void *userData, float diagonalCost=1.41f)
113
+		// Dijkstra constructor
114
+		TCODDijkstra::TCODDijkstra(int width, int height, const ITCODPathCallback *callback, void *userData, float diagonalCost=1.41f)
115
+	@C 
116
+		typedef float (*TCOD_path_func_t)( int xFrom, int yFrom, int xTo, int yTo, void *user_data )
117
+		TCOD_path_t TCOD_path_new_using_function(int width, int height, TCOD_path_func_t callback, void *user_data, float diagonalCost)
118
+		TCOD_dijkstra_t TCOD_dijkstra_new_using_function(int width, int height, TCOD_path_func_t callback, void *user_data, float diagonalCost)
119
+	@Py 
120
+		def path_func(xFrom,yFrom,xTo,yTo,userData) : ...
121
+		path_new_using_function(width, height, path_func, user_data=0, diagonalCost=1.41)
122
+		dijkstra_new_using_function(width, height, path_func, user_data=0, diagonalCost=1.41)
123
+	@C#
124
+		TCODPath(int width, int height, ITCODPathCallback listener, float diagonalCost)
125
+		TCODPath(int width, int height, ITCODPathCallback listener)
126
+		TCODDijkstra(int width, int height, ITCODPathCallback listener, float diagonalCost)
127
+		TCODDijkstra(int width, int height, ITCODPathCallback listener)
128
+	@Param width,height	The size of the map (in map cells).
129
+	@Param callback	A custom function that must return the walk cost from coordinates xFrom,yFrom to coordinates xTo,yTo.
130
+		The cost must be > 0.0f if the cell xTo,yTo is walkable.
131
+		It must be equal to 0.0f if it's not.
132
+		You must not take additional cost due to diagonal movements into account as it's already done by the pathfinder.
133
+	@Param userData	Custom data that will be passed to the function.
134
+	@Param diagonalCost	Cost of a diagonal movement compared to an horizontal or vertical movement. On a standard cartesian map, it should be sqrt(2) (1.41f).
135
+		It you want the same cost for all movements, use 1.0f.
136
+		If you don't want the path finder to use diagonal movements, use 0.0f.
137
+	@CppEx 
138
+		class MyCallback : public ITCODPathCallback {
139
+		public :
140
+			float getWalkCost(int xFrom, int yFrom, int xTo, int yTo, void *userData ) const { ... }
141
+		};
142
+		TCODPath *path = new TCODPath(50,50,new MyCallback(),NULL); // allocate the path
143
+		TCODDijkstra *dijkstra = new TCODDijkstra(50,50,new MyCallback(),NULL); // allocate Dijkstra
144
+	@CEx 
145
+		float my_func(int xFrom, int yFrom, int xTo, int yTo, void *user_data) { ... }
146
+		TCOD_path_t path = TCOD_path_new_using_function(50,50,my_func,NULL,1.41f);
147
+		TCOD_dijkstra_t dijkstra = TCOD_dijkstra_new_using_function(50,50,my_func,NULL,1.41f);
148
+	@PyEx 
149
+		def my_func(xFrom, yFrom, xTo, yTo, user_data) :
150
+			# return a float cost for this movement
151
+			return 1.0
152
+		path = libtcod.path_new_using_function(50,50,my_func)
153
+		dijkstra = libtcod.dijkstra_new_using_function(50,50,my_func)
154
+	*/	
155
+	TCODPath(int width, int height, const ITCODPathCallback *listener, void *userData, float diagonalCost=1.41f);
156
+	
157
+	/**
158
+	@PageName path_init
159
+	@FuncTitle Destroying a path
160
+	@FuncDesc To release the resources used by a path, destroy it with :
161
+	@Cpp 
162
+		TCODPath::~TCODPath()
163
+		TCODDijkstra::~TCODDijkstra()
164
+	@C 
165
+		void TCOD_path_delete(TCOD_path_t path)
166
+		void TCOD_dijkstra_delete(TCOD_dijkstra_t dijkstra)
167
+	@Py 
168
+		path_delete(path)
169
+		dijkstra_delete(dijkstra)
170
+	@C#
171
+		void TCODPath::Dispose()
172
+		void TCODDijkstra::Dispose()
173
+	@Param path	In the C version, the path handler returned by one of the TCOD_path_new_* function.
174
+	@Param dijkstra	In the C version, the path handler returned by one of the TCOD_dijkstra_new* function.
175
+	@CppEx 
176
+		TCODPath *path = new TCODPath(myMap); // allocate the path
177
+		// use the path...
178
+		delete path; // destroy the path
179
+		
180
+		TCODDijkstra *dijkstra = new TCODDijkstra(myMap); // allocate the path
181
+		// use the path...
182
+		delete dijkstra; // destroy the path
183
+	@CEx 
184
+		TCOD_path_t path = TCOD_path_new_using_map(my_map);
185
+		// use the path ... 
186
+		TCOD_path_delete(path);
187
+		
188
+		TCOD_dijkstra_t dijkstra = TCOD_dijkstra_new(my_map);
189
+		// use the path ... 
190
+		TCOD_dijkstra_delete(dijkstra);
191
+	@PyEx 
192
+		path = libtcod.path_new_using_map(my_map)
193
+		# use the path ... 
194
+		libtcod.path_delete(path)
195
+		
196
+		dijkstra = libtcod.dijkstra_new(my_map)
197
+		# use the path ... 
198
+		libtcod.dijkstra_delete(dijkstra)	
199
+	*/	
200
+	virtual ~TCODPath();
201
+
202
+	/**
203
+	@PageName path_compute
204
+	@PageFather path
205
+	@PageTitle Computing the path
206
+	@FuncTitle Computing an A* path
207
+	@FuncDesc Once you created a TCODPath object, you can compute the path between two points:
208
+	@Cpp bool TCODPath::compute(int ox, int oy, int dx, int dy)     
209
+	@C bool TCOD_path_compute(TCOD_path_t path, int ox,int oy, int dx, int dy)
210
+	@Py path_compute(path, ox, oy, dx, dy)
211
+	@C#	void TCODPath::compute(int ox, int oy, int dx, int dy)
212
+	@Param path	In the C version, the path handler returned by a creation function.
213
+	@Param ox,oy	Coordinates of the origin of the path.
214
+	@Param dx,dy	Coordinates of the destination of the path.
215
+		Both points should be inside the map, and at a walkable position. The function returns false if there is no possible path.
216
+	@CppEx 
217
+		TCODMap *myMap = new TCODMap(50,50);
218
+		TCODPath *path = new TCODPath(myMap); // allocate the path
219
+		path->compute(5,5,25,25); // calculate path from 5,5 to 25,25
220
+	@CEx 
221
+		TCOD_map_t my_map=TCOD_map_new(50,50);
222
+		TCOD_path_t path = TCOD_path_new_using_map(my_map);
223
+		TCOD_path_compute(path,5,5,25,25);
224
+	@PyEx 
225
+		my_map=libtcod.map_new(50,50)
226
+		path = libtcod.path_new_using_map(my_map)
227
+		libtcod.path_compute(path,5,5,25,25)	
228
+	*/	
229
+	bool compute(int ox, int oy, int dx, int dy);
230
+
231
+	/**
232
+	@PageName path_compute
233
+	@FuncTitle Reversing a path
234
+	@FuncDesc Once you computed a path, you can exchange origin and destination :
235
+	@Cpp 
236
+		void TCODPath::reverse()     
237
+		void TCODDijkstra::reverse()
238
+	@C 
239
+		void TCOD_path_reverse(TCOD_path_t path)
240
+		void TCOD_dijkstra_reverse(TCOD_dijkstra_t dijkstra)
241
+	@Py 
242
+		path_reverse(path)
243
+		dijkstra_reverse(dijkstra)
244
+	@C#	
245
+		void TCODPath::reverse()
246
+		void TCODDijkstra::reverse()
247
+	@Param path	In the C version, the path handler returned by a creation function.
248
+	@CppEx 
249
+		TCODMap *myMap = new TCODMap(50,50);
250
+		TCODPath *path = new TCODPath(myMap); // allocate the path
251
+		path->compute(5,5,25,25); // calculate path from 5,5 to 25,25
252
+		path->reverse(); // now the path goes from 25,25 to 5,5
253
+	@CEx 
254
+		TCOD_map_t my_map=TCOD_map_new(50,50);
255
+		TCOD_path_t path = TCOD_path_new_using_map(my_map);
256
+		TCOD_path_compute(path,5,5,25,25); // calculate path from 5,5 to 25,25
257
+		TCOD_path_reverse(path); // now the path goes from 25,25 to 5,5
258
+	@PyEx 
259
+		my_map=libtcod.map_new(50,50)
260
+		path = libtcod.path_new_using_map(my_map)
261
+		libtcod.path_compute(path,5,5,25,25) # calculate path from 5,5 to 25,25
262
+		libtcod.path_reverse(path) # now the path goes from 25,25 to 5,5
263
+	*/
264
+	void reverse();
265
+	
266
+
267
+	/**
268
+	@PageName path_read
269
+	@PageTitle Reading path information
270
+	@PageFather path
271
+	@PageDescDesc Once the path has been computed, you can get information about it using of one those functions.
272
+	@FuncTitle Getting the path origin and destination
273
+	@FuncDesc 	
274
+		You can read the current origin and destination cells with getOrigin/getDestination.
275
+		Note that when you walk the path, the origin changes at each step.
276
+	@Cpp 
277
+		void TCODPath::getOrigin(int *x,int *y) const
278
+		void TCODPath::getDestination(int *x,int *y) const
279
+	@C 
280
+		void TCOD_path_get_origin(TCOD_path_t path, int *x, int *y)
281
+		void TCOD_path_get_destination(TCOD_path_t path, int *x, int *y)
282
+	@Py 
283
+		path_get_origin(path) # returns x,y
284
+		path_get_destination(path) # returns x,y
285
+	@C#
286
+		void TCODPath::getOrigin(out int x, out int y)
287
+		void TCODPath::getDestination(out int x, out int y)
288
+	@Param path	In the C version, the path handler returned by a creation function.
289
+	@Param x,y	The function returns the cell coordinates in these variables
290
+	*/	
291
+	void getOrigin(int *x,int *y) const;
292
+	void getDestination(int *x,int *y) const;
293
+
294
+	/**
295
+	@PageName path_read
296
+	@FuncTitle Getting the path length
297
+	@FuncDesc You can get the number of steps needed to reach destination :
298
+	@Cpp 
299
+		int TCODPath::size() const
300
+		int TCODDijkstra::size() const
301
+	@C 
302
+		int TCOD_path_size(TCOD_path_t path)
303
+		int TCOD_dijkstra_size(TCOD_dijkstra_t dijkstra)
304
+	@Py 
305
+		path_size(path)
306
+		dijkstra_size(dijkstra)
307
+	@C#
308
+		int TCODPath::size()
309
+		int TCODDijkstra::size()
310
+	@Param path, dijkstra	In the C version, the path handler returned by a creation function.
311
+	*/		
312
+	int size() const;
313
+	
314
+	/**
315
+	@PageName path_read
316
+	@FuncTitle Read the path cells' coordinates	
317
+	@FuncDesc You can get the coordinates of each point along the path :
318
+	@Cpp 
319
+		void TCODPath::get(int index, int *x, int *y) const
320
+		void TCODDijkstra::get(int index, int *x, int *y) const
321
+	@C 
322
+		void TCOD_path_get(TCOD_path_t path, int index, int *x, int *y)
323
+		void TCOD_dijkstra_get(TCOD_dijkstra_t dijkstra, int index, int *x, int *y)
324
+	@Py 
325
+		path_get(path, index) # returns x,y
326
+		dijkstra_get(dijkstra, index) # returns x,y
327
+	@C#
328
+		int TCODPath::size()
329
+		int TCODDijkstra::size()
330
+	@Param path, dijkstra	In the C version, the path handler returned by a creation function.
331
+	@Param index	Step number.
332
+		0 <= index < path size
333
+	@Param x,y	Address of the variables receiving the coordinates of the point.
334
+	@CppEx 
335
+		for (int i=0; i < path->size(); i++ ) {
336
+			int x,y;
337
+			path->get(i,&x,&y);
338
+			printf ("Astar coord : %d %d\n", x,y );
339
+		}
340
+		for (int i=0; i < dijkstra->size(); i++ ) {
341
+			int x,y;
342
+			dijkstra->get(i,&x,&y);
343
+			printf ("Dijkstra coord : %d %d\n", x,y );
344
+		}
345
+	@CEx 
346
+		int i;
347
+		for (i=0; i < TCOD_path_size(path); i++ ) {
348
+			int x,y;
349
+			TCOD_path_get(path,i,&x,&y);
350
+			printf ("Astar coord : %d %d\n", x,y );
351
+		}
352
+		for (i=0; i < TCOD_dijkstra_size(dijkstra); i++ ) {
353
+			int x,y;
354
+			TCOD_dijkstra_get(dijkstra,i,&x,&y);
355
+			printf ("Dijsktra coord : %d %d\n", x,y );
356
+		}
357
+	@PyEx 
358
+		for i in range (libtcod.path_size(path)) :
359
+			x,y=libtcod.path_get(path,i)
360
+			print 'Astar coord : ',x,y
361
+		for i in range (libtcod.dijkstra_size(dijkstra)) :
362
+			x,y=libtcod.dijkstra_get(dijkstra,i)
363
+			print 'Dijkstra coord : ',x,y
364
+	*/	
365
+	void get(int index, int *x, int *y) const;
366
+
367
+	/**
368
+	@PageName path_read
369
+	@FuncTitle Checking if the path is empty
370
+	@FuncDesc If you want a creature to follow the path, a more convenient way is to walk the path :
371
+		You know when you reached destination when the path is empty :
372
+	@Cpp 
373
+		bool TCODPath::isEmpty() const
374
+		bool TCODDijkstra::isEmpty() const
375
+	@C 
376
+		bool TCOD_path_is_empty(TCOD_path_t path)
377
+		bool TCOD_dijkstra_is_empty(TCOD_dijkstra_t dijkstra)
378
+	@Py 
379
+		path_is_empty(path)
380
+		dijkstra_is_empty(dijkstra)
381
+	@C#
382
+		bool TCODPath::isEmpty()
383
+		bool TCODDijkstra::isEmpty()
384
+	@Param path, dijkstra	In the C version, the path handler returned by a creation function.	
385
+	*/
386
+	bool isEmpty() const;
387
+
388
+	/**
389
+	@PageName path_read
390
+	@FuncTitle Walking the path
391
+	@FuncDesc You can walk the path and go to the next step with :
392
+		Note that walking the path consume one step (and decrease the path size by one). The function returns false if recalculateWhenNeeded is false and the next cell on the path is no longer walkable, or if recalculateWhenNeeded is true, the next cell on the path is no longer walkable and no other path has been found. Also note that recalculateWhenNeeded only applies to A*.
393
+	@Cpp 
394
+		bool TCODPath::walk(int *x, int *y, bool recalculateWhenNeeded)
395
+		bool TCODDijkstra::walk(int *x, int *y)
396
+	@C 
397
+		bool TCOD_path_walk(TCOD_path_t path, int *x, int *y, bool recalculate_when_needed)
398
+		bool TCOD_dijkstra_walk(TCOD_dijkstra_t dijkstra, int *x, int *y)
399
+	@Py 
400
+		path_walk(TCOD_path_t path, recalculate_when_needed) # returns x,y or None,None if no path
401
+		dijkstra_walk(TCOD_dijkstra_t dijkstra)
402
+	@C#
403
+		bool TCODPath::walk(ref int x, ref int y, bool recalculateWhenNeeded)
404
+		bool TCODDijkstra::walk(ref int x, ref int y)
405
+	@Param path, dijkstra	In the C version, the path handler returned by a creation function.
406
+	@Param x,y	Address of the variables receiving the coordinates of the next point.
407
+	@Param recalculateWhenNeeded	If the next point is no longer walkable (another creature may be in the way), recalculate a new path and walk it.
408
+	@CppEx 
409
+		while (! path->isEmpty()) {
410
+			int x,y;
411
+			if (path->walk(&x,&y,true)) {
412
+				printf ("Astar coord: %d %d\n",x,y );
413
+			} else {
414
+				printf ("I'm stuck!\n" );
415
+				break;
416
+			}
417
+		}
418
+		while (! dijkstra->isEmpty()) {
419
+			int x,y;
420
+			if (dijkstra->walk(&x,&y)) {
421
+				printf ("Dijkstra coord: %d %d\n",x,y );
422
+			} else {
423
+				printf ("I'm stuck!\n" );
424
+				break;
425
+			}
426
+		}
427
+	@CEx 
428
+		while (! TCOD_path_is_empty(path)) {
429
+			int x,y;
430
+			if (TCOD_path_walk(path,&x,&y,true)) {
431
+				printf ("Astar coord: %d %d\n",x,y );
432
+			} else {
433
+				printf ("I'm stuck!\n" );
434
+				break;
435
+			}
436
+		}
437
+		while (! TCOD_dijkstra_is_empty(dijkstra)) {
438
+			int x,y;
439
+			if (TCOD_dijkstra_walk(dijkstra,&x,&y)) {
440
+				printf ("Dijkstra coord: %d %d\n",x,y );
441
+			} else {
442
+				printf ("I'm stuck!\n" );
443
+				break;
444
+			}
445
+		}
446
+	@PyEx 
447
+		while not libtcod.path_is_empty(path)) :
448
+			x,y=libtcod.path_walk(path,True)
449
+			if not x is None :
450
+				print 'Astar coord: ',x,y
451
+			else :
452
+				print "I'm stuck!"
453
+				break
454
+		while not libtcod.dijkstra_is_empty(dijkstra)) :
455
+			x,y=libtcod.dijkstra_walk(dijkstra,True)
456
+			if not x is None :
457
+				print 'Dijkstra coord: ',x,y
458
+			else :
459
+				print "I'm stuck!"
460
+				break	
461
+	*/	
462
+	bool walk(int *x, int *y, bool recalculateWhenNeeded);
463
+
464
+protected :
465
+	friend float TCOD_path_func(int xFrom, int yFrom, int xTo,int yTo, void *data);
466
+	TCOD_path_t data;
467
+	struct WrapperData {
468
+		void *userData;
469
+		const ITCODPathCallback *listener;
470
+	} cppData;
471
+};
472
+
473
+//Dijkstra kit
474
+class TCODLIB_API TCODDijkstra {
475
+    public:
476
+        TCODDijkstra (TCODMap *map, float diagonalCost=1.41f);
477
+        TCODDijkstra (int width, int height, const ITCODPathCallback *listener, void *userData, float diagonalCost=1.41f);
478
+        ~TCODDijkstra (void);
479
+        /**
480
+        @PageName path_compute
481
+		@FuncTitle Computing a Dijkstra grid
482
+		@FuncDesc In case of Dijkstra, this works in a slightly different way. In order to be able to compute a path, Dijkstra must first analyse the distances from the selected root (origin) node to all other nodes:
483
+		@Cpp void TCODDijkstra::compute(int rootX, int rootY)     
484
+		@C void TCOD_dijkstra_compute(TCOD_dijkstra_t dijkstra, int root_x, int root_y)
485
+		@Py dijkstra_compute(dijkstra, root_x, root_y)
486
+		@C# void TCODDijkstra::compute(int rootX, int rootY)
487
+		@Param dijkstra	In the C version, the path handler returned by a creation function.
488
+		@Param root_x,root_y	Coordinates of the root node (origin) of the path.
489
+			The coordinates should be inside the map, at a walkable position. Otherwise, the function's behaviour will be undefined.        
490
+        */        
491
+        void compute (int rootX, int rootY);
492
+
493
+        /**
494
+        @PageName path_compute
495
+		@FuncTitle Computing a path from a Dijkstra grid
496
+		@FuncDesc After the map is analysed and all the distances from the root node are known, an unlimited number of paths can be set, all originating at the root node, using:
497
+			The path setting function will return true if there's a path from the root node to the destination node. Otherwise, it will return false.
498
+		@Cpp bool TCODDijkstra::setPath(int toX, int toY)     
499
+		@C bool TCOD_dijkstra_path_set(TCOD_dijkstra_t dijkstra, int to_x, int to_y)
500
+		@Py dijkstra_path_set(dijkstra, to_x, to_y)
501
+		@C# bool TCODDijkstra::setPath(int toX, int toY)
502
+		@Param dijkstra	In the C version, the path handler returned by a creation function.
503
+		@Param to_x,to_y	Coordinates of the destination node of the path.
504
+		@CppEx 
505
+			TCODMap *myMap = new TCODMap(50,50);
506
+			TCODDijkstra *dijkstra = new TCODDijkstra(myMap); // allocate the path
507
+			dijkstra->compute(25,25); // calculate distance from 25,25 to all other nodes
508
+			dijkstra->setPath(5,5); // calculate a path to node 5,5
509
+			dijkstra->setPath(45,45); //calculate another path from the same origin
510
+		@CEx 
511
+			TCOD_map_t my_map=TCOD_map_new(50,50);
512
+			TCOD_dijkstra_t dijkstra = TCOD_dijkstra_new(my_map);
513
+			TCOD_dijkstra_compute(dijkstra,25,25);
514
+			TCOD_dijkstra_path_set(dijkstra,5,5);
515
+			TCOD_dijkstra_path_set(dijkstra,45,45);
516
+		@PyEx 
517
+			my_map=libtcod.map_new(50,50)
518
+			dijkstra = libtcod.dijkstra_new(my_map)
519
+			libtcod.dijkstra_compute(dijkstra,25,25)
520
+			libtcod.dijkstra_path_set(dijkstra,5,5)
521
+			libtcod.dijkstra_path_set(dijkstra,45,45)        
522
+        */        
523
+        bool setPath (int toX, int toY);
524
+
525
+        /**
526
+        @PageName path_read
527
+		@FuncTitle Getting the distance from a cell to the root node
528
+		@FuncDesc You can get the distance of any set of coordinates from the root node:
529
+			Note that if the coordinates x,y are outside of the map or are a non-walkable position, the function will return -1.0f. This functionality is only available for Dijkstra's algorithm.        
530
+		@Cpp float TCODDijkstra::getDistance(int x, int y)
531
+		@C float TCOD_dijkstra_get_distance(TCOD_dijkstra_t dijkstra, int x, int y)
532
+		@Py dijkstra_get_distance(dijkstra, x, y)
533
+		@C# float TCODDijkstra::getDistance(int x, int y)
534
+		@Param dijkstra	In the C version, the path handler returned by a creation function.
535
+		@Param x,y	The coordinates whose distance from the root node are to be checked
536
+        */        
537
+        float getDistance (int x, int y);
538
+        bool walk (int *x, int *y);
539
+		bool isEmpty() const;
540
+		void reverse();
541
+		int size() const;
542
+		void get(int index, int *x, int *y) const;
543
+    private:
544
+        TCOD_dijkstra_t data;
545
+        struct WrapperData {
546
+            void *userData;
547
+            const ITCODPathCallback *listener;
548
+        } cppData;
549
+};
550
+
551
+#endif
552
+
0 553
new file mode 100644
... ...
@@ -0,0 +1,119 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_SYS_H
29
+#define _TCOD_SYS_H
30
+
31
+TCODLIB_API uint32 TCOD_sys_elapsed_milli();
32
+TCODLIB_API float TCOD_sys_elapsed_seconds();
33
+TCODLIB_API void TCOD_sys_sleep_milli(uint32 val);
34
+TCODLIB_API void TCOD_sys_save_screenshot(const char *filename);
35
+TCODLIB_API void TCOD_sys_force_fullscreen_resolution(int width, int height);
36
+TCODLIB_API void TCOD_sys_set_renderer(TCOD_renderer_t renderer);
37
+TCODLIB_API TCOD_renderer_t TCOD_sys_get_renderer();
38
+TCODLIB_API void TCOD_sys_set_fps(int val);
39
+TCODLIB_API int TCOD_sys_get_fps();
40
+TCODLIB_API float TCOD_sys_get_last_frame_length();
41
+TCODLIB_API void TCOD_sys_get_current_resolution(int *w, int *h);
42
+TCODLIB_API void TCOD_sys_get_fullscreen_offsets(int *offx, int *offy);
43
+TCODLIB_API void TCOD_sys_update_char(int asciiCode, int fontx, int fonty, TCOD_image_t img, int x, int y);
44
+TCODLIB_API void TCOD_sys_get_char_size(int *w, int *h);
45
+TCODLIB_API void *TCOD_sys_get_SDL_window();
46
+
47
+typedef enum {
48
+  TCOD_EVENT_NONE=0,
49
+  TCOD_EVENT_KEY_PRESS=1,
50
+  TCOD_EVENT_KEY_RELEASE=2,
51
+  TCOD_EVENT_KEY=TCOD_EVENT_KEY_PRESS|TCOD_EVENT_KEY_RELEASE,
52
+  TCOD_EVENT_MOUSE_MOVE=4,
53
+  TCOD_EVENT_MOUSE_PRESS=8,
54
+  TCOD_EVENT_MOUSE_RELEASE=16,
55
+  TCOD_EVENT_MOUSE=TCOD_EVENT_MOUSE_MOVE|TCOD_EVENT_MOUSE_PRESS|TCOD_EVENT_MOUSE_RELEASE,
56
+/* #ifdef TCOD_TOUCH_INPUT */
57
+  TCOD_EVENT_FINGER_MOVE=32,
58
+  TCOD_EVENT_FINGER_PRESS=64,
59
+  TCOD_EVENT_FINGER_RELEASE=128,
60
+  TCOD_EVENT_FINGER=TCOD_EVENT_FINGER_MOVE|TCOD_EVENT_FINGER_PRESS|TCOD_EVENT_FINGER_RELEASE,
61
+/* #endif */
62
+  TCOD_EVENT_ANY=TCOD_EVENT_KEY|TCOD_EVENT_MOUSE|TCOD_EVENT_FINGER,
63
+} TCOD_event_t;
64
+TCODLIB_API TCOD_event_t TCOD_sys_wait_for_event(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse, bool flush);
65
+TCODLIB_API TCOD_event_t TCOD_sys_check_for_event(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse);
66
+
67
+/* filesystem stuff */
68
+TCODLIB_API bool TCOD_sys_create_directory(const char *path);
69
+TCODLIB_API bool TCOD_sys_delete_file(const char *path);
70
+TCODLIB_API bool TCOD_sys_delete_directory(const char *path);
71
+TCODLIB_API bool TCOD_sys_is_directory(const char *path);
72
+TCODLIB_API TCOD_list_t TCOD_sys_get_directory_content(const char *path, const char *pattern);
73
+TCODLIB_API bool TCOD_sys_file_exists(const char * filename, ...);
74
+TCODLIB_API bool TCOD_sys_read_file(const char *filename, unsigned char **buf, size_t *size);
75
+TCODLIB_API bool TCOD_sys_write_file(const char *filename, unsigned char *buf, uint32 size);
76
+
77
+/* clipboard */
78
+TCODLIB_API void TCOD_sys_clipboard_set(const char *value);
79
+TCODLIB_API char *TCOD_sys_clipboard_get();
80
+
81
+/* thread stuff */
82
+typedef void *TCOD_thread_t;
83
+typedef void *TCOD_semaphore_t;
84
+typedef void *TCOD_mutex_t;
85
+typedef void *TCOD_cond_t;
86
+/* threads */
87
+TCODLIB_API TCOD_thread_t TCOD_thread_new(int (*func)(void *), void *data);
88
+TCODLIB_API void TCOD_thread_delete(TCOD_thread_t th);
89
+TCODLIB_API int TCOD_sys_get_num_cores();
90
+TCODLIB_API void TCOD_thread_wait(TCOD_thread_t th);
91
+/* mutex */
92
+TCODLIB_API TCOD_mutex_t TCOD_mutex_new();
93
+TCODLIB_API void TCOD_mutex_in(TCOD_mutex_t mut);
94
+TCODLIB_API void TCOD_mutex_out(TCOD_mutex_t mut);
95
+TCODLIB_API void TCOD_mutex_delete(TCOD_mutex_t mut);
96
+/* semaphore */
97
+TCODLIB_API TCOD_semaphore_t TCOD_semaphore_new(int initVal);
98
+TCODLIB_API void TCOD_semaphore_lock(TCOD_semaphore_t sem);
99
+TCODLIB_API void TCOD_semaphore_unlock(TCOD_semaphore_t sem);
100
+TCODLIB_API void TCOD_semaphore_delete( TCOD_semaphore_t sem);
101
+/* condition */
102
+TCODLIB_API TCOD_cond_t TCOD_condition_new();
103
+TCODLIB_API void TCOD_condition_signal(TCOD_cond_t sem);
104
+TCODLIB_API void TCOD_condition_broadcast(TCOD_cond_t sem);
105
+TCODLIB_API void TCOD_condition_wait(TCOD_cond_t sem, TCOD_mutex_t mut);
106
+TCODLIB_API void TCOD_condition_delete( TCOD_cond_t sem);
107
+/* dynamic library */
108
+typedef void *TCOD_library_t;
109
+TCODLIB_API TCOD_library_t TCOD_load_library(const char *path);
110
+TCODLIB_API void * TCOD_get_function_address(TCOD_library_t library, const char *function_name);
111
+TCODLIB_API void TCOD_close_library(TCOD_library_t);
112
+/* SDL renderer callback */
113
+#ifdef TCOD_SDL2
114
+typedef void (*SDL_renderer_t) (void *sdl_renderer);
115
+#else
116
+typedef void (*SDL_renderer_t) (void *sdl_surface);
117
+#endif
118
+TCODLIB_API void TCOD_sys_register_SDL_renderer(SDL_renderer_t renderer);
119
+#endif
0 120
new file mode 100644
... ...
@@ -0,0 +1,541 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_SYS_HPP
29
+#define _TCOD_SYS_HPP
30
+
31
+/**
32
+	@PageName system
33
+	@PageCategory Core
34
+	@PageTitle System layer
35
+	@PageDesc This toolkit contains some system specific miscellaneous utilities. Use them is you want your code to be easily portable.
36
+ */
37
+
38
+class TCODLIB_API ITCODSDLRenderer {
39
+public :
40
+	virtual ~ITCODSDLRenderer() {}
41
+	virtual void render(void *sdlSurface) = 0;
42
+};
43
+
44
+class TCODLIB_API TCODSystem {
45
+public :
46
+	/**
47
+	@PageName system_time
48
+	@PageFather system
49
+	@PageTitle High precision time functions
50
+	@PageDesc These are functions specifically aimed at real time game development.
51
+	@FuncTitle Limit the frames per second
52
+	@FuncDesc The setFps function allows you to limit the number of frames per second.
53
+		If a frame is rendered faster than expected, the TCOD_console_flush function will wait so that the frame rate never exceed this value.
54
+		You can call this function during your game initialization.
55
+		You can dynamically change the frame rate. Just call this function once again.
56
+		<b>You should always limit the frame rate, except during benchmarks, else your game will use 100% of the CPU power</b>
57
+	@Cpp static void TCODSystem::setFps(int val)
58
+	@C void TCOD_sys_set_fps(int val)
59
+	@Py sys_set_fps(val)
60
+	@C# static void TCODSystem::setFps(int val)
61
+	@Lua tcod.system.setFps(val)
62
+	@Param val Maximum number of frames per second. 0 means unlimited frame rate.
63
+	*/
64
+	static void setFps(int val);
65
+
66
+	/**
67
+	@PageName system_time
68
+	@FuncTitle Get the number of frames rendered during the last second
69
+	@FuncDesc The value returned by this function is updated every second.
70
+	@Cpp static int TCODSystem::getFps()
71
+	@C int TCOD_sys_get_fps()
72
+	@Py sys_get_fps()
73
+	@C# static int TCODSystem::getFps()
74
+	@Lua tcod.system.getFps()
75
+	*/
76
+	static int getFps();
77
+
78
+	/**
79
+	@PageName system_time
80
+	@FuncTitle Get the duration of the last frame
81
+	@FuncDesc This function returns the length in seconds of the last rendered frame.
82
+		You can use this value to update every time dependent object in the world.
83
+	@Cpp static float TCODSystem::getLastFrameLength()
84
+	@C float TCOD_sys_get_last_frame_length()
85
+	@Py sys_get_last_frame_length()
86
+	@C# static float TCODSystem::getLastFrameLength()
87
+	@Lua tcod.system.getLastFrameLength()
88
+	@CppEx
89
+		// moving an objet at 5 console cells per second
90
+		float x=0,y=0; // object coordinates
91
+		x += 5 * TCODSystem::getLastFrameLength();
92
+		TCODConsole::root->putChar((int)(x),(int)(y),'X');
93
+	@CEx
94
+		float x=0,y=0;
95
+		x += 5 * TCOD_sys_get_last_frame_length();
96
+		TCOD_console_put_char(NULL,(int)(x),(int)(y),'X');
97
+	@PyEx
98
+		x=0.0
99
+		y=0.0
100
+		x += 5 * libtcod.sys_get_last_frame_length()
101
+		libtcod.console_put_char(0,int(x),int(y),'X')
102
+	@LuaEx
103
+		-- moving an objet at 5 console cells per second
104
+		x=0
105
+		y=0 -- object coordinates
106
+		x = x + 5 * tcod.system.getLastFrameLength()
107
+		libtcod.TCODConsole_root:putChar(x,y,'X')
108
+	*/
109
+	static float getLastFrameLength();
110
+
111
+	/**
112
+	@PageName system_time
113
+	@FuncTitle Pause the program
114
+	@FuncDesc Use this function to stop the program execution for a specified number of milliseconds.
115
+	@Cpp static void TCODSystem::sleepMilli(uint32 val)
116
+	@C void TCOD_sys_sleep_milli(uint32 val)
117
+	@Py sys_sleep_milli(val)
118
+	@C# static void TCODSystem::sleepMilli(uint val)
119
+	@Lua tcod.system.sleepMilli(val)
120
+	@Param val number of milliseconds before the function returns
121
+	*/
122
+	static void sleepMilli(uint32 val);
123
+
124
+	/**
125
+	@PageName system_time
126
+	@FuncTitle Get global timer in milliseconds
127
+	@FuncDesc This function returns the number of milliseconds since the program has started.
128
+	@Cpp static uint32 TCODSystem::getElapsedMilli()
129
+	@C uint32 TCOD_sys_elapsed_milli()
130
+	@Py sys_elapsed_milli()
131
+	@C# static uint TCODSystem::getElapsedMilli()
132
+	@Lua tcod.system.getElapsedMilli()
133
+	*/
134
+	static uint32 getElapsedMilli();
135
+
136
+	/**
137
+	@PageName system_time
138
+	@FuncTitle Get global timer in seconds
139
+	@FuncDesc This function returns the number of seconds since the program has started.
140
+	@Cpp static float TCODSystem::getElapsedSeconds()
141
+	@C float TCOD_sys_elapsed_seconds()
142
+	@Py sys_elapsed_seconds()
143
+	@C# static float TCODSystem::getElapsedSeconds()
144
+	@Lua tcod.system.getElapsedSeconds()
145
+	*/
146
+	static float getElapsedSeconds();
147
+
148
+	/**
149
+	@PageName console_blocking_input
150
+	@FuncTitle Waiting for any event (mouse or keyboard)
151
+	@FuncDesc This function waits for an event from the user. The eventMask shows what events we're waiting for.
152
+		The return value indicate what event was actually triggered. Values in key and mouse structures are updated accordingly.
153
+		If flush is false, the function waits only if there are no pending events, else it returns the first event in the buffer.
154
+	@Cpp typedef enum {
155
+		TCOD_EVENT_NONE=0,
156
+		TCOD_EVENT_KEY_PRESS=1,
157
+		TCOD_EVENT_KEY_RELEASE=2,
158
+		TCOD_EVENT_KEY=TCOD_EVENT_KEY_PRESS|TCOD_EVENT_KEY_RELEASE,
159
+		TCOD_EVENT_MOUSE_MOVE=4,
160
+		TCOD_EVENT_MOUSE_PRESS=8,
161
+		TCOD_EVENT_MOUSE_RELEASE=16,
162
+		TCOD_EVENT_MOUSE=TCOD_EVENT_MOUSE_MOVE|TCOD_EVENT_MOUSE_PRESS|TCOD_EVENT_MOUSE_RELEASE,
163
+		TCOD_EVENT_ANY=TCOD_EVENT_KEY|TCOD_EVENT_MOUSE,		
164
+	} TCOD_event_t; 
165
+	static TCOD_event_t TCODSystem::waitForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse, bool flush)
166
+	@C TCOD_event_t TCOD_sys_wait_for_event(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse, bool flush)
167
+	@Py sys_wait_for_event(eventMask,key,mouse,flush)
168
+	@Param eventMask event types to wait for (other types are discarded)
169
+	@Param key updated in case of a key event. Can be null if eventMask contains no key event type
170
+	@Param mouse updated in case of a mouse event. Can be null if eventMask contains no mouse event type
171
+	@Param flush if true, all pending events are flushed from the buffer. Else, return the first available event
172
+	@CppEx
173
+		TCOD_key_t key;
174
+		TCOD_mouse_t mouse;
175
+		TCOD_event_t ev = TCODSystem::waitForEvent(TCOD_EVENT_ANY,&key,&mouse,true);
176
+		if ( ev == TCOD_EVENT_KEY_PRESS && key.c == 'i' ) { ... open inventory ... }
177
+	@CEx
178
+		TCOD_key_t key;
179
+		TCOD_mouse_t mouse;
180
+		TCOD_event_t ev = TCOD_sys_wait_for_event(TCOD_EVENT_ANY,&key,&mouse,true);
181
+		if ( ev == TCOD_EVENT_KEY_PRESS && key.c == 'i' ) { ... open inventory ... }	
182
+	*/
183
+	static TCOD_event_t waitForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse, bool flush);
184
+
185
+	/**
186
+	@PageName console_non_blocking_input
187
+	@FuncTitle Checking for any event (mouse or keyboard)
188
+	@FuncDesc This function checks if an event from the user is in the buffer. The eventMask shows what events we're waiting for.
189
+		The return value indicate what event was actually found. Values in key and mouse structures are updated accordingly.
190
+	@Cpp typedef enum {
191
+		TCOD_EVENT_KEY_PRESS=1,
192
+		TCOD_EVENT_KEY_RELEASE=2,
193
+		TCOD_EVENT_KEY=TCOD_EVENT_KEY_PRESS|TCOD_EVENT_KEY_RELEASE,
194
+		TCOD_EVENT_MOUSE_MOVE=4,
195
+		TCOD_EVENT_MOUSE_PRESS=8,
196
+		TCOD_EVENT_MOUSE_RELEASE=16,
197
+		TCOD_EVENT_MOUSE=TCOD_EVENT_MOUSE_MOVE|TCOD_EVENT_MOUSE_PRESS|TCOD_EVENT_MOUSE_RELEASE,
198
+		TCOD_EVENT_ANY=TCOD_EVENT_KEY|TCOD_EVENT_MOUSE,		
199
+	} TCOD_event_t; 
200
+	static TCOD_event_t TCODSystem::checkForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse)
201
+	@C TCOD_event_t TCOD_sys_check_for_event(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse)
202
+	@Py sys_check_for_event(eventMask,key,mouse)
203
+	@Param eventMask event types to wait for (other types are discarded)
204
+	@Param key updated in case of a key event. Can be null if eventMask contains no key event type
205
+	@Param mouse updated in case of a mouse event. Can be null if eventMask contains no mouse event type
206
+	@CppEx
207
+		TCOD_key_t key;
208
+		TCOD_mouse_t mouse;
209
+		TCOD_event_t ev = TCODSystem::checkForEvent(TCOD_EVENT_ANY,&key,&mouse);
210
+		if ( ev == TCOD_EVENT_KEY_PRESS && key.c == 'i' ) { ... open inventory ... }
211
+	@CEx
212
+		TCOD_key_t key;
213
+		TCOD_mouse_t mouse;
214
+		TCOD_event_t ev = TCOD_sys_check_for_event(TCOD_EVENT_ANY,&key,&mouse);
215
+		if ( ev == TCOD_EVENT_KEY_PRESS && key.c == 'i' ) { ... open inventory ... }	
216
+	*/
217
+	static TCOD_event_t checkForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse);
218
+	/**
219
+	@PageName system_screenshots
220
+	@PageFather system
221
+	@PageTitle Easy screenshots
222
+	@FuncDesc This function allows you to save the current game screen in a png file, or possibly a bmp file if you provide a filename ending with .bmp.
223
+	@Cpp static void TCODSystem::saveScreenshot(const char *filename)
224
+	@C void TCOD_sys_save_screenshot(const char *filename)
225
+	@Py sys_save_screenshot(filename)
226
+	@C# static void TCODSystem::saveScreenshot(string filename);
227
+	@Lua tcod.system.saveScreenshot(filename)
228
+	@Param filename Name of the file. If NULL, a filename is automatically generated with the form "./screenshotNNN.png", NNN being the first free number (if a file named screenshot000.png already exist, screenshot001.png will be used, and so on...).
229
+	*/
230
+	static void saveScreenshot(const char *filename);
231
+
232
+	/**
233
+	@PageName system_filesystem
234
+	@PageFather system
235
+	@PageTitle Filesystem utilities
236
+	@PageDesc Those are a few function that cannot be easily implemented in a portable way in C/C++. They have no python wrapper since python provides its own builtin functions. All those functions return false if an error occured.
237
+	@FuncTitle Create a directory
238
+	@Cpp static bool TCODSystem::createDirectory(const char *path)
239
+	@C bool TCOD_sys_create_directory(const char *path)
240
+	@Param path Directory path. The immediate father directory (<path>/..) must exist and be writable.
241
+	*/
242
+	static bool createDirectory(const char *path);
243
+
244
+	/**
245
+	@PageName system_filesystem
246
+	@FuncTitle Delete an empty directory
247
+	@Cpp static bool TCODSystem::deleteDirectory(const char *path)
248
+	@C bool TCOD_sys_delete_directory(const char *path)
249
+	@Param path directory path. This directory must exist, be writable and empty
250
+	*/
251
+	static bool deleteDirectory(const char *path);
252
+
253
+	/**
254
+	@PageName system_filesystem
255
+	@FuncTitle Delete a file
256
+	@Cpp static bool TCODSystem::deleteFile(const char *path)
257
+	@C bool TCOD_sys_delete_file(const char *path)
258
+	@Param path File path. This file must exist and be writable.
259
+	*/
260
+	static bool deleteFile(const char *path);
261
+
262
+	/**
263
+	@PageName system_filesystem
264
+	@FuncTitle Check if a path is a directory
265
+	@Cpp static bool TCODSystem::isDirectory(const char *path)
266
+	@C bool TCOD_sys_is_directory(const char *path)
267
+	@Param path a path to check
268
+	*/
269
+	static bool isDirectory(const char *path);
270
+
271
+	/**
272
+	@PageName system_filesystem
273
+	@FuncTitle List files in a directory
274
+	@FuncDesc To get the list of entries in a directory (including sub-directories, except . and ..).
275
+		The returned list is allocated by the function and must be deleted by you. All the const char * inside must be also freed with TCODList::clearAndDelete.
276
+	@Cpp static TCODList TCODSystem::getDirectoryContent(const char *path, const char *pattern)
277
+	@C TCOD_list_t TCOD_sys_get_directory_content(const char *path)
278
+	@Param path a directory
279
+	@Param pattern If NULL or empty, returns all directory entries. Else returns only entries matching the pattern. The pattern is NOT a regular expression. It can only handle one '*' wildcard. Examples : *.png, saveGame*, font*.png
280
+	*/
281
+	static TCOD_list_t getDirectoryContent(const char *path, const char *pattern);
282
+
283
+	/**
284
+	@PageName system_filesystem
285
+	@FuncTitle Check if a given file exists
286
+	@FuncDesc In order to check whether a given file exists in the filesystem. Useful for detecting errors caused by missing files.
287
+	@Cpp static bool TCODSystem::fileExists(const char *filename, ...)
288
+	@C bool TCOD_sys_file_exists(const char * filename, ...)
289
+	@Param filename the file name, using printf-like formatting
290
+	@Param ... optional arguments for filename formatting
291
+	@CppEx
292
+		if (!TCODSystem::fileExists("myfile.%s","txt")) {
293
+		    fprintf(stderr,"no such file!");
294
+		}
295
+	@CEx
296
+		if (!TCOD_sys_file_exists("myfile.%s","txt")) {
297
+		    fprintf(stderr,"no such file!");
298
+		}
299
+	*/
300
+	static bool fileExists(const char * filename, ...);
301
+	/**
302
+	@PageName system_filesystem
303
+	@FuncTitle Read the content of a file into memory
304
+	@FuncDesc This is a portable function to read the content of a file from disk or from the application apk (android).
305
+		buf must be freed with free(buf).
306
+	@Cpp static bool TCODSystem::readFile(const char *filename, unsigned char **buf, uint32 *size)
307
+	@C bool TCOD_sys_read_file(const char *filename, unsigned char **buf, uint32 *size)
308
+	@Param filename the file name
309
+	@Param buf a buffer to be allocated and filled with the file content
310
+	@Param size the size of the allocated buffer.
311
+	@CppEx
312
+		unsigned char *buf;
313
+		uint32 size;
314
+		if (TCODSystem::readFile("myfile.dat",&buf,&size)) {
315
+		    // do something with buf
316
+		    free(buf);
317
+		}
318
+	@CEx
319
+		if (TCOD_sys_read_file("myfile.dat",&buf,&size)) {
320
+		    // do something with buf
321
+		    free(buf);
322
+		}
323
+	*/	
324
+	static bool readFile(const char *filename, unsigned char **buf, size_t *size);
325
+	/**
326
+	@PageName system_filesystem
327
+	@FuncTitle Write the content of a memory buffer to a file
328
+	@FuncDesc This is a portable function to write some data to a file.
329
+	@Cpp static bool TCODSystem::writeFile(const char *filename, unsigned char *buf, uint32 size)
330
+	@C bool TCOD_sys_write_file(const char *filename, unsigned char *buf, uint32 size)
331
+	@Param filename the file name
332
+	@Param buf a buffer containing the data to write
333
+	@Param size the number of bytes to write.
334
+	@CppEx
335
+		TCODSystem::writeFile("myfile.dat",buf,size));
336
+	@CEx
337
+		TCOD_sys_write_file("myfile.dat",buf,size));
338
+	*/		
339
+	static bool writeFile(const char *filename, unsigned char *buf, uint32 size);
340
+	/**
341
+	@PageName system_sdlcbk
342
+	@PageFather system
343
+	@PageTitle Draw custom graphics on top of the root console
344
+	@PageDesc You can register a callback that will be called after the libtcod rendering phase, but before the screen buffer is swapped. This callback receives the screen SDL_Surface reference.
345
+		This makes it possible to use any SDL drawing functions (including openGL) on top of the libtcod console.
346
+	@FuncTitle Render custom graphics
347
+	@FuncDesc To disable the custom renderer, call the same method with a NULL parameter.
348
+		Note that to keep libtcod from requiring the SDL headers, the callback parameter is a void pointer. You have to include SDL headers and cast it to SDL_Surface in your code.
349
+	@Cpp
350
+		class TCODLIB_API ITCODSDLRenderer {
351
+		public :
352
+			virtual void render(void *sdlSurface) = 0;
353
+		};
354
+		static void TCODSystem::registerSDLRenderer(ITCODSDLRenderer *callback);
355
+	@C
356
+		typedef void (*SDL_renderer_t) (void *sdl_surface);
357
+		void TCOD_sys_register_SDL_renderer(SDL_renderer_t callback)
358
+	@Py
359
+		def renderer ( sdl_surface ) : ...
360
+		TCOD_sys_register_SDL_renderer( callback )
361
+	@Param callback The renderer to call before swapping the screen buffer. If NULL, custom rendering is disabled
362
+	@CppEx
363
+		class MyRenderer : public ITCODSDLRenderer {
364
+		public :
365
+			void render(void *sdlSurface) {
366
+				SDL_Surface *s = (SDL_Surface *)sdlSurface;
367
+				... draw something on s
368
+			}
369
+		};
370
+		TCODSystem::registerSDLRenderer(new MyRenderer());
371
+	@CEx
372
+		void my_renderer( void *sdl_surface ) {
373
+			SDL_Surface *s = (SDL_Surface *)sdl_surface;
374
+			... draw something on s
375
+		}
376
+		TCOD_sys_register_SDL_renderer(my_renderer);
377
+	@Py
378
+		def my_renderer(sdl_surface) :
379
+			... draw something on sdl_surface using pygame
380
+		libtcod.sys_register_SDL_renderer(my_renderer)
381
+	*/
382
+	static void registerSDLRenderer(ITCODSDLRenderer *renderer);
383
+
384
+	/**
385
+	@PageName system_sdlcbk
386
+	@FuncTitle Managing screen redraw
387
+	@FuncDesc libtcod is not aware of the part of the screen your SDL renderer has updated. If no change occured in the console, it won't redraw them except if you tell him to do so with this function
388
+	@Cpp void TCODConsole::setDirty(int x, int y, int w, int h)
389
+	@C void TCOD_console_set_dirty(int x, int y, int w, int h)
390
+	@Py TCOD_console_set_dirty(x, y, w, h)
391
+	@Param x,y,w,h Part of the root console you want to redraw even if nothing has changed in the console back/fore/char.
392
+	*/
393
+
394
+	/**
395
+	@PageName system_misc
396
+	@PageFather system
397
+	@PageTitle Miscellaneous utilities
398
+	@FuncTitle Using a custom resolution for the fullscreen mode
399
+	@FuncDesc This function allows you to force the use of a specific resolution in fullscreen mode.
400
+		The default resolution depends on the root console size and the font character size.
401
+	@Cpp static void TCODSystem::forceFullscreenResolution(int width, int height)
402
+	@C void TCOD_sys_force_fullscreen_resolution(int width, int height)
403
+	@Py sys_force_fullscreen_resolution(width, height)
404
+	@C# static void TCODSystem::forceFullscreenResolution(int width, int height);
405
+	@Lua tcod.system.forceFullscreenResolution(width,height)
406
+	@Param width,height Resolution to use when switching to fullscreen.
407
+		Will use the smallest available resolution so that :
408
+		resolution width >= width and resolution width >= root console width * font char width
409
+		resolution width >= height and resolution height >= root console height * font char height
410
+	@CppEx
411
+		TCODSystem::forceFullscreenResolution(800,600); // use 800x600 in fullscreen instead of 640x400
412
+		TCODConsole::initRoot(80,50,"",true); // 80x50 console with 8x8 char => 640x400 default resolution
413
+	@CEx
414
+		TCOD_sys_force_fullscreen_resolution(800,600);
415
+		TCOD_console_init_root(80,50,"",true);
416
+	@PyEx
417
+		libtcod.sys_force_fullscreen_resolution(800,600)
418
+		libtcod.console_init_root(80,50,"",True)
419
+	@LuaEx
420
+		tcod.system.forceFullscreenResolution(800,600) -- use 800x600 in fullscreen instead of 640x400
421
+		tcod.console.initRoot(80,50,"",true) -- 80x50 console with 8x8 char => 640x400 default resolution
422
+	*/
423
+	static void forceFullscreenResolution(int width, int height);
424
+
425
+	/**
426
+	@PageName system_misc
427
+	@FuncTitle Get current resolution
428
+	@FuncDesc You can get the current screen resolution with getCurrentResolution. You can use it for example to get the desktop resolution before initializing the root console.
429
+	@Cpp static void TCODSystem::getCurrentResolution(int *width, int *height)
430
+	@C void TCOD_sys_get_current_resolution(int *width, int *height)
431
+	@Py sys_get_current_resolution() # returns w,h
432
+	@C# static void TCODSystem::getCurrentResolution(out int w, out int h);
433
+	@Param width,height contains current resolution when the function returns
434
+	*/
435
+	static void getCurrentResolution(int *w, int *h);
436
+	/**
437
+	@PageName system_misc
438
+	@FuncTitle Get fullscreen offset
439
+	@FuncDesc If the fullscreen resolution does not matches the console size in pixels, black borders are added. This function returns the position in pixels of the console top left corner in the screen.
440
+	@Cpp static void TCODSystem::getFullscreenOffsets(int *offx, int *offy)
441
+	@C void TCOD_sys_get_fullscreen_offsets(int *offx, int *offy)
442
+	@C# static void TCODSystem::getFullscreenOffsets(out int offx, out int offy);
443
+	@Param offx,offy contains the position of the console on the screen when using fullscreen mode.
444
+	*/
445
+	static void getFullscreenOffsets(int *offx, int *offy);
446
+	/**
447
+	@PageName system_misc
448
+	@FuncTitle Get the font size
449
+	@FuncDesc You can get the size of the characters in the font
450
+	@Cpp static void TCODSystem::getCharSize(int *width, int *height)
451
+	@C void TCOD_sys_get_char_size(int *width, int *height)
452
+	@Py sys_get_char_size() # returns w,h
453
+	@C# static void TCODSystem::getCharSize(out int w, out int h);
454
+	@Param width,height contains a character size when the function returns
455
+	*/
456
+	static void getCharSize(int *w, int *h);
457
+
458
+	/**
459
+	@PageName system_misc
460
+	@FuncTitle Dynamically updating the font bitmap
461
+	@FuncDesc You can dynamically change the bitmap of a character in the font. All cells using this ascii code will be updated at next flush call.
462
+	@Cpp static void TCODSystem::updateChar(int asciiCode, int fontx, int fonty,const TCODImage *img,int x,int y)
463
+	@C void TCOD_sys_update_char(int asciiCode, int fontx, int fonty, TCOD_image_t img, int x, int y)
464
+	@Py sys_update_char(asciiCode,fontx,fonty,img,x,y)
465
+	@Param asciiCode ascii code corresponding to the character to update
466
+	@Param fontx,fonty coordinate of the character in the bitmap font (in characters, not pixels)
467
+	@Param img image containing the new character bitmap
468
+	@Param x,y position in pixels of the top-left corner of the character in the image
469
+	*/
470
+	static void updateChar(int asciiCode, int fontx, int fonty,const TCODImage *img,int x,int y);
471
+
472
+	/**
473
+	@PageName system_misc
474
+	@FuncTitle Dynamically change libtcod's internal renderer
475
+	@FuncDesc As of 1.5.1, libtcod contains 3 different renderers :
476
+		* SDL : historic libtcod renderer. Should work and be pretty fast everywhere
477
+		* OpenGL : requires OpenGL compatible video card. Might be much faster or much slower than SDL, depending on the drivers
478
+		* GLSDL : requires OpenGL 1.4 compatible video card with GL_ARB_shader_objects extension. Blazing fast if you have the proper hardware and drivers.
479
+		This function switches the current renderer dynamically.
480
+	@Cpp static void TCODSystem::setRenderer(TCOD_renderer_t renderer)
481
+	@C void TCOD_sys_set_renderer(TCOD_renderer_t renderer)
482
+	@Py sys_set_renderer(renderer)
483
+	@C# static void TCODSystem::setRenderer(TCODRendererType renderer);
484
+	@Param renderer Either TCOD_RENDERER_GLSL, TCOD_RENDERER_OPENGL or TCOD_RENDERER_SDL
485
+	*/
486
+	static void setRenderer(TCOD_renderer_t renderer);
487
+
488
+	/**
489
+	@PageName system_misc
490
+	@FuncTitle Get the current internal renderer
491
+	@Cpp static TCOD_renderer_t TCODSystem::getRenderer()
492
+	@C TCOD_renderer_t TCOD_sys_get_renderer()
493
+	@Py sys_get_renderer()
494
+	@C# static TCODRendererType TCODSystem::getRenderer();
495
+	*/
496
+	static TCOD_renderer_t getRenderer();
497
+
498
+	/**
499
+	@PageName system_clipboard
500
+	@PageTitle Clipboard integration
501
+	@PageDesc With these functions, you can copy data in your OS' clipboard from the game or retrieve data from the clipboard.
502
+	@PageFather system
503
+	@FuncTitle Copy data to the clipboard
504
+	@Cpp static void TCODSystem::setClipboard(const char *value)
505
+	@C void TCOD_sys_clipboard_set(const char *value)
506
+	@Param value Text to copy in the clipboard
507
+	*/
508
+	static void setClipboard(const char *value);
509
+
510
+	/**
511
+	@PageName system_clipboard
512
+	@FuncTitle Paste data from the clipboard
513
+	@Cpp static char *TCODSystem::getClipboard()
514
+	@C char *TCOD_sys_clipboard_get()
515
+	*/
516
+	static char *getClipboard();
517
+
518
+	// thread stuff
519
+	static int getNumCores();
520
+	static TCOD_thread_t newThread(int (*func)(void *), void *data);
521
+	static void deleteThread(TCOD_thread_t th);
522
+	static void waitThread(TCOD_thread_t th);
523
+	// mutex
524
+	static TCOD_mutex_t newMutex();
525
+	static void mutexIn(TCOD_mutex_t mut);
526
+	static void mutexOut(TCOD_mutex_t mut);
527
+	static void deleteMutex(TCOD_mutex_t mut);
528
+	// semaphore
529
+	static TCOD_semaphore_t newSemaphore(int initVal);
530
+	static void lockSemaphore(TCOD_semaphore_t sem);
531
+	static void unlockSemaphore(TCOD_semaphore_t sem);
532
+	static void deleteSemaphore( TCOD_semaphore_t sem);
533
+	// condition
534
+	static TCOD_cond_t newCondition();
535
+	static void signalCondition(TCOD_cond_t sem);
536
+	static void broadcastCondition(TCOD_cond_t sem);
537
+	static void waitCondition(TCOD_cond_t sem, TCOD_mutex_t mut);
538
+	static void deleteCondition( TCOD_cond_t sem);
539
+};
540
+
541
+#endif
0 542
new file mode 100644
... ...
@@ -0,0 +1,40 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_TREE_H
29
+#define _TCOD_TREE_H
30
+
31
+typedef struct _TCOD_tree_t {
32
+	struct _TCOD_tree_t *next;
33
+	struct _TCOD_tree_t *father;
34
+	struct _TCOD_tree_t *sons;
35
+} TCOD_tree_t;
36
+
37
+TCODLIB_API TCOD_tree_t *TCOD_tree_new();
38
+TCODLIB_API void TCOD_tree_add_son(TCOD_tree_t *node, TCOD_tree_t *son);
39
+
40
+#endif
0 41
new file mode 100644
... ...
@@ -0,0 +1,51 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_TREE_HPP
29
+#define _TCOD_TREE_HPP
30
+
31
+class TCODLIB_API TCODTree {
32
+public :
33
+	TCODTree *next;
34
+	TCODTree *father;
35
+	TCODTree *sons;
36
+
37
+	TCODTree() : next(NULL),father(NULL),sons(NULL){}
38
+	void addSon(TCODTree *data) {
39
+		data->father=this;
40
+		TCODTree *lastson = sons;
41
+		while ( lastson && lastson->next ) lastson=lastson->next;
42
+		if ( lastson ) {
43
+			lastson->next=data;
44
+		} else {
45
+			sons=data;
46
+		}
47
+	}
48
+
49
+};
50
+
51
+#endif
0 52
new file mode 100644
... ...
@@ -0,0 +1,45 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+
29
+#ifndef _TCOD_TEXT_H_
30
+#define _TCOD_TEXT_H_
31
+
32
+typedef void * TCOD_text_t;
33
+
34
+TCODLIB_API TCOD_text_t TCOD_text_init(int x, int y, int w, int h, int max_chars);
35
+TCODLIB_API TCOD_text_t TCOD_text_init2(int w, int h, int max_chars);
36
+TCODLIB_API void TCOD_text_set_pos(TCOD_text_t txt, int x, int y);
37
+TCODLIB_API void TCOD_text_set_properties(TCOD_text_t txt, int cursor_char, int blink_interval, const char * prompt, int tab_size);
38
+TCODLIB_API void TCOD_text_set_colors(TCOD_text_t txt, TCOD_color_t fore, TCOD_color_t back, float back_transparency);
39
+TCODLIB_API bool TCOD_text_update(TCOD_text_t txt, TCOD_key_t key);
40
+TCODLIB_API void TCOD_text_render(TCOD_text_t txt, TCOD_console_t con);
41
+TCODLIB_API const char * TCOD_text_get(TCOD_text_t txt);
42
+TCODLIB_API void TCOD_text_reset(TCOD_text_t txt);
43
+TCODLIB_API void TCOD_text_delete(TCOD_text_t txt);
44
+
45
+#endif
0 46
new file mode 100644
... ...
@@ -0,0 +1,50 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_TEXT_HPP_
29
+#define _TCOD_TEXT_HPP_
30
+
31
+#include "color.hpp"
32
+
33
+class TCODLIB_API TCODText {
34
+public :
35
+	TCODText(int x, int y, int w, int h, int max_chars);
36
+	TCODText(int w, int h, int max_chars);
37
+	~TCODText();
38
+	void setProperties(int cursor_char, int blink_interval, const char * prompt, int tab_size);
39
+	void setColors(TCODColor fore, TCODColor back, float back_transparency);
40
+	void setPos(int x, int y);
41
+	bool update(TCOD_key_t key);
42
+	void render(TCODConsole * con);
43
+	const char *getText();
44
+	void reset();
45
+protected :
46
+	TCOD_text_t data;
47
+};
48
+
49
+
50
+#endif
0 51
new file mode 100644
... ...
@@ -0,0 +1,148 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef WRAPPERS_H
28
+#define WRAPPERS_H
29
+
30
+/* wrappers to ease other languages integration */
31
+typedef unsigned int colornum_t;
32
+
33
+/* color module */
34
+TCODLIB_API bool TCOD_color_equals_wrapper (colornum_t c1, colornum_t c2);
35
+TCODLIB_API colornum_t TCOD_color_add_wrapper (colornum_t c1,
36
+						 colornum_t c2);
37
+TCODLIB_API colornum_t TCOD_color_subtract_wrapper (colornum_t c1,
38
+						 colornum_t c2);
39
+TCODLIB_API colornum_t TCOD_color_multiply_wrapper (colornum_t c1,
40
+						      colornum_t c2);
41
+TCODLIB_API colornum_t TCOD_color_multiply_scalar_wrapper (colornum_t c1,
42
+							     float value);
43
+TCODLIB_API colornum_t TCOD_color_lerp_wrapper(colornum_t c1,
44
+						 colornum_t c2, float coef);
45
+TCODLIB_API void TCOD_color_get_HSV_wrapper(colornum_t c,float * h,
46
+					    float * s, float * v);
47
+TCODLIB_API float TCOD_color_get_hue_ (colornum_t c);
48
+TCODLIB_API float TCOD_color_get_saturation_ (colornum_t c);
49
+TCODLIB_API float TCOD_color_get_value_ (colornum_t c);
50
+
51
+/* console module */
52
+/* TCODLIB_API void TCOD_console_set_custom_font_wrapper(const char *fontFile,
53
+                        int char_width, int char_height, int nb_char_horiz,
54
+                        int nb_char_vertic, bool chars_by_row,
55
+                        colornum_t key_color); */
56
+
57
+TCODLIB_API void TCOD_console_set_default_background_wrapper(TCOD_console_t con,
58
+						   colornum_t col);
59
+TCODLIB_API void TCOD_console_set_default_foreground_wrapper(TCOD_console_t con,
60
+						   colornum_t col);
61
+TCODLIB_API colornum_t TCOD_console_get_default_background_wrapper(TCOD_console_t con);
62
+TCODLIB_API colornum_t TCOD_console_get_default_foreground_wrapper(TCOD_console_t con);
63
+TCODLIB_API colornum_t TCOD_console_get_char_background_wrapper(TCOD_console_t con,
64
+						       int x, int y);
65
+TCODLIB_API void TCOD_console_set_char_background_wrapper(TCOD_console_t con,int x, int y,
66
+                                      colornum_t col,
67
+                                      TCOD_bkgnd_flag_t flag);
68
+TCODLIB_API colornum_t TCOD_console_get_char_foreground_wrapper (TCOD_console_t con,
69
+                                              int x, int y);
70
+TCODLIB_API void TCOD_console_set_char_foreground_wrapper(TCOD_console_t con,int x, int y,
71
+                                      colornum_t col);
72
+TCODLIB_API void TCOD_console_put_char_ex_wrapper(TCOD_console_t con, int x,
73
+	int y, int c, colornum_t fore, colornum_t back);
74
+TCODLIB_API void TCOD_console_set_fade_wrapper(uint8 val, colornum_t fade);
75
+TCODLIB_API colornum_t TCOD_console_get_fading_color_wrapper();
76
+TCODLIB_API void TCOD_console_set_color_control_wrapper(TCOD_colctrl_t con,
77
+						colornum_t fore,
78
+						colornum_t back);
79
+TCODLIB_API bool TCOD_console_check_for_keypress_wrapper(TCOD_key_t *holder,
80
+							 int flags);
81
+TCODLIB_API void TCOD_console_wait_for_keypress_wrapper(TCOD_key_t *holder,
82
+							bool flush);
83
+TCODLIB_API uint32 TCOD_console_check_for_keypress_bitfield (int flags);
84
+TCODLIB_API uint32 TCOD_console_wait_for_keypress_bitfield (bool flush);
85
+TCODLIB_API void TCOD_console_fill_background(TCOD_console_t con, int *r, int *g, int *b);
86
+TCODLIB_API void TCOD_console_fill_foreground(TCOD_console_t con, int *r, int *g, int *b);
87
+TCODLIB_API void TCOD_console_fill_char(TCOD_console_t con, int *arr);
88
+
89
+TCODLIB_API void TCOD_console_double_hline(TCOD_console_t con,int x,int y, int l,
90
+					   TCOD_bkgnd_flag_t flag);
91
+TCODLIB_API void TCOD_console_double_vline(TCOD_console_t con,int x,int y,
92
+					   int l, TCOD_bkgnd_flag_t flag);
93
+TCODLIB_API void TCOD_console_print_double_frame(TCOD_console_t con,int x,int y,
94
+						 int w,int h, bool empty,
95
+						 TCOD_bkgnd_flag_t flag,
96
+						 const char *fmt, ...);
97
+
98
+TCODLIB_API char *TCOD_console_print_return_string(TCOD_console_t con,int x,
99
+						   int y, int rw, int rh,
100
+						   TCOD_bkgnd_flag_t flag,
101
+						   TCOD_alignment_t align, char *msg,
102
+						   bool can_split,
103
+						   bool count_only);
104
+TCODLIB_API void console_set_key_color_wrapper (TCOD_console_t con, colornum_t c);
105
+
106
+/* image module */
107
+
108
+TCODLIB_API void TCOD_image_clear_wrapper(TCOD_image_t image,
109
+					  colornum_t color);
110
+TCODLIB_API colornum_t TCOD_image_get_pixel_wrapper(TCOD_image_t image,
111
+						      int x, int y);
112
+TCODLIB_API colornum_t TCOD_image_get_mipmap_pixel_wrapper(TCOD_image_t image,
113
+				 float x0,float y0, float x1, float y1);
114
+TCODLIB_API void TCOD_image_put_pixel_wrapper(TCOD_image_t image,int x, int y,
115
+				      colornum_t col);
116
+TCODLIB_API void TCOD_image_set_key_color_wrapper(TCOD_image_t image,
117
+					  colornum_t key_color);
118
+
119
+/* mouse module */
120
+TCODLIB_API void TCOD_mouse_get_status_wrapper(TCOD_mouse_t *holder);
121
+TCODLIB_API int TCOD_mouse_get_x();
122
+TCODLIB_API int TCOD_mouse_get_y();
123
+TCODLIB_API int TCOD_mouse_get_cx();
124
+TCODLIB_API int TCOD_mouse_get_cy();
125
+TCODLIB_API int TCOD_mouse_get_dx();
126
+TCODLIB_API int TCOD_mouse_get_dy();
127
+TCODLIB_API int TCOD_mouse_get_dcx();
128
+TCODLIB_API int TCOD_mouse_get_dcy();
129
+TCODLIB_API uint32 TCOD_mouse_get_lbutton();
130
+TCODLIB_API uint32 TCOD_mouse_get_mbutton();
131
+TCODLIB_API uint32 TCOD_mouse_get_rbutton();
132
+TCODLIB_API uint32 TCOD_mouse_get_lbutton_pressed();
133
+TCODLIB_API uint32 TCOD_mouse_get_mbutton_pressed();
134
+TCODLIB_API uint32 TCOD_mouse_get_rbutton_pressed();
135
+
136
+/* parser module */
137
+TCODLIB_API colornum_t TCOD_parser_get_color_property_wrapper(TCOD_parser_t parser, const char *name);
138
+
139
+/* namegen module */
140
+TCODLIB_API int TCOD_namegen_get_nb_sets_wrapper();
141
+TCODLIB_API void TCOD_namegen_get_sets_wrapper(char **sets);
142
+
143
+/* sys module */
144
+TCODLIB_API int TCOD_sys_get_current_resolution_x();
145
+TCODLIB_API int TCOD_sys_get_current_resolution_y();
146
+
147
+#endif	/* WRAPPERS_H */
148
+
0 149
new file mode 100644
... ...
@@ -0,0 +1,62 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_ZIP_H
29
+#define _TCOD_ZIP_H
30
+
31
+typedef void *TCOD_zip_t;
32
+
33
+TCODLIB_API TCOD_zip_t TCOD_zip_new();
34
+TCODLIB_API void TCOD_zip_delete(TCOD_zip_t zip);
35
+
36
+/* output interface */
37
+TCODLIB_API void TCOD_zip_put_char(TCOD_zip_t zip, char val);
38
+TCODLIB_API void TCOD_zip_put_int(TCOD_zip_t zip, int val);
39
+TCODLIB_API void TCOD_zip_put_float(TCOD_zip_t zip, float val);
40
+TCODLIB_API void TCOD_zip_put_string(TCOD_zip_t zip, const char *val);
41
+TCODLIB_API void TCOD_zip_put_color(TCOD_zip_t zip, const TCOD_color_t val);
42
+TCODLIB_API void TCOD_zip_put_image(TCOD_zip_t zip, const TCOD_image_t val);
43
+TCODLIB_API void TCOD_zip_put_console(TCOD_zip_t zip, const TCOD_console_t val);
44
+TCODLIB_API void TCOD_zip_put_data(TCOD_zip_t zip, int nbBytes, const void *data);
45
+TCODLIB_API uint32 TCOD_zip_get_current_bytes(TCOD_zip_t zip);
46
+TCODLIB_API int TCOD_zip_save_to_file(TCOD_zip_t zip, const char *filename);
47
+
48
+/* input interface */
49
+TCODLIB_API int TCOD_zip_load_from_file(TCOD_zip_t zip, const char *filename);
50
+TCODLIB_API char TCOD_zip_get_char(TCOD_zip_t zip);
51
+TCODLIB_API int TCOD_zip_get_int(TCOD_zip_t zip);
52
+TCODLIB_API float TCOD_zip_get_float(TCOD_zip_t zip);
53
+TCODLIB_API const char *TCOD_zip_get_string(TCOD_zip_t zip);
54
+TCODLIB_API TCOD_color_t TCOD_zip_get_color(TCOD_zip_t zip);
55
+TCODLIB_API TCOD_image_t TCOD_zip_get_image(TCOD_zip_t zip);
56
+TCODLIB_API TCOD_console_t TCOD_zip_get_console(TCOD_zip_t zip);
57
+TCODLIB_API int TCOD_zip_get_data(TCOD_zip_t zip, int nbBytes, void *data);
58
+TCODLIB_API uint32 TCOD_zip_get_remaining_bytes(TCOD_zip_t zip);
59
+TCODLIB_API void TCOD_zip_skip_bytes(TCOD_zip_t zip, uint32 nbBytes);
60
+
61
+#endif
62
+
0 63
new file mode 100644
... ...
@@ -0,0 +1,331 @@
1
+/*
2
+* libtcod 1.6.0
3
+* Copyright (c) 2008,2009,2010,2012,2013 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
+#ifndef _TCOD_ZIP_HPP
29
+#define _TCOD_ZIP_HPP
30
+
31
+/**
32
+ @PageName zip
33
+ @PageCategory Base toolkits
34
+ @PageTitle Compression toolkit
35
+ @PageDesc This toolkit provides functions to save or read compressed data from a file. While the module is named Zip, it has nothing to do with the .zip format as it uses zlib compression (.gz format).
36
+	Note that this modules has no python wrapper. Use python built-in zip module instead.
37
+	
38
+	You can use the compression buffer in two modes:
39
+	* put data in the buffer, then save it to a file,
40
+	* load a file into the buffer, then get data from it.
41
+ */
42
+class TCODLIB_API TCODZip {
43
+public :
44
+
45
+	/**
46
+	@PageName zip_init
47
+	@PageFather zip
48
+	@PageTitle Creating a compression buffer
49
+	@FuncDesc This function initializes a compression buffer.
50
+	@Cpp TCODZip::TCODZip()
51
+	@C TCOD_zip_t TCOD_zip_new()	
52
+	*/	
53
+	TCODZip();
54
+	
55
+	/**
56
+	@PageName zip_init
57
+	@FuncDesc Once you don't need the buffer anymore, you can release resources. Note that the adresses returned by the getString function are no longer valid once the buffer has been destroyed.
58
+	@Cpp TCODZip::~TCODZip()
59
+	@C void TCOD_zip_delete(TCOD_zip_t zip)
60
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
61
+	@CppEx 
62
+		TCODZip *zip = new TCODZip();
63
+		zip->loadFromFile("myCompressedFile.gz");
64
+		char c=zip->getChar();
65
+		int i=zip->getInt();
66
+		float f= zip->getFloat();
67
+		const char *s=strdup(zip->getString()); // we duplicate the string to be able to use it after the buffer deletion
68
+		zip->getData(nbBytes, dataPtr);
69
+		delete zip;
70
+	@CEx 
71
+		TCOD_zip_t zip=TCOD_zip_new();
72
+		TCOD_zip_load_from_file(zip,"myCompressedFile.gz");
73
+		char c=TCOD_zip_get_char(zip);
74
+		int i=TCOD_zip_get_int(zip);
75
+		float f=TCOD_zip_get_float(zip);
76
+		const char *s=strdup(TCOD_zip_get_string(zip));
77
+		TCOD_zip_get_data(zip,nbBytes, dataPtr);
78
+		TCOD_zip_delete(zip);	
79
+	*/	
80
+	~TCODZip();
81
+
82
+	/**
83
+	@PageName zip_put
84
+	@PageFather zip
85
+	@PageTitle Using the buffer in output mode
86
+	@FuncTitle Putting a char in the buffer
87
+	@Cpp void TCODZip::putChar(char val)
88
+	@C void TCOD_zip_put_char(TCOD_zip_t zip, char val)
89
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
90
+	@Param val	A 8 bits value to store in the buffer
91
+	*/	
92
+	void putChar(char val);
93
+	
94
+	/**
95
+	@PageName zip_put
96
+	@FuncTitle Putting an integer in the buffer
97
+	@Cpp void TCODZip::putInt(int val)
98
+	@C void TCOD_zip_put_int(TCOD_zip_t zip, int val)
99
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
100
+	@Param val	An integer value to store in the buffer
101
+	*/	
102
+	void putInt(int val);
103
+
104
+	/**
105
+	@PageName zip_put
106
+	@FuncTitle Putting a floating point value in the buffer
107
+	@Cpp void TCODZip::putFloat(float val)
108
+	@C void TCOD_zip_put_float(TCOD_zip_t zip, float val)
109
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
110
+	@Param val	A float value to store in the buffer
111
+	*/
112
+	void putFloat(float val);
113
+
114
+	/**
115
+	@PageName zip_put
116
+	@FuncTitle Putting a string in the buffer
117
+	@Cpp void TCODZip::putString(const char *val)
118
+	@C void TCOD_zip_put_string(TCOD_zip_t zip, const char *val)
119
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
120
+	@Param val	A string to store in the buffer
121
+	*/
122
+	void putString(const char *val);
123
+
124
+   	/**
125
+	@PageName zip_put
126
+	@FuncTitle Putting a color in the buffer
127
+	@Cpp void TCODZip::putColor(const TCODColor *val)
128
+	@C void TCOD_zip_put_color(TCOD_zip_t zip, const TCOD_color_t val)
129
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
130
+	@Param val	A color to store in the buffer
131
+	*/
132
+	void putColor(const TCODColor *val);
133
+
134
+	/**
135
+	@PageName zip_put
136
+	@FuncTitle Putting an image in the buffer
137
+	@Cpp void TCODZip::putImage(const TCODImage *val)
138
+	@C void TCOD_zip_put_image(TCOD_zip_t zip, const TCOD_image_t val)
139
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
140
+	@Param val	An image to store in the buffer
141
+	*/
142
+	void putImage(const TCODImage *val);
143
+
144
+	/**
145
+	@PageName zip_put
146
+	@FuncTitle Putting a console in the buffer
147
+	@Cpp void TCODZip::putConsole(const TCODConsole *val)
148
+	@C void TCOD_zip_put_console(TCOD_zip_t zip, const TCOD_console_t val)
149
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
150
+	@Param val	A console to store in the buffer
151
+	*/
152
+	void putConsole(const TCODConsole *val);
153
+
154
+	/**
155
+	@PageName zip_put
156
+	@FuncTitle Putting some custom data in the buffer
157
+	@Cpp void TCODZip::putData(int nbBytes, const void *data)
158
+	@C void TCOD_zip_put_data(TCOD_zip_t zip, int nbBytes, const void *data)
159
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
160
+	@Param nbBytes	Number of bytes to store in the buffer
161
+	@Param val	Address of the data to store in the buffer
162
+	*/
163
+	void putData(int nbBytes, const void *data);
164
+
165
+	/**
166
+	@PageName zip_put
167
+	@FuncTitle Reading the number of (uncompressed) bytes in the buffer
168
+	@Cpp uint32 TCODZip::getCurrentBytes()
169
+	@C uint32 TCOD_zip_get_current_bytes(TCOD_zip_t zip)
170
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
171
+	*/	
172
+	uint32 getCurrentBytes() const;
173
+	
174
+	/**
175
+	@PageName zip_put
176
+	@FuncTitle Saving the buffer on disk
177
+	@FuncDesc Once you have finished adding data in the buffer, you can compress it and save it in a file.
178
+		The function returns the number of (uncompressed) bytes saved.
179
+	@Cpp int TCODZip::saveToFile(const char *filename)
180
+	@C int TCOD_zip_save_to_file(TCOD_zip_t zip, const char *filename)
181
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
182
+	@Param filename	Name of the file
183
+	@CppEx 
184
+		TCODZip zip;
185
+		zip.putChar('A');
186
+		zip.putInt(1764);
187
+		zip.putFloat(3.14f);
188
+		zip.putString("A string");
189
+		zip.putData(nbBytes, dataPtr);
190
+		zip.saveToFile("myCompressedFile.gz");
191
+	@CEx 
192
+		TCOD_zip_t zip=TCOD_zip_new();
193
+		TCOD_zip_put_char(zip,'A');
194
+		TCOD_zip_put_int(zip,1764);
195
+		TCOD_zip_put_float(zip,3.14f);
196
+		TCOD_zip_put_string(zip,"A string");
197
+		TCOD_zip_put_data(zip,nbBytes, dataPtr);
198
+		TCOD_zip_save_to_file(zip,"myCompressedFile.gz");
199
+	*/	
200
+	int saveToFile(const char *filename);
201
+
202
+	/**
203
+	@PageName zip_load
204
+	@PageTitle Using the buffer in input mode
205
+	@PageFather zip
206
+	@FuncTitle Reading from a compressed file
207
+	@FuncDesc You can read data from a file (compressed or not) into the buffer.
208
+		The function returns the number of (uncompressed) bytes read or 0 if an error occured. 
209
+	@Cpp int TCODZip::loadFromFile(const char *filename)
210
+	@C int TCOD_zip_load_from_file(TCOD_zip_t zip, const char *filename)
211
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
212
+	@Param filename	Name of the file
213
+	*/	
214
+	int loadFromFile(const char *filename);
215
+	
216
+	/**
217
+	@PageName zip_load
218
+	@FuncTitle Reading a char from the buffer
219
+	@Cpp char TCODZip::getChar()
220
+	@C char TCOD_zip_get_char(TCOD_zip_t zip)
221
+	@Param zip	In the C version, the buffer handler, returned by the constructor
222
+	*/	
223
+	char getChar();
224
+	
225
+	/**
226
+	@PageName zip_load
227
+	@FuncTitle Reading an integer from the buffer
228
+	@Cpp int TCODZip::getInt()
229
+	@C int TCOD_zip_get_int(TCOD_zip_t zip)
230
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
231
+	*/	
232
+	int getInt();
233
+	
234
+	/**
235
+	@PageName zip_load
236
+	@FuncTitle Reading a floating point value from the buffer
237
+	@Cpp float TCODZip::getFloat()
238
+	@C float TCOD_zip_get_float(TCOD_zip_t zip)
239
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
240
+	*/	
241
+	float getFloat();
242
+	
243
+	/**
244
+	@PageName zip_load
245
+	@FuncTitle Reading a string from the buffer
246
+	@FuncDesc The address returned is in the buffer. It is valid as long as you don't destroy the buffer.
247
+	@Cpp const char *TCODZip::getString()
248
+	@C const char *TCOD_zip_get_string(TCOD_zip_t zip)
249
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
250
+	*/	
251
+	const char *getString();
252
+	
253
+	/**
254
+	@PageName zip_load
255
+	@FuncTitle Reading a color from the buffer
256
+	@Cpp TCODColor TCODZip::getColor()
257
+	@C TCOD_color_t TCOD_zip_get_color(TCOD_zip_t zip)
258
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
259
+	*/	
260
+	TCODColor getColor();
261
+	
262
+	/**
263
+	@PageName zip_load
264
+	@FuncTitle Reading a color from the buffer
265
+	@Cpp TCODImage *TCODZip::getImage()
266
+	@C TCOD_image_t TCOD_zip_get_image(TCOD_zip_t zip)
267
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
268
+	*/	
269
+	TCODImage *getImage();
270
+	
271
+	/**
272
+	@PageName zip_load
273
+	@FuncTitle Reading a console from the buffer
274
+	@Cpp TCODConsole *TCODZip::getConsole()
275
+	@C TCOD_console_t TCOD_zip_get_console(TCOD_zip_t zip)
276
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
277
+	*/	
278
+	TCODConsole *getConsole();
279
+	
280
+	/**
281
+	@PageName zip_load
282
+	@FuncTitle Reading some custom data from the buffer
283
+	@FuncDesc Note that the getData length must match the length of the data when the file was created (with putData).
284
+		The function returns the number of bytes that were stored in the file by the putData call. If more than nbBytes were stored, the function read only nbBytes and skip the rest of them.
285
+	@Cpp int TCODZip::getData(int nbBytes, void *data)
286
+	@C int TCOD_zip_get_data(TCOD_zip_t zip, int nbBytes, void *data)
287
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
288
+	@Param nbBytes	Number of bytes to read
289
+	@Param data	Address of a pre-allocated buffer (at least nbBytes bytes)
290
+	@CppEx 
291
+		TCODZip zip;
292
+		zip.loadFromFile("myCompressedFile.gz");
293
+		char c=zip.getChar();
294
+		int i=zip.getInt();
295
+		float f= zip.getFloat();
296
+		const char *s=zip.getString();
297
+		zip.getData(nbBytes, dataPtr);
298
+	@CEx 
299
+		TCOD_zip_t zip=TCOD_zip_new();
300
+		TCOD_zip_load_from_file(zip,"myCompressedFile.gz");
301
+		char c=TCOD_zip_get_char(zip);
302
+		int i=TCOD_zip_get_int(zip);
303
+		float f=TCOD_zip_get_float(zip);
304
+		const char *s=TCOD_zip_get_string(zip);
305
+		TCOD_zip_get_data(zip,nbBytes, dataPtr);
306
+	*/	
307
+	int getData(int nbBytes, void *data);
308
+	
309
+	/**
310
+	@PageName zip_load
311
+	@FuncTitle Getting the number of remaining bytes in the buffer
312
+	@Cpp uint32 TCODZip::getRemainingBytes() const
313
+	@C uint32 TCOD_zip_get_remaining_bytes(TCOD_zip_t zip)
314
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
315
+	*/	
316
+	uint32 getRemainingBytes() const;
317
+
318
+	/**
319
+	@PageName zip_load
320
+	@FuncTitle Skiping some bytes in the buffer
321
+	@Cpp void TCODZip::skipBytes(uint32 nbBytes)
322
+	@C void TCOD_zip_skip_bytes(TCOD_zip_t zip, uint32 nbBytes)
323
+	@Param zip	In the C version, the buffer handler, returned by the constructor.
324
+	@Param nbBytes number of uncompressed bytes to skip
325
+	*/	
326
+	void skipBytes(uint32 nbBytes);
327
+protected :
328
+	TCOD_zip_t data;
329
+};
330
+
331
+#endif
0 332
new file mode 100755
1 333
Binary files /dev/null and b/libtcod.so differ
2 334
new file mode 100755
3 335
Binary files /dev/null and b/libtcod_debug.so differ
4 336
new file mode 100755
5 337
Binary files /dev/null and b/libtcodgui.so differ
6 338
new file mode 100755
7 339
Binary files /dev/null and b/libtcodgui_debug.so differ
8 340
new file mode 100644
... ...
@@ -0,0 +1,1973 @@
1
+#
2
+# libtcod 1.6.0 python wrapper
3
+# Copyright (c) 2008,2009,2010,2012,2013 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
+elif sys.platform.find('haiku') != -1:
53
+    _lib = ctypes.cdll['./libtcod.so']
54
+    HAIKU = True
55
+else:
56
+    try:
57
+        _lib = ctypes.cdll['./libtcod-mingw.dll']
58
+        MINGW=True
59
+    except WindowsError:
60
+        _lib = ctypes.cdll['./libtcod-VS.dll']
61
+        MSVC=True
62
+    # On Windows, ctypes doesn't work well with function returning structs,
63
+    # so we have to user the _wrapper functions instead
64
+    _lib.TCOD_color_multiply = _lib.TCOD_color_multiply_wrapper
65
+    _lib.TCOD_color_add = _lib.TCOD_color_add_wrapper
66
+    _lib.TCOD_color_multiply_scalar = _lib.TCOD_color_multiply_scalar_wrapper
67
+    _lib.TCOD_color_subtract = _lib.TCOD_color_subtract_wrapper
68
+    _lib.TCOD_color_lerp = _lib.TCOD_color_lerp_wrapper
69
+    _lib.TCOD_console_get_default_background = _lib.TCOD_console_get_default_background_wrapper
70
+    _lib.TCOD_console_get_default_foreground = _lib.TCOD_console_get_default_foreground_wrapper
71
+    _lib.TCOD_console_get_char_background = _lib.TCOD_console_get_char_background_wrapper
72
+    _lib.TCOD_console_get_char_foreground = _lib.TCOD_console_get_char_foreground_wrapper
73
+    _lib.TCOD_console_get_fading_color = _lib.TCOD_console_get_fading_color_wrapper
74
+    _lib.TCOD_image_get_pixel = _lib.TCOD_image_get_pixel_wrapper
75
+    _lib.TCOD_image_get_mipmap_pixel = _lib.TCOD_image_get_mipmap_pixel_wrapper
76
+    _lib.TCOD_parser_get_color_property = _lib.TCOD_parser_get_color_property_wrapper
77
+
78
+HEXVERSION = 0x010600
79
+STRVERSION = "1.6.0"
80
+TECHVERSION = 0x01060000
81
+
82
+############################
83
+# color module
84
+############################
85
+class Color(Structure):
86
+    _fields_ = [('r', c_uint8),
87
+                ('g', c_uint8),
88
+                ('b', c_uint8),
89
+                ]
90
+
91
+    def __eq__(self, c):
92
+        return _lib.TCOD_color_equals(self, c)
93
+
94
+    def __mul__(self, c):
95
+        if isinstance(c,Color):
96
+            return _lib.TCOD_color_multiply(self, c)
97
+        else:
98
+            return _lib.TCOD_color_multiply_scalar(self, c_float(c))
99
+
100
+    def __add__(self, c):
101
+        return _lib.TCOD_color_add(self, c)
102
+
103
+    def __sub__(self, c):
104
+        return _lib.TCOD_color_subtract(self, c)
105
+
106
+    def __repr__(self):
107
+        return "Color(%d,%d,%d)" % (self.r, self.g, self.b)
108
+
109
+    def __getitem__(self, i):
110
+        if type(i) == str:
111
+            return getattr(self, i)
112
+        else:
113
+            return getattr(self, "rgb"[i])
114
+
115
+    def __setitem__(self, i, c):
116
+        if type(i) == str:
117
+            setattr(self, i, c)
118
+        else:
119
+            setattr(self, "rgb"[i], c)
120
+
121
+    def __iter__(self):
122
+        yield self.r
123
+        yield self.g
124
+        yield self.b
125
+
126
+# Should be valid on any platform, check it!  Has to be done after Color is defined.
127
+if MAC:
128
+    from cprotos import setup_protos
129
+    setup_protos(_lib)
130
+
131
+_lib.TCOD_color_equals.restype = c_bool
132
+_lib.TCOD_color_multiply.restype = Color
133
+_lib.TCOD_color_multiply_scalar.restype = Color
134
+_lib.TCOD_color_add.restype = Color
135
+_lib.TCOD_color_subtract.restype = Color
136
+
137
+# default colors
138
+# grey levels
139
+black=Color(0,0,0)
140
+darkest_grey=Color(31,31,31)
141
+darker_grey=Color(63,63,63)
142
+dark_grey=Color(95,95,95)
143
+grey=Color(127,127,127)
144
+light_grey=Color(159,159,159)
145
+lighter_grey=Color(191,191,191)
146
+lightest_grey=Color(223,223,223)
147
+darkest_gray=Color(31,31,31)
148
+darker_gray=Color(63,63,63)
149
+dark_gray=Color(95,95,95)
150
+gray=Color(127,127,127)
151
+light_gray=Color(159,159,159)
152
+lighter_gray=Color(191,191,191)
153
+lightest_gray=Color(223,223,223)
154
+white=Color(255,255,255)
155
+
156
+# sepia
157
+darkest_sepia=Color(31,24,15)
158
+darker_sepia=Color(63,50,31)
159
+dark_sepia=Color(94,75,47)
160
+sepia=Color(127,101,63)
161
+light_sepia=Color(158,134,100)
162
+lighter_sepia=Color(191,171,143)
163
+lightest_sepia=Color(222,211,195)
164
+
165
+#standard colors
166
+red=Color(255,0,0)
167
+flame=Color(255,63,0)
168
+orange=Color(255,127,0)
169
+amber=Color(255,191,0)
170
+yellow=Color(255,255,0)
171
+lime=Color(191,255,0)
172
+chartreuse=Color(127,255,0)
173
+green=Color(0,255,0)
174
+sea=Color(0,255,127)
175
+turquoise=Color(0,255,191)
176
+cyan=Color(0,255,255)
177
+sky=Color(0,191,255)
178
+azure=Color(0,127,255)
179
+blue=Color(0,0,255)
180
+han=Color(63,0,255)
181
+violet=Color(127,0,255)
182
+purple=Color(191,0,255)
183
+fuchsia=Color(255,0,255)
184
+magenta=Color(255,0,191)
185
+pink=Color(255,0,127)
186
+crimson=Color(255,0,63)
187
+
188
+# dark colors
189
+dark_red=Color(191,0,0)
190
+dark_flame=Color(191,47,0)
191
+dark_orange=Color(191,95,0)
192
+dark_amber=Color(191,143,0)
193
+dark_yellow=Color(191,191,0)
194
+dark_lime=Color(143,191,0)
195
+dark_chartreuse=Color(95,191,0)
196
+dark_green=Color(0,191,0)
197
+dark_sea=Color(0,191,95)
198
+dark_turquoise=Color(0,191,143)
199
+dark_cyan=Color(0,191,191)
200
+dark_sky=Color(0,143,191)
201
+dark_azure=Color(0,95,191)
202
+dark_blue=Color(0,0,191)
203
+dark_han=Color(47,0,191)
204
+dark_violet=Color(95,0,191)
205
+dark_purple=Color(143,0,191)
206
+dark_fuchsia=Color(191,0,191)
207
+dark_magenta=Color(191,0,143)
208
+dark_pink=Color(191,0,95)
209
+dark_crimson=Color(191,0,47)
210
+
211
+# darker colors
212
+darker_red=Color(127,0,0)
213
+darker_flame=Color(127,31,0)
214
+darker_orange=Color(127,63,0)
215
+darker_amber=Color(127,95,0)
216
+darker_yellow=Color(127,127,0)
217
+darker_lime=Color(95,127,0)
218
+darker_chartreuse=Color(63,127,0)
219
+darker_green=Color(0,127,0)
220
+darker_sea=Color(0,127,63)
221
+darker_turquoise=Color(0,127,95)
222
+darker_cyan=Color(0,127,127)
223
+darker_sky=Color(0,95,127)
224
+darker_azure=Color(0,63,127)
225
+darker_blue=Color(0,0,127)
226
+darker_han=Color(31,0,127)
227
+darker_violet=Color(63,0,127)
228
+darker_purple=Color(95,0,127)
229
+darker_fuchsia=Color(127,0,127)
230
+darker_magenta=Color(127,0,95)
231
+darker_pink=Color(127,0,63)
232
+darker_crimson=Color(127,0,31)
233
+
234
+# darkest colors
235
+darkest_red=Color(63,0,0)
236
+darkest_flame=Color(63,15,0)
237
+darkest_orange=Color(63,31,0)
238
+darkest_amber=Color(63,47,0)
239
+darkest_yellow=Color(63,63,0)
240
+darkest_lime=Color(47,63,0)
241
+darkest_chartreuse=Color(31,63,0)
242
+darkest_green=Color(0,63,0)
243
+darkest_sea=Color(0,63,31)
244
+darkest_turquoise=Color(0,63,47)
245
+darkest_cyan=Color(0,63,63)
246
+darkest_sky=Color(0,47,63)
247
+darkest_azure=Color(0,31,63)
248
+darkest_blue=Color(0,0,63)
249
+darkest_han=Color(15,0,63)
250
+darkest_violet=Color(31,0,63)
251
+darkest_purple=Color(47,0,63)
252
+darkest_fuchsia=Color(63,0,63)
253
+darkest_magenta=Color(63,0,47)
254
+darkest_pink=Color(63,0,31)
255
+darkest_crimson=Color(63,0,15)
256
+
257
+# light colors
258
+light_red=Color(255,114,114)
259
+light_flame=Color(255,149,114)
260
+light_orange=Color(255,184,114)
261
+light_amber=Color(255,219,114)
262
+light_yellow=Color(255,255,114)
263
+light_lime=Color(219,255,114)
264
+light_chartreuse=Color(184,255,114)
265
+light_green=Color(114,255,114)
266
+light_sea=Color(114,255,184)
267
+light_turquoise=Color(114,255,219)
268
+light_cyan=Color(114,255,255)
269
+light_sky=Color(114,219,255)
270
+light_azure=Color(114,184,255)
271
+light_blue=Color(114,114,255)
272
+light_han=Color(149,114,255)
273
+light_violet=Color(184,114,255)
274
+light_purple=Color(219,114,255)
275
+light_fuchsia=Color(255,114,255)
276
+light_magenta=Color(255,114,219)
277
+light_pink=Color(255,114,184)
278
+light_crimson=Color(255,114,149)
279
+
280
+#lighter colors
281
+lighter_red=Color(255,165,165)
282
+lighter_flame=Color(255,188,165)
283
+lighter_orange=Color(255,210,165)
284
+lighter_amber=Color(255,232,165)
285
+lighter_yellow=Color(255,255,165)
286
+lighter_lime=Color(232,255,165)
287
+lighter_chartreuse=Color(210,255,165)
288
+lighter_green=Color(165,255,165)
289
+lighter_sea=Color(165,255,210)
290
+lighter_turquoise=Color(165,255,232)
291
+lighter_cyan=Color(165,255,255)
292
+lighter_sky=Color(165,232,255)
293
+lighter_azure=Color(165,210,255)
294
+lighter_blue=Color(165,165,255)
295
+lighter_han=Color(188,165,255)
296
+lighter_violet=Color(210,165,255)
297
+lighter_purple=Color(232,165,255)
298
+lighter_fuchsia=Color(255,165,255)
299
+lighter_magenta=Color(255,165,232)
300
+lighter_pink=Color(255,165,210)
301
+lighter_crimson=Color(255,165,188)
302
+
303
+# lightest colors
304
+lightest_red=Color(255,191,191)
305
+lightest_flame=Color(255,207,191)
306
+lightest_orange=Color(255,223,191)
307
+lightest_amber=Color(255,239,191)
308
+lightest_yellow=Color(255,255,191)
309
+lightest_lime=Color(239,255,191)
310
+lightest_chartreuse=Color(223,255,191)
311
+lightest_green=Color(191,255,191)
312
+lightest_sea=Color(191,255,223)
313
+lightest_turquoise=Color(191,255,239)
314
+lightest_cyan=Color(191,255,255)
315
+lightest_sky=Color(191,239,255)
316
+lightest_azure=Color(191,223,255)
317
+lightest_blue=Color(191,191,255)
318
+lightest_han=Color(207,191,255)
319
+lightest_violet=Color(223,191,255)
320
+lightest_purple=Color(239,191,255)
321
+lightest_fuchsia=Color(255,191,255)
322
+lightest_magenta=Color(255,191,239)
323
+lightest_pink=Color(255,191,223)
324
+lightest_crimson=Color(255,191,207)
325
+
326
+# desaturated colors
327
+desaturated_red=Color(127,63,63)
328
+desaturated_flame=Color(127,79,63)
329
+desaturated_orange=Color(127,95,63)
330
+desaturated_amber=Color(127,111,63)
331
+desaturated_yellow=Color(127,127,63)
332
+desaturated_lime=Color(111,127,63)
333
+desaturated_chartreuse=Color(95,127,63)
334
+desaturated_green=Color(63,127,63)
335
+desaturated_sea=Color(63,127,95)
336
+desaturated_turquoise=Color(63,127,111)
337
+desaturated_cyan=Color(63,127,127)
338
+desaturated_sky=Color(63,111,127)
339
+desaturated_azure=Color(63,95,127)
340
+desaturated_blue=Color(63,63,127)
341
+desaturated_han=Color(79,63,127)
342
+desaturated_violet=Color(95,63,127)
343
+desaturated_purple=Color(111,63,127)
344
+desaturated_fuchsia=Color(127,63,127)
345
+desaturated_magenta=Color(127,63,111)
346
+desaturated_pink=Color(127,63,95)
347
+desaturated_crimson=Color(127,63,79)
348
+
349
+# metallic
350
+brass=Color(191,151,96)
351
+copper=Color(197,136,124)
352
+gold=Color(229,191,0)
353
+silver=Color(203,203,203)
354
+
355
+# miscellaneous
356
+celadon=Color(172,255,175)
357
+peach=Color(255,159,127)
358
+
359
+# color functions
360
+_lib.TCOD_color_lerp.restype = Color
361
+def color_lerp(c1, c2, a):
362
+    return _lib.TCOD_color_lerp(c1, c2, c_float(a))
363
+
364
+def color_set_hsv(c, h, s, v):
365
+    _lib.TCOD_color_set_HSV(byref(c), c_float(h), c_float(s), c_float(v))
366
+
367
+def color_get_hsv(c):
368
+    h = c_float()
369
+    s = c_float()
370
+    v = c_float()
371
+    _lib.TCOD_color_get_HSV(c, byref(h), byref(s), byref(v))
372
+    return h.value, s.value, v.value
373
+
374
+def color_scale_HSV(c, scoef, vcoef) :
375
+    _lib.TCOD_color_scale_HSV(byref(c),c_float(scoef),c_float(vcoef))
376
+
377
+def color_gen_map(colors, indexes):
378
+    ccolors = (Color * len(colors))(*colors)
379
+    cindexes = (c_int * len(indexes))(*indexes)
380
+    cres = (Color * (max(indexes) + 1))()
381
+    _lib.TCOD_color_gen_map(cres, len(colors), ccolors, cindexes)
382
+    return cres
383
+
384
+############################
385
+# console module
386
+############################
387
+class Key(Structure):
388
+    _fields_=[('vk', c_int),
389
+              ('c', c_uint8),
390
+              ('pressed', c_bool),
391
+              ('lalt', c_bool),
392
+              ('lctrl', c_bool),
393
+              ('ralt', c_bool),
394
+              ('rctrl', c_bool),
395
+              ('shift', c_bool),
396
+              ]
397
+
398
+class ConsoleBuffer:
399
+    # simple console that allows direct (fast) access to cells. simplifies
400
+    # use of the "fill" functions.
401
+    def __init__(self, width, height, back_r=0, back_g=0, back_b=0, fore_r=0, fore_g=0, fore_b=0, char=' '):
402
+        # initialize with given width and height. values to fill the buffer
403
+        # are optional, defaults to black with no characters.
404
+        n = width * height
405
+        self.width = width
406
+        self.height = height
407
+        self.clear(back_r, back_g, back_b, fore_r, fore_g, fore_b, char)
408
+
409
+    def clear(self, back_r=0, back_g=0, back_b=0, fore_r=0, fore_g=0, fore_b=0, char=' '):
410
+        # clears the console. values to fill it with are optional, defaults
411
+        # to black with no characters.
412
+        n = self.width * self.height
413
+        self.back_r = [back_r] * n
414
+        self.back_g = [back_g] * n
415
+        self.back_b = [back_b] * n
416
+        self.fore_r = [fore_r] * n
417
+        self.fore_g = [fore_g] * n
418
+        self.fore_b = [fore_b] * n
419
+        self.char = [ord(char)] * n
420
+    
421
+    def copy(self):
422
+        # returns a copy of this ConsoleBuffer.
423
+        other = ConsoleBuffer(0, 0)
424
+        other.width = self.width
425
+        other.height = self.height
426
+        other.back_r = list(self.back_r)  # make explicit copies of all lists
427
+        other.back_g = list(self.back_g)
428
+        other.back_b = list(self.back_b)
429
+        other.fore_r = list(self.fore_r)
430
+        other.fore_g = list(self.fore_g)
431
+        other.fore_b = list(self.fore_b)
432
+        other.char = list(self.char)
433
+        return other
434
+    
435
+    def set_fore(self, x, y, r, g, b, char):
436
+        # set the character and foreground color of one cell.
437
+        i = self.width * y + x
438
+        self.fore_r[i] = r
439
+        self.fore_g[i] = g
440
+        self.fore_b[i] = b
441
+        self.char[i] = ord(char)
442
+    
443
+    def set_back(self, x, y, r, g, b):
444
+        # set the background color of one cell.
445
+        i = self.width * y + x
446
+        self.back_r[i] = r
447
+        self.back_g[i] = g
448
+        self.back_b[i] = b
449
+    
450
+    def set(self, x, y, back_r, back_g, back_b, fore_r, fore_g, fore_b, char):
451
+        # set the background color, foreground color and character of one cell.
452
+        i = self.width * y + x
453
+        self.back_r[i] = back_r
454
+        self.back_g[i] = back_g
455
+        self.back_b[i] = back_b
456
+        self.fore_r[i] = fore_r
457
+        self.fore_g[i] = fore_g
458
+        self.fore_b[i] = fore_b
459
+        self.char[i] = ord(char)
460
+    
461
+    def blit(self, dest, fill_fore=True, fill_back=True):
462
+        # use libtcod's "fill" functions to write the buffer to a console.
463
+        if (console_get_width(dest) != self.width or
464
+            console_get_height(dest) != self.height):
465
+            raise ValueError('ConsoleBuffer.blit: Destination console has an incorrect size.')
466
+
467
+        s = struct.Struct('%di' % len(self.back_r))
468
+
469
+        if fill_back:
470
+            _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))
471
+
472
+        if fill_fore:
473
+            _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))
474
+            _lib.TCOD_console_fill_char(dest, (c_int * len(self.char))(*self.char))
475
+
476
+_lib.TCOD_console_credits_render.restype = c_bool
477
+_lib.TCOD_console_is_fullscreen.restype = c_bool
478
+_lib.TCOD_console_is_window_closed.restype = c_bool
479
+_lib.TCOD_console_has_mouse_focus.restype = c_bool
480
+_lib.TCOD_console_is_active.restype = c_bool
481
+_lib.TCOD_console_get_default_background.restype = Color
482
+_lib.TCOD_console_get_default_foreground.restype = Color
483
+_lib.TCOD_console_get_char_background.restype = Color
484
+_lib.TCOD_console_get_char_foreground.restype = Color
485
+_lib.TCOD_console_get_fading_color.restype = Color
486
+_lib.TCOD_console_is_key_pressed.restype = c_bool
487
+
488
+# background rendering modes
489
+BKGND_NONE = 0
490
+BKGND_SET = 1
491
+BKGND_MULTIPLY = 2
492
+BKGND_LIGHTEN = 3
493
+BKGND_DARKEN = 4
494
+BKGND_SCREEN = 5
495
+BKGND_COLOR_DODGE = 6
496
+BKGND_COLOR_BURN = 7
497
+BKGND_ADD = 8
498
+BKGND_ADDA = 9
499
+BKGND_BURN = 10
500
+BKGND_OVERLAY = 11
501
+BKGND_ALPH = 12
502
+BKGND_DEFAULT=13
503
+
504
+def BKGND_ALPHA(a):
505
+    return BKGND_ALPH | (int(a * 255) << 8)
506
+
507
+def BKGND_ADDALPHA(a):
508
+    return BKGND_ADDA | (int(a * 255) << 8)
509
+
510
+# non blocking key events types
511
+KEY_PRESSED = 1
512
+KEY_RELEASED = 2
513
+# key codes
514
+KEY_NONE = 0
515
+KEY_ESCAPE = 1
516
+KEY_BACKSPACE = 2
517
+KEY_TAB = 3
518
+KEY_ENTER = 4
519
+KEY_SHIFT = 5
520
+KEY_CONTROL = 6
521
+KEY_ALT = 7
522
+KEY_PAUSE = 8
523
+KEY_CAPSLOCK = 9
524
+KEY_PAGEUP = 10
525
+KEY_PAGEDOWN = 11
526
+KEY_END = 12
527
+KEY_HOME = 13
528
+KEY_UP = 14
529
+KEY_LEFT = 15
530
+KEY_RIGHT = 16
531
+KEY_DOWN = 17
532
+KEY_PRINTSCREEN = 18
533
+KEY_INSERT = 19
534
+KEY_DELETE = 20
535
+KEY_LWIN = 21
536
+KEY_RWIN = 22
537
+KEY_APPS = 23
538
+KEY_0 = 24
539
+KEY_1 = 25
540
+KEY_2 = 26
541
+KEY_3 = 27
542
+KEY_4 = 28
543
+KEY_5 = 29
544
+KEY_6 = 30
545
+KEY_7 = 31
546
+KEY_8 = 32
547
+KEY_9 = 33
548
+KEY_KP0 = 34
549
+KEY_KP1 = 35
550
+KEY_KP2 = 36
551
+KEY_KP3 = 37
552
+KEY_KP4 = 38
553
+KEY_KP5 = 39
554
+KEY_KP6 = 40
555
+KEY_KP7 = 41
556
+KEY_KP8 = 42
557
+KEY_KP9 = 43
558
+KEY_KPADD = 44
559
+KEY_KPSUB = 45
560
+KEY_KPDIV = 46
561
+KEY_KPMUL = 47
562
+KEY_KPDEC = 48
563
+KEY_KPENTER = 49
564
+KEY_F1 = 50
565
+KEY_F2 = 51
566
+KEY_F3 = 52
567
+KEY_F4 = 53
568
+KEY_F5 = 54
569
+KEY_F6 = 55
570
+KEY_F7 = 56
571
+KEY_F8 = 57
572
+KEY_F9 = 58
573
+KEY_F10 = 59
574
+KEY_F11 = 60
575
+KEY_F12 = 61
576
+KEY_NUMLOCK = 62
577
+KEY_SCROLLLOCK = 63
578
+KEY_SPACE = 64
579
+KEY_CHAR = 65
580
+# special chars
581
+# single walls
582
+CHAR_HLINE = 196
583
+CHAR_VLINE = 179
584
+CHAR_NE = 191
585
+CHAR_NW = 218
586
+CHAR_SE = 217
587
+CHAR_SW = 192
588
+CHAR_TEEW = 180
589
+CHAR_TEEE = 195
590
+CHAR_TEEN = 193
591
+CHAR_TEES = 194
592
+CHAR_CROSS = 197
593
+# double walls
594
+CHAR_DHLINE = 205
595
+CHAR_DVLINE = 186
596
+CHAR_DNE = 187
597
+CHAR_DNW = 201
598
+CHAR_DSE = 188
599
+CHAR_DSW = 200
600
+CHAR_DTEEW = 185
601
+CHAR_DTEEE = 204
602
+CHAR_DTEEN = 202
603
+CHAR_DTEES = 203
604
+CHAR_DCROSS = 206
605
+# blocks
606
+CHAR_BLOCK1 = 176
607
+CHAR_BLOCK2 = 177
608
+CHAR_BLOCK3 = 178
609
+# arrows
610
+CHAR_ARROW_N = 24
611
+CHAR_ARROW_S = 25
612
+CHAR_ARROW_E = 26
613
+CHAR_ARROW_W = 27
614
+# arrows without tail
615
+CHAR_ARROW2_N = 30
616
+CHAR_ARROW2_S = 31
617
+CHAR_ARROW2_E = 16
618
+CHAR_ARROW2_W = 17
619
+# double arrows
620
+CHAR_DARROW_H = 29
621
+CHAR_DARROW_V = 18
622
+# GUI stuff
623
+CHAR_CHECKBOX_UNSET = 224
624
+CHAR_CHECKBOX_SET = 225
625
+CHAR_RADIO_UNSET = 9
626
+CHAR_RADIO_SET = 10
627
+# sub-pixel resolution kit
628
+CHAR_SUBP_NW = 226
629
+CHAR_SUBP_NE = 227
630
+CHAR_SUBP_N = 228
631
+CHAR_SUBP_SE = 229
632
+CHAR_SUBP_DIAG = 230
633
+CHAR_SUBP_E = 231
634
+CHAR_SUBP_SW = 232
635
+# misc characters
636
+CHAR_BULLET = 7
637
+CHAR_BULLET_INV = 8
638
+CHAR_BULLET_SQUARE = 254
639
+CHAR_CENT = 189
640
+CHAR_CLUB = 5
641
+CHAR_COPYRIGHT = 184
642
+CHAR_CURRENCY = 207
643
+CHAR_DIAMOND = 4
644
+CHAR_DIVISION = 246
645
+CHAR_EXCLAM_DOUBLE = 19
646
+CHAR_FEMALE = 12
647
+CHAR_FUNCTION = 159
648
+CHAR_GRADE = 248
649
+CHAR_HALF = 171
650
+CHAR_HEART = 3
651
+CHAR_LIGHT = 15
652
+CHAR_MALE = 11
653
+CHAR_MULTIPLICATION = 158
654
+CHAR_NOTE = 13
655
+CHAR_NOTE_DOUBLE = 14
656
+CHAR_ONE_QUARTER = 172
657
+CHAR_PILCROW = 20
658
+CHAR_POUND = 156
659
+CHAR_POW1 = 251
660
+CHAR_POW2 = 253
661
+CHAR_POW3 = 252
662
+CHAR_RESERVED = 169
663
+CHAR_SECTION = 21
664
+CHAR_SMILIE = 1
665
+CHAR_SMILIE_INV = 2
666
+CHAR_SPADE = 6
667
+CHAR_THREE_QUARTERS = 243
668
+CHAR_UMLAUT = 249
669
+CHAR_YEN = 190
670
+# font flags
671
+FONT_LAYOUT_ASCII_INCOL = 1
672
+FONT_LAYOUT_ASCII_INROW = 2
673
+FONT_TYPE_GREYSCALE = 4
674
+FONT_TYPE_GRAYSCALE = 4
675
+FONT_LAYOUT_TCOD = 8
676
+# color control codes
677
+COLCTRL_1=1
678
+COLCTRL_2=2
679
+COLCTRL_3=3
680
+COLCTRL_4=4
681
+COLCTRL_5=5
682
+COLCTRL_NUMBER=5
683
+COLCTRL_FORE_RGB=6
684
+COLCTRL_BACK_RGB=7
685
+COLCTRL_STOP=8
686
+# renderers
687
+RENDERER_GLSL=0
688
+RENDERER_OPENGL=1
689
+RENDERER_SDL=2
690
+NB_RENDERERS=3
691
+# alignment
692
+LEFT=0
693
+RIGHT=1
694
+CENTER=2
695
+# initializing the console
696
+def console_init_root(w, h, title, fullscreen=False, renderer=RENDERER_SDL):
697
+    _lib.TCOD_console_init_root(w, h, c_char_p(title), fullscreen, renderer)
698
+
699
+def console_get_width(con):
700
+    return _lib.TCOD_console_get_width(con)
701
+
702
+def console_get_height(con):
703
+    return _lib.TCOD_console_get_height(con)
704
+
705
+def console_set_custom_font(fontFile, flags=FONT_LAYOUT_ASCII_INCOL, nb_char_horiz=0, nb_char_vertic=0):
706
+    _lib.TCOD_console_set_custom_font(c_char_p(fontFile), flags, nb_char_horiz, nb_char_vertic)
707
+
708
+def console_map_ascii_code_to_font(asciiCode, fontCharX, fontCharY):
709
+    if type(asciiCode) == str or type(asciiCode) == bytes:
710
+        _lib.TCOD_console_map_ascii_code_to_font(ord(asciiCode), fontCharX,
711
+                                                 fontCharY)
712
+    else:
713
+        _lib.TCOD_console_map_ascii_code_to_font(asciiCode, fontCharX,
714
+                                                 fontCharY)
715
+
716
+def console_map_ascii_codes_to_font(firstAsciiCode, nbCodes, fontCharX,
717
+                                    fontCharY):
718
+    if type(firstAsciiCode) == str or type(firstAsciiCode) == bytes:
719
+        _lib.TCOD_console_map_ascii_codes_to_font(ord(firstAsciiCode), nbCodes,
720
+                                                  fontCharX, fontCharY)
721
+    else:
722
+        _lib.TCOD_console_map_ascii_codes_to_font(firstAsciiCode, nbCodes,
723
+                                                  fontCharX, fontCharY)
724
+
725
+def console_map_string_to_font(s, fontCharX, fontCharY):
726
+    if type(s) == bytes:
727
+        _lib.TCOD_console_map_string_to_font(s, fontCharX, fontCharY)
728
+    else:
729
+        _lib.TCOD_console_map_string_to_font_utf(s, fontCharX, fontCharY)
730
+
731
+def console_is_fullscreen():
732
+    return _lib.TCOD_console_is_fullscreen()
733
+
734
+def console_set_fullscreen(fullscreen):
735
+    _lib.TCOD_console_set_fullscreen(c_int(fullscreen))
736
+
737
+def console_is_window_closed():
738
+    return _lib.TCOD_console_is_window_closed()
739
+
740
+def console_has_mouse_focus():
741
+    return _lib.TCOD_console_has_mouse_focus()
742
+
743
+def console_is_active():
744
+    return _lib.TCOD_console_is_active()
745
+
746
+def console_set_window_title(title):
747
+    _lib.TCOD_console_set_window_title(c_char_p(title))
748
+
749
+def console_credits():
750
+    _lib.TCOD_console_credits()
751
+
752
+def console_credits_reset():
753
+    _lib.TCOD_console_credits_reset()
754
+
755
+def console_credits_render(x, y, alpha):
756
+    return _lib.TCOD_console_credits_render(x, y, c_int(alpha))
757
+
758
+def console_flush():
759
+    _lib.TCOD_console_flush()
760
+
761
+# drawing on a console
762
+def console_set_default_background(con, col):
763
+    _lib.TCOD_console_set_default_background(con, col)
764
+
765
+def console_set_default_foreground(con, col):
766
+    _lib.TCOD_console_set_default_foreground(con, col)
767
+
768
+def console_clear(con):
769
+    return _lib.TCOD_console_clear(con)
770
+
771
+def console_put_char(con, x, y, c, flag=BKGND_DEFAULT):
772
+    if type(c) == str or type(c) == bytes:
773
+        _lib.TCOD_console_put_char(con, x, y, ord(c), flag)
774
+    else:
775
+        _lib.TCOD_console_put_char(con, x, y, c, flag)
776
+
777
+def console_put_char_ex(con, x, y, c, fore, back):
778
+    if type(c) == str or type(c) == bytes:
779
+        _lib.TCOD_console_put_char_ex(con, x, y, ord(c), fore, back)
780
+    else:
781
+        _lib.TCOD_console_put_char_ex(con, x, y, c, fore, back)
782
+
783
+def console_set_char_background(con, x, y, col, flag=BKGND_SET):
784
+    _lib.TCOD_console_set_char_background(con, x, y, col, flag)
785
+
786
+def console_set_char_foreground(con, x, y, col):
787
+    _lib.TCOD_console_set_char_foreground(con, x, y, col)
788
+
789
+def console_set_char(con, x, y, c):
790
+    if type(c) == str or type(c) == bytes:
791
+        _lib.TCOD_console_set_char(con, x, y, ord(c))
792
+    else:
793
+        _lib.TCOD_console_set_char(con, x, y, c)
794
+
795
+def console_set_background_flag(con, flag):
796
+    _lib.TCOD_console_set_background_flag(con, c_int(flag))
797
+
798
+def console_get_background_flag(con):
799
+    return _lib.TCOD_console_get_background_flag(con)
800
+
801
+def console_set_alignment(con, alignment):
802
+    _lib.TCOD_console_set_alignment(con, c_int(alignment))
803
+
804
+def console_get_alignment(con):
805
+    return _lib.TCOD_console_get_alignment(con)
806
+
807
+def console_print(con, x, y, fmt):
808
+    if type(fmt) == bytes:
809
+        _lib.TCOD_console_print(c_void_p(con), x, y, c_char_p(fmt))
810
+    else:
811
+        _lib.TCOD_console_print_utf(c_void_p(con), x, y, fmt)
812
+
813
+def console_print_ex(con, x, y, flag, alignment, fmt):
814
+    if type(fmt) == bytes:
815
+        _lib.TCOD_console_print_ex(c_void_p(con), x, y, flag, alignment, c_char_p(fmt))
816
+    else:
817
+        _lib.TCOD_console_print_ex_utf(c_void_p(con), x, y, flag, alignment, fmt)
818
+
819
+def console_print_rect(con, x, y, w, h, fmt):
820
+    if type(fmt) == bytes:
821
+        return _lib.TCOD_console_print_rect(c_void_p(con), x, y, w, h, c_char_p(fmt))
822
+    else:
823
+        return _lib.TCOD_console_print_rect_utf(c_void_p(con), x, y, w, h, fmt)
824
+
825
+def console_print_rect_ex(con, x, y, w, h, flag, alignment, fmt):
826
+    if type(fmt) == bytes:
827
+        return _lib.TCOD_console_print_rect_ex(c_void_p(con), x, y, w, h, flag, alignment, c_char_p(fmt))
828
+    else:
829
+        return _lib.TCOD_console_print_rect_ex_utf(c_void_p(con), x, y, w, h, flag, alignment, fmt)
830
+
831
+def console_get_height_rect(con, x, y, w, h, fmt):
832
+    if type(fmt) == bytes:
833
+        return _lib.TCOD_console_get_height_rect(c_void_p(con), x, y, w, h, c_char_p(fmt))
834
+    else:
835
+        return _lib.TCOD_console_get_height_rect_utf(c_void_p(con), x, y, w, h, fmt)
836
+
837
+def console_rect(con, x, y, w, h, clr, flag=BKGND_DEFAULT):
838
+    _lib.TCOD_console_rect(con, x, y, w, h, c_int(clr), flag)
839
+
840
+def console_hline(con, x, y, l, flag=BKGND_DEFAULT):
841
+    _lib.TCOD_console_hline( con, x, y, l, flag)
842
+
843
+def console_vline(con, x, y, l, flag=BKGND_DEFAULT):
844
+    _lib.TCOD_console_vline( con, x, y, l, flag)
845
+
846
+def console_print_frame(con, x, y, w, h, clear=True, flag=BKGND_DEFAULT, fmt=0):
847
+    _lib.TCOD_console_print_frame(c_void_p(con), x, y, w, h, c_int(clear), flag, c_char_p(fmt))
848
+
849
+def console_set_color_control(con,fore,back) :
850
+    _lib.TCOD_console_set_color_control(con,fore,back)
851
+
852
+def console_get_default_background(con):
853
+    return _lib.TCOD_console_get_default_background(con)
854
+
855
+def console_get_default_foreground(con):
856
+    return _lib.TCOD_console_get_default_foreground(con)
857
+
858
+def console_get_char_background(con, x, y):
859
+    return _lib.TCOD_console_get_char_background(con, x, y)
860
+
861
+def console_get_char_foreground(con, x, y):
862
+    return _lib.TCOD_console_get_char_foreground(con, x, y)
863
+
864
+def console_get_char(con, x, y):
865
+    return _lib.TCOD_console_get_char(con, x, y)
866
+
867
+def console_set_fade(fade, fadingColor):
868
+    _lib.TCOD_console_set_fade(fade, fadingColor)
869
+    ##_lib.TCOD_console_set_fade_wrapper(fade, fadingColor)
870
+
871
+def console_get_fade():
872
+    return _lib.TCOD_console_get_fade().value
873
+
874
+def console_get_fading_color():
875
+    return _lib.TCOD_console_get_fading_color()
876
+
877
+# handling keyboard input
878
+def console_wait_for_keypress(flush):
879
+    k=Key()
880
+    _lib.TCOD_console_wait_for_keypress_wrapper(byref(k),c_bool(flush))
881
+    return k
882
+
883
+def console_check_for_keypress(flags=KEY_RELEASED):
884
+    k=Key()
885
+    _lib.TCOD_console_check_for_keypress_wrapper(byref(k),c_int(flags))
886
+    return k
887
+
888
+def console_is_key_pressed(key):
889
+    return _lib.TCOD_console_is_key_pressed(key)
890
+
891
+def console_set_keyboard_repeat(initial_delay, interval):
892
+    _lib.TCOD_console_set_keyboard_repeat(initial_delay, interval)
893
+
894
+def console_disable_keyboard_repeat():
895
+    _lib.TCOD_console_disable_keyboard_repeat()
896
+
897
+# using offscreen consoles
898
+def console_new(w, h):
899
+    return _lib.TCOD_console_new(w, h)
900
+def console_from_file(filename):
901
+    return _lib.TCOD_console_from_file(filename)
902
+def console_get_width(con):
903
+    return _lib.TCOD_console_get_width(con)
904
+
905
+def console_get_height(con):
906
+    return _lib.TCOD_console_get_height(con)
907
+
908
+def console_blit(src, x, y, w, h, dst, xdst, ydst, ffade=1.0,bfade=1.0):
909
+    _lib.TCOD_console_blit(src, x, y, w, h, dst, xdst, ydst, c_float(ffade), c_float(bfade))
910
+
911
+def console_set_key_color(con, col):
912
+    _lib.TCOD_console_set_key_color(con, col)
913
+
914
+def console_delete(con):
915
+    _lib.TCOD_console_delete(con)
916
+
917
+# fast color filling
918
+def console_fill_foreground(con,r,g,b) :
919
+    if len(r) != len(g) or len(r) != len(b):
920
+        raise TypeError('R, G and B must all have the same size.')
921
+
922
+    if (numpy_available and isinstance(r, numpy.ndarray) and
923
+        isinstance(g, numpy.ndarray) and isinstance(b, numpy.ndarray)):
924
+        #numpy arrays, use numpy's ctypes functions
925
+        r = numpy.ascontiguousarray(r, dtype=numpy.int32)
926
+        g = numpy.ascontiguousarray(g, dtype=numpy.int32)
927
+        b = numpy.ascontiguousarray(b, dtype=numpy.int32)
928
+        cr = r.ctypes.data_as(POINTER(c_int))
929
+        cg = g.ctypes.data_as(POINTER(c_int))
930
+        cb = b.ctypes.data_as(POINTER(c_int))
931
+    else:
932
+        # otherwise convert using ctypes arrays
933
+        cr = (c_int * len(r))(*r)
934
+        cg = (c_int * len(g))(*g)
935
+        cb = (c_int * len(b))(*b)
936
+
937
+    _lib.TCOD_console_fill_foreground(con, cr, cg, cb)
938
+
939
+def console_fill_background(con,r,g,b) :
940
+    if len(r) != len(g) or len(r) != len(b):
941
+        raise TypeError('R, G and B must all have the same size.')
942
+
943
+    if (numpy_available and isinstance(r, numpy.ndarray) and
944
+        isinstance(g, numpy.ndarray) and isinstance(b, numpy.ndarray)):
945
+        #numpy arrays, use numpy's ctypes functions
946
+        r = numpy.ascontiguousarray(r, dtype=numpy.int32)
947
+        g = numpy.ascontiguousarray(g, dtype=numpy.int32)
948
+        b = numpy.ascontiguousarray(b, dtype=numpy.int32)
949
+        cr = r.ctypes.data_as(POINTER(c_int))
950
+        cg = g.ctypes.data_as(POINTER(c_int))
951
+        cb = b.ctypes.data_as(POINTER(c_int))
952
+    else:
953
+        # otherwise convert using ctypes arrays
954
+        cr = (c_int * len(r))(*r)
955
+        cg = (c_int * len(g))(*g)
956
+        cb = (c_int * len(b))(*b)
957
+
958
+    _lib.TCOD_console_fill_background(con, cr, cg, cb)
959
+
960
+def console_fill_char(con,arr) :
961
+    if (numpy_available and isinstance(arr, numpy.ndarray) ):
962
+        #numpy arrays, use numpy's ctypes functions
963
+        arr = numpy.ascontiguousarray(arr, dtype=numpy.int32)
964
+        carr = arr.ctypes.data_as(POINTER(c_int))
965
+    else:
966
+        #otherwise convert using the struct module
967
+        carr = struct.pack('%di' % len(arr), *arr)
968
+
969
+    _lib.TCOD_console_fill_char(con, carr)
970
+        
971
+def console_load_asc(con, filename) :
972
+    _lib.TCOD_console_load_asc(con,filename)
973
+def console_save_asc(con, filename) :
974
+    _lib.TCOD_console_save_asc(con,filename)
975
+def console_load_apf(con, filename) :
976
+    _lib.TCOD_console_load_apf(con,filename)
977
+def console_save_apf(con, filename) :
978
+    _lib.TCOD_console_save_apf(con,filename)
979
+
980
+############################
981
+# sys module
982
+############################
983
+_lib.TCOD_sys_get_last_frame_length.restype = c_float
984
+_lib.TCOD_sys_elapsed_seconds.restype = c_float
985
+
986
+# high precision time functions
987
+def sys_set_fps(fps):
988
+    _lib.TCOD_sys_set_fps(fps)
989
+
990
+def sys_get_fps():
991
+    return _lib.TCOD_sys_get_fps()
992
+
993
+def sys_get_last_frame_length():
994
+    return _lib.TCOD_sys_get_last_frame_length()
995
+
996
+def sys_sleep_milli(val):
997
+    _lib.TCOD_sys_sleep_milli(c_uint(val))
998
+
999
+def sys_elapsed_milli():
1000
+    return _lib.TCOD_sys_elapsed_milli()
1001
+
1002
+def sys_elapsed_seconds():
1003
+    return _lib.TCOD_sys_elapsed_seconds()
1004
+
1005
+def sys_set_renderer(renderer):
1006
+    _lib.TCOD_sys_set_renderer(renderer)
1007
+
1008
+def sys_get_renderer():
1009
+    return _lib.TCOD_sys_get_renderer()
1010
+
1011
+# easy screenshots
1012
+def sys_save_screenshot(name=0):
1013
+    _lib.TCOD_sys_save_screenshot(c_char_p(name))
1014
+
1015
+# custom fullscreen resolution
1016
+def sys_force_fullscreen_resolution(width, height):
1017
+    _lib.TCOD_sys_force_fullscreen_resolution(width, height)
1018
+
1019
+def sys_get_current_resolution():
1020
+    w = c_int()
1021
+    h = c_int()
1022
+    _lib.TCOD_sys_get_current_resolution(byref(w), byref(h))
1023
+    return w.value, h.value
1024
+
1025
+def sys_get_char_size():
1026
+    w = c_int()
1027
+    h = c_int()
1028
+    _lib.TCOD_sys_get_char_size(byref(w), byref(h))
1029
+    return w.value, h.value
1030
+
1031
+# update font bitmap
1032
+def sys_update_char(asciiCode, fontx, fonty, img, x, y) :
1033
+    _lib.TCOD_sys_update_char(c_int(asciiCode),c_int(fontx),c_int(fonty),img,c_int(x),c_int(y))
1034
+
1035
+# custom SDL post renderer
1036
+SDL_RENDERER_FUNC = CFUNCTYPE(None, c_void_p)
1037
+def sys_register_SDL_renderer(callback):
1038
+    global sdl_renderer_func
1039
+    sdl_renderer_func = SDL_RENDERER_FUNC(callback)
1040
+    _lib.TCOD_sys_register_SDL_renderer(sdl_renderer_func)
1041
+
1042
+# events
1043
+EVENT_NONE=0
1044
+EVENT_KEY_PRESS=1
1045
+EVENT_KEY_RELEASE=2
1046
+EVENT_KEY=EVENT_KEY_PRESS|EVENT_KEY_RELEASE
1047
+EVENT_MOUSE_MOVE=4
1048
+EVENT_MOUSE_PRESS=8
1049
+EVENT_MOUSE_RELEASE=16
1050
+EVENT_MOUSE=EVENT_MOUSE_MOVE|EVENT_MOUSE_PRESS|EVENT_MOUSE_RELEASE
1051
+EVENT_ANY=EVENT_KEY|EVENT_MOUSE
1052
+def sys_check_for_event(mask,k,m) :
1053
+    return _lib.TCOD_sys_check_for_event(c_int(mask),byref(k),byref(m))
1054
+
1055
+def sys_wait_for_event(mask,k,m,flush) :
1056
+    return _lib.TCOD_sys_wait_for_event(c_int(mask),byref(k),byref(m),c_bool(flush))
1057
+
1058
+############################
1059
+# line module
1060
+############################
1061
+_lib.TCOD_line_step.restype = c_bool
1062
+_lib.TCOD_line.restype=c_bool
1063
+_lib.TCOD_line_step_mt.restype = c_bool
1064
+
1065
+def line_init(xo, yo, xd, yd):
1066
+    _lib.TCOD_line_init(xo, yo, xd, yd)
1067
+
1068
+def line_step():
1069
+    x = c_int()
1070
+    y = c_int()
1071
+    ret = _lib.TCOD_line_step(byref(x), byref(y))
1072
+    if not ret:
1073
+        return x.value, y.value
1074
+    return None,None
1075
+
1076
+def line(xo,yo,xd,yd,py_callback) :
1077
+    LINE_CBK_FUNC=CFUNCTYPE(c_bool,c_int,c_int)
1078
+    c_callback=LINE_CBK_FUNC(py_callback)
1079
+    return _lib.TCOD_line(xo,yo,xd,yd,c_callback)
1080
+
1081
+def line_iter(xo, yo, xd, yd):
1082
+    data = (c_int * 9)()        # struct TCOD_bresenham_data_t
1083
+    _lib.TCOD_line_init_mt(xo, yo, xd, yd, data)
1084
+    x = c_int(xo)
1085
+    y = c_int(yo)
1086
+    done = False
1087
+    while not done:
1088
+        yield x.value, y.value
1089
+        done = _lib.TCOD_line_step_mt(byref(x), byref(y), data)
1090
+
1091
+############################
1092
+# image module
1093
+############################
1094
+_lib.TCOD_image_is_pixel_transparent.restype = c_bool
1095
+_lib.TCOD_image_get_pixel.restype = Color
1096
+_lib.TCOD_image_get_mipmap_pixel.restype = Color
1097
+
1098
+def image_new(width, height):
1099
+    return _lib.TCOD_image_new(width, height)
1100
+
1101
+def image_clear(image,col) :
1102
+    _lib.TCOD_image_clear(image,col)
1103
+
1104
+def image_invert(image) :
1105
+    _lib.TCOD_image_invert(image)
1106
+
1107
+def image_hflip(image) :
1108
+    _lib.TCOD_image_hflip(image)
1109
+
1110
+def image_rotate90(image, num=1) :
1111
+    _lib.TCOD_image_rotate90(image,num)
1112
+
1113
+def image_vflip(image) :
1114
+    _lib.TCOD_image_vflip(image)
1115
+
1116
+def image_scale(image, neww, newh) :
1117
+    _lib.TCOD_image_scale(image,c_int(neww),c_int(newh))
1118
+
1119
+def image_set_key_color(image,col) :
1120
+    _lib.TCOD_image_set_key_color(image,col)
1121
+
1122
+def image_get_alpha(image,x,y) :
1123
+    return _lib.TCOD_image_get_alpha(image,c_int(x),c_int(y))
1124
+
1125
+def image_is_pixel_transparent(image,x,y) :
1126
+    return _lib.TCOD_image_is_pixel_transparent(image,c_int(x),c_int(y))
1127
+
1128
+def image_load(filename):
1129
+    return _lib.TCOD_image_load(c_char_p(filename))
1130
+
1131
+def image_from_console(console):
1132
+    return _lib.TCOD_image_from_console(console)
1133
+
1134
+def image_refresh_console(image, console):
1135
+    _lib.TCOD_image_refresh_console(image, console)
1136
+
1137
+def image_get_size(image):
1138
+    w=c_int()
1139
+    h=c_int()
1140
+    _lib.TCOD_image_get_size(image, byref(w), byref(h))
1141
+    return w.value, h.value
1142
+
1143
+def image_get_pixel(image, x, y):
1144
+    return _lib.TCOD_image_get_pixel(image, x, y)
1145
+
1146
+def image_get_mipmap_pixel(image, x0, y0, x1, y1):
1147
+    return _lib.TCOD_image_get_mipmap_pixel(image, c_float(x0), c_float(y0),
1148
+                                            c_float(x1), c_float(y1))
1149
+def image_put_pixel(image, x, y, col):
1150
+    _lib.TCOD_image_put_pixel(image, x, y, col)
1151
+    ##_lib.TCOD_image_put_pixel_wrapper(image, x, y, col)
1152
+
1153
+def image_blit(image, console, x, y, bkgnd_flag, scalex, scaley, angle):
1154
+    _lib.TCOD_image_blit(image, console, c_float(x), c_float(y), bkgnd_flag,
1155
+                         c_float(scalex), c_float(scaley), c_float(angle))
1156
+
1157
+def image_blit_rect(image, console, x, y, w, h, bkgnd_flag):
1158
+    _lib.TCOD_image_blit_rect(image, console, x, y, w, h, bkgnd_flag)
1159
+
1160
+def image_blit_2x(image, console, dx, dy, sx=0, sy=0, w=-1, h=-1):
1161
+    _lib.TCOD_image_blit_2x(image, console, dx,dy,sx,sy,w,h)
1162
+
1163
+def image_save(image, filename):
1164
+    _lib.TCOD_image_save(image, c_char_p(filename))
1165
+
1166
+def image_delete(image):
1167
+    _lib.TCOD_image_delete(image)
1168
+
1169
+############################
1170
+# mouse module
1171
+############################
1172
+class Mouse(Structure):
1173
+    _fields_=[('x', c_int),
1174
+              ('y', c_int),
1175
+              ('dx', c_int),
1176
+              ('dy', c_int),
1177
+              ('cx', c_int),
1178
+              ('cy', c_int),
1179
+              ('dcx', c_int),
1180
+              ('dcy', c_int),
1181
+              ('lbutton', c_bool),
1182
+              ('rbutton', c_bool),
1183
+              ('mbutton', c_bool),
1184
+              ('lbutton_pressed', c_bool),
1185
+              ('rbutton_pressed', c_bool),
1186
+              ('mbutton_pressed', c_bool),
1187
+              ('wheel_up', c_bool),
1188
+              ('wheel_down', c_bool),
1189
+              ]
1190
+
1191
+_lib.TCOD_mouse_is_cursor_visible.restype = c_bool
1192
+
1193
+def mouse_show_cursor(visible):
1194
+    _lib.TCOD_mouse_show_cursor(c_int(visible))
1195
+
1196
+def mouse_is_cursor_visible():
1197
+    return _lib.TCOD_mouse_is_cursor_visible()
1198
+
1199
+def mouse_move(x, y):
1200
+    _lib.TCOD_mouse_move(x, y)
1201
+
1202
+def mouse_get_status():
1203
+    mouse=Mouse()
1204
+    _lib.TCOD_mouse_get_status_wrapper(byref(mouse))
1205
+    return mouse
1206
+
1207
+############################
1208
+# parser module
1209
+############################
1210
+_lib.TCOD_struct_get_name.restype = c_char_p
1211
+_lib.TCOD_struct_is_mandatory.restype = c_bool
1212
+_lib.TCOD_parser_has_property.restype = c_bool
1213
+_lib.TCOD_parser_get_bool_property.restype = c_bool
1214
+_lib.TCOD_parser_get_float_property.restype = c_float
1215
+_lib.TCOD_parser_get_string_property.restype = c_char_p
1216
+_lib.TCOD_parser_get_color_property.restype = Color
1217
+
1218
+class Dice(Structure):
1219
+    _fields_=[('nb_dices', c_int),
1220
+              ('nb_faces', c_int),
1221
+              ('multiplier', c_float),
1222
+              ('addsub', c_float),
1223
+              ]
1224
+
1225
+    def __repr__(self):
1226
+        return "Dice(%d, %d, %s, %s)" % (self.nb_dices, self.nb_faces,
1227
+                                      self.multiplier, self.addsub)
1228
+
1229
+class _CValue(Union):
1230
+    _fields_=[('c',c_uint8),
1231
+              ('i',c_int),
1232
+              ('f',c_float),
1233
+              ('s',c_char_p),
1234
+              # JBR03192012 See http://bugs.python.org/issue14354 for why these are not defined as their actual types
1235
+              ('col',c_uint8 * 3),
1236
+              ('dice',c_int * 4),
1237
+              ('custom',c_void_p),
1238
+              ]
1239
+
1240
+_CFUNC_NEW_STRUCT = CFUNCTYPE(c_uint, c_void_p, c_char_p)
1241
+_CFUNC_NEW_FLAG = CFUNCTYPE(c_uint, c_char_p)
1242
+_CFUNC_NEW_PROPERTY = CFUNCTYPE(c_uint, c_char_p, c_int, _CValue)
1243
+
1244
+class _CParserListener(Structure):
1245
+    _fields_=[('new_struct', _CFUNC_NEW_STRUCT),
1246
+              ('new_flag',_CFUNC_NEW_FLAG),
1247
+              ('new_property',_CFUNC_NEW_PROPERTY),
1248
+              ('end_struct',_CFUNC_NEW_STRUCT),
1249
+              ('error',_CFUNC_NEW_FLAG),
1250
+              ]
1251
+
1252
+# property types
1253
+TYPE_NONE = 0
1254
+TYPE_BOOL = 1
1255
+TYPE_CHAR = 2
1256
+TYPE_INT = 3
1257
+TYPE_FLOAT = 4
1258
+TYPE_STRING = 5
1259
+TYPE_COLOR = 6
1260
+TYPE_DICE = 7
1261
+TYPE_VALUELIST00 = 8
1262
+TYPE_VALUELIST01 = 9
1263
+TYPE_VALUELIST02 = 10
1264
+TYPE_VALUELIST03 = 11
1265
+TYPE_VALUELIST04 = 12
1266
+TYPE_VALUELIST05 = 13
1267
+TYPE_VALUELIST06 = 14
1268
+TYPE_VALUELIST07 = 15
1269
+TYPE_VALUELIST08 = 16
1270
+TYPE_VALUELIST09 = 17
1271
+TYPE_VALUELIST10 = 18
1272
+TYPE_VALUELIST11 = 19
1273
+TYPE_VALUELIST12 = 20
1274
+TYPE_VALUELIST13 = 21
1275
+TYPE_VALUELIST14 = 22
1276
+TYPE_VALUELIST15 = 23
1277
+TYPE_LIST = 1024
1278
+
1279
+def _convert_TCODList(clist, typ):
1280
+    res = list()
1281
+    for i in range(_lib.TCOD_list_size(clist)):
1282
+        elt = _lib.TCOD_list_get(clist, i)
1283
+        elt = cast(elt, c_void_p)
1284
+        if typ == TYPE_BOOL:
1285
+            elt = c_bool.from_buffer(elt).value
1286
+        elif typ == TYPE_CHAR:
1287
+            elt = c_char.from_buffer(elt).value
1288
+        elif typ == TYPE_INT:
1289
+            elt = c_int.from_buffer(elt).value
1290
+        elif typ == TYPE_FLOAT:
1291
+            elt = c_float.from_buffer(elt).value
1292
+        elif typ == TYPE_STRING or TYPE_VALUELIST15 >= typ >= TYPE_VALUELIST00:
1293
+            elt = cast(elt, c_char_p).value
1294
+        elif typ == TYPE_COLOR:
1295
+            elt = Color.from_buffer_copy(elt)
1296
+        elif typ == TYPE_DICE:
1297
+            # doesn't work
1298
+            elt = Dice.from_buffer_copy(elt)
1299
+        res.append(elt)
1300
+    return res
1301
+
1302
+def parser_new():
1303
+    return _lib.TCOD_parser_new()
1304
+
1305
+def parser_new_struct(parser, name):
1306
+    return _lib.TCOD_parser_new_struct(parser, name)
1307
+
1308
+def struct_add_flag(struct, name):
1309
+    _lib.TCOD_struct_add_flag(struct, name)
1310
+
1311
+def struct_add_property(struct, name, typ, mandatory):
1312
+    _lib.TCOD_struct_add_property(struct, name, typ, c_bool(mandatory))
1313
+
1314
+def struct_add_value_list(struct, name, value_list, mandatory):
1315
+    CARRAY = c_char_p * (len(value_list) + 1)
1316
+    cvalue_list = CARRAY()
1317
+    for i in range(len(value_list)):
1318
+        cvalue_list[i] = cast(value_list[i], c_char_p)
1319
+    cvalue_list[len(value_list)] = 0
1320
+    _lib.TCOD_struct_add_value_list(struct, name, cvalue_list, c_bool(mandatory))
1321
+
1322
+def struct_add_list_property(struct, name, typ, mandatory):
1323
+    _lib.TCOD_struct_add_list_property(struct, name, typ, c_bool(mandatory))
1324
+
1325
+def struct_add_structure(struct, sub_struct):
1326
+    _lib.TCOD_struct_add_structure(struct, sub_struct)
1327
+
1328
+def struct_get_name(struct):
1329
+    return _lib.TCOD_struct_get_name(struct)
1330
+
1331
+def struct_is_mandatory(struct, name):
1332
+    return _lib.TCOD_struct_is_mandatory(struct, name)
1333
+
1334
+def struct_get_type(struct, name):
1335
+    return _lib.TCOD_struct_get_type(struct, name)
1336
+
1337
+def parser_run(parser, filename, listener=0):
1338
+    if listener != 0:
1339
+        clistener=_CParserListener()
1340
+        def value_converter(name, typ, value):
1341
+            if typ == TYPE_BOOL:
1342
+                return listener.new_property(name, typ, value.c == 1)
1343
+            elif typ == TYPE_CHAR:
1344
+                return listener.new_property(name, typ, '%c' % (value.c & 0xFF))
1345
+            elif typ == TYPE_INT:
1346
+                return listener.new_property(name, typ, value.i)
1347
+            elif typ == TYPE_FLOAT:
1348
+                return listener.new_property(name, typ, value.f)
1349
+            elif typ == TYPE_STRING or \
1350
+                 TYPE_VALUELIST15 >= typ >= TYPE_VALUELIST00:
1351
+                 return listener.new_property(name, typ, value.s)
1352
+            elif typ == TYPE_COLOR:
1353
+                col = cast(value.col, POINTER(Color)).contents
1354
+                return listener.new_property(name, typ, col)
1355
+            elif typ == TYPE_DICE:
1356
+                dice = cast(value.dice, POINTER(Dice)).contents
1357
+                return listener.new_property(name, typ, dice)
1358
+            elif typ & TYPE_LIST:
1359
+                return listener.new_property(name, typ,
1360
+                                        _convert_TCODList(value.custom, typ & 0xFF))
1361
+            return True
1362
+        clistener.new_struct = _CFUNC_NEW_STRUCT(listener.new_struct)
1363
+        clistener.new_flag = _CFUNC_NEW_FLAG(listener.new_flag)
1364
+        clistener.new_property = _CFUNC_NEW_PROPERTY(value_converter)
1365
+        clistener.end_struct = _CFUNC_NEW_STRUCT(listener.end_struct)
1366
+        clistener.error = _CFUNC_NEW_FLAG(listener.error)
1367
+        _lib.TCOD_parser_run(parser, c_char_p(filename), byref(clistener))
1368
+    else:
1369
+        _lib.TCOD_parser_run(parser, c_char_p(filename), 0)
1370
+
1371
+def parser_delete(parser):
1372
+    _lib.TCOD_parser_delete(parser)
1373
+
1374
+def parser_has_property(parser, name):
1375
+    return _lib.TCOD_parser_has_property(parser, c_char_p(name))
1376
+
1377
+def parser_get_bool_property(parser, name):
1378
+    return _lib.TCOD_parser_get_bool_property(parser, c_char_p(name))
1379
+
1380
+def parser_get_int_property(parser, name):
1381
+    return _lib.TCOD_parser_get_int_property(parser, c_char_p(name))
1382
+
1383
+def parser_get_char_property(parser, name):
1384
+    return '%c' % _lib.TCOD_parser_get_char_property(parser, c_char_p(name))
1385
+
1386
+def parser_get_float_property(parser, name):
1387
+    return _lib.TCOD_parser_get_float_property(parser, c_char_p(name))
1388
+
1389
+def parser_get_string_property(parser, name):
1390
+    return _lib.TCOD_parser_get_string_property(parser, c_char_p(name))
1391
+
1392
+def parser_get_color_property(parser, name):
1393
+    return _lib.TCOD_parser_get_color_property(parser, c_char_p(name))
1394
+
1395
+def parser_get_dice_property(parser, name):
1396
+    d = Dice()
1397
+    _lib.TCOD_parser_get_dice_property_py(c_void_p(parser), c_char_p(name), byref(d))
1398
+    return d
1399
+
1400
+def parser_get_list_property(parser, name, typ):
1401
+    clist = _lib.TCOD_parser_get_list_property(parser, c_char_p(name), c_int(typ))
1402
+    return _convert_TCODList(clist, typ)
1403
+
1404
+############################
1405
+# random module
1406
+############################
1407
+_lib.TCOD_random_get_float.restype = c_float
1408
+_lib.TCOD_random_get_double.restype = c_double
1409
+
1410
+RNG_MT = 0
1411
+RNG_CMWC = 1
1412
+
1413
+DISTRIBUTION_LINEAR = 0
1414
+DISTRIBUTION_GAUSSIAN = 1
1415
+DISTRIBUTION_GAUSSIAN_RANGE = 2
1416
+DISTRIBUTION_GAUSSIAN_INVERSE = 3
1417
+DISTRIBUTION_GAUSSIAN_RANGE_INVERSE = 4
1418
+
1419
+def random_get_instance():
1420
+    return _lib.TCOD_random_get_instance()
1421
+
1422
+def random_new(algo=RNG_CMWC):
1423
+    return _lib.TCOD_random_new(algo)
1424
+
1425
+def random_new_from_seed(seed, algo=RNG_CMWC):
1426
+    return _lib.TCOD_random_new_from_seed(algo,c_uint(seed))
1427
+
1428
+def random_set_distribution(rnd, dist) :
1429
+	_lib.TCOD_random_set_distribution(rnd, dist)
1430
+
1431
+def random_get_int(rnd, mi, ma):
1432
+    return _lib.TCOD_random_get_int(rnd, mi, ma)
1433
+
1434
+def random_get_float(rnd, mi, ma):
1435
+    return _lib.TCOD_random_get_float(rnd, c_float(mi), c_float(ma))
1436
+
1437
+def random_get_double(rnd, mi, ma):
1438
+    return _lib.TCOD_random_get_double(rnd, c_double(mi), c_double(ma))
1439
+
1440
+def random_get_int_mean(rnd, mi, ma, mean):
1441
+    return _lib.TCOD_random_get_int_mean(rnd, mi, ma, mean)
1442
+
1443
+def random_get_float_mean(rnd, mi, ma, mean):
1444
+    return _lib.TCOD_random_get_float_mean(rnd, c_float(mi), c_float(ma), c_float(mean))
1445
+
1446
+def random_get_double_mean(rnd, mi, ma, mean):
1447
+    return _lib.TCOD_random_get_double_mean(rnd, c_double(mi), c_double(ma), c_double(mean))
1448
+
1449
+def random_save(rnd):
1450
+    return _lib.TCOD_random_save(rnd)
1451
+
1452
+def random_restore(rnd, backup):
1453
+    _lib.TCOD_random_restore(rnd, backup)
1454
+
1455
+def random_delete(rnd):
1456
+    _lib.TCOD_random_delete(rnd)
1457
+
1458
+############################
1459
+# noise module
1460
+############################
1461
+_lib.TCOD_noise_get.restype = c_float
1462
+_lib.TCOD_noise_get_ex.restype = c_float
1463
+_lib.TCOD_noise_get_fbm.restype = c_float
1464
+_lib.TCOD_noise_get_fbm_ex.restype = c_float
1465
+_lib.TCOD_noise_get_turbulence.restype = c_float
1466
+_lib.TCOD_noise_get_turbulence_ex.restype = c_float
1467
+
1468
+NOISE_DEFAULT_HURST = 0.5
1469
+NOISE_DEFAULT_LACUNARITY = 2.0
1470
+
1471
+NOISE_DEFAULT = 0
1472
+NOISE_PERLIN = 1
1473
+NOISE_SIMPLEX = 2
1474
+NOISE_WAVELET = 4
1475
+
1476
+_NOISE_PACKER_FUNC = (None,
1477
+                      (c_float * 1),
1478
+                      (c_float * 2),
1479
+                      (c_float * 3),
1480
+                      (c_float * 4),
1481
+                      )
1482
+
1483
+def noise_new(dim, h=NOISE_DEFAULT_HURST, l=NOISE_DEFAULT_LACUNARITY, random=0):
1484
+    return _lib.TCOD_noise_new(dim, c_float(h), c_float(l), random)
1485
+
1486
+def noise_set_type(n, typ) :
1487
+    _lib.TCOD_noise_set_type(n,typ)
1488
+
1489
+def noise_get(n, f, typ=NOISE_DEFAULT):
1490
+    return _lib.TCOD_noise_get_ex(n, _NOISE_PACKER_FUNC[len(f)](*f), typ)
1491
+
1492
+def noise_get_fbm(n, f, oc, typ=NOISE_DEFAULT):
1493
+    return _lib.TCOD_noise_get_fbm_ex(n, _NOISE_PACKER_FUNC[len(f)](*f), c_float(oc), typ)
1494
+
1495
+def noise_get_turbulence(n, f, oc, typ=NOISE_DEFAULT):
1496
+    return _lib.TCOD_noise_get_turbulence_ex(n, _NOISE_PACKER_FUNC[len(f)](*f), c_float(oc), typ)
1497
+
1498
+def noise_delete(n):
1499
+    _lib.TCOD_noise_delete(n)
1500
+
1501
+############################
1502
+# fov module
1503
+############################
1504
+_lib.TCOD_map_is_in_fov.restype = c_bool
1505
+_lib.TCOD_map_is_transparent.restype = c_bool
1506
+_lib.TCOD_map_is_walkable.restype = c_bool
1507
+
1508
+FOV_BASIC = 0
1509
+FOV_DIAMOND = 1
1510
+FOV_SHADOW = 2
1511
+FOV_PERMISSIVE_0 = 3
1512
+FOV_PERMISSIVE_1 = 4
1513
+FOV_PERMISSIVE_2 = 5
1514
+FOV_PERMISSIVE_3 = 6
1515
+FOV_PERMISSIVE_4 = 7
1516
+FOV_PERMISSIVE_5 = 8
1517
+FOV_PERMISSIVE_6 = 9
1518
+FOV_PERMISSIVE_7 = 10
1519
+FOV_PERMISSIVE_8 = 11
1520
+FOV_RESTRICTIVE = 12
1521
+NB_FOV_ALGORITHMS = 13
1522
+
1523
+def FOV_PERMISSIVE(p) :
1524
+    return FOV_PERMISSIVE_0+p
1525
+
1526
+def map_new(w, h):
1527
+    return _lib.TCOD_map_new(w, h)
1528
+
1529
+def map_copy(source, dest):
1530
+    return _lib.TCOD_map_copy(source, dest)
1531
+
1532
+def map_set_properties(m, x, y, isTrans, isWalk):
1533
+    _lib.TCOD_map_set_properties(m, x, y, c_int(isTrans), c_int(isWalk))
1534
+
1535
+def map_clear(m,walkable=False,transparent=False):
1536
+    _lib.TCOD_map_clear(m,c_int(walkable),c_int(transparent))
1537
+
1538
+def map_compute_fov(m, x, y, radius=0, light_walls=True, algo=FOV_RESTRICTIVE ):
1539
+    _lib.TCOD_map_compute_fov(m, x, y, c_int(radius), c_bool(light_walls), c_int(algo))
1540
+
1541
+def map_is_in_fov(m, x, y):
1542
+    return _lib.TCOD_map_is_in_fov(m, x, y)
1543
+
1544
+def map_is_transparent(m, x, y):
1545
+    return _lib.TCOD_map_is_transparent(m, x, y)
1546
+
1547
+def map_is_walkable(m, x, y):
1548
+    return _lib.TCOD_map_is_walkable(m, x, y)
1549
+
1550
+def map_delete(m):
1551
+    return _lib.TCOD_map_delete(m)
1552
+
1553
+def map_get_width(map):
1554
+    return _lib.TCOD_map_get_width(map)
1555
+
1556
+def map_get_height(map):
1557
+    return _lib.TCOD_map_get_height(map)
1558
+
1559
+############################
1560
+# pathfinding module
1561
+############################
1562
+_lib.TCOD_path_compute.restype = c_bool
1563
+_lib.TCOD_path_is_empty.restype = c_bool
1564
+_lib.TCOD_path_walk.restype = c_bool
1565
+
1566
+PATH_CBK_FUNC = CFUNCTYPE(c_float, c_int, c_int, c_int, c_int, py_object)
1567
+
1568
+def path_new_using_map(m, dcost=1.41):
1569
+    return (_lib.TCOD_path_new_using_map(c_void_p(m), c_float(dcost)), None)
1570
+
1571
+def path_new_using_function(w, h, func, userdata=0, dcost=1.41):
1572
+    cbk_func = PATH_CBK_FUNC(func)
1573
+    return (_lib.TCOD_path_new_using_function(w, h, cbk_func,
1574
+            py_object(userdata), c_float(dcost)), cbk_func)
1575
+
1576
+def path_compute(p, ox, oy, dx, dy):
1577
+    return _lib.TCOD_path_compute(p[0], ox, oy, dx, dy)
1578
+
1579
+def path_get_origin(p):
1580
+    x = c_int()
1581
+    y = c_int()
1582
+    _lib.TCOD_path_get_origin(p[0], byref(x), byref(y))
1583
+    return x.value, y.value
1584
+
1585
+def path_get_destination(p):
1586
+    x = c_int()
1587
+    y = c_int()
1588
+    _lib.TCOD_path_get_destination(p[0], byref(x), byref(y))
1589
+    return x.value, y.value
1590
+
1591
+def path_size(p):
1592
+    return _lib.TCOD_path_size(p[0])
1593
+
1594
+def path_reverse(p):
1595
+    _lib.TCOD_path_reverse(p[0])  
1596
+
1597
+def path_get(p, idx):
1598
+    x = c_int()
1599
+    y = c_int()
1600
+    _lib.TCOD_path_get(p[0], idx, byref(x), byref(y))
1601
+    return x.value, y.value
1602
+
1603
+def path_is_empty(p):
1604
+    return _lib.TCOD_path_is_empty(p[0])
1605
+
1606
+def path_walk(p, recompute):
1607
+    x = c_int()
1608
+    y = c_int()
1609
+    if _lib.TCOD_path_walk(p[0], byref(x), byref(y), c_int(recompute)):
1610
+        return x.value, y.value
1611
+    return None,None
1612
+
1613
+def path_delete(p):
1614
+    _lib.TCOD_path_delete(p[0])
1615
+
1616
+_lib.TCOD_dijkstra_path_set.restype = c_bool
1617
+_lib.TCOD_dijkstra_is_empty.restype = c_bool
1618
+_lib.TCOD_dijkstra_path_walk.restype = c_bool
1619
+_lib.TCOD_dijkstra_get_distance.restype = c_float
1620
+
1621
+def dijkstra_new(m, dcost=1.41):
1622
+    return (_lib.TCOD_dijkstra_new(c_void_p(m), c_float(dcost)), None)
1623
+
1624
+def dijkstra_new_using_function(w, h, func, userdata=0, dcost=1.41):
1625
+    cbk_func = PATH_CBK_FUNC(func)
1626
+    return (_lib.TCOD_path_dijkstra_using_function(w, h, cbk_func,
1627
+            py_object(userdata), c_float(dcost)), cbk_func)
1628
+
1629
+def dijkstra_compute(p, ox, oy):
1630
+    _lib.TCOD_dijkstra_compute(p[0], c_int(ox), c_int(oy))
1631
+
1632
+def dijkstra_path_set(p, x, y):
1633
+    return _lib.TCOD_dijkstra_path_set(p[0], c_int(x), c_int(y))
1634
+
1635
+def dijkstra_get_distance(p, x, y):
1636
+    return _lib.TCOD_dijkstra_get_distance(p[0], c_int(x), c_int(y))
1637
+
1638
+def dijkstra_size(p):
1639
+    return _lib.TCOD_dijkstra_size(p[0])
1640
+
1641
+def dijkstra_reverse(p):
1642
+    _lib.TCOD_dijkstra_reverse(p[0])
1643
+
1644
+def dijkstra_get(p, idx):
1645
+    x = c_int()
1646
+    y = c_int()
1647
+    _lib.TCOD_dijkstra_get(p[0], c_int(idx), byref(x), byref(y))
1648
+    return x.value, y.value
1649
+
1650
+def dijkstra_is_empty(p):
1651
+    return _lib.TCOD_dijkstra_is_empty(p[0])
1652
+
1653
+def dijkstra_path_walk(p):
1654
+    x = c_int()
1655
+    y = c_int()
1656
+    if _lib.TCOD_dijkstra_path_walk(p[0], byref(x), byref(y)):
1657
+        return x.value, y.value
1658
+    return None,None
1659
+
1660
+def dijkstra_delete(p):
1661
+    _lib.TCOD_dijkstra_delete(p[0])
1662
+
1663
+############################
1664
+# bsp module
1665
+############################
1666
+class _CBsp(Structure):
1667
+    _fields_ = [('next', c_void_p),
1668
+                ('father', c_void_p),
1669
+                ('son', c_void_p),
1670
+                ('x', c_int),
1671
+                ('y', c_int),
1672
+                ('w', c_int),
1673
+                ('h', c_int),
1674
+                ('position', c_int),
1675
+                ('level', c_uint8),
1676
+                ('horizontal', c_bool),
1677
+                ]
1678
+
1679
+_lib.TCOD_bsp_new_with_size.restype = POINTER(_CBsp)
1680
+_lib.TCOD_bsp_left.restype = POINTER(_CBsp)
1681
+_lib.TCOD_bsp_right.restype = POINTER(_CBsp)
1682
+_lib.TCOD_bsp_father.restype = POINTER(_CBsp)
1683
+_lib.TCOD_bsp_is_leaf.restype = c_bool
1684
+_lib.TCOD_bsp_contains.restype = c_bool
1685
+_lib.TCOD_bsp_find_node.restype = POINTER(_CBsp)
1686
+
1687
+BSP_CBK_FUNC = CFUNCTYPE(c_int, c_void_p, c_void_p)
1688
+
1689
+# python class encapsulating the _CBsp pointer
1690
+class Bsp(object):
1691
+    def __init__(self, cnode):
1692
+        pcbsp = cast(cnode, POINTER(_CBsp))
1693
+        self.p = pcbsp
1694
+
1695
+    def getx(self):
1696
+        return self.p.contents.x
1697
+    def setx(self, value):
1698
+        self.p.contents.x = value
1699
+    x = property(getx, setx)
1700
+
1701
+    def gety(self):
1702
+        return self.p.contents.y
1703
+    def sety(self, value):
1704
+        self.p.contents.y = value
1705
+    y = property(gety, sety)
1706
+
1707
+    def getw(self):
1708
+        return self.p.contents.w
1709
+    def setw(self, value):
1710
+        self.p.contents.w = value
1711
+    w = property(getw, setw)
1712
+
1713
+    def geth(self):
1714
+        return self.p.contents.h
1715
+    def seth(self, value):
1716
+        self.p.contents.h = value
1717
+    h = property(geth, seth)
1718
+
1719
+    def getpos(self):
1720
+        return self.p.contents.position
1721
+    def setpos(self, value):
1722
+        self.p.contents.position = value
1723
+    position = property(getpos, setpos)
1724
+
1725
+    def gethor(self):
1726
+        return self.p.contents.horizontal
1727
+    def sethor(self,value):
1728
+        self.p.contents.horizontal = value
1729
+    horizontal = property(gethor, sethor)
1730
+
1731
+    def getlev(self):
1732
+        return self.p.contents.level
1733
+    def setlev(self,value):
1734
+        self.p.contents.level = value
1735
+    level = property(getlev, setlev)
1736
+
1737
+
1738
+def bsp_new_with_size(x, y, w, h):
1739
+    return Bsp(_lib.TCOD_bsp_new_with_size(x, y, w, h))
1740
+
1741
+def bsp_split_once(node, horizontal, position):
1742
+    _lib.TCOD_bsp_split_once(node.p, c_int(horizontal), position)
1743
+
1744
+def bsp_split_recursive(node, randomizer, nb, minHSize, minVSize, maxHRatio,
1745
+                        maxVRatio):
1746
+    _lib.TCOD_bsp_split_recursive(node.p, randomizer, nb, minHSize, minVSize,
1747
+                                  c_float(maxHRatio), c_float(maxVRatio))
1748
+
1749
+def bsp_resize(node, x, y, w, h):
1750
+    _lib.TCOD_bsp_resize(node.p, x, y, w, h)
1751
+
1752
+def bsp_left(node):
1753
+    return Bsp(_lib.TCOD_bsp_left(node.p))
1754
+
1755
+def bsp_right(node):
1756
+    return Bsp(_lib.TCOD_bsp_right(node.p))
1757
+
1758
+def bsp_father(node):
1759
+    return Bsp(_lib.TCOD_bsp_father(node.p))
1760
+
1761
+def bsp_is_leaf(node):
1762
+    return _lib.TCOD_bsp_is_leaf(node.p)
1763
+
1764
+def bsp_contains(node, cx, cy):
1765
+    return _lib.TCOD_bsp_contains(node.p, cx, cy)
1766
+
1767
+def bsp_find_node(node, cx, cy):
1768
+    return Bsp(_lib.TCOD_bsp_find_node(node.p, cx, cy))
1769
+
1770
+def _bsp_traverse(node, callback, userData, func):
1771
+    # convert the c node into a python node
1772
+    #before passing it to the actual callback
1773
+    def node_converter(cnode, data):
1774
+        node = Bsp(cnode)
1775
+        return callback(node, data)
1776
+    cbk_func = BSP_CBK_FUNC(node_converter)
1777
+    func(node.p, cbk_func, userData)
1778
+
1779
+def bsp_traverse_pre_order(node, callback, userData=0):
1780
+    _bsp_traverse(node, callback, userData, _lib.TCOD_bsp_traverse_pre_order)
1781
+
1782
+def bsp_traverse_in_order(node, callback, userData=0):
1783
+    _bsp_traverse(node, callback, userData, _lib.TCOD_bsp_traverse_in_order)
1784
+
1785
+def bsp_traverse_post_order(node, callback, userData=0):
1786
+    _bsp_traverse(node, callback, userData, _lib.TCOD_bsp_traverse_post_order)
1787
+
1788
+def bsp_traverse_level_order(node, callback, userData=0):
1789
+    _bsp_traverse(node, callback, userData, _lib.TCOD_bsp_traverse_level_order)
1790
+
1791
+def bsp_traverse_inverted_level_order(node, callback, userData=0):
1792
+    _bsp_traverse(node, callback, userData,
1793
+                  _lib.TCOD_bsp_traverse_inverted_level_order)
1794
+
1795
+def bsp_remove_sons(node):
1796
+    _lib.TCOD_bsp_remove_sons(node.p)
1797
+
1798
+def bsp_delete(node):
1799
+    _lib.TCOD_bsp_delete(node.p)
1800
+
1801
+############################
1802
+# heightmap module
1803
+############################
1804
+class _CHeightMap(Structure):
1805
+    _fields_=[('w', c_int),
1806
+              ('h', c_int),
1807
+              ('values', POINTER(c_float)),
1808
+              ]
1809
+
1810
+_lib.TCOD_heightmap_new.restype = POINTER(_CHeightMap)
1811
+_lib.TCOD_heightmap_get_value.restype = c_float
1812
+_lib.TCOD_heightmap_has_land_on_border.restype = c_bool
1813
+
1814
+class HeightMap(object):
1815
+    def __init__(self, chm):
1816
+        pchm = cast(chm, POINTER(_CHeightMap))
1817
+        self.p = pchm
1818
+
1819
+    def getw(self):
1820
+        return self.p.contents.w
1821
+    def setw(self, value):
1822
+        self.p.contents.w = value
1823
+    w = property(getw, setw)
1824
+
1825
+    def geth(self):
1826
+        return self.p.contents.h
1827
+    def seth(self, value):
1828
+        self.p.contents.h = value
1829
+    h = property(geth, seth)
1830
+
1831
+def heightmap_new(w, h):
1832
+    phm = _lib.TCOD_heightmap_new(w, h)
1833
+    return HeightMap(phm)
1834
+
1835
+def heightmap_set_value(hm, x, y, value):
1836
+    _lib.TCOD_heightmap_set_value(hm.p, x, y, c_float(value))
1837
+
1838
+def heightmap_add(hm, value):
1839
+    _lib.TCOD_heightmap_add(hm.p, c_float(value))
1840
+
1841
+def heightmap_scale(hm, value):
1842
+    _lib.TCOD_heightmap_scale(hm.p, c_float(value))
1843
+
1844
+def heightmap_clear(hm):
1845
+    _lib.TCOD_heightmap_clear(hm.p)
1846
+
1847
+def heightmap_clamp(hm, mi, ma):
1848
+    _lib.TCOD_heightmap_clamp(hm.p, c_float(mi),c_float(ma))
1849
+
1850
+def heightmap_copy(hm1, hm2):
1851
+    _lib.TCOD_heightmap_copy(hm1.p, hm2.p)
1852
+
1853
+def heightmap_normalize(hm,  mi=0.0, ma=1.0):
1854
+    _lib.TCOD_heightmap_normalize(hm.p, c_float(mi), c_float(ma))
1855
+
1856
+def heightmap_lerp_hm(hm1, hm2, hm3, coef):
1857
+    _lib.TCOD_heightmap_lerp_hm(hm1.p, hm2.p, hm3.p, c_float(coef))
1858
+
1859
+def heightmap_add_hm(hm1, hm2, hm3):
1860
+    _lib.TCOD_heightmap_add_hm(hm1.p, hm2.p, hm3.p)
1861
+
1862
+def heightmap_multiply_hm(hm1, hm2, hm3):
1863
+    _lib.TCOD_heightmap_multiply_hm(hm1.p, hm2.p, hm3.p)
1864
+
1865
+def heightmap_add_hill(hm, x, y, radius, height):
1866
+    _lib.TCOD_heightmap_add_hill(hm.p, c_float( x), c_float( y),
1867
+                                 c_float( radius), c_float( height))
1868
+
1869
+def heightmap_dig_hill(hm, x, y, radius, height):
1870
+    _lib.TCOD_heightmap_dig_hill(hm.p, c_float( x), c_float( y),
1871
+                                 c_float( radius), c_float( height))
1872
+
1873
+def heightmap_mid_point_displacement(hm, rng, roughness):
1874
+    _lib.TCOD_heightmap_mid_point_displacement(hm.p, rng, c_float(roughness))
1875
+
1876
+def heightmap_rain_erosion(hm, nbDrops, erosionCoef, sedimentationCoef, rnd=0):
1877
+    _lib.TCOD_heightmap_rain_erosion(hm.p, nbDrops, c_float( erosionCoef),
1878
+                                     c_float( sedimentationCoef), rnd)
1879
+
1880
+def heightmap_kernel_transform(hm, kernelsize, dx, dy, weight, minLevel,
1881
+                               maxLevel):
1882
+    FARRAY = c_float * kernelsize
1883
+    IARRAY = c_int * kernelsize
1884
+    cdx = IARRAY(*dx)
1885
+    cdy = IARRAY(*dy)
1886
+    cweight = FARRAY(*weight)
1887
+    _lib.TCOD_heightmap_kernel_transform(hm.p, kernelsize, cdx, cdy, cweight,
1888
+                                         c_float(minLevel), c_float(maxLevel))
1889
+
1890
+def heightmap_add_voronoi(hm, nbPoints, nbCoef, coef, rnd=0):
1891
+    FARRAY = c_float * nbCoef
1892
+    ccoef = FARRAY(*coef)
1893
+    _lib.TCOD_heightmap_add_voronoi(hm.p, nbPoints, nbCoef, ccoef, rnd)
1894
+
1895
+def heightmap_add_fbm(hm, noise, mulx, muly, addx, addy, octaves, delta, scale):
1896
+    _lib.TCOD_heightmap_add_fbm(hm.p, noise, c_float(mulx), c_float(muly),
1897
+                                c_float(addx), c_float(addy),
1898
+                                c_float(octaves), c_float(delta),
1899
+                                c_float(scale))
1900
+def heightmap_scale_fbm(hm, noise, mulx, muly, addx, addy, octaves, delta,
1901
+                        scale):
1902
+    _lib.TCOD_heightmap_scale_fbm(hm.p, noise, c_float(mulx), c_float(muly),
1903
+                                  c_float(addx), c_float(addy),
1904
+                                  c_float(octaves), c_float(delta),
1905
+                                  c_float(scale))
1906
+def heightmap_dig_bezier(hm, px, py, startRadius, startDepth, endRadius,
1907
+                         endDepth):
1908
+    IARRAY = c_int * 4
1909
+    cpx = IARRAY(*px)
1910
+    cpy = IARRAY(*py)
1911
+    _lib.TCOD_heightmap_dig_bezier(hm.p, cpx, cpy, c_float(startRadius),
1912
+                                   c_float(startDepth), c_float(endRadius),
1913
+                                   c_float(endDepth))
1914
+
1915
+def heightmap_get_value(hm, x, y):
1916
+    return _lib.TCOD_heightmap_get_value(hm.p, x, y)
1917
+
1918
+def heightmap_get_interpolated_value(hm, x, y):
1919
+    return _lib.TCOD_heightmap_get_interpolated_value(hm.p, c_float(x),
1920
+                                                     c_float(y))
1921
+
1922
+def heightmap_get_slope(hm, x, y):
1923
+    return _lib.TCOD_heightmap_get_slope(hm.p, x, y)
1924
+
1925
+def heightmap_get_normal(hm, x, y, waterLevel):
1926
+    FARRAY = c_float * 3
1927
+    cn = FARRAY()
1928
+    _lib.TCOD_heightmap_get_normal(hm.p, c_float(x), c_float(y), cn,
1929
+                                   c_float(waterLevel))
1930
+    return cn[0], cn[1], cn[2]
1931
+
1932
+def heightmap_count_cells(hm, mi, ma):
1933
+    return _lib.TCOD_heightmap_count_cells(hm.p, c_float(mi), c_float(ma))
1934
+
1935
+def heightmap_has_land_on_border(hm, waterlevel):
1936
+    return _lib.TCOD_heightmap_has_land_on_border(hm.p, c_float(waterlevel))
1937
+
1938
+def heightmap_get_minmax(hm):
1939
+    mi = c_float()
1940
+    ma = c_float()
1941
+    _lib.TCOD_heightmap_get_minmax(hm.p, byref(mi), byref(ma))
1942
+    return mi.value, ma.value
1943
+
1944
+def heightmap_delete(hm):
1945
+    _lib.TCOD_heightmap_delete(hm.p)
1946
+
1947
+
1948
+############################
1949
+# name generator module
1950
+############################
1951
+_lib.TCOD_namegen_generate.restype = c_char_p
1952
+_lib.TCOD_namegen_generate_custom.restype = c_char_p
1953
+
1954
+def namegen_parse(filename,random=0) :
1955
+    _lib.TCOD_namegen_parse(filename,random)
1956
+
1957
+def namegen_generate(name) :
1958
+    return _lib.TCOD_namegen_generate(name, 0)
1959
+
1960
+def namegen_generate_custom(name, rule) :
1961
+    return _lib.TCOD_namegen_generate(name, rule, 0)
1962
+
1963
+def namegen_get_sets():
1964
+    nb=_lib.TCOD_namegen_get_nb_sets_wrapper()
1965
+    SARRAY = c_char_p * nb;
1966
+    setsa = SARRAY()
1967
+    _lib.TCOD_namegen_get_sets_wrapper(setsa)
1968
+    return list(setsa)
1969
+
1970
+def namegen_destroy() :
1971
+    _lib.TCOD_namegen_destroy()
1972
+
1973
+
0 1974
new file mode 100755
1 1975
Binary files /dev/null and b/libtcodxx.so differ
2 1976
new file mode 100755
3 1977
Binary files /dev/null and b/libtcodxx_debug.so differ
4 1978
new file mode 100644
... ...
@@ -0,0 +1,110 @@
1
+import libtcodpy as tc
2
+import numpy as np
3
+
4
+class Player(object):
5
+	@property
6
+	def pos(self):
7
+		return self.x, self.y
8
+
9
+	def __init__(self, x,y, map):
10
+		self.x = x
11
+		self.y = y
12
+		self.char = ord('@')
13
+		self.color = (255,255,255)
14
+		self.map = map
15
+	def move(self, dx, dy):
16
+		self.map.move(self, dx,dy)
17
+		self.x += dx
18
+		self.y += dy
19
+
20
+class Console(object):
21
+	# TBI: must have a self.con member with the console to be drawn on
22
+	pass
23
+
24
+class Screen(object):
25
+	def __init__(self, w, h):
26
+		self.width = w
27
+		self.height = h
28
+		self.con = 0
29
+	def init(self, title, fullscreen=False):
30
+		tc.console_init_root(self.width, self.height, title, fullscreen, 2)
31
+		return self
32
+
33
+class Map(object):
34
+	def __init__(self, w, h):
35
+		self.width = w
36
+		self.height = h
37
+		self.map = np.random.random_integers(ord('a'), ord('z'), (w,h) )
38
+		self.fgcolors = np.random.random_integers(100,255, (w,h,3) )
39
+		self.bgcolors = np.random.random_integers(0,100, (w,h,3) )
40
+		overlays = {} # (x,y): { set( (char,fg), ... ) }
41
+
42
+	def move(self, object, dx,dy):
43
+		overlays[object.pos].remove(object)
44
+		ox,oy = object.pos
45
+		x = ox+dx
46
+		y = oy+dy
47
+		if 0 < x < self.width and 0 < y < self.height:
48
+			self.overlays[x,y] = object
49
+			return x,y
50
+		#elif 
51
+
52
+	def get_rgb(self, fg=True,slices=(slice(0),slice(0))):
53
+		if fg:
54
+			return np.rollaxis(self.fgcolors[slices], 2)
55
+		else:
56
+			return np.rollaxis(self.bgcolors[slices], 2)
57
+
58
+	def draw(self, con, tl=(0,0)):
59
+		br = tl[0]+con.width, tl[1]+con.height
60
+		slices = tuple(map(slice, tl,br))
61
+		tc.console_fill_foreground(con.con, *self.get_rgb(slices=slices))
62
+		tc.console_fill_background(con.con, *self.get_rgb(False,slices=slices))
63
+		tc.console_fill_char(con.con, self.map[slices])
64
+
65
+class EventHandler(object):
66
+	def __init__(self):
67
+		self.key = tc.Key()
68
+		self.mouse = tc.Mouse()
69
+		self.cbs = {}
70
+
71
+	def tick(self):
72
+		tc.sys_check_for_event(tc.EVENT_KEY_PRESS|tc.EVENT_MOUSE|tc.KEY_PRESSED,
73
+			self.key, self.mouse
74
+		)
75
+
76
+		char = chr(self.key.c)
77
+		if char != '\x00' and char in self.cbs:
78
+			for cb in self.cbs[char]:
79
+				cb()
80
+
81
+		elif self.key.vk in self.cbs:
82
+			for cb in self.cbs[self.key.vk]:
83
+				cb()
84
+
85
+
86
+
87
+class Application(object):
88
+	def __init__(self):
89
+		self.screen = Screen(120,75)
90
+		self.map = Map(120,78)
91
+		self.player = Player(40,25, self.map)
92
+		self.events = EventHandler()
93
+
94
+		tc.sys_set_fps(60)
95
+
96
+	def init(self):
97
+		self.screen.init("test")
98
+
99
+	def run(self):
100
+		while not tc.console_is_window_closed():
101
+			self.events.tick()
102
+			self.map.draw(self.screen)
103
+			tc.console_print(0, 0,0, '%d' % tc.sys_get_fps())
104
+			tc.console_flush()
105
+
106
+
107
+if __name__ == '__main__':
108
+	app = Application()
109
+	app.init()
110
+	app.run()
0 111
new file mode 100644
1 112
Binary files /dev/null and b/terminal.png differ