Skip to content

Conversation

@JumpLink
Copy link
Contributor

@JumpLink JumpLink commented Aug 31, 2025

This PR implements a comprehensive Map Editor for the RPG Maker using Excalibur.js ECS architecture with clean separation between game runtime and editor functionality.

🏗️ Architecture Overview

Key Innovation: ECS Mode Switching

  • Game Mode: Zero editor overhead (no editor components/systems)
  • Editor Mode: Full editing capabilities through component activation
  • Runtime Switching: Seamless mode transitions during execution

Core Components:

  • Component-based editor activation/deactivation
  • RPC-driven communication between GJS host and Excalibur engine
  • Modular tool system with extensible architecture
  • Performance-optimized ECS queries and caching

📋 Implementation Status

  • Phase 0: Planning & DocumentationCompleted

    • Architecture analysis and ECS concepts
    • Modular documentation structure
    • Implementation plan with detailed phases
    • Git commit with comprehensive documentation
  • Phase 1: Core Tile ReplacementCompleted

    • Implement tile visual replacement using Excalibur Canvas graphics
    • Fix Canvas/ImageSource compatibility with proper Excalibur patterns
    • Add MapResource methods for sprite sheet access and editor integration
    • Create MapEditorService for UI-engine state synchronization
    • All packages build successfully without errors
  • Phase 2: UI IntegrationCompleted

    • Import MapEditorService in main GJS app
    • Connect TilesetSelector signals to MapEditorService
    • Add tool selection UI (Brush/Eraser buttons)
    • Connect tool buttons to service methods
    • Fix timing issues with sidebar signal connections
    • Test tile selection updates engine state
    • Test tool switching updates editor mode
  • Phase 3: ECS Systems Implementation 📋 Planned

    • Create MapEditorSystem (packages/engine-excalibur/src/systems/map-editor.system.ts)
    • Create TileInteractionSystem (packages/engine-excalibur/src/systems/tile-interaction.system.ts)
    • Implement scene integration (packages/engine-excalibur/src/engine.ts)
    • Add system activation/deactivation logic
  • Phase 4: Tool System Implementation 📋 Planned

    • Create AbstractTool class (packages/engine-gjs/src/tools/abstract-tool.ts)
    • Implement BrushTool (packages/engine-gjs/src/tools/brush-tool.ts)
    • Implement EraserTool (packages/engine-gjs/src/tools/eraser-tool.ts)
    • Implement FillTool (packages/engine-gjs/src/tools/fill-tool.ts)
  • Phase 5: Testing & Polish 📋 Planned

    • Unit tests (>80% coverage)
    • Integration tests for workflows
    • Performance optimization
    • UI/UX improvements and accessibility

📖 Documentation

Implementation Plan: View Documentation
Current Status: Implementation Checklist
Architecture Overview: ECS Mode Switching
Phase Details: Phase 1 | Phase 2 | Phase 3 | Phase 4 | Phase 5

🎨 Key Features

  • ECS-First Architecture: Pure Excalibur ECS with component-based features
  • Zero Runtime Overhead: Editor systems only active when needed
  • Modular Tool System: Extensible architecture for future tools
  • Performance Optimized: Query caching, RPC batching, coordinate optimization
  • Clean Separation: Game and editor code completely isolated
  • Type Safe: Full TypeScript coverage with proper interfaces

🔄 Development Workflow

  1. Phase-by-Phase: Each phase is self-contained with clear acceptance criteria
  2. Continuous Integration: Regular commits with working code only
  3. Quality Assurance: Comprehensive testing and performance monitoring
  4. Documentation Driven: Detailed specs for each implementation phase

📊 Current Status

  • Phase: 2 (UI Integration) ✅
  • Progress: 90% (UI integration completed, engine state reception next)
  • Next Milestone: Phase 3 - ECS Systems Implementation
  • Build Status: ✅ All packages compile successfully
  • Architecture: ✅ Validated and implemented
  • Testing: ✅ Basic functionality validated

🧪 Testing Strategy

  • Unit Tests: Component and system isolation testing
  • Integration Tests: End-to-end workflow validation
  • Performance Tests: Query efficiency and system overhead
  • UI Tests: User experience and accessibility validation

🎯 Success Criteria

  • Phase 1 completed with tile replacement working
  • Phase 2 completed with full UI integration
  • Phase 3 completed with ECS systems implemented
  • All phases completed with acceptance criteria met
  • >80% test coverage across critical components
  • Performance benchmarks met (query <1ms, overhead <5%)
  • Full TypeScript type safety maintained
  • Comprehensive documentation for maintenance
  • Clean, maintainable, and extensible codebase

🚀 Recent Achievements

Latest Commits:

  • b0ecc6d feat: integrate MapEditorService with Engine and WebView
  • 3e38d3b docs: update implementation checklist for UI integration completion
  • 20db9fd feat: connect sidebar signals to MapEditorService
  • e40fa50 feat: connect MapEditorPanel signals to Sidebar
  • 87425f0 feat: add tool selection UI buttons
  • 936312f fix: resolve MapEditorService RPC timing issues

This PR demonstrates steady progress with working code at each milestone. The modular architecture ensures clean separation between game runtime and editor functionality.

- Add architecture overview with ECS mode switching concepts
- Create detailed phase-by-phase documentation (5 phases)
- Split implementation plan into focused, KI-optimized documents
- Include acceptance criteria, testing strategies, and dependencies
- Establish clear workflow for phased development approach
- Add TILE_CLICKED, TILE_HOVERED, TILE_PLACED, EDITOR_STATE_CHANGED events
- Extend RpcEngineParamMap with proper type definitions
- Update EditorInputSystem to send tile interaction RPC notifications
- Add MapEditorComponent to mark TileMap entities as editable
- Add EditorToolComponent to manage editor tool state
- Implement component lifecycle management and callbacks
- Support for tool selection, layer management, and interaction state
- Add MapEditorSystem for centralized editor state management
- Add TileInteractionSystem for handling tile click/hover interactions
- Implement Excalibur Query system for efficient entity filtering
- Add RPC communication between systems and GJS host
- Simplify engine integration by removing complex monitoring
- Add MapEditorSystem and TileInteractionSystem to scene automatically
- Systems run continuously and process entities with editor components
- Follow Excalibur ECS best practices for system lifecycle management
- Move implementation docs to WIP folder for active development
- Update map-editor-implementation-plan.md with Phase 2 completion
- Document MapEditorSystem and TileInteractionSystem implementation
- Add implementation summaries and architectural insights
- Fix TypeScript errors with improved type annotations
…pment

- Remove old documentation files from root docs/ directory
- All implementation plans moved to docs/WIP/ for ongoing development
- Maintain clean documentation structure for active development phases
- Replace TSyringe with Needle DI for modern decorator support
- Update Phase 3, 4, 5 documentation with Needle DI patterns
- Configure TypeScript for modern ECMAScript decorators
- Add DI container setup and service injection examples
- Update testing strategy to use Needle DI in stories
- Ensure GJS and GObject compatibility with new DI approach

Needle DI provides better GJS compatibility and modern standards
without requiring experimentalDecorators or reflection polyfills.
…I integration

- Update Phase 3 documentation to reflect app-level DI container setup
- Introduce package-separation strategy for improved service management
- Add examples for service registration and usage across packages
- Emphasize benefits of app-level container for type safety and maintainability
- Clarify architecture benefits and acceptance criteria for Needle DI implementation
- Deleted files: current-status-and-problems.md, implementation-checklist.md, MIGRATION-GUIDE.md, SOLUTION-tile-replacement.md
- These documents were superseded by updated plans and streamlined processes for the map editor implementation.
- Focus is now on concise, actionable documentation to support ongoing development.
- Implement tile visual replacement using Excalibur Canvas graphics
- Add MapResource methods for sprite sheet access and editor integration
- Create MapEditorService for UI-engine state synchronization
- Update implementation documentation with current progress status
- Fix Canvas/ImageSource compatibility issues with proper Excalibur patterns

This completes Steps 1-3 of the tile replacement implementation:
✅ Tile replacement with visual feedback (color-coded placeholders)
✅ SpriteSheet infrastructure ready for real sprites
✅ Service-based architecture for UI-Engine communication
✅ All packages build successfully without errors
- Fix RPC endpoint initialization in constructor
- Add safe removeRpcHandlers() method to prevent getter exceptions
- Add try-catch blocks for robust RPC handler cleanup
- Ensure WebView is properly set before accessing RPC
- Add Tools tab to MapEditorPanel with Brush/Eraser toggle buttons
- Implement tool-changed signal emission from MapEditorPanel
- Add signal handlers for tool button toggles
- Connect tool buttons to signal emission chain
- Add tool-changed signal forwarding from MapEditorPanel to Sidebar
- Implement _onToolChanged handler in Sidebar
- Add signal connections in vfunc_map() for tool button events
- Update vfunc_unmap() to properly disconnect all signal handlers
- Move sidebar signal connections from constructor to _onMapLoaded
- Add _connectSidebarSignals() method for proper timing
- Connect tile-selected and tool-changed signals to service methods
- Ensure MapEditorService is available before connecting signals
- Add proper error handling for missing service instances
- Mark Step 4 (UI Integration) as completed
- Update progress from 75% to 90% completion
- Add new known issues and their solutions
- Update next priority to Step 5 (Engine State Reception)
- Refresh current capabilities and success metrics
- Update Engine widget to support MapEditorService integration
- Update WebView widget for proper RPC communication setup
- Ensure Engine-WebView-MapEditorService communication pipeline
… up hover handling

- Move layer selection logic from MapEditorPanel to LayerSelector for better separation of concerns
- Simplify hover event handling in EditorInputSystem to remove complex optimization attempts
- Remove debug console.log statements for clean production code
- Update documentation with current status and next steps for remaining issues
- Fix CSS styling for layer selection visual feedback

Related issues:
- Layer display now shows all layers correctly
- Hover events are more reliable and less noisy
- Architecture is cleaner with self-contained widgets

Next steps:
- Analyze remaining integration issues (layer selection, tile selection, tool state)
- Implement fixes for proper state synchronization between UI and engine
…consistency

- Replace all German text with English equivalents
- Maintain consistent language throughout documentation
- Ensure professional documentation standards
- Keep all technical details and formatting intact

This ensures the documentation follows the project's English-only policy
and maintains consistency with the codebase comments and documentation.
…lity

- Implement configurable EditorToolComponent with constructor options
- Add Sprite index property for proper tile ID mapping
- Optimize hover events with hoverHasChanged flag to reduce RPC calls
- Unify TILE_HOVERED event handling in TileInteractionSystem
- Synchronize UI defaults with Engine defaults for seamless initialization
- Complete documentation update for Session 2 readiness
- Fix layer selection integration and tool state management
- Achieve MVP: functional tile replacement, eraser tool, and RPC communication

All packages build successfully with no errors or warnings.
- Remove excessive debug logging from all systems
- Extract sprite management logic into SpriteUtils class
- Improve error handling and input validation throughout
- Consolidate state synchronization cache structure
- Extract magic numbers into constants file
- Apply DRY principle by removing code duplication
- Ensure clear separation of component responsibilities
- Add comprehensive validation for tile operations

This refactor makes the codebase more maintainable, reduces technical debt, and establishes clear patterns for future development.
…xports

- Format long function calls for better readability in editor-input.system.ts
- Add exports for constants and sprite-utils in utils/index.ts
- Remove unnecessary whitespace and empty lines
- Ensure consistent code style across the codebase
- Update project status to January 2025
- Mark Session 2 as successfully completed
- Document Multi-Tileset Support implementation
- Add roadmap for Session 3: Visual Improvements
- Include technical highlights and code examples
- Translate all German documentation to English for international accessibility
- Update current status documentation with Session 2 completion details
- Add comprehensive path resolution refactoring documentation
- Include Session 3 roadmap for transparency improvements
- Document technical achievements and architectural improvements
…support

- Extract path resolution logic into reusable resolveResourcePath utility
- Add comprehensive GIO-based path resolution with fallback mechanisms
- Remove Node.js-specific process.env checks for GJS compatibility
- Enhance SpriteUtils to support both Array and Record sprite formats
- Implement automatic SpriteSet loading in MapResource
- Add robust firstGid handling for global tile ID mapping
- Improve cross-platform compatibility between GJS and Excalibur
- Simplify tile interaction logic in EditorInputSystem by extracting tile click and hover handling into dedicated methods
- Improve validation and error handling for tile placement operations
- Refactor SpriteUtils to streamline sprite retrieval and validation processes
- Remove redundant comments and improve code readability
- Ensure consistent handling of input events and hover states across the editor
…on issues

- Fix sprite loading for both array and object formats in SpriteUtils
- Implement proper Z-index management for correct tile rendering order
- Ensure layer-specific operations don't affect other layers
- Add automatic TileMap Z-index updates for proper layering
- Clean up debug logging while preserving error handling

Resolves tile rendering issues where tiles were not displaying in correct order and layer operations affected all layers instead of selected layer only.
…ter organization

- Rename manager/ to services/ directory for semantic clarity
- Rename utils/ to lib/ directory to distinguish from business logic
- Split SpriteUtils into specialized service classes:
  * SpriteValidator - input validation
  * SpriteInfoResolver - sprite information resolution
  * TileGraphicsManager - graphics operations
  * LayerManager - layer-specific operations
  * SpriteUtils - facade for all services
- Update all import statements across the codebase
- Fix barrelsby build configuration for new directory structure
- Add TypeScript architecture refactoring guidelines
- Maintain backward compatibility through re-exports

Improves code organization following SOLID principles and modern TypeScript architecture patterns. All changes maintain existing functionality while improving maintainability and developer experience.
- Update comprehensive documentation for the Map Editor, ensuring clarity and consistency in English.
- Reflect the successful completion of all sessions, highlighting achievements in multi-tileset support, layer system functionality, and visual improvements.
- Document the resolution of all remaining issues, including tile transparency and performance optimizations.
- Revise implementation plan and checklist to indicate full functionality and readiness for production use.

This update ensures that all project documentation accurately represents the current state and achievements of the Map Editor, providing a clear resource for future development and user guidance.
- Introduce a new CONTRIBUTING.md file outlining guidelines for contributors, including code of conduct, development workflow, and submission processes.
- Revise README.md to provide a clearer overview of the PixelRPG Map Editor, including installation instructions, architecture details, and a detailed table of contents.
- Update project documentation to ensure clarity and consistency, making it easier for new contributors to engage with the project.

This update enhances the onboarding experience for contributors and improves the overall documentation quality for the project.
- Introduce a new adwaita-styling.mdc file for GNOME/Adwaita CSS variables and style classes.
- Update blueprint-templates.mdc to include a reference to the new adwaita-styling rules.

This addition enhances the styling capabilities for GNOME applications and improves documentation links for better navigation.
- Bump esbuild version to ^0.25.10 in cli package.
- Upgrade jsdom to ^27.0.0 in cli package.
- Update @types/node to ^24.5.2 in multiple packages.
- Upgrade mime to ^4.1.0 in several packages.
- Update vite to ^7.1.7 in multiple packages.
- Upgrade various @Girs dependencies to their latest beta versions in data-gjs, maker-gjs, story-gjs, and ui-gjs packages.
- Update @gjsify/vite-plugin-blueprint version in maker-gjs and story-gjs packages.
- Bump serve version to ^14.2.5 in zelda-like package.
- Update rollup plugin utils to ^5.3.0 in engine-excalibur package.
- Update other dependencies to ensure compatibility and leverage new features.
@JumpLink JumpLink merged commit 2e45043 into main Sep 29, 2025
1 check passed
@JumpLink JumpLink deleted the feat/map-edit branch September 29, 2025 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant