Skip to content

Commit 27b424e

Browse files
committed
fixed _set_batch regression, removed dead cffi code
1 parent eaccbd4 commit 27b424e

File tree

3 files changed

+40
-41
lines changed

3 files changed

+40
-41
lines changed

examples/life.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def main():
145145
console.clear()
146146
for x, y in board.live_cells:
147147
console.draw_char(x, y, '*')
148+
#console.draw_rect(0, -1, None, None, None, bg=(64, 64, 80))
148149
console.draw_rect(0, -1, None, None, None, bg=(64, 64, 80))
149150
console.draw_str(0, -1, "Mouse:Toggle Cells, Space:%5s, [S]tep, [C]lear, [W]rap Turn %s" % (['Play', 'Pause'][play], ['On', 'Off'][board.wrap]), None, None)
150151
if (mouse_x, mouse_y) in console:

tdl/__init__.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -978,30 +978,32 @@ def _set_batch(self, batch, fg, bg, bgblend=1, nullChar=False):
978978
if bg is Ellipsis:
979979
bg = self._bg
980980

981-
if fg != -1:
982-
fg = _to_tcod_color(fg)
983-
if bg != -1:
984-
bg = _to_tcod_color(bg)
981+
#if fg != -1:
982+
# fg = _to_tcod_color(fg)
983+
#if bg != -1:
984+
# bg = _to_tcod_color(bg)
985985

986-
987-
if fg != -1 and not nullChar:
988-
# buffer values as ctypes objects
989-
self._typewriter = None # clear the typewriter as colors will be set
990-
console = self._as_parameter_
991-
#bgblend = _ctypes.c_int(bgblend)
992-
993-
if bg == -1:
994-
bgblend = 0
995-
else:
996-
_lib.TCOD_console_set_default_background(console, bg[0])
997-
_lib.TCOD_console_set_default_foreground(console, fg[0])
998-
_putChar = _lib.TCOD_console_put_char # remove dots and make local
999-
for (x, y), char in batch:
1000-
_putChar(console, x, y, char, bgblend)
986+
for (x, y), char in batch:
987+
self._set_char(x, y, char, fg, bg, bgblend)
1001988

1002-
else:
1003-
for (x, y), char in batch:
1004-
self._set_char(x, y, char, fg, bg, bgblend)
989+
# if fg != -1 and not nullChar:
990+
# # buffer values as ctypes objects
991+
# self._typewriter = None # clear the typewriter as colors will be set
992+
# console = self._as_parameter_
993+
# #bgblend = _ctypes.c_int(bgblend)
994+
995+
# if bg == -1:
996+
# bgblend = 0
997+
# else:
998+
# _lib.TCOD_console_set_default_background(console, bg[0])
999+
# _lib.TCOD_console_set_default_foreground(console, fg[0])
1000+
# _putChar = _lib.TCOD_console_put_char # remove dots and make local
1001+
# for (x, y), char in batch:
1002+
# _putChar(console, x, y, char, bgblend)
1003+
1004+
# else:
1005+
# for (x, y), char in batch:
1006+
# self._set_char(x, y, char, fg, bg, bgblend)
10051007

10061008
def get_char(self, x, y):
10071009
# inherit docstring

tdl/libtcod.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11

2-
import os as _os
3-
from tdl import __path__
2+
import sys
3+
import os
44

5-
_os.environ['PATH'] += ';' + _os.path.join(__path__[0], 'lib/win32/')
6-
7-
from ._libtcod import ffi
5+
import platform
86

7+
from . import __path__
98

109
try: # decide how files are unpacked depending on if we have the pkg_resources module
1110
from pkg_resources import resource_filename
@@ -14,36 +13,33 @@ def _unpackfile(filename):
1413
except ImportError:
1514
#from tdl import __path__
1615
def _unpackfile(filename):
17-
return _os.path.abspath(_os.path.join(__path__[0], filename))
16+
return os.path.abspath(os.path.join(__path__[0], filename))
1817

1918
def _unpackFramework(framework, path):
2019
"""get framework.tar file, remove ".tar" and add path"""
21-
return _os.path.abspath(_os.path.join(_unpackfile(framework)[:-4], path))
20+
return os.path.abspath(os.path.join(_unpackfile(framework)[:-4], path))
2221

2322
def _loadDLL(dll):
2423
"""shorter version of file unpacking and linking"""
2524
return ffi.LoadLibrary(_unpackfile(dll))
2625

2726
def _get_library_crossplatform():
2827
bits, linkage = platform.architecture()
29-
libpath = None
3028
if 'win32' in sys.platform:
31-
pass
29+
return 'lib/win32/'
3230
elif 'linux' in sys.platform:
3331
if bits == '32bit':
34-
pass
32+
return 'lib/linux32/'
3533
elif bits == '64bit':
36-
pass
34+
return 'lib/linux64/'
3735
elif 'darwin' in sys.platform:
38-
pass
39-
else:
40-
raise ImportError('Operating system "%s" has no supported dynamic link libarary. (%s, %s)' % (sys.platform, bits, linkage))
41-
return libTCOD, libSDL
36+
return 'lib/darwin/'
37+
raise ImportError('Operating system "%s" has no supported dynamic link libarary. (%s, %s)' % (sys.platform, bits, linkage))
4238

39+
os.environ['PATH'] += ';' + os.path.join(__path__[0],
40+
_get_library_crossplatform())
4341

44-
ffi.dlopen(_unpackfile('lib/win32/zlib1.dll'))
45-
ffi.dlopen(_unpackfile('lib/win32/SDL.dll'))
46-
lib = ffi.dlopen(_unpackfile('lib/win32/libtcod-VS.dll'))
42+
from ._libtcod import ffi, lib
4743

4844
_ffi = ffi
49-
_lib = lib
45+
_lib = lib

0 commit comments

Comments
 (0)