Marquee System
Overview
The Marquee System provides a scrolling notification system that displays important game information at the top of the screen. Messages scroll horizontally from right to left, providing users with real-time updates about game events, join confirmations, and other important notifications.
This document covers the technical implementation, architecture, and API for engineers working with or extending the marquee system.
Technical Architecture
Core Components
MarqueeManager Class (client/src/ui/MarqueeManager.js)
client/src/ui/MarqueeManager.js)The central manager for the marquee system with the following key features:
Configuration Properties:
this.scrollSpeed = 30; // Pixels per second
this.messageSpacing = 100; // Minimum gap between messages (pixels)
this.messageDuration = 12000; // Display duration (milliseconds)
this.maxMessages = 1; // Only one message displays at a timePriority Queue System:
this.queues = {
high: [], // Game-critical messages
medium: [], // Join confirmations
low: [] // General notifications
};Key Methods
Public API:
queueMessage(text, options, priority)- Add a message to the queueclearQueues()- Clear all pending messages
Internal Methods:
addMessage(text, options)- Display a message immediatelytryShowNextMessage()- Check queue and display next message if possiblecanShowNextMessage()- Check spacing conditionsanimateMessage()- Handle scroll animation
Priority System
Messages are processed in priority order:
High Priority (game messages) - Processed first
Medium Priority (join messages) - Processed second
Low Priority (general) - Processed last
Timing System
The system uses periodic checking (every 500ms) rather than event-driven updates:
Scene Integration
The marquee manager is initialized globally in the InstructionsScene and persists across all game scenes:
Cross-Scene Compatibility
The system automatically detects the active scene when displaying messages:
API Reference
Static Methods (Global Access)
MarqueeManager.addMessage(text, options, priority)
MarqueeManager.addMessage(text, options, priority)Add a message to the marquee system.
Parameters:
text(string): The message text to displayoptions(object, optional): Display optionscolor(string): Text color (default: '#FFFFFF')fontSize(string): Font size (default: '16px')fontFamily(string): Font family (default: 'Arial')stroke(string): Text outline color (default: '#000000')strokeThickness(number): Outline thickness (default: 3)
priority(string): Queue priority ('high', 'medium', 'low')
Example:
MarqueeManager.clearQueues()
MarqueeManager.clearQueues()Clear all pending messages from all priority queues.
Utility Functions
showMarqueeMessage(text, options, priority)
showMarqueeMessage(text, options, priority)Convenience function for displaying marquee messages.
Parameters: Same as MarqueeManager.addMessage
Example:
clearMarqueeQueues()
clearMarqueeQueues()Convenience function to clear all queues.
Integration Examples
Adding Join Confirmations
Adding Game Notifications
Adding General Messages
Configuration
Adjusting Scroll Speed:
Adjusting Message Duration:
Adjusting Spacing:
Performance Considerations
Memory Management: Messages are properly destroyed after animation completes
Queue Limits: Maximum of 3 simultaneous messages prevents overflow
Efficient Checking: Periodic polling (500ms) balances responsiveness with performance
Scene Cleanup: Timer is properly destroyed when scenes shut down
Testing
The system includes built-in test messages that can be enabled in development:
Future Enhancements
Troubleshooting
Maintenance
Regular Tasks
Monitor message queue lengths for performance
Update color schemes for accessibility
Test across different screen resolutions
Verify timing works on various devices
Code Organization
client/src/ui/MarqueeManager.js- Core marquee logicclient/src/scenes/InstructionsScene.js- Initializationclient/src/chat/GlobalChatHandler.js- Join confirmationsclient/src/Utils.js- Utility functions
The marquee system provides a robust, performant way to deliver important information to players without disrupting gameplay flow.
