Fix critical issues: script loading, entity types, and color properties
- Issue #37: Fix Windows scripts subdirectory not checked - Updated executeScript() to use executable_path() from platform.h - Scripts now load correctly when working directory differs from executable - Issue #76: Fix UIEntityCollection returns wrong type - Updated UIEntityCollectionIter::next() to check for stored Python object - Derived Entity classes now preserve their type when retrieved from collections - Issue #9: Recreate RenderTexture when resized (already fixed) - Confirmed RenderTexture recreation already implemented in set_size() and set_float_member() - Uses 1.5x padding and 4096 max size limit - Issue #79: Fix Color r, g, b, a properties return None - Implemented get_member() and set_member() in PyColor.cpp - Color component properties now work correctly with proper validation - Additional fix: Grid.at() method signature - Changed from METH_O to METH_VARARGS to accept two arguments All fixes include comprehensive tests to verify functionality. closes #37, closes #76, closes #9, closes #79 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d03182d347
commit
e5affaf317
50 changed files with 3690 additions and 16 deletions
69
example_monitoring.py
Normal file
69
example_monitoring.py
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Example monitoring script that works alongside automation
|
||||
Usage: ./mcrogueface game.py --exec example_automation.py --exec example_monitoring.py
|
||||
"""
|
||||
import mcrfpy
|
||||
import time
|
||||
|
||||
class PerformanceMonitor:
|
||||
def __init__(self):
|
||||
self.start_time = time.time()
|
||||
self.frame_samples = []
|
||||
self.scene_changes = []
|
||||
self.last_scene = None
|
||||
print("Monitor: Performance monitoring initialized")
|
||||
|
||||
def collect_metrics(self):
|
||||
"""Collect performance and state metrics"""
|
||||
current_frame = mcrfpy.getFrame()
|
||||
current_time = time.time() - self.start_time
|
||||
current_scene = mcrfpy.currentScene()
|
||||
|
||||
# Track frame rate
|
||||
if len(self.frame_samples) > 0:
|
||||
last_frame, last_time = self.frame_samples[-1]
|
||||
fps = (current_frame - last_frame) / (current_time - last_time)
|
||||
print(f"Monitor: FPS = {fps:.1f}")
|
||||
|
||||
self.frame_samples.append((current_frame, current_time))
|
||||
|
||||
# Track scene changes
|
||||
if current_scene != self.last_scene:
|
||||
print(f"Monitor: Scene changed from '{self.last_scene}' to '{current_scene}'")
|
||||
self.scene_changes.append((current_time, self.last_scene, current_scene))
|
||||
self.last_scene = current_scene
|
||||
|
||||
# Keep only last 100 samples
|
||||
if len(self.frame_samples) > 100:
|
||||
self.frame_samples = self.frame_samples[-100:]
|
||||
|
||||
def generate_report(self):
|
||||
"""Generate a summary report"""
|
||||
if len(self.frame_samples) < 2:
|
||||
return
|
||||
|
||||
total_frames = self.frame_samples[-1][0] - self.frame_samples[0][0]
|
||||
total_time = self.frame_samples[-1][1] - self.frame_samples[0][1]
|
||||
avg_fps = total_frames / total_time
|
||||
|
||||
print("\n=== Performance Report ===")
|
||||
print(f"Monitor: Total time: {total_time:.1f} seconds")
|
||||
print(f"Monitor: Total frames: {total_frames}")
|
||||
print(f"Monitor: Average FPS: {avg_fps:.1f}")
|
||||
print(f"Monitor: Scene changes: {len(self.scene_changes)}")
|
||||
|
||||
# Stop monitoring
|
||||
mcrfpy.delTimer("performance_monitor")
|
||||
|
||||
# Create monitor instance
|
||||
monitor = PerformanceMonitor()
|
||||
|
||||
# Register monitoring timer (runs every 500ms)
|
||||
mcrfpy.setTimer("performance_monitor", monitor.collect_metrics, 500)
|
||||
|
||||
# Register report generation (runs after 30 seconds)
|
||||
mcrfpy.setTimer("performance_report", monitor.generate_report, 30000)
|
||||
|
||||
print("Monitor: Script loaded - collecting metrics every 500ms")
|
||||
print("Monitor: Will generate report after 30 seconds")
|
||||
Loading…
Add table
Add a link
Reference in a new issue