forked from libtcod/python-tcod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibtcod.py
More file actions
63 lines (45 loc) · 1.51 KB
/
Copy pathlibtcod.py
File metadata and controls
63 lines (45 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""This module handles loading of the libtcod cffi API.
"""
from __future__ import absolute_import as _
import sys as _sys
import os as _os
import platform as _platform
from tcod import __path__
if _sys.platform == 'win32':
# add Windows dll's to PATH
_bits, _linkage = _platform.architecture()
_os.environ['PATH'] = '%s;%s' % (
_os.path.join(__path__[0], 'x86' if _bits == '32bit' else 'x64'),
_os.environ['PATH'],
)
NOISE_DEFAULT_HURST = 0.5
NOISE_DEFAULT_LACUNARITY = 2.0
def FOV_PERMISSIVE(p) :
return FOV_PERMISSIVE_0+p
def BKGND_ALPHA(a):
return BKGND_ALPH | (int(a * 255) << 8)
def BKGND_ADDALPHA(a):
return BKGND_ADDA | (int(a * 255) << 8)
class _Mock(object):
"""Mock object needed for ReadTheDocs."""
CData = () # This gets passed to an isinstance call.
@staticmethod
def def_extern():
"""Pass def_extern call silently."""
return lambda func: func
def __getattr__(self, attr):
"""This object pretends to have everything."""
return self
def __call__(self, *args, **kargs):
"""Suppress any other calls"""
return self
def __str__(self):
"""Just have ? in case anything leaks as a parameter default."""
return '?'
if _os.environ.get('READTHEDOCS'):
# Mock the lib and ffi objects needed to compile docs for readthedocs.io
# Allows an import without building the cffi module first.
lib = ffi = _Mock()
else:
from tcod._libtcod import lib, ffi
from tcod.constants import *