Skip to content

Main Menu Video Background#838

Open
Mentalleger wants to merge 14 commits into
CnCNet:developfrom
Mentalleger:Main-Menu-Video-Background-via-VLC
Open

Main Menu Video Background#838
Mentalleger wants to merge 14 commits into
CnCNet:developfrom
Mentalleger:Main-Menu-Video-Background-via-VLC

Conversation

@Mentalleger
Copy link
Copy Markdown

Added a new video background to the main menu, developed mostly for RA2 YR

Added a new video background to the main menu, developed mostly for RA2 YR
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Oct 2, 2025

Nightly build for this pull request:

  • artifacts.zip
    This comment is automatic and is meant to allow guests to get latest automatic builds without registering. It is updated on every successful build.

Comment thread DXMainClient/DXGUI/Generic/MainMenu.cs Outdated
using DTAClient.DXGUI.Multiplayer.CnCNet;
using DTAClient.DXGUI.Multiplayer.GameLobby;
using DTAClient.Online;
//using DTAConfig;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line, DTAConfig project has been removed from client's code base.

Comment on lines +6 to +8
namespace DXMainClient.Domain
{
public class VideoBackground : IDisposable
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a generic UI class. Move it to the ClientGUI please.

removed a commented code (" using DTAConfig; ")

moved VideoBackground.cs from Domain into DXGUI\Generic
@SadPencil
Copy link
Copy Markdown
Member

Remaining works:

  1. We have macOS/Linux users. If the codes do not contains such a support, please make sure the client shows the static image as if this PR were not merged. Make sure the client does not crash when the video player fails (I don't know).
  2. We have a common way to read "RA2MD.ini", which is defined in UserINISettings class

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds video background support to the main menu, primarily developed for Red Alert 2: Yuri's Revenge. The implementation uses LibVLC to play MP4 video files as an animated background, falling back to the static PNG background if the video file is not found.

Key changes:

  • Integrated LibVLCSharp and VideoLAN.LibVLC.Windows packages for video playback
  • Created a new VideoBackground class to handle video decoding and texture updates
  • Modified MainMenu to optionally load and display video backgrounds

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
Directory.Packages.props Added LibVLCSharp (3.9.4) and VideoLAN.LibVLC.Windows (3.0.21) package references
DXMainClient/DXMainClient.csproj Added VideoLAN.LibVLC.Windows package reference to the main client project
ClientGUI/ClientGUI.csproj Added LibVLCSharp package reference to the GUI library
ClientGUI/VideoBackground.cs New class implementing video playback using LibVLC with XNA/MonoGame texture integration
DXMainClient/DXGUI/Generic/MainMenu.cs Integrated video background loading with fallback to static image, added LibVLC cleanup on exit

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ClientGUI/VideoBackground.cs Outdated
_texture = new Texture2D(graphicsDevice, (int)_videoWidth, (int)_videoHeight, false, SurfaceFormat.Color);

_mediaPlayer.SetVideoCallbacks(Lock, Unlock, Display);
_mediaPlayer.SetVideoFormat("RGBA", (uint)_videoWidth, (uint)_videoHeight, (uint)_videoWidth * 4); // do not use RV32, use RGBA instead, else the color will be messed up as if it were blue
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment contains grammatical errors and unclear explanation. Consider rephrasing to: "// Use RGBA format instead of RV32 to ensure correct color channel mapping"

Suggested change
_mediaPlayer.SetVideoFormat("RGBA", (uint)_videoWidth, (uint)_videoHeight, (uint)_videoWidth * 4); // do not use RV32, use RGBA instead, else the color will be messed up as if it were blue
_mediaPlayer.SetVideoFormat("RGBA", (uint)_videoWidth, (uint)_videoHeight, (uint)_videoWidth * 4); // Use RGBA format instead of RV32 to ensure correct color channel mapping

Copilot uses AI. Check for mistakes.
_media = new Media(_libVLC, videoPath, FromType.FromPath);

// add more option if you want to edit the video via VLC
_media.AddOption(":scale=0.5"); // compress the video (a little help with the lower end devices.||_ ps. its a 50/50 in the lower end device)
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment contains grammatical errors and is unclear. The phrase "a little help with the lower end devices.||_ ps. its a 50/50 in the lower end device" should be rephrased more professionally, e.g., "// Reduce video quality to improve performance on lower-end devices (may have variable results)"

Suggested change
_media.AddOption(":scale=0.5"); // compress the video (a little help with the lower end devices.||_ ps. its a 50/50 in the lower end device)
_media.AddOption(":scale=0.5"); // Reduce video quality to improve performance on lower-end devices (may have variable results)

Copilot uses AI. Check for mistakes.
_media = new Media(_libVLC, videoPath, FromType.FromPath);

// add more option if you want to edit the video via VLC
_media.AddOption(":scale=0.5"); // compress the video (a little help with the lower end devices.||_ ps. its a 50/50 in the lower end device)
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The :scale=0.5 option compresses/scales the video to 50%, but the texture buffer is allocated at full size (_videoWidth * _videoHeight * 4). This mismatch could cause rendering issues or leave parts of the texture uninitialized. Either remove the scale option or adjust the buffer and texture size accordingly.

Copilot uses AI. Check for mistakes.
Comment thread ClientGUI/VideoBackground.cs Outdated
Comment thread DXMainClient/DXGUI/Generic/MainMenu.cs Outdated
Comment thread ClientGUI/VideoBackground.cs Outdated
Comment on lines +67 to +72
private void Display(IntPtr opaque, IntPtr picture)
{
lock (_lock)
{
_texture.SetData(_videoBuffer);
}
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Display callback writes to _texture from the VLC thread, but Texture2D.SetData in XNA/MonoGame is not thread-safe and should only be called from the main/game thread. This can cause crashes or rendering corruption.

Consider using a flag to indicate new data is ready and perform the SetData call from the main thread's update or draw method instead.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thought. I'll leave this conversation open.

Comment thread ClientGUI/VideoBackground.cs Outdated
// add more option if you want to edit the video via VLC
_media.AddOption(":scale=0.5"); // compress the video (a little help with the lower end devices.||_ ps. its a 50/50 in the lower end device)
_media.AddOption(":no-audio"); // disables the audio
_media.AddOption(":input-repeat=65535"); // this means looping the video 65.535 times, its stupid but it works
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment "its stupid but it works" is unprofessional and doesn't add value. Consider rephrasing to explain why this approach was chosen, e.g., ":input-repeat=65535 // Loop video continuously (maximum repeat count)"

Suggested change
_media.AddOption(":input-repeat=65535"); // this means looping the video 65.535 times, its stupid but it works
_media.AddOption(":input-repeat=65535"); // Loop video continuously (maximum repeat count supported by VLC)

Copilot uses AI. Check for mistakes.
public VideoBackground(GraphicsDevice graphicsDevice, string videoPath, int width, int height)
{
if (_libVLC == null)
_libVLC = new LibVLC("--no-xlib", "--drop-late-frames", "--skip-frames");
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write to static field from instance method, property, or constructor.

Copilot uses AI. Check for mistakes.
Comment thread DXMainClient/DXGUI/Generic/MainMenu.cs
Comment thread ClientGUI/VideoBackground.cs
@SadPencil SadPencil added this to the long term milestone May 5, 2026
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.

5 participants