McRogueFace/src/McRFPy_API.cpp

1410 lines
51 KiB
C++
Raw Normal View History

#include "McRFPy_API.h"
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
#include "McRFPy_Automation.h"
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
#include "McRFPy_Libtcod.h"
#include "McRFPy_Doc.h"
#include "platform.h"
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
#include "PyAnimation.h"
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
#include "PyDrawable.h"
#include "PyTimer.h"
#include "PyWindow.h"
#include "PySceneObject.h"
#include "PyFOV.h"
2026-01-03 13:53:18 -05:00
#include "PyTransition.h"
2026-01-04 12:59:28 -05:00
#include "PyEasing.h"
#include "PySound.h"
#include "PyMusic.h"
#include "PyKeyboard.h"
#include "PyMouse.h"
#include "McRogueFaceVersion.h"
#include "GameEngine.h"
#include "ImGuiConsole.h"
#include "BenchmarkLogger.h"
#include "UI.h"
#include "UILine.h"
#include "UICircle.h"
#include "UIArc.h"
#include "GridLayers.h"
#include "Resources.h"
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
#include "PyScene.h"
#include "PythonObjectCache.h"
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
#include <filesystem>
#include <cstring>
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
#include <libtcod.h>
std::shared_ptr<PyFont> McRFPy_API::default_font;
std::shared_ptr<PyTexture> McRFPy_API::default_texture;
PyObject* McRFPy_API::mcrf_module;
// Exception handling state
std::atomic<bool> McRFPy_API::exception_occurred{false};
std::atomic<int> McRFPy_API::exit_code{0};
// #151: Module-level __getattr__ for dynamic properties (current_scene, scenes)
static PyObject* mcrfpy_module_getattr(PyObject* self, PyObject* args)
{
const char* name;
if (!PyArg_ParseTuple(args, "s", &name)) {
return NULL;
}
if (strcmp(name, "current_scene") == 0) {
return McRFPy_API::api_get_current_scene();
}
if (strcmp(name, "scenes") == 0) {
return McRFPy_API::api_get_scenes();
}
if (strcmp(name, "timers") == 0) {
return McRFPy_API::api_get_timers();
}
2026-01-03 13:53:18 -05:00
if (strcmp(name, "default_transition") == 0) {
return PyTransition::to_python(PyTransition::default_transition);
}
if (strcmp(name, "default_transition_duration") == 0) {
return PyFloat_FromDouble(PyTransition::default_duration);
}
// Attribute not found - raise AttributeError
PyErr_Format(PyExc_AttributeError, "module 'mcrfpy' has no attribute '%s'", name);
return NULL;
}
// #151: Custom module type with __setattr__ support for current_scene
static int mcrfpy_module_setattro(PyObject* self, PyObject* name, PyObject* value)
{
const char* name_str = PyUnicode_AsUTF8(name);
if (!name_str) return -1;
if (strcmp(name_str, "current_scene") == 0) {
return McRFPy_API::api_set_current_scene(value);
}
if (strcmp(name_str, "scenes") == 0) {
PyErr_SetString(PyExc_AttributeError, "'scenes' is read-only");
return -1;
}
if (strcmp(name_str, "timers") == 0) {
PyErr_SetString(PyExc_AttributeError, "'timers' is read-only");
return -1;
}
2026-01-03 13:53:18 -05:00
if (strcmp(name_str, "default_transition") == 0) {
TransitionType trans;
if (!PyTransition::from_arg(value, &trans, nullptr)) {
return -1;
}
PyTransition::default_transition = trans;
return 0;
}
if (strcmp(name_str, "default_transition_duration") == 0) {
double duration;
if (PyFloat_Check(value)) {
duration = PyFloat_AsDouble(value);
} else if (PyLong_Check(value)) {
duration = PyLong_AsDouble(value);
} else {
PyErr_SetString(PyExc_TypeError, "default_transition_duration must be a number");
return -1;
}
if (duration < 0.0) {
PyErr_SetString(PyExc_ValueError, "default_transition_duration must be non-negative");
return -1;
}
PyTransition::default_duration = static_cast<float>(duration);
return 0;
}
// For other attributes, use default module setattr
return PyObject_GenericSetAttr(self, name, value);
}
// Custom module type that inherits from PyModule_Type but has our __setattr__
static PyTypeObject McRFPyModuleType = {
.ob_base = {.ob_base = {.ob_refcnt = 1, .ob_type = NULL}, .ob_size = 0},
.tp_name = "mcrfpy.module",
.tp_basicsize = 0, // Inherited from base
.tp_itemsize = 0,
.tp_dealloc = NULL,
.tp_vectorcall_offset = 0,
.tp_getattr = NULL,
.tp_setattr = NULL,
.tp_as_async = NULL,
.tp_repr = NULL,
.tp_as_number = NULL,
.tp_as_sequence = NULL,
.tp_as_mapping = NULL,
.tp_hash = NULL,
.tp_call = NULL,
.tp_str = NULL,
.tp_getattro = NULL,
.tp_setattro = mcrfpy_module_setattro,
.tp_as_buffer = NULL,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_doc = "McRogueFace module with property support",
};
static PyMethodDef mcrfpyMethods[] = {
// Note: setTimer and delTimer removed in #173 - use Timer objects instead
{"step", McRFPy_API::_step, METH_VARARGS,
MCRF_FUNCTION(step,
MCRF_SIG("(dt: float = None)", "float"),
MCRF_DESC("Advance simulation time (headless mode only)."),
MCRF_ARGS_START
MCRF_ARG("dt", "Time to advance in seconds. If None, advances to the next scheduled event (timer/animation).")
MCRF_RETURNS("float: Actual time advanced in seconds. Returns 0.0 in windowed mode.")
MCRF_NOTE("In windowed mode, this is a no-op and returns 0.0. Use this for deterministic simulation control in headless/testing scenarios.")
)},
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
{"exit", McRFPy_API::_exit, METH_NOARGS,
MCRF_FUNCTION(exit,
MCRF_SIG("()", "None"),
MCRF_DESC("Cleanly shut down the game engine and exit the application."),
MCRF_RETURNS("None")
MCRF_NOTE("This immediately closes the window and terminates the program.")
)},
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
{"setScale", McRFPy_API::_setScale, METH_VARARGS,
MCRF_FUNCTION(setScale,
MCRF_SIG("(multiplier: float)", "None"),
MCRF_DESC("Scale the game window size."),
MCRF_ARGS_START
MCRF_ARG("multiplier", "Scale factor (e.g., 2.0 for double size)")
MCRF_RETURNS("None")
MCRF_NOTE("The internal resolution remains 1024x768, but the window is scaled. This is deprecated - use Window.resolution instead.")
)},
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
{"find", McRFPy_API::_find, METH_VARARGS,
MCRF_FUNCTION(find,
MCRF_SIG("(name: str, scene: str = None)", "UIDrawable | None"),
MCRF_DESC("Find the first UI element with the specified name."),
MCRF_ARGS_START
MCRF_ARG("name", "Exact name to search for")
MCRF_ARG("scene", "Scene to search in (default: current scene)")
MCRF_RETURNS("Frame, Caption, Sprite, Grid, or Entity if found; None otherwise")
MCRF_NOTE("Searches scene UI elements and entities within grids.")
)},
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
{"findAll", McRFPy_API::_findAll, METH_VARARGS,
MCRF_FUNCTION(findAll,
MCRF_SIG("(pattern: str, scene: str = None)", "list"),
MCRF_DESC("Find all UI elements matching a name pattern."),
MCRF_ARGS_START
MCRF_ARG("pattern", "Name pattern with optional wildcards (* matches any characters)")
MCRF_ARG("scene", "Scene to search in (default: current scene)")
MCRF_RETURNS("list: All matching UI elements and entities")
MCRF_NOTE("Example: findAll('enemy*') finds all elements starting with 'enemy', findAll('*_button') finds all elements ending with '_button'")
)},
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
{"getMetrics", McRFPy_API::_getMetrics, METH_NOARGS,
MCRF_FUNCTION(getMetrics,
MCRF_SIG("()", "dict"),
MCRF_DESC("Get current performance metrics."),
MCRF_RETURNS("dict: Performance data with keys: frame_time (last frame duration in seconds), avg_frame_time (average frame time), fps (frames per second), draw_calls (number of draw calls), ui_elements (total UI element count), visible_elements (visible element count), current_frame (frame counter), runtime (total runtime in seconds)")
)},
{"setDevConsole", McRFPy_API::_setDevConsole, METH_VARARGS,
MCRF_FUNCTION(setDevConsole,
MCRF_SIG("(enabled: bool)", "None"),
MCRF_DESC("Enable or disable the developer console overlay."),
MCRF_ARGS_START
MCRF_ARG("enabled", "True to enable the console (default), False to disable")
MCRF_RETURNS("None")
MCRF_NOTE("When disabled, the grave/tilde key will not open the console. Use this to ship games without debug features.")
)},
{"start_benchmark", McRFPy_API::_startBenchmark, METH_NOARGS,
MCRF_FUNCTION(start_benchmark,
MCRF_SIG("()", "None"),
MCRF_DESC("Start capturing benchmark data to a file."),
MCRF_RETURNS("None")
MCRF_RAISES("RuntimeError", "If a benchmark is already running")
MCRF_NOTE("Benchmark filename is auto-generated from PID and timestamp. Use end_benchmark() to stop and get filename.")
)},
{"end_benchmark", McRFPy_API::_endBenchmark, METH_NOARGS,
MCRF_FUNCTION(end_benchmark,
MCRF_SIG("()", "str"),
MCRF_DESC("Stop benchmark capture and write data to JSON file."),
MCRF_RETURNS("str: The filename of the written benchmark data")
MCRF_RAISES("RuntimeError", "If no benchmark is currently running")
MCRF_NOTE("Returns the auto-generated filename (e.g., 'benchmark_12345_20250528_143022.json')")
)},
{"log_benchmark", McRFPy_API::_logBenchmark, METH_VARARGS,
MCRF_FUNCTION(log_benchmark,
MCRF_SIG("(message: str)", "None"),
MCRF_DESC("Add a log message to the current benchmark frame."),
MCRF_ARGS_START
MCRF_ARG("message", "Text to associate with the current frame")
MCRF_RETURNS("None")
MCRF_RAISES("RuntimeError", "If no benchmark is currently running")
MCRF_NOTE("Messages appear in the 'logs' array of each frame in the output JSON.")
)},
// #151: Module-level attribute access for current_scene and scenes
{"__getattr__", mcrfpy_module_getattr, METH_VARARGS,
"Module-level __getattr__ for dynamic properties (current_scene, scenes)"},
{NULL, NULL, 0, NULL}
};
static PyModuleDef mcrfpyModule = {
PyModuleDef_HEAD_INIT, /* m_base - Always initialize this member to PyModuleDef_HEAD_INIT. */
"mcrfpy", /* m_name */
PyDoc_STR("McRogueFace Python API\n\n"
"Core game engine interface for creating roguelike games with Python.\n\n"
"This module provides:\n"
2026-01-03 11:01:42 -05:00
"- Scene management via Scene objects (mcrfpy.Scene, mcrfpy.current_scene)\n"
"- UI components (Frame, Caption, Sprite, Grid)\n"
"- Entity system for game objects\n"
"- Audio playback (sound effects and music)\n"
"- Timer system for scheduled events\n"
"- Input handling\n"
"- Performance metrics\n\n"
"Example:\n"
" import mcrfpy\n"
" \n"
2026-01-03 11:01:42 -05:00
" # Create and activate a scene\n"
" scene = mcrfpy.Scene('game')\n"
" scene.activate()\n"
" \n"
" # Add UI elements\n"
" frame = mcrfpy.Frame(10, 10, 200, 100)\n"
" caption = mcrfpy.Caption('Hello World', 50, 50)\n"
2026-01-03 11:01:42 -05:00
" scene.children.extend([frame, caption])\n"
" \n"
" # Set keyboard handler\n"
" scene.on_key = lambda key, action: print(f'{key} {action}')\n"),
-1, /* m_size - Setting m_size to -1 means that the module does not support sub-interpreters, because it has global state. */
mcrfpyMethods, /* m_methods */
NULL, /* m_slots - An array of slot definitions ... When using single-phase initialization, m_slots must be NULL. */
NULL, /* traverseproc m_traverse - A traversal function to call during GC traversal of the module object */
NULL, /* inquiry m_clear - A clear function to call during GC clearing of the module object */
NULL /* freefunc m_free - A function to call during deallocation of the module object */
};
// Module initializer fn, passed to PyImport_AppendInittab
PyObject* PyInit_mcrfpy()
{
PyObject* m = PyModule_Create(&mcrfpyModule);
if (m == NULL)
{
return NULL;
}
// #151: Set up custom module type for current_scene/scenes property support
// The custom type inherits from PyModule_Type and adds __setattr__ handling
McRFPyModuleType.tp_base = &PyModule_Type;
if (PyType_Ready(&McRFPyModuleType) < 0) {
std::cout << "ERROR: PyType_Ready failed for McRFPyModuleType" << std::endl;
return NULL;
}
// Change the module's type to our custom type
Py_SET_TYPE(m, &McRFPyModuleType);
Squashed commit of the following: [standardize_texture_handling] closes #18 commit b114ec308518607fad5777c6c1b516381e2a78b9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 22:22:35 2024 -0400 cleaning up for merge commit d7228172c4d5455159cd91782b49304a971bb444 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 21:39:15 2024 -0400 Messy, but monumental: PyTexture::pyObject works this also coincidentally fixes a weird bug I encountered while (mis?)using tp_alloc: by using PyType_GenericAlloc, I avoid the segfault that tp_alloc sometimes causes. See the horrible UIDrawable retrieval macro that I use in UI.h for a workaround that can probably be replaced with this technique commit 2cf8f9431025b3eecb67422e98ec95e3f2b4038f Author: John McCardle <mccardle.john@gmail.com> Date: Wed Mar 20 21:16:52 2024 -0400 Radical new example pattern for exposing a C++ class to Python commit 84a8886da2570a8087f83141f0d41fef65073d99 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:29:33 2024 -0400 Fixed render issue with UIGrid / PyTexture: wasn't positioning or scaling properly after fetching sprite commit 20f80c4114fce029faf28a195ffdbb041181e484 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:23:52 2024 -0400 Fixed sprite indexing error in PyTexture; needs non-square sprite tests, but feeling confident! commit afd4ff1925382622abf79db132b6123ee33b946b Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 21:53:24 2024 -0400 good progress, we're building again. Issue with Grid (tile sprite) textures and I think the sprite indexes are being calculated wrong (x and y transposed?) commit bfd33102d13072eb4624cb07dcf5a55a98e93aa0 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 14:52:35 2024 -0400 Squashed basically all the compile bugs in UISprite, but UIEntity and UIGrid use textures as well, so they need to be fixed too before the project will build again commit 47d0e34a17eb4aa86f781d0a022180d637cec602 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 11:31:39 2024 -0400 Initial PyTexture class no testing done. should enable rectangular (non-square) textures "sprite" method; let's just overwrite sprites with texture coords Hoping to replace awful code like: `self->data->sprite.sprite.setTextureRect(self->data->sprite.itex->spriteCoordinates(val));` with something like: `self->data->sprite = self->data->texture->sprite(val);`
2024-03-21 22:24:42 -04:00
using namespace mcrfpydef;
// Types that are exported to Python (visible in module namespace)
PyTypeObject* exported_types[] = {
Squashed commit of the following: [standardize_texture_handling] closes #18 commit b114ec308518607fad5777c6c1b516381e2a78b9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 22:22:35 2024 -0400 cleaning up for merge commit d7228172c4d5455159cd91782b49304a971bb444 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 21:39:15 2024 -0400 Messy, but monumental: PyTexture::pyObject works this also coincidentally fixes a weird bug I encountered while (mis?)using tp_alloc: by using PyType_GenericAlloc, I avoid the segfault that tp_alloc sometimes causes. See the horrible UIDrawable retrieval macro that I use in UI.h for a workaround that can probably be replaced with this technique commit 2cf8f9431025b3eecb67422e98ec95e3f2b4038f Author: John McCardle <mccardle.john@gmail.com> Date: Wed Mar 20 21:16:52 2024 -0400 Radical new example pattern for exposing a C++ class to Python commit 84a8886da2570a8087f83141f0d41fef65073d99 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:29:33 2024 -0400 Fixed render issue with UIGrid / PyTexture: wasn't positioning or scaling properly after fetching sprite commit 20f80c4114fce029faf28a195ffdbb041181e484 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:23:52 2024 -0400 Fixed sprite indexing error in PyTexture; needs non-square sprite tests, but feeling confident! commit afd4ff1925382622abf79db132b6123ee33b946b Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 21:53:24 2024 -0400 good progress, we're building again. Issue with Grid (tile sprite) textures and I think the sprite indexes are being calculated wrong (x and y transposed?) commit bfd33102d13072eb4624cb07dcf5a55a98e93aa0 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 14:52:35 2024 -0400 Squashed basically all the compile bugs in UISprite, but UIEntity and UIGrid use textures as well, so they need to be fixed too before the project will build again commit 47d0e34a17eb4aa86f781d0a022180d637cec602 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 11:31:39 2024 -0400 Initial PyTexture class no testing done. should enable rectangular (non-square) textures "sprite" method; let's just overwrite sprites with texture coords Hoping to replace awful code like: `self->data->sprite.sprite.setTextureRect(self->data->sprite.itex->spriteCoordinates(val));` with something like: `self->data->sprite = self->data->texture->sprite(val);`
2024-03-21 22:24:42 -04:00
/*SFML exposed types*/
&PyColorType, /*&PyLinkedColorType,*/ &PyFontType, &PyTextureType, &PyVectorType,
Squashed commit of the following: [standardize_texture_handling] closes #18 commit b114ec308518607fad5777c6c1b516381e2a78b9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 22:22:35 2024 -0400 cleaning up for merge commit d7228172c4d5455159cd91782b49304a971bb444 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 21:39:15 2024 -0400 Messy, but monumental: PyTexture::pyObject works this also coincidentally fixes a weird bug I encountered while (mis?)using tp_alloc: by using PyType_GenericAlloc, I avoid the segfault that tp_alloc sometimes causes. See the horrible UIDrawable retrieval macro that I use in UI.h for a workaround that can probably be replaced with this technique commit 2cf8f9431025b3eecb67422e98ec95e3f2b4038f Author: John McCardle <mccardle.john@gmail.com> Date: Wed Mar 20 21:16:52 2024 -0400 Radical new example pattern for exposing a C++ class to Python commit 84a8886da2570a8087f83141f0d41fef65073d99 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:29:33 2024 -0400 Fixed render issue with UIGrid / PyTexture: wasn't positioning or scaling properly after fetching sprite commit 20f80c4114fce029faf28a195ffdbb041181e484 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:23:52 2024 -0400 Fixed sprite indexing error in PyTexture; needs non-square sprite tests, but feeling confident! commit afd4ff1925382622abf79db132b6123ee33b946b Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 21:53:24 2024 -0400 good progress, we're building again. Issue with Grid (tile sprite) textures and I think the sprite indexes are being calculated wrong (x and y transposed?) commit bfd33102d13072eb4624cb07dcf5a55a98e93aa0 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 14:52:35 2024 -0400 Squashed basically all the compile bugs in UISprite, but UIEntity and UIGrid use textures as well, so they need to be fixed too before the project will build again commit 47d0e34a17eb4aa86f781d0a022180d637cec602 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 11:31:39 2024 -0400 Initial PyTexture class no testing done. should enable rectangular (non-square) textures "sprite" method; let's just overwrite sprites with texture coords Hoping to replace awful code like: `self->data->sprite.sprite.setTextureRect(self->data->sprite.itex->spriteCoordinates(val));` with something like: `self->data->sprite = self->data->texture->sprite(val);`
2024-03-21 22:24:42 -04:00
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
/*Base classes*/
&PyDrawableType,
Squashed commit of the following: [standardize_texture_handling] closes #18 commit b114ec308518607fad5777c6c1b516381e2a78b9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 22:22:35 2024 -0400 cleaning up for merge commit d7228172c4d5455159cd91782b49304a971bb444 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 21:39:15 2024 -0400 Messy, but monumental: PyTexture::pyObject works this also coincidentally fixes a weird bug I encountered while (mis?)using tp_alloc: by using PyType_GenericAlloc, I avoid the segfault that tp_alloc sometimes causes. See the horrible UIDrawable retrieval macro that I use in UI.h for a workaround that can probably be replaced with this technique commit 2cf8f9431025b3eecb67422e98ec95e3f2b4038f Author: John McCardle <mccardle.john@gmail.com> Date: Wed Mar 20 21:16:52 2024 -0400 Radical new example pattern for exposing a C++ class to Python commit 84a8886da2570a8087f83141f0d41fef65073d99 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:29:33 2024 -0400 Fixed render issue with UIGrid / PyTexture: wasn't positioning or scaling properly after fetching sprite commit 20f80c4114fce029faf28a195ffdbb041181e484 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:23:52 2024 -0400 Fixed sprite indexing error in PyTexture; needs non-square sprite tests, but feeling confident! commit afd4ff1925382622abf79db132b6123ee33b946b Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 21:53:24 2024 -0400 good progress, we're building again. Issue with Grid (tile sprite) textures and I think the sprite indexes are being calculated wrong (x and y transposed?) commit bfd33102d13072eb4624cb07dcf5a55a98e93aa0 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 14:52:35 2024 -0400 Squashed basically all the compile bugs in UISprite, but UIEntity and UIGrid use textures as well, so they need to be fixed too before the project will build again commit 47d0e34a17eb4aa86f781d0a022180d637cec602 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 11:31:39 2024 -0400 Initial PyTexture class no testing done. should enable rectangular (non-square) textures "sprite" method; let's just overwrite sprites with texture coords Hoping to replace awful code like: `self->data->sprite.sprite.setTextureRect(self->data->sprite.itex->spriteCoordinates(val));` with something like: `self->data->sprite = self->data->texture->sprite(val);`
2024-03-21 22:24:42 -04:00
/*UI widgets*/
&PyUICaptionType, &PyUISpriteType, &PyUIFrameType, &PyUIEntityType, &PyUIGridType,
&PyUILineType, &PyUICircleType, &PyUIArcType,
Squashed commit of the following: [standardize_texture_handling] closes #18 commit b114ec308518607fad5777c6c1b516381e2a78b9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 22:22:35 2024 -0400 cleaning up for merge commit d7228172c4d5455159cd91782b49304a971bb444 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 21:39:15 2024 -0400 Messy, but monumental: PyTexture::pyObject works this also coincidentally fixes a weird bug I encountered while (mis?)using tp_alloc: by using PyType_GenericAlloc, I avoid the segfault that tp_alloc sometimes causes. See the horrible UIDrawable retrieval macro that I use in UI.h for a workaround that can probably be replaced with this technique commit 2cf8f9431025b3eecb67422e98ec95e3f2b4038f Author: John McCardle <mccardle.john@gmail.com> Date: Wed Mar 20 21:16:52 2024 -0400 Radical new example pattern for exposing a C++ class to Python commit 84a8886da2570a8087f83141f0d41fef65073d99 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:29:33 2024 -0400 Fixed render issue with UIGrid / PyTexture: wasn't positioning or scaling properly after fetching sprite commit 20f80c4114fce029faf28a195ffdbb041181e484 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:23:52 2024 -0400 Fixed sprite indexing error in PyTexture; needs non-square sprite tests, but feeling confident! commit afd4ff1925382622abf79db132b6123ee33b946b Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 21:53:24 2024 -0400 good progress, we're building again. Issue with Grid (tile sprite) textures and I think the sprite indexes are being calculated wrong (x and y transposed?) commit bfd33102d13072eb4624cb07dcf5a55a98e93aa0 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 14:52:35 2024 -0400 Squashed basically all the compile bugs in UISprite, but UIEntity and UIGrid use textures as well, so they need to be fixed too before the project will build again commit 47d0e34a17eb4aa86f781d0a022180d637cec602 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 11:31:39 2024 -0400 Initial PyTexture class no testing done. should enable rectangular (non-square) textures "sprite" method; let's just overwrite sprites with texture coords Hoping to replace awful code like: `self->data->sprite.sprite.setTextureRect(self->data->sprite.itex->spriteCoordinates(val));` with something like: `self->data->sprite = self->data->texture->sprite(val);`
2024-03-21 22:24:42 -04:00
/*grid layers (#147)*/
&PyColorLayerType, &PyTileLayerType,
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
/*animation*/
&PyAnimationType,
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
/*timer*/
&PyTimerType,
/*window singleton type (#184 - type exported for isinstance checks)*/
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
&PyWindowType,
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
/*scene class*/
&PySceneType,
/*audio (#66)*/
&PySoundType,
&PyMusicType,
/*keyboard state (#160)*/
&PyKeyboardType,
/*mouse state (#186)*/
&PyMouseType,
Squashed commit of the following: [standardize_texture_handling] closes #18 commit b114ec308518607fad5777c6c1b516381e2a78b9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 22:22:35 2024 -0400 cleaning up for merge commit d7228172c4d5455159cd91782b49304a971bb444 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 21:39:15 2024 -0400 Messy, but monumental: PyTexture::pyObject works this also coincidentally fixes a weird bug I encountered while (mis?)using tp_alloc: by using PyType_GenericAlloc, I avoid the segfault that tp_alloc sometimes causes. See the horrible UIDrawable retrieval macro that I use in UI.h for a workaround that can probably be replaced with this technique commit 2cf8f9431025b3eecb67422e98ec95e3f2b4038f Author: John McCardle <mccardle.john@gmail.com> Date: Wed Mar 20 21:16:52 2024 -0400 Radical new example pattern for exposing a C++ class to Python commit 84a8886da2570a8087f83141f0d41fef65073d99 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:29:33 2024 -0400 Fixed render issue with UIGrid / PyTexture: wasn't positioning or scaling properly after fetching sprite commit 20f80c4114fce029faf28a195ffdbb041181e484 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:23:52 2024 -0400 Fixed sprite indexing error in PyTexture; needs non-square sprite tests, but feeling confident! commit afd4ff1925382622abf79db132b6123ee33b946b Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 21:53:24 2024 -0400 good progress, we're building again. Issue with Grid (tile sprite) textures and I think the sprite indexes are being calculated wrong (x and y transposed?) commit bfd33102d13072eb4624cb07dcf5a55a98e93aa0 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 14:52:35 2024 -0400 Squashed basically all the compile bugs in UISprite, but UIEntity and UIGrid use textures as well, so they need to be fixed too before the project will build again commit 47d0e34a17eb4aa86f781d0a022180d637cec602 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 11:31:39 2024 -0400 Initial PyTexture class no testing done. should enable rectangular (non-square) textures "sprite" method; let's just overwrite sprites with texture coords Hoping to replace awful code like: `self->data->sprite.sprite.setTextureRect(self->data->sprite.itex->spriteCoordinates(val));` with something like: `self->data->sprite = self->data->texture->sprite(val);`
2024-03-21 22:24:42 -04:00
nullptr};
// Types that are used internally but NOT exported to module namespace (#189)
// These still need PyType_Ready() but are not added to module
PyTypeObject* internal_types[] = {
/*game map & perspective data - returned by Grid.at() but not directly instantiable*/
&PyUIGridPointType, &PyUIGridPointStateType,
/*collections & iterators - returned by .children/.entities but not directly instantiable*/
&PyUICollectionType, &PyUICollectionIterType,
&PyUIEntityCollectionType, &PyUIEntityCollectionIterType,
nullptr};
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
// Set up PyWindowType methods and getsetters before PyType_Ready
PyWindowType.tp_methods = PyWindow::methods;
PyWindowType.tp_getset = PyWindow::getsetters;
// Set up PySceneType methods and getsetters
PySceneType.tp_methods = PySceneClass::methods;
PySceneType.tp_getset = PySceneClass::getsetters;
Squashed commit of the following: [alpha_presentable] Author: John McCardle <mccardle.john@gmail.com> Co-Authored-By: Claude <noreply@anthropic.com> commit dc47f2474c7b2642d368f9772894aed857527807 the UIEntity rant commit 673ca8e1b089ea670257fc04ae1a676ed95a40ed I forget when these tests were written, but I want them in the squash merge commit 70c71565c684fa96e222179271ecb13a156d80ad Fix UI object segfault by switching from managed to manual weakref management The UI types (Frame, Caption, Sprite, Grid, Entity) were using Py_TPFLAGS_MANAGED_WEAKREF while also trying to manually create weakrefs for the PythonObjectCache. This is fundamentally incompatible - when Python manages weakrefs internally, PyWeakref_NewRef() cannot access the weakref list properly, causing segfaults. Changed all UI types to use manual weakref management (like PyTimer): - Restored weakreflist field in all UI type structures - Removed Py_TPFLAGS_MANAGED_WEAKREF from all UI type flags - Added tp_weaklistoffset for all UI types in module initialization - Initialize weakreflist=NULL in tp_new and init methods - Call PyObject_ClearWeakRefs() in dealloc functions This allows the PythonObjectCache to continue working correctly, maintaining Python object identity for C++ objects across the boundary. Fixes segfault when creating UI objects (e.g., Caption, Grid) that was preventing tutorial scripts from running. This is the bulk of the required behavior for Issue #126. that issure isn't ready for closure yet; several other sub-issues left. closes #110 mention issue #109 - resolves some __init__ related nuisances commit 3dce3ec539ae99e32d869007bf3f49d03e4e2f89 Refactor timer system for cleaner architecture and enhanced functionality Major improvements to the timer system: - Unified all timer logic in the Timer class (C++) - Removed PyTimerCallable subclass, now using PyCallable directly - Timer objects are now passed to callbacks as first argument - Added 'once' parameter for one-shot timers that auto-stop - Implemented proper PythonObjectCache integration with weakref support API enhancements: - New callback signature: callback(timer, runtime) instead of just (runtime) - Timer objects expose: name, interval, remaining, paused, active, once properties - Methods: pause(), resume(), cancel(), restart() - Comprehensive documentation with examples - Enhanced repr showing timer state (active/paused/once/remaining time) This cleanup follows the UIEntity/PyUIEntity pattern and makes the timer system more Pythonic while maintaining backward compatibility through the legacy setTimer/delTimer API. closes #121 commit 145834cfc31b8dabc4cb3591b9cb4ed99fc8b964 Implement Python object cache to preserve derived types in collections Add a global cache system that maintains weak references to Python objects, ensuring that derived Python classes maintain their identity when stored in and retrieved from C++ collections. Key changes: - Add PythonObjectCache singleton with serial number system - Each cacheable object (UIDrawable, UIEntity, Timer, Animation) gets unique ID - Cache stores weak references to prevent circular reference memory leaks - Update all UI type definitions to support weak references (Py_TPFLAGS_MANAGED_WEAKREF) - Enable subclassing for all UI types (Py_TPFLAGS_BASETYPE) - Collections check cache before creating new Python wrappers - Register objects in cache during __init__ methods - Clean up cache entries in C++ destructors This ensures that Python code like: ```python class MyFrame(mcrfpy.Frame): def __init__(self): super().__init__() self.custom_data = "preserved" frame = MyFrame() scene.ui.append(frame) retrieved = scene.ui[0] # Same MyFrame instance with custom_data intact ``` Works correctly, with retrieved maintaining the derived type and custom attributes. Closes #112 commit c5e7e8e29835a69f4c50f3c99fd3123012635a9a Update test demos for new Python API and entity system - Update all text input demos to use new Entity constructor signature - Fix pathfinding showcase to work with new entity position handling - Remove entity_waypoints tracking in favor of simplified movement - Delete obsolete exhaustive_api_demo.py (superseded by newer demos) - Adjust entity creation calls to match Entity((x, y), texture, sprite_index) pattern commit 6d29652ae7418745dc24066532454167d447df89 Update animation demo suite with crash fixes and improvements - Add warnings about AnimationManager segfault bug in sizzle_reel_final.py - Create sizzle_reel_final_fixed.py that works around the crash by hiding objects instead of removing them - Increase font sizes for better visibility in demos - Extend demo durations for better showcase of animations - Remove debug prints from animation_sizzle_reel_working.py - Minor cleanup and improvements to all animation demos commit a010e5fa968feaba620dcf2eda44fb9514512151 Update game scripts for new Python API - Convert entity position access from tuple to x/y properties - Update caption size property to font_size - Fix grid boundary checks to use grid_size instead of exceptions - Clean up demo timer on menu exit to prevent callbacks These changes adapt the game scripts to work with the new standardized Python API constructors and property names. commit 9c8d6c459109be883cb8070b8ef83c60bfc1a970 Fix click event z-order handling in PyScene Changed click detection to properly respect z-index by: - Sorting ui_elements in-place when needed (same as render order) - Using reverse iterators to check highest z-index elements first - This ensures top-most elements receive clicks before lower ones commit dcd1b0ca33d46639023221f4d7d52000b947dbdf Add roguelike tutorial implementation files Implement Parts 0-2 of the classic roguelike tutorial adapted for McRogueFace: - Part 0: Basic grid setup and tile rendering - Part 1: Drawing '@' symbol and basic movement - Part 1b: Variant with sprite-based player - Part 2: Entity system and NPC implementation with three movement variants: - part_2.py: Standard implementation - part_2-naive.py: Naive movement approach - part_2-onemovequeued.py: Queued movement system Includes tutorial assets: - tutorial2.png: Tileset for dungeon tiles - tutorial_hero.png: Player sprite sheet commit 6813fb5129738cca2d79c80304834523561ba7fb Standardize Python API constructors and remove PyArgHelpers - Remove PyArgHelpers.h and all macro-based argument parsing - Convert all UI class constructors to use PyArg_ParseTupleAndKeywords - Standardize constructor signatures across UICaption, UIEntity, UIFrame, UIGrid, and UISprite - Replace PYARGHELPER_SINGLE/MULTI macros with explicit argument parsing - Improve error messages and argument validation - Maintain backward compatibility with existing Python code This change improves code maintainability and consistency across the Python API. commit 6f67fbb51efaf70e52fba8c939298dcdff50450a Fix animation callback crashes from iterator invalidation (#119) Resolved segfaults caused by creating new animations from within animation callbacks. The issue was iterator invalidation in AnimationManager::update() when callbacks modified the active animations vector. Changes: - Add deferred animation queue to AnimationManager - New animations created during update are queued and added after - Set isUpdating flag to track when in update loop - Properly handle Animation destructor during callback execution - Add clearCallback() method for safe cleanup scenarios This fixes the "free(): invalid pointer" and "malloc(): unaligned fastbin chunk detected" errors that occurred with rapid animation creation in callbacks. commit eb88c7b3aab3da519db7569106c34f3510b6e963 Add animation completion callbacks (#119) Implement callbacks that fire when animations complete, enabling direct causality between animation end and game state changes. This eliminates race conditions from parallel timer workarounds. - Add optional callback parameter to Animation constructor - Callbacks execute synchronously when animation completes - Proper Python reference counting with GIL safety - Callbacks receive (anim, target) parameters (currently None) - Exception handling prevents crashes from Python errors Example usage: ```python def on_complete(anim, target): player_moving = False anim = mcrfpy.Animation("x", 300.0, 1.0, "easeOut", callback=on_complete) anim.start(player) ``` closes #119 commit 9fb428dd0176a4d7cfad09deb7509d8aa5562868 Update ROADMAP with GitHub issue numbers (#111-#125) Added issue numbers from GitHub tracker to roadmap items: - #111: Grid Click Events Broken in Headless - #112: Object Splitting Bug (Python type preservation) - #113: Batch Operations for Grid - #114: CellView API - #115: SpatialHash Implementation - #116: Dirty Flag System - #117: Memory Pool for Entities - #118: Scene as Drawable - #119: Animation Completion Callbacks - #120: Animation Property Locking - #121: Timer Object System - #122: Parent-Child UI System - #123: Grid Subgrid System - #124: Grid Point Animation - #125: GitHub Issues Automation Also updated existing references: - #101/#110: Constructor standardization - #109: Vector class indexing Note: Tutorial-specific items and Python-implementable features (input queue, collision reservation) are not tracked as engine issues. commit 062e4dadc42833bf5a3559e5d7c4ceb4abb7e9c0 Fix animation segfaults with RAII weak_ptr implementation Resolved two critical segmentation faults in AnimationManager: 1. Race condition when creating multiple animations in timer callbacks 2. Exit crash when animations outlive their target objects Changes: - Replace raw pointers with std::weak_ptr for automatic target invalidation - Add Animation::complete() to jump animations to final value - Add Animation::hasValidTarget() to check if target still exists - Update AnimationManager to auto-remove invalid animations - Add AnimationManager::clear() call to GameEngine::cleanup() - Update Python bindings to pass shared_ptr instead of raw pointers This ensures animations can never reference destroyed objects, following proper RAII principles. Tested with sizzle_reel_final.py and stress tests creating/destroying hundreds of animated objects. commit 98fc49a978ec792ee6096f40fd4e19841b8ec6a3 Directory structure cleanup and organization overhaul
2025-07-15 21:30:49 -04:00
// Set up weakref support for all types that need it
PyTimerType.tp_weaklistoffset = offsetof(PyTimerObject, weakreflist);
PyUIFrameType.tp_weaklistoffset = offsetof(PyUIFrameObject, weakreflist);
PyUICaptionType.tp_weaklistoffset = offsetof(PyUICaptionObject, weakreflist);
PyUISpriteType.tp_weaklistoffset = offsetof(PyUISpriteObject, weakreflist);
PyUIGridType.tp_weaklistoffset = offsetof(PyUIGridObject, weakreflist);
PyUIEntityType.tp_weaklistoffset = offsetof(PyUIEntityObject, weakreflist);
PyUILineType.tp_weaklistoffset = offsetof(PyUILineObject, weakreflist);
PyUICircleType.tp_weaklistoffset = offsetof(PyUICircleObject, weakreflist);
PyUIArcType.tp_weaklistoffset = offsetof(PyUIArcObject, weakreflist);
Squashed commit of the following: [alpha_presentable] Author: John McCardle <mccardle.john@gmail.com> Co-Authored-By: Claude <noreply@anthropic.com> commit dc47f2474c7b2642d368f9772894aed857527807 the UIEntity rant commit 673ca8e1b089ea670257fc04ae1a676ed95a40ed I forget when these tests were written, but I want them in the squash merge commit 70c71565c684fa96e222179271ecb13a156d80ad Fix UI object segfault by switching from managed to manual weakref management The UI types (Frame, Caption, Sprite, Grid, Entity) were using Py_TPFLAGS_MANAGED_WEAKREF while also trying to manually create weakrefs for the PythonObjectCache. This is fundamentally incompatible - when Python manages weakrefs internally, PyWeakref_NewRef() cannot access the weakref list properly, causing segfaults. Changed all UI types to use manual weakref management (like PyTimer): - Restored weakreflist field in all UI type structures - Removed Py_TPFLAGS_MANAGED_WEAKREF from all UI type flags - Added tp_weaklistoffset for all UI types in module initialization - Initialize weakreflist=NULL in tp_new and init methods - Call PyObject_ClearWeakRefs() in dealloc functions This allows the PythonObjectCache to continue working correctly, maintaining Python object identity for C++ objects across the boundary. Fixes segfault when creating UI objects (e.g., Caption, Grid) that was preventing tutorial scripts from running. This is the bulk of the required behavior for Issue #126. that issure isn't ready for closure yet; several other sub-issues left. closes #110 mention issue #109 - resolves some __init__ related nuisances commit 3dce3ec539ae99e32d869007bf3f49d03e4e2f89 Refactor timer system for cleaner architecture and enhanced functionality Major improvements to the timer system: - Unified all timer logic in the Timer class (C++) - Removed PyTimerCallable subclass, now using PyCallable directly - Timer objects are now passed to callbacks as first argument - Added 'once' parameter for one-shot timers that auto-stop - Implemented proper PythonObjectCache integration with weakref support API enhancements: - New callback signature: callback(timer, runtime) instead of just (runtime) - Timer objects expose: name, interval, remaining, paused, active, once properties - Methods: pause(), resume(), cancel(), restart() - Comprehensive documentation with examples - Enhanced repr showing timer state (active/paused/once/remaining time) This cleanup follows the UIEntity/PyUIEntity pattern and makes the timer system more Pythonic while maintaining backward compatibility through the legacy setTimer/delTimer API. closes #121 commit 145834cfc31b8dabc4cb3591b9cb4ed99fc8b964 Implement Python object cache to preserve derived types in collections Add a global cache system that maintains weak references to Python objects, ensuring that derived Python classes maintain their identity when stored in and retrieved from C++ collections. Key changes: - Add PythonObjectCache singleton with serial number system - Each cacheable object (UIDrawable, UIEntity, Timer, Animation) gets unique ID - Cache stores weak references to prevent circular reference memory leaks - Update all UI type definitions to support weak references (Py_TPFLAGS_MANAGED_WEAKREF) - Enable subclassing for all UI types (Py_TPFLAGS_BASETYPE) - Collections check cache before creating new Python wrappers - Register objects in cache during __init__ methods - Clean up cache entries in C++ destructors This ensures that Python code like: ```python class MyFrame(mcrfpy.Frame): def __init__(self): super().__init__() self.custom_data = "preserved" frame = MyFrame() scene.ui.append(frame) retrieved = scene.ui[0] # Same MyFrame instance with custom_data intact ``` Works correctly, with retrieved maintaining the derived type and custom attributes. Closes #112 commit c5e7e8e29835a69f4c50f3c99fd3123012635a9a Update test demos for new Python API and entity system - Update all text input demos to use new Entity constructor signature - Fix pathfinding showcase to work with new entity position handling - Remove entity_waypoints tracking in favor of simplified movement - Delete obsolete exhaustive_api_demo.py (superseded by newer demos) - Adjust entity creation calls to match Entity((x, y), texture, sprite_index) pattern commit 6d29652ae7418745dc24066532454167d447df89 Update animation demo suite with crash fixes and improvements - Add warnings about AnimationManager segfault bug in sizzle_reel_final.py - Create sizzle_reel_final_fixed.py that works around the crash by hiding objects instead of removing them - Increase font sizes for better visibility in demos - Extend demo durations for better showcase of animations - Remove debug prints from animation_sizzle_reel_working.py - Minor cleanup and improvements to all animation demos commit a010e5fa968feaba620dcf2eda44fb9514512151 Update game scripts for new Python API - Convert entity position access from tuple to x/y properties - Update caption size property to font_size - Fix grid boundary checks to use grid_size instead of exceptions - Clean up demo timer on menu exit to prevent callbacks These changes adapt the game scripts to work with the new standardized Python API constructors and property names. commit 9c8d6c459109be883cb8070b8ef83c60bfc1a970 Fix click event z-order handling in PyScene Changed click detection to properly respect z-index by: - Sorting ui_elements in-place when needed (same as render order) - Using reverse iterators to check highest z-index elements first - This ensures top-most elements receive clicks before lower ones commit dcd1b0ca33d46639023221f4d7d52000b947dbdf Add roguelike tutorial implementation files Implement Parts 0-2 of the classic roguelike tutorial adapted for McRogueFace: - Part 0: Basic grid setup and tile rendering - Part 1: Drawing '@' symbol and basic movement - Part 1b: Variant with sprite-based player - Part 2: Entity system and NPC implementation with three movement variants: - part_2.py: Standard implementation - part_2-naive.py: Naive movement approach - part_2-onemovequeued.py: Queued movement system Includes tutorial assets: - tutorial2.png: Tileset for dungeon tiles - tutorial_hero.png: Player sprite sheet commit 6813fb5129738cca2d79c80304834523561ba7fb Standardize Python API constructors and remove PyArgHelpers - Remove PyArgHelpers.h and all macro-based argument parsing - Convert all UI class constructors to use PyArg_ParseTupleAndKeywords - Standardize constructor signatures across UICaption, UIEntity, UIFrame, UIGrid, and UISprite - Replace PYARGHELPER_SINGLE/MULTI macros with explicit argument parsing - Improve error messages and argument validation - Maintain backward compatibility with existing Python code This change improves code maintainability and consistency across the Python API. commit 6f67fbb51efaf70e52fba8c939298dcdff50450a Fix animation callback crashes from iterator invalidation (#119) Resolved segfaults caused by creating new animations from within animation callbacks. The issue was iterator invalidation in AnimationManager::update() when callbacks modified the active animations vector. Changes: - Add deferred animation queue to AnimationManager - New animations created during update are queued and added after - Set isUpdating flag to track when in update loop - Properly handle Animation destructor during callback execution - Add clearCallback() method for safe cleanup scenarios This fixes the "free(): invalid pointer" and "malloc(): unaligned fastbin chunk detected" errors that occurred with rapid animation creation in callbacks. commit eb88c7b3aab3da519db7569106c34f3510b6e963 Add animation completion callbacks (#119) Implement callbacks that fire when animations complete, enabling direct causality between animation end and game state changes. This eliminates race conditions from parallel timer workarounds. - Add optional callback parameter to Animation constructor - Callbacks execute synchronously when animation completes - Proper Python reference counting with GIL safety - Callbacks receive (anim, target) parameters (currently None) - Exception handling prevents crashes from Python errors Example usage: ```python def on_complete(anim, target): player_moving = False anim = mcrfpy.Animation("x", 300.0, 1.0, "easeOut", callback=on_complete) anim.start(player) ``` closes #119 commit 9fb428dd0176a4d7cfad09deb7509d8aa5562868 Update ROADMAP with GitHub issue numbers (#111-#125) Added issue numbers from GitHub tracker to roadmap items: - #111: Grid Click Events Broken in Headless - #112: Object Splitting Bug (Python type preservation) - #113: Batch Operations for Grid - #114: CellView API - #115: SpatialHash Implementation - #116: Dirty Flag System - #117: Memory Pool for Entities - #118: Scene as Drawable - #119: Animation Completion Callbacks - #120: Animation Property Locking - #121: Timer Object System - #122: Parent-Child UI System - #123: Grid Subgrid System - #124: Grid Point Animation - #125: GitHub Issues Automation Also updated existing references: - #101/#110: Constructor standardization - #109: Vector class indexing Note: Tutorial-specific items and Python-implementable features (input queue, collision reservation) are not tracked as engine issues. commit 062e4dadc42833bf5a3559e5d7c4ceb4abb7e9c0 Fix animation segfaults with RAII weak_ptr implementation Resolved two critical segmentation faults in AnimationManager: 1. Race condition when creating multiple animations in timer callbacks 2. Exit crash when animations outlive their target objects Changes: - Replace raw pointers with std::weak_ptr for automatic target invalidation - Add Animation::complete() to jump animations to final value - Add Animation::hasValidTarget() to check if target still exists - Update AnimationManager to auto-remove invalid animations - Add AnimationManager::clear() call to GameEngine::cleanup() - Update Python bindings to pass shared_ptr instead of raw pointers This ensures animations can never reference destroyed objects, following proper RAII principles. Tested with sizzle_reel_final.py and stress tests creating/destroying hundreds of animated objects. commit 98fc49a978ec792ee6096f40fd4e19841b8ec6a3 Directory structure cleanup and organization overhaul
2025-07-15 21:30:49 -04:00
// Process exported types - PyType_Ready AND add to module
Squashed commit of the following: [standardize_texture_handling] closes #18 commit b114ec308518607fad5777c6c1b516381e2a78b9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 22:22:35 2024 -0400 cleaning up for merge commit d7228172c4d5455159cd91782b49304a971bb444 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 21:39:15 2024 -0400 Messy, but monumental: PyTexture::pyObject works this also coincidentally fixes a weird bug I encountered while (mis?)using tp_alloc: by using PyType_GenericAlloc, I avoid the segfault that tp_alloc sometimes causes. See the horrible UIDrawable retrieval macro that I use in UI.h for a workaround that can probably be replaced with this technique commit 2cf8f9431025b3eecb67422e98ec95e3f2b4038f Author: John McCardle <mccardle.john@gmail.com> Date: Wed Mar 20 21:16:52 2024 -0400 Radical new example pattern for exposing a C++ class to Python commit 84a8886da2570a8087f83141f0d41fef65073d99 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:29:33 2024 -0400 Fixed render issue with UIGrid / PyTexture: wasn't positioning or scaling properly after fetching sprite commit 20f80c4114fce029faf28a195ffdbb041181e484 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:23:52 2024 -0400 Fixed sprite indexing error in PyTexture; needs non-square sprite tests, but feeling confident! commit afd4ff1925382622abf79db132b6123ee33b946b Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 21:53:24 2024 -0400 good progress, we're building again. Issue with Grid (tile sprite) textures and I think the sprite indexes are being calculated wrong (x and y transposed?) commit bfd33102d13072eb4624cb07dcf5a55a98e93aa0 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 14:52:35 2024 -0400 Squashed basically all the compile bugs in UISprite, but UIEntity and UIGrid use textures as well, so they need to be fixed too before the project will build again commit 47d0e34a17eb4aa86f781d0a022180d637cec602 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 11:31:39 2024 -0400 Initial PyTexture class no testing done. should enable rectangular (non-square) textures "sprite" method; let's just overwrite sprites with texture coords Hoping to replace awful code like: `self->data->sprite.sprite.setTextureRect(self->data->sprite.itex->spriteCoordinates(val));` with something like: `self->data->sprite = self->data->texture->sprite(val);`
2024-03-21 22:24:42 -04:00
int i = 0;
auto t = exported_types[i];
Squashed commit of the following: [standardize_texture_handling] closes #18 commit b114ec308518607fad5777c6c1b516381e2a78b9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 22:22:35 2024 -0400 cleaning up for merge commit d7228172c4d5455159cd91782b49304a971bb444 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 21:39:15 2024 -0400 Messy, but monumental: PyTexture::pyObject works this also coincidentally fixes a weird bug I encountered while (mis?)using tp_alloc: by using PyType_GenericAlloc, I avoid the segfault that tp_alloc sometimes causes. See the horrible UIDrawable retrieval macro that I use in UI.h for a workaround that can probably be replaced with this technique commit 2cf8f9431025b3eecb67422e98ec95e3f2b4038f Author: John McCardle <mccardle.john@gmail.com> Date: Wed Mar 20 21:16:52 2024 -0400 Radical new example pattern for exposing a C++ class to Python commit 84a8886da2570a8087f83141f0d41fef65073d99 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:29:33 2024 -0400 Fixed render issue with UIGrid / PyTexture: wasn't positioning or scaling properly after fetching sprite commit 20f80c4114fce029faf28a195ffdbb041181e484 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:23:52 2024 -0400 Fixed sprite indexing error in PyTexture; needs non-square sprite tests, but feeling confident! commit afd4ff1925382622abf79db132b6123ee33b946b Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 21:53:24 2024 -0400 good progress, we're building again. Issue with Grid (tile sprite) textures and I think the sprite indexes are being calculated wrong (x and y transposed?) commit bfd33102d13072eb4624cb07dcf5a55a98e93aa0 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 14:52:35 2024 -0400 Squashed basically all the compile bugs in UISprite, but UIEntity and UIGrid use textures as well, so they need to be fixed too before the project will build again commit 47d0e34a17eb4aa86f781d0a022180d637cec602 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 11:31:39 2024 -0400 Initial PyTexture class no testing done. should enable rectangular (non-square) textures "sprite" method; let's just overwrite sprites with texture coords Hoping to replace awful code like: `self->data->sprite.sprite.setTextureRect(self->data->sprite.itex->spriteCoordinates(val));` with something like: `self->data->sprite = self->data->texture->sprite(val);`
2024-03-21 22:24:42 -04:00
while (t != nullptr)
{
Iterators, other Python C API improvements closes #72 ref #69 - this resolves the "UICollection" (not "UIEntityCollection", perhaps renamed since the issue opened) and "UIEntityCollection" portion. The Grid point based iterators were not updated. **RPATH updates** Will this RPATH setting allow McRogueFace to execute using its included "lib" subdirectory after being unzipped on a new computer? The change from "./lib" to "$ORIGIN/./lib" improves portability. The $ORIGIN token is a special Linux/Unix convention that refers to the directory containing the executable itself. This makes the path relative to the executable's location rather than the current working directory, which means McRogueFace will correctly find its libraries in the lib subdirectory regardless of where it's run from after being unzipped on a new computer. **New standard object initialization** PyColor, PyVector - Fixed all 15 PyTypeObject definitions to use proper designated initializer syntax - Replaced PyType_GenericAlloc usage in PyColor.cpp and PyVector.cpp - Updated PyObject_New usage in UIEntity.cpp - All object creation now uses module-based type lookups instead of static references - Created centralized utilities in PyObjectUtils.h **RAII Wrappers** automatic reference counting via C++ object lifecycle - Created PyRAII.h with PyObjectRef and PyTypeRef classes - These provide automatic reference counting management - Updated PyColor::from_arg() to demonstrate RAII usage - Prevents memory leaks and reference counting errors **Python object base in type defs:** `.ob_base = {.ob_base = {.ob_refcnt = 1, .ob_type = NULL}, .ob_size = 0}` PyColor, PyTexture, PyVector, UICaption, UICollection, UIEntity, UIFrame, UIGrid **convertDrawableToPython** replace crazy macro to detect the correct Python type of a UIDrawable instance - Removed the problematic macro from UIDrawable.h - Created template-based functions in PyObjectUtils.h - Updated UICollection.cpp to use local helper function - The new approach is cleaner, more debuggable, and avoids static type references **Iterator fixes** tp_iter on UICollection, UIGrid, UIGridPoint, UISprite UIGrid logic improved, standard **List vs Vector usage analysis** there are different use cases that weren't standardized: - UICollection (for Frame children) uses std::vector<std::shared_ptr<UIDrawable>> - UIEntityCollection (for Grid entities) uses std::list<std::shared_ptr<UIEntity>> The rationale is currently connected to frequency of expected changes. * A "UICollection" is likely either all visible or not; it's also likely to be created once and have a static set of contents. They should be contiguous in memory in hopes that this helps rendering speed. * A "UIEntityCollection" is expected to be rendered as a subset within the visible rectangle of the UIGrid. Scrolling the grid or gameplay logic is likely to frequently create and destroy entities. In general I expect Entity collections to have a much higher common size than UICollections. For these reasons I've made them Lists in hopes that they never have to be reallocated or moved during a frame.
2025-05-31 08:58:52 -04:00
if (PyType_Ready(t) < 0) {
std::cout << "ERROR: PyType_Ready failed for " << t->tp_name << std::endl;
return NULL;
}
Squashed commit of the following: [standardize_texture_handling] closes #18 commit b114ec308518607fad5777c6c1b516381e2a78b9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 22:22:35 2024 -0400 cleaning up for merge commit d7228172c4d5455159cd91782b49304a971bb444 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Mar 21 21:39:15 2024 -0400 Messy, but monumental: PyTexture::pyObject works this also coincidentally fixes a weird bug I encountered while (mis?)using tp_alloc: by using PyType_GenericAlloc, I avoid the segfault that tp_alloc sometimes causes. See the horrible UIDrawable retrieval macro that I use in UI.h for a workaround that can probably be replaced with this technique commit 2cf8f9431025b3eecb67422e98ec95e3f2b4038f Author: John McCardle <mccardle.john@gmail.com> Date: Wed Mar 20 21:16:52 2024 -0400 Radical new example pattern for exposing a C++ class to Python commit 84a8886da2570a8087f83141f0d41fef65073d99 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:29:33 2024 -0400 Fixed render issue with UIGrid / PyTexture: wasn't positioning or scaling properly after fetching sprite commit 20f80c4114fce029faf28a195ffdbb041181e484 Author: John McCardle <mccardle.john@gmail.com> Date: Sun Mar 17 16:23:52 2024 -0400 Fixed sprite indexing error in PyTexture; needs non-square sprite tests, but feeling confident! commit afd4ff1925382622abf79db132b6123ee33b946b Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 21:53:24 2024 -0400 good progress, we're building again. Issue with Grid (tile sprite) textures and I think the sprite indexes are being calculated wrong (x and y transposed?) commit bfd33102d13072eb4624cb07dcf5a55a98e93aa0 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 14:52:35 2024 -0400 Squashed basically all the compile bugs in UISprite, but UIEntity and UIGrid use textures as well, so they need to be fixed too before the project will build again commit 47d0e34a17eb4aa86f781d0a022180d637cec602 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Mar 16 11:31:39 2024 -0400 Initial PyTexture class no testing done. should enable rectangular (non-square) textures "sprite" method; let's just overwrite sprites with texture coords Hoping to replace awful code like: `self->data->sprite.sprite.setTextureRect(self->data->sprite.itex->spriteCoordinates(val));` with something like: `self->data->sprite = self->data->texture->sprite(val);`
2024-03-21 22:24:42 -04:00
PyModule_AddType(m, t);
Iterators, other Python C API improvements closes #72 ref #69 - this resolves the "UICollection" (not "UIEntityCollection", perhaps renamed since the issue opened) and "UIEntityCollection" portion. The Grid point based iterators were not updated. **RPATH updates** Will this RPATH setting allow McRogueFace to execute using its included "lib" subdirectory after being unzipped on a new computer? The change from "./lib" to "$ORIGIN/./lib" improves portability. The $ORIGIN token is a special Linux/Unix convention that refers to the directory containing the executable itself. This makes the path relative to the executable's location rather than the current working directory, which means McRogueFace will correctly find its libraries in the lib subdirectory regardless of where it's run from after being unzipped on a new computer. **New standard object initialization** PyColor, PyVector - Fixed all 15 PyTypeObject definitions to use proper designated initializer syntax - Replaced PyType_GenericAlloc usage in PyColor.cpp and PyVector.cpp - Updated PyObject_New usage in UIEntity.cpp - All object creation now uses module-based type lookups instead of static references - Created centralized utilities in PyObjectUtils.h **RAII Wrappers** automatic reference counting via C++ object lifecycle - Created PyRAII.h with PyObjectRef and PyTypeRef classes - These provide automatic reference counting management - Updated PyColor::from_arg() to demonstrate RAII usage - Prevents memory leaks and reference counting errors **Python object base in type defs:** `.ob_base = {.ob_base = {.ob_refcnt = 1, .ob_type = NULL}, .ob_size = 0}` PyColor, PyTexture, PyVector, UICaption, UICollection, UIEntity, UIFrame, UIGrid **convertDrawableToPython** replace crazy macro to detect the correct Python type of a UIDrawable instance - Removed the problematic macro from UIDrawable.h - Created template-based functions in PyObjectUtils.h - Updated UICollection.cpp to use local helper function - The new approach is cleaner, more debuggable, and avoids static type references **Iterator fixes** tp_iter on UICollection, UIGrid, UIGridPoint, UISprite UIGrid logic improved, standard **List vs Vector usage analysis** there are different use cases that weren't standardized: - UICollection (for Frame children) uses std::vector<std::shared_ptr<UIDrawable>> - UIEntityCollection (for Grid entities) uses std::list<std::shared_ptr<UIEntity>> The rationale is currently connected to frequency of expected changes. * A "UICollection" is likely either all visible or not; it's also likely to be created once and have a static set of contents. They should be contiguous in memory in hopes that this helps rendering speed. * A "UIEntityCollection" is expected to be rendered as a subset within the visible rectangle of the UIGrid. Scrolling the grid or gameplay logic is likely to frequently create and destroy entities. In general I expect Entity collections to have a much higher common size than UICollections. For these reasons I've made them Lists in hopes that they never have to be reallocated or moved during a frame.
2025-05-31 08:58:52 -04:00
i++;
t = exported_types[i];
}
// Process internal types - PyType_Ready only, NOT added to module (#189)
i = 0;
t = internal_types[i];
while (t != nullptr)
{
if (PyType_Ready(t) < 0) {
std::cout << "ERROR: PyType_Ready failed for " << t->tp_name << std::endl;
return NULL;
}
// Note: NOT calling PyModule_AddType - these are internal-only types
i++;
t = internal_types[i];
}
// Add default_font and default_texture to module
McRFPy_API::default_font = std::make_shared<PyFont>("assets/JetbrainsMono.ttf");
McRFPy_API::default_texture = std::make_shared<PyTexture>("assets/kenney_tinydungeon.png", 16, 16);
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
// These will be set later when the window is created
PyModule_AddObject(m, "default_font", Py_None);
PyModule_AddObject(m, "default_texture", Py_None);
// Add keyboard singleton (#160)
PyObject* keyboard_instance = PyObject_CallObject((PyObject*)&PyKeyboardType, NULL);
if (keyboard_instance) {
PyModule_AddObject(m, "keyboard", keyboard_instance);
}
// Add mouse singleton (#186)
PyObject* mouse_instance = PyObject_CallObject((PyObject*)&PyMouseType, NULL);
if (mouse_instance) {
PyModule_AddObject(m, "mouse", mouse_instance);
}
// Add window singleton (#184)
// Use tp_alloc directly to bypass tp_new which blocks user instantiation
PyObject* window_instance = PyWindowType.tp_alloc(&PyWindowType, 0);
if (window_instance) {
PyModule_AddObject(m, "window", window_instance);
}
// Add version string (#164)
PyModule_AddStringConstant(m, "__version__", MCRFPY_VERSION);
// Add FOV enum class (uses Python's IntEnum) (#114)
PyObject* fov_class = PyFOV::create_enum_class(m);
if (!fov_class) {
// If enum creation fails, continue without it (non-fatal)
PyErr_Clear();
}
// Add default_fov module property - defaults to FOV.BASIC
// New grids copy this value at creation time
if (fov_class) {
PyObject* default_fov = PyObject_GetAttrString(fov_class, "BASIC");
if (default_fov) {
PyModule_AddObject(m, "default_fov", default_fov);
} else {
PyErr_Clear();
// Fallback to integer
PyModule_AddIntConstant(m, "default_fov", FOV_BASIC);
}
} else {
// Fallback to integer if enum failed
PyModule_AddIntConstant(m, "default_fov", FOV_BASIC);
}
2026-01-03 13:53:18 -05:00
// Add Transition enum class (uses Python's IntEnum)
PyObject* transition_class = PyTransition::create_enum_class(m);
if (!transition_class) {
// If enum creation fails, continue without it (non-fatal)
PyErr_Clear();
}
// Note: default_transition and default_transition_duration are handled via
// mcrfpy_module_getattr/setattro using PyTransition::default_transition/default_duration
2026-01-04 12:59:28 -05:00
// Add Easing enum class (uses Python's IntEnum)
PyObject* easing_class = PyEasing::create_enum_class(m);
if (!easing_class) {
// If enum creation fails, continue without it (non-fatal)
PyErr_Clear();
}
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
// Add automation submodule
PyObject* automation_module = McRFPy_Automation::init_automation_module();
if (automation_module != NULL) {
PyModule_AddObject(m, "automation", automation_module);
// Also add to sys.modules for proper import behavior
PyObject* sys_modules = PyImport_GetModuleDict();
PyDict_SetItemString(sys_modules, "mcrfpy.automation", automation_module);
}
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
// Add libtcod submodule
PyObject* libtcod_module = McRFPy_Libtcod::init_libtcod_module();
if (libtcod_module != NULL) {
PyModule_AddObject(m, "libtcod", libtcod_module);
// Also add to sys.modules for proper import behavior
PyObject* sys_modules = PyImport_GetModuleDict();
PyDict_SetItemString(sys_modules, "mcrfpy.libtcod", libtcod_module);
}
//McRFPy_API::mcrf_module = m;
return m;
}
// init_python - configure interpreter details here
PyStatus init_python(const char *program_name)
{
PyStatus status;
//**preconfig to establish locale**
PyPreConfig preconfig;
PyPreConfig_InitIsolatedConfig(&preconfig);
preconfig.utf8_mode = 1;
status = Py_PreInitialize(&preconfig);
if (PyStatus_Exception(status)) {
Py_ExitStatusException(status);
}
PyConfig config;
PyConfig_InitIsolatedConfig(&config);
config.dev_mode = 0;
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
// Configure UTF-8 for stdio
PyConfig_SetString(&config, &config.stdio_encoding, L"UTF-8");
PyConfig_SetString(&config, &config.stdio_errors, L"surrogateescape");
config.configure_c_stdio = 1;
// Set sys.executable to the McRogueFace binary path
auto exe_filename = executable_filename();
PyConfig_SetString(&config, &config.executable, exe_filename.c_str());
PyConfig_SetBytesString(&config, &config.home,
narrow_string(executable_path() + L"/lib/Python").c_str());
status = PyConfig_SetBytesString(&config, &config.program_name,
program_name);
// Check for sibling venv/ directory (self-contained deployment)
auto exe_dir = std::filesystem::path(executable_path());
auto sibling_venv = exe_dir / "venv";
if (std::filesystem::exists(sibling_venv)) {
// Platform-specific site-packages path
#ifdef _WIN32
auto site_packages = sibling_venv / "Lib" / "site-packages";
#else
auto site_packages = sibling_venv / "lib" / "python3.14" / "site-packages";
#endif
if (std::filesystem::exists(site_packages)) {
// Prepend so venv packages take priority over bundled
PyWideStringList_Insert(&config.module_search_paths, 0,
site_packages.wstring().c_str());
config.module_search_paths_set = 1;
}
}
// under Windows, the search paths are correct; under Linux, they need manual insertion
#if __PLATFORM_SET_PYTHON_SEARCH_PATHS == 1
if (!config.module_search_paths_set) {
config.module_search_paths_set = 1;
}
// search paths for python libs/modules/scripts
const wchar_t* str_arr[] = {
L"/scripts",
L"/lib/Python/lib.linux-x86_64-3.14",
L"/lib/Python",
L"/lib/Python/Lib"
// Note: venv site-packages handled above via sibling_venv detection
};
for(auto s : str_arr) {
status = PyWideStringList_Append(&config.module_search_paths, (executable_path() + s).c_str());
if (PyStatus_Exception(status)) {
continue;
}
}
#endif
status = Py_InitializeFromConfig(&config);
PyConfig_Clear(&config);
return status;
}
PyStatus McRFPy_API::init_python_with_config(const McRogueFaceConfig& config)
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
{
// If Python is already initialized, just return success
if (Py_IsInitialized()) {
return PyStatus_Ok();
}
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
PyStatus status;
PyConfig pyconfig;
PyConfig_InitIsolatedConfig(&pyconfig);
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
// Configure UTF-8 for stdio
PyConfig_SetString(&pyconfig, &pyconfig.stdio_encoding, L"UTF-8");
PyConfig_SetString(&pyconfig, &pyconfig.stdio_errors, L"surrogateescape");
pyconfig.configure_c_stdio = 1;
// Set sys.executable to the McRogueFace binary path
auto exe_path = executable_filename();
PyConfig_SetString(&pyconfig, &pyconfig.executable, exe_path.c_str());
// Set interactive mode (replaces deprecated Py_InspectFlag)
if (config.interactive_mode) {
pyconfig.inspect = 1;
}
// Don't modify sys.path based on script location (replaces PySys_SetArgvEx updatepath=0)
pyconfig.safe_path = 1;
// Construct Python argv from config (replaces deprecated PySys_SetArgvEx)
// Python convention:
// - Script mode: argv[0] = script_path, argv[1:] = script_args
// - -c mode: argv[0] = "-c"
// - -m mode: argv[0] = module_name, argv[1:] = script_args
// - Interactive only: argv[0] = ""
std::vector<std::wstring> argv_storage;
if (!config.script_path.empty()) {
// Script execution: argv[0] = script path
argv_storage.push_back(config.script_path.wstring());
for (const auto& arg : config.script_args) {
std::wstring warg(arg.begin(), arg.end());
argv_storage.push_back(warg);
}
} else if (!config.python_command.empty()) {
// -c command: argv[0] = "-c"
argv_storage.push_back(L"-c");
} else if (!config.python_module.empty()) {
// -m module: argv[0] = module name
std::wstring wmodule(config.python_module.begin(), config.python_module.end());
argv_storage.push_back(wmodule);
for (const auto& arg : config.script_args) {
std::wstring warg(arg.begin(), arg.end());
argv_storage.push_back(warg);
}
} else {
// Interactive mode or no script: argv[0] = ""
argv_storage.push_back(L"");
}
// Build wchar_t* array for PyConfig
std::vector<wchar_t*> argv_ptrs;
for (auto& ws : argv_storage) {
argv_ptrs.push_back(const_cast<wchar_t*>(ws.c_str()));
}
status = PyConfig_SetWideStringList(&pyconfig, &pyconfig.argv,
argv_ptrs.size(), argv_ptrs.data());
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
if (PyStatus_Exception(status)) {
return status;
}
// Check if we're in a virtual environment (symlinked into a venv)
auto exe_wpath = executable_filename();
auto exe_path_fs = std::filesystem::path(exe_wpath);
auto exe_dir = exe_path_fs.parent_path();
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
auto venv_root = exe_dir.parent_path();
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
if (std::filesystem::exists(venv_root / "pyvenv.cfg")) {
// We're running from within a venv!
// Add venv's site-packages to module search paths
auto site_packages = venv_root / "lib" / "python3.14" / "site-packages";
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
PyWideStringList_Append(&pyconfig.module_search_paths,
site_packages.wstring().c_str());
pyconfig.module_search_paths_set = 1;
}
// Check for sibling venv/ directory (self-contained deployment)
auto sibling_venv = exe_dir / "venv";
if (std::filesystem::exists(sibling_venv)) {
// Platform-specific site-packages path
#ifdef _WIN32
auto site_packages = sibling_venv / "Lib" / "site-packages";
#else
auto site_packages = sibling_venv / "lib" / "python3.14" / "site-packages";
#endif
if (std::filesystem::exists(site_packages)) {
// Prepend so venv packages take priority over bundled
PyWideStringList_Insert(&pyconfig.module_search_paths, 0,
site_packages.wstring().c_str());
pyconfig.module_search_paths_set = 1;
}
}
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
// Set Python home to our bundled Python
auto python_home = executable_path() + L"/lib/Python";
PyConfig_SetString(&pyconfig, &pyconfig.home, python_home.c_str());
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
// Set up module search paths
#if __PLATFORM_SET_PYTHON_SEARCH_PATHS == 1
if (!pyconfig.module_search_paths_set) {
pyconfig.module_search_paths_set = 1;
}
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
// search paths for python libs/modules/scripts
const wchar_t* str_arr[] = {
L"/scripts",
L"/lib/Python/lib.linux-x86_64-3.14",
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
L"/lib/Python",
L"/lib/Python/Lib"
// Note: venv site-packages handled above via sibling_venv detection
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
};
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
for(auto s : str_arr) {
status = PyWideStringList_Append(&pyconfig.module_search_paths, (executable_path() + s).c_str());
if (PyStatus_Exception(status)) {
continue;
}
}
#endif
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
// Register mcrfpy module before initialization
PyImport_AppendInittab("mcrfpy", &PyInit_mcrfpy);
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
status = Py_InitializeFromConfig(&pyconfig);
PyConfig_Clear(&pyconfig);
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
return status;
}
/*
void McRFPy_API::setSpriteTexture(int ti)
{
int tx = ti % texture_width, ty = ti / texture_width;
sprite.setTextureRect(sf::IntRect(
tx * texture_size,
ty * texture_size,
texture_size, texture_size));
}
*/
// functionality
//void McRFPy_API::
void McRFPy_API::api_init() {
// build API exposure before python initialization
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
if (!Py_IsInitialized()) {
PyImport_AppendInittab("mcrfpy", &PyInit_mcrfpy);
// use full path version of argv[0] from OS to init python
init_python(narrow_string(executable_filename()).c_str());
}
//texture.loadFromFile("./assets/kenney_tinydungeon.png");
//texture_size = 16, texture_width = 12, texture_height= 11;
//texture_sprite_count = texture_width * texture_height;
//texture.setSmooth(false);
// Add default_font and default_texture to module
McRFPy_API::mcrf_module = PyImport_ImportModule("mcrfpy");
std::cout << PyUnicode_AsUTF8(PyObject_Repr(McRFPy_API::mcrf_module)) << std::endl;
//PyModule_AddObject(McRFPy_API::mcrf_module, "default_font", McRFPy_API::default_font->pyObject());
PyObject_SetAttrString(McRFPy_API::mcrf_module, "default_font", McRFPy_API::default_font->pyObject());
//PyModule_AddObject(McRFPy_API::mcrf_module, "default_texture", McRFPy_API::default_texture->pyObject());
PyObject_SetAttrString(McRFPy_API::mcrf_module, "default_texture", McRFPy_API::default_texture->pyObject());
//sprite.setTexture(texture);
//sprite.setScale(sf::Vector2f(4.0f, 4.0f));
//setSpriteTexture(0);
}
void McRFPy_API::api_init(const McRogueFaceConfig& config) {
// Initialize Python with proper argv constructed from config
PyStatus status = init_python_with_config(config);
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
if (PyStatus_Exception(status)) {
Py_ExitStatusException(status);
}
McRFPy_API::mcrf_module = PyImport_ImportModule("mcrfpy");
// For -m module execution, let Python handle it
if (!config.python_module.empty() && config.python_module != "venv") {
// Py_RunMain() will handle -m execution
return;
}
// Execute based on mode - this is handled in main.cpp now
// The actual execution logic is in run_python_interpreter()
// Set up default resources only if in game mode
if (!config.python_mode) {
//PyModule_AddObject(McRFPy_API::mcrf_module, "default_font", McRFPy_API::default_font->pyObject());
PyObject_SetAttrString(McRFPy_API::mcrf_module, "default_font", McRFPy_API::default_font->pyObject());
//PyModule_AddObject(McRFPy_API::mcrf_module, "default_texture", McRFPy_API::default_texture->pyObject());
PyObject_SetAttrString(McRFPy_API::mcrf_module, "default_texture", McRFPy_API::default_texture->pyObject());
}
}
void McRFPy_API::executeScript(std::string filename)
{
Squashed commit of the following: [alpha_streamline_1] the low-hanging fruit of pre-existing issues and standardizing the Python interfaces Special thanks to Claude Code, ~100k output tokens for this merge 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 99f301e3a0e9e81ad28c9e1d410390c32dfd933c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 16:25:32 2025 -0400 Add position tuple support and pos property to UI elements closes #83, closes #84 - Issue #83: Add position tuple support to constructors - Frame and Sprite now accept both (x, y) and ((x, y)) forms - Also accept Vector objects as position arguments - Caption and Entity already supported tuple/Vector forms - Uses PyVector::from_arg for flexible position parsing - Issue #84: Add pos property to Frame and Sprite - Added pos getter that returns a Vector - Added pos setter that accepts Vector or tuple - Provides consistency with Caption and Entity which already had pos properties - All UI elements now have a uniform way to get/set positions as Vectors Both features improve API consistency and make it easier to work with positions. commit 2f2b488fb54da12c39c0010dbd83cb9f6c429b01 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 16:18:10 2025 -0400 Standardize sprite_index property and add scale_x/scale_y to UISprite closes #81, closes #82 - Issue #81: Standardized property name to sprite_index across UISprite and UIEntity - Added sprite_index as the primary property name - Kept sprite_number as a deprecated alias for backward compatibility - Updated repr() methods to use sprite_index - Updated animation system to recognize both names - Issue #82: Added scale_x and scale_y properties to UISprite - Enables non-uniform scaling of sprites - scale property still works for uniform scaling - Both properties work with the animation system All existing code using sprite_number continues to work due to backward compatibility. commit 5a003a9aa587eb8ee4b79ac67ca8f342ab62e2d2 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 16:09:52 2025 -0400 Fix multiple low priority issues closes #12, closes #80, closes #95, closes #96, closes #99 - Issue #12: Set tp_new to NULL for GridPoint and GridPointState to prevent instantiation from Python - Issue #80: Renamed Caption.size to Caption.font_size for semantic clarity - Issue #95: Fixed UICollection repr to show actual derived types instead of generic UIDrawable - Issue #96: Added extend() method to UICollection for API consistency with UIEntityCollection - Issue #99: Exposed read-only properties for Texture (sprite_width, sprite_height, sheet_width, sheet_height, sprite_count, source) and Font (family, source) All issues have corresponding tests that verify the fixes work correctly. commit e5affaf317665395135c936bc4a6b840ae321765 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 15:50:09 2025 -0400 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
2025-07-05 17:30:49 -04:00
std::filesystem::path script_path(filename);
// If the path is relative and the file doesn't exist, try resolving it relative to the executable
if (script_path.is_relative() && !std::filesystem::exists(script_path)) {
// Get the directory where the executable is located using platform-specific function
std::wstring exe_dir_w = executable_path();
std::filesystem::path exe_dir(exe_dir_w);
// Try the script path relative to the executable directory
std::filesystem::path resolved_path = exe_dir / script_path;
if (std::filesystem::exists(resolved_path)) {
script_path = resolved_path;
}
}
FILE* PScriptFile = fopen(script_path.string().c_str(), "r");
if(PScriptFile) {
Squashed commit of the following: [alpha_streamline_1] the low-hanging fruit of pre-existing issues and standardizing the Python interfaces Special thanks to Claude Code, ~100k output tokens for this merge 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 99f301e3a0e9e81ad28c9e1d410390c32dfd933c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 16:25:32 2025 -0400 Add position tuple support and pos property to UI elements closes #83, closes #84 - Issue #83: Add position tuple support to constructors - Frame and Sprite now accept both (x, y) and ((x, y)) forms - Also accept Vector objects as position arguments - Caption and Entity already supported tuple/Vector forms - Uses PyVector::from_arg for flexible position parsing - Issue #84: Add pos property to Frame and Sprite - Added pos getter that returns a Vector - Added pos setter that accepts Vector or tuple - Provides consistency with Caption and Entity which already had pos properties - All UI elements now have a uniform way to get/set positions as Vectors Both features improve API consistency and make it easier to work with positions. commit 2f2b488fb54da12c39c0010dbd83cb9f6c429b01 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 16:18:10 2025 -0400 Standardize sprite_index property and add scale_x/scale_y to UISprite closes #81, closes #82 - Issue #81: Standardized property name to sprite_index across UISprite and UIEntity - Added sprite_index as the primary property name - Kept sprite_number as a deprecated alias for backward compatibility - Updated repr() methods to use sprite_index - Updated animation system to recognize both names - Issue #82: Added scale_x and scale_y properties to UISprite - Enables non-uniform scaling of sprites - scale property still works for uniform scaling - Both properties work with the animation system All existing code using sprite_number continues to work due to backward compatibility. commit 5a003a9aa587eb8ee4b79ac67ca8f342ab62e2d2 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 16:09:52 2025 -0400 Fix multiple low priority issues closes #12, closes #80, closes #95, closes #96, closes #99 - Issue #12: Set tp_new to NULL for GridPoint and GridPointState to prevent instantiation from Python - Issue #80: Renamed Caption.size to Caption.font_size for semantic clarity - Issue #95: Fixed UICollection repr to show actual derived types instead of generic UIDrawable - Issue #96: Added extend() method to UICollection for API consistency with UIEntityCollection - Issue #99: Exposed read-only properties for Texture (sprite_width, sprite_height, sheet_width, sheet_height, sprite_count, source) and Font (family, source) All issues have corresponding tests that verify the fixes work correctly. commit e5affaf317665395135c936bc4a6b840ae321765 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 15:50:09 2025 -0400 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
2025-07-05 17:30:49 -04:00
PyRun_SimpleFile(PScriptFile, script_path.string().c_str());
fclose(PScriptFile);
Squashed commit of the following: [alpha_streamline_1] the low-hanging fruit of pre-existing issues and standardizing the Python interfaces Special thanks to Claude Code, ~100k output tokens for this merge 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 99f301e3a0e9e81ad28c9e1d410390c32dfd933c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 16:25:32 2025 -0400 Add position tuple support and pos property to UI elements closes #83, closes #84 - Issue #83: Add position tuple support to constructors - Frame and Sprite now accept both (x, y) and ((x, y)) forms - Also accept Vector objects as position arguments - Caption and Entity already supported tuple/Vector forms - Uses PyVector::from_arg for flexible position parsing - Issue #84: Add pos property to Frame and Sprite - Added pos getter that returns a Vector - Added pos setter that accepts Vector or tuple - Provides consistency with Caption and Entity which already had pos properties - All UI elements now have a uniform way to get/set positions as Vectors Both features improve API consistency and make it easier to work with positions. commit 2f2b488fb54da12c39c0010dbd83cb9f6c429b01 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 16:18:10 2025 -0400 Standardize sprite_index property and add scale_x/scale_y to UISprite closes #81, closes #82 - Issue #81: Standardized property name to sprite_index across UISprite and UIEntity - Added sprite_index as the primary property name - Kept sprite_number as a deprecated alias for backward compatibility - Updated repr() methods to use sprite_index - Updated animation system to recognize both names - Issue #82: Added scale_x and scale_y properties to UISprite - Enables non-uniform scaling of sprites - scale property still works for uniform scaling - Both properties work with the animation system All existing code using sprite_number continues to work due to backward compatibility. commit 5a003a9aa587eb8ee4b79ac67ca8f342ab62e2d2 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 16:09:52 2025 -0400 Fix multiple low priority issues closes #12, closes #80, closes #95, closes #96, closes #99 - Issue #12: Set tp_new to NULL for GridPoint and GridPointState to prevent instantiation from Python - Issue #80: Renamed Caption.size to Caption.font_size for semantic clarity - Issue #95: Fixed UICollection repr to show actual derived types instead of generic UIDrawable - Issue #96: Added extend() method to UICollection for API consistency with UIEntityCollection - Issue #99: Exposed read-only properties for Texture (sprite_width, sprite_height, sheet_width, sheet_height, sprite_count, source) and Font (family, source) All issues have corresponding tests that verify the fixes work correctly. commit e5affaf317665395135c936bc4a6b840ae321765 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 15:50:09 2025 -0400 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
2025-07-05 17:30:49 -04:00
} else {
std::cout << "Failed to open script: " << script_path.string() << std::endl;
}
}
void McRFPy_API::api_shutdown()
{
// Audio cleanup now handled by Python garbage collection (Sound/Music classes)
Py_Finalize();
}
void McRFPy_API::executePyString(std::string pycode)
{
PyRun_SimpleString(pycode.c_str());
}
void McRFPy_API::REPL()
{
PyRun_InteractiveLoop(stdin, "<stdin>");
}
void McRFPy_API::REPL_device(FILE * fp, const char *filename)
{
PyRun_InteractiveLoop(fp, filename);
}
// python connection
/*
PyObject* McRFPy_API::_refreshFov(PyObject* self, PyObject* args) {
for (auto e : McRFPy_API::entities.getEntities("player")) {
e->cGrid->grid->refreshTCODsight(e->cGrid->x, e->cGrid->y);
}
Py_INCREF(Py_None);
return Py_None;
}
*/
// Removed deprecated audio functions - use mcrfpy.Sound and mcrfpy.Music classes instead (#66)
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
// Removed deprecated player_input, computerTurn, playerTurn functions
// These were part of the old turn-based system that is no longer used
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
/*
PyObject* McRFPy_API::_camFollow(PyObject* self, PyObject* args) {
PyObject* set_camfollow = NULL;
//std::cout << "camFollow Parse Args" << std::endl;
if (!PyArg_ParseTuple(args, "|O", &set_camfollow)) return NULL;
//std::cout << "Parsed" << std::endl;
if (set_camfollow == NULL) {
// return value
//std::cout << "null; Returning value " << McRFPy_API::do_camfollow << std::endl;
Py_INCREF(McRFPy_API::do_camfollow ? Py_True : Py_False);
return McRFPy_API::do_camfollow ? Py_True : Py_False;
}
//std::cout << "non-null; setting value" << std::endl;
McRFPy_API::do_camfollow = PyObject_IsTrue(set_camfollow);
Py_INCREF(Py_None);
return Py_None;
}
*/
2026-01-03 11:01:42 -05:00
// Internal use - called by PySceneClass_get_children()
PyObject* McRFPy_API::_sceneUI(PyObject* self, PyObject* args) {
using namespace mcrfpydef;
const char *scene_cstr;
if (!PyArg_ParseTuple(args, "s", &scene_cstr)) return NULL;
auto ui = Resources::game->scene_ui(scene_cstr);
if(!ui)
{
PyErr_SetString(PyExc_RuntimeError, "No scene found by that name");
return NULL;
}
//std::cout << "vector returned has size=" << ui->size() << std::endl;
//Py_INCREF(Py_None);
//return Py_None;
PyUICollectionObject* o = (PyUICollectionObject*)PyUICollectionType.tp_alloc(&PyUICollectionType, 0);
if (o) {
o->data = ui;
o->scene_name = scene_cstr; // #183: Track scene ownership
}
return (PyObject*)o;
}
2024-03-06 10:50:19 -05:00
2026-01-03 11:01:42 -05:00
// Internal use - called by PySceneObject::activate()
2024-03-06 10:50:19 -05:00
PyObject* McRFPy_API::_setScene(PyObject* self, PyObject* args) {
const char* newscene;
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
const char* transition_str = nullptr;
float duration = 0.0f;
// Parse arguments: scene name, optional transition type, optional duration
if (!PyArg_ParseTuple(args, "s|sf", &newscene, &transition_str, &duration)) return NULL;
// Map transition string to enum
TransitionType transition_type = TransitionType::None;
if (transition_str) {
std::string trans(transition_str);
if (trans == "fade") transition_type = TransitionType::Fade;
else if (trans == "slide_left") transition_type = TransitionType::SlideLeft;
else if (trans == "slide_right") transition_type = TransitionType::SlideRight;
else if (trans == "slide_up") transition_type = TransitionType::SlideUp;
else if (trans == "slide_down") transition_type = TransitionType::SlideDown;
}
game->changeScene(newscene, transition_type, duration);
2024-03-06 10:50:19 -05:00
Py_INCREF(Py_None);
return Py_None;
}
// #180: Create a Python wrapper for an existing C++ Timer (for orphaned timers)
static PyObject* createTimerWrapper(std::shared_ptr<Timer> timer)
{
// Allocate new PyTimerObject
PyTypeObject* type = &mcrfpydef::PyTimerType;
PyTimerObject* obj = (PyTimerObject*)type->tp_alloc(type, 0);
if (!obj) return nullptr;
// Initialize - use placement new for std::string
new(&obj->name) std::string(timer->name);
obj->data = timer; // Share the existing C++ Timer
obj->weakreflist = nullptr;
// Register in cache for future lookups
if (timer->serial_number == 0) {
timer->serial_number = PythonObjectCache::getInstance().assignSerial();
}
PyObject* weakref = PyWeakref_NewRef((PyObject*)obj, NULL);
if (weakref) {
PythonObjectCache::getInstance().registerObject(timer->serial_number, weakref);
Py_DECREF(weakref);
}
return (PyObject*)obj;
}
// #173: Get all timers as a tuple of Python Timer objects
PyObject* McRFPy_API::api_get_timers()
{
if (!game) {
return PyTuple_New(0);
}
std::vector<PyObject*> timer_objs;
for (auto& pair : game->timers) {
auto& timer = pair.second;
if (!timer) continue;
PyObject* timer_obj = nullptr;
// Try to find existing Python wrapper
if (timer->serial_number != 0) {
timer_obj = PythonObjectCache::getInstance().lookup(timer->serial_number);
}
// #180: If no wrapper exists (orphaned timer), create a new one
if (!timer_obj || timer_obj == Py_None) {
timer_obj = createTimerWrapper(timer);
}
if (timer_obj && timer_obj != Py_None) {
timer_objs.push_back(timer_obj);
}
}
2024-03-07 08:59:26 -05:00
PyObject* tuple = PyTuple_New(timer_objs.size());
if (!tuple) return NULL;
for (Py_ssize_t i = 0; i < static_cast<Py_ssize_t>(timer_objs.size()); i++) {
// timer_objs already has a reference from lookup() or createTimerWrapper()
// PyTuple_SET_ITEM steals that reference, so no additional INCREF needed
PyTuple_SET_ITEM(tuple, i, timer_objs[i]);
}
return tuple;
2024-03-07 08:59:26 -05:00
}
// #153 - Headless simulation control
PyObject* McRFPy_API::_step(PyObject* self, PyObject* args) {
PyObject* dt_obj = Py_None;
if (!PyArg_ParseTuple(args, "|O", &dt_obj)) return NULL;
float dt;
if (dt_obj == Py_None) {
// None means "advance to next event"
dt = -1.0f;
} else if (PyFloat_Check(dt_obj)) {
dt = static_cast<float>(PyFloat_AsDouble(dt_obj));
} else if (PyLong_Check(dt_obj)) {
dt = static_cast<float>(PyLong_AsLong(dt_obj));
} else {
PyErr_SetString(PyExc_TypeError, "step() argument must be a float, int, or None");
return NULL;
}
if (!game) {
PyErr_SetString(PyExc_RuntimeError, "Game engine not initialized");
return NULL;
}
float actual_dt = game->step(dt);
return PyFloat_FromDouble(actual_dt);
}
PyObject* McRFPy_API::_exit(PyObject* self, PyObject* args) {
game->quit();
Py_INCREF(Py_None);
return Py_None;
}
2024-03-08 16:55:58 -05:00
PyObject* McRFPy_API::_setScale(PyObject* self, PyObject* args) {
float multiplier;
if (!PyArg_ParseTuple(args, "f", &multiplier)) return NULL;
if (multiplier < 0.2 || multiplier > 4)
{
PyErr_SetString(PyExc_ValueError, "Window scale must be between 0.2 and 4");
return NULL;
}
game->setWindowScale(multiplier);
Py_INCREF(Py_None);
return Py_None;
}
Squashed commit of the following: [interpreter_mode] closes #63 closes #69 closes #59 closes #47 closes #2 closes #3 closes #33 closes #27 closes #73 closes #74 closes #78 I'd like to thank Claude Code for ~200-250M total tokens and 500-700k output tokens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> commit 9bd1561bfc9b02d8db71b5d9390ef2631fac5b28 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 11:20:07 2025 -0400 Alpha 0.1 release - Move RenderTexture (#6) out of alpha requirements, I don't need it that badly - alpha blockers resolved: * Animation system (#59) * Z-order rendering (#63) * Python Sequence Protocol (#69) * New README (#47) * Removed deprecated methods (#2, #3) 🍾 McRogueFace 0.1.0 commit 43321487eb762e17639ba4113322b6f5df71a8d9 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:36:09 2025 -0400 Issue #63 (z-order rendering) complete - Archive z-order test files commit 90c318104bfb31ab4c741702e6661e6bf7e4d19c Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 10:34:06 2025 -0400 Fix Issue #63: Implement z-order rendering with dirty flag optimization - Add dirty flags to PyScene and UIFrame to track when sorting is needed - Implement lazy sorting - only sort when z_index changes or elements are added/removed - Make Frame children respect z_index (previously rendered in insertion order only) - Update UIDrawable::set_int to notify when z_index changes - Mark collections dirty on append, remove, setitem, and slice operations - Remove per-frame vector copy in PyScene::render for better performance commit e4482e7189095d88eec1e2ec55e01e271ed4f55f Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 01:58:03 2025 -0400 Implement complete Python Sequence Protocol for collections (closes #69) Major implementation of the full sequence protocol for both UICollection and UIEntityCollection, making them behave like proper Python sequences. Core Features Implemented: - __setitem__ (collection[i] = value) with type validation - __delitem__ (del collection[i]) with proper cleanup - __contains__ (item in collection) by C++ pointer comparison - __add__ (collection + other) returns Python list - __iadd__ (collection += other) with full validation before modification - Negative indexing support throughout - Complete slice support (getting, setting, deletion) - Extended slices with step \!= 1 - index() and count() methods - Type safety enforced for all operations UICollection specifics: - Accepts Frame, Caption, Sprite, and Grid objects only - Preserves z_index when replacing items - Auto-assigns z_index on append (existing behavior maintained) UIEntityCollection specifics: - Accepts Entity objects only - Manages grid references on add/remove/replace - Uses std::list iteration with std::advance() Also includes: - Default value support for constructors: - Caption accepts None for font (uses default_font) - Grid accepts None for texture (uses default_texture) - Sprite accepts None for texture (uses default_texture) - Entity accepts None for texture (uses default_texture) This completes Issue #69, removing it as an Alpha Blocker. commit 70cf44f8f044ed49544dd9444245115187d3b318 Author: John McCardle <mccardle.john@gmail.com> Date: Sat Jul 5 00:56:42 2025 -0400 Implement comprehensive animation system (closes #59) - Add Animation class with 30+ easing functions (linear, ease in/out, quad, cubic, elastic, bounce, etc.) - Add property system to all UI classes for animation support: - UIFrame: position, size, colors (including individual r/g/b/a components) - UICaption: position, size, text, colors - UISprite: position, scale, sprite_number (with sequence support) - UIGrid: position, size, camera center, zoom - UIEntity: position, sprite properties - Create AnimationManager singleton for frame-based updates - Add Python bindings through PyAnimation wrapper - Support for delta animations (relative values) - Fix segfault when running scripts directly (mcrf_module initialization) - Fix headless/windowed mode behavior to respect --headless flag - Animations run purely in C++ without Python callbacks per frame All UI properties are now animatable with smooth interpolation and professional easing curves. commit 05bddae5112f2b5949a9d2b32dd3dc2bf4656837 Author: John McCardle <mccardle.john@gmail.com> Date: Fri Jul 4 06:59:02 2025 -0400 Update comprehensive documentation for Alpha release (Issue #47) - Completely rewrote README.md to reflect current features - Updated GitHub Pages documentation site with: - Modern landing page highlighting Crypt of Sokoban - Comprehensive API reference (2700+ lines) with exhaustive examples - Updated getting-started guide with installation and first game tutorial - 8 detailed tutorials covering all major game systems - Quick reference cheat sheet for common operations - Generated documentation screenshots showing UI elements - Fixed deprecated API references and added new features - Added automation API documentation - Included Python 3.12 requirement and platform-specific instructions Note: Text rendering in headless mode has limitations for screenshots commit af6a5e090b9f52e3328294a988bdc18ff4b6c981 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:58 2025 -0400 Update ROADMAP.md to reflect completion of Issues #2 and #3 - Marked both issues as completed with the removal of deprecated action system - Updated open issue count from ~50 to ~48 - These were both Alpha blockers, bringing us closer to release commit 281800cd2345cc57024c9bcdd18860d2bb8db027 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:43:22 2025 -0400 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. commit cc8a7d20e8ea5c7b32cad2565cc9e85e27bef147 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:59 2025 -0400 Clean up temporary test files commit ff83fd8bb159cd2e7d9056379576d147bd99656b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:13:46 2025 -0400 Update ROADMAP.md to reflect massive progress today - Fixed 12+ critical bugs in a single session - Implemented 3 missing features (Entity.index, EntityCollection.extend, sprite validation) - Updated Phase 1 progress showing 11 of 12 items complete - Added detailed summary of today's achievements with issue numbers - Emphasized test-driven development approach used throughout commit dae400031fe389025955bee423f9b327fd596b1d Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:12:29 2025 -0400 Remove deprecated player_input and turn-based functions for Issue #3 Removed the commented-out player_input(), computerTurn(), and playerTurn() functions that were part of the old turn-based system. These are no longer needed as input is now handled through Scene callbacks. Partial fix for #3 commit cb0130b46eb873d7a38b4647b0f3d2698f234ab9 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:09:06 2025 -0400 Implement sprite index validation for Issue #33 Added validation to prevent setting sprite indices outside the valid range for a texture. The implementation: - Adds getSpriteCount() method to PyTexture to expose total sprites - Validates sprite_number setter to ensure index is within bounds - Provides clear error messages showing valid range - Works for both Sprite and Entity objects closes #33 commit 1e7f5e9e7e9e4d6e9494ba6c19f1ae0c5282b449 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:05:47 2025 -0400 Implement EntityCollection.extend() method for Issue #27 Added extend() method to EntityCollection that accepts any iterable of Entity objects and adds them all to the collection. The method: - Accepts lists, tuples, generators, or any iterable - Validates all items are Entity objects - Sets the grid association for each added entity - Properly handles errors and empty iterables closes #27 commit 923350137d148c56e617eae966467c77617c131b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 21:02:14 2025 -0400 Implement Entity.index() method for Issue #73 Added index() method to Entity class that returns the entity's position in its parent grid's entity collection. This enables proper entity removal patterns using entity.index(). commit 6134869371cf4e7ae79515690960a563fd0db40e Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:41:03 2025 -0400 Add validation to keypressScene() for non-callable arguments Added PyCallable_Check validation to ensure keypressScene() only accepts callable objects. Now properly raises TypeError with a clear error message when passed non-callable arguments like strings, numbers, None, or dicts. commit 4715356b5e760b9fd8f2087565adaab2fb94573b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:31:36 2025 -0400 Fix Sprite texture setter 'error return without exception set' Implemented the missing UISprite::set_texture method to properly: - Validate the input is a Texture instance - Update the sprite's texture using setTexture() - Return appropriate error messages for invalid inputs The setter now works correctly and no longer returns -1 without setting an exception. commit 6dd1cec600efd3b9f44f67968a23c88e05e19ec8 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 20:27:32 2025 -0400 Fix Entity property setters and PyVector implementation Fixed the 'new style getargs format' error in Entity property setters by: - Implementing PyObject_to_sfVector2f/2i using PyVector::from_arg - Adding proper error checking in Entity::set_position - Implementing PyVector get_member/set_member for x/y properties - Fixing PyVector::from_arg to handle non-tuple arguments correctly Now Entity.pos and Entity.sprite_number setters work correctly with proper type validation. commit f82b861bcdffa9d3df69bd29c7c88be2a30c9ba5 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:48:33 2025 -0400 Fix Issue #74: Add missing Grid.grid_y property Added individual grid_x and grid_y getter properties to the Grid class to complement the existing grid_size property. This allows direct access to grid dimensions and fixes error messages that referenced these properties before they existed. closes #74 commit 59e6f8d53dda6938914ce854249925b3ce7f41f4 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:42:32 2025 -0400 Fix Issue #78: Middle mouse click no longer sends 'C' keyboard event The bug was caused by accessing event.key.code on a mouse event without checking the event type first. Since SFML uses a union for events, this read garbage data. The middle mouse button value (2) coincidentally matched the keyboard 'C' value (2), causing the spurious keyboard event. Fixed by adding event type check before accessing key-specific fields. Only keyboard events (KeyPressed/KeyReleased) now trigger key callbacks. Test added to verify middle clicks no longer generate keyboard events. Closes #78 commit 1c71d8d4f743900bf2bef097b3d1addf64dbe04a Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:36:15 2025 -0400 Fix Grid to support None/null texture and fix error message bug - Allow Grid to be created with None as texture parameter - Use default cell dimensions (16x16) when no texture provided - Skip sprite rendering when texture is null, but still render colors - Fix issue #77: Corrected copy/paste error in Grid.at() error messages - Grid now functional for color-only rendering and entity positioning Test created to verify Grid works without texture, showing colored cells. Closes #77 commit 18cfe93a44a9f4dcde171f442dc3d56711a0906b Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 19:25:49 2025 -0400 Fix --exec interactive prompt bug and create comprehensive test suite Major fixes: - Fixed --exec entering Python REPL instead of game loop - Resolved screenshot transparency issue (requires timer callbacks) - Added debug output to trace Python initialization Test suite created: - 13 comprehensive tests covering all Python-exposed methods - Tests use timer callback pattern for proper game loop interaction - Discovered multiple critical bugs and missing features Critical bugs found: - Grid class segfaults on instantiation (blocks all Grid functionality) - Issue #78 confirmed: Middle mouse click sends 'C' keyboard event - Entity property setters have argument parsing errors - Sprite texture setter returns improper error - keypressScene() segfaults on non-callable arguments Documentation updates: - Updated CLAUDE.md with testing guidelines and TDD practices - Created test reports documenting all findings - Updated ROADMAP.md with test results and new priorities The Grid segfault is now the highest priority as it blocks all Grid-based functionality. commit 9ad0b6850d5f77d93c22eb52cbeb4d8442e77918 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 15:55:24 2025 -0400 Update ROADMAP.md to reflect Python interpreter and automation API progress - Mark #32 (Python interpreter behavior) as 90% complete - All major Python flags implemented: -h, -V, -c, -m, -i - Script execution with proper sys.argv handling works - Only stdin (-) support missing - Note that new automation API enables: - Automated UI testing capabilities - Demo recording and playback - Accessibility testing support - Flag issues #53 and #45 as potentially aided by automation API commit 7ec4698653383cb28f0115d1abf1db0a500257ec Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:57:59 2025 -0400 Update ROADMAP.md to remove closed issues - Remove #72 (iterator improvements - closed) - Remove #51 (UIEntity derive from UIDrawable - closed) - Update issue counts: 64 open issues from original 78 - Update dependencies and references to reflect closed issues - Clarify that core iterators are complete, only grid points remain commit 68c1a016b0e1d1b438c926f5576e5650b9617fe1 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 14:27:01 2025 -0400 Implement --exec flag and PyAutoGUI-compatible automation API - Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements commit 763fa201f041a0d32bc45695c1bbbac5590adba0 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 10:43:17 2025 -0400 Python command emulation commit a44b8c93e938ca0c58cff7e5157293d97d182a39 Author: John McCardle <mccardle.john@gmail.com> Date: Thu Jul 3 09:42:46 2025 -0400 Prep: Cleanup for interpreter mode
2025-07-05 12:04:20 -04:00
void McRFPy_API::markSceneNeedsSort() {
// Mark the current scene as needing a z_index sort
auto scene = game->currentScene();
if (scene && scene->ui_elements) {
// Cast to PyScene to access ui_elements_need_sort
PyScene* pyscene = dynamic_cast<PyScene*>(scene);
if (pyscene) {
pyscene->ui_elements_need_sort = true;
}
}
}
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
// Helper function to check if a name matches a pattern with wildcards
static bool name_matches_pattern(const std::string& name, const std::string& pattern) {
if (pattern.find('*') == std::string::npos) {
// No wildcards, exact match
return name == pattern;
}
// Simple wildcard matching - * matches any sequence
size_t name_pos = 0;
size_t pattern_pos = 0;
while (pattern_pos < pattern.length() && name_pos < name.length()) {
if (pattern[pattern_pos] == '*') {
// Skip consecutive stars
while (pattern_pos < pattern.length() && pattern[pattern_pos] == '*') {
pattern_pos++;
}
if (pattern_pos == pattern.length()) {
// Pattern ends with *, matches rest of name
return true;
}
// Find next non-star character in pattern
char next_char = pattern[pattern_pos];
while (name_pos < name.length() && name[name_pos] != next_char) {
name_pos++;
}
} else if (pattern[pattern_pos] == name[name_pos]) {
pattern_pos++;
name_pos++;
} else {
return false;
}
}
// Skip trailing stars in pattern
while (pattern_pos < pattern.length() && pattern[pattern_pos] == '*') {
pattern_pos++;
}
return pattern_pos == pattern.length() && name_pos == name.length();
}
// Helper to recursively search a collection for named elements
static void find_in_collection(std::vector<std::shared_ptr<UIDrawable>>* collection, const std::string& pattern,
bool find_all, PyObject* results) {
if (!collection) return;
for (auto& drawable : *collection) {
if (!drawable) continue;
// Check this element's name
if (name_matches_pattern(drawable->name, pattern)) {
// Convert to Python object using RET_PY_INSTANCE logic
PyObject* py_obj = nullptr;
switch (drawable->derived_type()) {
case PyObjectsEnum::UIFRAME: {
auto frame = std::static_pointer_cast<UIFrame>(drawable);
auto type = (PyTypeObject*)PyObject_GetAttrString(McRFPy_API::mcrf_module, "Frame");
auto o = (PyUIFrameObject*)type->tp_alloc(type, 0);
if (o) {
o->data = frame;
py_obj = (PyObject*)o;
}
break;
}
case PyObjectsEnum::UICAPTION: {
auto caption = std::static_pointer_cast<UICaption>(drawable);
auto type = (PyTypeObject*)PyObject_GetAttrString(McRFPy_API::mcrf_module, "Caption");
auto o = (PyUICaptionObject*)type->tp_alloc(type, 0);
if (o) {
o->data = caption;
py_obj = (PyObject*)o;
}
break;
}
case PyObjectsEnum::UISPRITE: {
auto sprite = std::static_pointer_cast<UISprite>(drawable);
auto type = (PyTypeObject*)PyObject_GetAttrString(McRFPy_API::mcrf_module, "Sprite");
auto o = (PyUISpriteObject*)type->tp_alloc(type, 0);
if (o) {
o->data = sprite;
py_obj = (PyObject*)o;
}
break;
}
case PyObjectsEnum::UIGRID: {
auto grid = std::static_pointer_cast<UIGrid>(drawable);
auto type = (PyTypeObject*)PyObject_GetAttrString(McRFPy_API::mcrf_module, "Grid");
auto o = (PyUIGridObject*)type->tp_alloc(type, 0);
if (o) {
o->data = grid;
py_obj = (PyObject*)o;
}
break;
}
default:
break;
}
if (py_obj) {
if (find_all) {
PyList_Append(results, py_obj);
Py_DECREF(py_obj);
} else {
// For find (not findAll), we store in results and return early
PyList_Append(results, py_obj);
Py_DECREF(py_obj);
return;
}
}
}
// Recursively search in Frame children
if (drawable->derived_type() == PyObjectsEnum::UIFRAME) {
auto frame = std::static_pointer_cast<UIFrame>(drawable);
find_in_collection(frame->children.get(), pattern, find_all, results);
if (!find_all && PyList_Size(results) > 0) {
return; // Found one, stop searching
}
}
}
}
// Also search Grid entities
static void find_in_grid_entities(UIGrid* grid, const std::string& pattern,
bool find_all, PyObject* results) {
if (!grid || !grid->entities) return;
for (auto& entity : *grid->entities) {
if (!entity) continue;
// Entities delegate name to their sprite
if (name_matches_pattern(entity->sprite.name, pattern)) {
auto type = (PyTypeObject*)PyObject_GetAttrString(McRFPy_API::mcrf_module, "Entity");
auto o = (PyUIEntityObject*)type->tp_alloc(type, 0);
if (o) {
o->data = entity;
PyObject* py_obj = (PyObject*)o;
if (find_all) {
PyList_Append(results, py_obj);
Py_DECREF(py_obj);
} else {
PyList_Append(results, py_obj);
Py_DECREF(py_obj);
return;
}
}
}
}
}
PyObject* McRFPy_API::_find(PyObject* self, PyObject* args) {
const char* name;
const char* scene_name = nullptr;
if (!PyArg_ParseTuple(args, "s|s", &name, &scene_name)) {
return NULL;
}
PyObject* results = PyList_New(0);
// Get the UI elements to search
std::shared_ptr<std::vector<std::shared_ptr<UIDrawable>>> ui_elements;
if (scene_name) {
// Search specific scene
ui_elements = game->scene_ui(scene_name);
if (!ui_elements) {
PyErr_Format(PyExc_ValueError, "Scene '%s' not found", scene_name);
Py_DECREF(results);
return NULL;
}
} else {
// Search current scene
Scene* current = game->currentScene();
if (!current) {
PyErr_SetString(PyExc_RuntimeError, "No current scene");
Py_DECREF(results);
return NULL;
}
ui_elements = current->ui_elements;
}
// Search the scene's UI elements
find_in_collection(ui_elements.get(), name, false, results);
// Also search all grids in the scene for entities
if (PyList_Size(results) == 0 && ui_elements) {
for (auto& drawable : *ui_elements) {
if (drawable && drawable->derived_type() == PyObjectsEnum::UIGRID) {
auto grid = std::static_pointer_cast<UIGrid>(drawable);
find_in_grid_entities(grid.get(), name, false, results);
if (PyList_Size(results) > 0) break;
}
}
}
// Return the first result or None
if (PyList_Size(results) > 0) {
PyObject* result = PyList_GetItem(results, 0);
Py_INCREF(result);
Py_DECREF(results);
return result;
}
Py_DECREF(results);
Py_RETURN_NONE;
}
PyObject* McRFPy_API::_findAll(PyObject* self, PyObject* args) {
const char* pattern;
const char* scene_name = nullptr;
if (!PyArg_ParseTuple(args, "s|s", &pattern, &scene_name)) {
return NULL;
}
PyObject* results = PyList_New(0);
// Get the UI elements to search
std::shared_ptr<std::vector<std::shared_ptr<UIDrawable>>> ui_elements;
if (scene_name) {
// Search specific scene
ui_elements = game->scene_ui(scene_name);
if (!ui_elements) {
PyErr_Format(PyExc_ValueError, "Scene '%s' not found", scene_name);
Py_DECREF(results);
return NULL;
}
} else {
// Search current scene
Scene* current = game->currentScene();
if (!current) {
PyErr_SetString(PyExc_RuntimeError, "No current scene");
Py_DECREF(results);
return NULL;
}
ui_elements = current->ui_elements;
}
// Search the scene's UI elements
find_in_collection(ui_elements.get(), pattern, true, results);
// Also search all grids in the scene for entities
if (ui_elements) {
for (auto& drawable : *ui_elements) {
if (drawable && drawable->derived_type() == PyObjectsEnum::UIGRID) {
auto grid = std::static_pointer_cast<UIGrid>(drawable);
find_in_grid_entities(grid.get(), pattern, true, results);
}
}
}
return results;
}
PyObject* McRFPy_API::_getMetrics(PyObject* self, PyObject* args) {
// Create a dictionary with metrics
PyObject* dict = PyDict_New();
if (!dict) return NULL;
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
// Add frame time metrics
PyDict_SetItemString(dict, "frame_time", PyFloat_FromDouble(game->metrics.frameTime));
PyDict_SetItemString(dict, "avg_frame_time", PyFloat_FromDouble(game->metrics.avgFrameTime));
PyDict_SetItemString(dict, "fps", PyLong_FromLong(game->metrics.fps));
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
// Add draw call metrics
PyDict_SetItemString(dict, "draw_calls", PyLong_FromLong(game->metrics.drawCalls));
PyDict_SetItemString(dict, "ui_elements", PyLong_FromLong(game->metrics.uiElements));
PyDict_SetItemString(dict, "visible_elements", PyLong_FromLong(game->metrics.visibleElements));
// #144 - Add detailed timing breakdown (in milliseconds)
PyDict_SetItemString(dict, "grid_render_time", PyFloat_FromDouble(game->metrics.gridRenderTime));
PyDict_SetItemString(dict, "entity_render_time", PyFloat_FromDouble(game->metrics.entityRenderTime));
PyDict_SetItemString(dict, "fov_overlay_time", PyFloat_FromDouble(game->metrics.fovOverlayTime));
PyDict_SetItemString(dict, "python_time", PyFloat_FromDouble(game->metrics.pythonScriptTime));
PyDict_SetItemString(dict, "animation_time", PyFloat_FromDouble(game->metrics.animationTime));
// #144 - Add grid-specific metrics
PyDict_SetItemString(dict, "grid_cells_rendered", PyLong_FromLong(game->metrics.gridCellsRendered));
PyDict_SetItemString(dict, "entities_rendered", PyLong_FromLong(game->metrics.entitiesRendered));
PyDict_SetItemString(dict, "total_entities", PyLong_FromLong(game->metrics.totalEntities));
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
// Add general metrics
PyDict_SetItemString(dict, "current_frame", PyLong_FromLong(game->getFrame()));
PyDict_SetItemString(dict, "runtime", PyFloat_FromDouble(game->runtime.getElapsedTime().asSeconds()));
Squashed commit of 53 Commits: [alpha_streamline_2] * Field of View, Pathing courtesy of libtcod * python-tcod emulation at `mcrfpy.libtcod` - partial implementation * documentation, tutorial drafts: in middling to good shape ┌────────────┬────────────────────┬───────────┬────────────┬───────────────┬────────────────┬────────────────┬─────────────┐ │ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-05 │ - opus-4 │ 13,630 │ 159,500 │ 3,854,900 │ 84,185,034 │ 88,213,064 │ $210.72 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-06 │ - opus-4 │ 5,814 │ 113,190 │ 4,242,407 │ 150,191,183 │ 154,552,594 │ $313.41 │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-07 │ - opus-4 │ 7,244 │ 104,599 │ 3,894,453 │ 81,781,179 │ 85,787,475 │ $184.46 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-08 │ - opus-4 │ 50,312 │ 158,599 │ 5,021,189 │ 60,028,561 │ 65,258,661 │ $167.05 │ │ │ - sonnet-4 │ │ │ │ │ │ │ ├────────────┼────────────────────┼───────────┼────────────┼───────────────┼────────────────┼────────────────┼─────────────┤ │ 2025-07-09 │ - opus-4 │ 6,311 │ 109,653 │ 4,171,140 │ 80,092,875 │ 84,379,979 │ $193.09 │ │ │ - sonnet-4 │ │ │ │ │ │ │ └────────────┴────────────────────┴───────────┴────────────┴───────────────┴────────────────┴────────────────┴─────────────┘ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Author: John McCardle <mccardle.john@gmail.com> Draft tutorials Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with FOV, A* pathfinding, and GUI text widget completions - Mark TCOD Integration Sprint as complete - Document FOV system with perspective rendering implementation - Update UIEntity pathfinding status to complete with A* and caching - Add comprehensive achievement entry for July 10 work - Reflect current engine capabilities accurately The engine now has all core roguelike mechanics: - Field of View with per-entity visibility - Pathfinding (both Dijkstra and A*) - Text input for in-game consoles - Performance optimizations throughout Author: John McCardle <mccardle.john@gmail.com> feat(engine): implement perspective FOV, pathfinding, and GUI text widgets Major Engine Enhancements: - Complete FOV (Field of View) system with perspective rendering - UIGrid.perspective property for entity-based visibility - Three-layer overlay colors (unexplored, explored, visible) - Per-entity visibility state tracking - Perfect knowledge updates only for explored areas - Advanced Pathfinding Integration - A* pathfinding implementation in UIGrid - Entity.path_to() method for direct pathfinding - Dijkstra maps for multi-target pathfinding - Path caching for performance optimization - GUI Text Input Widgets - TextInputWidget class with cursor, selection, scrolling - Improved widget with proper text rendering and input handling - Example showcase of multiple text input fields - Foundation for in-game console and chat systems - Performance & Architecture Improvements - PyTexture copy operations optimized - GameEngine update cycle refined - UIEntity property handling enhanced - UITestScene modernized Test Suite: - Interactive visibility demos showing FOV in action - Pathfinding comparison (A* vs Dijkstra) - Debug utilities for visibility and empty path handling - Sizzle reel demo combining pathfinding and vision - Multiple text input test scenarios This commit brings McRogueFace closer to a complete roguelike engine with essential features like line-of-sight, intelligent pathfinding, and interactive text input capabilities. Author: John McCardle <mccardle.john@gmail.com> feat(demos): enhance interactive pathfinding demos with entity.path_to() - dijkstra_interactive_enhanced.py: Animation along paths with smooth movement - M key to start movement animation - P to pause/resume - R to reset positions - Visual path gradient for better clarity - pathfinding_showcase.py: Advanced multi-entity behaviors - Chase mode: enemies pursue player - Flee mode: enemies avoid player - Patrol mode: entities follow waypoints - WASD player movement - Dijkstra distance field visualization (D key) - Larger dungeon map with multiple rooms - Both demos use new entity.path_to() method - Smooth interpolated movement animations - Real-time pathfinding recalculation - Comprehensive test coverage These demos showcase the power of integrated pathfinding for game AI. Author: John McCardle <mccardle.john@gmail.com> feat(entity): implement path_to() method for entity pathfinding - Add path_to(target_x, target_y) method to UIEntity class - Uses existing Dijkstra pathfinding implementation from UIGrid - Returns list of (x, y) coordinate tuples for complete path - Supports both positional and keyword argument formats - Proper error handling for out-of-bounds and no-grid scenarios - Comprehensive test suite covering normal and edge cases Part of TCOD integration sprint - gives entities immediate pathfinding capabilities. Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap with Dijkstra pathfinding progress - Mark UIGrid TCOD Integration as completed - Document critical PyArg bug fix achievement - Update UIEntity Pathfinding to 50% complete - Add detailed progress notes for July 9 sprint work Author: John McCardle <mccardle.john@gmail.com> feat(tcod): complete Dijkstra pathfinding implementation with critical PyArg fix - Add complete Dijkstra pathfinding to UIGrid class - compute_dijkstra(), get_dijkstra_distance(), get_dijkstra_path() - Full TCODMap and TCODDijkstra integration - Proper memory management in constructors/destructors - Create mcrfpy.libtcod submodule with Python bindings - dijkstra_compute(), dijkstra_get_distance(), dijkstra_get_path() - line() function for drawing corridors - Foundation for future FOV and pathfinding algorithms - Fix critical PyArg bug in UIGridPoint color setter - PyObject_to_sfColor() now handles both Color objects and tuples - Prevents "SystemError: new style getargs format but argument is not a tuple" - Proper error handling and exception propagation - Add comprehensive test suite - test_dijkstra_simple.py validates all pathfinding operations - dijkstra_test.py for headless testing with screenshots - dijkstra_interactive.py for full user interaction demos - Consolidate and clean up test files - Removed 6 duplicate/broken demo attempts - Two clean versions: headless test + interactive demo Part of TCOD integration sprint for RoguelikeDev Tutorial Event. Author: John McCardle <mccardle.john@gmail.com> Roguelike Tutorial Planning + Prep Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete markdown API documentation export - Created comprehensive markdown documentation matching HTML completeness - Documented all 75 functions, 20 classes, 56 methods, and 20 automation methods - Zero ellipsis instances - complete coverage with no missing documentation - Added proper markdown formatting with code blocks and navigation - Included full parameter documentation, return values, and examples Key features: - 23KB GitHub-compatible markdown documentation - 47 argument sections with detailed parameters - 35 return value specifications - 23 code examples with syntax highlighting - 38 explanatory notes and 10 exception specifications - Full table of contents with anchor links - Professional markdown formatting Both export formats now available: - HTML: docs/api_reference_complete.html (54KB, rich styling) - Markdown: docs/API_REFERENCE_COMPLETE.md (23KB, GitHub-compatible) Author: John McCardle <mccardle.john@gmail.com> feat(docs): complete API documentation with zero missing methods - Eliminated ALL ellipsis instances (0 remaining) - Documented 40 functions with complete signatures and examples - Documented 21 classes with full method and property documentation - Added 56 method descriptions with detailed parameters and return values - Included 15 complete property specifications - Added 24 code examples and 38 explanatory notes - Comprehensive coverage of all collection methods, system classes, and functions Key highlights: - EntityCollection/UICollection: Complete method docs (append, remove, extend, count, index) - Animation: Full property and method documentation with examples - Color: All manipulation methods (from_hex, to_hex, lerp) with examples - Vector: Complete mathematical operations (magnitude, normalize, dot, distance_to, angle, copy) - Scene: All management methods including register_keyboard - Timer: Complete control methods (pause, resume, cancel, restart) - Window: All management methods (get, center, screenshot) - System functions: Complete audio, scene, UI, and system function documentation Author: John McCardle <mccardle.john@gmail.com> feat(docs): create professional HTML API documentation - Fixed all formatting issues from original HTML output - Added comprehensive constructor documentation for all classes - Enhanced visual design with modern styling and typography - Fixed literal newline display and markdown link conversion - Added proper semantic HTML structure and navigation - Includes detailed documentation for Entity, collections, and system types Author: John McCardle <mccardle.john@gmail.com> feat: complete API reference generator and finish Phase 7 documentation Implemented comprehensive API documentation generator that: - Introspects live mcrfpy module for accurate documentation - Generates organized Markdown reference (docs/API_REFERENCE.md) - Categorizes classes and functions by type - Includes full automation module documentation - Provides summary statistics Results: - 20 classes documented - 19 module functions documented - 20 automation methods documented - 100% coverage of public API - Clean, readable Markdown output Phase 7 Summary: - Completed 4/5 tasks (1 cancelled as architecturally inappropriate) - All documentation tasks successful - Type stubs, docstrings, and API reference all complete Author: John McCardle <mccardle.john@gmail.com> docs: cancel PyPI wheel task and add future vision for Python extension architecture Task #70 Analysis: - Discovered fundamental incompatibility with PyPI distribution - McRogueFace embeds CPython rather than being loaded by it - Traditional wheels expect to extend existing Python interpreter - Current architecture is application-with-embedded-Python Decisions: - Cancelled PyPI wheel preparation as out of scope for Alpha - Cleaned up attempted packaging files (pyproject.toml, setup.py, etc.) - Identified better distribution methods (installers, package managers) Added Future Vision: - Comprehensive plan for pure Python extension architecture - Would allow true "pip install mcrogueface" experience - Requires major refactoring to invert control flow - Python would drive main loop with C++ performance extensions - Unscheduled but documented as long-term possibility This clarifies the architectural boundaries and sets realistic expectations for distribution methods while preserving the vision of what McRogueFace could become with significant rework. Author: John McCardle <mccardle.john@gmail.com> feat: generate comprehensive .pyi type stubs for IDE support (#108) Created complete type stub files for the mcrfpy module to enable: - Full IntelliSense/autocomplete in IDEs - Static type checking with mypy/pyright - Better documentation tooltips - Parameter hints and return types Implementation details: - Manually crafted stubs for accuracy (15KB, 533 lines) - Complete coverage: 19 classes, 112 functions/methods - Proper type annotations using typing module - @overload decorators for multiple signatures - Type aliases for common patterns (UIElement union) - Preserved all docstrings for IDE help - Automation module fully typed - PEP 561 compliant with py.typed marker Testing: - Validated Python syntax with ast.parse() - Verified all expected classes and functions - Confirmed type annotations are well-formed - Checked docstring preservation (80 docstrings) Usage: - VS Code: Add stubs/ to python.analysis.extraPaths - PyCharm: Mark stubs/ directory as Sources Root - Other IDEs will auto-detect .pyi files This significantly improves the developer experience when using McRogueFace as a Python game engine. Author: John McCardle <mccardle.john@gmail.com> docs: add comprehensive parameter documentation to all API methods (#86) Enhanced documentation for the mcrfpy module with: - Detailed docstrings for all API methods - Type hints in documentation (name: type format) - Return type specifications - Exception documentation where applicable - Usage examples for complex methods - Module-level documentation with overview and example code Specific improvements: - Audio API: Added parameter types and return values - Scene API: Documented transition types and error conditions - Timer API: Clarified handler signature and runtime parameter - UI Search: Added wildcard pattern examples for findAll() - Metrics API: Documented all dictionary keys returned Also fixed method signatures: - Changed METH_VARARGS to METH_NOARGS for parameterless methods - Ensures proper Python calling conventions Test coverage included - all documentation is accessible via Python's __doc__ attributes and shows correctly formatted information. Author: John McCardle <mccardle.john@gmail.com> docs: mark issue #85 as completed in Phase 7 Author: John McCardle <mccardle.john@gmail.com> docs: replace all 'docstring' placeholders with comprehensive documentation (#85) Added proper Python docstrings for all UI component classes: UIFrame: - Container element that can hold child drawables - Documents position, size, colors, outline, and clip_children - Includes constructor signature with all parameters UICaption: - Text display element with font and styling - Documents text content, position, font, colors, outline - Notes that w/h are computed from text content UISprite: - Texture/sprite display element - Documents position, texture, sprite_index, scale - Notes that w/h are computed from texture and scale UIGrid: - Tile-based grid for game worlds - Documents grid dimensions, tile size, texture atlas - Includes entities collection and background_color All docstrings follow consistent format: - Constructor signature with defaults - Brief description - Args section with types and defaults - Attributes section with all properties This completes Phase 7 task #85 for documentation improvements. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP with PyArgHelpers infrastructure completion Author: John McCardle <mccardle.john@gmail.com> refactor: implement PyArgHelpers for standardized Python argument parsing This major refactoring standardizes how position, size, and other arguments are parsed across all UI components. PyArgHelpers provides consistent handling for various argument patterns: - Position as (x, y) tuple or separate x, y args - Size as (w, h) tuple or separate width, height args - Grid position and size with proper validation - Color parsing with PyColorObject support Changes across UI components: - UICaption: Migrated to PyArgHelpers, improved resize() for future multiline support - UIFrame: Uses standardized position parsing - UISprite: Consistent position handling - UIGrid: Grid-specific position/size helpers - UIEntity: Unified argument parsing Also includes: - Improved error messages for type mismatches (int or float accepted) - Reduced code duplication across constructors - Better handling of keyword/positional argument conflicts - Maintains backward compatibility with existing API This addresses the inconsistent argument handling patterns discovered during the inheritance hierarchy work and prepares for Phase 7 documentation. Author: John McCardle <mccardle.john@gmail.com> feat(Python): establish proper inheritance hierarchy for UI types All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UISprite) - Update UISprite to use base class position instead of sprite position - Synchronize sprite position with base class position for rendering - Implement onPositionChanged() for position synchronization - Update all UISprite methods to use base position consistently - Add comprehensive test coverage for UISprite position handling This is part 3 of moving position to the base class. UIGrid is the final class that needs to be updated. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UICaption) - Update UICaption to use base class position instead of text position - Synchronize text position with base class position for rendering - Add onPositionChanged() virtual method for position synchronization - Update all UICaption methods to use base position consistently - Add comprehensive test coverage for UICaption position handling This is part 2 of moving position to the base class. UISprite and UIGrid will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: move position property to UIDrawable base class (UIFrame) - Add position member to UIDrawable base class - Add common position getters/setters (x, y, pos) to base class - Update UIFrame to use base class position instead of box position - Synchronize box position with base class position for rendering - Update all UIFrame methods to use base position consistently - Add comprehensive test coverage for UIFrame position handling This is part 1 of moving position to the base class. Other derived classes (UICaption, UISprite, UIGrid) will be updated in subsequent commits. Author: John McCardle <mccardle.john@gmail.com> refactor: remove UIEntity collision_pos field - Remove redundant collision_pos field from UIEntity - Update position getters/setters to use integer-cast position when needed - Remove all collision_pos synchronization code - Simplify entity position handling to use single float position field - Add comprehensive test coverage proving functionality is preserved This removes technical debt and simplifies the codebase without changing API behavior. Author: John McCardle <mccardle.john@gmail.com> feat: add PyArgHelpers infrastructure for standardized argument parsing - Create PyArgHelpers.h with parsing functions for position, size, grid coordinates, and color - Support tuple-based vector arguments with conflict detection - Provide consistent error messages and validation - Add comprehensive test coverage for infrastructure This sets the foundation for standardizing all Python API constructors. Author: John McCardle <mccardle.john@gmail.com> docs: mark Phase 6 (Rendering Revolution) as complete Phase 6 is now complete with all core rendering features implemented: Completed Features: - Grid background colors (#50) - customizable backgrounds with animation - RenderTexture overhaul (#6) - UIFrame clipping with opt-in architecture - Viewport-based rendering (#8) - three scaling modes with coordinate transform Strategic Decisions: - UIGrid already has optimal RenderTexture implementation for its viewport needs - UICaption/UISprite clipping deemed unnecessary (no children to clip) - Effects/Shader/Particle systems deferred to post-Phase 7 for focused delivery The rendering foundation is now solid and ready for Phase 7: Documentation & Distribution. Author: John McCardle <mccardle.john@gmail.com> feat(viewport): complete viewport-based rendering system (#8) Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. Author: John McCardle <mccardle.john@gmail.com> docs: update ROADMAP for Phase 6 progress - Marked Phase 6 as IN PROGRESS - Updated RenderTexture overhaul (#6) as PARTIALLY COMPLETE - Marked Grid background colors (#50) as COMPLETED - Added technical notes from implementation experience - Identified viewport rendering (#8) as next priority Author: John McCardle <mccardle.john@gmail.com> feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6) - Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering. Author: John McCardle <mccardle.john@gmail.com> docs: create RenderTexture overhaul design document - Comprehensive design for Issue #6 implementation - Opt-in architecture to maintain backward compatibility - Phased implementation plan with clear milestones - Performance considerations and risk mitigation - API design for clipping and future effects Also includes Grid background color test Author: John McCardle <mccardle.john@gmail.com> feat(Grid): add customizable background_color property (#50) - Added sf::Color background_color member with default dark gray - Python property getter/setter for background_color - Animation support for individual color components (r/g/b/a) - Replaces hardcoded clear color in render method - Test demonstrates color changes and property access Closes #50 Author: John McCardle <mccardle.john@gmail.com> docs: update roadmap for Phase 6 preparation - Mark Phase 5 (Window/Scene Architecture) as complete - Update issue statuses (#34, #61, #1, #105 completed) - Add Phase 6 implementation strategy for RenderTexture overhaul - Archive Phase 5 test files to .archive/ - Identify quick wins and technical approach for rendering work Author: John McCardle <mccardle.john@gmail.com> feat(Phase 5): Complete Window/Scene Architecture - Window singleton with properties (resolution, fullscreen, vsync, title) - OOP Scene support with lifecycle methods (on_enter, on_exit, on_keypress, update) - Window resize events trigger scene.on_resize callbacks - Scene transitions (fade, slide_left/right/up/down) with smooth animations - Full integration of Python Scene objects with C++ engine All Phase 5 tasks (#34, #1, #61, #105) completed successfully. Author: John McCardle <mccardle.john@gmail.com> research: SFML 3.0 migration analysis - Analyzed SFML 3.0 breaking changes (event system, scoped enums, C++17) - Assessed migration impact on McRogueFace (40+ files affected) - Evaluated timing relative to mcrfpy.sfml module plans - Recommended deferring migration until after mcrfpy.sfml implementation - Created SFML_3_MIGRATION_RESEARCH.md with comprehensive strategy Author: John McCardle <mccardle.john@gmail.com> research: SFML exposure options analysis (#14) - Analyzed current SFML 2.6.1 usage throughout codebase - Evaluated python-sfml (abandoned, only supports SFML 2.3.2) - Recommended direct integration as mcrfpy.sfml module - Created comprehensive SFML_EXPOSURE_RESEARCH.md with implementation plan - Identified opportunity to provide modern SFML 2.6+ Python bindings Author: John McCardle <mccardle.john@gmail.com> feat: add basic profiling/metrics system (#104) - Add ProfilingMetrics struct to track performance data - Track frame time (current and 60-frame rolling average) - Calculate FPS from average frame time - Count draw calls, UI elements, and visible elements per frame - Track total runtime and current frame number - PyScene counts elements during render - Expose metrics via mcrfpy.getMetrics() returning dict This provides basic performance monitoring capabilities for identifying bottlenecks and optimizing rendering performance. Author: John McCardle <mccardle.john@gmail.com> fix: improve click handling with proper z-order and coordinate transforms - UIFrame: Fix coordinate transformation (subtract parent pos, not add) - UIFrame: Check children in reverse order (highest z-index first) - UIFrame: Skip invisible elements entirely - PyScene: Sort elements by z-index before checking clicks - PyScene: Stop at first element that handles the click - UIGrid: Implement entity click detection with grid coordinate transform - UIGrid: Check entities in reverse order, return sprite as target Click events now correctly respect z-order (top elements get priority), handle coordinate transforms for nested frames, and support clicking on grid entities. Elements without click handlers are transparent to clicks, allowing elements below to receive them. Note: Click testing requires non-headless mode due to PyScene limitation. feat: implement name system for finding UI elements (#39/40/41) - Add 'name' property to UIDrawable base class - All UI elements (Frame, Caption, Sprite, Grid, Entity) support .name - Entity delegates name to its sprite member - Add find(name, scene=None) function for exact match search - Add findAll(pattern, scene=None) with wildcard support (* matches any sequence) - Both functions search recursively through Frame children and Grid entities - Comprehensive test coverage for all functionality This provides a simple way to find UI elements by name in Python scripts, supporting both exact matches and wildcard patterns. Author: John McCardle <mccardle.john@gmail.com> fix: prevent segfault when closing window via X button - Add cleanup() method to GameEngine to clear Python references before destruction - Clear timers and McRFPy_API references in proper order - Call cleanup() at end of run loop and in destructor - Ensure cleanup is only called once per GameEngine instance Also includes: - Fix audio ::stop() calls (already in place, OpenAL warning is benign) - Add Caption support for x, y keywords (e.g. Caption("text", x=5, y=10)) - Refactor UIDrawable_methods.h into UIBase.h for better organization - Move UIEntity-specific implementations to UIEntityPyMethods.h Author: John McCardle <mccardle.john@gmail.com> feat: stabilize test suite and add UIDrawable methods - Add visible, opacity properties to all UI classes (#87, #88) - Add get_bounds(), move(), resize() methods to UIDrawable (#89, #98) - Create UIDrawable_methods.h with template implementations - Fix test termination issues - all tests now exit properly - Fix test_sprite_texture_swap.py click handler signature - Fix test_drawable_base.py segfault in headless mode - Convert audio objects to pointers for cleanup (OpenAL warning persists) - Remove debug print statements from UICaption - Special handling for UIEntity to delegate drawable methods to sprite All test files are now "airtight" - they complete successfully, terminate on their own, and handle edge cases properly. Author: John McCardle <mccardle.john@gmail.com> docs: add Phase 1-3 completion summary - Document all completed tasks across three phases - Show before/after API improvements - Highlight technical achievements - Outline next steps for Phase 4-7 Author: John McCardle <mccardle.john@gmail.com> feat: implement mcrfpy.Timer object with pause/resume/cancel capabilities closes #103 - Created PyTimer.h/cpp with object-oriented timer interface - Enhanced PyTimerCallable with pause/resume state tracking - Added timer control methods: pause(), resume(), cancel(), restart() - Added timer properties: interval, remaining, paused, active, callback - Fixed timing logic to prevent rapid catch-up after resume - Timer objects automatically register with game engine - Added comprehensive test demonstrating all functionality Author: John McCardle <mccardle.john@gmail.com> feat(Color): add helper methods from_hex, to_hex, lerp closes #94 - Add Color.from_hex(hex_string) class method for creating colors from hex - Support formats: #RRGGBB, RRGGBB, #RRGGBBAA, RRGGBBAA - Add color.to_hex() to convert Color to hex string - Add color.lerp(other, t) for smooth color interpolation - Comprehensive test coverage for all methods Author: John McCardle <mccardle.john@gmail.com> fix: properly configure UTF-8 encoding for Python stdio - Use PyConfig to set stdio_encoding="UTF-8" during initialization - Set stdio_errors="surrogateescape" for robust handling - Configure in both init_python() and init_python_with_config() - Cleaner solution than wrapping streams after initialization - Fixes UnicodeEncodeError when printing unicode characters Author: John McCardle <mccardle.john@gmail.com> feat(Vector): implement arithmetic operations closes #93 - Add PyNumberMethods with add, subtract, multiply, divide, negate, absolute - Add rich comparison for equality/inequality checks - Add boolean check (zero vector is False) - Implement vector methods: magnitude(), normalize(), dot(), distance_to(), angle(), copy() - Fix UIDrawable::get_click() segfault when click_callable is null - Comprehensive test coverage for all arithmetic operations Author: John McCardle <mccardle.john@gmail.com> feat: Complete position argument standardization for all UI classes - Frame and Sprite now support pos keyword override - Entity now accepts x,y arguments (was pos-only before) - All UI classes now consistently support: - (x, y) positional - ((x, y)) tuple - x=x, y=y keywords - pos=(x,y) keyword - pos=Vector keyword - Improves API consistency and flexibility Author: John McCardle <mccardle.john@gmail.com> feat: Standardize position arguments across all UI classes - Create PyPositionHelper for consistent position parsing - Grid.at() now accepts (x,y), ((x,y)), x=x, y=y, pos=(x,y) - Caption now accepts x,y args in addition to pos - Grid init fully supports keyword arguments - Maintain backward compatibility for all formats - Consistent error messages across classes Author: John McCardle <mccardle.john@gmail.com> feat: Add Entity.die() method for lifecycle management closes #30 - Remove entity from its grid's entity list - Clear grid reference after removal - Safe to call multiple times (no-op if not on grid) - Works with shared_ptr entity management Author: John McCardle <mccardle.john@gmail.com> perf: Skip out-of-bounds entities during Grid rendering closes #52 - Add visibility bounds check in entity render loop - Skip entities outside view with 1 cell margin - Improves performance for large grids with many entities - Bounds check considers zoom and pan settings Author: John McCardle <mccardle.john@gmail.com> verify: Sprite texture swapping functionality closes #19 - Texture property getter/setter already implemented - Position/scale preservation during swap confirmed - Type validation for texture assignment working - Tests verify functionality is complete Author: John McCardle <mccardle.john@gmail.com> feat: Grid size tuple support closes #90 - Add grid_size keyword parameter to Grid.__init__ - Accept tuple or list of two integers - Override grid_x/grid_y if grid_size provided - Maintain backward compatibility - Add comprehensive test coverage Author: John McCardle <mccardle.john@gmail.com> feat: Phase 1 - safe constructors and _Drawable foundation Closes #7 - Make all UI class constructors safe: - Added safe default constructors for UISprite, UIGrid, UIEntity, UICaption - Initialize all members to predictable values - Made Python init functions accept no arguments - Added x,y properties to UIEntity Closes #71 - Create _Drawable Python base class: - Created PyDrawable.h/cpp with base type (not yet inherited by UI types) - Registered in module initialization Closes #87 - Add visible property: - Added bool visible=true to UIDrawable base class - All render methods check visibility before drawing Closes #88 - Add opacity property: - Added float opacity=1.0 to UIDrawable base class - UICaption and UISprite apply opacity to alpha channel Closes #89 - Add get_bounds() method: - Virtual method returns sf::FloatRect(x,y,w,h) - Implemented in Frame, Caption, Sprite, Grid Closes #98 - Add move() and resize() methods: - move(dx,dy) for relative movement - resize(w,h) for absolute sizing - Caption resize is no-op (size controlled by font) Author: John McCardle <mccardle.john@gmail.com> docs: comprehensive alpha_streamline_2 plan and strategic vision - Add 7-phase development plan for alpha_streamline_2 branch - Define architectural dependencies and critical path - Identify new issues needed (Timer objects, event system, etc.) - Add strategic vision document with 3 transformative directions - Timeline: 10-12 weeks to solid Beta foundation Author: John McCardle <mccardle.john@gmail.com> feat(Grid): flexible at() method arguments - Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility
2025-07-09 22:41:15 -04:00
return dict;
}
PyObject* McRFPy_API::_setDevConsole(PyObject* self, PyObject* args) {
int enabled;
if (!PyArg_ParseTuple(args, "p", &enabled)) { // "p" for boolean predicate
return NULL;
}
ImGuiConsole::setEnabled(enabled);
Py_RETURN_NONE;
}
// Benchmark logging implementation (#104)
PyObject* McRFPy_API::_startBenchmark(PyObject* self, PyObject* args) {
try {
// Warn if in headless mode - benchmark frames are only recorded by the game loop
if (game && game->isHeadless()) {
PyErr_WarnEx(PyExc_UserWarning,
"Benchmark started in headless mode. Note: step() and screenshot() do not "
"record benchmark frames. The benchmark API captures per-frame data from the "
"game loop, which is bypassed when using step()-based simulation control. "
"For headless performance measurement, use Python's time module instead.", 1);
}
g_benchmarkLogger.start();
Py_RETURN_NONE;
} catch (const std::runtime_error& e) {
PyErr_SetString(PyExc_RuntimeError, e.what());
return NULL;
}
}
PyObject* McRFPy_API::_endBenchmark(PyObject* self, PyObject* args) {
try {
std::string filename = g_benchmarkLogger.end();
return PyUnicode_FromString(filename.c_str());
} catch (const std::runtime_error& e) {
PyErr_SetString(PyExc_RuntimeError, e.what());
return NULL;
}
}
PyObject* McRFPy_API::_logBenchmark(PyObject* self, PyObject* args) {
const char* message;
if (!PyArg_ParseTuple(args, "s", &message)) {
return NULL;
}
try {
g_benchmarkLogger.log(message);
Py_RETURN_NONE;
} catch (const std::runtime_error& e) {
PyErr_SetString(PyExc_RuntimeError, e.what());
return NULL;
}
}
// Exception handling implementation
void McRFPy_API::signalPythonException() {
// Check if we should exit on exception (consult config via game)
if (game && !game->isHeadless()) {
// In windowed mode, respect the config setting
// Access config through game engine - but we need to check the config
}
// For now, always signal - the game loop will check the config
exception_occurred.store(true);
exit_code.store(1);
}
bool McRFPy_API::shouldExit() {
return exception_occurred.load();
}