Skip to content

Commit 6c0b70f

Browse files
committed
Deprecate older keyboard constants.
Add warnings telling which enum replaces any key. Test deprecated keys and colors.
1 parent cac2835 commit 6c0b70f

5 files changed

Lines changed: 62 additions & 970 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ This project adheres to [Semantic Versioning](https://semver.org/) since version
55

66
## [Unreleased]
77
### Deprecated
8-
- Deprecated all color constants
8+
- Deprecated all libtcod color constants. Replace these with your own manually defined colors.
9+
Using a color will tell you the color values of the deprecated color in the warning.
10+
- Deprecated older scancode and keysym constants. These were replaced with the Scancode and KeySym enums.
911

1012
### Fixed
1113
- DLL loader could fail to load `SDL2.dll` when other tcod namespace packages were installed.

build_libtcod.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,8 @@ def find_sdl_attrs(prefix: str) -> Iterator[Tuple[str, Union[int, str, Any]]]:
256256
yield attr[name_starts_at:], getattr(lib, attr)
257257

258258

259-
def parse_sdl_attrs(prefix: str, all_names: List[str]) -> Tuple[str, str]:
260-
"""Return the name/value pairs, and the final dictionary string for the
261-
library attributes with `prefix`.
259+
def parse_sdl_attrs(prefix: str, all_names: list[str] | None) -> tuple[str, str]:
260+
"""Return the name/value pairs, and the final dictionary string for the library attributes with `prefix`.
262261
263262
Append matching names to the `all_names` list.
264263
"""
@@ -267,10 +266,11 @@ def parse_sdl_attrs(prefix: str, all_names: List[str]) -> Tuple[str, str]:
267266
for name, value in sorted(find_sdl_attrs(prefix), key=lambda item: item[1]):
268267
if name == "KMOD_RESERVED":
269268
continue
270-
all_names.append(name)
269+
if all_names is not None:
270+
all_names.append(name)
271271
names.append(f"{name} = {value}")
272272
lookup.append(f'{value}: "{name}"')
273-
return "\n".join(names), "{\n %s,\n}" % (",\n ".join(lookup),)
273+
return "\n".join(names), "{{\n {},\n}}".format(",\n ".join(lookup))
274274

275275

276276
EXCLUDE_CONSTANTS = [
@@ -370,10 +370,10 @@ def write_library_constants() -> None:
370370
all_names = []
371371
f.write(EVENT_CONSTANT_MODULE_HEADER)
372372
f.write("\n# --- SDL scancodes ---\n")
373-
f.write(f"""{parse_sdl_attrs("SDL_SCANCODE", all_names)[0]}\n""")
373+
f.write(f"""{parse_sdl_attrs("SDL_SCANCODE", None)[0]}\n""")
374374

375375
f.write("\n# --- SDL keyboard symbols ---\n")
376-
f.write(f"""{parse_sdl_attrs("SDLK", all_names)[0]}\n""")
376+
f.write(f"""{parse_sdl_attrs("SDLK", None)[0]}\n""")
377377

378378
f.write("\n# --- SDL keyboard modifiers ---\n")
379379
f.write("%s\n_REVERSE_MOD_TABLE = %s\n" % parse_sdl_attrs("KMOD", all_names))

0 commit comments

Comments
 (0)