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

@ -44,7 +44,7 @@ entity.sprite_index = 64 # @
# UI setup
ui = test_anim.children
ui.append(grid)
grid.position = (100, 100)
grid.pos = (100, 100)
grid.size = (450, 450) # 15 * 30 pixels per cell
# Title
@ -160,23 +160,21 @@ def test_immediate_position():
# Input handler
def handle_input(key, state):
if state != "start":
if state != mcrfpy.InputState.PRESSED:
return
key = key.lower()
if key == "q":
if key == mcrfpy.Key.Q:
print("Exiting test...")
sys.exit(0)
elif key == "space":
elif key == mcrfpy.Key.SPACE:
if not animating:
start_animation()
else:
print("Animation already in progress!")
elif key == "t":
elif key == mcrfpy.Key.T:
# Test immediate position change
test_immediate_position()
elif key == "r":
elif key == mcrfpy.Key.R:
# Reset position
entity.x = 5
entity.y = 5