Background Video for Credits Screen (#732)
* Add Credits Background Video * Add Credits Background Video * Add Credits Background Video * Add Credits Background Video * Add Background video
This commit is contained in:
1 parent
8dde27426c
commit
928a261f26
3 files changed
+95
-32
No files matched your search
Binary file not shown.
@@ -109,6 +109,7 @@ namespace Vocaluxe.Base
|
|||||||
public const string FileNameLogo = "Logo.png";
|
public const string FileNameLogo = "Logo.png";
|
||||||
public const string FileNameFonts = "Fonts.xml";
|
public const string FileNameFonts = "Fonts.xml";
|
||||||
public const string FileNameCreditsLogo = "CreditsLogo.png";
|
public const string FileNameCreditsLogo = "CreditsLogo.png";
|
||||||
|
public const string FileNameCreditsVideo = "Credits_BGVideo.mp4";
|
||||||
|
|
||||||
public const string FileNameOldHighscoreDB = "Ultrastar.db";
|
public const string FileNameOldHighscoreDB = "Ultrastar.db";
|
||||||
public const string FileNameCoverDB = "CoverDB.sqlite";
|
public const string FileNameCoverDB = "CoverDB.sqlite";
|
||||||
|
|||||||
@@ -44,10 +44,13 @@ namespace Vocaluxe.Screens
|
|||||||
|
|
||||||
private List<dynamic> _ScrollingElements;
|
private List<dynamic> _ScrollingElements;
|
||||||
private Dictionary<dynamic, float> _ElementStartYPositions;
|
private Dictionary<dynamic, float> _ElementStartYPositions;
|
||||||
private float _previousElapsedMilliseconds;
|
private float _previousVideoElapsedMilliseconds;
|
||||||
|
private float _previousAnimationElapsedMilliseconds;
|
||||||
|
|
||||||
private CTextureRef _TexLogo;
|
private CTextureRef _TexLogo;
|
||||||
|
|
||||||
|
private CVideoStream _BackgroundVideo;
|
||||||
|
private float _BackgroundVideoTime;
|
||||||
|
|
||||||
public override EMusicType CurrentMusicType
|
public override EMusicType CurrentMusicType
|
||||||
{
|
{
|
||||||
@@ -71,8 +74,8 @@ namespace Vocaluxe.Screens
|
|||||||
|
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
_TexLogo = CDraw.AddTexture(path);
|
_TexLogo = CDraw.AddTexture(path);
|
||||||
ressourceOK &= _TexLogo != null;
|
ressourceOK &= _TexLogo != null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -80,33 +83,26 @@ namespace Vocaluxe.Screens
|
|||||||
}
|
}
|
||||||
if (!ressourceOK)
|
if (!ressourceOK)
|
||||||
{
|
{
|
||||||
CLog.Fatal("Could not load all resources!");
|
CLog.Fatal("Could not load all resources!");
|
||||||
|
// Prevent further execution
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize background theme
|
|
||||||
SThemeBackground _BGTheme = new SThemeBackground
|
|
||||||
{
|
|
||||||
Type = EBackgroundTypes.Color,
|
|
||||||
Color = new SThemeColor { Name = "Black", R = 0f, G = 0f, B = 0f, A = 1f }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create and add background
|
|
||||||
CBackground bg = new CBackground(_BGTheme, -1);
|
|
||||||
bg.LoadSkin();
|
|
||||||
_AddBackground(bg);
|
|
||||||
|
|
||||||
// Position Y for the first scrolling element
|
// Position Y for the first scrolling element
|
||||||
float scrollY = CSettings.RenderH - 1f;
|
float scrollY = CSettings.RenderH - 1f;
|
||||||
|
|
||||||
// Create logo
|
// Create logo
|
||||||
_Logo = GetNewStatic(_TexLogo, new SColorF(1, 1, 1, 1),
|
if (_TexLogo != null)
|
||||||
new SRectF((float)(CSettings.RenderW - _TexLogo.OrigSize.Width) / 2, scrollY, _TexLogo.OrigSize.Width, _TexLogo.OrigSize.Height, -2));
|
{
|
||||||
_Logo.Visible = false;
|
_Logo = GetNewStatic(_TexLogo, new SColorF(1, 1, 1, 1),
|
||||||
_AddStatic(_Logo);
|
new SRectF((float)(CSettings.RenderW - _TexLogo.OrigSize.Width) / 2, scrollY, _TexLogo.OrigSize.Width, _TexLogo.OrigSize.Height, -2));
|
||||||
_ScrollingElements.Add(_Logo);
|
_Logo.Visible = false;
|
||||||
_ElementStartYPositions[_Logo] = scrollY;
|
_AddStatic(_Logo);
|
||||||
|
_ScrollingElements.Add(_Logo);
|
||||||
|
_ElementStartYPositions[_Logo] = scrollY;
|
||||||
|
|
||||||
scrollY += _Logo.Rect.H + 20f; // Update scrollY after logo
|
scrollY += _Logo.Rect.H + 20f; // Update scrollY after logo
|
||||||
|
}
|
||||||
|
|
||||||
// Helper variables for font sizes
|
// Helper variables for font sizes
|
||||||
int bigHeadlineSize = 45;
|
int bigHeadlineSize = 45;
|
||||||
@@ -221,7 +217,7 @@ namespace Vocaluxe.Screens
|
|||||||
case Keys.Escape:
|
case Keys.Escape:
|
||||||
case Keys.Back:
|
case Keys.Back:
|
||||||
case Keys.Enter:
|
case Keys.Enter:
|
||||||
CGraphics.FadeTo(EScreen.Main);
|
_LeaveScreen();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,15 +228,35 @@ namespace Vocaluxe.Screens
|
|||||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||||
{
|
{
|
||||||
if (mouseEvent.LB || mouseEvent.RB)
|
if (mouseEvent.LB || mouseEvent.RB)
|
||||||
CGraphics.FadeTo(EScreen.Main);
|
_LeaveScreen();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool UpdateGame()
|
public override bool UpdateGame()
|
||||||
{
|
{
|
||||||
if (!_Animation() && CGraphics.NextScreen != CGraphics.GetScreen(EScreen.Main))
|
if (_BackgroundVideo != null)
|
||||||
CGraphics.FadeTo(EScreen.Main);
|
{
|
||||||
return true;
|
float deltaTime = (_ScrollTimer.ElapsedMilliseconds - _previousVideoElapsedMilliseconds) / 1000f;
|
||||||
|
_previousVideoElapsedMilliseconds = _ScrollTimer.ElapsedMilliseconds;
|
||||||
|
|
||||||
|
_BackgroundVideoTime += deltaTime;
|
||||||
|
|
||||||
|
float videoLength = CVideo.GetLength(_BackgroundVideo);
|
||||||
|
|
||||||
|
// Keep time within video length to avoid seeking backward
|
||||||
|
if (_BackgroundVideoTime >= videoLength)
|
||||||
|
{
|
||||||
|
_BackgroundVideoTime -= videoLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
CVideo.GetFrame(_BackgroundVideo, _BackgroundVideoTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_Animation() && CGraphics.NextScreen != CGraphics.GetScreen(EScreen.Main))
|
||||||
|
_LeaveScreen();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnShow()
|
public override void OnShow()
|
||||||
@@ -263,7 +279,24 @@ namespace Vocaluxe.Screens
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set all elements to visible immediately
|
_previousVideoElapsedMilliseconds = 0f;
|
||||||
|
|
||||||
|
string path = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameGraphics, CSettings.FileNameCreditsVideo);
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
// Load the video if not already loaded
|
||||||
|
if (_BackgroundVideo == null)
|
||||||
|
{
|
||||||
|
_BackgroundVideo = CVideo.Load(path);
|
||||||
|
CVideo.SetLoop(_BackgroundVideo, true); // Set the video to loop
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CLog.Error("Background video not found: " + path);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (dynamic element in _ScrollingElements)
|
foreach (dynamic element in _ScrollingElements)
|
||||||
{
|
{
|
||||||
element.Visible = true;
|
element.Visible = true;
|
||||||
@@ -272,17 +305,46 @@ namespace Vocaluxe.Screens
|
|||||||
// Start the scroll timer immediately
|
// Start the scroll timer immediately
|
||||||
_ScrollTimer.Reset();
|
_ScrollTimer.Reset();
|
||||||
_ScrollTimer.Start();
|
_ScrollTimer.Start();
|
||||||
_previousElapsedMilliseconds = 0;
|
_previousAnimationElapsedMilliseconds = 0;
|
||||||
|
_BackgroundVideoTime = 0f;
|
||||||
|
|
||||||
|
foreach (dynamic element in _ScrollingElements)
|
||||||
|
{
|
||||||
|
element.Visible = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Draw()
|
||||||
|
{
|
||||||
|
if (_Active && _BackgroundVideo != null && _BackgroundVideo.Texture != null)
|
||||||
|
{
|
||||||
|
CTextureRef background = _BackgroundVideo.Texture;
|
||||||
|
SRectF bounds = CSettings.RenderRect;
|
||||||
|
SRectF rect = CHelper.FitInBounds(bounds, background.OrigAspect, EAspect.Crop);
|
||||||
|
CDraw.DrawTexture(background, rect, background.Color, bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
base.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _LeaveScreen()
|
||||||
|
{
|
||||||
|
CGraphics.FadeTo(EScreen.Options);
|
||||||
|
|
||||||
|
if (_BackgroundVideo != null)
|
||||||
|
{
|
||||||
|
CVideo.Close(ref _BackgroundVideo);
|
||||||
|
_BackgroundVideo = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool _Animation()
|
private bool _Animation()
|
||||||
{
|
{
|
||||||
if (!_ScrollTimer.IsRunning)
|
if (!_ScrollTimer.IsRunning)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
float deltaTime = (_ScrollTimer.ElapsedMilliseconds - _previousElapsedMilliseconds) / 1000f; // Convert milliseconds to seconds
|
float deltaTime = (_ScrollTimer.ElapsedMilliseconds - _previousAnimationElapsedMilliseconds) / 1000f; // Convert milliseconds to seconds
|
||||||
_previousElapsedMilliseconds = _ScrollTimer.ElapsedMilliseconds;
|
_previousAnimationElapsedMilliseconds = _ScrollTimer.ElapsedMilliseconds;
|
||||||
|
|
||||||
float scrollSpeed = 60f;
|
float scrollSpeed = 60f;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user