From 83b72604a9a2a5cf31d053f250bb4f0954e9b53f Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sat, 19 Oct 2013 02:02:53 +0200 Subject: [PATCH] Remove confusing ActSongId --- .../Menu/SongMenu/CSongMenuFramework.cs | 34 +++++-------------- .../Menu/SongMenu/CSongMenuTileBoard.cs | 2 +- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index 2b1971db..4f84bfae 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -122,15 +122,18 @@ namespace VocaluxeLib.Menu.SongMenu protected virtual int _PreviewId { get { return _PreviewIdInternal; } - set { _PreviewIdInternal = value; } + set + { + //Do this first, otherwhise song will restart + _PlaySong(value); + _PreviewIdInternal = value; + } } protected int _PreviewSongStream { get; private set; } protected int _PreviewVideoStream { get; private set; } - protected int _ActPlayingSongId { get; private set; } - public SRectF Rect { get; protected set; } public SColorF Color @@ -172,7 +175,6 @@ namespace VocaluxeLib.Menu.SongMenu _PartyModeID = partyModeID; _PreviewVideoStream = -1; _PreviewSongStream = -1; - _ActPlayingSongId = -1; _Locked = -1; _Theme = new SThemeSongMenu { @@ -371,9 +373,6 @@ namespace VocaluxeLib.Menu.SongMenu if (!_Initialized) return; - if (_ActPlayingSongId != _PreviewId) - _PlaySong(_PreviewId); - if (_Streams.Count <= 0 || _PreviewVideoStream == -1) return; @@ -523,31 +522,15 @@ namespace VocaluxeLib.Menu.SongMenu CBase.Songs.SetCategory(-1); } - public void ApplyVolume() - { - CBase.Sound.SetStreamVolume(_PreviewSongStream, CBase.Config.GetPreviewMusicVolume()); - } - private void _PlaySong(int nr) { - if (CBase.Songs.IsInCategory() && (CBase.Songs.GetNumSongsVisible() > 0) && (nr >= 0) && ((_ActPlayingSongId != nr) || (_Streams.Count == 0))) + if (CBase.Songs.IsInCategory() && (_PreviewId != nr || _Streams.Count == 0)) { - _Streams.ForEach(soundStream => CBase.Sound.FadeAndStop(soundStream, 0f, 1f)); - _Streams.Clear(); - - CBase.Video.Close(_PreviewVideoStream); - _PreviewVideoStream = -1; - - CBase.Drawing.RemoveTexture(ref _Vidtex); + _Reset(); CSong song = CBase.Songs.GetVisibleSong(nr); if (song == null) - { - _ActPlayingSongId = -1; return; - } - - _ActPlayingSongId = nr; int stream = CBase.Sound.Load(Path.Combine(song.Folder, song.MP3FileName), true); CBase.Sound.SetStreamVolumeMax(stream, _MaxVolume); @@ -563,6 +546,7 @@ namespace VocaluxeLib.Menu.SongMenu CBase.Sound.SetPosition(stream, startposition); CBase.Sound.Play(stream); + CBase.Sound.SetStreamVolumeMax(stream, CBase.Config.GetPreviewMusicVolume()); CBase.Sound.Fade(stream, 100f, 3f); _Streams.Add(stream); _PreviewSongStream = stream; diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index fd70a47b..eac8be4c 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -208,7 +208,7 @@ namespace VocaluxeLib.Menu.SongMenu _PreviewId = -1; _UpdateList(0, true); //AfterCategoryChange(); - SetSelectedSong(_ActPlayingSongId); + SetSelectedSong(_PreviewId); _AfterCategoryChange(); if (_PreviewId < 0)