Skip to content

Commit 89a4e38

Browse files
committed
Add context module.
Mouse coordinates are now int types. Import modules on the top package so that you don't need to manually import them.
1 parent 6208d2d commit 89a4e38

File tree

8 files changed

+400
-4
lines changed

8 files changed

+400
-4
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ v2.0.0
88

99
Unreleased
1010
------------------
11+
Added
12+
- Added `tcod.context` module. You now have more options for making libtcod
13+
controlled contexts.
14+
1115
Changed
1216
- `EventDispatch.dispatch` can now return the values returned by the `ev_*`
1317
methods. The class is now generic to support type checking these values.
18+
- Event mouse coordinates are now strictly int types.
19+
- Submodules are now implicitly imported.
1420

1521
11.11.4 - 2020-04-26
1622
--------------------

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Contents:
2929

3030
tcod/bsp
3131
tcod/console
32+
tcod/context
3233
tcod/event
3334
tcod/image
3435
tcod/map

docs/tcod/context.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tcod.context
2+
============
3+
4+
.. automodule:: tcod.context
5+
:members:

tcod/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,41 @@
1818
from tcod.loader import lib, ffi, __sdl_version__ # noqa: F4
1919
from tcod.libtcodpy import * # noqa: F4
2020

21+
from tcod import (
22+
bsp,
23+
color,
24+
console,
25+
context,
26+
event,
27+
image,
28+
map,
29+
noise,
30+
path,
31+
random,
32+
tileset,
33+
)
34+
from tcod.console import Console # noqa: F401
35+
2136
try:
2237
from tcod.version import __version__
2338
except ImportError: # Gets imported without version.py by ReadTheDocs
2439
__version__ = ""
2540

2641
__all__ = [ # noqa: F405
2742
"__version__",
43+
"bsp",
44+
"color",
45+
"console",
46+
"context",
47+
"event",
48+
"tileset",
49+
"image",
50+
"map",
51+
"noise",
52+
"path",
53+
"random",
54+
"tileset",
55+
"Console",
2856
# --- From libtcodpy.py ---
2957
"Color",
3058
"Bsp",

tcod/_internal.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""This module internal helper functions used by the rest of the library.
22
"""
33
import functools
4-
from typing import Any, AnyStr, Callable, TypeVar, cast
4+
from typing import Any, AnyStr, Callable, NoReturn, TypeVar, cast
55
import warnings
66

77
import numpy as np
@@ -57,10 +57,15 @@ def handle_order(shape: Any, order: str) -> Any:
5757
return tuple(reversed(shape))
5858

5959

60+
def _raise_tcod_error() -> NoReturn:
61+
"""Raise an error from libtcod, this function assumes an error exists."""
62+
raise RuntimeError(ffi.string(lib.TCOD_get_error()).decode("utf-8"))
63+
64+
6065
def _check(error: int) -> int:
6166
"""Detect and convert a libtcod error code it into an exception."""
6267
if error < 0:
63-
raise RuntimeError(ffi.string(lib.TCOD_get_error()).decode())
68+
_raise_tcod_error()
6469
return error
6570

6671

0 commit comments

Comments
 (0)