From 2018f3a16b7ba5b89354dada4731d9655ef82c60 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Fri, 3 May 2013 19:04:35 +0200 Subject: [PATCH] Fixed EAspect.Letterbox Removed "Vd" prefixes on IVideo functions --- Vocaluxe/Base/CBackgroundMusic.cs | 34 +++++++------- Vocaluxe/Base/CDraw.cs | 4 +- Vocaluxe/Base/CMain.cs | 10 ++-- Vocaluxe/Base/CTheme.cs | 26 +++++------ Vocaluxe/Base/CVideo.cs | 41 ++++++++--------- Vocaluxe/Program.cs | 2 +- Vocaluxe/Screens/CScreenSing.cs | 46 ++++++++----------- VocaluxeLib/Menu/CBackground.cs | 12 ++--- VocaluxeLib/Menu/CHelper.cs | 39 ++++++++-------- .../Menu/SongMenu/CSongMenuTileBoard.cs | 4 +- 10 files changed, 101 insertions(+), 117 deletions(-) diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index 53a169db..40b3c014 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -155,7 +155,7 @@ namespace Vocaluxe.Base CSound.Fade(_CurrentMusicStream, 100f, CSettings.BackgroundMusicFadeTime); CSound.Play(_CurrentMusicStream); if (_VideoEnabled && _Video != -1) - CVideo.VdResume(_Video); + CVideo.Resume(_Video); IsPlaying = true; } else @@ -173,7 +173,7 @@ namespace Vocaluxe.Base if (_VideoEnabled && _Video != -1) { - CVideo.VdClose(_Video); + CVideo.Close(_Video); CDraw.RemoveTexture(ref _CurrentVideoTexture); _Video = -1; } @@ -191,8 +191,8 @@ namespace Vocaluxe.Base if (_VideoEnabled && _Video != -1) { - CVideo.VdPause(_Video); - CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap); + CVideo.Pause(_Video); + CVideo.Skip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap); } CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime); IsPlaying = false; @@ -221,9 +221,9 @@ namespace Vocaluxe.Base if (_VideoEnabled && _Video != -1) { if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) - CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); + CVideo.Skip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); else - CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); + CVideo.Skip(_Video, 0f, _CurrentPlaylistElement.VideoGap); } } else @@ -287,9 +287,9 @@ namespace Vocaluxe.Base if (_VideoEnabled && _Video != -1) { if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) - CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); + CVideo.Skip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); else - CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); + CVideo.Skip(_Video, 0f, _CurrentPlaylistElement.VideoGap); } } else @@ -319,9 +319,9 @@ namespace Vocaluxe.Base if (_VideoEnabled && _Video != -1) { if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) - CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); + CVideo.Skip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); else - CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); + CVideo.Skip(_Video, 0f, _CurrentPlaylistElement.VideoGap); } } } @@ -441,14 +441,14 @@ namespace Vocaluxe.Base if (_VideoEnabled) { _VideoEnabled = false; - CVideo.VdClose(_Video); + CVideo.Close(_Video); _Video = -1; CDraw.RemoveTexture(ref _CurrentVideoTexture); return; } - if (CVideo.VdFinished(_Video)) + if (CVideo.Finished(_Video)) { - CVideo.VdClose(_Video); + CVideo.Close(_Video); CDraw.RemoveTexture(ref _CurrentVideoTexture); _Video = -1; } @@ -462,7 +462,7 @@ namespace Vocaluxe.Base if (_Video != -1) { float vtime; - CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), out vtime); + CVideo.GetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), out vtime); if (_FadeTimer.ElapsedMilliseconds <= 3000L) _CurrentVideoTexture.Color.A = _FadeTimer.ElapsedMilliseconds / 3000f; else @@ -484,11 +484,11 @@ namespace Vocaluxe.Base { if (_Video == -1) { - _Video = CVideo.VdLoad(_CurrentPlaylistElement.VideoFilePath); + _Video = CVideo.Load(_CurrentPlaylistElement.VideoFilePath); if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) - CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); + CVideo.Skip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); else - CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); + CVideo.Skip(_Video, 0f, _CurrentPlaylistElement.VideoGap); _VideoEnabled = true; _FadeTimer.Reset(); _FadeTimer.Start(); diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs index 82c0bdd2..e7f48201 100644 --- a/Vocaluxe/Base/CDraw.cs +++ b/Vocaluxe/Base/CDraw.cs @@ -200,9 +200,9 @@ namespace Vocaluxe.Base return; RectangleF bounds = new RectangleF(staticBounds.Rect.X, staticBounds.Rect.Y, staticBounds.Rect.W, staticBounds.Rect.H); - RectangleF rect = new RectangleF(0f, 0f, texture.Width, texture.Height); + RectangleF rect; - CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, aspect); + CHelper.SetRect(bounds, out rect, texture.Width / texture.Height, aspect); DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, staticBounds.Rect.Z), texture.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f)); } diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index aaaf62dc..1a4cc94a 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -672,27 +672,27 @@ namespace Vocaluxe.Base { public int Load(string videoFileName) { - return CVideo.VdLoad(videoFileName); + return CVideo.Load(videoFileName); } public bool Skip(int videoStream, float startPosition, float videoGap) { - return CVideo.VdSkip(videoStream, startPosition, videoGap); + return CVideo.Skip(videoStream, startPosition, videoGap); } public bool GetFrame(int videoStream, ref STexture videoTexture, float time, out float videoTime) { - return CVideo.VdGetFrame(videoStream, ref videoTexture, time, out videoTime); + return CVideo.GetFrame(videoStream, ref videoTexture, time, out videoTime); } public bool IsFinished(int videoStream) { - return CVideo.VdFinished(videoStream); + return CVideo.Finished(videoStream); } public bool Close(int videoStream) { - return CVideo.VdClose(videoStream); + return CVideo.Close(videoStream); } } diff --git a/Vocaluxe/Base/CTheme.cs b/Vocaluxe/Base/CTheme.cs index fa7a3c2b..d26b8813 100644 --- a/Vocaluxe/Base/CTheme.cs +++ b/Vocaluxe/Base/CTheme.cs @@ -199,9 +199,9 @@ namespace Vocaluxe.Base { xmlReader.GetValue("//root/Videos/" + _Skins[skinIndex].VideoList[i].Name, out value, String.Empty); SSkinElement sk = new SSkinElement {Name = _Skins[skinIndex].VideoList[i].Name, Value = value}; - sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[skinIndex].Path, sk.Value)); - CVideo.VdSetLoop(sk.VideoIndex, true); - CVideo.VdPause(sk.VideoIndex); + sk.VideoIndex = CVideo.Load(Path.Combine(_Skins[skinIndex].Path, sk.Value)); + CVideo.SetLoop(sk.VideoIndex, true); + CVideo.Pause(sk.VideoIndex); sk.Texture = new STexture(-1); _Skins[skinIndex].VideoList[i] = sk; } @@ -230,7 +230,7 @@ namespace Vocaluxe.Base for (int j = 0; j < _Skins[i].VideoList.Count; j++) { - CVideo.VdClose(_Skins[i].VideoList[j].VideoIndex); + CVideo.Close(_Skins[i].VideoList[j].VideoIndex); STexture videoTexture = _Skins[i].VideoList[j].Texture; CDraw.RemoveTexture(ref videoTexture); } @@ -617,10 +617,10 @@ namespace Vocaluxe.Base float time = 0f; if (sk.VideoIndex == -1) { - sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, partyModeID)); - CVideo.VdSetLoop(sk.VideoIndex, true); + sk.VideoIndex = CVideo.Load(GetVideoFilePath(sk.Name, partyModeID)); + CVideo.SetLoop(sk.VideoIndex, true); } - CVideo.VdGetFrame(sk.VideoIndex, ref sk.Texture, time, out time); + CVideo.GetFrame(sk.VideoIndex, ref sk.Texture, time, out time); _Skins[skinIndex].VideoList[i] = sk; return sk.Texture; } @@ -641,10 +641,10 @@ namespace Vocaluxe.Base { if (sk.VideoIndex == -1) { - sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, partyModeID)); - CVideo.VdSetLoop(sk.VideoIndex, true); + sk.VideoIndex = CVideo.Load(GetVideoFilePath(sk.Name, partyModeID)); + CVideo.SetLoop(sk.VideoIndex, true); } - CVideo.VdPause(sk.VideoIndex); + CVideo.Pause(sk.VideoIndex); _Skins[skinIndex].VideoList[i] = sk; return; } @@ -664,10 +664,10 @@ namespace Vocaluxe.Base { if (sk.VideoIndex == -1) { - sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, partyModeID)); - CVideo.VdSetLoop(sk.VideoIndex, true); + sk.VideoIndex = CVideo.Load(GetVideoFilePath(sk.Name, partyModeID)); + CVideo.SetLoop(sk.VideoIndex, true); } - CVideo.VdResume(sk.VideoIndex); + CVideo.Resume(sk.VideoIndex); _Skins[skinIndex].VideoList[i] = sk; return; } diff --git a/Vocaluxe/Base/CVideo.cs b/Vocaluxe/Base/CVideo.cs index db7390fb..b78ef2c9 100644 --- a/Vocaluxe/Base/CVideo.cs +++ b/Vocaluxe/Base/CVideo.cs @@ -50,12 +50,7 @@ namespace Vocaluxe.Base #endregion Init #region Interface - public static bool VdInit() - { - return _VideoDecoder.Init(); - } - - public static void VdCloseAll() + public static void CloseAll() { _VideoDecoder.CloseAll(); } @@ -65,47 +60,47 @@ namespace Vocaluxe.Base return _VideoDecoder.GetNumStreams(); } - public static int VdLoad(string videoFileName) + public static int Load(string videoFileName) { return _VideoDecoder.Load(videoFileName); } - public static bool VdClose(int streamID) + public static bool Close(int streamID) { return _VideoDecoder.Close(streamID); } - public static float VdGetLength(int streamID) + public static float GetLength(int streamID) { return _VideoDecoder.GetLength(streamID); } - public static bool VdGetFrame(int streamID, ref STexture frame, float time, out float videoTime) + public static bool GetFrame(int streamID, ref STexture frame, float time, out float videoTime) { return _VideoDecoder.GetFrame(streamID, ref frame, time, out videoTime); } - public static bool VdSkip(int streamID, float start, float gap) + public static bool Skip(int streamID, float start, float gap) { return _VideoDecoder.Skip(streamID, start, gap); } - public static void VdSetLoop(int streamID, bool loop) + public static void SetLoop(int streamID, bool loop) { _VideoDecoder.SetLoop(streamID, loop); } - public static void VdPause(int streamID) + public static void Pause(int streamID) { _VideoDecoder.Pause(streamID); } - public static void VdResume(int streamID) + public static void Resume(int streamID) { _VideoDecoder.Resume(streamID); } - public static bool VdFinished(int streamID) + public static bool Finished(int streamID) { return _VideoDecoder.Finished(streamID); } @@ -134,7 +129,7 @@ namespace Vocaluxe.Base public bool Loop { - set { CVideo.VdSetLoop(_VideoStream, value); } + set { CVideo.SetLoop(_VideoStream, value); } } public CVideoPlayer() @@ -147,7 +142,7 @@ namespace Vocaluxe.Base public void Load(string videoName) { - _VideoStream = CVideo.VdLoad(CTheme.GetVideoFilePath(videoName, -1)); + _VideoStream = CVideo.Load(CTheme.GetVideoFilePath(videoName, -1)); _Loaded = true; } @@ -174,10 +169,10 @@ namespace Vocaluxe.Base if (!_Finished) { float videoTime = _VideoTimer.ElapsedMilliseconds / 1000f; - _Finished = CVideo.VdFinished(_VideoStream); + _Finished = CVideo.Finished(_VideoStream); STexture tex = new STexture(-1) {Height = 0f}; - CVideo.VdGetFrame(_VideoStream, ref tex, videoTime, out videoTime); + CVideo.GetFrame(_VideoStream, ref tex, videoTime, out videoTime); if (tex.Height > 0) { @@ -186,8 +181,8 @@ namespace Vocaluxe.Base } } RectangleF bounds = new RectangleF(0f, 0f, CSettings.RenderW, CSettings.RenderH); - RectangleF rect = new RectangleF(0f, 0f, _VideoTexture.Width, _VideoTexture.Height); - CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, EAspect.Crop); + RectangleF rect; + CHelper.SetRect(bounds, out rect, _VideoTexture.Width / _VideoTexture.Height, EAspect.Crop); CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.ZFar / 4)); } @@ -198,14 +193,14 @@ namespace Vocaluxe.Base while (_VideoTexture.Index == -1 && videoTime < 1f) { float dummy; - CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, out dummy); + CVideo.GetFrame(_VideoStream, ref _VideoTexture, 0, out dummy); videoTime += 0.05f; } } public void Close() { - CVideo.VdClose(_VideoStream); + CVideo.Close(_VideoStream); CDraw.RemoveTexture(ref _VideoTexture); _Loaded = false; _Finished = false; diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index f45e8866..955dc023 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -223,7 +223,7 @@ namespace Vocaluxe CController.Close(); CSound.RecordCloseAll(); CSound.CloseAllStreams(); - CVideo.VdCloseAll(); + CVideo.CloseAll(); CDraw.Unload(); CDataBase.CloseConnections(); CWebcam.Close(); diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index f85934f9..04f7e174 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -395,7 +395,7 @@ namespace Vocaluxe.Screens if (_CurrentVideo != -1 && !_FadeOut && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON) { float vtime; - CVideo.VdGetFrame(_CurrentVideo, ref _CurrentVideoTexture, _CurrentTime, out vtime); + CVideo.GetFrame(_CurrentVideo, ref _CurrentVideoTexture, _CurrentTime, out vtime); } if (_Webcam) @@ -453,34 +453,26 @@ namespace Vocaluxe.Screens { if (_Active) { + STexture background; + EAspect aspect = EAspect.Crop; if (_CurrentVideo != -1 && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam) { - RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH); - RectangleF rect = new RectangleF(0f, 0f, _CurrentVideoTexture.Width, _CurrentVideoTexture.Height); - CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, _VideoAspect); - - CDraw.DrawTexture(_CurrentVideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f), - _CurrentVideoTexture.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false); + background = _CurrentVideoTexture; + aspect = _VideoAspect; } else if (_Webcam) { - RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH); - RectangleF rect = new RectangleF(0f, 0f, _CurrentWebcamFrameTexture.Width, _CurrentWebcamFrameTexture.Height); - CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, _VideoAspect); - - CDraw.DrawTexture(_CurrentWebcamFrameTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f), - _CurrentVideoTexture.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false); + background = _CurrentWebcamFrameTexture; + aspect = _VideoAspect; } else - { - // Draw Background - RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH); - RectangleF rect = new RectangleF(0f, 0f, _Background.Width, _Background.Height); - CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, EAspect.Crop); + background = _Background; + RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH); + RectangleF rect; + CHelper.SetRect(bounds, out rect, background.Width / background.Height, aspect); - CDraw.DrawTexture(_Background, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f), - _Background.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false); - } + CDraw.DrawTexture(_Background, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f), + _Background.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f)); } _DrawBG(); @@ -556,7 +548,7 @@ namespace Vocaluxe.Screens CSound.RecordStop(); if (_CurrentVideo != -1) { - CVideo.VdClose(_CurrentVideo); + CVideo.Close(_CurrentVideo); _CurrentVideo = -1; CDraw.RemoveTexture(ref _CurrentVideoTexture); } @@ -621,8 +613,8 @@ namespace Vocaluxe.Screens if (song.VideoFileName != "") { - _CurrentVideo = CVideo.VdLoad(Path.Combine(song.Folder, song.VideoFileName)); - CVideo.VdSkip(_CurrentVideo, song.Start, song.VideoGap); + _CurrentVideo = CVideo.Load(Path.Combine(song.Folder, song.VideoFileName)); + CVideo.Skip(_CurrentVideo, song.Start, song.VideoGap); _VideoAspect = song.VideoAspect; } @@ -691,9 +683,9 @@ namespace Vocaluxe.Screens } else { - bool lyricsOnTop = CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_TOP - || CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH - || (CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && (CGame.NumPlayer > 2 && CGame.NumPlayer != 4)); + bool lyricsOnTop = CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_TOP + || CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH + || (CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && (CGame.NumPlayer > 2 && CGame.NumPlayer != 4)); _Lyrics[_LyricMainTop].Visible = lyricsOnTop; _Lyrics[_LyricSubTop].Visible = lyricsOnTop; _Statics[_StaticLyricsTop].Visible = lyricsOnTop; diff --git a/VocaluxeLib/Menu/CBackground.cs b/VocaluxeLib/Menu/CBackground.cs index 11cf7124..3dafcbb5 100644 --- a/VocaluxeLib/Menu/CBackground.cs +++ b/VocaluxeLib/Menu/CBackground.cs @@ -206,8 +206,8 @@ namespace VocaluxeLib.Menu if (texture.Height > 0) { RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); - RectangleF rect = new RectangleF(0f, 0f, texture.Width, texture.Height); - CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, EAspect.Crop); + RectangleF rect; + CHelper.SetRect(bounds, out rect, texture.Width / texture.Height, EAspect.Crop); CBase.Drawing.DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CBase.Settings.GetZFar() / 4)); return true; @@ -221,8 +221,8 @@ namespace VocaluxeLib.Menu if (videoTexture.Height > 0) { RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); - RectangleF rect = new RectangleF(0f, 0f, videoTexture.Width, videoTexture.Height); - CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, EAspect.Crop); + RectangleF rect; + CHelper.SetRect(bounds, out rect, videoTexture.Width / videoTexture.Height, EAspect.Crop); CBase.Drawing.DrawTexture(videoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CBase.Settings.GetZFar() / 4)); return true; @@ -236,8 +236,8 @@ namespace VocaluxeLib.Menu if (videoTexture.Height > 0) { RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); - RectangleF rect = new RectangleF(0f, 0f, videoTexture.Width, videoTexture.Height); - CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, EAspect.Crop); + RectangleF rect; + CHelper.SetRect(bounds, out rect, videoTexture.Width / videoTexture.Height, EAspect.Crop); CBase.Drawing.DrawTexture(videoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CBase.Settings.GetZFar() / 4)); return true; diff --git a/VocaluxeLib/Menu/CHelper.cs b/VocaluxeLib/Menu/CHelper.cs index bdf1a007..fba78729 100644 --- a/VocaluxeLib/Menu/CHelper.cs +++ b/VocaluxeLib/Menu/CHelper.cs @@ -91,9 +91,9 @@ namespace VocaluxeLib.Menu public static void SetRect(RectangleF bounds, out RectangleF rect, float rectAspect, EAspect aspect) { - float rW = bounds.Right - bounds.Left; - float rH = bounds.Bottom - bounds.Top; - float rA = rW / rH; + float boundsW = bounds.Width; + float boundsH = bounds.Height; + float boundsAspect = boundsW / boundsH; float scaledWidth; float scaledHeight; @@ -101,42 +101,39 @@ namespace VocaluxeLib.Menu switch (aspect) { case EAspect.Crop: - if (rA >= rectAspect) + if (boundsAspect >= rectAspect) { - scaledWidth = rW; - scaledHeight = rH * rA / rectAspect; + scaledWidth = boundsW; + scaledHeight = boundsW / rectAspect; } else { - scaledHeight = rH; - scaledWidth = rW * rectAspect / rA; + scaledHeight = boundsH; + scaledWidth = boundsH * rectAspect; } break; case EAspect.LetterBox: - if (rectAspect >= 1) + if (boundsAspect <= rectAspect) { - scaledWidth = rW; - scaledHeight = rH * rA / rectAspect; + scaledWidth = boundsW; + scaledHeight = boundsW / rectAspect; } else { - scaledHeight = rH; - scaledWidth = rW * rectAspect / rA; + scaledHeight = boundsH; + scaledWidth = boundsH * rectAspect; } break; default: - scaledWidth = rW; - scaledHeight = rH; + scaledWidth = boundsW; + scaledHeight = boundsH; break; } - float left = (rW - scaledWidth) / 2 + bounds.Left; - float rigth = left + scaledWidth; + float left = (boundsW - scaledWidth) / 2 + bounds.Left; + float upper = (boundsH - scaledHeight) / 2 + bounds.Top; - float upper = (rH - scaledHeight) / 2 + bounds.Top; - float lower = upper + scaledHeight; - - rect = new RectangleF(left, upper, rigth - left, lower - upper); + rect = new RectangleF(left, upper, scaledWidth, scaledHeight); } public static List ListFiles(string path, string cast, bool recursive = false, bool fullpath = false) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index 3c234a73..5d437d1d 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -458,8 +458,8 @@ namespace VocaluxeLib.Menu.SongMenu if (_Vidtex.Color.A < 1) _CoverBig.Draw(1f, EAspect.Crop); RectangleF bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H); - RectangleF rect = new RectangleF(0f, 0f, _Vidtex.Width, _Vidtex.Height); - CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, EAspect.Crop); + RectangleF rect; + CHelper.SetRect(bounds, out rect, _Vidtex.Width / _Vidtex.Height, EAspect.Crop); SRectF vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z); SRectF vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f);