|
1
|
|
|
"""This module handles loading of the libtcod cffi API. |
|
2
|
|
|
""" |
|
3
|
|
|
from __future__ import absolute_import as _ |
|
4
|
|
|
|
|
5
|
|
|
import sys as _sys |
|
6
|
|
|
import os as _os |
|
7
|
|
|
|
|
8
|
|
|
import platform as _platform |
|
9
|
|
|
|
|
10
|
|
|
from tcod import __path__ |
|
11
|
|
|
|
|
12
|
|
|
# add Windows dll's to PATH |
|
13
|
|
|
if _sys.platform == 'win32': |
|
14
|
|
|
_bits, _linkage = _platform.architecture() |
|
15
|
|
|
_os.environ['PATH'] += (';' + |
|
16
|
|
|
_os.path.join(__path__[0], 'x86/' if _bits == '32bit' else 'x64')) |
|
17
|
|
|
|
|
18
|
|
|
from tcod._libtcod import lib, ffi |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
def _import_library_functions(lib): |
|
|
|
|
|
|
21
|
|
|
# imports libtcod namespace into thie module |
|
22
|
|
|
# does not override existing names |
|
23
|
|
|
g = globals() |
|
24
|
|
|
for name in dir(lib): |
|
25
|
|
|
if name[:5] == 'TCOD_': |
|
26
|
|
|
if (isinstance(getattr(lib, name), ffi.CData) and |
|
27
|
|
|
ffi.typeof(getattr(lib, name)) == ffi.typeof('TCOD_color_t')): |
|
28
|
|
|
g[name[5:]] = _FrozenColor.from_cdata(getattr(lib, name)) |
|
29
|
|
|
elif name.isupper(): |
|
30
|
|
|
g[name[5:]] = getattr(lib, name) # const names |
|
31
|
|
|
#else: |
|
32
|
|
|
# g[name[5:]] = getattr(lib, name) # function names |
|
33
|
|
|
elif name[:6] == 'TCODK_': # key name |
|
34
|
|
|
g['KEY_' + name[6:]] = getattr(lib, name) |
|
35
|
|
|
|
|
36
|
|
|
NOISE_DEFAULT_HURST = 0.5 |
|
37
|
|
|
NOISE_DEFAULT_LACUNARITY = 2.0 |
|
38
|
|
|
|
|
39
|
|
|
def FOV_PERMISSIVE(p) : |
|
|
|
|
|
|
40
|
|
|
return FOV_PERMISSIVE_0+p |
|
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
def BKGND_ALPHA(a): |
|
|
|
|
|
|
43
|
|
|
return BKGND_ALPH | (int(a * 255) << 8) |
|
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
def BKGND_ADDALPHA(a): |
|
|
|
|
|
|
46
|
|
|
return BKGND_ADDA | (int(a * 255) << 8) |
|
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
from tcod.tcod import FrozenColor as _FrozenColor |
|
49
|
|
|
|
|
50
|
|
|
_import_library_functions(lib) |
|
51
|
|
|
|
|
52
|
|
|
__all__ = [_name for _name in list(globals()) if _name[0] != '_'] |
|
53
|
|
|
|