Remove deprecated registerPyAction/registerInputAction system (closes #2, closes #3)

This is our largest net-negative commit yet\! Removed the entire deprecated
action registration system that provided unnecessary two-step indirection:
keyboard → action string → Python callback

Removed components:
- McRFPy_API::_registerPyAction() and _registerInputAction() methods
- McRFPy_API::callbacks map for storing Python callables
- McRFPy_API::doAction() method for executing callbacks
- ACTIONPY macro from Scene.h for detecting "_py" suffixed actions
- Scene::registerActionInjected() and unregisterActionInjected() methods
- tests/api_registerPyAction_issue2_test.py (tested deprecated functionality)

The game now exclusively uses keypressScene() for keyboard input handling,
which is simpler and more direct. Also commented out the unused _camFollow
function that referenced non-existent do_camfollow variable.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John McCardle 2025-07-03 21:43:22 -04:00
commit 281800cd23
6 changed files with 2 additions and 180 deletions

View file

@ -1,90 +0,0 @@
#!/usr/bin/env python3
"""Test for registerPyAction - Related to issue #2 (review necessity)"""
import mcrfpy
from mcrfpy import automation
from datetime import datetime
action_calls = {"test_action": 0, "another_action": 0}
def test_action_handler():
"""Handler for test_action"""
action_calls["test_action"] += 1
print(f"test_action called: {action_calls['test_action']} times")
def another_action_handler():
"""Handler for another_action"""
action_calls["another_action"] += 1
print(f"another_action called: {action_calls['another_action']} times")
def test_registerPyAction():
"""Test registerPyAction functionality (Alpha Blocker Issue #2)"""
print("Testing registerPyAction (Issue #2 - Review necessity)...")
print("This is marked as an Alpha Blocker - may need removal")
# Register actions
try:
mcrfpy.registerPyAction("test_action", test_action_handler)
print("✓ Registered test_action")
mcrfpy.registerPyAction("another_action", another_action_handler)
print("✓ Registered another_action")
except Exception as e:
print(f"✗ registerPyAction failed: {e}")
print("FAIL")
return
# Test registerInputAction to map keys to actions
try:
# These are SFML key codes - may need adjustment
mcrfpy.registerInputAction(0, "test_action") # Key A
mcrfpy.registerInputAction(1, "another_action") # Key B
print("✓ Registered input mappings")
except Exception as e:
print(f"✗ registerInputAction failed: {e}")
# Note: In headless mode, we can't easily trigger these actions
# They would normally be triggered by keyboard input
print("\nAnalysis for Issue #2:")
print("- registerPyAction allows mapping string names to Python callbacks")
print("- registerInputAction maps keyboard codes to action strings")
print("- This creates a two-step indirection: key -> action string -> callback")
print("- Modern approach might be direct key -> callback mapping")
print("- Or use keypressScene() for all keyboard handling")
# Try to trigger actions programmatically if possible
# This depends on internal implementation
def check_results(runtime):
print(f"\nAction call counts:")
print(f"- test_action: {action_calls['test_action']}")
print(f"- another_action: {action_calls['another_action']}")
if action_calls["test_action"] > 0 or action_calls["another_action"] > 0:
print("✓ Actions were triggered")
else:
print("✗ No actions triggered (expected in headless mode)")
# Take screenshot
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
filename = f"test_registerPyAction_issue2_{timestamp}.png"
automation.screenshot(filename)
print(f"Screenshot saved: {filename}")
print("PASS - Test completed, Issue #2 needs review for removal")
mcrfpy.delTimer("check_results")
# In headless mode, run synchronously
print("\nAction call counts:")
print(f"- test_action: {action_calls['test_action']}")
print(f"- another_action: {action_calls['another_action']}")
print("✗ No actions triggered (expected in headless mode)")
print("PASS - Test completed, Issue #2 needs review for removal")
# Run test directly in headless mode
test_registerPyAction()
# Exit cleanly
import sys
sys.exit(0)