Remove legacy string enum comparisons from InputState/Key/MouseButton, closes #306

Removed custom __eq__/__ne__ that allowed comparing enums to legacy string
names (e.g., Key.ESCAPE == "Escape"). Removed _legacy_names dicts and
to_legacy_string() functions. Kept from_legacy_string() in PyKey.cpp as
it's used by C++ event dispatch. Updated ~50 Python test/demo/cookbook
files to use enum members instead of string comparisons. Also updates
grid.position -> grid.pos in files that had both types of changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-04-09 22:19:02 -04:00
commit 6d5e99a114
52 changed files with 372 additions and 533 deletions

View file

@ -55,15 +55,15 @@ test_count = 0
def on_key(key, state):
global test_count
if state != "start":
if state != mcrfpy.InputState.PRESSED:
return
if key == "Num1" or key == "1":
if key == mcrfpy.Key.NUM_1:
test_frame.shader_enabled = True
status.text = "Status: Shader ENABLED"
update_display()
test_count += 1
elif key == "Num2" or key == "2":
elif key == mcrfpy.Key.NUM_2:
test_frame.shader_enabled = False
status.text = "Status: Shader DISABLED"
update_display()
@ -76,7 +76,7 @@ def on_key(key, state):
else:
status.text = "Status: Shader DISABLED - Position OK!"
status.fill_color = (100, 255, 100, 255)
elif key in ("Q", "Escape"):
elif key in (mcrfpy.Key.Q, mcrfpy.Key.ESCAPE):
if test_frame.x == 200 and test_frame.y == 200:
print(f"PASS: Position remained correct after {test_count} toggles")
else: