diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index 2a5d76c2..daf92609 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -28,7 +28,7 @@ namespace Vocaluxe.Base private static bool _BackgroundMusicAdded; private static bool _Playing; private static bool _VideoEnabled; - private static bool _SmallVideoIsEnabled; + private static bool _Disabled; private static int _Video = -1; private static STexture _CurrentVideoTexture = new STexture(-1); @@ -50,8 +50,8 @@ namespace Vocaluxe.Base if(CConfig.BackgroundMusicSource != EBackgroundMusicSource.TR_CONFIG_ONLY_OWN_MUSIC) AddBackgroundMusic(); - if (VideoToBackgroundIsEnabled()) - ApplyBackgroundVideo(); + if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON) + EnableVideo(); _Playing = false; } @@ -72,8 +72,6 @@ namespace Vocaluxe.Base } else Next(); - if ((_VideoEnabled && _SmallVideoIsEnabled) || (_VideoEnabled && VideoToBackgroundIsEnabled())) - LoadVideo(); } } } @@ -94,7 +92,7 @@ namespace Vocaluxe.Base public static void Pause() { - if (_VideoEnabled && _Video != 0) + if (_VideoEnabled && _Video != -1) CVideo.VdPause(_Video); CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime); _Playing = false; @@ -135,6 +133,8 @@ namespace Vocaluxe.Base _CurrentPlaylistElement = _PreviousFileNames[_PreviousMusicIndex]; } _CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.GetMusicFilePath()); + if (_VideoEnabled) + LoadVideo(); CSound.SetStreamVolume(_CurrentMusicStream, 0f); Play(); } @@ -155,6 +155,8 @@ namespace Vocaluxe.Base _CurrentPlaylistElement = _PreviousFileNames[_PreviousMusicIndex]; _CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.GetMusicFilePath()); + if (_VideoEnabled) + LoadVideo(); CSound.SetStreamVolume(_CurrentMusicStream, 0f); Play(); } @@ -352,22 +354,6 @@ namespace Vocaluxe.Base return _VideoEnabled; } - public static bool VideoToBackgroundIsEnabled() - { - return CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON; - } - - public static bool SmallVideoIsEnabled() - { - return _SmallVideoIsEnabled; - } - - public static void ToggleSmallVideo() - { - _SmallVideoIsEnabled = !_SmallVideoIsEnabled; - ApplyBackgroundVideo(); - } - public static bool HasVideo() { return File.Exists(_CurrentPlaylistElement.GetVideoFilePath()); @@ -395,26 +381,27 @@ namespace Vocaluxe.Base } } - public static void ToggleVideoToBackground() + public static void EnableVideo() { - if (VideoToBackgroundIsEnabled()) - { - CConfig.VideosToBackground = EOffOn.TR_CONFIG_OFF; - if (!_SmallVideoIsEnabled) //No videos are enabled so we should call ToggleVideo() to close - ToggleVideo(); - } - else - { - CConfig.VideosToBackground = EOffOn.TR_CONFIG_ON; - ApplyBackgroundVideo(); - } - CConfig.SaveConfig(); + if (!_VideoEnabled) + ToggleVideo(); } - public static void ApplyBackgroundVideo() + public static void Disable() { - if (!_VideoEnabled && (!_SmallVideoIsEnabled || !VideoToBackgroundIsEnabled()) || (!_SmallVideoIsEnabled && !VideoToBackgroundIsEnabled())) //No videos are enabled so we should call ToggleVideo() to close - ToggleVideo(); + Pause(); + _Disabled = true; + } + + public static void Enable() + { + Play(); + _Disabled = false; + } + + public static bool IsEnabled() + { + return !_Disabled; } } } diff --git a/Vocaluxe/Menu/CBackground.cs b/Vocaluxe/Menu/CBackground.cs index 1a21156b..f04c1813 100644 --- a/Vocaluxe/Menu/CBackground.cs +++ b/Vocaluxe/Menu/CBackground.cs @@ -137,7 +137,7 @@ namespace Vocaluxe.Menu public bool Draw() { bool ok = false; - if (_Theme.Type == EBackgroundTypes.Video && CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON && CBackgroundMusic.VideoToBackgroundIsEnabled() && CBackgroundMusic.IsPlaying() && CBackgroundMusic.HasVideo() && CBackgroundMusic.IsVideoEnabled()) + if (_Theme.Type == EBackgroundTypes.Video && CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON && CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON && CBackgroundMusic.IsPlaying() && CBackgroundMusic.HasVideo() && CBackgroundMusic.IsVideoEnabled() && CBackgroundMusic.IsEnabled()) { Pause(); ok = DrawBackgroundMusicVideo(); diff --git a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs index 51217b96..fa40ad60 100644 --- a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs +++ b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs @@ -30,6 +30,30 @@ namespace Vocaluxe.Screens private const string TextCurrentSong = "TextCurrentSong"; + private bool _VideoPreview = false; + private bool _VideoBackground + { + get + { + return CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON; + } + set + { + if (CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON) + { + CConfig.VideosToBackground = EOffOn.TR_CONFIG_OFF; + if (!_VideoPreview) //No videos are enabled so we should call ToggleVideo() to close + CBackgroundMusic.ToggleVideo(); + } + else + { + CConfig.VideosToBackground = EOffOn.TR_CONFIG_ON; + CBackgroundMusic.EnableVideo(); + } + CConfig.SaveConfig(); + } + } + public CPopupScreenPlayerControl() { Init(); @@ -92,11 +116,11 @@ namespace Vocaluxe.Screens if (Buttons[htButtons(ButtonRepeat)].Selected) CBackgroundMusic.Repeat(); if (Buttons[htButtons(ButtonShowVideo)].Selected) - CBackgroundMusic.ToggleSmallVideo(); + TogglePreviewVideo(); if (Buttons[htButtons(ButtonSing)].Selected) StartSong(CBackgroundMusic.GetSongNr(), CBackgroundMusic.IsDuet()); if (Buttons[htButtons(ButtonToBackgroundVideo)].Selected) - CBackgroundMusic.ToggleVideoToBackground(); + ToggleBackgroundVideo(); break; } } @@ -120,11 +144,11 @@ namespace Vocaluxe.Screens if (Buttons[htButtons(ButtonRepeat)].Selected) CBackgroundMusic.Repeat(); if (Buttons[htButtons(ButtonShowVideo)].Selected) - CBackgroundMusic.ToggleSmallVideo(); + TogglePreviewVideo(); if (Buttons[htButtons(ButtonSing)].Selected) StartSong(CBackgroundMusic.GetSongNr(), CBackgroundMusic.IsDuet()); if (Buttons[htButtons(ButtonToBackgroundVideo)].Selected) - CBackgroundMusic.ToggleVideoToBackground(); + ToggleBackgroundVideo(); } else if (MouseEvent.LB) { CGraphics.HidePopup(EPopupScreens.PopupPlayerControl); @@ -139,33 +163,24 @@ namespace Vocaluxe.Screens public override bool UpdateGame() { - Statics[htStatics(StaticCover)].Visible = !CBackgroundMusic.SmallVideoIsEnabled(); - Buttons[htButtons(ButtonToBackgroundVideo)].Pressed = CBackgroundMusic.VideoToBackgroundIsEnabled(); - Buttons[htButtons(ButtonShowVideo)].Pressed = CBackgroundMusic.SmallVideoIsEnabled(); + Statics[htStatics(StaticCover)].Visible = !_VideoPreview; + Buttons[htButtons(ButtonToBackgroundVideo)].Pressed = _VideoBackground; + Buttons[htButtons(ButtonShowVideo)].Pressed = _VideoPreview; return true; } public override void OnShow() { base.OnShow(); - } public override bool Draw() { if (!_Active) return false; + Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.GetCover(); if (CBackgroundMusic.IsVideoEnabled() && CBackgroundMusic.HasVideo()) - { - Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.GetCover(); - //Statics[htStatics(StaticCover)].Visible = false; CDraw.DrawTexture(Statics[htStatics(StaticCover)], CBackgroundMusic.GetVideoTexture(), EAspect.Crop); - } - else - { - //Statics[htStatics(StaticCover)].Visible = true; - Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.GetCover(); - } Buttons[htButtons(ButtonPause)].Visible = CBackgroundMusic.IsPlaying(); Buttons[htButtons(ButtonPlay)].Visible = !CBackgroundMusic.IsPlaying(); Texts[htTexts(TextCurrentSong)].Text = CBackgroundMusic.GetSongArtistAndTitle(); @@ -191,5 +206,30 @@ namespace Vocaluxe.Screens CGraphics.FadeTo(EScreens.ScreenNames); } } + + private void ToggleBackgroundVideo() + { + if (_VideoBackground) + { + CConfig.VideosToBackground = EOffOn.TR_CONFIG_OFF; + if (!_VideoPreview) //No videos are enabled so we should call ToggleVideo() to close + CBackgroundMusic.ToggleVideo(); + } + else + { + CConfig.VideosToBackground = EOffOn.TR_CONFIG_ON; + CBackgroundMusic.EnableVideo(); + } + CConfig.SaveConfig(); + } + + private void TogglePreviewVideo() + { + _VideoPreview = !_VideoPreview; + if (!_VideoPreview && !_VideoBackground) + CBackgroundMusic.ToggleVideo(); + else + CBackgroundMusic.EnableVideo(); + } } } diff --git a/Vocaluxe/Screens/CScreenOptionsVideo.cs b/Vocaluxe/Screens/CScreenOptionsVideo.cs index 34d6dfaf..b5e6b93c 100644 --- a/Vocaluxe/Screens/CScreenOptionsVideo.cs +++ b/Vocaluxe/Screens/CScreenOptionsVideo.cs @@ -128,7 +128,7 @@ namespace Vocaluxe.Screens CConfig.VideoPreview = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideoPreview)].Selection; CConfig.VideosInSongs = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideosInSongs)].Selection; CConfig.VideosToBackground = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideosToBackground)].Selection; - CBackgroundMusic.ApplyBackgroundVideo(); + CBackgroundMusic.EnableVideo(); CConfig.SaveConfig(); } diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 48ea1105..7616d49c 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -326,7 +326,7 @@ namespace Vocaluxe.Screens } SetVisuability(); - CBackgroundMusic.Pause(); + CBackgroundMusic.Disable(); } public override void OnShowFinish() @@ -335,7 +335,7 @@ namespace Vocaluxe.Screens CGame.Start(); LoadNextSong(); - CBackgroundMusic.Pause(); + CBackgroundMusic.Disable(); } public override bool Draw() @@ -418,6 +418,7 @@ namespace Vocaluxe.Screens public override void OnClose() { base.OnClose(); + CBackgroundMusic.Enable(); CloseSong(); } diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index abc609de..54be0274 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -173,12 +173,12 @@ namespace Vocaluxe.Screens if ((CSongs.Category >= 0) && (song >= 0) && song < CSongs.VisibleSongs.Length) { Texts[htTexts(TextSelection)].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title; - CBackgroundMusic.Pause(); + CBackgroundMusic.Disable(); } else if ((CSongs.Category == -1) && (song >= 0) && song < CSongs.Categories.Length) { Texts[htTexts(TextSelection)].Text = CSongs.Categories[song].Name; - CBackgroundMusic.Play(); + CBackgroundMusic.Enable(); } else Texts[htTexts(TextSelection)].Text = String.Empty; @@ -213,6 +213,7 @@ namespace Vocaluxe.Screens public override void OnClose() { base.OnClose(); + CBackgroundMusic.Enable(); SongMenus[htSongMenus(SongMenu)].OnHide(); }