Update game logic out of game

parent 7afccaf1
...@@ -2079,11 +2079,15 @@ class QtVideoPlayer(QObject): ...@@ -2079,11 +2079,15 @@ class QtVideoPlayer(QObject):
self.message_bus.subscribe(self.name, MessageType.START_INTRO, self._handle_start_intro) self.message_bus.subscribe(self.name, MessageType.START_INTRO, self._handle_start_intro)
self.message_bus.subscribe(self.name, MessageType.PLAY_VIDEO_MATCH, self._handle_play_video_match) self.message_bus.subscribe(self.name, MessageType.PLAY_VIDEO_MATCH, self._handle_play_video_match)
self.message_bus.subscribe(self.name, MessageType.PLAY_VIDEO_RESULT, self._handle_play_video_result) self.message_bus.subscribe(self.name, MessageType.PLAY_VIDEO_RESULT, self._handle_play_video_result)
self.message_bus.subscribe(self.name, MessageType.GAME_STATUS, self._handle_game_status)
logger.info("QtPlayer subscriptions completed successfully") logger.info("QtPlayer subscriptions completed successfully")
# Delay loading default overlay to allow JavaScript initialization # Delay loading default overlay to allow JavaScript initialization
QTimer.singleShot(2000, self._load_default_overlay) # Wait 2 seconds QTimer.singleShot(2000, self._load_default_overlay) # Wait 2 seconds
# Request initial game status to check if we should play intro
QTimer.singleShot(3000, self._request_initial_game_status) # Wait 3 seconds for everything to be ready
logger.info("QtVideoPlayer (PyQt6) initialized successfully") logger.info("QtVideoPlayer (PyQt6) initialized successfully")
return True return True
...@@ -3440,3 +3444,102 @@ class QtVideoPlayer(QObject): ...@@ -3440,3 +3444,102 @@ class QtVideoPlayer(QObject):
self.message_bus.publish(status_response) self.message_bus.publish(status_response)
except Exception as e: except Exception as e:
logger.error(f"Failed to execute status request: {e}") logger.error(f"Failed to execute status request: {e}")
def _request_initial_game_status(self):
"""Request initial game status to determine if we should play intro"""
try:
logger.info("Requesting initial game status to check if intro should be played")
status_request = MessageBuilder.system_status(
sender=self.name,
status="status_request",
details={"request_type": "game_status"}
)
self.message_bus.publish(status_request, broadcast=True)
except Exception as e:
logger.error(f"Failed to request initial game status: {e}")
def _handle_game_status(self, message: Message):
"""Handle GAME_STATUS messages to determine when to play intro"""
try:
status = message.data.get("status")
logger.info(f"Received GAME_STATUS: {status}")
# Check if this indicates no active game
if status in ["ready", "shutdown", "completed_no_old_matches"]:
logger.info("No active game detected, checking if we should play intro")
self._check_and_play_intro()
elif status == "started":
logger.info("Game is active, intro will be handled by START_INTRO message")
elif status == "already_active":
logger.info("Game already active, no intro needed")
except Exception as e:
logger.error(f"Failed to handle game status: {e}")
def _check_and_play_intro(self):
"""Check if we should play the intro video when no game is active"""
try:
# Only play intro if we're not already playing something
if self.window and self.window.media_player.playbackState() == QMediaPlayer.PlaybackState.StoppedState:
logger.info("Player is stopped, playing waiting intro")
self._play_waiting_intro()
else:
logger.info("Player is already playing, skipping intro")
except Exception as e:
logger.error(f"Failed to check and play intro: {e}")
def _play_waiting_intro(self):
"""Play the INTRO video on repeat with waiting overlay when no game is active"""
try:
logger.info("Playing waiting intro video")
# Find the INTRO video file
intro_path = self._find_intro_video_file_for_waiting()
if intro_path:
# Set up loop control for infinite repeat
loop_data = {
'infinite_loop': True,
'continuous_playback': True
}
# Create overlay data for waiting state
overlay_data = {
"title": "Waiting for game to start...",
"message": "Waiting for game to start...",
"icon": "⏳"
}
# Play the intro video with loop and overlay
if self.window:
self.window.play_video(
str(intro_path),
template_data=overlay_data,
template_name="default.html", # Use default template
loop_data=loop_data
)
logger.info("Waiting intro video started with overlay")
else:
logger.error("No window available for waiting intro playback")
else:
logger.warning("No INTRO video found for waiting state")
except Exception as e:
logger.error(f"Failed to play waiting intro: {e}")
def _find_intro_video_file_for_waiting(self) -> Optional[Path]:
"""Find the INTRO video file for waiting state"""
try:
# Priority 1: Check for INTRO.mp4 in assets directory
assets_dir = Path(__file__).parent.parent / "assets"
assets_intro = assets_dir / "INTRO.mp4"
if assets_intro.exists():
logger.info(f"Using INTRO.mp4 from assets for waiting: {assets_intro}")
return assets_intro
logger.warning("No INTRO video found for waiting state")
return None
except Exception as e:
logger.error(f"Failed to find intro video for waiting: {e}")
return None
# MbetterClient v1.2.11
Cross-platform multimedia client application
## Installation
1. Extract this package to your desired location
2. Run the executable file
3. The application will create necessary configuration files on first run
## System Requirements
- **Operating System**: Linux 6.16.3+deb14-amd64
- **Architecture**: x86_64
- **Memory**: 512 MB RAM minimum, 1 GB recommended
- **Disk Space**: 100 MB free space
## Configuration
The application stores its configuration and database in:
- **Windows**: `%APPDATA%\MbetterClient`
- **macOS**: `~/Library/Application Support/MbetterClient`
- **Linux**: `~/.config/MbetterClient`
## Web Interface
By default, the web interface is available at: http://localhost:5001
Default login credentials:
- Username: admin
- Password: admin
**Please change the default password after first login.**
## Support
For support and documentation, please visit: https://git.nexlab.net/mbetter/mbetterc
## Version Information
- Version: 1.2.11
- Build Date: zeiss
- Platform: Linux-6.16.3+deb14-amd64-x86_64-with-glibc2.41
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment